Combatants can now be assigned to party or enemy side via a toggle in the difficulty breakdown panel. Party-side NPCs subtract their XP from the encounter total, letting allied NPCs reduce difficulty. PCs default to party, non-PCs to enemy — users who don't use sides see no change. Side persists across reload and export/import. Closes #22 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
19 lines
460 B
TypeScript
19 lines
460 B
TypeScript
import {
|
|
type CombatantId,
|
|
type DomainError,
|
|
type DomainEvent,
|
|
setSide,
|
|
} from "@initiative/domain";
|
|
import type { EncounterStore } from "./ports.js";
|
|
import { runEncounterAction } from "./run-encounter-action.js";
|
|
|
|
export function setSideUseCase(
|
|
store: EncounterStore,
|
|
combatantId: CombatantId,
|
|
value: "party" | "enemy",
|
|
): DomainEvent[] | DomainError {
|
|
return runEncounterAction(store, (encounter) =>
|
|
setSide(encounter, combatantId, value),
|
|
);
|
|
}
|