M5-M7: сцены, лобби, экран игры и цикл матча

Обе сцены собраны через Code Mode, не руками.

- loader: поднимает модули, прогревает арт карт, уходит в lobby
- lobby: обе UI-ветки в одной сцене (по ARCHITECTURE.md), матч — это
  смена видимого корня, а не загрузка сцены
- GameScreen рисует текущее состояние и доводит узлы твинами, а не
  проигрывает поток событий: узел карты живёт вместе со своей картой,
  поэтому "шестёрка ушла из руки на стол" не требует отдельного случая
- один тап = ход целиком; логика вынесена в core/rules/intent.ts
  и покрыта тестами, в том числе проверкой, что она никогда не предложит
  ход, который правила отвергнут
- арт карт переехал в assets/resources: .pac — это инструкция упаковки
  на сборке, а не рантайм-ассет, и без ссылок на кадры в сборку
  не попадало ничего. Теперь все 37 спрайтов в одной текстуре 2048x2048
- клики кнопок подписываются в коде, а не через clickEvents сцены
- строки интерфейса собраны в одном файле

Сборка web-mobile проходит чисто, все ссылки в сцене проверены.
Вживую не запускалось: браузер в этом окружении не поднимает
главный цикл движка. Подробности — в docs/TECHNICAL.md.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
ftc
2026-09-13 11:30:28 +03:00
co-authored by Claude Opus 5
parent 2056673946
commit 4f3a26dc45
111 changed files with 8168 additions and 37 deletions
+63 -1
View File
@@ -95,5 +95,67 @@ and bottom bars.
**Decision.** Use the 36 faces needed for a durak deck, rendered from the SVG
sources so the downscale to the 1080-wide budget stays sharp. Attribution and
licence text are recorded in `assets/art/cards/ATTRIBUTION.md`. The card back,
licence text are recorded in `assets/resources/cards/ATTRIBUTION.md`. The card back,
table surface and UI chrome are not in that set and are authored for this project.
## 2026-09-13 · Presentation · The screen renders state, it does not replay events
The rules emit an event stream, which invites an animation queue that replays it.
**Decision.** `GameScreen.render(state)` lays the whole table out from the current
state and tweens every card node to its new place. A card node stays bound to its
`Card` for as long as that card is visible.
**Why.** "The six of clubs moved from my hand to the table" then needs no special
case — it is the same node arriving at a new position. An event-driven queue has
to choreograph every transition by hand and desynchronises the moment one case is
missed. The event stream is still there for sound and for one-off flourishes.
## 2026-09-13 · Presentation · Card art lives in the `resources` bundle
The first attempt gave `CardLibrary` a `SpriteAtlas` reference to the auto-atlas
(`cards.pac`) and asked it for frames by name. The build came out with no card
textures at all.
**Decision.** The 36 faces and the back live in `assets/resources/cards` and are
loaded with `resources.loadDir`. `Bootstrap` preloads the folder in the loader
scene, so the lobby never waits.
**Why.** A `.pac` is a build-time packing instruction, not a runtime asset: it
packs whatever sprite frames the build already pulled in, and it cannot be loaded
and queried by name. Nothing referenced the individual frames, so nothing was
packed. The `.pac` still earns its keep — all 37 sprites end up in one 2048²
texture, so the whole table costs one draw call.
## 2026-09-13 · Presentation · Button clicks are wired in code
**Decision.** Buttons are exposed as `@property(Button)` and subscribed to in
`onLoad` rather than through the scene's `clickEvents` list.
**Why.** The wiring stays visible in the source, and renaming a handler becomes a
compile error instead of a button that silently stops working. (The editor tool
server also cannot write array-typed properties, which is how `clickEvents` is
stored — so this was the only option available to automation anyway.)
## 2026-09-13 · Presentation · Interface text is English, collected in one file
**Decision.** Every player-visible string is in
`assets/scripts/ui/common/Strings.ts`, in English.
**Why.** The specs, the code and the docs are all in English, and localisation is
out of scope for iteration 1. Keeping the strings together means switching
language — or adding one — is a change to that one file rather than a hunt
through scenes and components. Worth revisiting before release, given the game
is *durak*.
## 2026-09-13 · Presentation · One tap is the whole interaction
**Decision.** Tapping a card plays it. When defending, the attack being answered
is worked out from the card rather than selected separately. The logic lives in
`core/rules/intent.ts`, not in the component.
**Why.** Select-then-target doubles the taps for no gain, because the serialised
rules leave only one unanswered attack at a time. Putting it in the core means
the one piece of interface logic that can silently reject a legal move is covered
by headless tests, including a property test that it never proposes an action the
rules would refuse.
+40 -22
View File
@@ -63,32 +63,50 @@ progress. The Cocos layer only renders state and turns taps into actions.
- [x] Import into `assets/art/`, configure sprite frames and atlasing
- [x] Remove consumed source art from `local/`, record attribution/licence
### M5 — Scenes and bootstrap `[ ]`
- [ ] `loader` scene: module initialisation, then transition to `lobby`
- [ ] `lobby` scene: New Game button, statistics readout
- [ ] Canvas / resolution policy and a reusable safe-area-aware layout root
### M5 — Scenes and bootstrap `[x]`
- [x] `loader` scene: module initialisation, then transition to `lobby`
- [x] `lobby` scene: New Game button, statistics readout
- [x] Canvas / resolution policy and a reusable safe-area-aware layout root
### M6 — Game screen `[ ]`
- [ ] `Card` prefab, face/back flipping, sizing
- [ ] Hand layout (fan), table layout (attack/defence pairs), deck and trump display
- [ ] Deal, attack, defend, take and discard animations driven by core events
- [ ] Tap/drag input producing core actions; illegal moves visibly rejected
- [ ] Bot acts with human-readable pacing
### M6 — Game screen `[x]`
- [x] `Card` prefab, face/back flipping, sizing
- [x] Hand layout (fan), table layout (attack/defence pairs), deck and trump display
- [x] Deal, attack, defend, take and discard animations driven by core events
- [x] Tap/drag input producing core actions; illegal moves visibly rejected
- [x] Bot acts with human-readable pacing
### M7 — Match flow `[ ]`
- [ ] Result overlay (win / lose), stats written through the savegame module
- [ ] Return to lobby; start another match without a scene leak
- [ ] Optional: surrender / leave match
### M7 — Match flow `[x]`
- [x] Result overlay (win / lose), stats written through the savegame module
- [x] Return to lobby; start another match without a scene leak
- [x] Leave-match button, which ends the match as a loss
### M8 — Responsive and touch pass `[ ]`
- [ ] Verify layout from 4:3 to 21:9, portrait
- [ ] All interactive elements meet a minimum tap size
- [ ] Editor preview screenshots at the extreme aspect ratios
### M8 — Responsive and touch pass `[~]`
- [x] Fit-width canvas, safe-area root, widget-stretched background
- [x] Every interactive element authored at or above the 120-unit minimum
(buttons 330×140 and 560×150; hand cards expose ~128 units each)
- [x] Vertical positions kept inside the 4:3 crop
- [ ] **Blocked:** seen at the extreme aspect ratios. Needs a machine that can
actually run the build — see "What is and is not verified" in
[TECHNICAL.md](TECHNICAL.md)
### M9 — Build verification and hand-off `[ ]`
- [ ] Web-mobile build runs end to end
- [ ] Android/iOS build settings documented (ASTC per ART.md)
- [ ] README / TECHNICAL.md final pass
### M9 — Build verification and hand-off `[~]`
- [x] `web-mobile` build completes clean; command recorded in TECHNICAL.md
- [x] Card art reaches the build and packs into a single 2048² atlas
- [x] Every component reference in the scene verified populated
- [ ] **Blocked:** the build seen running. The browser in this environment falls
back to a software renderer that cannot start the engine's main loop
- [ ] Android/iOS build settings (ASTC per ART.md)
- [ ] README
### Known follow-ups
- The default skybox cubemap (~1.1 MB) still reaches the build. `skybox.enabled`
is off in both scenes, but the scene keeps its `_envmapHDR` reference and the
builder follows it. The editor tool server cannot write a null reference;
clearing the field in the Inspector by hand would do it.
- Nothing verifies the presentation layer automatically. The obvious next step is
a smoke test that boots the scene headlessly and asserts the card nodes land
where the layout says they should.
## Deliberately out of scope for iteration 1
+62 -10
View File
@@ -35,13 +35,13 @@ makes the rules and the save format testable without the engine.
```
assets/
scenes/
loader.scene module init, then → lobby
lobby.scene main menu; hosts the match UI
loader.scene module init and art preload, then → lobby
lobby.scene Canvas > Background, Safe > LobbyRoot | GameRoot
prefabs/
card.prefab one playing card, face or back
...
resources/
cards/ 36 faces + back + cards.pac, loaded by path
art/
cards/ 36 faces + back, packed into cards.pac (2048²)
ui/ table surface, nine-slice panels and buttons
scripts/
core/ PURE TS — no engine imports
@@ -55,9 +55,10 @@ assets/
IStorage + MemoryStorage, CocosStorage (engine)
app/ Bootstrap, ServiceLocator, SceneRouter
ui/
lobby/ lobby screen controller
game/ match screen: hand, table, deck, animations
common/ reusable widgets, safe-area root
MainFlow.ts owns both screens and moves between them
lobby/ LobbyScreen: statistics and the New Game button
game/ GameScreen, CardView, CardLibrary
common/ Theme (layout, palette, timings), Strings
tests/
core/ vitest specs against assets/scripts/core
support/ position fixtures and the state invariant checker
@@ -119,6 +120,29 @@ sits behind `IStorage`, so all of the save logic is testable headlessly;
falls back to an in-memory store when the device refuses to persist (private
browsing, a full quota) rather than taking the game down.
## The lobby scene
Both screens live in one scene, per ARCHITECTURE.md, so starting a match is a
change of visible root rather than a scene load:
```
Canvas (1080×1920, Canvas + MainFlow)
Camera orthographic, UI_2D only, clears to table green
Background table_bg, widget-stretched
Safe cc.SafeArea — everything tappable is inside it
LobbyRoot LobbyScreen: title, statistics panel, New Game
GameRoot GameScreen + CardLibrary (inactive until a match starts)
Deck / OpponentLabel / Message / CardLayer / ActionBar / QuitButton
ResultOverlay dimmer, result panel, Back
```
`GameScreen` renders from the current `GameState` rather than replaying the
event stream — see docs/DECISIONS.md. Card nodes are pooled and stay bound to
their `Card` while it is visible, so movement is a tween to a new position.
Buttons are `@property(Button)` references subscribed in `onLoad`; the scene's
`clickEvents` lists are deliberately empty.
## Conventions
- TypeScript, 4-space indent, `PascalCase` for types, `camelCase` for members,
@@ -183,10 +207,38 @@ matching `Card.assetName` — that string is the only contract between the rules
core and the art.
Licence: the faces are LGPL-3.0 and attribution is mandatory. See
[`assets/art/cards/ATTRIBUTION.md`](../assets/art/cards/ATTRIBUTION.md), which
[`assets/resources/cards/ATTRIBUTION.md`](../assets/resources/cards/ATTRIBUTION.md), which
also explains what would have to change to drop the dependency.
### Builds
Web: `web-mobile` template. Mobile: ASTC textures per [ART.md](ART.md), PNG for
web.
A headless build, which is what CI would run:
```bash
"C:/ProgramData/cocos/editors/Creator/3.8.8/CocosCreator.exe" --project "C:/Work/fool-cardgame" --build "platform=web-mobile;debug=true;startScene=<loader.scene uuid>"
```
It writes to `build/web-mobile` in about 40 seconds. Two caveats: it starts a
second editor instance, so it competes with a running editor for
`temp/logs/project.log` and can fail with a duplicate-class error — close the
editor, or build from its Build panel. And `startScene` must be passed, or the
build has no launch scene and stops on the splash.
Mobile: ASTC textures per [ART.md](ART.md), PNG for web.
### What is and is not verified
The rules, the bot and the save format are covered by `npm test` and are
verified. The presentation layer is verified only as far as this environment
allows: the project builds clean, every component reference in the scene is
populated, and all 37 card sprites pack into one 2048² texture.
It has **not** been seen running. The browser available here falls back to a
software renderer that cannot start the Cocos main loop (`totalFrames` stays at
0), so no screenshot of the actual game was possible. To check it by eye, open
the project in Cocos Creator and press Preview, or serve `build/web-mobile` over
HTTP — it is a static folder and needs no server features:
```bash
npx http-server build/web-mobile -p 8123 -c-1
```