Files
initiative/packages/domain/src/events.ts
T
LukasandClaude Opus 4.6 4b1c1deda2
CI / check (push) Successful in 2m39s
CI / build-image (push) Successful in 19s
Add PF2e persistent damage condition tags
Persistent damage displayed as compact tags with damage type icon and
formula (e.g., Flame + "2d6"). Supports fire, bleed, acid, cold,
electricity, poison, and mental types. One instance per type, added via
sub-picker in the condition picker. PF2e only, persists across reload.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 12:09:31 +02:00

205 lines
5.0 KiB
TypeScript

import type { ConditionId } from "./conditions.js";
import type { CreatureId } from "./creature-types.js";
import type { PersistentDamageType } from "./persistent-damage.js";
import type { PlayerCharacterId } from "./player-character-types.js";
import type { CombatantId } from "./types.js";
export interface TurnAdvanced {
readonly type: "TurnAdvanced";
readonly previousCombatantId: CombatantId;
readonly newCombatantId: CombatantId;
readonly roundNumber: number;
}
export interface RoundAdvanced {
readonly type: "RoundAdvanced";
readonly newRoundNumber: number;
}
export interface CombatantAdded {
readonly type: "CombatantAdded";
readonly combatantId: CombatantId;
readonly name: string;
readonly position: number;
readonly init?: {
readonly maxHp?: number;
readonly ac?: number;
readonly initiative?: number;
readonly creatureId?: CreatureId;
readonly color?: string;
readonly icon?: string;
readonly playerCharacterId?: PlayerCharacterId;
};
}
export interface CombatantRemoved {
readonly type: "CombatantRemoved";
readonly combatantId: CombatantId;
readonly name: string;
}
export interface CombatantUpdated {
readonly type: "CombatantUpdated";
readonly combatantId: CombatantId;
readonly oldName: string;
readonly newName: string;
}
export interface InitiativeSet {
readonly type: "InitiativeSet";
readonly combatantId: CombatantId;
readonly previousValue: number | undefined;
readonly newValue: number | undefined;
}
export interface MaxHpSet {
readonly type: "MaxHpSet";
readonly combatantId: CombatantId;
readonly previousMaxHp: number | undefined;
readonly newMaxHp: number | undefined;
readonly previousCurrentHp: number | undefined;
readonly newCurrentHp: number | undefined;
}
export interface CurrentHpAdjusted {
readonly type: "CurrentHpAdjusted";
readonly combatantId: CombatantId;
readonly previousHp: number;
readonly newHp: number;
readonly delta: number;
}
export interface TempHpSet {
readonly type: "TempHpSet";
readonly combatantId: CombatantId;
readonly previousTempHp: number | undefined;
readonly newTempHp: number | undefined;
}
export interface TurnRetreated {
readonly type: "TurnRetreated";
readonly previousCombatantId: CombatantId;
readonly newCombatantId: CombatantId;
readonly roundNumber: number;
}
export interface RoundRetreated {
readonly type: "RoundRetreated";
readonly newRoundNumber: number;
}
export interface AcSet {
readonly type: "AcSet";
readonly combatantId: CombatantId;
readonly previousAc: number | undefined;
readonly newAc: number | undefined;
}
export interface CrSet {
readonly type: "CrSet";
readonly combatantId: CombatantId;
readonly previousCr: string | undefined;
readonly newCr: string | undefined;
}
export interface SideSet {
readonly type: "SideSet";
readonly combatantId: CombatantId;
readonly previousSide: "party" | "enemy" | undefined;
readonly newSide: "party" | "enemy";
}
export interface ConditionAdded {
readonly type: "ConditionAdded";
readonly combatantId: CombatantId;
readonly condition: ConditionId;
readonly value?: number;
}
export interface ConditionRemoved {
readonly type: "ConditionRemoved";
readonly combatantId: CombatantId;
readonly condition: ConditionId;
readonly value?: number;
}
export interface ConcentrationStarted {
readonly type: "ConcentrationStarted";
readonly combatantId: CombatantId;
}
export interface ConcentrationEnded {
readonly type: "ConcentrationEnded";
readonly combatantId: CombatantId;
}
export interface PersistentDamageAdded {
readonly type: "PersistentDamageAdded";
readonly combatantId: CombatantId;
readonly damageType: PersistentDamageType;
readonly formula: string;
}
export interface PersistentDamageRemoved {
readonly type: "PersistentDamageRemoved";
readonly combatantId: CombatantId;
readonly damageType: PersistentDamageType;
}
export interface CreatureAdjustmentSet {
readonly type: "CreatureAdjustmentSet";
readonly combatantId: CombatantId;
readonly adjustment: "weak" | "elite" | undefined;
}
export interface EncounterCleared {
readonly type: "EncounterCleared";
readonly combatantCount: number;
}
export interface PlayerCharacterCreated {
readonly type: "PlayerCharacterCreated";
readonly playerCharacterId: PlayerCharacterId;
readonly name: string;
}
export interface PlayerCharacterUpdated {
readonly type: "PlayerCharacterUpdated";
readonly playerCharacterId: PlayerCharacterId;
readonly oldName: string;
readonly newName: string;
}
export interface PlayerCharacterDeleted {
readonly type: "PlayerCharacterDeleted";
readonly playerCharacterId: PlayerCharacterId;
readonly name: string;
}
export type DomainEvent =
| TurnAdvanced
| RoundAdvanced
| CombatantAdded
| CombatantRemoved
| CombatantUpdated
| InitiativeSet
| MaxHpSet
| CurrentHpAdjusted
| TempHpSet
| TurnRetreated
| RoundRetreated
| AcSet
| CrSet
| SideSet
| ConditionAdded
| ConditionRemoved
| ConcentrationStarted
| ConcentrationEnded
| PersistentDamageAdded
| PersistentDamageRemoved
| CreatureAdjustmentSet
| EncounterCleared
| PlayerCharacterCreated
| PlayerCharacterUpdated
| PlayerCharacterDeleted;