[PR #6266] [MERGED] feat(game): hybrid tactical terrain and movement capabilities #7112

Closed
opened 2026-10-23 04:16:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6266
Author: @kolacheee
Created: 9/16/2026
Status: ✅ Merged
Merged: 9/17/2026
Merged by: @kolacheee

Base: staging ← Head: codex/hybrid-tactical-terrain


📝 Commits (10+)

  • 2c94bc6 docs: record approved combat terrain and rules roadmap (#6265)
  • fff1844 feat(game): add hybrid tactical terrain and movement (#6265)
  • 9326e14 refactor(game): reuse pinned combat style for battlefield art
  • 4b15163 fix(game): harden terrain recovery and setup export validation
  • b453b68 fix(game): discard late tactical launch responses after navigation
  • 3e0854d fix(game): preserve terrain validation errors and input data
  • 84c1400 fix(game): isolate tactical chat state and localize battlefield summaries
  • 4d956bc fix(game): align battlefield provenance and active combat context
  • 4c4a8f9 fix(game): retain readable size labels for malformed saved settings
  • 4880d5e refactor(game): derive barrier legality from terrain data

📊 Changes

29 files changed (+3068 additions, -124 deletions)

View changed files

📝 AGENTS.md (+1 -0)
📝 CHANGELOG.md (+4 -0)
➕ docs/development/game-combat-roadmap.md (+66 -0)
📝 docs/game/combat.md (+37 -6)
📝 docs/game/getting-started.md (+3 -1)
📝 e2e/game-experience-setup.e2e.ts (+73 -0)
➕ e2e/game-hybrid-terrain.e2e.ts (+401 -0)
➕ e2e/game-terrain-restore.e2e.ts (+459 -0)
📝 packages/client/src/components/game/GameSetupWizard.tsx (+138 -10)
📝 packages/client/src/components/game/GameSurface.tsx (+120 -29)
📝 packages/client/src/components/game/TacticalCombatUI.tsx (+159 -25)
📝 packages/client/src/hooks/use-game.ts (+2 -0)
📝 packages/client/src/lib/game-setup-share.ts (+87 -8)
📝 packages/client/src/localization/locales/en.json (+46 -2)
📝 packages/server/src/routes/encounter.routes.ts (+43 -1)
📝 packages/server/src/routes/game.routes.ts (+67 -17)
📝 packages/server/src/services/game/gm-prompts.ts (+12 -0)
➕ packages/server/src/services/game/tactical-battlefield.service.ts (+124 -0)
📝 packages/server/src/services/generation/game-gm-prompt-runtime.ts (+33 -3)
➕ packages/shared/src/features/tactical-combat/battlefield-summary.ts (+69 -0)

...and 9 more files

📄 Description

Linked issue

Closes #6265. Owned by @kolacheee with Astra coordinating Sol, Terra, and GPT-5.5 implementation/review work. Targets staging.

Why this change

Tactical Game Mode already has a grid, but its generated terrain cannot reflect player guidance and a bounded GM terrain brief. Units with established flight or teleportation also follow ordinary walking rules. This adds scene-aware, reproducible battlefields and distinct movement capabilities while preserving older setups and saves.

What changed

  • Tactical creation settings now offer an optional seed (including zero), battlefield size, and terrain guidance; setup sharing/import and summaries preserve those choices.
  • The GM requests at most four terrain patches/barriers. Seeded engine generation preserves accepted landmarks, repairs only generated terrain, and validates reachable deployment. Invalid or conflicting requests stop with an explicit Use generated terrain recovery action.
  • Flying and teleporting units bypass intervening terrain, occupied units, and forest movement costs. Flying can hover on blocked tiles; teleportation requires a walkable destination. Occupancy still applies, and terrain defense/evasion bonuses remain intact.
  • Accepted grids, seed/provenance, pending errors, and encounter style survive refresh. Restart reuses the accepted inputs, including after fallback. Changing the next battle's style cannot replace the current fight or its GM instructions. Existing tactical saves without the new style field remain tactical. Late restart/fallback responses cannot update or save a battle after its screen closes.
  • GM context and final battle reports include the accepted terrain. Added localized controls, movement labels, user documentation, and a contributor roadmap for separate participation settings, summoning, tabletop profiles, and later line-of-sight/cover work.
  • Recorded the maintainer's preference for local CodeRabbit review before requesting PR review, with their explicit permission to dismiss documented false positives and pedantic suggestions.

This is a flat-grid movement/terrain increment. Full summoning, 5e/V20 rules, individual initiative, altitude/ceilings, spell-specific teleport costs, and ranged line of sight remain future work; the roadmap documents their boundaries and prior work.

Validation

Observed local results for this change:

  • pnpm check: passed on 025442b17 (localization, formatting, lint/types, and production build). One existing GameNarration hook-dependency warning remains outside this change.
  • node scripts/run-regressions.mjs --filter hybrid-terrain: all 3 suites passed after the review fixes, including real route validation, legacy generation, legal/illegal movement, terrain bonuses, setup round trips, pinned GM prompt rules, and rejection of malformed persisted battlefield grids.
  • pnpm regression:prompt: all three prompt lanes passed again after the saved-grid summary validation fix.
  • Browser checks: 33 feature cases passed across desktop Chromium, mobile Chromium, and mobile WebKit (the latter in the official Playwright v1.61.0 Noble container). The five existing wizard cases also passed in all three configurations during earlier implementation runs. Coverage includes seed-zero import/export eligibility, invalid seed feedback/export prevention, flying movement, refresh/restart, keyboard fallback, rejected terrain, current/legacy/malformed GameSurface restoration, delayed restart/fallback responses after the battle screen unmounts, malformed terrain responses without a server-supplied error, and switching saved battles without carrying action state between chats.
  • Earlier implementation Podman build and isolated runtime smoke: passed on 4c4a8f9c (not the current head); /api/health returned healthy and the web root served the client shell. The documented private-network opt-in was used only inside the disposable smoke container; its container and volume were removed.
  • Local CodeRabbit: pass 16 completed with zero findings before the GitHub review. After fixing the two legitimate GitHub findings, pass 17 completed against 025442b17 with three non-actionable suggestions, dismissed against the code and existing tests below. No additional review loop is needed under the maintainer's clarified policy. GitHub CodeRabbit and required CI remain merge gates.

Local pass 17 dispositions:

  • Normalize/truncate imported battlefield settings again in the wizard: the only import handler first calls parseGameSetupShareFileJson, which already rejects unknown sizes and oversized/non-string guidance before any state update. The setup regression covers these invalid imports. Silently replacing or truncating them would weaken the existing error contract.
  • Add battlefieldError to the initial launch effect dependencies: the sole GameSurface caller sets terrain errors together with combatants before mounting the chat-keyed tactical UI. The post-mount error change clears it after accepting a fallback board; rerunning the initial launch at that point could start another battle before saved metadata refreshes. The existing mount-only launch and explicit recovery preserve the current caller contract.
  • Silently degrade unsupported movement modes to walking: explicitly unsupported capabilities deliberately fail validation, while omitted legacy modes default to walking. The documented validator contract and regression already cover this distinction; the proposed movement-error reporting mechanism does not exist.

Additional review-fix proof: valid battlefield summaries are byte-for-byte unchanged; seven malformed-grid inputs reproduced incorrect summaries before the fix and now return no context. A forced delayed-request failure reproduced an unhandled rejection before the test-helper fix; afterward both returned promises retain the original error with zero unhandled rejections.

The following boxes remain a human contributor's checklist, not automated proof:

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Automated real-browser flows and their screenshots were inspected during implementation. Human follow-up:

  • Manually verify Tactical creation with blank/zero/custom seeds, each size, and terrain guidance in light/dark themes and on a phone.
  • Manually verify a real GM provider chooses scene-appropriate landmarks and grants flight/teleportation only to established capabilities. Automated encounter/terrain tests use synthetic fixtures and do not establish model judgment quality.
  • Manually verify an impossible brief offers explicit recovery, then movement, refresh, restart, and next-battle style changes retain the accepted battlefield.
  • Manually verify touch interaction and visual rendering on physical Safari/iOS hardware; container WebKit is browser emulation.

CI failure triage

On 616c5f451, one mobile-WebKit dice-turn case timed out on the visible Close Chat Settings button; the separate mobile-webkit failure is the aggregate verdict. Filed #6269 with the trace and passing controls on the PR base and earlier terrain head. The dice test and settings drawer are unchanged between the green feature head and failing head; GameSurface changes in that interval are comments only. Evidence supports a test/browser actionability flake, with the underlying timing cause still unconfirmed. The unrelated dice test is unchanged in this patch. The pushed fixes trigger fresh CI; this triage does not bypass merge gates.

Docs and release impact

Updated docs/game/combat.md, docs/game/getting-started.md, docs/development/game-combat-roadmap.md, and CHANGELOG.md. Translation follow-up: #6267. No release/version bump.

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence

Before/after browser gallery. Download the gist ZIP and open browser-evidence.html; it embeds the original PNG captures and requires no network or scripts. Includes desktop/mobile setup, a flying unit on a wall, and explicit terrain fallback. Before captures use the original staging wizard at b659229c2e9c7c30d6e3d0e0921f583297dca96e. Synthetic game data only; no screenshot assets are committed to the repository.

Summary by CodeRabbit

  • New Features

    • Added Tactical combat mode with configurable battlefield seed, size, and terrain guidance.
    • Added generated battlefields that preserve requested landmarks when possible and offer a generated-terrain fallback when requests cannot be used.
    • Added distinct movement behavior for walking, flying, and teleporting units.
    • Tactical battles now display battlefield summaries, terrain details, movement labels, and accessible tile information.
    • Tactical battlefield settings and combat state are preserved across setup sharing, reloads, and battle restarts.
    • Added validation messages for invalid battlefield settings and terrain requests.
  • Documentation

    • Updated setup and combat guides with Tactical mode instructions, movement rules, battlefield generation details, and current limitations.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/6266 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/16/2026 **Status:** ✅ Merged **Merged:** 9/17/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `codex/hybrid-tactical-terrain` --- ### 📝 Commits (10+) - [`2c94bc6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2c94bc66f5c9ecae991636d57eef97ae46e6e167) docs: record approved combat terrain and rules roadmap (#6265) - [`fff1844`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fff18447e4e275030e089d7c6473bc5b6be622a8) feat(game): add hybrid tactical terrain and movement (#6265) - [`9326e14`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9326e14ef4536e7418ba32e5dd450e321dc0b265) refactor(game): reuse pinned combat style for battlefield art - [`4b15163`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4b15163e85e329133f7ad634e704334f2d6ebe20) fix(game): harden terrain recovery and setup export validation - [`b453b68`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b453b68785ca381068e4dedaa0ec85c1be5b4b00) fix(game): discard late tactical launch responses after navigation - [`3e0854d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3e0854d6bf7cf67d9c302c47cc898dc08c180c82) fix(game): preserve terrain validation errors and input data - [`84c1400`](https://github.com/Pasta-Devs/Marinara-Engine/commit/84c1400e98372049b225397fda46a48c4430231c) fix(game): isolate tactical chat state and localize battlefield summaries - [`4d956bc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4d956bc4e1cd353a70ee939fdf4b8fc10a78f986) fix(game): align battlefield provenance and active combat context - [`4c4a8f9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4c4a8f9c3912abfb3ea7ffa4421b246058d43e28) fix(game): retain readable size labels for malformed saved settings - [`4880d5e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4880d5e51bb23bac23c46d566a37fb470167d1ed) refactor(game): derive barrier legality from terrain data ### 📊 Changes **29 files changed** (+3068 additions, -124 deletions) <details> <summary>View changed files</summary> 📝 `AGENTS.md` (+1 -0) 📝 `CHANGELOG.md` (+4 -0) ➕ `docs/development/game-combat-roadmap.md` (+66 -0) 📝 `docs/game/combat.md` (+37 -6) 📝 `docs/game/getting-started.md` (+3 -1) 📝 `e2e/game-experience-setup.e2e.ts` (+73 -0) ➕ `e2e/game-hybrid-terrain.e2e.ts` (+401 -0) ➕ `e2e/game-terrain-restore.e2e.ts` (+459 -0) 📝 `packages/client/src/components/game/GameSetupWizard.tsx` (+138 -10) 📝 `packages/client/src/components/game/GameSurface.tsx` (+120 -29) 📝 `packages/client/src/components/game/TacticalCombatUI.tsx` (+159 -25) 📝 `packages/client/src/hooks/use-game.ts` (+2 -0) 📝 `packages/client/src/lib/game-setup-share.ts` (+87 -8) 📝 `packages/client/src/localization/locales/en.json` (+46 -2) 📝 `packages/server/src/routes/encounter.routes.ts` (+43 -1) 📝 `packages/server/src/routes/game.routes.ts` (+67 -17) 📝 `packages/server/src/services/game/gm-prompts.ts` (+12 -0) ➕ `packages/server/src/services/game/tactical-battlefield.service.ts` (+124 -0) 📝 `packages/server/src/services/generation/game-gm-prompt-runtime.ts` (+33 -3) ➕ `packages/shared/src/features/tactical-combat/battlefield-summary.ts` (+69 -0) _...and 9 more files_ </details> ### 📄 Description ## Linked issue Closes #6265. Owned by @kolacheee with Astra coordinating Sol, Terra, and GPT-5.5 implementation/review work. Targets `staging`. ## Why this change Tactical Game Mode already has a grid, but its generated terrain cannot reflect player guidance and a bounded GM terrain brief. Units with established flight or teleportation also follow ordinary walking rules. This adds scene-aware, reproducible battlefields and distinct movement capabilities while preserving older setups and saves. ## What changed - Tactical creation settings now offer an optional seed (including zero), battlefield size, and terrain guidance; setup sharing/import and summaries preserve those choices. - The GM requests at most four terrain patches/barriers. Seeded engine generation preserves accepted landmarks, repairs only generated terrain, and validates reachable deployment. Invalid or conflicting requests stop with an explicit **Use generated terrain** recovery action. - Flying and teleporting units bypass intervening terrain, occupied units, and forest movement costs. Flying can hover on blocked tiles; teleportation requires a walkable destination. Occupancy still applies, and terrain defense/evasion bonuses remain intact. - Accepted grids, seed/provenance, pending errors, and encounter style survive refresh. Restart reuses the accepted inputs, including after fallback. Changing the next battle's style cannot replace the current fight or its GM instructions. Existing tactical saves without the new style field remain tactical. Late restart/fallback responses cannot update or save a battle after its screen closes. - GM context and final battle reports include the accepted terrain. Added localized controls, movement labels, user documentation, and a contributor roadmap for separate participation settings, summoning, tabletop profiles, and later line-of-sight/cover work. - Recorded the maintainer's preference for local CodeRabbit review before requesting PR review, with their explicit permission to dismiss documented false positives and pedantic suggestions. This is a flat-grid movement/terrain increment. Full summoning, 5e/V20 rules, individual initiative, altitude/ceilings, spell-specific teleport costs, and ranged line of sight remain future work; the roadmap documents their boundaries and prior work. ## Validation Observed local results for this change: - `pnpm check`: passed on `025442b17` (localization, formatting, lint/types, and production build). One existing GameNarration hook-dependency warning remains outside this change. - `node scripts/run-regressions.mjs --filter hybrid-terrain`: all 3 suites passed after the review fixes, including real route validation, legacy generation, legal/illegal movement, terrain bonuses, setup round trips, pinned GM prompt rules, and rejection of malformed persisted battlefield grids. - `pnpm regression:prompt`: all three prompt lanes passed again after the saved-grid summary validation fix. - Browser checks: 33 feature cases passed across desktop Chromium, mobile Chromium, and mobile WebKit (the latter in the official Playwright v1.61.0 Noble container). The five existing wizard cases also passed in all three configurations during earlier implementation runs. Coverage includes seed-zero import/export eligibility, invalid seed feedback/export prevention, flying movement, refresh/restart, keyboard fallback, rejected terrain, current/legacy/malformed GameSurface restoration, delayed restart/fallback responses after the battle screen unmounts, malformed terrain responses without a server-supplied error, and switching saved battles without carrying action state between chats. - Earlier implementation Podman build and isolated runtime smoke: passed on `4c4a8f9c` (not the current head); `/api/health` returned healthy and the web root served the client shell. The documented private-network opt-in was used only inside the disposable smoke container; its container and volume were removed. - Local CodeRabbit: pass 16 completed with zero findings before the GitHub review. After fixing the two legitimate GitHub findings, pass 17 completed against `025442b17` with three non-actionable suggestions, dismissed against the code and existing tests below. No additional review loop is needed under the maintainer's clarified policy. GitHub CodeRabbit and required CI remain merge gates. Local pass 17 dispositions: - **Normalize/truncate imported battlefield settings again in the wizard:** the only import handler first calls `parseGameSetupShareFileJson`, which already rejects unknown sizes and oversized/non-string guidance before any state update. The setup regression covers these invalid imports. Silently replacing or truncating them would weaken the existing error contract. - **Add `battlefieldError` to the initial launch effect dependencies:** the sole `GameSurface` caller sets terrain errors together with combatants before mounting the chat-keyed tactical UI. The post-mount error change clears it after accepting a fallback board; rerunning the initial launch at that point could start another battle before saved metadata refreshes. The existing mount-only launch and explicit recovery preserve the current caller contract. - **Silently degrade unsupported movement modes to walking:** explicitly unsupported capabilities deliberately fail validation, while omitted legacy modes default to walking. The documented validator contract and regression already cover this distinction; the proposed movement-error reporting mechanism does not exist. Additional review-fix proof: valid battlefield summaries are byte-for-byte unchanged; seven malformed-grid inputs reproduced incorrect summaries before the fix and now return no context. A forced delayed-request failure reproduced an unhandled rejection before the test-helper fix; afterward both returned promises retain the original error with zero unhandled rejections. The following boxes remain a human contributor's checklist, not automated proof: - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes Automated real-browser flows and their screenshots were inspected during implementation. Human follow-up: - Manually verify Tactical creation with blank/zero/custom seeds, each size, and terrain guidance in light/dark themes and on a phone. - Manually verify a real GM provider chooses scene-appropriate landmarks and grants flight/teleportation only to established capabilities. Automated encounter/terrain tests use synthetic fixtures and do not establish model judgment quality. - Manually verify an impossible brief offers explicit recovery, then movement, refresh, restart, and next-battle style changes retain the accepted battlefield. - Manually verify touch interaction and visual rendering on physical Safari/iOS hardware; container WebKit is browser emulation. ## CI failure triage On `616c5f451`, one mobile-WebKit dice-turn case timed out on the visible **Close Chat Settings** button; the separate `mobile-webkit` failure is the aggregate verdict. Filed #6269 with the trace and passing controls on the PR base and earlier terrain head. The dice test and settings drawer are unchanged between the green feature head and failing head; GameSurface changes in that interval are comments only. Evidence supports a test/browser actionability flake, with the underlying timing cause still unconfirmed. The unrelated dice test is unchanged in this patch. The pushed fixes trigger fresh CI; this triage does not bypass merge gates. ## Docs and release impact Updated `docs/game/combat.md`, `docs/game/getting-started.md`, `docs/development/game-combat-roadmap.md`, and `CHANGELOG.md`. Translation follow-up: #6267. No release/version bump. - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence [Before/after browser gallery](https://gist.github.com/kolacheee/6484f881a5a0b82549d7de2e6868b049). Download the gist ZIP and open `browser-evidence.html`; it embeds the original PNG captures and requires no network or scripts. Includes desktop/mobile setup, a flying unit on a wall, and explicit terrain fallback. Before captures use the original staging wizard at `b659229c2e9c7c30d6e3d0e0921f583297dca96e`. Synthetic game data only; no screenshot assets are committed to the repository. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added Tactical combat mode with configurable battlefield seed, size, and terrain guidance. - Added generated battlefields that preserve requested landmarks when possible and offer a generated-terrain fallback when requests cannot be used. - Added distinct movement behavior for walking, flying, and teleporting units. - Tactical battles now display battlefield summaries, terrain details, movement labels, and accessible tile information. - Tactical battlefield settings and combat state are preserved across setup sharing, reloads, and battle restarts. - Added validation messages for invalid battlefield settings and terrain requests. - **Documentation** - Updated setup and combat guides with Tactical mode instructions, movement rules, battlefield generation details, and current limitations. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:16:39 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7112
No description provided.