fix: api changes fix
This commit is contained in:
@@ -2,7 +2,6 @@ import Phaser from 'phaser';
|
||||
import type {TicTacToeState, TicTacToePart} from '@/game/tic-tac-toe';
|
||||
import { GameHostScene } from 'boardgame-phaser';
|
||||
import { spawnEffect, type Spawner } from 'boardgame-phaser';
|
||||
import type { ReadonlySignal } from '@preact/signals-core';
|
||||
import {commands} from "@/game/tic-tac-toe";
|
||||
|
||||
const CELL_SIZE = 120;
|
||||
@@ -26,9 +25,9 @@ export class GameScene extends GameHostScene<TicTacToeState> {
|
||||
this.gridGraphics = this.add.graphics();
|
||||
this.drawGrid();
|
||||
|
||||
this.disposables.add(spawnEffect(new TicTacToePartSpawner(this, this.gameHost.state)));
|
||||
this.disposables.add(spawnEffect(new TicTacToePartSpawner(this)));
|
||||
|
||||
this.watch(() => {
|
||||
this.addEffect(() => {
|
||||
const winner = this.state.winner;
|
||||
if (winner) {
|
||||
this.showWinner(winner);
|
||||
@@ -38,7 +37,7 @@ export class GameScene extends GameHostScene<TicTacToeState> {
|
||||
}
|
||||
});
|
||||
|
||||
this.watch(() => {
|
||||
this.addEffect(() => {
|
||||
const currentPlayer = this.state.currentPlayer;
|
||||
this.updateTurnText(currentPlayer);
|
||||
});
|
||||
@@ -163,10 +162,10 @@ export class GameScene extends GameHostScene<TicTacToeState> {
|
||||
}
|
||||
|
||||
class TicTacToePartSpawner implements Spawner<TicTacToePart, Phaser.GameObjects.Text> {
|
||||
constructor(public readonly scene: GameScene, public readonly state: ReadonlySignal<TicTacToeState>) {}
|
||||
constructor(public readonly scene: GameScene) {}
|
||||
|
||||
*getData() {
|
||||
for (const part of Object.values(this.state.value.parts)) {
|
||||
for (const part of Object.values(this.scene.state.parts)) {
|
||||
yield part;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user