Skip to main content

wowlab_types/types/data/
partial.rs

1use compact_str::CompactString;
2use serde::Deserialize;
3
4macro_rules! define_partial {
5    (
6        $(#[$meta:meta])*
7        $vis:vis struct $name:ident {
8            $(
9                #[column = $col:literal]
10                $(#[$field_meta:meta])*
11                $field_vis:vis $field:ident : $ty:ty
12            ),* $(,)?
13        }
14    ) => {
15        $(#[$meta])*
16        $vis struct $name {
17            $(
18                $(#[$field_meta])*
19                $field_vis $field : $ty,
20            )*
21        }
22
23        impl $name {
24            pub const COLUMNS: &'static [&'static str] = &[$($col),*];
25        }
26    };
27}
28
29define_partial! {
30    #[derive(Debug, Clone, Deserialize)]
31    pub struct SpellSummary {
32        #[column = "id"]
33        pub id: i32,
34        #[column = "name"]
35        pub name: CompactString,
36        #[column = "file_name"]
37        pub file_name: CompactString,
38    }
39}
40
41define_partial! {
42    #[derive(Debug, Clone, Deserialize)]
43    pub struct SpellTiming {
44        #[column = "id"]
45        pub id: i32,
46        #[column = "cast_time"]
47        pub cast_time: i32,
48        #[column = "recovery_time"]
49        pub recovery_time: i32,
50        #[column = "start_recovery_time"]
51        pub start_recovery_time: i32,
52        #[column = "charge_recovery_time"]
53        pub charge_recovery_time: i32,
54        #[column = "max_charges"]
55        pub max_charges: i32,
56    }
57}
58
59define_partial! {
60    #[derive(Debug, Clone, Deserialize)]
61    pub struct SpellCost {
62        #[column = "id"]
63        pub id: i32,
64        #[column = "power_type"]
65        pub power_type: i32,
66        #[column = "power_cost"]
67        pub power_cost: i32,
68        #[column = "power_cost_pct"]
69        pub power_cost_pct: f64,
70        #[column = "power_cost_max_pct"]
71        pub power_cost_max_pct: f64,
72        #[column = "optional_cost_pct"]
73        pub optional_cost_pct: f64,
74        #[column = "mana_cost"]
75        pub mana_cost: i32,
76    }
77}
78
79define_partial! {
80    #[derive(Debug, Clone, Deserialize)]
81    pub struct SpellDamage {
82        #[column = "id"]
83        pub id: i32,
84        #[column = "school_mask"]
85        pub school_mask: i32,
86        #[column = "bonus_coefficient_from_ap"]
87        pub bonus_coefficient_from_ap: f64,
88        #[column = "effect_bonus_coefficient"]
89        pub effect_bonus_coefficient: f64,
90    }
91}
92
93define_partial! {
94    #[derive(Debug, Clone, Deserialize)]
95    pub struct SpellRange {
96        #[column = "id"]
97        pub id: i32,
98        #[column = "range_max_0"]
99        pub range_max_0: f32,
100        #[column = "range_max_1"]
101        pub range_max_1: f32,
102        #[column = "range_min_0"]
103        pub range_min_0: f32,
104        #[column = "range_min_1"]
105        pub range_min_1: f32,
106        #[column = "radius_max"]
107        pub radius_max: f32,
108        #[column = "radius_min"]
109        pub radius_min: f32,
110        #[column = "cone_degrees"]
111        pub cone_degrees: f32,
112    }
113}
114
115define_partial! {
116    #[derive(Debug, Clone, Deserialize)]
117    pub struct ItemSummary {
118        #[column = "id"]
119        pub id: i32,
120        #[column = "name"]
121        pub name: CompactString,
122        #[column = "item_level"]
123        pub item_level: i32,
124        #[column = "quality"]
125        pub quality: i32,
126        #[column = "file_name"]
127        pub file_name: CompactString,
128    }
129}
130
131define_partial! {
132    #[derive(Debug, Clone, Deserialize)]
133    pub struct TalentNodeSummary {
134        #[column = "id"]
135        pub id: i32,
136        #[column = "pos_x"]
137        pub pos_x: i32,
138        #[column = "pos_y"]
139        pub pos_y: i32,
140        #[column = "max_ranks"]
141        pub max_ranks: i32,
142        #[column = "type"]
143        #[serde(rename = "type")]
144        pub node_type: i32,
145    }
146}