[PR #3586] [MERGED] feat(game-mode): Combat Preference — classic or tactical grid battles #6005

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3586
Author: @Romuromylus
Created: 7/13/2026
Status: ✅ Merged
Merged: 7/14/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/game-mode-tactical-combat


📝 Commits (10+)

  • d903264 feat(game-mode): Combat Preference setting with tactical grid-battle style
  • cc25a3d feat(game-mode): tactical combat playtest fixes — movement UX, scene backdrops, formations, painted tiles
  • 7f49e6a feat(game-mode): tactical combat classes + action-race fix
  • 7c7e605 feat(game-mode): tactical combat QoL — draggable inspector, restart, theming
  • c92b3f4 feat(game-mode): surface Combat Style as its own Chat Settings section
  • b45d8da fix(game-mode): tactical combat overlay fixes — HUD overlap + draggable action menu
  • 5e921d1 fix(game-mode): tactical combat — seamless move animation + impassable mountains
  • f484ed5 fix(game-mode): tactical combat — review-round fixes (snapshot lifecycle, endpoint hardening, classic prompt purity)
  • 8278cc4 fix(game-mode): tactical combat — review round 2 (log cap, start bounds, stale-snapshot clear)
  • cdec711 fix(game-mode): tactical combat — KO'd units leave the board, staged moves read as previews

📊 Changes

30 files changed (+4827 additions, -30 deletions)

View changed files

📝 CHANGELOG.md (+4 -0)
➕ packages/client/public/tactical/forest.webp (+0 -0)
➕ packages/client/public/tactical/mountain.webp (+0 -0)
➕ packages/client/public/tactical/plains.webp (+0 -0)
➕ packages/client/public/tactical/ruin.webp (+0 -0)
➕ packages/client/public/tactical/wall.webp (+0 -0)
➕ packages/client/public/tactical/water.webp (+0 -0)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+16 -1)
📝 packages/client/src/components/game/GameSetupWizard.tsx (+36 -0)
📝 packages/client/src/components/game/GameSurface.tsx (+200 -24)
➕ packages/client/src/components/game/TacticalCombatUI.tsx (+2160 -0)
➕ packages/client/src/features/chat-settings/sections/CombatStyleSection.tsx (+38 -0)
📝 packages/client/src/hooks/use-game.ts (+33 -0)
📝 packages/client/src/lib/game-setup-share.ts (+1 -0)
📝 packages/server/src/routes/encounter.routes.ts (+29 -1)
📝 packages/server/src/routes/game.routes.ts (+193 -1)
📝 packages/server/src/services/game/gm-prompts.ts (+11 -3)
📝 packages/server/src/services/generation/game-gm-prompt-runtime.ts (+4 -0)
➕ packages/shared/src/features/tactical-combat/ai.ts (+192 -0)
➕ packages/shared/src/features/tactical-combat/classes.ts (+81 -0)

...and 10 more files

📄 Description

Linked issue

No linked issue — I built and playtested this directly as maintainer work. Happy to open a retroactive feature request if we want it on the board.

Why this change

  • Game mode has exactly one combat flow today: narrative "classic" combat resolved in prose by the GM. Players who want crunchier, more game-like fights have no option.
  • This adds a Combat Preference so each game can choose between the existing classic combat and a new tactical, grid-based battle style (Fire Emblem / FF Tactics-inspired). Games that stay on classic are untouched — their prompts and flow are byte-identical.

What changed

  • New shared feature packages/shared/src/features/tactical-combat/ — a deterministic, seed-driven battle engine (engine.ts), enemy-phase AI (ai.ts), unit classes (classes.ts), procedural terrain/grid generation (grid-gen.ts), plus RNG/math helpers and types. All combat resolution happens in the engine and is reproducible from a seed; the LLM only supplies the encounter blueprint (units, flavor, scene), never dice outcomes.
  • Server — game.routes.ts gains tactical encounter start/action endpoints. Combat state round-trips through the client and is validated on every action; the enemy phase runs server-side through the same engine. encounter.routes.ts and GM prompts were touched only to branch on the preference, so classic-combat prompt assembly is unchanged when tactical is off.
  • Client — new TacticalCombatUI.tsx: painted terrain grid with per-scene backdrops, movement/attack range overlays, animated unit movement, floating damage/heal/miss popups, a draggable unit inspector and action menu, staged moves rendered as translucent dashed previews until confirmed ("Confirm Move"), KO'd units exit-fading off the battlefield, encounter restart, and a mobile-friendly layout. GameSetupWizard gets the Combat Preference selector; Chat Settings gets a Combat Style section so the preference can be changed mid-game; GameSurface handles encounter lifecycle, formations, and background generation.
  • Terrain tile art under packages/client/public/tactical/ (webp).
  • CHANGELOG.md — feature entry added under [Unreleased].

Validation

  • 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

  • pnpm check exits 0 on the current head; 25 local engine tests pass (node:test via tsx).
  • Playtested over seven feedback rounds on a private test deployment, on desktop and mobile: full battles against the AI across all four difficulties, every unit class, movement/attack ranges, counters, crits, misses, KO removal mid-animation, staged-move previews, restart, light + dark themes, and the container Docker build (the test deployment builds from this branch's Dockerfile).
  • Engine correctness was property-tested with a 300-battle seeded auto-battle simulation (local-only test, gitignored like the rest of the test suite): no offensive event ever targets an already-dead unit, no unit ever moves twice in one action, and every battle's event stream replays to the engine's exact HP values.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

CHANGELOG.md was updated in this branch; no other docs are affected and there is no version bump.

UI evidence (if applicable)

Choosing Combat Mode

https://github.com/user-attachments/assets/c7e877aa-11ea-465f-b0ab-fbe62dba810e

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Added “Combat Preference” / “Combat Style” setting to choose Classic or Tactical (grid) combat for the next battle (setup + in-game/chat settings).
    • Tactical battles include themed terrain/formation, unit inspection and action menus, movement previews, enemy threat overlay, combat log, and animated resolution with victory/defeat/flee and restartable encounters.
  • Documentation
    • Updated the changelog to describe the new Combat Preference and tactical battle experience.

🔄 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/3586 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 7/13/2026 **Status:** ✅ Merged **Merged:** 7/14/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/game-mode-tactical-combat` --- ### 📝 Commits (10+) - [`d903264`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d9032643638dc3d15c714204ce8421e5fd7eebb5) feat(game-mode): Combat Preference setting with tactical grid-battle style - [`cc25a3d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cc25a3d72d55f9f27fe26eaedc2eb85d0f1ea508) feat(game-mode): tactical combat playtest fixes — movement UX, scene backdrops, formations, painted tiles - [`7f49e6a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7f49e6a4d4b1f119a18bb6d8a74144b2cbedb006) feat(game-mode): tactical combat classes + action-race fix - [`7c7e605`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7c7e605837e7e7568dfe3ba3c43682153120189f) feat(game-mode): tactical combat QoL — draggable inspector, restart, theming - [`c92b3f4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c92b3f461d9284b0363a45f60a75fd5472d90e3a) feat(game-mode): surface Combat Style as its own Chat Settings section - [`b45d8da`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b45d8dae4466e18c04282e9fd8ae9bbe67d3d760) fix(game-mode): tactical combat overlay fixes — HUD overlap + draggable action menu - [`5e921d1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5e921d18a7cec555da4cfb52999cd41fd75b5308) fix(game-mode): tactical combat — seamless move animation + impassable mountains - [`f484ed5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f484ed5a48211b690452b0c12baaffef878e9152) fix(game-mode): tactical combat — review-round fixes (snapshot lifecycle, endpoint hardening, classic prompt purity) - [`8278cc4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8278cc42660cd8f675a7b198cc681674da137f32) fix(game-mode): tactical combat — review round 2 (log cap, start bounds, stale-snapshot clear) - [`cdec711`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cdec711078238e4a0298915e735d9d6a3063c6f5) fix(game-mode): tactical combat — KO'd units leave the board, staged moves read as previews ### 📊 Changes **30 files changed** (+4827 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+4 -0) ➕ `packages/client/public/tactical/forest.webp` (+0 -0) ➕ `packages/client/public/tactical/mountain.webp` (+0 -0) ➕ `packages/client/public/tactical/plains.webp` (+0 -0) ➕ `packages/client/public/tactical/ruin.webp` (+0 -0) ➕ `packages/client/public/tactical/wall.webp` (+0 -0) ➕ `packages/client/public/tactical/water.webp` (+0 -0) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+16 -1) 📝 `packages/client/src/components/game/GameSetupWizard.tsx` (+36 -0) 📝 `packages/client/src/components/game/GameSurface.tsx` (+200 -24) ➕ `packages/client/src/components/game/TacticalCombatUI.tsx` (+2160 -0) ➕ `packages/client/src/features/chat-settings/sections/CombatStyleSection.tsx` (+38 -0) 📝 `packages/client/src/hooks/use-game.ts` (+33 -0) 📝 `packages/client/src/lib/game-setup-share.ts` (+1 -0) 📝 `packages/server/src/routes/encounter.routes.ts` (+29 -1) 📝 `packages/server/src/routes/game.routes.ts` (+193 -1) 📝 `packages/server/src/services/game/gm-prompts.ts` (+11 -3) 📝 `packages/server/src/services/generation/game-gm-prompt-runtime.ts` (+4 -0) ➕ `packages/shared/src/features/tactical-combat/ai.ts` (+192 -0) ➕ `packages/shared/src/features/tactical-combat/classes.ts` (+81 -0) _...and 10 more files_ </details> ### 📄 Description <!-- Target branch: staging --> ## Linked issue No linked issue — I built and playtested this directly as maintainer work. Happy to open a retroactive feature request if we want it on the board. ## Why this change - Game mode has exactly one combat flow today: narrative "classic" combat resolved in prose by the GM. Players who want crunchier, more game-like fights have no option. - This adds a **Combat Preference** so each game can choose between the existing classic combat and a new tactical, grid-based battle style (Fire Emblem / FF Tactics-inspired). Games that stay on classic are untouched — their prompts and flow are byte-identical. ## What changed - **New shared feature `packages/shared/src/features/tactical-combat/`** — a deterministic, seed-driven battle engine (`engine.ts`), enemy-phase AI (`ai.ts`), unit classes (`classes.ts`), procedural terrain/grid generation (`grid-gen.ts`), plus RNG/math helpers and types. All combat resolution happens in the engine and is reproducible from a seed; the LLM only supplies the encounter blueprint (units, flavor, scene), never dice outcomes. - **Server** — `game.routes.ts` gains tactical encounter start/action endpoints. Combat state round-trips through the client and is validated on every action; the enemy phase runs server-side through the same engine. `encounter.routes.ts` and GM prompts were touched only to branch on the preference, so classic-combat prompt assembly is unchanged when tactical is off. - **Client** — new `TacticalCombatUI.tsx`: painted terrain grid with per-scene backdrops, movement/attack range overlays, animated unit movement, floating damage/heal/miss popups, a draggable unit inspector and action menu, staged moves rendered as translucent dashed previews until confirmed ("Confirm Move"), KO'd units exit-fading off the battlefield, encounter restart, and a mobile-friendly layout. `GameSetupWizard` gets the Combat Preference selector; Chat Settings gets a **Combat Style** section so the preference can be changed mid-game; `GameSurface` handles encounter lifecycle, formations, and background generation. - **Terrain tile art** under `packages/client/public/tactical/` (webp). - **CHANGELOG.md** — feature entry added under `[Unreleased]`. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - `pnpm check` exits 0 on the current head; 25 local engine tests pass (`node:test` via tsx). - Playtested over seven feedback rounds on a private test deployment, on desktop and mobile: full battles against the AI across all four difficulties, every unit class, movement/attack ranges, counters, crits, misses, KO removal mid-animation, staged-move previews, restart, light + dark themes, and the container Docker build (the test deployment builds from this branch's Dockerfile). - Engine correctness was property-tested with a 300-battle seeded auto-battle simulation (local-only test, gitignored like the rest of the test suite): no offensive event ever targets an already-dead unit, no unit ever moves twice in one action, and every battle's event stream replays to the engine's exact HP values. ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) CHANGELOG.md was updated in this branch; no other docs are affected and there is no version bump. ## UI evidence (if applicable) <img width="491" height="584" alt="Choosing Combat Mode" src="https://github.com/user-attachments/assets/6a6ccc56-30f1-4fe8-b1fc-a4a3f550de13" /> https://github.com/user-attachments/assets/c7e877aa-11ea-465f-b0ab-fbe62dba810e <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit * **New Features** * Added “Combat Preference” / “Combat Style” setting to choose **Classic** or **Tactical (grid)** combat for the next battle (setup + in-game/chat settings). * Tactical battles include themed terrain/formation, unit inspection and action menus, movement previews, enemy threat overlay, combat log, and animated resolution with victory/defeat/flee and restartable encounters. * **Documentation** * Updated the changelog to describe the new Combat Preference and tactical battle experience. <!-- 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:06:07 +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#6005
No description provided.