Skip to the content

Houseki宝石

Run five native gem and stone engines, play measured challenges and lessons, and save deterministic games.

Houseki (宝石) is Japanese for a gem or precious stone. About the name

Contents

Reference · Gem Swap

applyActionfunction

Applies one recorded player action. Rejected actions preserve state identity and are not recorded.

Import it

import { applyAction } from "@johnmorrisdotca/houseki/gem-swap";

Definition

function applyAction(state: GameState, action: Action): Transition

Parameters

NameTypeDescription
stateGameState

The immutable native state to read or transition; the input is retained.

actionAction

One native action for this entry point; inspect accepted and reason on the result.

Returns

Transition

Applies one recorded player action. Rejected actions preserve state identity and are not recorded.

Examples

import { applyAction, createGame } from "@johnmorrisdotca/houseki/gem-swap";
import type { Action } from "@johnmorrisdotca/houseki/gem-swap";

const state=createGame({seed:"docs"});
const action: Action={kind:"hint"};
console.log(applyAction(state,action).accepted);
true

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/houseki 0.4.2.