Skip to content

Commit

Permalink
wip: change next
Browse files Browse the repository at this point in the history
  • Loading branch information
wighawag committed Sep 11, 2023
1 parent 3d01037 commit bacccf8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 3 additions & 1 deletion web/src/lib/components/info/Epoch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
</script>

Expand Down
11 changes: 11 additions & 0 deletions web/src/lib/render/PIXIState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 6 additions & 3 deletions web/src/lib/state/ViewState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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) {
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit bacccf8

Please sign in to comment.