Transitiontype
The resulting native state, emitted events and acceptance decision; rejected actions preserve the input.
Import it
import type { Transition } from "@johnmorrisdotca/houseki/magnetic-blocks";
Definition
interface Transition {
readonly state: GameState;
readonly events: readonly GameEvent[];
readonly accepted: boolean;
readonly reason?: string;
}
Members
| Name | Type | Description |
|---|---|---|
state | GameState | |
events | readonly GameEvent[] | |
accepted | boolean | |
reason (optional) | string | undefined |
Examples
import { applyAction, createGame } from "@johnmorrisdotca/houseki/magnetic-blocks";
import type { Action, Transition } from "@johnmorrisdotca/houseki/magnetic-blocks";
const state=createGame({seed:"docs"});
const action: Action={kind:"left"};
const value: Transition = applyAction(state,action);
console.log(value == null ? value : typeof value === "object" ? Object.keys(value).slice(0,6) : value);[ 'state', 'events', 'accepted' ]What it prints (run when this page was built)