diff --git a/src/core/game.ts b/src/core/game.ts index 5d07ef5..c8a9945 100644 --- a/src/core/game.ts +++ b/src/core/game.ts @@ -58,7 +58,6 @@ export function createGameContextFromModule = {} >(): CommandRegistry> { return createCommandRegistry>(); } - export function createGameCommand = {} , TResult = unknown>( schema: CommandSchema | string, diff --git a/src/core/part.ts b/src/core/part.ts index 5638577..16a5de5 100644 --- a/src/core/part.ts +++ b/src/core/part.ts @@ -4,9 +4,11 @@ import {RNG} from "../utils/rng"; export type Part = { id: string; - sides: number; + + sides?: number; + side?: number; + alignments?: string[]; - side: number; alignment?: string; region: Entity; position: number[]; @@ -14,18 +16,21 @@ export type Part = { export function flip(part: Entity) { part.produce(draft => { - draft.side = (draft.side + 1) % draft.sides; + if(!draft.sides)return; + draft.side = ((draft.side||0) + 1) % draft.sides; }); } export function flipTo(part: Entity, side: number) { part.produce(draft => { + if(!draft.sides || side >= draft.sides)return; draft.side = side; }); } export function roll(part: Entity, rng: RNG) { part.produce(draft => { + if(!draft.sides)return; draft.side = rng.nextInt(draft.sides); }); } diff --git a/src/samples/tic-tac-toe.ts b/src/samples/tic-tac-toe.ts index 54f13e8..20174d0 100644 --- a/src/samples/tic-tac-toe.ts +++ b/src/samples/tic-tac-toe.ts @@ -63,8 +63,6 @@ export function placePiece(host: IGameContext, row: number, col: const board = getBoardRegion(host); const piece: Part = { id: `piece-${moveCount}`, - sides: 1, - side: 0, region: board, position: [row, col], };