wowlab_engine_combat/handler/
introspection.rs1use wowlab_types::combat::ResourceType;
2
3use crate::{builder::InfoCtx, state::CombatProgram};
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 program: &CombatProgram,
11 names: &[Box<str>],
12) -> wowlab_types::game::SpecIntrospection {
13 let base = &program.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: &program.auras,
37 };
38
39 wowlab_types::game::SpecIntrospection {
40 resource_primary,
41 resource_secondary,
42 spells: program
43 .spells
44 .iter()
45 .map(|s| s.into_info(&info_ctx))
46 .collect(),
47 auras: program
48 .auras
49 .iter()
50 .map(|a| a.into_info(&info_ctx))
51 .collect(),
52 auto_attacks: program
53 .auto_attacks
54 .iter()
55 .map(|aa| aa.into_info(&info_ctx))
56 .collect(),
57 hero_talents: Vec::new(),
58 }
59}