Persistent player character templates (name, AC, HP, color, icon) with full CRUD, bestiary-style search to add PCs to encounters with pre-filled stats, and color/icon visual distinction in combatant rows. Also stops the stat block panel from auto-opening when adding a creature. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
24 lines
536 B
TypeScript
24 lines
536 B
TypeScript
import {
|
|
type DomainError,
|
|
type DomainEvent,
|
|
deletePlayerCharacter,
|
|
isDomainError,
|
|
type PlayerCharacterId,
|
|
} from "@initiative/domain";
|
|
import type { PlayerCharacterStore } from "./ports.js";
|
|
|
|
export function deletePlayerCharacterUseCase(
|
|
store: PlayerCharacterStore,
|
|
id: PlayerCharacterId,
|
|
): DomainEvent[] | DomainError {
|
|
const characters = store.getAll();
|
|
const result = deletePlayerCharacter(characters, id);
|
|
|
|
if (isDomainError(result)) {
|
|
return result;
|
|
}
|
|
|
|
store.save([...result.characters]);
|
|
return result.events;
|
|
}
|