22 lines
725 B
JavaScript
22 lines
725 B
JavaScript
export async function checkHpAfterDamageCondition(config, context) {
|
|
const actor = context.targetActor ?? context.actor;
|
|
if (!actor) return false;
|
|
|
|
const hp = actor.system?.attributes?.hp;
|
|
const value = Number(hp?.value ?? 0);
|
|
const max = Number(hp?.max ?? 0);
|
|
if (max <= 0) return false;
|
|
|
|
const actual = config.mode === "percent" ? (value / max) * 100 : value;
|
|
const threshold = Number(config.value ?? 0);
|
|
|
|
switch (config.operator ?? "lte") {
|
|
case "lt": return actual < threshold;
|
|
case "lte": return actual <= threshold;
|
|
case "gt": return actual > threshold;
|
|
case "gte": return actual >= threshold;
|
|
case "eq": return actual === threshold;
|
|
default: return actual <= threshold;
|
|
}
|
|
}
|