Implement the 017-combat-conditions feature that adds D&D 5e status conditions to combatants with icon tags, color coding, and a compact toggle picker in the encounter tracker
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,3 +8,4 @@ export { retreatTurnUseCase } from "./retreat-turn-use-case.js";
|
||||
export { setAcUseCase } from "./set-ac-use-case.js";
|
||||
export { setHpUseCase } from "./set-hp-use-case.js";
|
||||
export { setInitiativeUseCase } from "./set-initiative-use-case.js";
|
||||
export { toggleConditionUseCase } from "./toggle-condition-use-case.js";
|
||||
|
||||
25
packages/application/src/toggle-condition-use-case.ts
Normal file
25
packages/application/src/toggle-condition-use-case.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
type CombatantId,
|
||||
type ConditionId,
|
||||
type DomainError,
|
||||
type DomainEvent,
|
||||
isDomainError,
|
||||
toggleCondition,
|
||||
} from "@initiative/domain";
|
||||
import type { EncounterStore } from "./ports.js";
|
||||
|
||||
export function toggleConditionUseCase(
|
||||
store: EncounterStore,
|
||||
combatantId: CombatantId,
|
||||
conditionId: ConditionId,
|
||||
): DomainEvent[] | DomainError {
|
||||
const encounter = store.get();
|
||||
const result = toggleCondition(encounter, combatantId, conditionId);
|
||||
|
||||
if (isDomainError(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
store.save(result.encounter);
|
||||
return result.events;
|
||||
}
|
||||
Reference in New Issue
Block a user