Skip to main content

wowlab_engine_domain/rotation/condition/
mod.rs

1//! Resolution of authored condition fields against a runtime descriptor schema.
2
3mod resolve;
4#[cfg(test)]
5mod tests;
6
7#[cfg(test)]
8use wowlab_types::sim::CompareOp;
9use wowlab_types::sim::{Condition, FieldRead};
10
11#[cfg(test)]
12#[rustfmt::skip]
13pub(super) use resolve::validate_condition;
14#[rustfmt::skip]
15pub use resolve::{ResolvedFieldRead, ResolvedKey};
16#[rustfmt::skip]
17pub(super) use resolve::resolve_field_read;
18
19pub(super) mod domain {
20    pub(crate) const COOLDOWN: &str = "cooldown";
21    pub(crate) const SPELL: &str = "spell";
22    pub(crate) const HISTORY: &str = "history";
23    pub(crate) const AURA: &str = "aura";
24    pub(crate) const RESOURCE: &str = "resource";
25    pub(crate) const TALENT: &str = "talent";
26    pub(crate) const HERO_TREE: &str = "hero_tree";
27    pub(crate) const EQUIPMENT: &str = "equipment";
28    pub(crate) const SET_BONUS: &str = "set_bonus";
29    pub(crate) const ITEM: &str = "item";
30    pub(crate) const SWING: &str = "swing";
31    pub(crate) const UNIT: &str = "unit";
32    pub(crate) const WEAPON_IMBUE: &str = "weapon_imbue";
33    pub(crate) const PLAYER: &str = "player";
34    pub(crate) const COMBAT: &str = "combat";
35    pub(crate) const PET: &str = "pet";
36}
37
38#[derive(Clone, Copy, Debug, Eq, PartialEq)]
39#[non_exhaustive]
40pub(super) enum KeyCategory {
41    Spell,
42    Aura,
43    Resource,
44    Named,
45}
46
47impl KeyCategory {
48    pub(super) fn for_domain(domain: &str) -> Option<Self> {
49        match domain {
50            domain::COOLDOWN | domain::SPELL | domain::HISTORY => Some(Self::Spell),
51            domain::AURA => Some(Self::Aura),
52            domain::RESOURCE => Some(Self::Resource),
53            domain::TALENT
54            | domain::HERO_TREE
55            | domain::EQUIPMENT
56            | domain::SET_BONUS
57            | domain::ITEM
58            | domain::SWING
59            | domain::UNIT
60            | domain::WEAPON_IMBUE => Some(Self::Named),
61            _ => None,
62        }
63    }
64}
65
66pub(super) fn spell_usable_condition(spell: &str) -> Condition {
67    Condition::Read {
68        field: FieldRead {
69            domain: domain::SPELL.to_string(),
70            name: "is_usable".to_string(),
71            key: Some(spell.to_string()),
72            on: None,
73        },
74    }
75}