@johnmorrisdotca/houseki 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,41 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.0
4
-
5
- - Add original Falling Triplets, Colour Chains, Stone Collapse and Gem Swap engines with immutable state, seeded play, validated settings and canonical saves.
6
- - Include 300 graded challenges and three bilingual lessons per game.
7
- - Provide family-style keyboard, keypad and touch demos, configurable boards, stored tools, goal progress and shared animation preferences.
8
- - Add optional Black Hole powers, Shizen magnetic stones and bounded rebound, and optional Arashi jumble/lightning schedules.
9
- - Include an experimental Magnetic Blocks engine with bonded squares, magnetic floor schedules, a Floor Switch and impact drops.
10
- - Publish typed entry points, a generated API reference, MIT license and reproducible package checks.
3
+ All notable changes to this package are written here, newest first, in the form of [Keep a Changelog](https://keepachangelog.com), and this package follows [Semantic Versioning](https://semver.org).
4
+
5
+ ## [Unreleased]
6
+
7
+ ### Changed
8
+
9
+ - Repository only: the package and everything it exports are unchanged. `CONTRIBUTING.md` is the family's one text with a section of its own for Houseki, held to the master in johnmorrisdotca/.github by `src/family.test.js`; `ci.yml` and `pages.yml` are the family's one text (`pnpm check`, the demo, and the package on Linux, macOS and Windows), and any jobs of the package's own after them.
10
+ - The demo's shared stylesheet is `demo/houseki.css` (it was `game.css`), named for the package like the family's.
11
+
12
+ ## [0.1.1] - 2026-10-05
13
+
14
+ ### Changed
15
+
16
+ - The package is brought to the family's standard: the same checks (`pnpm check` is lint, types and tests), tests run by Vitest, a CI workflow on Node 22 and 24, a release workflow that publishes by trusted publishing, and a Pages workflow, all on current action versions; `pnpm test:package` packs, installs and imports every entry point.
17
+ - `package.json` is made like the family's: a description short enough for npm, homepage, author, `module` and `sideEffects`.
18
+ - The README follows the family's order and lists all twenty-four packages of the family, made from the shared template.
19
+ - The demo's four pages are made under the family's header, footer, language chooser, Help switch and table cloths, with a description, an icon and a title in the family's form, and an API reference in the same header. The page's own Theme button is gone: light and dark follow the device, as in the other demos.
20
+ - The demo's tests are Playwright tests that run at a phone's width and a desk's, in Chromium, and the pages themselves in WebKit too.
21
+
22
+ ### Fixed
23
+
24
+ - A new game on a page served over plain http, from an address other than localhost, no longer fails: the seed falls back to random bytes where `crypto.randomUUID` does not exist.
25
+ - The API reference no longer widens the page on a phone for a doc comment that names a long entry path.
26
+ - Unused imports and variables are removed from the source; no public export, signature or behaviour changes.
27
+
28
+ ## [0.1.0] - 2026-10-05
29
+
30
+ ### Added
31
+
32
+ - Original Falling Triplets, Colour Chains, Stone Collapse and Gem Swap engines with immutable state, seeded play, validated settings and canonical saves.
33
+ - 300 graded challenges and three bilingual lessons for each game.
34
+ - Family-style keyboard, keypad and touch demos, configurable boards, stored tools, goal progress and shared animation preferences.
35
+ - Optional Black Hole powers, Shizen magnetic stones with bounded rebound, and Arashi jumble and lightning schedules.
36
+ - An experimental Magnetic Blocks engine with bonded squares, magnetic floor schedules, a Floor Switch and impact drops.
37
+ - Typed entry points, a generated API reference, an MIT licence and reproducible package checks.
38
+
39
+ [Unreleased]: https://github.com/johnmorrisdotca/houseki/compare/v0.1.1...HEAD
40
+ [0.1.1]: https://github.com/johnmorrisdotca/houseki/compare/v0.1.0...v0.1.1
41
+ [0.1.0]: https://github.com/johnmorrisdotca/houseki/releases/tag/v0.1.0
package/README.md CHANGED
@@ -1,80 +1,273 @@
1
- # Houseki · 宝石
1
+ <h1 align="center">Houseki <sub>宝石</sub></h1>
2
2
 
3
- [![Checks](https://github.com/johnmorrisdotca/houseki/actions/workflows/check.yml/badge.svg)](https://github.com/johnmorrisdotca/houseki/actions/workflows/check.yml) [![MIT licence](https://img.shields.io/badge/licence-MIT-blue.svg)](LICENSE)
3
+ <p align="center"><strong>Four original gem and stone puzzle games for JavaScript and TypeScript.</strong><br>
4
+ Falling Triplets, Colour Chains, Stone Collapse and Gem Swap: each an immutable, seeded rules engine that runs anywhere, with graded challenges and lessons, saves that replay to the same board, and a keyboard, keypad and touch player in the demo. Magnetic Blocks, with bonded squares and a magnetic floor, is an experiment beside them. In English and Japanese. No dependencies.</p>
4
5
 
5
- Original gem and stone puzzle games with immutable TypeScript rules and a shared English/Japanese player.
6
+ <p align="center">
7
+ <a href="https://github.com/johnmorrisdotca/houseki/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/johnmorrisdotca/houseki/actions/workflows/ci.yml/badge.svg"></a>
8
+ <a href="https://www.npmjs.com/package/@johnmorrisdotca/houseki"><img alt="npm" src="https://img.shields.io/npm/v/@johnmorrisdotca/houseki?color=2f5d4a"></a>
9
+ <a href="./LICENSE"><img alt="MIT licence" src="https://img.shields.io/badge/licence-MIT-2f5d4a"></a>
10
+ <img alt="No dependencies" src="https://img.shields.io/badge/dependencies-0-2f5d4a">
11
+ <img alt="TypeScript" src="https://img.shields.io/badge/types-TypeScript-2f5d4a">
12
+ </p>
6
13
 
7
- **Initial release:** four playable games with tested rules, campaigns and demos. Physical-device feel, fluent Japanese copy and human difficulty review remain ongoing. Magnetic Blocks and nature variants are experimental. Website integration is maintained separately.
14
+ <p align="center"><a href="https://johnmorrisdotca.github.io/houseki/"><strong>Play a game →</strong></a> · <a href="https://johnmorrisdotca.github.io/houseki/api.html">API reference</a></p>
8
15
 
9
- | Game | Distinctive mechanic |
10
- | --- | --- |
11
- | Falling Triplets | Cycle a falling vertical triplet; clear horizontal, vertical and diagonal lines |
12
- | Stone Collapse | Select connected groups; plan removal order and column compression |
13
- | Colour Chains | Rotate falling pairs; build connected groups and cascading chains |
14
- | Gem Swap | Swap neighbours; create and combine specials to complete objectives |
16
+ <p align="center">
17
+ <img src="docs/images/gem-swap-desktop.png" alt="Gem Swap on a full board in the demo: a grid of red, blue, green, gold, purple and teal gems with permanent symbols on them, the tool tray beside it with Bomb, Row clear and Colour clear, and the family's header above" width="620">
18
+ <img src="docs/images/tool-tray-phone.png" alt="The same tool tray on a phone, under the board" width="200">
19
+ </p>
15
20
 
16
- An optional experimental `magnetic-blocks` entry point provides bonded 2×2 squares, magnetic floor schedules, a one-use Floor Switch and impact drops. [Play its demo](https://johnmorrisdotca.github.io/houseki/blocks.html). It has no graded campaign yet. The `nature` entry point exposes deterministic attraction, rebound and environment utilities.
21
+ Houseki is a set of match-style puzzle games made to be dropped into a page or a server. Every game is a set of plain functions on plain data: a state in, a new state out, nothing read from the page, the clock or the network. The demo's players draw those states, and a person can play them with the keyboard, a keypad or a finger.
17
22
 
18
- ![Falling Triplets demo](https://raw.githubusercontent.com/johnmorrisdotca/houseki/main/docs/images/falling-triplets-desktop.png)
23
+ ## In 30 seconds
19
24
 
20
- ![Colour Chains demo](https://raw.githubusercontent.com/johnmorrisdotca/houseki/main/docs/images/colour-chains-desktop.png)
25
+ ```sh
26
+ npm install @johnmorrisdotca/houseki
27
+ ```
21
28
 
22
- ![Gem Swap demo](https://raw.githubusercontent.com/johnmorrisdotca/houseki/main/docs/images/gem-swap-desktop.png)
29
+ ```ts
30
+ import { createGame, applyAction, advanceTicks } from "@johnmorrisdotca/houseki/falling-triplets";
23
31
 
24
- ![Stone Collapse demo](https://raw.githubusercontent.com/johnmorrisdotca/houseki/main/docs/images/stone-collapse-desktop.png)
32
+ let game = createGame({ mode: "relaxed", seed: "first-game" });
33
+ game = applyAction(game, { kind: "cycle-forward" }).state;
34
+ game = applyAction(game, { kind: "place" }).state;
35
+ game = advanceTicks(game, 22).state;
36
+ ```
25
37
 
26
- [API reference](https://johnmorrisdotca.github.io/houseki/api.html) is generated locally by `pnpm site`; the hosted page becomes available after deployment. [Incremental draft PR](https://github.com/johnmorrisdotca/houseki/pull/1).
38
+ Every engine is a path of its own, and the main entry groups them by game:
27
39
 
28
- ## Design and progression
40
+ ```ts
41
+ import { colourChains } from "@johnmorrisdotca/houseki";
29
42
 
30
- The [design pack](https://github.com/johnmorrisdotca/houseki/blob/main/docs/design/README.md) specifies rules, controls, materials, accessibility, generation, grading, persistence and acceptance checks. [Level generation](https://github.com/johnmorrisdotca/houseki/blob/main/docs/design/LEVEL-GENERATION.md) follows a deliberate complete count and measured progression: generate and prove original boards, remove duplicates, grade player-facing decisions, then sort and number from easy to hard. Stable content IDs preserve saved progress across future ordering changes.
43
+ const firstChallenge = colourChains.createLevel(1);
44
+ const goal = firstChallenge.settings.goal;
45
+ ```
31
46
 
32
- The shared player uses the family's ivory, brass and felt palette, permanent colour symbols and configurable boards. Each set of three interactive lessons is separate from the graded campaign. Physical-device feel testing and fluent Japanese copy review are recorded independently from automated checks.
47
+ Or straight from a page, with nothing to build:
33
48
 
34
- ## Local development
49
+ ```html
50
+ <script type="module">
51
+ import { createGame } from "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/houseki@0/dist/gem-swap.js";
52
+ const game = createGame({ seed: "hello" });
53
+ </script>
54
+ ```
35
55
 
36
- Requires Node.js 22 or newer and pnpm.
56
+ ## Who it is for
37
57
 
38
- ```sh
39
- pnpm install
40
- pnpm build
41
- pnpm test
42
- pnpm demo
43
- ```
58
+ - **Game and puzzle sites** that want match games with the rules already right: challenges everybody plays alike, a win that is witnessed, and saves that cannot drift.
59
+ - **Anyone who needs the rules without a screen**: a server that checks a finished game, a test that plays a campaign, a bot, a solver. Every engine is deterministic from its seed.
60
+ - **Teachers and parents**: nothing is timed against you in Relaxed play, every colour has its own permanent symbol, and every word is plain.
44
61
 
45
- The local demo instructions print its address. The first page plays Falling Triplets; `chains.html` plays Colour Chains; `tools.html` plays Gem Swap and Stone Collapse with optional stored-tool trays. The campaigns contain 100 Falling Triplets, 50 Colour Chains, 100 Stone Collapse and 50 Gem Swap challenges, ordered by measured difficulty. Finite goals show progress and remaining pieces or moves. All players share the persisted default-on Animation setting and respect reduced motion. See [CONTRIBUTING.md](https://github.com/johnmorrisdotca/houseki/blob/main/CONTRIBUTING.md) for contribution conventions and [the implementation plan](https://github.com/johnmorrisdotca/houseki/blob/main/docs/design/IMPLEMENTATION-PLAN.md) for bounded review milestones.
62
+ ## Features
46
63
 
47
- ## Engine example
64
+ - **Four games**, each its own engine and its own entry point: [Falling Triplets](docs/design/01-FALLING-TRIPLETS.md), [Stone Collapse](docs/design/02-STONE-COLLAPSE.md), [Colour Chains](docs/design/03-COLOUR-CHAINS.md) and [Gem Swap](docs/design/04-GEM-SWAP.md).
65
+ - **Graded campaigns and lessons**: 100 Falling Triplets, 50 Colour Chains, 100 Stone Collapse and 50 Gem Swap challenges, ordered by measured difficulty, each with a recorded winning play that the tests replay, and three guided lessons for each game. The boards are original, regenerated from a script, and a challenge keeps its identity if the order changes.
66
+ - **Three modes**: Relaxed (no clock, plan each move), Arcade (a timer drops the pieces) and Daily (the same board for everyone on a date).
67
+ - **Seeded and replayable**: a state is made from a seed and a list of actions, so a save is that list, and it decodes to exactly the board it came from.
68
+ - **Configurable boards**: presets from compact to extra wide and deep, custom sizes within stated limits, up to six colours, and shaped boards (heart, star, hexagon) for the full-board games.
69
+ - **Stored tools** for Gem Swap (Bomb, Row clear, Colour clear) and Stone Collapse (Bomb, Pick): select a tool and a stone, look at the highlighted effect, then confirm or cancel. A run that uses a tool is marked assisted. An optional earned Black Hole shrinks as it consumes nearby gems.
70
+ - **Nature, optional**: Shizen magnetic stones with one bounded rebound, and Arashi weather, a rare or frequent earthquake that jumbles stones and lightning that removes exposed ones, on a seeded schedule.
71
+ - **Magnetic Blocks, experimental**: bonded 2×2 squares, a floor that turns magnetic on a schedule, a one-use Floor Switch and impact drops. It has no graded campaign yet.
72
+ - **Accessible**: permanent colour symbols, keyboard and keypad control, an Animation setting that is on by default and a reduced-motion choice that is respected.
73
+ - **Light and dark** that follow the device, in the demo's family look.
74
+ - **English and Japanese** words for every lesson, challenge, button and line of the demo.
75
+ - **Zero dependencies**, for the package and for the demo.
48
76
 
49
- The currently reviewed Falling Triplets entry point is independent of DOM, storage and network access:
77
+ ### The games
78
+
79
+ | Game | Entry | You | A match is | Challenges |
80
+ | --- | --- | --- | --- | --- |
81
+ | Falling Triplets | `falling-triplets` | cycle a falling vertical triplet and place it | a line of three, across, down or diagonal | 100 |
82
+ | Stone Collapse | `stone-collapse` | select a connected group and confirm | two or more touching stones of one colour | 100 |
83
+ | Colour Chains | `colour-chains` | rotate a falling pair | a group of four or more | 50 |
84
+ | Gem Swap | `gem-swap` | swap two neighbours | a run of three or more, which can make special gems | 50 |
85
+ | Magnetic Blocks (experimental) | `magnetic-blocks` | rotate a falling 2×2 block | bonded groups, on a floor that pulls | none yet |
86
+
87
+ ## Use it in your project
88
+
89
+ Import a game directly from `@johnmorrisdotca/houseki/falling-triplets`, `@johnmorrisdotca/houseki/stone-collapse`, `@johnmorrisdotca/houseki/colour-chains`, `@johnmorrisdotca/houseki/gem-swap` or `@johnmorrisdotca/houseki/magnetic-blocks`, and the deterministic attraction, rebound and environment utilities from `@johnmorrisdotca/houseki/nature`. The main entry, `@johnmorrisdotca/houseki`, groups the same names as the namespaces `fallingTriplets`, `stoneCollapse`, `colourChains`, `gemSwap`, `nature` and `magneticBlocks`. The engines do not touch the DOM, storage or the network.
90
+
91
+ Every engine works the same way:
50
92
 
51
93
  ```ts
52
- import { createGame, applyAction, advanceTicks } from '@johnmorrisdotca/houseki/falling-triplets';
94
+ import { createGame, createLevel, applyAction, advanceTicks, legalActions, encodeGame, decodeGame } from "@johnmorrisdotca/houseki/colour-chains";
53
95
 
54
- let game = createGame({ mode: 'relaxed', seed: 'first-game' });
55
- game = applyAction(game, { kind: 'cycle-forward' }).state;
56
- game = applyAction(game, { kind: 'place' }).state;
57
- game = advanceTicks(game, 22).state;
96
+ const level = createLevel(1); // a graded challenge; createGame({ seed }) is a free game
97
+ const move = applyAction(level, { kind: "rotate-clockwise" });
98
+ move.accepted; // false when the action is not allowed
99
+ move.events; // what happened, in order, for a screen to animate
100
+ const later = advanceTicks(move.state, 30).state; // time is a count of ticks, never the clock
101
+ const saved = encodeGame(later); // a string; decodeGame(saved) is the same game again
58
102
  ```
59
103
 
60
- The package exposes an entry point for each game. The generated API reference lists every exported function, type and setting.
104
+ Every function returns a new state and leaves the one it was given untouched. `legalActions(state)` lists what may be done now, so a bot or a test needs no knowledge of the rules. The two full-board games, Gem Swap and Stone Collapse, also have an undo and a hint (`undoGame` and `hintGame` in Gem Swap, `undo` and `requestHint` in Stone Collapse) and a restart; their stored tools are actions of their own.
61
105
 
62
- ## Licence
106
+ To run the whole demo, `pnpm install && pnpm site`, then serve `site/` with any static server. A page of the demo takes `?seed=anything` in its address to start the same board again, and `?lang=ja` for Japanese.
63
107
 
64
- [MIT](LICENSE), copyright John Morris. Original game content and presentation are maintained in this repository. Shared family files preserve their existing copyright notices. Report vulnerabilities through [SECURITY.md](https://github.com/johnmorrisdotca/houseki/blob/main/SECURITY.md).
108
+ ## API
65
109
 
66
- ## Stored tools
110
+ Every export of every entry point is in the [API reference](https://johnmorrisdotca.github.io/houseki/api.html), made from the source when the demo is built, with each signature and doc comment. A test fails when a public export has no doc comment.
67
111
 
68
- [Stored-tool rules](https://github.com/johnmorrisdotca/houseki/blob/main/docs/design/STORED-TOOLS.md) distinguish inventory from special gems on the board. Gem Swap offers Bomb, Row clear and Colour clear; Stone Collapse offers Bomb and Pick. Select a tool and an occupied square, inspect the highlighted effect, then confirm or cancel. Ordinary clears earn capped inventory; using tools marks the run assisted. Daily and existing authored challenges keep their declared tool-free rules. Gem Swap also offers an optional earned [Black Hole](https://github.com/johnmorrisdotca/houseki/blob/main/docs/design/BLACK-HOLE.md): consume nearby gems with a visibly shrinking capacity and bounded lifetime. Enable it before starting a casual board.
112
+ ## Theming
69
113
 
70
- ## Package entry points
114
+ The engines draw nothing. The demo's players take their colours from the family's stylesheet, `demo/family.css`: custom properties for the page, ink, accent and the felt the board sits on, which follow `prefers-color-scheme`, and five table cloths (green, blue, red, black and wood) chosen in the header. The boards add their own `--board`, `--frame` and `--gem-edge` in `demo/houseki.css`, and a Board material choice (ivory, slate or wood). Gems are told apart by their symbol as well as their colour, so no choice of cloth hides a colour.
71
115
 
72
- Import a game directly from `@johnmorrisdotca/houseki/falling-triplets`, `/stone-collapse`, `/colour-chains` or `/gem-swap`. The root entry groups the same APIs as `fallingTriplets`, `stoneCollapse`, `colourChains` and `gemSwap` namespaces. Engines do not depend on the DOM or external services.
116
+ ## Limits
73
117
 
74
- ```ts
75
- import { colourChains } from '@johnmorrisdotca/houseki';
76
- const firstChallenge = colourChains.createLevel(1);
77
- const objective = firstChallenge.settings.goal;
118
+ | What | Limit |
119
+ | --- | --- |
120
+ | Colours | 4 to 6 |
121
+ | Colour Chains | 5 to 16 columns and 12 to 32 visible rows |
122
+ | Magnetic Blocks | 4 to 16 columns and 4 to 32 rows; at most 200 pieces in the demo |
123
+ | Stone Collapse | presets from 6×8 to 16×10 and 8×32 deep; shaped boards by mask |
124
+ | Daily mode | the standard board and colour count only, from a date |
125
+ | Saves | a replay of the actions taken, checked when it is decoded; a save that does not match its own record is refused |
126
+ | Tools | capped inventory, earned by ordinary clears, and not offered in Daily or in authored challenges |
127
+
128
+ ## Browser support
129
+
130
+ The engines run wherever JavaScript does: Node 22 or later, and current Chrome, Edge, Firefox and Safari. The demo's tests run in Chromium and WebKit, at a phone's width and a desk's.
131
+
132
+ ## Languages
133
+
134
+ The demo is in English and Japanese: every lesson and challenge title, button, status line and the family's header and footer. The Japanese has not yet been read by a native reader: corrections are welcome as a *Fix a translation* issue.
135
+
136
+ ## Roadmap
137
+
138
+ Physical-device feel testing, a fluent Japanese review and human difficulty review of the campaigns are next, and a graded campaign for Magnetic Blocks. [docs/COVERAGE.md](docs/COVERAGE.md) says what is verified by tests and what is not. Nothing here is promised for a date.
139
+
140
+ ## Architecture
141
+
142
+ ```text
143
+ src/
144
+ ├── colour-chains/
145
+ │ ├── challenge.ts
146
+ │ ├── content-data.ts
147
+ │ ├── content-types.ts
148
+ │ ├── content.ts
149
+ │ ├── engine.ts
150
+ │ ├── input.ts
151
+ │ ├── match.ts
152
+ │ ├── persistence.ts
153
+ │ ├── random.ts
154
+ │ ├── types.ts
155
+ │ └── validation.ts
156
+ ├── colour-chains.ts
157
+ ├── falling-triplets/
158
+ │ ├── content-data.ts
159
+ │ ├── content-types.ts
160
+ │ ├── content.ts
161
+ │ ├── engine.ts
162
+ │ ├── input.ts
163
+ │ ├── match.ts
164
+ │ ├── random.ts
165
+ │ └── types.ts
166
+ ├── falling-triplets.ts
167
+ ├── gem-swap/
168
+ │ ├── black-hole.ts
169
+ │ ├── board.ts
170
+ │ ├── content.ts
171
+ │ ├── engine.ts
172
+ │ ├── persistence.ts
173
+ │ ├── practice.ts
174
+ │ ├── random.ts
175
+ │ ├── specials.ts
176
+ │ ├── tools.ts
177
+ │ └── types.ts
178
+ ├── gem-swap.ts
179
+ ├── index.ts
180
+ ├── magnetic-blocks/
181
+ │ ├── engine.ts
182
+ │ ├── persistence.ts
183
+ │ ├── physics.ts
184
+ │ ├── random.ts
185
+ │ ├── types.ts
186
+ │ └── validation.ts
187
+ ├── magnetic-blocks.ts
188
+ ├── nature/
189
+ │ ├── attraction.ts
190
+ │ ├── environment.ts
191
+ │ ├── marking.ts
192
+ │ ├── random.ts
193
+ │ ├── rebound.ts
194
+ │ ├── state.ts
195
+ │ ├── types.ts
196
+ │ └── validation.ts
197
+ ├── nature.ts
198
+ ├── stone-collapse/
199
+ │ ├── content-data.ts
200
+ │ ├── content-types.ts
201
+ │ ├── content.ts
202
+ │ ├── engine.ts
203
+ │ ├── persistence.ts
204
+ │ ├── types.ts
205
+ │ └── validation.ts
206
+ └── stone-collapse.ts
78
207
  ```
79
208
 
80
- Run `npm run check:package` to build, pack and install the actual tarball into a temporary consumer and check every game entry point. `npm run test:browser` verifies desktop and phone player controls, witnessed campaign wins, progress, tool use, persistence of animation preferences and reduced motion.
209
+ The [design pack](docs/design/README.md) specifies the rules, controls, materials, accessibility, level generation, grading, persistence and acceptance checks of every game; [level generation](docs/design/LEVEL-GENERATION.md) follows a deliberate complete count: generate and prove original boards, remove duplicates, grade the decisions a player faces, then sort and number from easy to hard.
210
+
211
+ ## The name
212
+
213
+ Houseki (宝石) is Japanese for a gem or precious stone: the pieces of these games are cut and polished, and the games are small.
214
+
215
+ ## Where it comes from
216
+
217
+ Match games are an old family and their rules are common property. These four are original: the rules are written out in the design pack in our own words, every board is generated and checked by the repository's own scripts, and the pictures are drawn in code. No art, sound or level comes from another game.
218
+
219
+ ### The family
220
+
221
+ <!-- family:start (made by scripts/family-readme.mjs from scripts/family-template.mjs; change those, not this) -->
222
+ Houseki is one of twenty-four packages, each made for the same site, each at
223
+ [github.com/johnmorrisdotca](https://github.com/johnmorrisdotca). The code of every one is MIT.
224
+
225
+ - [Korokoro](https://github.com/johnmorrisdotca/korokoro) (コロコロ): dice, with notation, exact odds, real sounds and the dice of many games. [Demo](https://johnmorrisdotca.github.io/korokoro/).
226
+ - [Kyuubu](https://github.com/johnmorrisdotca/kyuubu) (キューブ): a turning cube for the browser, 2×2 to 7×7, with record solves to replay. [Demo](https://johnmorrisdotca.github.io/kyuubu/).
227
+ - [Hitotsu](https://github.com/johnmorrisdotca/hitotsu) (一つ): a colour-card shedding game for two to eight, with the house rules people play. [Demo](https://johnmorrisdotca.github.io/hitotsu/).
228
+ - [Toranpu](https://github.com/johnmorrisdotca/toranpu) (トランプ): a deck of playing cards, card games with computer players, and solitaires. [Demo](https://johnmorrisdotca.github.io/toranpu/).
229
+ - [Tane](https://github.com/johnmorrisdotca/tane) (種): seeded random numbers and daily seeds, the same in every browser and on every server. [Demo](https://johnmorrisdotca.github.io/tane/).
230
+ - [Narabe](https://github.com/johnmorrisdotca/narabe) (並べ): one rules engine for abstract board games, from gomoku and Reversi to Go and checkers. [Demo](https://johnmorrisdotca.github.io/narabe/).
231
+ - [Tenka](https://github.com/johnmorrisdotca/tenka) (天下): world conquest for two to six, on a map of the real world. [Demo](https://johnmorrisdotca.github.io/tenka/).
232
+ - [Kumimoji](https://github.com/johnmorrisdotca/kumimoji) (組み文字): a crossword tile race, in English and Japanese kana. [Demo](https://johnmorrisdotca.github.io/kumimoji/).
233
+ - [Tsunagi](https://github.com/johnmorrisdotca/tsunagi) (繋ぎ): a line-joining logic puzzle whose every level has exactly one answer. [Demo](https://johnmorrisdotca.github.io/tsunagi/).
234
+ - [Jarajara](https://github.com/johnmorrisdotca/jarajara) (ジャラジャラ): mahjong tiles drawn as SVG, stacked layouts, and the matching solitaire Awase. [Demo](https://johnmorrisdotca.github.io/jarajara/).
235
+ - [Suido](https://github.com/johnmorrisdotca/suido) (水道): a pipe puzzle: turn the pieces until the water reaches every drain. [Demo](https://johnmorrisdotca.github.io/suido/).
236
+ - [Domino](https://github.com/johnmorrisdotca/domino) (ドミノ): dominoes and Mexican Train. [Demo](https://johnmorrisdotca.github.io/domino/).
237
+ - [Kotoba](https://github.com/johnmorrisdotca/kotoba) (言葉): word lists and word-game rules in English, French, German and Japanese. [Demo](https://johnmorrisdotca.github.io/kotoba/).
238
+ - [Sugoroku](https://github.com/johnmorrisdotca/sugoroku) (双六): backgammon and its variants, with the doubling cube and match play. [Demo](https://johnmorrisdotca.github.io/sugoroku/).
239
+ - [Kazu](https://github.com/johnmorrisdotca/kazu) (数): grid number puzzles: Sudoku and its variants, Futoshiki and Skyscrapers. [Demo](https://johnmorrisdotca.github.io/kazu/).
240
+ - [Meikyuu](https://github.com/johnmorrisdotca/meikyuu) (迷宮): mazes on squares, hexagons, triangles and circles, made from a seed and drawn through with a finger or the mouse. [Demo](https://johnmorrisdotca.github.io/meikyuu/).
241
+ - [Hikidashi](https://github.com/johnmorrisdotca/hikidashi) (引き出し): a drawer of small Japanese text tools: era dates, kanji numerals, readings and sentence difficulty. [Demo](https://johnmorrisdotca.github.io/hikidashi/).
242
+ - [Chizu](https://github.com/johnmorrisdotca/chizu) (地図): maps of the world and of countries' regions, in English and Japanese, with a quiz and callouts. [Demo](https://johnmorrisdotca.github.io/chizu/).
243
+ - [Bushu](https://github.com/johnmorrisdotca/bushu) (部首): find a kanji by the parts it is made of. [Demo](https://johnmorrisdotca.github.io/bushu/).
244
+ - [Tobiishi](https://github.com/johnmorrisdotca/tobiishi) (飛び石): peg solitaire with nine boards and seeded solvable challenges. [Demo](https://johnmorrisdotca.github.io/tobiishi/).
245
+ - [Jirai](https://github.com/johnmorrisdotca/jirai) (地雷): minesweeper on shaped grids with verified no-guess boards. [Demo](https://johnmorrisdotca.github.io/jirai/).
246
+ - [Gunjin](https://github.com/johnmorrisdotca/gunjin) (軍人): five hidden-rank strategy games with pass-the-device play. [Demo](https://johnmorrisdotca.github.io/gunjin/).
247
+ - [Karakuri](https://github.com/johnmorrisdotca/karakuri) (からくり): eight hyper-casual puzzle games, some of them physics: draw a shield, pull pins, cut ropes, slide blocks, pour tubes. [Demo](https://johnmorrisdotca.github.io/karakuri/).
248
+ - [Houseki](https://github.com/johnmorrisdotca/houseki) (宝石): gem and stone matching puzzles: falling triplets, stone collapse, colour chains and gem swap. [Demo](https://johnmorrisdotca.github.io/houseki/).
249
+
250
+ **This package is Houseki.** The demos of all twenty-four share one header and footer, so each links the rest.
251
+ <!-- family:end -->
252
+
253
+ ## Development
254
+
255
+ ```sh
256
+ pnpm install
257
+ pnpm check # lint, types and tests: every game's rules, every campaign's recorded wins
258
+ pnpm test:package # pack it as npm does, install it in an empty project, import every entry
259
+ pnpm test:demo # build the demo and play it in a real browser, at a phone's width and a desk's
260
+ pnpm site # build the demo and the API reference into site/
261
+ ```
262
+
263
+ ## Contributing
264
+
265
+ Ideas, bug reports and pull requests are welcome in the [issues](https://github.com/johnmorrisdotca/houseki/issues). See [CONTRIBUTING.md](./CONTRIBUTING.md).
266
+
267
+ ## Changes
268
+
269
+ Every release is written up in [CHANGELOG.md](./CHANGELOG.md).
270
+
271
+ ## Licence
272
+
273
+ [MIT](./LICENSE) © John Morris. The code, the boards and the words are all the package's own. Report vulnerabilities through [SECURITY.md](./SECURITY.md).
@@ -14,6 +14,7 @@ export function setHeldInput(state, control, pressed) {
14
14
  /** Queues a one-shot rotation, drop, Place, pause or resume edge for the next logical tick. */
15
15
  export function queueInputEdge(state, action) { return { ...state, queued: Object.freeze([...state.queued, action]) }; }
16
16
  /** Releases every held or queued control after focus loss, lock, resolution or pause. */
17
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- the public signature takes the state a caller holds, though nothing of it is kept
17
18
  export function releaseAllInput(state) { return createInputScheduler(); }
18
19
  /** Resolves this tick's inputs in lateral, rotation, drop, soft-drop, pause order. */
19
20
  export function actionsForTick(game, input) {
@@ -79,7 +79,7 @@ export function createGame(options = {}) {
79
79
  const settings = { mode, width, height, colourCount, seed, ...(pieceLimit === undefined ? {} : { pieceLimit }) };
80
80
  if (![4, 5, 6].includes(settings.colourCount))
81
81
  throw new RangeError('Colour count must be 4, 5, or 6');
82
- let randomState = seedState(`falling-triplets|${RULES}|${seed}`);
82
+ const randomState = seedState(`falling-triplets|${RULES}|${seed}`);
83
83
  const initial = { game: 'falling-triplets', rules: RULES, settings, board: Array(width * (height + HIDDEN)).fill(null), phase: 'falling', active: null, next: [], bag: [], randomState, nextId: 1, score: 0, maxChain: 0, completedPieces: 0, elapsedTicks: 0, pieceTicks: 0, resolutionTick: 0, waves: [], assisted: false, hintsUsed: 0, witnessPathMatches: true, recording: [] };
84
84
  const first = drawTriplet(initial);
85
85
  let state = { ...initial, bag: first.bag, randomState: first.randomState, hintsUsed: 0 };
@@ -38,4 +38,5 @@ export function actionsForTick(state) {
38
38
  return [actions, { held, queued: [] }];
39
39
  }
40
40
  /** Releases every held action after blur, pause, or pointer cancellation. */
41
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- the public signature takes the state a caller holds, though nothing of it is kept
41
42
  export function releaseAllActions(state) { return { held: {}, queued: [] }; }
@@ -418,7 +418,7 @@ function awardTools(state, removed) {
418
418
  return { inventory: state.inventory, progress: state.toolProgress, cursor: state.toolAwardCursor, events: Object.freeze([]) };
419
419
  let progress = state.toolProgress + removed;
420
420
  let cursor = state.toolAwardCursor;
421
- let inventory = { ...state.inventory };
421
+ const inventory = { ...state.inventory };
422
422
  const events = [];
423
423
  while (progress >= 12) {
424
424
  progress -= 12;
@@ -211,7 +211,7 @@ function comboPlan(state, p, q, protectedCells, pairIds) {
211
211
  return null;
212
212
  }
213
213
  function effectCells(state, cell, kind) {
214
- const { width, height } = state.settings;
214
+ const { width } = state.settings;
215
215
  const x = cell % width;
216
216
  const y = Math.floor(cell / width);
217
217
  if (kind === 'row-beam')
@@ -1,7 +1,7 @@
1
1
  import { planWave } from './specials.js';
2
2
  /** Computes the occupied cells affected by a tool and all special activations it causes. */
3
3
  export function previewTool(state, tool, target) {
4
- const { width, height, mask } = state.settings;
4
+ const { width, mask } = state.settings;
5
5
  if (!Number.isInteger(target) || target < 0 || target >= state.board.length || !mask[target] || !state.board[target])
6
6
  return Object.freeze([]);
7
7
  const x = target % width;
@@ -73,9 +73,8 @@ function validateLightningOptions(options, width) {
73
73
  function faultPath(state) {
74
74
  if (state.width < 3)
75
75
  throw new NatureOptionsError('invalid-grid-size', 'A fault needs at least three columns to preserve playable space on both sides');
76
- let randomState = state.randomState;
77
- let draw;
78
- [randomState, draw] = drawBelow(randomState, state.width - 2);
76
+ const [firstState, draw] = drawBelow(state.randomState, state.width - 2);
77
+ let randomState = firstState;
79
78
  let x = draw + 1;
80
79
  const path = [at(x, 0, state.width)];
81
80
  for (let y = 1; y < state.height; y++) {
@@ -146,8 +145,8 @@ export function previewJumble(state) {
146
145
  const candidates = candidatePatches(state);
147
146
  if (candidates.length === 0)
148
147
  return deepFreeze({ patchCells: [], moves: [], changed: false, reason: 'no-eligible-patch', cells: state.cells, randomStateAfter: state.randomState });
149
- let randomState, selectedIndex;
150
- [randomState, selectedIndex] = drawBelow(state.randomState, candidates.length);
148
+ const [firstState, selectedIndex] = drawBelow(state.randomState, candidates.length);
149
+ let randomState = firstState;
151
150
  const patch = candidates[selectedIndex];
152
151
  const shuffled = [...patch.stones];
153
152
  for (let index = shuffled.length - 1; index > 0; index--) {
@@ -57,7 +57,7 @@ export function previewPowerDrop(state, request) {
57
57
  }
58
58
  const eligible = request.power && state.rules.reboundEnabled;
59
59
  let randomStateAfter = state.randomState;
60
- let attempts = [];
60
+ const attempts = [];
61
61
  let finalCells = normal;
62
62
  let selectedDirection;
63
63
  let selectedTurn = 0;
@@ -74,7 +74,7 @@ function previewAt(state, tool, target) {
74
74
  }
75
75
  return cells;
76
76
  }
77
- function clearToolSelection(state) {
77
+ function clearToolSelection(_state) {
78
78
  return { selectedTool: null, toolTarget: null, toolPreview: Object.freeze([]) };
79
79
  }
80
80
  function recordToolAction(state, action) {
@@ -1,7 +1,6 @@
1
1
  const PRESETS = {
2
2
  compact: [6, 8], standard: [8, 10], wide: [10, 8], tall: [6, 12], extraWide: [16, 10], deep: [8, 32], large: [12, 32],
3
3
  };
4
- const COLOURS = ['red', 'blue', 'green', 'gold', 'purple', 'teal'];
5
4
  /** Typed public-settings validation error. */
6
5
  export class StoneCollapseOptionsError extends RangeError {
7
6
  code;
@@ -96,7 +95,7 @@ export function optionsFor(options) {
96
95
  const hasDimensions = options.width !== undefined || options.height !== undefined;
97
96
  let width;
98
97
  let height;
99
- let shape = options.shape;
98
+ const shape = options.shape;
100
99
  let mask = options.mask;
101
100
  if (shape !== undefined) {
102
101
  if (options.preset !== undefined || hasDimensions || mask !== undefined || !['heart', 'star', 'hexagon'].includes(shape))
package/package.json CHANGED
@@ -1,19 +1,53 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/houseki",
3
- "version": "0.1.0",
4
- "description": "Original immutable gem-matching game engines and accessible English/Japanese play.",
5
- "type": "module",
6
- "author": "John Morris",
7
- "license": "MIT",
3
+ "version": "0.1.1",
4
+ "description": "Houseki \u5b9d\u77f3: four original gem and stone puzzle games, Falling Triplets, Colour Chains, Stone Collapse and Gem Swap, as immutable seeded engines with 300 graded levels, plus experimental Magnetic Blocks. English and Japanese. Zero dependencies.",
5
+ "keywords": [
6
+ "puzzle",
7
+ "puzzle-game",
8
+ "match-three",
9
+ "match-3",
10
+ "falling-triplets",
11
+ "colour-chains",
12
+ "stone-collapse",
13
+ "gem-swap",
14
+ "magnetic-blocks",
15
+ "gravity",
16
+ "cascade",
17
+ "game-engine",
18
+ "levels",
19
+ "immutable",
20
+ "deterministic",
21
+ "seeded-random",
22
+ "accessible",
23
+ "touch",
24
+ "keyboard",
25
+ "japanese",
26
+ "typescript",
27
+ "javascript",
28
+ "zero-dependencies",
29
+ "browser",
30
+ "node",
31
+ "itsutsu"
32
+ ],
33
+ "homepage": "https://johnmorrisdotca.github.io/houseki/",
8
34
  "repository": {
9
35
  "type": "git",
10
36
  "url": "git+https://github.com/johnmorrisdotca/houseki.git"
11
37
  },
12
- "homepage": "https://johnmorrisdotca.github.io/houseki/",
13
38
  "bugs": {
14
39
  "url": "https://github.com/johnmorrisdotca/houseki/issues"
15
40
  },
41
+ "author": {
42
+ "name": "John Morris",
43
+ "email": "john@johnmorris.ca",
44
+ "url": "https://johnmorris.ca"
45
+ },
46
+ "license": "MIT",
47
+ "type": "module",
48
+ "sideEffects": false,
16
49
  "main": "./dist/index.js",
50
+ "module": "./dist/index.js",
17
51
  "types": "./dist/index.d.ts",
18
52
  "exports": {
19
53
  ".": {
@@ -63,36 +97,24 @@
63
97
  },
64
98
  "scripts": {
65
99
  "build": "tsc -p tsconfig.json",
100
+ "lint": "eslint .",
66
101
  "typecheck": "tsc -p tsconfig.json --noEmit",
67
- "test": "npm run build && node --test test/*.test.mjs",
68
- "site": "npm run build && node scripts/site.mjs",
69
- "demo": "npm run site && node scripts/serve.mjs",
70
- "test:browser": "npm run site && node test/browser/tools.mjs",
71
- "check:package": "npm run build && node scripts/check-package.mjs"
102
+ "test": "pnpm build && vitest run",
103
+ "test:package": "pnpm build && node scripts/check-package.mjs",
104
+ "family:readme": "node scripts/family-readme.mjs",
105
+ "check": "pnpm lint && pnpm typecheck && pnpm test",
106
+ "prepublishOnly": "pnpm check && pnpm build",
107
+ "site": "pnpm build && node scripts/site.mjs",
108
+ "test:demo": "pnpm site && playwright test && node --test --test-concurrency=2 e2e/review/appearance-api.test.mjs e2e/review/endings.test.mjs e2e/review/full-board-recovery.test.mjs e2e/review/nature-previews.test.mjs e2e/review/responsive.test.mjs",
109
+ "test:review": "pnpm site && node --test --test-concurrency=2 e2e/review/appearance-api.test.mjs e2e/review/endings.test.mjs e2e/review/full-board-recovery.test.mjs e2e/review/nature-previews.test.mjs e2e/review/responsive.test.mjs"
72
110
  },
73
111
  "devDependencies": {
74
- "typescript": "^5.9.3",
75
- "@playwright/test": "^1.58.2"
112
+ "@eslint/js": "^9.0.0",
113
+ "@playwright/test": "^1.63.0",
114
+ "eslint": "^9.0.0",
115
+ "typescript": "^5.9.0",
116
+ "typescript-eslint": "^8.0.0",
117
+ "vitest": "^5.0.0"
76
118
  },
77
- "packageManager": "pnpm@10.11.0",
78
- "keywords": [
79
- "falling-triplets",
80
- "match-three",
81
- "puzzle-game",
82
- "immutable",
83
- "typescript",
84
- "zero-dependencies",
85
- "accessible",
86
- "touch",
87
- "keyboard",
88
- "japanese",
89
- "stone-collapse",
90
- "colour-chains",
91
- "gem-swap",
92
- "match-3",
93
- "gravity",
94
- "cascade",
95
- "puzzle",
96
- "game-engine"
97
- ]
119
+ "packageManager": "pnpm@10.11.0"
98
120
  }