From bacccf8ed36eab8f561642b461692245e58e5348 Mon Sep 17 00:00:00 2001 From: wighawag Date: Mon, 11 Sep 2023 23:01:37 +0000 Subject: [PATCH] wip: change next --- web/src/lib/components/info/Epoch.svelte | 4 +++- web/src/lib/render/PIXIState.ts | 11 +++++++++++ web/src/lib/state/ViewState.ts | 9 ++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/web/src/lib/components/info/Epoch.svelte b/web/src/lib/components/info/Epoch.svelte index c06a0690..3087bcf2 100644 --- a/web/src/lib/components/info/Epoch.svelte +++ b/web/src/lib/components/info/Epoch.svelte @@ -10,7 +10,9 @@ $: isAdmin = $account.address?.toLowerCase() === $contractsInfos.contracts.Stratagems.linkedData.admin?.toLowerCase(); async function nextPhase() { - await increaseContractTime($epochInfo.isActionPhase ? $epochInfo.timeLeftToCommit : $epochInfo.timeLeftToReveal); + const timeToSkip = $epochInfo.isActionPhase ? $epochInfo.timeLeftToCommit : $epochInfo.timeLeftToReveal; + console.log({timeToSkip: timeToText(timeToSkip)}); + await increaseContractTime(timeToSkip); } diff --git a/web/src/lib/render/PIXIState.ts b/web/src/lib/render/PIXIState.ts index f3f12234..baf1432c 100644 --- a/web/src/lib/render/PIXIState.ts +++ b/web/src/lib/render/PIXIState.ts @@ -48,6 +48,16 @@ export class PIXIState { sprite.y = 0.08; sprite.width = sprite.height = 0.84; + // if (cell.contract) { + // for (let i = 0; i < cell.contract.life; i++) { + // const child = sprite.addChild(new Sprite(Texture.WHITE)); + // const offset = 0.2 * Texture.WHITE.width; + // const margin = 0.3 * Texture.WHITE.width; + // child.tint = 0x000000; + // child.width = child.height = Texture.WHITE.width / 5; + // child.position.set(offset + margin * (i % 3), offset + margin * Math.floor(i / 3)); + // } + // } else { for (let i = 0; i < cell.next.life; i++) { const child = sprite.addChild(new Sprite(Texture.WHITE)); const offset = 0.2 * Texture.WHITE.width; @@ -75,6 +85,7 @@ export class PIXIState { child.position.set(offset + margin * (i % 3), offset + margin * Math.floor(i / 3)); } } + // } elem.last = { nextLife: cell.next.life, diff --git a/web/src/lib/state/ViewState.ts b/web/src/lib/state/ViewState.ts index 97c5c80c..6e50bbae 100644 --- a/web/src/lib/state/ViewState.ts +++ b/web/src/lib/state/ViewState.ts @@ -18,7 +18,7 @@ export type ViewCell = ContractCell & { localState?: 'pending' | 'planned'; }; -export type ViewCellData = {next: ViewCell; future: ViewCell; currentPlayer: boolean}; +export type ViewCellData = {next: ViewCell; future: ViewCell; contract?: ContractCell; currentPlayer: boolean}; export type ViewData = { cells: { @@ -39,6 +39,8 @@ function merge( const copyState = copy(state); const stratagems = new StratagemsContract(copyState, 7); + console.log({epoch: epochState.epoch, isActionPhase: epochState.isActionPhase}); + let hasCommitment = false; if (offchainState.moves !== undefined) { for (const move of offchainState.moves) { @@ -70,8 +72,8 @@ function merge( for (const cellID of Object.keys(copyState.cells)) { const {x, y} = bigIntIDToXY(BigInt(cellID)); const cell = copyState.cells[cellID]; - const next = stratagems.getUpdatedCell(BigInt(cellID), epochState.epoch + 1); - const future = stratagems.getUpdatedCell(BigInt(cellID), epochState.epoch + 2); + const next = stratagems.getUpdatedCell(BigInt(cellID), epochState.epoch + 0); + const future = stratagems.getUpdatedCell(BigInt(cellID), epochState.epoch + 1); // console.log({ // x, // y, @@ -82,6 +84,7 @@ function merge( const viewCell = { next, future, + contract: state.cells[cellID], currentPlayer: copyState.owners[cellID].toLowerCase() === account.address?.toLowerCase(), }; viewState.cells[xyToXYID(x, y)] = viewCell;