fix: fix entrance rig and details
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import Phaser from 'phaser';
|
||||
import type { TicTacToeState, TicTacToePart } from '@/game/tic-tac-toe';
|
||||
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';
|
||||
|
||||
@@ -33,6 +34,7 @@ export class GameScene extends ReactiveScene<TicTacToeState> {
|
||||
}
|
||||
|
||||
create(): void {
|
||||
super.create();
|
||||
this.boardContainer = this.add.container(0, 0);
|
||||
this.gridGraphics = this.add.graphics();
|
||||
this.drawGrid();
|
||||
@@ -49,18 +51,18 @@ export class GameScene extends ReactiveScene<TicTacToeState> {
|
||||
this.updateTurnText(currentPlayer);
|
||||
});
|
||||
|
||||
this.setupBindings();
|
||||
this.setupInput();
|
||||
}
|
||||
|
||||
protected setupBindings(): void {
|
||||
bindRegion<TicTacToePart>(
|
||||
bindRegion<TicTacToeState, { player: PlayerType }>(
|
||||
this.state,
|
||||
(state) => state.parts,
|
||||
this.state.value.board,
|
||||
this.state.value.parts,
|
||||
{
|
||||
cellSize: { x: CELL_SIZE, y: CELL_SIZE },
|
||||
offset: BOARD_OFFSET,
|
||||
factory: (part: TicTacToePart, pos: Phaser.Math.Vector2) => {
|
||||
factory: (part, pos: Phaser.Math.Vector2) => {
|
||||
const text = this.add.text(pos.x + CELL_SIZE / 2, pos.y + CELL_SIZE / 2, part.player, {
|
||||
fontSize: '64px',
|
||||
fontFamily: 'Arial',
|
||||
@@ -85,8 +87,7 @@ export class GameScene extends ReactiveScene<TicTacToeState> {
|
||||
if (this.state.value.winner) return null;
|
||||
|
||||
const currentPlayer = this.state.value.currentPlayer;
|
||||
const board = this.state.value.board;
|
||||
if (board.partMap[`${row},${col}`]) return null;
|
||||
if (isCellOccupied(this.state.value.parts, 'board', [row, col])) return null;
|
||||
|
||||
return `play ${currentPlayer} ${row} ${col}`;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user