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 · Stone Collapse

GameStatetype

The immutable authoritative native game state, including its board, random state and recording.

Import it

import type { GameState } from "@johnmorrisdotca/houseki/stone-collapse";

Definition

interface GameState {
    readonly game: 'stone-collapse';
    readonly rules: 'collapse-2';
    readonly settings: Settings;
    readonly challenge: ChallengeDefinition | null;
    readonly initialBoard: readonly (Stone | null)[];
    readonly board: readonly (Stone | null)[];
    readonly phase: GamePhase;
    readonly selectedId: number | null;
    readonly selectedIds: readonly number[];
    readonly previewScore: number;
    readonly score: number;
    readonly moves: number;
    readonly removed: number;
    readonly randomState: number;
    readonly nextId: number;
    readonly usedFallback: boolean;
    readonly resolutionTick: number;
    readonly pendingIds: readonly number[];
    readonly gravityBoard: readonly (Stone | null)[] | null;
    readonly finishAdjustmentApplied: boolean;
    readonly assisted: boolean;
    readonly history: readonly UndoFrame[];
    readonly witnessIndex: number;
    readonly elapsedTicks: number;
    readonly reason?: string;
    readonly recording: readonly RecordedAction[];
    readonly inventory: ToolInventory;
    readonly toolProgress: number;
    readonly toolAwardCursor: 0 | 1;
    readonly selectedTool: StoredTool | null;
    readonly toolTarget: number | null;
    readonly toolPreview: readonly number[];
}

Members

NameTypeDescription
game"stone-collapse"
rules"collapse-2"
settingsSettings
challengeChallengeDefinition | null
initialBoardreadonly (Stone | null)[]
boardreadonly (Stone | null)[]

Row-major; masked and currently empty cells contain null.

phaseGamePhase
selectedIdnumber | null
selectedIdsreadonly number[]
previewScorenumber
scorenumber
movesnumber
removednumber
randomStatenumber
nextIdnumber
usedFallbackboolean
resolutionTicknumber
pendingIdsreadonly number[]
gravityBoardreadonly (Stone | null)[] | null

Settled destination board held during the gravity animation.

finishAdjustmentAppliedboolean
assistedboolean
historyreadonly UndoFrame[]
witnessIndexnumber

-1 means the player's current board has left the supplied witness path.

elapsedTicksnumber
reason (optional)string | undefined
recordingreadonly RecordedAction[]
inventoryToolInventory
toolProgressnumber

Ordinary removed stones carried toward the next tool award; always 0–11.

toolAwardCursor0 | 1

0 awards Bomb next; 1 awards Pick next.

selectedToolStoredTool | null
toolTargetnumber | null
toolPreviewreadonly number[]

Exact row-major cells affected by the current target.

Examples

import { createGame } from "@johnmorrisdotca/houseki/stone-collapse";
import type { GameState } from "@johnmorrisdotca/houseki/stone-collapse";

const state=createGame({seed:"docs"});
const value: GameState = state;
console.log(value == null ? value : typeof value === "object" ? Object.keys(value).slice(0,6) : value);
[ 'game', 'rules', 'settings', 'challenge', 'initialBoard', 'board' ]

What it prints (run when this page was built)

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