refactor: state signal
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { IGameContext, createGameCommand } from '../core/game';
|
||||
import { createCommandRegistry, type CommandRegistry, registerCommand } from '../utils/command';
|
||||
import { createCommandRegistry, registerCommand } from '../utils/command';
|
||||
import type { Part } from '../core/part';
|
||||
|
||||
export type TicTacToeState = {
|
||||
@@ -77,7 +77,7 @@ export function placePiece(host: TicTacToeContext, row: number, col: number, mov
|
||||
board.value.children.push(host.parts.get(piece.id));
|
||||
}
|
||||
|
||||
const setup = createGameCommand<TicTacToeContext, { winner: 'X' | 'O' | 'draw' | null }>(
|
||||
const setup = createGameCommand<TicTacToeState, { winner: 'X' | 'O' | 'draw' | null }>(
|
||||
'setup',
|
||||
async function() {
|
||||
this.context.regions.add({
|
||||
@@ -106,7 +106,7 @@ const setup = createGameCommand<TicTacToeContext, { winner: 'X' | 'O' | 'draw' |
|
||||
}
|
||||
)
|
||||
|
||||
const turn = createGameCommand<TicTacToeContext, TurnResult>(
|
||||
const turn = createGameCommand<TicTacToeState, TurnResult>(
|
||||
'turn <player> <turn:number>',
|
||||
async function(cmd) {
|
||||
const [turnPlayer, turnNumber] = cmd.params as [string, number];
|
||||
|
||||
Reference in New Issue
Block a user