Skip to main content

wowlab_engine_gamedata/game_data/
mod.rs

1//! Resolved game data for a spec: spell coefficients, costs, cooldowns, aura properties.
2
3macro_rules! require_accessor {
4    (
5        spell {
6            $(
7                $(#[$meta:meta])*
8                $required:ident -> $ty:ty, $field:literal
9                    => |$this:ident, $spell:ident| $value:expr
10            ),+ $(,)?
11        }
12    ) => {
13        $(
14            $(#[$meta])*
15            pub fn $required(
16                &self,
17                spell_id: wowlab_types::sim::SpellIdx,
18            ) -> Result<$ty, crate::GameDataError> {
19                {
20                    let $this = self;
21                    let $spell = spell_id;
22                    $value
23                }
24                .ok_or_else(|| missing_field(spell_id, $field))
25            }
26        )+
27    };
28    (
29        effect {
30            $(
31                $(#[$meta:meta])*
32                $required:ident -> $ty:ty => $field:ident, $field_name:literal
33            ),+ $(,)?
34        }
35    ) => {
36        $(
37            $(#[$meta])*
38            pub fn $required(
39                &self,
40                spell_id: wowlab_types::sim::SpellIdx,
41                effect_index: u8,
42            ) -> Result<$ty, crate::GameDataError> {
43                match self
44                    .inner
45                    .effects
46                    .values
47                    .get(&wowlab_types::sim::EffectRef::new(spell_id, effect_index))
48                {
49                    Some(values) => Ok(values.$field),
50                    None if self.is_empty() => Ok(0.0),
51                    None => Err(crate::GameDataError::missing_effect_field(
52                        spell_id,
53                        effect_index,
54                        $field_name,
55                    )),
56                }
57            }
58        )+
59    };
60}
61
62mod builder;
63mod consumables;
64mod curves;
65mod effect;
66mod effect_access;
67mod environment_access;
68mod game_tables;
69mod item_budget;
70mod passive_access;
71mod props;
72mod resolved_game_data;
73mod resolved_map;
74mod scaling_access;
75mod spell_access;
76mod stores;
77
78#[cfg(test)]
79mod tests;
80
81pub use builder::ResolvedGameDataBuilder;
82pub use consumables::{ConsumableBuff, ConsumableSpells, FoodBuff};
83pub use curves::ResolvedCurves;
84pub(crate) use effect::{CLASS_FAMILY_FLAGS, EffectValues, SpellClassFlags};
85pub use game_tables::{RatingMultiplierSlot, ResolvedGameTables};
86pub use item_budget::{ItemBudget, rating_multiplier_slot_for_gear};
87pub use props::{
88    AuraProps, PowerTypeProps, ResolvedDamageDef, ResolvedDamageKind, ResolvedDamageWeapon,
89    SpellProps,
90};
91pub(crate) use props::{
92    default_aura_props, neutral_spell_props, normalize_spell_modifier_defaults,
93};
94pub use resolved_game_data::ResolvedGameData;
95pub(crate) use resolved_game_data::ResolvedGameDataInner;
96pub use resolved_map::ResolvedMap;
97pub(crate) use stores::{EffectStore, EnvironmentStore, PassiveStore, ScalingStore, SpellStore};