refactor: state signal

This commit is contained in:
2026-04-02 12:53:49 +08:00
parent 004d49c36f
commit 74f56b9da4
2 changed files with 10 additions and 8 deletions
+3 -3
View File
@@ -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];