files-tcg/gameplay-plan.md
Forrest Church 1436ecf293 plans
2026-10-01 19:23:59 -04:00

254 lines
14 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Gameplay Plan: Files TCG Table and Presentation
_Prepared 2026-10-01 from `gameplay.md`, against the Godot project in `files-game/`._
Companion document: **`ui-plan.md`**, which owns the shared design foundation (tokens, fonts, the
chamfered StyleBox, the panel-geometry constant). **Its Phase 0 is a prerequisite for everything
here** — read §2–3 of that document first.
## 1. Why
`godot-plan.md` §10 records M1 (engine), M2 (table slice) and M3 (all Set 1 cards + greedy bot) as
done and conformance-clean — 1,100 traces, 1.68 M steps matching the TypeScript reference exactly.
What is not done is **M4 Presentation**. `gameplay.md` is, almost line for line, a request to build
M4 with the art direction settled.
Three concrete problems:
- **Cards are unreadable, measurably.** The hand renders at ~**153 × 215 px** on screen
(`HAND_DISTANCE = 9.0`, fov 45, at the 1600 × 900 base), and the inspector renders a 750 × 1050
card face into a **150 × 210** `TextureRect`. They are the same size, which is why neither works.
`godot-plan.md` §4 promises *"Hovering a card shows it large (right-click pins it)"* — never
built; right-click is Cancel.
- **The world is a physical tabletop, not cyberspace.** A suede-fabric playmat on a 64 × 1 × 52
dark-wood table. The cards are a chamfered neon HUD. The two do not look related.
- **Nothing is animated.** There are **five tween calls in the whole project**: `Card3D.glide()`
and `GameTable._place_camera()`. One generic 0.28 s glide serves draw, play and discard alike.
Damage and capture pop-ups are fired by **regex-matching log text** in
`scenes/game.gd:_pop_new_lines()` — so every reworded log line is a silently broken animation.
There is no engine event stream, so the table cannot know what actually happened.
**Outcome:** a table that reads as cyberspace, a hand you can actually read, firewalls that look
like hardware, and a game that acts itself out.
## 2. Decisions taken
| Question | Decision |
| --- | --- |
| World look | **Keep the 3D tabletop** — `playmat.glb`, seat/top camera, `Card3D`. Restyle the surface to dark glass with a neon grid inlay, black void + grid horizon, chamfered tiles. |
| Card legibility | Enlarge the 2D inspector **and** add a hand-focus mode. |
| Firewalls | Procedural RJ45 port with emissive LEDs. No custom model. |
| Animation | Port `s.events` per `godot-plan.md` §3 with a presenter queue. |
| Owner colours | Keep Okabe–Ito `#56b4e9` / `#e69f00`; add a stripe/dot pattern cue; cyan is chrome only. |
Colours used below come from `ui-plan.md` §2. The ones this plan needs: `bg #05080a`,
`accent #22d3ee`, `accent_dk #0e6b78`, owner `#56b4e9` / `#e69f00`, and a **22 px-at-750 px
chamfer**, i.e. ~3 % of the shorter edge.
The cards already use a gold **edge connector** bus to mean *"hardware plugs in here"* — so
firewalls-as-ethernet-ports (§B4) extends an established visual vocabulary rather than inventing one.
## 3. The work
### B1. The cyberspace table
`GameTable._build_room()` (`table/game_table.gd:101-146`) builds a `WorldEnvironment` with bg
`Color(0.035, 0.035, 0.045)`, ambient 0.85, filmic tonemap and **glow already enabled** at
intensity 0.4 / HDR threshold 1.2 — the bloom foundation exists. Plus a sun at energy 1.35 and a
64 × 1 × 52 dark-wood `BoxMesh` table top under the mat.
- Black void background with a neon-blue grid horizon; drop or sink the wood table top.
- Replace `assets/playmat.tres` with a dark-glass grid material. **The swap is contained:** that
`.tres` is a `StandardMaterial3D` bound in exactly one place —
`table/playmat.tscn`'s `surface_material_override/0` on `Plane_003`. Point a new `ShaderMaterial`
+ `playmat.gdshader` at that one line and the mat's look becomes a shader parameter rather than a
texture. The three suede maps (~3.5 MB) fall out of use.
- The old material carries `uv1_scale (2.284, 1.903, 1)` and `uv1_offset (0.908, 0, 0)`. Derive
the grid spacing from `BoardLayout.MAT_SIZE` (18.288 × 15.24) and the tile pitch instead, so the
grid **lines up with the locations** rather than with the old UVs.
- Raise glow once emission is the primary light source.
### B2. Chamfer the location tiles
`tile.gdshader` is a 29-line rounded-rect SDF with `radius = 0.2` and `instance uniform`
`fill_color` / `edge_color` / `glow` already in place.
Swapping the rounded-rect SDF for a **chamfered octagon SDF** is roughly a five-line change that
instantly matches the cards' chamfer across all 15 locations **and** all 14 printed card spots,
which share the same shader. **This is the highest ratio of visual payoff to diff size in either
plan — do it first.**
Add the **stripe/dot owner pattern** here too, as one more instance uniform. That is what lets
owner identity survive beside cyan chrome (`ui-plan.md` §2).
On the "large play spaces" note in `gameplay.md`: tiles are ~`5.53 × 2.06` units, about **4.3 cards
wide**. Keeping that footprint was accepted. Integrating it means making the tile read as a
*socket* — chamfered frame, corner ticks, microtext label, dim interior — rather than a grey slab.
### B3. Make the cards readable
Three levers, all already instrumented:
1. **The inspector.** `ui/hud.gd:189-194` is a `150 × 210` `TextureRect` fed by `Hud._art()`
(`:624-628`, cached in `_art_cache`). Grow it substantially; let the text panel scroll beside or
below it. Pure reuse — the full-resolution 750 × 1050 face is already loaded.
2. **Hand focus mode.** `GameTable._layout_hand()` (`:837-864`) lays the hand as a flat row
parented to the `Camera3D`. Add a mode — mouse to the bottom edge, or a held key — that expands
the hand into a large, legible 2D row drawn from the same textures, clickable, carrying the
salvage chip from `ui-plan.md` §A6. Reuse `Hud._art()`.
3. **Hover lift already exists** (`:837`, `y += CARD_SIZE.y * 0.42`). Keep it as the at-rest cue.
Also fix the at-rest case: `HAND_SHOWN = 0.62` behind a 150 px bottom panel reserve is why only a
sliver shows. Retune `HAND_SHOWN` and `HAND_DISTANCE` (`:21-22`) once `ui-plan.md` §0.4 lands —
not before, since the reserve is one of the numbers that moves.
### B4. Firewalls as RJ45 ports
`_make_gate()` (`table/game_table.gd:249-291`) builds a `PlaneMesh` diamond plus a `BoxMesh` wall
(`1 × 1 × 0.14`). `_sync_gates()` (`:461-484`) scales it by level (`h = 0.22 + 0.2 * level`), tints
it from `FIREWALL_COLORS`, and pins a `"Lv N"` 2D tag.
Replace with a procedural socket: a chamfered port body on the gateway, **emissive LEDs encoding
the level**, and a plug-in animation on place or upgrade. Scale reference: 1 unit = 5 cm, a card is
1.27 × 1.778 units, the gateway diamond is 0.34 × 0.34.
Two engine facts constrain the design:
- **Max level is `rules.firewallCost.size()`**, not a hardcoded 3 (`engine/engine.gd:619`; costs
default `[2, 4, 8]`). `FIREWALL_COLORS` hardcodes three entries and `_sync_gates` clamps with
`mini(...)`. Drive the LED count from the rules instead, or a rule variant silently caps the display.
- **Firewalls have no HP.** They are only placed, upgraded, or cleared for cost
(`engine/engine.gd:811-817`), and clearing is a *purchase* available to either player — there is
no free removal. So there is no damage state to show. The animation vocabulary is
**plug in / swap up / unplug**, not break.
Keep it legible in both the seat and top-down views; the LEDs are the level readout in top-down,
where the port body foreshortens away.
### B5. Engine events and the presenter
The foundation for every animation. Specified in `godot-plan.md` §3 and never ported — §10
confirms *"Not ported yet: engine events for animation (M4)"*.
- The engine appends **`s.events`**: `drew, moved, placed, combat started, rolled, rerolled,
damaged, destroyed, captured, Firewall changed, Bandwidth changed, counter changed`. Most zone
changes already funnel through helpers in `engine/state.gd` (`to_hand`, `to_discard`,
`gain_bandwidth` at `:417`, `say` at `:58`), so emission lands in a handful of places.
- Filter per player via `events_for(s, p)`, mirroring what `State.log_for` already does for the log.
- A new presenter plays them **in order**, then snaps the table to `view_for(s, you)`. That
ordering is the safety invariant from §3: *a missed or mis-drawn animation never leaves the table
showing the wrong state.* It composes cleanly with `GameTable.sync()` being an idempotent
full-resync and `Card3D.glide()` early-returning on an unchanged goal.
- This **retires `scenes/game.gd:_pop_new_lines()`** (`:137-164`), which infers animations by
substring-matching log text (`" captures "`, `" wins the roll"`, `"Tie,"`, `"destroyed"`) plus a
regex.
> **Conformance hazard — the one thing that will bite.** `tests/conformance.gd` fingerprints the
> state through `_body()` (`:230-235`), which shallow-duplicates and erases `defs` and `log`.
> Adding an `events` key changes that hash and **fails all 1,100 traces at once**. `_compare()`
> (`:211`) also runs the *decider's view* through the same `_body()`, so the leak would hit twice.
>
> **The whole fix is one line** — add `b.erase("events")` to `_body()`. That covers the state md5
> and the view md5 together and leaves the per-line log check alone. `godot-plan.md` §3 already
> rules that events "stay out of conformance, because TS doesn't have them". **Do it in the same
> commit that adds the key.**
### B6. The animation language
`gameplay.md` asks for flashy, warped speed trails on a **rush in → slow hold/drift → rush out**
curve. The current state: five tween calls total — `Card3D.glide()` (`GLIDE_TIME = 0.28`,
`TRANS_CUBIC`/`EASE_OUT`) and `GameTable._place_camera()` (0.45 s, `EASE_IN_OUT`). No particles
anywhere, no `AnimationPlayer`.
Build the curve as a reusable helper beside the presenter, driving: card movement **per event kind**
(a draw should not look like a discard), firewall plug-in, capture, damage, and the log drawer from
`ui-plan.md` §A3.
Speed trails suit the existing `card.gdshader`, which already carries `instance uniform highlight`
(rgb + strength) and a rim-glow term — flashes and trails can ride those **without duplicating
materials**, which is the constraint `godot-plan.md` §4 sets for card rendering.
> **Pacing is a real risk, not a detail.** A game asks each player ~367 decisions and opens ~43
> response windows. `godot-plan.md` §4 requires an animation-speed setting **including instant**,
> and a click that skips the current animation. `Card3D.instant` — a static kill-switch set by
> `tests/table_smoke.gd:46` — already exists and must keep working, or the UI test hangs.
## 4. Order
```
ui-plan Phase 0 (prerequisite)
│
├──▶ B2 ──▶ B1 (cheap visual direction first)
│
├──▶ B3 ──▶ ui-plan A6 (inspector + hand row carry the salvage chip)
│
└──▶ B5 ──▶ B6 ──▶ B4
└──▶ ui-plan A5 (bandwidth delta)
```
1. **`ui-plan.md` Phase 0 first, always.**
2. **B2 then B1.** The chamfered tile SDF is a five-line change that sets the visual direction
before the heavier world and material work.
3. **B5 before B6.** Events gate every real animation.
4. **B4 last of the 3D work** — most self-contained, and it benefits from B6's vocabulary.
**Hazards.**
- Doing **B6 before B5** means writing animations against log-string matching, then rewriting them.
- Adding **`s.events` without the `_body()` strip** fails all 1,100 traces simultaneously.
- Retuning **`HAND_SHOWN` before `ui-plan.md` §0.4** means tuning against a panel reserve that is
about to change.
## 5. Verification
Custom harness — no GUT, no gdUnit4. Each test is a standalone `extends SceneTree` script run via
`--script`, passing on exit code plus `Util.errors` being empty.
Godot is **not on `PATH`** here. It is 4.7.2 stable at
`/Applications/Godot.app/Contents/MacOS/Godot`, matching the project's 4.7 target.
```sh
export GODOT=/Applications/Godot.app/Contents/MacOS/Godot
cd /Users/forrestchurch/Trog-Chamber/files-game
# Run this FIRST — see the note below.
"$GODOT" --headless --import
# Rules unchanged. THE gate for B5. tests/traces/ is gitignored and currently empty:
tools/make_traces.sh # needs the TS sim; SIM env points at files-tcg/sim
"$GODOT" --headless --script res://tests/conformance.gd -- --check
"$GODOT" --headless --script res://tests/table_smoke.gd -- --games 20
"$GODOT" --headless --script res://tests/smoke.gd -- --games 50
"$GODOT" --headless --script res://tests/bot_speed.gd # bot must stay off the main thread
# Look harness — needs a display, so no --headless.
"$GODOT" --script res://tests/screenshot.gd -- --out /tmp/shot.png
"$GODOT" --script res://tests/screenshot.gd -- --top --out /tmp/shot-top.png
```
> **Import before testing.** `.godot/` is gitignored and this checkout's `.godot/imported/` holds
> 13 entries with **no entry for `card.glb` or `playmat.glb`**. Unimported, `$Model` resolves to
> `null` and `Card3D._ready()` (`table/card_3d.gd:70`) throws on every card spawned;
> `tests/table_smoke.gd` then reports a meaningless *"35 unreachable move kinds"*, because picking
> needs collision bodies that `_ready()` never added. That number is an artifact, not a
> reachability bug — do not go hunting it. The pass covers 274 card PNGs plus two `.glb`s.
>
> `tests/smoke.gd` is green as of writing: 20/20 games clean in 37 s.
Compare screenshots against `20261001_171420.png` (the current state) and the card faces in
`files-game/assets/cards/` (the target). Then play a full game and confirm: the hand is legible at
rest **and** in focus mode; a firewall plugs in and shows its level; a draw does not look like a
discard; captures and damage read without the log; and the animation-speed setting still has a
working **instant** option.
**Guardrails.**
- `camelCase` dictionary keys and action-type strings are the TypeScript wire format
(`s.firewalls`, `installHardware`, `bandwidthFromSalvage`). Renaming any fails every trace.
Do not tidy them.
- `tests/table_smoke.gd` reaches into `scenes/game.gd` privates (`_play`, `_select`, `_paused`,
`moves`) and `GameTable.screen_point_for`. Restructuring `game.gd` breaks the only automated UI
test — keep those names.
- `scenes/game.gd` must not call `Odds` while the bot thinks; its static caches are unlocked.
- Keep `Card3D.instant` working as a global animation kill-switch.
- `engine/` and `match/` use **no nodes or scenes** (`godot-plan.md` §3) so they run headless, on
the bot thread, and later on a PvP server. The presenter in B5 must live outside them.