1use serde::{Deserialize, Serialize};
2use wowlab_engine_macros::CopyInsert;
3
4#[derive(Clone, CopyInsert, Debug, Default, Deserialize, Serialize)]
6pub struct CreatureFlat {
7 pub id: i32,
8 pub name: String,
10 pub classification: i32,
11 pub creature_type: i32,
12 pub creature_family: i32,
13}
14
15#[derive(Clone, CopyInsert, Debug, Default, Deserialize, Serialize)]
17pub struct CreatureDifficultyFlat {
18 pub id: i32,
19 pub creature_id: i32,
20 pub content_tuning_id: i32,
21 pub faction_template_id: i32,
22 pub field_9_0_1_35522_003_min: i32,
24 pub field_9_0_1_35522_003_max: i32,
26 pub flags_0: i32,
27 pub flags_1: i32,
28 pub flags_2: i32,
29 pub flags_3: i32,
30 pub flags_4: i32,
31 pub flags_5: i32,
32 pub flags_6: i32,
33 pub flags_7: i32,
34 pub flags_8: i32,
35}
36
37#[derive(Clone, CopyInsert, Debug, Default, Deserialize, Serialize)]
39pub struct ContentTuningFlat {
40 pub id: i32,
41 pub flags: i32,
42 pub expansion_id: i32,
43 pub hp_scaling_curve_id: i32,
44 pub dmg_scaling_curve_id: i32,
45 pub hp_primary_stat_scaling_curve_id: i32,
46 pub dmg_primary_stat_scaling_curve_id: i32,
47 pub primary_stat_scaling_mod_player_data_element_character_id: i32,
48 #[serde(alias = "primary_stat_scaling_mod_player_data_element_character_multipli")]
49 pub primary_stat_scaling_mod_player_data_element_character_multiplier: f32,
50 pub min_level_squish: i32,
51 pub max_level_squish: i32,
52 pub min_level_scaling_offset: i32,
53 pub max_level_scaling_offset: i32,
54 pub allowed_min_offset: i32,
55 pub allowed_max_offset: i32,
56 pub lfg_min_level: i32,
57 pub lfg_max_level: i32,
58 pub ilevel: i32,
59 pub xp_mult_quest: f32,
60}
61
62#[derive(Clone, CopyInsert, Debug, Default, Deserialize, Serialize)]
64pub struct ContentTuningXDifficultyFlat {
65 pub id: i32,
66 pub content_tuning_id: i32,
67 pub difficulty_id: i32,
68}
69
70#[derive(Clone, CopyInsert, Debug, Default, Deserialize, Serialize)]
72pub struct ContentTuningXExpectedFlat {
73 pub id: i32,
74 pub content_tuning_id: i32,
75 pub expected_stat_mod_id: i32,
76 pub min_mythic_plus_season_id: i32,
77 pub max_mythic_plus_season_id: i32,
78}
79
80#[cfg(test)]
81mod tests {
82 use googletest::prelude::*;
83
84 use super::*;
85
86 #[gtest]
87 fn creature_flat_serde_shape() -> Result<()> {
88 let flat = CreatureFlat {
89 id: 220_586,
90 name: "Queen Ansurek".to_string(),
91 classification: 1,
92 creature_type: 7,
93 creature_family: 0,
94 };
95 let json = serde_json::to_value(&flat).or_fail()?;
96
97 verify_that!(
98 json,
99 eq(&serde_json::json!({
100 "id": 220_586,
101 "name": "Queen Ansurek",
102 "classification": 1,
103 "creature_type": 7,
104 "creature_family": 0,
105 }))
106 )?;
107 let back: CreatureFlat = serde_json::from_value(json).or_fail()?;
108
109 verify_that!(back.name, eq("Queen Ansurek"))?;
110
111 verify_that!(back.id, eq(220_586))
112 }
113
114 #[gtest]
115 fn creature_difficulty_flat_serde_shape() -> Result<()> {
116 let flat = CreatureDifficultyFlat {
117 id: 270_199,
118 creature_id: 220_586,
119 content_tuning_id: 719,
120 faction_template_id: 16,
121 flags_0: 268_959_756,
122 flags_4: 16_777_216,
123 ..CreatureDifficultyFlat::default()
124 };
125 let json = serde_json::to_value(&flat).or_fail()?;
126
127 verify_that!(
128 json,
129 eq(&serde_json::json!({
130 "id": 270_199,
131 "creature_id": 220_586,
132 "content_tuning_id": 719,
133 "faction_template_id": 16,
134 "field_9_0_1_35522_003_min": 0,
135 "field_9_0_1_35522_003_max": 0,
136 "flags_0": 268_959_756,
137 "flags_1": 0,
138 "flags_2": 0,
139 "flags_3": 0,
140 "flags_4": 16_777_216,
141 "flags_5": 0,
142 "flags_6": 0,
143 "flags_7": 0,
144 "flags_8": 0,
145 }))
146 )?;
147 let back: CreatureDifficultyFlat = serde_json::from_value(json).or_fail()?;
148
149 verify_that!(back.content_tuning_id, eq(719))?;
150
151 verify_that!(back.creature_id, eq(220_586))
152 }
153
154 #[gtest]
155 fn content_tuning_flat_serde_shape() -> Result<()> {
156 let flat = ContentTuningFlat {
157 id: 719,
158 flags: 32,
159 expansion_id: 7,
160 min_level_squish: 50,
161 max_level_squish: 50,
162 xp_mult_quest: 1.0,
163 ..ContentTuningFlat::default()
164 };
165 let json = serde_json::to_value(&flat).or_fail()?;
166
167 verify_that!(
168 json,
169 eq(&serde_json::json!({
170 "id": 719,
171 "flags": 32,
172 "expansion_id": 7,
173 "hp_scaling_curve_id": 0,
174 "dmg_scaling_curve_id": 0,
175 "hp_primary_stat_scaling_curve_id": 0,
176 "dmg_primary_stat_scaling_curve_id": 0,
177 "primary_stat_scaling_mod_player_data_element_character_id": 0,
178 "primary_stat_scaling_mod_player_data_element_character_multiplier": 0.0,
179 "min_level_squish": 50,
180 "max_level_squish": 50,
181 "min_level_scaling_offset": 0,
182 "max_level_scaling_offset": 0,
183 "allowed_min_offset": 0,
184 "allowed_max_offset": 0,
185 "lfg_min_level": 0,
186 "lfg_max_level": 0,
187 "ilevel": 0,
188 "xp_mult_quest": 1.0,
189 }))
190 )?;
191 let back: ContentTuningFlat = serde_json::from_value(json).or_fail()?;
192
193 verify_that!(back.expansion_id, eq(7))?;
194
195 verify_that!(back.min_level_squish, eq(50))
196 }
197
198 #[gtest]
199 fn content_tuning_x_difficulty_flat_serde_shape() -> Result<()> {
200 let flat = ContentTuningXDifficultyFlat {
201 id: 4135,
202 content_tuning_id: 719,
203 difficulty_id: 14,
204 };
205 let json = serde_json::to_value(&flat).or_fail()?;
206
207 verify_that!(
208 json,
209 eq(&serde_json::json!({
210 "id": 4135,
211 "content_tuning_id": 719,
212 "difficulty_id": 14,
213 }))
214 )?;
215 let back: ContentTuningXDifficultyFlat = serde_json::from_value(json).or_fail()?;
216
217 verify_that!(back.difficulty_id, eq(14))
218 }
219
220 #[gtest]
221 fn content_tuning_x_expected_flat_serde_shape() -> Result<()> {
222 let flat = ContentTuningXExpectedFlat {
223 id: 3032,
224 content_tuning_id: 1279,
225 expected_stat_mod_id: 391,
226 min_mythic_plus_season_id: 117,
227 max_mythic_plus_season_id: 0,
228 };
229 let json = serde_json::to_value(&flat).or_fail()?;
230
231 verify_that!(
232 json,
233 eq(&serde_json::json!({
234 "id": 3032,
235 "content_tuning_id": 1279,
236 "expected_stat_mod_id": 391,
237 "min_mythic_plus_season_id": 117,
238 "max_mythic_plus_season_id": 0,
239 }))
240 )?;
241 let back: ContentTuningXExpectedFlat = serde_json::from_value(json).or_fail()?;
242
243 verify_that!(back.expected_stat_mod_id, eq(391))?;
244
245 verify_that!(back.min_mythic_plus_season_id, eq(117))
246 }
247}