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) {
|
async function setup(game: BoopGame) {
|
||||||
while (true) {
|
while (true) {
|
||||||
const currentPlayer = game.value.currentPlayer;
|
const currentPlayer = game.value.currentPlayer;
|
||||||
const turnOutput = await turnCommand(game, currentPlayer);
|
const { winner } = await turnCommand(game, currentPlayer);
|
||||||
if (!turnOutput.success) throw new Error(turnOutput.error);
|
|
||||||
|
|
||||||
await game.produceAsync((state: BoopState) => {
|
await game.produceAsync((state: BoopState) => {
|
||||||
state.winner = turnOutput.result.winner;
|
state.winner = winner;
|
||||||
if (!state.winner) {
|
if (!state.winner) {
|
||||||
state.currentPlayer = state.currentPlayer === 'white' ? 'black' : 'white';
|
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 placeCommand(game, row, col, turnPlayer, pieceType);
|
||||||
await boopCommand(game, row, col, pieceType);
|
await boopCommand(game, row, col, pieceType);
|
||||||
const winner = await checkWinCommand(game);
|
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 checkGraduatesCommand(game);
|
||||||
await checkFullBoard(game, turnPlayer);
|
await checkFullBoard(game, turnPlayer);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ class BoopPartSpawner implements Spawner<BoopPart, Phaser.GameObjects.Container>
|
||||||
|
|
||||||
*getData() {
|
*getData() {
|
||||||
for (const part of Object.values(this.scene.state.pieces)) {
|
for (const part of Object.values(this.scene.state.pieces)) {
|
||||||
yield part;
|
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 scene = useComputed(() => new props.gameScene());
|
||||||
|
|
||||||
const handleReset = async () => {
|
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');
|
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 scene = useComputed(() => new props.gameScene());
|
||||||
|
|
||||||
const handleReset = async () => {
|
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');
|
const label = useComputed(() => gameHost.value.gameHost.status.value === 'running' ? 'Restart' : 'Start');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue