| 1 | import { StatusEffectType } from "./rules.js"; |
| 2 | |
| 3 | /** |
| 4 | * Player-facing copy + icon paths for HUD buff/debuff icons. |
| 5 | * Art lives under `client/assets/status-effects/<iconKey>.png` (placeholders until final art). |
| 6 | */ |
| 7 | export const STATUS_EFFECT_DISPLAY = Object.freeze({ |
| 8 | [StatusEffectType.healthRegen]: Object.freeze({ |
| 9 | iconKey: "health-regen", |
| 10 | title: "Health regeneration", |
| 11 | polarity: "buff", |
| 12 | describe (effect) |
| 13 | { |
| 14 | const rate = Number(effect?.amountPerSecond) || 1; |
| 15 | return `Restores ${rate} health each second.`; |
| 16 | } |
| 17 | }), |
| 18 | [StatusEffectType.staminaRegen]: Object.freeze({ |
| 19 | iconKey: "stamina-regen", |
| 20 | title: "Stamina regeneration", |
| 21 | polarity: "buff", |
| 22 | describe (effect) |
| 23 | { |
| 24 | const rate = Number(effect?.amountPerSecond) || 1; |
| 25 | return `Restores ${rate} stamina each second.`; |
| 26 | } |
| 27 | }), |
| 28 | [StatusEffectType.strengthBonus]: Object.freeze({ |
| 29 | iconKey: "strength-bonus", |
| 30 | title: "Strength", |
| 31 | polarity: "buff", |
| 32 | describe (effect) |
| 33 | { |
| 34 | const amount = effect?.amount | 0 || 0; |
| 35 | return `Increases Strength by ${amount}.`; |
| 36 | } |
| 37 | }), |
| 38 | [StatusEffectType.mindBonus]: Object.freeze({ |
| 39 | iconKey: "mind-bonus", |
| 40 | title: "Clarity", |
| 41 | polarity: "buff", |
| 42 | describe (effect) |
| 43 | { |
| 44 | const amount = effect?.amount | 0 || 0; |
| 45 | return `Increases Mind by ${amount}.`; |
| 46 | } |
| 47 | }), |
| 48 | [StatusEffectType.staminaDrain]: Object.freeze({ |
| 49 | iconKey: "stamina-drain", |
| 50 | title: "Stamina drain", |
| 51 | polarity: "debuff", |
| 52 | describe (effect) |
| 53 | { |
| 54 | const rate = Number(effect?.amountPerSecond) || 1; |
| 55 | return `Drains ${rate} stamina each second.`; |
| 56 | } |
| 57 | }), |
| 58 | [StatusEffectType.glow]: Object.freeze({ |
| 59 | iconKey: "glow", |
| 60 | title: "Glow", |
| 61 | polarity: "debuff", |
| 62 | describe () |
| 63 | { |
| 64 | return "You cast a faint light around yourself."; |
| 65 | } |
| 66 | }), |
| 67 | [StatusEffectType.shrink]: Object.freeze({ |
| 68 | iconKey: "shrink", |
| 69 | title: "Diminished", |
| 70 | polarity: "debuff", |
| 71 | describe (effect) |
| 72 | { |
| 73 | const scale = Math.round((Number(effect?.scale) || 0.5) * 100); |
| 74 | return `Your body is shrunk to ${scale}% size.`; |
| 75 | } |
| 76 | }), |
| 77 | [StatusEffectType.blind]: Object.freeze({ |
| 78 | iconKey: "blind", |
| 79 | title: "Blindness", |
| 80 | polarity: "debuff", |
| 81 | describe () |
| 82 | { |
| 83 | return "Darkness closes in; you can barely see what is next to you."; |
| 84 | } |
| 85 | }) |
| 86 | }); |
| 87 | |
| 88 | export function statusEffectDisplay (type) |
| 89 | { |
| 90 | return STATUS_EFFECT_DISPLAY[type] ?? null; |
| 91 | } |
| 92 | |
| 93 | export function statusEffectIconPath (type) |
| 94 | { |
| 95 | const display = statusEffectDisplay(type); |
| 96 | const key = display?.iconKey ?? String(type ?? "unknown"); |
| 97 | return `/assets/status-effects/${key}.png`; |
| 98 | } |
| 99 | |
| 100 | export function formatStatusRemaining (ms) |
| 101 | { |
| 102 | const total = Math.max(0, Math.ceil((ms | 0) / 1000)); |
| 103 | if (total < 60) |
| 104 | { return `${total}s`; } |
| 105 | const minutes = (total / 60) | 0; |
| 106 | const seconds = total % 60; |
| 107 | return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`; |
| 108 | } |