[PR #4391] [CLOSED] feat(game): expand Classic & Tactical combat — server-authoritative sessions, maneuvers that always resolve, objectives & bosses #6358

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4391
Author: @Romuromylus
Created: 8/1/2026
Status: ❌ Closed

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


📝 Commits (6)

  • 4620197 feat(game): expand Classic and Tactical combat
  • 5cf27c4 fix(game): make combat maneuvers always resolve
  • e85d6af fix(game): dedupe activeChatIdRef after staging rebase
  • 65c5424 fix(game): release combat aftermath guard after it resolves
  • 4f2bb3f fix(game): never hydrate a completed combat session as a live battle
  • aa1ac51 fix(game): don't unwind combat state while a combat declaration is pending

📊 Changes

33 files changed (+7505 additions, -597 deletions)

View changed files

📝 CHANGELOG.md (+13 -1)
➕ COMBAT_EXPANSION_IMPLEMENTATION_PLAN.md (+214 -0)
📝 docs/game/combat.md (+20 -9)
📝 docs/game/getting-started.md (+18 -16)
➕ docs/game/tactical-combat.md (+92 -0)
📝 package.json (+2 -1)
📝 packages/client/src/components/game/GameCombatUI.tsx (+449 -120)
📝 packages/client/src/components/game/GameSurface.tsx (+519 -110)
📝 packages/client/src/components/game/TacticalCombatUI.tsx (+854 -177)
📝 packages/client/src/hooks/use-game.ts (+109 -7)
📝 packages/client/src/localization/locales/en.json (+10 -0)
📝 packages/server/src/db/file-backed-store.ts (+2 -0)
➕ packages/server/src/db/schema/game-combat-sessions.ts (+21 -0)
📝 packages/server/src/db/schema/index.ts (+1 -0)
📝 packages/server/src/routes/encounter.routes.ts (+6 -2)
📝 packages/server/src/routes/game.routes.ts (+840 -46)
➕ packages/server/src/services/game/combat-session.service.ts (+1073 -0)
📝 packages/server/src/services/game/combat.service.ts (+118 -38)
📝 packages/server/src/services/game/loot.service.ts (+21 -13)
➕ packages/server/src/services/game/maneuver-proposal.ts (+379 -0)

...and 13 more files

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.

Linked issue

No linked issue yet — this grew out of my own game-mode testing (the maneuver no-op below was found while playing a paladin run). I can open a tracking issue for the expansion if we want one on the board.

Why this change

  • Game-mode combat resolved everything client-side and shallowly; there was no server-authoritative session state, so objectives, bosses, and multi-turn structure could not exist and results were easy to desync.
  • Combat "maneuvers" (free-text player actions) silently did nothing in both styles: the LLM adjudicator's output was validated by a .strict() zod schema, so one malformed key (e.g. flat x/y instead of a nested tile) rejected the entire proposal and the player got an invalid-maneuver toast with their turn consumed. Confirmed in production logs (ZodError: unrecognized_keys ["x","y"]).

What changed

  • Server-authoritative combat sessions (combat-session.service.ts, new combat-session shared types): seeded RNG, per-action cursors, objectives and boss phases, for BOTH Classic and Tactical styles.
  • Maneuver pipeline rework so a maneuver always resolves:
    • New maneuver-proposal.ts normalizer salvages near-miss adjudicator output (flat coords, duration→turnsLeft, name/"self"→unit id, percent difficulties, tile-less cover→defense buff), drops only unusable effects with player-readable reasons, and reports what was coerced.
    • The strict schema is deleted; the adjudicator prompt now includes per-effect JSON examples and reach rules, gets a 3000-token budget, a streamed retry on empty output, and one repair round — and returns null instead of throwing, so the engine's deterministic keyword resolvers take over as the last rung. A maneuver can no longer 400.
    • Tactical engine: shared rollManeuver, self-target defaults for heal/guard, nearestReachableFoe, partial-application notes ("Part of the maneuver could not take effect: …"), and keyword fallback reusing the same roll when every proposed effect is dropped.
    • Classic: keyword fallback extracted and reused, cover becomes a Shielded status, move/terrain narrate instead of vanishing, self-target defaults.
  • Client: combat UI for sessions/objectives/log in GameSurface.tsx and related components.
  • Regressions: new regression:combat lane (combat-session.regression.ts, tactical-combat.regression.ts) with adversarial fixtures including the exact production payload that used to 400; wired into the aggregate regression script.
  • Docs: docs/game/combat.md + docs/game/tactical-combat.md document the resolution ladder and reach limits; CHANGELOG entries under [Unreleased].
  • Rebase reconciliation: staging's ea70ba89f introduced its own activeChatIdRef in GameSurface.tsx alongside this branch's; deduped to a single declaration keeping upstream's render-time assignment semantics (d5edfb6aa).

33 files, +7451/−597 against current staging (ed0e2422b).

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

Runs already performed on this exact head (boxes left unchecked until I re-verify and sign off):

  • pnpm check green (impeccable, localization, lint 0 warnings, full build), pnpm regression:combat 2/2, pnpm regression:docs 1/1, lockfile unchanged.
  • Docker image built and deployed to my private test instance; container healthy (HTTP 200), server dist verified to contain the new maneuver pipeline and zero references to the removed strict schema.
  • Still to do by hand in the browser: paladin "heal myself and summon a shield" in both styles, targetless maneuvers, out-of-reach partial application, nonsense input hitting the keyword fallback, and a chat-switch pass over the shared-world setup path touched by the activeChatIdRef dedupe.

Docs and release impact

  • 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)

Note: docs/game/combat.md and docs/game/tactical-combat.md changed, so a [docs-i18n] follow-up is needed before merge.

UI evidence (if applicable)

To be attached after the in-browser test pass.


🔄 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/4391 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 8/1/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `feat/game-mode-combat-expansion` --- ### 📝 Commits (6) - [`4620197`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4620197c4d321f040408086364ef4c96452e36ca) feat(game): expand Classic and Tactical combat - [`5cf27c4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5cf27c409210cdf111a7dbccdbd4c56cf597da48) fix(game): make combat maneuvers always resolve - [`e85d6af`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e85d6aff4c1ec66f8981874c281df4d03202c9fe) fix(game): dedupe activeChatIdRef after staging rebase - [`65c5424`](https://github.com/Pasta-Devs/Marinara-Engine/commit/65c542461fa2d48b11b0696719d2a45f2e1a08b4) fix(game): release combat aftermath guard after it resolves - [`4f2bb3f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4f2bb3fdc328c89f6a1cd59c6eae262403ea5cbb) fix(game): never hydrate a completed combat session as a live battle - [`aa1ac51`](https://github.com/Pasta-Devs/Marinara-Engine/commit/aa1ac51467d5c68530bb2c724c9c429129e8a086) fix(game): don't unwind combat state while a combat declaration is pending ### 📊 Changes **33 files changed** (+7505 additions, -597 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+13 -1) ➕ `COMBAT_EXPANSION_IMPLEMENTATION_PLAN.md` (+214 -0) 📝 `docs/game/combat.md` (+20 -9) 📝 `docs/game/getting-started.md` (+18 -16) ➕ `docs/game/tactical-combat.md` (+92 -0) 📝 `package.json` (+2 -1) 📝 `packages/client/src/components/game/GameCombatUI.tsx` (+449 -120) 📝 `packages/client/src/components/game/GameSurface.tsx` (+519 -110) 📝 `packages/client/src/components/game/TacticalCombatUI.tsx` (+854 -177) 📝 `packages/client/src/hooks/use-game.ts` (+109 -7) 📝 `packages/client/src/localization/locales/en.json` (+10 -0) 📝 `packages/server/src/db/file-backed-store.ts` (+2 -0) ➕ `packages/server/src/db/schema/game-combat-sessions.ts` (+21 -0) 📝 `packages/server/src/db/schema/index.ts` (+1 -0) 📝 `packages/server/src/routes/encounter.routes.ts` (+6 -2) 📝 `packages/server/src/routes/game.routes.ts` (+840 -46) ➕ `packages/server/src/services/game/combat-session.service.ts` (+1073 -0) 📝 `packages/server/src/services/game/combat.service.ts` (+118 -38) 📝 `packages/server/src/services/game/loot.service.ts` (+21 -13) ➕ `packages/server/src/services/game/maneuver-proposal.ts` (+379 -0) _...and 13 more files_ </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. ## Linked issue No linked issue yet — this grew out of my own game-mode testing (the maneuver no-op below was found while playing a paladin run). I can open a tracking issue for the expansion if we want one on the board. ## Why this change - Game-mode combat resolved everything client-side and shallowly; there was no server-authoritative session state, so objectives, bosses, and multi-turn structure could not exist and results were easy to desync. - Combat "maneuvers" (free-text player actions) silently did nothing in both styles: the LLM adjudicator's output was validated by a `.strict()` zod schema, so one malformed key (e.g. flat `x`/`y` instead of a nested `tile`) rejected the entire proposal and the player got an invalid-maneuver toast with their turn consumed. Confirmed in production logs (`ZodError: unrecognized_keys ["x","y"]`). ## What changed - **Server-authoritative combat sessions** (`combat-session.service.ts`, new `combat-session` shared types): seeded RNG, per-action cursors, objectives and boss phases, for BOTH Classic and Tactical styles. - **Maneuver pipeline rework** so a maneuver always resolves: - New `maneuver-proposal.ts` normalizer salvages near-miss adjudicator output (flat coords, `duration`→`turnsLeft`, name/"self"→unit id, percent difficulties, tile-less cover→defense buff), drops only unusable effects with player-readable reasons, and reports what was coerced. - The strict schema is deleted; the adjudicator prompt now includes per-effect JSON examples and reach rules, gets a 3000-token budget, a streamed retry on empty output, and one repair round — and returns `null` instead of throwing, so the engine's deterministic keyword resolvers take over as the last rung. A maneuver can no longer 400. - Tactical engine: shared `rollManeuver`, self-target defaults for heal/guard, `nearestReachableFoe`, partial-application notes ("Part of the maneuver could not take effect: …"), and keyword fallback reusing the same roll when every proposed effect is dropped. - Classic: keyword fallback extracted and reused, cover becomes a `Shielded` status, move/terrain narrate instead of vanishing, self-target defaults. - **Client**: combat UI for sessions/objectives/log in `GameSurface.tsx` and related components. - **Regressions**: new `regression:combat` lane (`combat-session.regression.ts`, `tactical-combat.regression.ts`) with adversarial fixtures including the exact production payload that used to 400; wired into the aggregate `regression` script. - **Docs**: `docs/game/combat.md` + `docs/game/tactical-combat.md` document the resolution ladder and reach limits; CHANGELOG entries under `[Unreleased]`. - **Rebase reconciliation**: staging's `ea70ba89f` introduced its own `activeChatIdRef` in `GameSurface.tsx` alongside this branch's; deduped to a single declaration keeping upstream's render-time assignment semantics (d5edfb6aa). 33 files, +7451/−597 against current `staging` (`ed0e2422b`). ## 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 Runs already performed on this exact head (boxes left unchecked until I re-verify and sign off): - `pnpm check` green (impeccable, localization, lint 0 warnings, full build), `pnpm regression:combat` 2/2, `pnpm regression:docs` 1/1, lockfile unchanged. - Docker image built and deployed to my private test instance; container healthy (HTTP 200), server dist verified to contain the new maneuver pipeline and zero references to the removed strict schema. - Still to do by hand in the browser: paladin "heal myself and summon a shield" in both styles, targetless maneuvers, out-of-reach partial application, nonsense input hitting the keyword fallback, and a chat-switch pass over the shared-world setup path touched by the `activeChatIdRef` dedupe. ## Docs and release impact - [ ] 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) Note: `docs/game/combat.md` and `docs/game/tactical-combat.md` changed, so a `[docs-i18n]` follow-up is needed before merge. ## UI evidence (if applicable) To be attached after the in-browser test pass. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:09: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#6358
No description provided.