fix: api changes fix

This commit is contained in:
2026-04-04 23:14:30 +08:00
parent c85fdb604c
commit 61857b8256
3 changed files with 25 additions and 15 deletions
+5 -6
View File
@@ -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;
}
}