Skip to main content

wowlab_engine_combat/builder/aura_builder/effects/
timing.rs

1use super::{
2    AuraDefinitionDraft, BuffEffect, BuilderError, EffectLookup, ModifierPropertyKind,
3    aura_subtype_modifier, effect_parts, modifier_property_is,
4};
5
6pub(in crate::builder::aura_builder) fn apply_timing_modifier_effect(
7    mut aura: AuraDefinitionDraft,
8    lookup: EffectLookup<'_>,
9) -> Result<AuraDefinitionDraft, BuilderError> {
10    let (data, idx, spell_id, effect_index) = effect_parts(lookup);
11    let effect_aura = data.effect_aura(idx, effect_index);
12    let property = data.effect_misc_value_0(idx, effect_index);
13    let Some((operation, _)) = aura_subtype_modifier(effect_aura) else {
14        return Ok(aura);
15    };
16    let effect = if modifier_property_is(property, ModifierPropertyKind::CastTime) {
17        Some(BuffEffect::SpellCastTimeFromEffect {
18            value: data.base_points(idx, effect_index),
19            source_spell_id: spell_id,
20            effect_index,
21            operation,
22        })
23    } else if modifier_property_is(property, ModifierPropertyKind::GlobalCooldown) {
24        Some(BuffEffect::SpellGcdFromEffect {
25            value: data.base_points(idx, effect_index),
26            source_spell_id: spell_id,
27            effect_index,
28            operation,
29        })
30    } else if modifier_property_is(property, ModifierPropertyKind::Duration) {
31        Some(BuffEffect::SpellDurationFromEffect {
32            value: data.base_points(idx, effect_index),
33            source_spell_id: spell_id,
34            effect_index,
35            operation,
36        })
37    } else if modifier_property_is(property, ModifierPropertyKind::TickTime) {
38        Some(BuffEffect::SpellTickTimeFromEffect {
39            value: data.base_points(idx, effect_index),
40            source_spell_id: spell_id,
41            effect_index,
42            operation,
43        })
44    } else if modifier_property_is(property, ModifierPropertyKind::ResistPushback) {
45        Some(BuffEffect::ResistPushbackFromEffect {
46            value: data.base_points(idx, effect_index),
47            source_spell_id: spell_id,
48            effect_index,
49            operation,
50        })
51    } else {
52        None
53    };
54
55    if let Some(effect) = effect {
56        aura = aura.push_effect(effect)?;
57    }
58
59    Ok(aura)
60}