[GH-ISSUE #8109] [Feature]: Pluggable combat-style seam in GameSurface (start / render / top-chrome / active) #7564

Closed
opened 2026-10-24 04:04:18 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @bahaynes on GitHub (Oct 22, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8109

Originally assigned to: @kolacheee on GitHub.

What problem does this solve?

GameCombatStyle is a closed union ("classic" | "tactical", packages/shared/src/types/game.ts:33, plus 6 more hardcoded ["classic", "tactical"] copies). GameSurface.tsx (~14.3k lines) branches on that union inline in several places. There's no seam a combat style can plug into, so adding one means hand-editing the same file in all of these places:

  1. Start dispatch in generateCombatStateForMessage (GameSurface.tsx:9557). A style that sets up its own encounter state has to return early before the classic party/enemies generation pass.
  2. Render branch. The DirectedCombatUI / effectiveCombatStyle === "tactical" ? <TacticalCombatUI> : <GameCombatUI> ternary (~13438) is the only place a combat surface can mount.
  3. Top-chrome offset. Two tacticalCombatActive ? "top-[calc(var(--tactical-chrome-height…" : topOverlayOffsetClass checks (~12995, ~13081), plus controlRowOffset, decide whether the HUD yields to a combat top bar. Only tactical can opt in.
  4. Overlay hiding. combatUiActive (8949) means "classic party/enemies are populated". A surface that keeps its own state never counts as active, so the persistent map/party overlays stay drawn on top of it.

I maintain a small downstream fork that carries one extra combat style. On every rebase onto staging, nearly all of the conflict volume lands in GameSurface.tsx. A trial merge against staging @ 8f8770cb6 gives 9 conflict hunks there, more than every other file combined. Most of them are just upstream JSX moving next to the ~20 small insertion points listed above, not real logic clashes. The same friction applies to anyone, upstream or downstream, who wants to try a combat style without touching the 14k-line surface.

Proposed solution

Additive and client-only. Combat mechanics stay vanilla, in the spirit of #5094.

A small combat-style lookup that GameSurface consults instead of branching on string literals:

interface CombatStyleSurface {
  /** Return true to take over combat start (skip the classic generation pass). */
  start?(ctx: { chatId: string; messageId: string; hint?: string }): boolean;
  /** Mounted in place of GameCombatUI/TacticalCombatUI while active. */
  render?(ctx: CombatSurfaceContext): ReactNode;
  /** The style draws its own top bar; HUD/controls shift below --tactical-chrome-height. */
  ownsTopChrome?: boolean;
  /** For styles that keep their own state outside combatParty/combatEnemies. */
  isActive?(chatId: string): boolean;
}
  • Register classic and tactical through it, so behavior doesn't change.
  • Replace the inline checks with surface.ownsTopChrome and combatUiActive || surface.isActive?.(chatId).
  • Widen GameCombatStyle to "classic" | "tactical" | (string & {}), or derive it from the registry, and validate setup-schema values against the registered keys.

Doing this would also shrink GameSurface.tsx, because the tactical branch moves out of it.

Alternatives considered

  • Ruleset fights (#8048/#8049) and the Experience combat seam (capability API 1.11, #5094). Both route into the vanilla generation pass and the built-in UIs. An Experience can request combat but cannot provide a combat surface or start handler, so neither covers this case.
  • Keep patching GameSurface downstream. This is what we do today. It works, but it's the single largest source of rebase conflicts.

Additional context

Verified against staging @ 8f8770cb6 by trial-merging the fork onto it (git merge-tree). Line numbers above refer to that commit. Happy to send a PR for the registry with classic/tactical migrated and no behavior change, if the shape is acceptable.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @bahaynes on GitHub (Oct 22, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8109 Originally assigned to: @kolacheee on GitHub. ## What problem does this solve? `GameCombatStyle` is a closed union (`"classic" | "tactical"`, `packages/shared/src/types/game.ts:33`, plus 6 more hardcoded `["classic", "tactical"]` copies). `GameSurface.tsx` (~14.3k lines) branches on that union inline in several places. There's no seam a combat style can plug into, so adding one means hand-editing the same file in all of these places: 1. **Start dispatch** in `generateCombatStateForMessage` (`GameSurface.tsx:9557`). A style that sets up its own encounter state has to return early before the classic party/enemies generation pass. 2. **Render branch.** The `DirectedCombatUI` / `effectiveCombatStyle === "tactical" ? <TacticalCombatUI> : <GameCombatUI>` ternary (~13438) is the only place a combat surface can mount. 3. **Top-chrome offset.** Two `tacticalCombatActive ? "top-[calc(var(--tactical-chrome-height…" : topOverlayOffsetClass` checks (~12995, ~13081), plus `controlRowOffset`, decide whether the HUD yields to a combat top bar. Only `tactical` can opt in. 4. **Overlay hiding.** `combatUiActive` (8949) means "classic party/enemies are populated". A surface that keeps its own state never counts as active, so the persistent map/party overlays stay drawn on top of it. I maintain a small downstream fork that carries one extra combat style. On every rebase onto `staging`, nearly all of the conflict volume lands in `GameSurface.tsx`. A trial merge against `staging` @ 8f8770cb6 gives 9 conflict hunks there, more than every other file combined. Most of them are just upstream JSX moving next to the ~20 small insertion points listed above, not real logic clashes. The same friction applies to anyone, upstream or downstream, who wants to try a combat style without touching the 14k-line surface. ## Proposed solution Additive and client-only. Combat mechanics stay vanilla, in the spirit of #5094. A small combat-style lookup that `GameSurface` consults instead of branching on string literals: ```ts interface CombatStyleSurface { /** Return true to take over combat start (skip the classic generation pass). */ start?(ctx: { chatId: string; messageId: string; hint?: string }): boolean; /** Mounted in place of GameCombatUI/TacticalCombatUI while active. */ render?(ctx: CombatSurfaceContext): ReactNode; /** The style draws its own top bar; HUD/controls shift below --tactical-chrome-height. */ ownsTopChrome?: boolean; /** For styles that keep their own state outside combatParty/combatEnemies. */ isActive?(chatId: string): boolean; } ``` - Register `classic` and `tactical` through it, so behavior doesn't change. - Replace the inline checks with `surface.ownsTopChrome` and `combatUiActive || surface.isActive?.(chatId)`. - Widen `GameCombatStyle` to `"classic" | "tactical" | (string & {})`, or derive it from the registry, and validate setup-schema values against the registered keys. Doing this would also shrink `GameSurface.tsx`, because the tactical branch moves out of it. ## Alternatives considered - **Ruleset fights (#8048/#8049) and the Experience combat seam (capability API 1.11, #5094).** Both route into the vanilla generation pass and the built-in UIs. An Experience can *request* combat but cannot *provide* a combat surface or start handler, so neither covers this case. - **Keep patching `GameSurface` downstream.** This is what we do today. It works, but it's the single largest source of rebase conflicts. ## Additional context Verified against `staging` @ 8f8770cb6 by trial-merging the fork onto it (`git merge-tree`). Line numbers above refer to that commit. Happy to send a PR for the registry with `classic`/`tactical` migrated and no behavior change, if the shape is acceptable. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-24 04:04:18 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Oct 22, 2026):

@kolacheee

<!-- gh-comment-id:6349640389 --> @SpicyMarinara commented on GitHub (Oct 22, 2026): @kolacheee
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#7564
No description provided.