Skip to main content

wowlab_engine_domain/dbc/game_data/
damage.rs

1//! Damage-school and equipped-weapon classification over resolved game data.
2
3use wowlab_engine_gamedata::{ResolvedDamageWeapon, ResolvedGameData};
4use wowlab_types::{combat::DamageSchool, data::EquippedItemRequirement, sim::SpellIdx};
5
6/// Whether a spell deals exclusively physical damage; `None` when absent.
7#[must_use]
8pub fn is_physical(data: &ResolvedGameData, spell_id: SpellIdx) -> Option<bool> {
9    let mask = super::super::SpellSchoolMask::from_dbc(data.school_mask(spell_id)?);
10
11    Some(mask.is_empty() || mask == super::super::SpellSchoolMask::PHYSICAL)
12}
13
14/// A spell's resolved damage school; `None` when the spell is absent.
15#[must_use]
16pub fn damage_school(data: &ResolvedGameData, spell_id: SpellIdx) -> Option<DamageSchool> {
17    Some(super::super::SpellSchoolMask::from_dbc(data.school_mask(spell_id)?).primary_school())
18}
19
20/// Whether the equipped weapon in `hand` satisfies a DBC item restriction.
21#[must_use]
22pub fn equipped_weapon_matches(
23    data: &ResolvedGameData,
24    hand: ResolvedDamageWeapon,
25    requirement: EquippedItemRequirement,
26) -> bool {
27    let weapon = match hand {
28        ResolvedDamageWeapon::MainHand => Some(data.main_hand()),
29        ResolvedDamageWeapon::OffHand => data.off_hand(),
30        _ => None,
31    };
32
33    weapon.is_some_and(|weapon| {
34        weapon.speed_ms > 0
35            // TrinityCore applies the inventory-type mask only to enchant-item
36            // effects. Ordinary spell weapon requirements use class/subclass.
37            && requirement.matches_class_and_subclass(weapon.item_class, weapon.subclass)
38    })
39}