Skip to main content

wowlab_engine_combat/builder/spell_builder/
cooldown.rs

1use super::{
2    CdrCondition, CdrEffect, CooldownCategoryId, LocalAuraIdx, LocalSpellIdx, SpellDefinitionDraft,
3};
4
5impl SpellDefinitionDraft {
6    pub fn cooldown(mut self, secs: f64) -> Self {
7        self.cooldown_secs = Some(secs);
8
9        self
10    }
11
12    pub fn charges(mut self, max: u8, recharge_secs: f64) -> Self {
13        self.max_charges = max;
14        self.recharge_secs = Some(recharge_secs);
15
16        if !self.cooldown_secs.is_some_and(|secs| secs > 0.0) {
17            self.cooldown_secs = Some(recharge_secs);
18        }
19
20        self
21    }
22
23    /// Scale this spell's cooldown or charge recharge with the actor's haste.
24    pub fn hasted_cooldown(mut self) -> Self {
25        self.cooldown_hasted = true;
26
27        self
28    }
29
30    /// Keep this spell's cooldown or charge recharge on wall-clock time.
31    pub fn unhasted_cooldown(mut self) -> Self {
32        self.cooldown_hasted = false;
33
34        self
35    }
36
37    pub fn gcd_haste_type(mut self, haste_type: wowlab_types::combat::GcdHasteType) -> Self {
38        self.gcd_haste_type = haste_type;
39
40        self
41    }
42
43    /// Applies the DBC start-recovery bucket.
44    pub fn start_recovery_category(mut self, category: Option<CooldownCategoryId>) -> Self {
45        self.start_recovery_category = category;
46
47        self
48    }
49
50    pub fn cooldown_categories(
51        mut self,
52        cooldown: Option<CooldownCategoryId>,
53        category_cooldown_secs: f64,
54        charge: Option<CooldownCategoryId>,
55    ) -> Self {
56        self.cooldown_category = cooldown;
57        self.category_cooldown_secs = category_cooldown_secs.max(0.0);
58        self.charge_category = charge;
59
60        self
61    }
62
63    pub fn reduces_cd(mut self, target: LocalSpellIdx, amount_ms: u32) -> Self {
64        self.cdr_effects.push(CdrEffect {
65            target_spell_local: target.0,
66            amount_ms,
67            condition: CdrCondition::Always,
68        });
69
70        self
71    }
72
73    pub fn reduces_cd_chance(mut self, target: LocalSpellIdx, amount_ms: u32, chance: f64) -> Self {
74        self.cdr_effects.push(CdrEffect {
75            target_spell_local: target.0,
76            amount_ms,
77            condition: CdrCondition::ProcChance { chance },
78        });
79
80        self
81    }
82
83    pub fn resets_cd_while(mut self, target: LocalSpellIdx, aura: LocalAuraIdx) -> Self {
84        self.cdr_effects.push(CdrEffect {
85            target_spell_local: target.0,
86            amount_ms: 0,
87            condition: CdrCondition::ResetWhileAura { aura_local: aura.0 },
88        });
89
90        self
91    }
92}