fix: api change
This commit is contained in:
parent
de4e83e4ea
commit
449727d650
|
|
@ -151,11 +151,10 @@ const checkGraduatesCommand = registry.register('check-graduates', checkGraduate
|
|||
async function setup(game: BoopGame) {
|
||||
while (true) {
|
||||
const currentPlayer = game.value.currentPlayer;
|
||||
const turnOutput = await turnCommand(game, currentPlayer);
|
||||
if (!turnOutput.success) throw new Error(turnOutput.error);
|
||||
const { winner } = await turnCommand(game, currentPlayer);
|
||||
|
||||
await game.produceAsync((state: BoopState) => {
|
||||
state.winner = turnOutput.result.winner;
|
||||
state.winner = winner;
|
||||
if (!state.winner) {
|
||||
state.currentPlayer = state.currentPlayer === 'white' ? 'black' : 'white';
|
||||
}
|
||||
|
|
@ -234,7 +233,7 @@ async function turn(game: BoopGame, turnPlayer: PlayerType) {
|
|||
await placeCommand(game, row, col, turnPlayer, pieceType);
|
||||
await boopCommand(game, row, col, pieceType);
|
||||
const winner = await checkWinCommand(game);
|
||||
if(winner.success) return { winner: winner.result as WinnerType };
|
||||
if(winner) return { winner: winner as WinnerType };
|
||||
|
||||
await checkGraduatesCommand(game);
|
||||
await checkFullBoard(game, turnPlayer);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ class BoopPartSpawner implements Spawner<BoopPart, Phaser.GameObjects.Container>
|
|||
|
||||
*getData() {
|
||||
for (const part of Object.values(this.scene.state.pieces)) {
|
||||
if(part.regionId === 'board')
|
||||
yield part;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,13 @@ export default function App<TState extends Record<string, unknown>>(props: { gam
|
|||
const scene = useComputed(() => new props.gameScene());
|
||||
|
||||
const handleReset = async () => {
|
||||
gameHost.value.gameHost.setup('setup');
|
||||
gameHost.value.gameHost.setup('setup').then(result => {
|
||||
if(!result.success) {
|
||||
console.error(result.error);
|
||||
}else{
|
||||
console.log('Game finished!', result.result);
|
||||
}
|
||||
});
|
||||
};
|
||||
const label = useComputed(() => gameHost.value.gameHost.status.value === 'running' ? 'Restart' : 'Start');
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,13 @@ export default function App<TState extends Record<string, unknown>>(props: { gam
|
|||
const scene = useComputed(() => new props.gameScene());
|
||||
|
||||
const handleReset = async () => {
|
||||
gameHost.value.gameHost.setup('setup');
|
||||
gameHost.value.gameHost.setup('setup').then(result => {
|
||||
if(!result.success) {
|
||||
console.error(result.error);
|
||||
}else{
|
||||
console.log('Game finished!', result.result);
|
||||
}
|
||||
});
|
||||
};
|
||||
const label = useComputed(() => gameHost.value.gameHost.status.value === 'running' ? 'Restart' : 'Start');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue