Skip to content

feat(ui): new-game screen — choose difficulty, then press Start (#304) - #312

Merged
LightAxe merged 5 commits into
mainfrom
feat/new-game-screen
Sep 21, 2026
Merged

LightAxe merged 5 commits into
mainfrom
feat/new-game-screen

Conversation

@LightAxe

@LightAxe LightAxe commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

Main-side part of #304 (items 1–2 and the Start button). The opponent picker and Jev options (items 3–4) stay on feat/jev-opponent (#298), which rebases onto this; the layout exposes an opponentSlot between the difficulty rows and Start for it.

What changed

  • Options first, one Start button last. The boot overlay is now a "New Game" screen: three radio-style difficulty rows with a visible selected state (default Normal), a single green Start game button, and "Enter also starts". Nothing above Start starts a round; clicking a row only changes the selection.
  • Each tier says what it changes, derived from the [Easy, Normal, Hard] triplets in src/sim/constants.ts and pinned by a unit test so a retune surfaces in review:
    • Easy — "Enemy queen waits 25% longer between eggs. Enemy needs 10 fighters to arm, 18 to invade. Spider gets hungry 90 s after a meal."
    • Normal — "The reference tuning. Enemy needs 8 fighters to arm, 15 to invade. Spider gets hungry 60 s after a meal."
    • Hard — "Enemy queen waits 25% less between eggs. Enemy needs 6 fighters to arm, 12 to invade. Spider gets hungry 45 s after a meal."
    • Subtitle: "Only the enemy colony and the spider change — your colony plays the same at every tier." (verified: no difficulty-indexed constant touches the player colony.)
  • Last-used difficulty persists via src/platform/settings.ts (stored on Start; corrupt or missing values fall back to Normal; the save-fallback paths that boot without the screen also honour it).
  • Single dispatcher for every boot overlay. Rows, Start, the SavePrompt buttons and the game-over Restart button no longer carry per-object pointer handlers; the scene-level handler hit-tests them in overlay order. This closes two dispatch-order bugs found in review: a Start click falling through to the HUD chain after the round booted, and the click that opens the screen (Restart / New Game) being replayed onto the freshly drawn rows.
  • Enter ignores editable targets, so on the website embed Enter inside a host-page input cannot start a round.
  • Layout rects live in src/render/boot-overlay-layout.ts (newGameScreenLayout is a pure function of the layout context; the section stack re-centres and clamps at the top) and are mirrored in tests/helpers/geometry.ts.
  • Playwright: one shared settleToPlaying(page, tier, { via: 'mouse' | 'touch' }) helper replaces the per-spec boot loops; new tests/new-game-screen.spec.ts covers default Normal, Hard-click-does-not-start, Start boots Hard, Enter starts, persistence across reload, unknown stored tier → Normal, Enter in a host input, no HUD fall-through after Start, and the opening-click replay cases (New Game inside the Hard/Normal bands with a persisted Easy; Restart via a new DEV-only __phase9_test.forceGameOver() that calls the extracted enterGameOver). The smoke underground screenshot now really toggles the view.

Render-only: nothing under src/sim, no simVersion bump.

Verification

Closes the main-side acceptance items of #304; the Jev items follow on #298.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh

Summary by CodeRabbit

  • New Features

    • Added a two-step New Game screen for selecting difficulty before starting a round.
    • Added Easy, Normal, and Hard difficulty descriptions and gameplay tuning details.
    • The selected difficulty is remembered and restored on future starts.
    • Start can be confirmed by clicking the button or pressing Enter.
    • New Game layout adapts to different screen sizes and supports mouse and touch input.
  • Bug Fixes

    • Invalid or missing saved difficulty values now safely default to Normal.
    • Improved overlay interaction handling to prevent accidental actions behind dialogs.

LightAxe and others added 5 commits September 21, 2026 11:06
Add `difficulty` to the render-side settings blob so the new-game screen
can reopen on the tier the player last started a round with. Default
Normal; the stored value is accepted only when it is exactly one of the
three tier names, otherwise it falls back to the default without touching
its siblings. A pre-#304 blob without the key loads as before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
…button (#304)

Options first, one Start button last. The boot-time "Choose Difficulty"
overlay becomes a "New Game" screen: three radio-style rows (Easy / Normal
/ Hard, default Normal, visible selected state) each carrying a
plain-language line about what the tier changes, and a single "Start game"
button. Only Start — or Enter — begins the round; clicking a row just moves
the selection. The screen reopens on the persisted last-used tier
(settings.difficulty), which is written on Start.

- boot-overlay-layout.ts: the screen is a section stack (title →
  difficulty → opponent slot → start) computed purely from the
  LayoutContext, centered as a group (#213/#238 discipline). The opponent
  slot has height 0 on main; the Jev opponent picker (PR #298) inserts its
  section by passing the height it needs, and nothing else moves.
- difficulty-copy.ts: the row copy DERIVES its numbers from the sim's
  [Easy, Normal, Hard] triplets (egg-interval numerator, WarFooting /
  Invading fighter thresholds, spider hunger threshold at 50 ms/tick), so
  it cannot drift from the constants; the wording is pinned by a test so a
  retune shows up in review.
- ui-scene.ts: re-render-in-place rows (the survey overlay's shape), an
  Enter binding scoped to the screen, `__phase9_ui.selectedDifficulty`
  for Playwright, and a scene-level pointer guard so clicks on the boot
  overlays no longer fall through to the HUD chain beneath the scrim.
- game-scene.ts: onStart callbacks (persist, then bootFresh) on both the
  fresh-boot and restart paths; the SavePrompt path is unchanged. The
  dev-only `__phase9_test.getRoundDifficulty()` lets a spec prove Start
  booted the selected tier.

Render-only: no sim change, no simVersion bump.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
…add #304 spec

Every spec that starts a round used to carry its own "poll-click Normal"
loop. The screen is now two steps (pick a row, press Start), so the loop
lives once in tests/helpers/boot.ts (settleToPlaying, plus the
activeOverlay / bootScreen / selectedDifficulty reads) and the four
boot-flow specs — phase-09-session, menu-and-dialog, survey-overlay,
touch-smoke — use it. The helper also refuses to mistake the pre-overlay
frame (activeOverlay defaults to 'none' before any boot overlay has been
shown) for Playing.

Rects come from tests/helpers/geometry.ts, which evaluates the pure
layout function at the default layout (DIFFICULTY_ROW_RECTS,
NEW_GAME_START_RECT) — no inline pixels in specs.

New tests/new-game-screen.spec.ts: default selection is Normal; a row
click moves the selection without starting; Start boots the selected
tier; Enter starts on the current selection; the last-used tier persists
across a reload; an unknown stored tier falls back to Normal.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
Adversarial-review findings on the #304 screen, all render/test-side:

- Dispatch: the rows and the Start button no longer carry per-object
  pointerdown handlers. Phaser fires those BEFORE the scene-level handler,
  so a Start handler that hid the screen let the very same dispatch reach
  the HUD chain beneath the scrim with the screen already gone (harmless
  at today's geometry, the speed/pause widget once the Jev opponent
  section pushes Start down). Hit-testing now lives in the scene-level
  pointerdown handler (dispatchNewGameClick: Start → commit, row → select,
  else absorbed), the pause menu's rule. Regression assertion: after Start,
  speedMultiplier is still 1×, the view is the surface, no overlay is up.
- smoke.spec's "underground screenshot" was vacuous once the boot overlays
  absorbed clicks (both screenshots byte-identical): it now starts a round,
  clicks VIEW_TOGGLE and asserts activeView === 'underground' first.
- Copy precision: hungerTicks accrues only outside Feeding, so the line
  reads "Spider gets hungry N s after a meal" (clock starts when the meal
  ends); pinned strings updated.
- Negative coverage: Enter on a real Continue/New Game SavePrompt leaves it
  up (SCEN-04); the touch project drives the screen with page.touchscreen
  taps (settleToPlaying `via: 'touch'`) so the touch path is pinned.
- Website embed: the Enter Key handler ignores events typed into an input,
  textarea, select or contenteditable (the keydown bubbles to Phaser's
  window listener); e2e injects a host-page <input> and proves Enter there
  does not start a round while Enter on the game still does.
- Save-fallback paths (corrupt / pre-V22 / future-build save on Continue)
  boot fresh on the persisted tier instead of a hard-coded Normal; the
  bootFresh default parameter is gone so every caller states the tier.
- Stale "Choose Difficulty" comments in the specs updated.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
77d7062 moved the new-game screen's rows and Start onto the scene-level
pointerdown handler but left the GameOver "Restart" and SavePrompt
"Continue" / "New Game" buttons on per-object handlers. Those run BEFORE
the scene-level handler for the same pointer, and both Restart and New
Game synchronously OPEN the new-game screen — so the same click was then
hit-tested against the freshly built rows. Before 77d7062 objects created
mid-dispatch were not in Phaser's hit list, so this could not happen.
Confirmed: GAME_OVER_RESTART_RECT lies inside the Hard row (every Restart
selected Hard regardless of the persisted tier); SAVE_PROMPT_NEW_GAME_RECT
straddles the Normal/Hard rows.

Fix: the single-dispatcher rule now covers all three boot overlays. The
GameOver and SavePrompt buttons keep setInteractive() only; their
callbacks are captured at show time and dispatched by the scene-level
handler (dispatchGameOverClick / dispatchSavePromptClick, checked BEFORE
the new-game branch in recomputeActiveOverlay precedence), each branch
returning whether or not it hit a button — an opening click can never
reach the screen it opened.

Specs (tests/new-game-screen.spec.ts): with a persisted Easy (Start on
Easy → Save Now → reload), New Game clicked inside the Hard band and
inside the Normal band opens on Easy and stays there; GameOver Restart
(inside the Hard band) opens on Easy and Start then boots Easy. Game over
is reached deterministically through a dev-only __phase9_test.forceGameOver()
seam that drives the SAME render-side transition a terminal tick outcome
takes — the onTickOutcome body is extracted verbatim into
GameScene.enterGameOver(outcome); the sim is never touched. Band points
are derived from the exported rects (button ∩ row), so the test throws
rather than passing vacuously if a future layout removes the overlap.
GAME_OVER_RESTART_RECT is re-exported from tests/helpers/geometry.ts and
clickCanvasPoint added to tests/helpers/boot.ts.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
@LightAxe

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: LightAxe/subterrans/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 34b88f7b-1fa6-4ef0-9927-76715f8e7268

📥 Commits

Reviewing files that changed from the base of the PR and between 7089811 and 41fe231.

📒 Files selected for processing (16)
  • src/platform/settings.test.ts
  • src/platform/settings.ts
  • src/render/boot-overlay-layout.test.ts
  • src/render/boot-overlay-layout.ts
  • src/render/difficulty-copy.test.ts
  • src/render/difficulty-copy.ts
  • src/render/game-scene.ts
  • src/render/ui-scene.ts
  • tests/helpers/boot.ts
  • tests/helpers/geometry.ts
  • tests/menu-and-dialog.spec.ts
  • tests/new-game-screen.spec.ts
  • tests/phase-09-session.spec.ts
  • tests/smoke.spec.ts
  • tests/survey-overlay.spec.ts
  • tests/touch-smoke.spec.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Changes

Difficulty-based new-game flow

Layer / File(s) Summary
Persisted difficulty contract
src/platform/settings.ts, src/platform/settings.test.ts
Settings now store Easy, Normal, or Hard. Missing and invalid values load as Normal.
New-game layout and copy
src/render/boot-overlay-layout.ts, src/render/difficulty-copy.ts, src/render/*test.ts
New responsive geometry, tier rows, Start controls, and simulation-derived difficulty descriptions are added and tested.
UI commitment and round boot integration
src/render/ui-scene.ts, src/render/game-scene.ts
Row clicks change selection without starting. Start or Enter commits the tier, persists it, and boots the round. Fresh-boot fallbacks reuse the persisted tier. Overlay dispatch is centralized.
Shared boot helpers and browser coverage
tests/helpers/*, tests/*.spec.ts
Playwright helpers now support the two-step mouse and touch flow. Browser tests cover selection, keyboard handling, persistence, fallback behavior, overlay boundaries, and existing scenarios.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Player
  participant UIScene
  participant GameScene
  participant Settings
  Player->>UIScene: choose Easy, Normal, or Hard
  Player->>UIScene: press Start or Enter
  UIScene->>GameScene: commit selected difficulty
  GameScene->>Settings: save started difficulty
  GameScene->>GameScene: start round with selected difficulty
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: a new-game screen where users choose a difficulty and press Start.
Docstring Coverage ✅ Passed Docstring coverage is 97.67% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 43 functions across 16 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 41fe231ee9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@LightAxe
LightAxe merged commit 0f2a876 into main Sep 21, 2026
4 checks passed
@LightAxe
LightAxe deleted the feat/new-game-screen branch September 21, 2026 18:42
LightAxe added a commit that referenced this pull request Sep 22, 2026
…ce, Jev options only when selected (#304)

Items 3–4 of #304 on the Jev beta branch, rebuilt on main's new-game
screen (#312) instead of the old difficulty-buttons overlay: an explicit
Opponent section between Difficulty and Start, the Jev options shown only
once Jev is selected, and the free-text box captioned for whose orders
they are.

The screen, top to bottom, on a build with a Jev endpoint:

  Difficulty      (main's three radio rows, unchanged)
  Opponent        two radio-style rows with a one-liner each —
                  "Standard AI · The built-in rule-based enemy colony."
                  "Jev (beta) · TypeSafe's Jev model plays the enemy; you
                  can instruct it."
  Jev options     ONLY while the Jev row is selected: "Custom instructions
                  for Jev, your opponent" (+ n/300 counter), the four
                  standing-orders presets, and the free-text box
  Start game      (main's single Start; Enter also starts)

Defaults are Normal + Standard AI; nothing above Start starts a round.
On a build with no endpoint no section is drawn at all — the screen is
main's, pixel for pixel — so Standard AI is implied rather than shown
disabled (the plain-build specs pass with no geometry change).

- boot-overlay-layout.ts: the section is laid out INSIDE the stack's
  opponentSlot (opponentSectionH / opponentSectionLayout /
  newGameScreenWithOpponent), so it inherits the LayoutContext discipline
  and the stack re-centres around it. Its height follows the picker:
  caption + two 30 px rows collapsed, + caption line / presets / 46 px
  free-text rect expanded — 190 px, exactly what keeps the fully expanded
  stack inside the shipping canvas with NEW_GAME_STACK_MIN_TOP clear at
  both ends (pinned by a test). The old top-anchored opponentPickerLayout
  (and its hint "Set the opponent below first", moot now that rows do not
  start the game) is gone.
- opponent-copy.ts: the section's strings, pinned by a test that also
  guards each row's one-liner against wrapping.
- ui-scene.ts: the section draws from the same re-render-in-place path as
  the difficulty rows; ALL clicks dispatch through dispatchNewGameClick
  (Start → commit, difficulty row → select, opponent row → toggleKind,
  preset → selectPreset, else absorbed — no per-object pointer handlers).
  The free-text box is a DOM <textarea> from the shared overlay-field
  factory (keydown stops propagation, so Enter inside it never reaches
  the Enter-starts binding; the caption doubles as its aria-label), torn
  down on hide, on leaving the Jev row and on scene shutdown, and never
  part of the Phaser group so a re-render keeps focus and caret. A canvas
  click blurs it explicitly — Phaser preventDefault()s the canvas
  mousedown, so the browser would otherwise leave every later key in the
  box. commitNewGame reads the picker's config BEFORE hiding.
  __phase9_ui.selectedOpponent is published alongside selectedDifficulty.
  The n/300 counter follows the drawn caption rather than sitting at the
  column's right edge, where the HUD view-toggle shows through the scrim.
- opponent-picker-state.ts: re-selecting the lit preset returns the same
  state object, so the overlay's identity check skips a needless rebuild.
- game-scene.ts: dev-only __phase9_test.getRoundOpponent() so a spec can
  prove Start booted the selected opponent.
- tests: geometry.ts exports the Jev-build rect sets for BOTH picker
  states (the stack moves between them); boot.ts gains selectedOpponent;
  jev-opponent.spec.ts pins the defaults, options hidden until Jev,
  the caption, nothing-above-Start-starts, Enter inside the box not
  starting, persistence across reload, and textarea teardown.

Render-only: no sim change, no simVersion bump; settings persistence
(opponent / jevOrders) is unchanged from the branch.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
LightAxe added a commit that referenced this pull request Sep 22, 2026
…ce, Jev options only when selected (#304)

Items 3–4 of #304 on the Jev beta branch, rebuilt on main's new-game
screen (#312) instead of the old difficulty-buttons overlay: an explicit
Opponent section between Difficulty and Start, the Jev options shown only
once Jev is selected, and the free-text box captioned for whose orders
they are.

The screen, top to bottom, on a build with a Jev endpoint:

  Difficulty      (main's three radio rows, unchanged)
  Opponent        two radio-style rows with a one-liner each —
                  "Standard AI · The built-in rule-based enemy colony."
                  "Jev (beta) · TypeSafe's Jev model plays the enemy; you
                  can instruct it."
  Jev options     ONLY while the Jev row is selected: "Custom instructions
                  for Jev, your opponent" (+ n/300 counter), the four
                  standing-orders presets, and the free-text box
  Start game      (main's single Start; Enter also starts)

Defaults are Normal + Standard AI; nothing above Start starts a round.
On a build with no endpoint no section is drawn at all — the screen is
main's, pixel for pixel — so Standard AI is implied rather than shown
disabled (the plain-build specs pass with no geometry change).

- boot-overlay-layout.ts: the section is laid out INSIDE the stack's
  opponentSlot (opponentSectionH / opponentSectionLayout /
  newGameScreenWithOpponent), so it inherits the LayoutContext discipline
  and the stack re-centres around it. Its height follows the picker:
  caption + two 30 px rows collapsed, + caption line / presets / 46 px
  free-text rect expanded — 190 px, exactly what keeps the fully expanded
  stack inside the shipping canvas with NEW_GAME_STACK_MIN_TOP clear at
  both ends (pinned by a test). The old top-anchored opponentPickerLayout
  (and its hint "Set the opponent below first", moot now that rows do not
  start the game) is gone.
- opponent-copy.ts: the section's strings, pinned by a test that also
  guards each row's one-liner against wrapping.
- ui-scene.ts: the section draws from the same re-render-in-place path as
  the difficulty rows; ALL clicks dispatch through dispatchNewGameClick
  (Start → commit, difficulty row → select, opponent row → toggleKind,
  preset → selectPreset, else absorbed — no per-object pointer handlers).
  The free-text box is a DOM <textarea> from the shared overlay-field
  factory (keydown stops propagation, so Enter inside it never reaches
  the Enter-starts binding; the caption doubles as its aria-label), torn
  down on hide, on leaving the Jev row and on scene shutdown, and never
  part of the Phaser group so a re-render keeps focus and caret. A canvas
  click blurs it explicitly — Phaser preventDefault()s the canvas
  mousedown, so the browser would otherwise leave every later key in the
  box. commitNewGame reads the picker's config BEFORE hiding.
  __phase9_ui.selectedOpponent is published alongside selectedDifficulty.
  The n/300 counter follows the drawn caption rather than sitting at the
  column's right edge, where the HUD view-toggle shows through the scrim.
- opponent-picker-state.ts: re-selecting the lit preset returns the same
  state object, so the overlay's identity check skips a needless rebuild.
- game-scene.ts: dev-only __phase9_test.getRoundOpponent() so a spec can
  prove Start booted the selected opponent.
- tests: geometry.ts exports the Jev-build rect sets for BOTH picker
  states (the stack moves between them); boot.ts gains selectedOpponent;
  jev-opponent.spec.ts pins the defaults, options hidden until Jev,
  the caption, nothing-above-Start-starts, Enter inside the box not
  starting, persistence across reload, and textarea teardown.

Render-only: no sim change, no simVersion bump; settings persistence
(opponent / jevOrders) is unchanged from the branch.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
LightAxe added a commit that referenced this pull request Sep 22, 2026
…ce, Jev options only when selected (#304)

Items 3–4 of #304 on the Jev beta branch, rebuilt on main's new-game
screen (#312) instead of the old difficulty-buttons overlay: an explicit
Opponent section between Difficulty and Start, the Jev options shown only
once Jev is selected, and the free-text box captioned for whose orders
they are.

The screen, top to bottom, on a build with a Jev endpoint:

  Difficulty      (main's three radio rows, unchanged)
  Opponent        two radio-style rows with a one-liner each —
                  "Standard AI · The built-in rule-based enemy colony."
                  "Jev (beta) · TypeSafe's Jev model plays the enemy; you
                  can instruct it."
  Jev options     ONLY while the Jev row is selected: "Custom instructions
                  for Jev, your opponent" (+ n/300 counter), the four
                  standing-orders presets, and the free-text box
  Start game      (main's single Start; Enter also starts)

Defaults are Normal + Standard AI; nothing above Start starts a round.
On a build with no endpoint no section is drawn at all — the screen is
main's, pixel for pixel — so Standard AI is implied rather than shown
disabled (the plain-build specs pass with no geometry change).

- boot-overlay-layout.ts: the section is laid out INSIDE the stack's
  opponentSlot (opponentSectionH / opponentSectionLayout /
  newGameScreenWithOpponent), so it inherits the LayoutContext discipline
  and the stack re-centres around it. Its height follows the picker:
  caption + two 30 px rows collapsed, + caption line / presets / 46 px
  free-text rect expanded — 190 px, exactly what keeps the fully expanded
  stack inside the shipping canvas with NEW_GAME_STACK_MIN_TOP clear at
  both ends (pinned by a test). The old top-anchored opponentPickerLayout
  (and its hint "Set the opponent below first", moot now that rows do not
  start the game) is gone.
- opponent-copy.ts: the section's strings, pinned by a test that also
  guards each row's one-liner against wrapping.
- ui-scene.ts: the section draws from the same re-render-in-place path as
  the difficulty rows; ALL clicks dispatch through dispatchNewGameClick
  (Start → commit, difficulty row → select, opponent row → toggleKind,
  preset → selectPreset, else absorbed — no per-object pointer handlers).
  The free-text box is a DOM <textarea> from the shared overlay-field
  factory (keydown stops propagation, so Enter inside it never reaches
  the Enter-starts binding; the caption doubles as its aria-label), torn
  down on hide, on leaving the Jev row and on scene shutdown, and never
  part of the Phaser group so a re-render keeps focus and caret. A canvas
  click blurs it explicitly — Phaser preventDefault()s the canvas
  mousedown, so the browser would otherwise leave every later key in the
  box. commitNewGame reads the picker's config BEFORE hiding.
  __phase9_ui.selectedOpponent is published alongside selectedDifficulty.
  The n/300 counter follows the drawn caption rather than sitting at the
  column's right edge, where the HUD view-toggle shows through the scrim.
- opponent-picker-state.ts: re-selecting the lit preset returns the same
  state object, so the overlay's identity check skips a needless rebuild.
- game-scene.ts: dev-only __phase9_test.getRoundOpponent() so a spec can
  prove Start booted the selected opponent.
- tests: geometry.ts exports the Jev-build rect sets for BOTH picker
  states (the stack moves between them); boot.ts gains selectedOpponent;
  jev-opponent.spec.ts pins the defaults, options hidden until Jev,
  the caption, nothing-above-Start-starts, Enter inside the box not
  starting, persistence across reload, and textarea teardown.

Render-only: no sim change, no simVersion bump; settings persistence
(opponent / jevOrders) is unchanged from the branch.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
LightAxe added a commit that referenced this pull request Oct 2, 2026
…ce, Jev options only when selected (#304)

Items 3–4 of #304 on the Jev beta branch, rebuilt on main's new-game
screen (#312) instead of the old difficulty-buttons overlay: an explicit
Opponent section between Difficulty and Start, the Jev options shown only
once Jev is selected, and the free-text box captioned for whose orders
they are.

The screen, top to bottom, on a build with a Jev endpoint:

  Difficulty      (main's three radio rows, unchanged)
  Opponent        two radio-style rows with a one-liner each —
                  "Standard AI · The built-in rule-based enemy colony."
                  "Jev (beta) · TypeSafe's Jev model plays the enemy; you
                  can instruct it."
  Jev options     ONLY while the Jev row is selected: "Custom instructions
                  for Jev, your opponent" (+ n/300 counter), the four
                  standing-orders presets, and the free-text box
  Start game      (main's single Start; Enter also starts)

Defaults are Normal + Standard AI; nothing above Start starts a round.
On a build with no endpoint no section is drawn at all — the screen is
main's, pixel for pixel — so Standard AI is implied rather than shown
disabled (the plain-build specs pass with no geometry change).

- boot-overlay-layout.ts: the section is laid out INSIDE the stack's
  opponentSlot (opponentSectionH / opponentSectionLayout /
  newGameScreenWithOpponent), so it inherits the LayoutContext discipline
  and the stack re-centres around it. Its height follows the picker:
  caption + two 30 px rows collapsed, + caption line / presets / 46 px
  free-text rect expanded — 190 px, exactly what keeps the fully expanded
  stack inside the shipping canvas with NEW_GAME_STACK_MIN_TOP clear at
  both ends (pinned by a test). The old top-anchored opponentPickerLayout
  (and its hint "Set the opponent below first", moot now that rows do not
  start the game) is gone.
- opponent-copy.ts: the section's strings, pinned by a test that also
  guards each row's one-liner against wrapping.
- ui-scene.ts: the section draws from the same re-render-in-place path as
  the difficulty rows; ALL clicks dispatch through dispatchNewGameClick
  (Start → commit, difficulty row → select, opponent row → toggleKind,
  preset → selectPreset, else absorbed — no per-object pointer handlers).
  The free-text box is a DOM <textarea> from the shared overlay-field
  factory (keydown stops propagation, so Enter inside it never reaches
  the Enter-starts binding; the caption doubles as its aria-label), torn
  down on hide, on leaving the Jev row and on scene shutdown, and never
  part of the Phaser group so a re-render keeps focus and caret. A canvas
  click blurs it explicitly — Phaser preventDefault()s the canvas
  mousedown, so the browser would otherwise leave every later key in the
  box. commitNewGame reads the picker's config BEFORE hiding.
  __phase9_ui.selectedOpponent is published alongside selectedDifficulty.
  The n/300 counter follows the drawn caption rather than sitting at the
  column's right edge, where the HUD view-toggle shows through the scrim.
- opponent-picker-state.ts: re-selecting the lit preset returns the same
  state object, so the overlay's identity check skips a needless rebuild.
- game-scene.ts: dev-only __phase9_test.getRoundOpponent() so a spec can
  prove Start booted the selected opponent.
- tests: geometry.ts exports the Jev-build rect sets for BOTH picker
  states (the stack moves between them); boot.ts gains selectedOpponent;
  jev-opponent.spec.ts pins the defaults, options hidden until Jev,
  the caption, nothing-above-Start-starts, Enter inside the box not
  starting, persistence across reload, and textarea teardown.

Render-only: no sim change, no simVersion bump; settings persistence
(opponent / jevOrders) is unchanged from the branch.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
LightAxe added a commit that referenced this pull request Oct 2, 2026
…ce, Jev options only when selected (#304)

Items 3–4 of #304 on the Jev beta branch, rebuilt on main's new-game
screen (#312) instead of the old difficulty-buttons overlay: an explicit
Opponent section between Difficulty and Start, the Jev options shown only
once Jev is selected, and the free-text box captioned for whose orders
they are.

The screen, top to bottom, on a build with a Jev endpoint:

  Difficulty      (main's three radio rows, unchanged)
  Opponent        two radio-style rows with a one-liner each —
                  "Standard AI · The built-in rule-based enemy colony."
                  "Jev (beta) · TypeSafe's Jev model plays the enemy; you
                  can instruct it."
  Jev options     ONLY while the Jev row is selected: "Custom instructions
                  for Jev, your opponent" (+ n/300 counter), the four
                  standing-orders presets, and the free-text box
  Start game      (main's single Start; Enter also starts)

Defaults are Normal + Standard AI; nothing above Start starts a round.
On a build with no endpoint no section is drawn at all — the screen is
main's, pixel for pixel — so Standard AI is implied rather than shown
disabled (the plain-build specs pass with no geometry change).

- boot-overlay-layout.ts: the section is laid out INSIDE the stack's
  opponentSlot (opponentSectionH / opponentSectionLayout /
  newGameScreenWithOpponent), so it inherits the LayoutContext discipline
  and the stack re-centres around it. Its height follows the picker:
  caption + two 30 px rows collapsed, + caption line / presets / 46 px
  free-text rect expanded — 190 px, exactly what keeps the fully expanded
  stack inside the shipping canvas with NEW_GAME_STACK_MIN_TOP clear at
  both ends (pinned by a test). The old top-anchored opponentPickerLayout
  (and its hint "Set the opponent below first", moot now that rows do not
  start the game) is gone.
- opponent-copy.ts: the section's strings, pinned by a test that also
  guards each row's one-liner against wrapping.
- ui-scene.ts: the section draws from the same re-render-in-place path as
  the difficulty rows; ALL clicks dispatch through dispatchNewGameClick
  (Start → commit, difficulty row → select, opponent row → toggleKind,
  preset → selectPreset, else absorbed — no per-object pointer handlers).
  The free-text box is a DOM <textarea> from the shared overlay-field
  factory (keydown stops propagation, so Enter inside it never reaches
  the Enter-starts binding; the caption doubles as its aria-label), torn
  down on hide, on leaving the Jev row and on scene shutdown, and never
  part of the Phaser group so a re-render keeps focus and caret. A canvas
  click blurs it explicitly — Phaser preventDefault()s the canvas
  mousedown, so the browser would otherwise leave every later key in the
  box. commitNewGame reads the picker's config BEFORE hiding.
  __phase9_ui.selectedOpponent is published alongside selectedDifficulty.
  The n/300 counter follows the drawn caption rather than sitting at the
  column's right edge, where the HUD view-toggle shows through the scrim.
- opponent-picker-state.ts: re-selecting the lit preset returns the same
  state object, so the overlay's identity check skips a needless rebuild.
- game-scene.ts: dev-only __phase9_test.getRoundOpponent() so a spec can
  prove Start booted the selected opponent.
- tests: geometry.ts exports the Jev-build rect sets for BOTH picker
  states (the stack moves between them); boot.ts gains selectedOpponent;
  jev-opponent.spec.ts pins the defaults, options hidden until Jev,
  the caption, nothing-above-Start-starts, Enter inside the box not
  starting, persistence across reload, and textarea teardown.

Render-only: no sim change, no simVersion bump; settings persistence
(opponent / jevOrders) is unchanged from the branch.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
LightAxe added a commit that referenced this pull request Oct 3, 2026
…ce, Jev options only when selected (#304)

Items 3–4 of #304 on the Jev beta branch, rebuilt on main's new-game
screen (#312) instead of the old difficulty-buttons overlay: an explicit
Opponent section between Difficulty and Start, the Jev options shown only
once Jev is selected, and the free-text box captioned for whose orders
they are.

The screen, top to bottom, on a build with a Jev endpoint:

  Difficulty      (main's three radio rows, unchanged)
  Opponent        two radio-style rows with a one-liner each —
                  "Standard AI · The built-in rule-based enemy colony."
                  "Jev (beta) · TypeSafe's Jev model plays the enemy; you
                  can instruct it."
  Jev options     ONLY while the Jev row is selected: "Custom instructions
                  for Jev, your opponent" (+ n/300 counter), the four
                  standing-orders presets, and the free-text box
  Start game      (main's single Start; Enter also starts)

Defaults are Normal + Standard AI; nothing above Start starts a round.
On a build with no endpoint no section is drawn at all — the screen is
main's, pixel for pixel — so Standard AI is implied rather than shown
disabled (the plain-build specs pass with no geometry change).

- boot-overlay-layout.ts: the section is laid out INSIDE the stack's
  opponentSlot (opponentSectionH / opponentSectionLayout /
  newGameScreenWithOpponent), so it inherits the LayoutContext discipline
  and the stack re-centres around it. Its height follows the picker:
  caption + two 30 px rows collapsed, + caption line / presets / 46 px
  free-text rect expanded — 190 px, exactly what keeps the fully expanded
  stack inside the shipping canvas with NEW_GAME_STACK_MIN_TOP clear at
  both ends (pinned by a test). The old top-anchored opponentPickerLayout
  (and its hint "Set the opponent below first", moot now that rows do not
  start the game) is gone.
- opponent-copy.ts: the section's strings, pinned by a test that also
  guards each row's one-liner against wrapping.
- ui-scene.ts: the section draws from the same re-render-in-place path as
  the difficulty rows; ALL clicks dispatch through dispatchNewGameClick
  (Start → commit, difficulty row → select, opponent row → toggleKind,
  preset → selectPreset, else absorbed — no per-object pointer handlers).
  The free-text box is a DOM <textarea> from the shared overlay-field
  factory (keydown stops propagation, so Enter inside it never reaches
  the Enter-starts binding; the caption doubles as its aria-label), torn
  down on hide, on leaving the Jev row and on scene shutdown, and never
  part of the Phaser group so a re-render keeps focus and caret. A canvas
  click blurs it explicitly — Phaser preventDefault()s the canvas
  mousedown, so the browser would otherwise leave every later key in the
  box. commitNewGame reads the picker's config BEFORE hiding.
  __phase9_ui.selectedOpponent is published alongside selectedDifficulty.
  The n/300 counter follows the drawn caption rather than sitting at the
  column's right edge, where the HUD view-toggle shows through the scrim.
- opponent-picker-state.ts: re-selecting the lit preset returns the same
  state object, so the overlay's identity check skips a needless rebuild.
- game-scene.ts: dev-only __phase9_test.getRoundOpponent() so a spec can
  prove Start booted the selected opponent.
- tests: geometry.ts exports the Jev-build rect sets for BOTH picker
  states (the stack moves between them); boot.ts gains selectedOpponent;
  jev-opponent.spec.ts pins the defaults, options hidden until Jev,
  the caption, nothing-above-Start-starts, Enter inside the box not
  starting, persistence across reload, and textarea teardown.

Render-only: no sim change, no simVersion bump; settings persistence
(opponent / jevOrders) is unchanged from the branch.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
LightAxe added a commit that referenced this pull request Oct 4, 2026
…ce, Jev options only when selected (#304)

Items 3–4 of #304 on the Jev beta branch, rebuilt on main's new-game
screen (#312) instead of the old difficulty-buttons overlay: an explicit
Opponent section between Difficulty and Start, the Jev options shown only
once Jev is selected, and the free-text box captioned for whose orders
they are.

The screen, top to bottom, on a build with a Jev endpoint:

  Difficulty      (main's three radio rows, unchanged)
  Opponent        two radio-style rows with a one-liner each —
                  "Standard AI · The built-in rule-based enemy colony."
                  "Jev (beta) · TypeSafe's Jev model plays the enemy; you
                  can instruct it."
  Jev options     ONLY while the Jev row is selected: "Custom instructions
                  for Jev, your opponent" (+ n/300 counter), the four
                  standing-orders presets, and the free-text box
  Start game      (main's single Start; Enter also starts)

Defaults are Normal + Standard AI; nothing above Start starts a round.
On a build with no endpoint no section is drawn at all — the screen is
main's, pixel for pixel — so Standard AI is implied rather than shown
disabled (the plain-build specs pass with no geometry change).

- boot-overlay-layout.ts: the section is laid out INSIDE the stack's
  opponentSlot (opponentSectionH / opponentSectionLayout /
  newGameScreenWithOpponent), so it inherits the LayoutContext discipline
  and the stack re-centres around it. Its height follows the picker:
  caption + two 30 px rows collapsed, + caption line / presets / 46 px
  free-text rect expanded — 190 px, exactly what keeps the fully expanded
  stack inside the shipping canvas with NEW_GAME_STACK_MIN_TOP clear at
  both ends (pinned by a test). The old top-anchored opponentPickerLayout
  (and its hint "Set the opponent below first", moot now that rows do not
  start the game) is gone.
- opponent-copy.ts: the section's strings, pinned by a test that also
  guards each row's one-liner against wrapping.
- ui-scene.ts: the section draws from the same re-render-in-place path as
  the difficulty rows; ALL clicks dispatch through dispatchNewGameClick
  (Start → commit, difficulty row → select, opponent row → toggleKind,
  preset → selectPreset, else absorbed — no per-object pointer handlers).
  The free-text box is a DOM <textarea> from the shared overlay-field
  factory (keydown stops propagation, so Enter inside it never reaches
  the Enter-starts binding; the caption doubles as its aria-label), torn
  down on hide, on leaving the Jev row and on scene shutdown, and never
  part of the Phaser group so a re-render keeps focus and caret. A canvas
  click blurs it explicitly — Phaser preventDefault()s the canvas
  mousedown, so the browser would otherwise leave every later key in the
  box. commitNewGame reads the picker's config BEFORE hiding.
  __phase9_ui.selectedOpponent is published alongside selectedDifficulty.
  The n/300 counter follows the drawn caption rather than sitting at the
  column's right edge, where the HUD view-toggle shows through the scrim.
- opponent-picker-state.ts: re-selecting the lit preset returns the same
  state object, so the overlay's identity check skips a needless rebuild.
- game-scene.ts: dev-only __phase9_test.getRoundOpponent() so a spec can
  prove Start booted the selected opponent.
- tests: geometry.ts exports the Jev-build rect sets for BOTH picker
  states (the stack moves between them); boot.ts gains selectedOpponent;
  jev-opponent.spec.ts pins the defaults, options hidden until Jev,
  the caption, nothing-above-Start-starts, Enter inside the box not
  starting, persistence across reload, and textarea teardown.

Render-only: no sim change, no simVersion bump; settings persistence
(opponent / jevOrders) is unchanged from the branch.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
LightAxe added a commit that referenced this pull request Oct 9, 2026
…ce, Jev options only when selected (#304)

Items 3–4 of #304 on the Jev beta branch, rebuilt on main's new-game
screen (#312) instead of the old difficulty-buttons overlay: an explicit
Opponent section between Difficulty and Start, the Jev options shown only
once Jev is selected, and the free-text box captioned for whose orders
they are.

The screen, top to bottom, on a build with a Jev endpoint:

  Difficulty      (main's three radio rows, unchanged)
  Opponent        two radio-style rows with a one-liner each —
                  "Standard AI · The built-in rule-based enemy colony."
                  "Jev (beta) · TypeSafe's Jev model plays the enemy; you
                  can instruct it."
  Jev options     ONLY while the Jev row is selected: "Custom instructions
                  for Jev, your opponent" (+ n/300 counter), the four
                  standing-orders presets, and the free-text box
  Start game      (main's single Start; Enter also starts)

Defaults are Normal + Standard AI; nothing above Start starts a round.
On a build with no endpoint no section is drawn at all — the screen is
main's, pixel for pixel — so Standard AI is implied rather than shown
disabled (the plain-build specs pass with no geometry change).

- boot-overlay-layout.ts: the section is laid out INSIDE the stack's
  opponentSlot (opponentSectionH / opponentSectionLayout /
  newGameScreenWithOpponent), so it inherits the LayoutContext discipline
  and the stack re-centres around it. Its height follows the picker:
  caption + two 30 px rows collapsed, + caption line / presets / 46 px
  free-text rect expanded — 190 px, exactly what keeps the fully expanded
  stack inside the shipping canvas with NEW_GAME_STACK_MIN_TOP clear at
  both ends (pinned by a test). The old top-anchored opponentPickerLayout
  (and its hint "Set the opponent below first", moot now that rows do not
  start the game) is gone.
- opponent-copy.ts: the section's strings, pinned by a test that also
  guards each row's one-liner against wrapping.
- ui-scene.ts: the section draws from the same re-render-in-place path as
  the difficulty rows; ALL clicks dispatch through dispatchNewGameClick
  (Start → commit, difficulty row → select, opponent row → toggleKind,
  preset → selectPreset, else absorbed — no per-object pointer handlers).
  The free-text box is a DOM <textarea> from the shared overlay-field
  factory (keydown stops propagation, so Enter inside it never reaches
  the Enter-starts binding; the caption doubles as its aria-label), torn
  down on hide, on leaving the Jev row and on scene shutdown, and never
  part of the Phaser group so a re-render keeps focus and caret. A canvas
  click blurs it explicitly — Phaser preventDefault()s the canvas
  mousedown, so the browser would otherwise leave every later key in the
  box. commitNewGame reads the picker's config BEFORE hiding.
  __phase9_ui.selectedOpponent is published alongside selectedDifficulty.
  The n/300 counter follows the drawn caption rather than sitting at the
  column's right edge, where the HUD view-toggle shows through the scrim.
- opponent-picker-state.ts: re-selecting the lit preset returns the same
  state object, so the overlay's identity check skips a needless rebuild.
- game-scene.ts: dev-only __phase9_test.getRoundOpponent() so a spec can
  prove Start booted the selected opponent.
- tests: geometry.ts exports the Jev-build rect sets for BOTH picker
  states (the stack moves between them); boot.ts gains selectedOpponent;
  jev-opponent.spec.ts pins the defaults, options hidden until Jev,
  the caption, nothing-above-Start-starts, Enter inside the box not
  starting, persistence across reload, and textarea teardown.

Render-only: no sim change, no simVersion bump; settings persistence
(opponent / jevOrders) is unchanged from the branch.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
LightAxe added a commit that referenced this pull request Oct 10, 2026
…ce, Jev options only when selected (#304)

Items 3–4 of #304 on the Jev beta branch, rebuilt on main's new-game
screen (#312) instead of the old difficulty-buttons overlay: an explicit
Opponent section between Difficulty and Start, the Jev options shown only
once Jev is selected, and the free-text box captioned for whose orders
they are.

The screen, top to bottom, on a build with a Jev endpoint:

  Difficulty      (main's three radio rows, unchanged)
  Opponent        two radio-style rows with a one-liner each —
                  "Standard AI · The built-in rule-based enemy colony."
                  "Jev (beta) · TypeSafe's Jev model plays the enemy; you
                  can instruct it."
  Jev options     ONLY while the Jev row is selected: "Custom instructions
                  for Jev, your opponent" (+ n/300 counter), the four
                  standing-orders presets, and the free-text box
  Start game      (main's single Start; Enter also starts)

Defaults are Normal + Standard AI; nothing above Start starts a round.
On a build with no endpoint no section is drawn at all — the screen is
main's, pixel for pixel — so Standard AI is implied rather than shown
disabled (the plain-build specs pass with no geometry change).

- boot-overlay-layout.ts: the section is laid out INSIDE the stack's
  opponentSlot (opponentSectionH / opponentSectionLayout /
  newGameScreenWithOpponent), so it inherits the LayoutContext discipline
  and the stack re-centres around it. Its height follows the picker:
  caption + two 30 px rows collapsed, + caption line / presets / 46 px
  free-text rect expanded — 190 px, exactly what keeps the fully expanded
  stack inside the shipping canvas with NEW_GAME_STACK_MIN_TOP clear at
  both ends (pinned by a test). The old top-anchored opponentPickerLayout
  (and its hint "Set the opponent below first", moot now that rows do not
  start the game) is gone.
- opponent-copy.ts: the section's strings, pinned by a test that also
  guards each row's one-liner against wrapping.
- ui-scene.ts: the section draws from the same re-render-in-place path as
  the difficulty rows; ALL clicks dispatch through dispatchNewGameClick
  (Start → commit, difficulty row → select, opponent row → toggleKind,
  preset → selectPreset, else absorbed — no per-object pointer handlers).
  The free-text box is a DOM <textarea> from the shared overlay-field
  factory (keydown stops propagation, so Enter inside it never reaches
  the Enter-starts binding; the caption doubles as its aria-label), torn
  down on hide, on leaving the Jev row and on scene shutdown, and never
  part of the Phaser group so a re-render keeps focus and caret. A canvas
  click blurs it explicitly — Phaser preventDefault()s the canvas
  mousedown, so the browser would otherwise leave every later key in the
  box. commitNewGame reads the picker's config BEFORE hiding.
  __phase9_ui.selectedOpponent is published alongside selectedDifficulty.
  The n/300 counter follows the drawn caption rather than sitting at the
  column's right edge, where the HUD view-toggle shows through the scrim.
- opponent-picker-state.ts: re-selecting the lit preset returns the same
  state object, so the overlay's identity check skips a needless rebuild.
- game-scene.ts: dev-only __phase9_test.getRoundOpponent() so a spec can
  prove Start booted the selected opponent.
- tests: geometry.ts exports the Jev-build rect sets for BOTH picker
  states (the stack moves between them); boot.ts gains selectedOpponent;
  jev-opponent.spec.ts pins the defaults, options hidden until Jev,
  the caption, nothing-above-Start-starts, Enter inside the box not
  starting, persistence across reload, and textarea teardown.

Render-only: no sim change, no simVersion bump; settings persistence
(opponent / jevOrders) is unchanged from the branch.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
LightAxe added a commit that referenced this pull request Oct 10, 2026
…ce, Jev options only when selected (#304)

Items 3–4 of #304 on the Jev beta branch, rebuilt on main's new-game
screen (#312) instead of the old difficulty-buttons overlay: an explicit
Opponent section between Difficulty and Start, the Jev options shown only
once Jev is selected, and the free-text box captioned for whose orders
they are.

The screen, top to bottom, on a build with a Jev endpoint:

  Difficulty      (main's three radio rows, unchanged)
  Opponent        two radio-style rows with a one-liner each —
                  "Standard AI · The built-in rule-based enemy colony."
                  "Jev (beta) · TypeSafe's Jev model plays the enemy; you
                  can instruct it."
  Jev options     ONLY while the Jev row is selected: "Custom instructions
                  for Jev, your opponent" (+ n/300 counter), the four
                  standing-orders presets, and the free-text box
  Start game      (main's single Start; Enter also starts)

Defaults are Normal + Standard AI; nothing above Start starts a round.
On a build with no endpoint no section is drawn at all — the screen is
main's, pixel for pixel — so Standard AI is implied rather than shown
disabled (the plain-build specs pass with no geometry change).

- boot-overlay-layout.ts: the section is laid out INSIDE the stack's
  opponentSlot (opponentSectionH / opponentSectionLayout /
  newGameScreenWithOpponent), so it inherits the LayoutContext discipline
  and the stack re-centres around it. Its height follows the picker:
  caption + two 30 px rows collapsed, + caption line / presets / 46 px
  free-text rect expanded — 190 px, exactly what keeps the fully expanded
  stack inside the shipping canvas with NEW_GAME_STACK_MIN_TOP clear at
  both ends (pinned by a test). The old top-anchored opponentPickerLayout
  (and its hint "Set the opponent below first", moot now that rows do not
  start the game) is gone.
- opponent-copy.ts: the section's strings, pinned by a test that also
  guards each row's one-liner against wrapping.
- ui-scene.ts: the section draws from the same re-render-in-place path as
  the difficulty rows; ALL clicks dispatch through dispatchNewGameClick
  (Start → commit, difficulty row → select, opponent row → toggleKind,
  preset → selectPreset, else absorbed — no per-object pointer handlers).
  The free-text box is a DOM <textarea> from the shared overlay-field
  factory (keydown stops propagation, so Enter inside it never reaches
  the Enter-starts binding; the caption doubles as its aria-label), torn
  down on hide, on leaving the Jev row and on scene shutdown, and never
  part of the Phaser group so a re-render keeps focus and caret. A canvas
  click blurs it explicitly — Phaser preventDefault()s the canvas
  mousedown, so the browser would otherwise leave every later key in the
  box. commitNewGame reads the picker's config BEFORE hiding.
  __phase9_ui.selectedOpponent is published alongside selectedDifficulty.
  The n/300 counter follows the drawn caption rather than sitting at the
  column's right edge, where the HUD view-toggle shows through the scrim.
- opponent-picker-state.ts: re-selecting the lit preset returns the same
  state object, so the overlay's identity check skips a needless rebuild.
- game-scene.ts: dev-only __phase9_test.getRoundOpponent() so a spec can
  prove Start booted the selected opponent.
- tests: geometry.ts exports the Jev-build rect sets for BOTH picker
  states (the stack moves between them); boot.ts gains selectedOpponent;
  jev-opponent.spec.ts pins the defaults, options hidden until Jev,
  the caption, nothing-above-Start-starts, Enter inside the box not
  starting, persistence across reload, and textarea teardown.

Render-only: no sim change, no simVersion bump; settings persistence
(opponent / jevOrders) is unchanged from the branch.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
LightAxe added a commit that referenced this pull request Oct 11, 2026
…ce, Jev options only when selected (#304)

Items 3–4 of #304 on the Jev beta branch, rebuilt on main's new-game
screen (#312) instead of the old difficulty-buttons overlay: an explicit
Opponent section between Difficulty and Start, the Jev options shown only
once Jev is selected, and the free-text box captioned for whose orders
they are.

The screen, top to bottom, on a build with a Jev endpoint:

  Difficulty      (main's three radio rows, unchanged)
  Opponent        two radio-style rows with a one-liner each —
                  "Standard AI · The built-in rule-based enemy colony."
                  "Jev (beta) · TypeSafe's Jev model plays the enemy; you
                  can instruct it."
  Jev options     ONLY while the Jev row is selected: "Custom instructions
                  for Jev, your opponent" (+ n/300 counter), the four
                  standing-orders presets, and the free-text box
  Start game      (main's single Start; Enter also starts)

Defaults are Normal + Standard AI; nothing above Start starts a round.
On a build with no endpoint no section is drawn at all — the screen is
main's, pixel for pixel — so Standard AI is implied rather than shown
disabled (the plain-build specs pass with no geometry change).

- boot-overlay-layout.ts: the section is laid out INSIDE the stack's
  opponentSlot (opponentSectionH / opponentSectionLayout /
  newGameScreenWithOpponent), so it inherits the LayoutContext discipline
  and the stack re-centres around it. Its height follows the picker:
  caption + two 30 px rows collapsed, + caption line / presets / 46 px
  free-text rect expanded — 190 px, exactly what keeps the fully expanded
  stack inside the shipping canvas with NEW_GAME_STACK_MIN_TOP clear at
  both ends (pinned by a test). The old top-anchored opponentPickerLayout
  (and its hint "Set the opponent below first", moot now that rows do not
  start the game) is gone.
- opponent-copy.ts: the section's strings, pinned by a test that also
  guards each row's one-liner against wrapping.
- ui-scene.ts: the section draws from the same re-render-in-place path as
  the difficulty rows; ALL clicks dispatch through dispatchNewGameClick
  (Start → commit, difficulty row → select, opponent row → toggleKind,
  preset → selectPreset, else absorbed — no per-object pointer handlers).
  The free-text box is a DOM <textarea> from the shared overlay-field
  factory (keydown stops propagation, so Enter inside it never reaches
  the Enter-starts binding; the caption doubles as its aria-label), torn
  down on hide, on leaving the Jev row and on scene shutdown, and never
  part of the Phaser group so a re-render keeps focus and caret. A canvas
  click blurs it explicitly — Phaser preventDefault()s the canvas
  mousedown, so the browser would otherwise leave every later key in the
  box. commitNewGame reads the picker's config BEFORE hiding.
  __phase9_ui.selectedOpponent is published alongside selectedDifficulty.
  The n/300 counter follows the drawn caption rather than sitting at the
  column's right edge, where the HUD view-toggle shows through the scrim.
- opponent-picker-state.ts: re-selecting the lit preset returns the same
  state object, so the overlay's identity check skips a needless rebuild.
- game-scene.ts: dev-only __phase9_test.getRoundOpponent() so a spec can
  prove Start booted the selected opponent.
- tests: geometry.ts exports the Jev-build rect sets for BOTH picker
  states (the stack moves between them); boot.ts gains selectedOpponent;
  jev-opponent.spec.ts pins the defaults, options hidden until Jev,
  the caption, nothing-above-Start-starts, Enter inside the box not
  starting, persistence across reload, and textarea teardown.

Render-only: no sim change, no simVersion bump; settings persistence
(opponent / jevOrders) is unchanged from the branch.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant