Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .claude/rules/scratch-vm/smalruby-prettier-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ upstream (Scratch) ファイルは対象外。
- `test/unit/blocks_operators_regex.js`
- `test/unit/runtime_extension_hat_shape.js`
- `test/unit/extension_koshien.js`
- `test/unit/koshien_golden_contract.js`
- `test/unit/extension_mesh_v2_delta_repro.js`
- `test/unit/extension_mesh_v2_delta.js`
- `test/unit/extension_mesh_v2_domain.js`
Expand Down
1 change: 1 addition & 0 deletions packages/scratch-vm/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ test/unit/*
!test/unit/runtime_extension_hat_shape.js
!test/unit/extension_koshien.js
!test/unit/koshien_map_utils.js
!test/unit/koshien_golden_contract.js
!test/unit/extension_mesh_v2_delta_repro.js
!test/unit/extension_mesh_v2_delta.js
!test/unit/extension_mesh_v2_domain.js
Expand Down
36 changes: 36 additions & 0 deletions packages/scratch-vm/test/fixtures/koshien/golden/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Koshien golden fixtures

These JSON files are **golden recordings of the real Smalruby Koshien game server's
behavior**, captured by driving the server's in-process API (the same `SpecHelper::Server`
the server's own RSpec suite uses) through deterministic scenarios.

They are the source of truth for the Koshien client contract: the JS client in
`src/extensions/koshien/` must reproduce these responses when connected to a real server
(verified by `test/unit/extensions/koshien_golden_contract.js`).

## Provenance / regeneration

Recorded from `tmp/smalruby-koshien/game_server` on Ruby 3.1 with `SK_RANDOM_SEED=1`.
The recorder script and full setup are documented in the project notes
(`notes/koshien/scripts/koshien-golden-recorder.rb`, `notes/koshien/server-setup.md`).

```bash
# (from the koshien repo checkout)
SK_RANDOM_SEED=1 ruby koshien-golden-recorder.rb <out-dir>
# then copy <out-dir>/*.json here
```

## Files

| File | Scenario |
|------|----------|
| `move_basic.json` | `move_to` is a reservation; position is confirmed only after `turnTransition`. |
| `get_map_area.json` | `getMapArea` returns the player's accumulated 15x15 map (`-1` = unexplored) + `enemy` + `other_player`. |
| `two_actions.json` | Two actions in one turn (`move_to` + `getMapArea`). |

## Notes captured from real behavior

- A `move_to` does **not** change `x`/`y` until the viewer calls `turnTransition`
(before: `[1,1]`, after: `[2,1]`).
- `getMapArea` returns the **full 15x15** player map (not a 5x5 slice); unexplored cells are `-1`.
- `enemy` is always present in `getMapArea`; `other_player` is `null` when out of range.
279 changes: 279 additions & 0 deletions packages/scratch-vm/test/fixtures/koshien/golden/get_map_area.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
{
"name": "get_map_area",
"description": "getMapArea は中心 5x5 と enemy/other_player を返す",
"seed": "1",
"steps": [
{
"label": "get_map_area_1_1",
"response": {
"map": [
[
2,
2,
2,
2,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1
],
[
2,
0,
0,
0,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1
],
[
2,
0,
0,
0,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1
],
[
2,
0,
0,
0,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1
],
[
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1
],
[
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1
],
[
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1
],
[
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1
],
[
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1
],
[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