Release Healer Man 0.1.6
This commit is contained in:
1 parent
55cfd43d66
commit
b12fb84859
96 files changed
+10874
-609
No files matched your search
@@ -0,0 +1,49 @@
|
||||
import type { DamageSchool } from "./combatAuras";
|
||||
|
||||
export type StructuredCombatEventKind =
|
||||
| "damage"
|
||||
| "healing"
|
||||
| "absorb"
|
||||
| "resource"
|
||||
| "aura"
|
||||
| "cast"
|
||||
| "interrupt"
|
||||
| "death"
|
||||
| "resurrection";
|
||||
|
||||
export interface StructuredCombatEvent {
|
||||
readonly id: number;
|
||||
readonly occurredAt: number;
|
||||
readonly kind: StructuredCombatEventKind;
|
||||
readonly sourceActorId: string;
|
||||
readonly targetActorId: string;
|
||||
readonly abilityId?: string;
|
||||
readonly school?: DamageSchool;
|
||||
readonly rawAmount: number;
|
||||
readonly effectiveAmount: number;
|
||||
readonly overheal: number;
|
||||
readonly absorbed: number;
|
||||
readonly critical: boolean;
|
||||
readonly outcome?: string;
|
||||
}
|
||||
export type CombatEventInput = Omit<StructuredCombatEvent, "id">;
|
||||
|
||||
export const MAX_COMBAT_EVENT_HISTORY = 200;
|
||||
|
||||
export function appendCombatEvent(
|
||||
events: readonly StructuredCombatEvent[],
|
||||
event: CombatEventInput,
|
||||
id: number,
|
||||
maximum = MAX_COMBAT_EVENT_HISTORY,
|
||||
): readonly StructuredCombatEvent[] {
|
||||
const next = Object.freeze({
|
||||
...event,
|
||||
id,
|
||||
occurredAt: Math.max(0, Number.isFinite(event.occurredAt) ? event.occurredAt : 0),
|
||||
rawAmount: Math.max(0, Number.isFinite(event.rawAmount) ? event.rawAmount : 0),
|
||||
effectiveAmount: Math.max(0, Number.isFinite(event.effectiveAmount) ? event.effectiveAmount : 0),
|
||||
overheal: Math.max(0, Number.isFinite(event.overheal) ? event.overheal : 0),
|
||||
absorbed: Math.max(0, Number.isFinite(event.absorbed) ? event.absorbed : 0),
|
||||
});
|
||||
return Object.freeze([...events, next].slice(-Math.max(1, Math.trunc(maximum))));
|
||||
}
|
||||
Reference in new issue
Block a user