Skip to main content

wowlab_engine_application/enemies/
provenance.rs

1//! Typed provenance: which source rows and multipliers produced each resolved enemy stat.
2
3use std::fmt;
4
5pub(super) const TABLE_CREATURE: &str = "Creature";
6pub(super) const TABLE_CREATURE_DIFFICULTY: &str = "CreatureDifficulty";
7pub(super) const TABLE_CONTENT_TUNING_X_DIFFICULTY: &str = "ContentTuningXDifficulty";
8pub(super) const TABLE_CONTENT_TUNING_X_EXPECTED: &str = "ContentTuningXExpected";
9pub(super) const TABLE_EXPECTED_STAT: &str = "ExpectedStat";
10pub(super) const TABLE_EXPECTED_STAT_MOD: &str = "ExpectedStatMod";
11
12pub(super) const OP_EXACT_KEY_LOOKUP: &str = "exact key lookup";
13pub(super) const OP_FOREIGN_KEY_LOOKUP: &str = "foreign key lookup";
14pub(super) const OP_EMPTY_NAME_FALLBACK: &str = "empty Name_lang fallback";
15pub(super) const OP_MULTIPLY_ARMOR_CONSTANT_MOD: &str = "multiply ArmorConstantMod";
16
17/// Resolved enemy-stat component named by provenance steps and typed data errors.
18#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
19#[non_exhaustive]
20pub enum EnemyStatField {
21    DisplayName,
22    Classification,
23    CreatureType,
24    ContentTuning,
25    Difficulty,
26    MaxHealth,
27    Armor,
28    ArmorConstant,
29    AutoAttackDps,
30    SpellDamage,
31}
32
33impl EnemyStatField {
34    /// Stable snake-case name used in error messages and reports.
35    #[must_use]
36    pub const fn name(self) -> &'static str {
37        match self {
38            Self::DisplayName => "display_name",
39            Self::Classification => "classification",
40            Self::CreatureType => "creature_type",
41            Self::ContentTuning => "content_tuning",
42            Self::Difficulty => "difficulty",
43            Self::MaxHealth => "max_health",
44            Self::Armor => "armor",
45            Self::ArmorConstant => "armor_constant",
46            Self::AutoAttackDps => "auto_attack_dps",
47            Self::SpellDamage => "spell_damage",
48        }
49    }
50}
51
52impl fmt::Display for EnemyStatField {
53    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54        f.write_str(self.name())
55    }
56}
57
58/// Output value carried by a provenance lookup step.
59#[derive(Clone, Debug, PartialEq)]
60#[non_exhaustive]
61pub enum ProvenanceValue {
62    Number(f64),
63    Text(String),
64}
65
66/// One audited resolution step: a chosen source row/multiplier or an explicit authored input.
67#[derive(Clone, Debug, PartialEq)]
68#[non_exhaustive]
69pub enum EnemyStatProvenanceStep {
70    Lookup {
71        table: &'static str,
72        row_id: i32,
73        field: EnemyStatField,
74        input: String,
75        operation: &'static str,
76        output: ProvenanceValue,
77    },
78    ExplicitOverride {
79        field: EnemyStatField,
80        value: f64,
81    },
82}