fix: update according to boardgame-core

This commit is contained in:
2026-04-03 19:13:12 +08:00
parent cbee709a27
commit 5d4c169fea
7 changed files with 83 additions and 51 deletions
+4 -17
View File
@@ -2,17 +2,12 @@ import Phaser from 'phaser';
import type { TicTacToeState, TicTacToePart, PlayerType } from '@/game/tic-tac-toe';
import { isCellOccupied } from 'boardgame-core';
import { ReactiveScene, bindRegion, createInputMapper, createPromptHandler } from 'boardgame-phaser';
import type { PromptEvent, MutableSignal, IGameContext } from 'boardgame-core';
import type { PromptEvent } from 'boardgame-core';
const CELL_SIZE = 120;
const BOARD_OFFSET = { x: 100, y: 100 };
const BOARD_SIZE = 3;
export interface GameSceneData {
state: MutableSignal<TicTacToeState>;
commands: IGameContext<TicTacToeState>['commands'];
}
export class GameScene extends ReactiveScene<TicTacToeState> {
private boardContainer!: Phaser.GameObjects.Container;
private gridGraphics!: Phaser.GameObjects.Graphics;
@@ -25,11 +20,6 @@ export class GameScene extends ReactiveScene<TicTacToeState> {
super('GameScene');
}
init(data: GameSceneData): void {
this.state = data.state;
this.commands = data.commands;
}
protected onStateReady(_state: TicTacToeState): void {
}
@@ -71,6 +61,9 @@ export class GameScene extends ReactiveScene<TicTacToeState> {
return text;
},
update: (part, obj) => {
// 可以在这里更新部件的视觉状态
},
},
this.boardContainer,
);
@@ -97,12 +90,6 @@ export class GameScene extends ReactiveScene<TicTacToeState> {
onPrompt: (prompt) => {
this.activePrompt = prompt;
},
onSubmit: (input) => {
if (this.activePrompt) {
return this.activePrompt.tryCommit(input);
}
return null;
},
onCancel: () => {
this.activePrompt = null;
},