Reference
Magnetic Blocks
import { … } from "@johnmorrisdotca/houseki/magnetic-blocks";
28.2 kB minified and gzipped, with everything it imports (measured with esbuild)
Exports
| Name | Kind | What it is |
|---|---|---|
Action | type | A native player action accepted or rejected according to the current phase and rules. |
advanceTicks | function | Advances fixed 60 Hz time, resolving phases in all modes and falling/locking only in Arcade. |
applyAction | function | Applies one movement, rotation, floor-switch or placement action without mutation. |
Block | type | The native active 2×2 block, orientation and fixed-tick descent/lock counters. |
blockBonds | function | List the native stable-id bonds connecting adjacent gems in the active block. |
blockCells | function | Returns stable-gem addresses after rotating the square block around its centre. |
Bond | type | An undirected stable-id connection between two gems in a magnetic block. |
calmGravity | function | Settles bonded connected components one cell per deterministic bottom/ID priority step. |
campaignManifest | constant | The frozen native campaign manifest with its ordering, revisions, checksum and measured levels. |
canPlace | function | Test whether the whole native block fits passable empty board cells. |
Colour | type | A standard gem colour used by a magnetic block. |
createGame | function | Creates an immutable seeded 2×2-block game with a fixed queue and explicit floor schedule. |
createLesson | function | Creates a fresh lesson game with its authored setup and queue. |
createLevel | function | Creates a fresh game with the authored rules, board, queue, and finite move budget. |
CreateOptions | type | Creation settings for this native engine; dimensions, mode, seed and optional mechanics are validated together. |
decodeGame | function | Replays bounded canonical input and verifies every saved checkpoint field. |
encodeGame | function | Encodes canonical settings, accepted tick-stamped actions and a verified replay checkpoint. |
Floor | type | The native calm or magnetic floor used when settling blocks. |
FloorSchedule | type | A fixed, periodic or authored schedule selecting the floor for committed block placements. |
GameEvent | type | An event emitted by one native transition; type selects the event’s additional fields. |
GameState | type | The immutable authoritative native game state, including its board, random state and recording. |
GameStatus | type | A compact native status derived from the authoritative state for a host’s labels. |
Gem | type | A native gem with a stable run-local id and colour. |
getLesson | function | Finds one of the three bilingual rules lessons by stable ID. |
getLevel | function | Finds a Magnetic Blocks campaign level by stable ID or one-based display number. |
getTutorial | function | Find a magnetic-block lesson by stable id; returns undefined when no lesson has that id. |
Goal | type | The native authored goal; its discriminant selects the required collection or clearing condition. |
GRAVITY_TICKS | constant | Fixed 60 Hz ticks in the magnetic-block gravity phase. |
impactSupportIds | function | Collects the occupied one-cell support layer under both block columns at first contact. |
landingY | function | Find the last legal block row before downward collision. |
legalActions | function | Lists accepted controls for the current falling or resolution phase. |
lessonManifest | constant | The frozen native bilingual lessons and their authored teaching steps. |
levelManifest | constant | The frozen ordered native levels; array indices start at zero and display numbers start at one. |
LocalizedText | type | One authored text in English and Japanese. |
MagneticBlocksOptionsError | class | A typed native magnetic-block setup validation error. |
MagneticCampaignLevel | type | One authored native challenge with its stable id, setup, winning witness, measurements and review status. |
MagneticCampaignManifest | type | The ordered native campaign, its generation/grading revisions, checksum and measured levels. |
MagneticDifficultyMetrics | type | The bounded engine measurements used to grade this campaign; they do not claim human difficulty. |
magneticGravity | function | Magnetic floor removes all bonds and settles each column segment independently. |
MagneticLesson | type | One bilingual native lesson with its authored setup, teaching steps and winning witness. |
MARK_TICKS | constant | The fixed 60 Hz ticks showing the magnetic-block match mark phase. |
matchGroups | function | Computes deterministic orthogonal colour components of at least four gems. |
Mode | type | The native game mode; authored challenges have fixed setup and queue rules. |
Phase | type | The native falling, resolution, pause and ending phases. |
RecordedAction | type | A native action recording with the logical position needed for deterministic replay. |
REMOVE_TICKS | constant | Fixed 60 Hz ticks in the magnetic-block removal phase. |
removeIds | function | Remove the selected native cell indices and discard bonds whose endpoint gems were removed. |
restartGame | function | Restarts the same seed, custom starting board, fixed queue, rules and floor options. |
Settings | type | Validated settings fixed at native game creation. |
settle | function | Settle surviving gems with the chosen floor rule and retain valid stable-id bonds. |
statusOf | function | Returns a compact immutable status including current and upcoming floor state. |
Transition | type | The resulting native state, emitted events and acceptance decision; rejected actions preserve the input. |
tutorialManifest | constant | Alias kept alongside other Houseki campaign lesson APIs. |