Skip to main content

wowlab_engine_combat/builder/spell_builder/
resources.rs

1use super::{BuilderSpellEffect, ResourcePool, SpellDefinitionDraft};
2
3impl SpellDefinitionDraft {
4    pub fn cost(mut self, amount: f64) -> Self {
5        self.resource_cost = amount;
6
7        self
8    }
9
10    /// Charge a percentage of the actor's configured base primary-resource maximum.
11    pub fn cost_percent_of_base(mut self, percent: f64) -> Self {
12        self.resource_cost_pct = wowlab_types::data::ResourceCostPercent::base(percent);
13
14        self
15    }
16
17    /// Charge a percentage of the actor's current modified primary-resource maximum.
18    pub fn cost_percent_of_maximum(mut self, percent: f64) -> Self {
19        self.resource_cost_pct = wowlab_types::data::ResourceCostPercent::maximum(percent);
20
21        self
22    }
23
24    /// Pay a flat amount plus a percent of caster maximum health when the spell is cast.
25    pub fn health_cost(mut self, amount: f64, percent_of_maximum: f64) -> Self {
26        self.health_cost = amount.max(0.0);
27        self.health_cost_pct = percent_of_maximum.max(0.0);
28
29        self
30    }
31
32    /// Optionally spend flat health plus a percentage of caster maximum health.
33    pub fn health_optional_cost(mut self, amount: f64, percent_of_maximum: f64) -> Self {
34        self.health_optional_cost = amount.max(0.0);
35        self.health_optional_cost_pct =
36            wowlab_types::data::ResourceCostPercent::maximum(percent_of_maximum.max(0.0));
37
38        self
39    }
40
41    pub fn gain(mut self, amount: f64) -> Self {
42        self.resource_gain = amount;
43
44        self
45    }
46
47    pub fn secondary_cost(mut self, amount: f64) -> Self {
48        self.secondary_resource_cost = amount;
49
50        self
51    }
52
53    pub fn secondary_gain(mut self, amount: f64) -> Self {
54        self.secondary_resource_gain = amount;
55
56        self
57    }
58
59    pub fn additional_resource_gain(mut self, amount: f64) -> Self {
60        self.followup_effects.push(BuilderSpellEffect::Energize {
61            effect: None,
62            pool: ResourcePool::Primary,
63            amount,
64        });
65
66        self
67    }
68
69    pub(super) fn optional_cost(mut self, amount: f64) -> Self {
70        self.optional_resource_cost = amount;
71
72        self
73    }
74
75    pub(super) fn secondary_optional_cost(mut self, amount: f64) -> Self {
76        self.secondary_optional_resource_cost = amount;
77
78        self
79    }
80}