wowlab_engine_combat/handler/
introspection.rs1use wowlab_types::combat::ResourceType;
2
3use crate::{builder::InfoCtx, state::CombatState};
4
5fn resource_type_id_u8(rt: Option<ResourceType>) -> u8 {
6 rt.map_or(0, u8::from)
7}
8
9pub(super) fn build_introspection(
10 state: &CombatState,
11 names: &[Box<str>],
12) -> wowlab_types::game::SpecIntrospection {
13 let base = &state.config.base_stats;
14
15 let resource_primary = wowlab_types::game::ResourceInfo {
16 name: base.resource_name.clone(),
17 max: base.resource_max,
18 regen: base.base_regen,
19 starts_at: base.resource_start,
20 type_id: resource_type_id_u8(base.resource_type),
21 };
22
23 let resource_secondary =
24 base.secondary_resource_name
25 .as_ref()
26 .map(|name| wowlab_types::game::ResourceInfo {
27 name: name.clone(),
28 max: base.secondary_resource_max,
29 regen: 0.0,
30 starts_at: 0.0,
31 type_id: resource_type_id_u8(base.secondary_resource_type),
32 });
33
34 let info_ctx = InfoCtx {
35 names,
36 auras: &state.defs.auras,
37 };
38
39 wowlab_types::game::SpecIntrospection {
40 resource_primary,
41 resource_secondary,
42 spells: state
43 .defs
44 .spells
45 .iter()
46 .map(|s| s.into_info(&info_ctx))
47 .collect(),
48 auras: state
49 .defs
50 .auras
51 .iter()
52 .map(|a| a.into_info(&info_ctx))
53 .collect(),
54 auto_attacks: state
55 .defs
56 .auto_attacks
57 .iter()
58 .map(|aa| aa.into_info(&info_ctx))
59 .collect(),
60 hero_talents: Vec::new(),
61 }
62}