Skip to content

Commit

Permalink
fix: open err
Browse files Browse the repository at this point in the history
  • Loading branch information
noyyyy committed Oct 11, 2024
1 parent fa89426 commit adbaf39
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/client/src/phaser/systems/initialize.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getComponentValueStrict, setComponent } from "@dojoengine/recs";
import { getComponentValue, setComponent } from "@dojoengine/recs";
import { PhaserLayer } from "..";
import { zeroEntity } from "../../utils";
import { logDebug } from "../../ui/lib/utils";
Expand All @@ -14,7 +14,7 @@ export const initialize = (layer: PhaserLayer) => {
},
} = layer;

const playerV = getComponentValueStrict(Player, playerEntity);
const playerV = getComponentValue(Player, playerEntity);

logDebug("init player value:", playerV);

Expand All @@ -23,7 +23,7 @@ export const initialize = (layer: PhaserLayer) => {
shouldPlay: false,
status: GameStatusEnum.Prepare,
currentRound: 1,
currentMatch: playerV.inMatch,
currentMatch: playerV?.inMatch || 0,
dangerous: false,
homePlayer: BigInt(address),
awayPlayer: 1n,
Expand Down
24 changes: 23 additions & 1 deletion packages/client/src/phaser/systems/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,34 @@ export const prepare = (layer: PhaserLayer) => {
},
account: { address },
account,
playerEntity,
},
} = layer;

const { spawnPiece } = pieceManage(layer);

// listen match update
defineSystemST<typeof Player.schema>(
world,
[Has(Player)],
({ entity, type, value: [v, preV] }) => {
if (!v) {
return;
}

if (v.player !== BigInt(address)) {
return;
}

const s = getComponentValueStrict(GameStatus, zeroEntity);

if (v.inMatch > s.currentMatch) {
updateComponent(GameStatus, zeroEntity, {
currentMatch: v.inMatch,
});
}
}
);

// listen whether the match is end
defineSystemST<typeof MatchResult.schema>(
world,
Expand Down

0 comments on commit adbaf39

Please sign in to comment.