diff --git a/common/src/draft.ts b/common/src/draft.ts new file mode 100644 index 00000000..48dc7d50 --- /dev/null +++ b/common/src/draft.ts @@ -0,0 +1,54 @@ +// computeDelta(position: bigint, newColor: Color): {newDelta: number; newEnemymask: number} { +// const {x, y} = bigIntIDToXY(position); +// const data = { +// newDelta: 0, +// newEnemymask: 0, +// }; + +// { +// const upPosition = xyToBigIntID(x, y - 1); +// const color = this.getCellInMemory(upPosition).color; +// if (color != Color.None) { +// const enemyOrFriend = color == newColor ? 1 : -1; +// if (enemyOrFriend < 0) { +// data.newEnemymask = data.newEnemymask | 1; +// } +// data.newDelta += enemyOrFriend; +// } +// } +// { +// const leftPosition = xyToBigIntID(x - 1, y); +// const color = this.getCellInMemory(leftPosition).color; +// if (color != Color.None) { +// const enemyOrFriend = color == newColor ? 1 : -1; +// if (enemyOrFriend < 0) { +// data.newEnemymask = data.newEnemymask | 1; +// } +// data.newDelta += enemyOrFriend; +// } +// } + +// { +// const downPosition = xyToBigIntID(x, y + 1); +// const color = this.getCellInMemory(downPosition).color; +// if (color != Color.None) { +// const enemyOrFriend = color == newColor ? 1 : -1; +// if (enemyOrFriend < 0) { +// data.newEnemymask = data.newEnemymask | 1; +// } +// data.newDelta += enemyOrFriend; +// } +// } +// { +// const rightPosition = xyToBigIntID(x + 1, y); +// const color = this.getCellInMemory(rightPosition).color; +// if (color != Color.None) { +// const enemyOrFriend = color == newColor ? 1 : -1; +// if (enemyOrFriend < 0) { +// data.newEnemymask = data.newEnemymask | 1; +// } +// data.newDelta += enemyOrFriend; +// } +// } +// return data; +// } diff --git a/common/src/stratagems.ts b/common/src/stratagems.ts index 2ac159cf..436f713c 100644 --- a/common/src/stratagems.ts +++ b/common/src/stratagems.ts @@ -49,12 +49,12 @@ export function xyToBigIntID(x: number, y: number): bigint { export enum Color { None = 0, - Blue = 1, - Red = 2, - Green = 3, - Yellow = 4, - Purple = 5, - Evil = 6, + Blue = 1, // 5ab9bb + Red = 2, // c5836e + Green = 3, // 8bffcb + Yellow = 4, // d3d66d + Purple = 5, // a9799d + Evil = 6, // 3d3d3d } export type ContractCell = { diff --git a/contracts/src/game/debug/StratagemsDebug.sol b/contracts/src/game/debug/StratagemsDebug.sol index 6edb627a..19439ba8 100644 --- a/contracts/src/game/debug/StratagemsDebug.sol +++ b/contracts/src/game/debug/StratagemsDebug.sol @@ -79,12 +79,15 @@ contract StratagemsDebug is UsingStratagemsSetters, UsingControlledTime, IStrata // we act as if the token were added in previous epochs // this is so it does not affect the resolution phase int256 potentialLife = int256(uint256(cell.life)) - cell.delta; - if (potentialLife <= 0) { + if (potentialLife < 0) { + potentialLife = 0; + } + if (uint256(potentialLife) > MAX_LIFE) { unchecked { int256 x = int256(int32(int256(uint256(position) & 0xFFFFFFFF))); int256 y = int256(int32(int256(uint256(position) >> 32))); require( - potentialLife > 0, + uint256(potentialLife) > MAX_LIFE, string.concat('INVALID_LIFE_CONFIGURATION: ', Strings.toString(x), ',', Strings.toString(y)) ); } diff --git a/contracts/test/scenarios/example_08.txt b/contracts/test/scenarios/example_08.txt new file mode 100644 index 00000000..147eb011 --- /dev/null +++ b/contracts/test/scenarios/example_08.txt @@ -0,0 +1,56 @@ +$01: 2 +$02: 0 +$03: 0 +------------------------- +| | | | | | +| | | | | | +------------------------- +| R3 | R4 | R0 | B0 | | +| 02 | 02 | 03 | 03 | | +------------------------- +| | B0 | R0 | | | +| | 02 | 02 | | | +------------------------- +| | | | | | +| | | | | | +------------------------- +| | | | | | +| | | | | | +------------------------- ++ +------------------------- +| | | | | | +| | | | | | +------------------------- +| | |+B | | | +| | | 01 | | | +------------------------- +| | |+B | | | +| | | 01 | | | +------------------------- +| | | | | | +| | | | | | +------------------------- +| | | | | | +| | | | | | +------------------------- += +------------------------- +| | | | | | +| | | | | | +------------------------- +| R4 | R3 | B2 | B0 | | +| 02 | 02 | 01 | 03 | | +------------------------- +| | B0 | B3 | | | +| | 02 | 01 | | | +------------------------- +| | | | | | +| | | | | | +------------------------- +| | | | | | +| | | | | | +------------------------- +$01: 0 +$02: 2 +$03: 2 \ No newline at end of file diff --git a/web/src/lib/action/ActionHandler.ts b/web/src/lib/action/ActionHandler.ts index 4794dc40..ba1c67df 100644 --- a/web/src/lib/action/ActionHandler.ts +++ b/web/src/lib/action/ActionHandler.ts @@ -19,7 +19,7 @@ export class ActionHandler { const currentMove = currentOffchainState.moves?.find((v) => v.x === x && v.y === y); if (currentMove) { accountData.offchainState.removeMove(x, y); - const color = ((currentMove.color + 1) % 5) as Color; + const color = ((currentMove.color + 1) % 6) as Color; if (color > 0) { accountData.offchainState.addMove({x, y, color, player}); } diff --git a/web/src/lib/blockchain/state/Epoch.ts b/web/src/lib/blockchain/state/Epoch.ts index 36ef4a27..65e9bc8c 100644 --- a/web/src/lib/blockchain/state/Epoch.ts +++ b/web/src/lib/blockchain/state/Epoch.ts @@ -11,7 +11,7 @@ export function computeEpoch(time: number) { const RESOLUTION_PHASE_DURATION = TOTAL - ACTION_PERIOD; const START_TIME = 0; // -------------------- - + // From Solidity const epochDuration = COMMIT_PHASE_DURATION + RESOLUTION_PHASE_DURATION; // const time = _timestamp(); const timePassed = time - START_TIME; @@ -25,29 +25,6 @@ export function computeEpoch(time: number) { const timeLeftToReveal = isActionPhase ? -1 : epochDuration - timePassedFromEpochStart; const timeLeftToEpochEnd = epochDuration - timePassedFromEpochStart; return {epoch, timeLeftToEpochEnd, timeLeftToReveal, timeLeftToCommit, isActionPhase}; - - // const totalTimePassed = time; - // const epoch = Math.floor(totalTimePassed / TOTAL + 1); - // const epochStartTime = (epoch - 1) * TOTAL; - // const timePassed = time - epochStartTime; - // const isActionPhase = timePassed < ACTION_PERIOD; - // const timeLeftToCommit = ACTION_PERIOD - timePassed; - // const timeLeftToReveal = isActionPhase ? -1 : TOTAL - timePassed; - // const timeLeftToEpochEnd = TOTAL - timePassed; - // return {epoch, timeLeftToEpochEnd, timeLeftToReveal, timeLeftToCommit, isActionPhase}; - /* - uint256 epochDuration = COMMIT_PHASE_DURATION + RESOLUTION_PHASE_DURATION; - console.log(COMMIT_PHASE_DURATION); - console.log(RESOLUTION_PHASE_DURATION); - console.log(START_TIME); - console.log(epochDuration); - uint256 time = _timestamp(); - console.log(time); - require(time >= START_TIME, 'GAME_NOT_STARTED'); - uint256 timePassed = time - START_TIME; - epoch = uint32(timePassed / epochDuration + 2); // epoch start at 2, this make the hypothetical previous resolution phase's epoch to be 1 - commiting = timePassed - ((epoch - 2) * epochDuration) < COMMIT_PHASE_DURATION; - */ } export type EpochState = { diff --git a/web/src/lib/render/PIXICanvas.svelte b/web/src/lib/render/PIXICanvas.svelte index 3fde79c3..da830312 100644 --- a/web/src/lib/render/PIXICanvas.svelte +++ b/web/src/lib/render/PIXICanvas.svelte @@ -19,7 +19,7 @@ view: canvas, resolution: 1, // window.devicePixelRatio || 1, // autoDensity: true, - backgroundColor: 0x6495ed, + backgroundColor: 0x47aba9, resizeTo: window, }); (window as any).__PIXI_APP__ = app; diff --git a/web/src/lib/render/colors.ts b/web/src/lib/render/colors.ts index 4fb9c61b..dd223ab6 100644 --- a/web/src/lib/render/colors.ts +++ b/web/src/lib/render/colors.ts @@ -1,13 +1,13 @@ import {parseColorV4} from '$lib/webgl/color'; -export const COLORS = [0x000000, 0xef476f, 0xffd166, 0x06d6a0, 0x118ab2, 0x118000, 0x000000]; +export const COLORS = [0x000000, 0x00a4dd, 0xff6e71, 0x27d17c, 0xd3d66d, 0x9660c8, 0x3d3d3d]; export const COLORS_VEC4 = [ [0, 0, 0, 1], - parseColorV4('ef476f'), - parseColorV4('ffd166'), - parseColorV4('06d6a0'), - parseColorV4('118ab2'), - parseColorV4('118000'), - parseColorV4('000000'), + parseColorV4('00a4dd'), + parseColorV4('ff6e71'), + parseColorV4('27d17c'), + parseColorV4('d3d66d'), + parseColorV4('9660c8'), + parseColorV4('3d3d3d'), ];