Skip to main content

wowlab_engine_content/
lib.rs

1//! Generated specialization and item bindings plus handwritten combat hooks.
2
3#![expect(
4    clippy::multiple_crate_versions,
5    reason = "the engine dependency graph currently resolves multiple versions of transitive crates"
6)]
7
8#[cfg(test)]
9#[global_allocator]
10static TEST_ALLOCATOR: wowlab_engine_combat::test_alloc::TestAllocator =
11    wowlab_engine_combat::test_alloc::TestAllocator;
12
13/// Crate version.
14pub const VERSION: &str = env!("CARGO_PKG_VERSION");
15
16mod catalog;
17mod composition;
18mod expansion_traits;
19#[rustfmt::skip]
20mod generated;
21pub(crate) mod hooks;
22pub(crate) mod items;
23mod racials;
24mod raid_buffs;
25#[cfg(test)]
26pub(crate) mod test_support;
27mod weapon_enchants;
28
29pub use catalog::force_link_generated_specs;
30/// Generated item metadata.
31pub use generated::items::REGISTERED_ITEMS;
32
33/// Resolve the registered on-use spell for an item, when its mechanic is implemented.
34#[must_use]
35pub fn registered_item_use_spell(item_id: u32) -> Option<u32> {
36    generated::items::ITEM_USE_SPELLS
37        .iter()
38        .find_map(|&(registered_item_id, spell_id)| {
39            (registered_item_id == item_id).then_some(spell_id)
40        })
41}
42
43#[cfg(test)]
44pub(crate) fn test_combat_builder(
45    stats: wowlab_engine_ports::CombatStats,
46) -> wowlab_engine_combat::CombatSystemBuilder {
47    let encounter = wowlab_engine_ports::test_support::introspection_fixture(300.0)
48        .expect("engine-content's unit-test encounter must resolve");
49
50    wowlab_engine_combat::CombatSystemBuilder::new(stats).encounter(encounter)
51}
52
53#[cfg(test)]
54pub(crate) fn test_combat_builder_for(
55    proof: wowlab_engine_combat::SpecIdentityProof,
56    stats: wowlab_engine_ports::CombatStats,
57) -> wowlab_engine_combat::CombatSystemBuilder {
58    let builder = test_combat_builder(stats)
59        .spec_identity(proof)
60        .effect_identities(wowlab_engine_combat::generated_identities::shared::ALL);
61
62    macro_rules! finish_for_spec {
63        ($($spec:ident),+ $(,)?) => {
64            $(
65                if proof
66                    == wowlab_engine_combat::generated_identities::specs::$spec::PROOF
67                {
68                    return builder.effect_identities(
69                        wowlab_engine_combat::generated_identities::specs::$spec::damage::ALL,
70                    );
71                }
72            )+
73        };
74    }
75
76    finish_for_spec!(
77        affliction_warlock,
78        arcane_mage,
79        arms_warrior,
80        assassination_rogue,
81        balance_druid,
82        beast_mastery_hunter,
83        demonology_warlock,
84        destruction_warlock,
85        devastation_evoker,
86        devourer_demon_hunter,
87        elemental_shaman,
88        enhancement_shaman,
89        feral_druid,
90        fire_mage,
91        frost_death_knight,
92        frost_mage,
93        fury_warrior,
94        havoc_demon_hunter,
95        marksmanship_hunter,
96        outlaw_rogue,
97        retribution_paladin,
98        shadow_priest,
99        subtlety_rogue,
100        survival_hunter,
101        unholy_death_knight,
102        vengeance_demon_hunter,
103        windwalker_monk,
104    );
105
106    panic!("test fixture uses an unknown generated specialization proof")
107}