Skip to main content

wowlab_types/types/data/
item.rs

1use compact_str::CompactString;
2use serde::{Deserialize, Serialize};
3use wowlab_engine_macros::CopyInsert;
4
5#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
6#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
7#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
8#[cfg_attr(feature = "wasm", tsify(into_wasm_abi, from_wasm_abi))]
9pub struct ItemStat {
10    #[serde(rename = "type")]
11    pub stat_type: i32,
12    pub value: i32,
13}
14
15#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
16#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
17#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
18#[cfg_attr(feature = "wasm", tsify(into_wasm_abi, from_wasm_abi))]
19pub struct ItemEffect {
20    pub spell_id: i32,
21    pub trigger_type: i32,
22    pub charges: i32,
23    pub cooldown: i32,
24    pub category_cooldown: i32,
25}
26
27#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
28#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
29#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
30#[cfg_attr(feature = "wasm", tsify(into_wasm_abi, from_wasm_abi))]
31pub struct ItemClassification {
32    pub class_id: i32,
33    #[cfg_attr(feature = "schema", schemars(with = "String"))]
34    #[cfg_attr(feature = "wasm", tsify(type = "string"))]
35    pub class_name: CompactString,
36    pub subclass_id: i32,
37    #[cfg_attr(feature = "schema", schemars(with = "String"))]
38    #[cfg_attr(feature = "wasm", tsify(type = "string"))]
39    pub subclass_name: CompactString,
40    pub inventory_type: i32,
41    #[cfg_attr(feature = "schema", schemars(with = "String"))]
42    #[cfg_attr(feature = "wasm", tsify(type = "string"))]
43    pub inventory_type_name: CompactString,
44    pub expansion_id: i32,
45    #[cfg_attr(feature = "schema", schemars(with = "String"))]
46    #[cfg_attr(feature = "wasm", tsify(type = "string"))]
47    pub expansion_name: CompactString,
48}
49
50#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
51#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
52#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
53#[cfg_attr(feature = "wasm", tsify(into_wasm_abi, from_wasm_abi))]
54pub struct ItemSetInfo {
55    pub set_id: i32,
56    #[cfg_attr(feature = "schema", schemars(with = "String"))]
57    #[cfg_attr(feature = "wasm", tsify(type = "string"))]
58    pub set_name: CompactString,
59    pub item_ids: Vec<i32>,
60    pub bonuses: Vec<ItemSetBonus>,
61}
62
63#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
64#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
65#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
66#[cfg_attr(feature = "wasm", tsify(into_wasm_abi, from_wasm_abi))]
67pub struct ItemSetBonus {
68    pub threshold: i32,
69    pub spell_id: i32,
70    pub spec_id: i32,
71}
72
73#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
74#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
75#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
76#[cfg_attr(feature = "wasm", tsify(into_wasm_abi, from_wasm_abi))]
77pub struct ItemDropSource {
78    pub instance_id: i32,
79    #[cfg_attr(feature = "schema", schemars(with = "String"))]
80    #[cfg_attr(feature = "wasm", tsify(type = "string"))]
81    pub instance_name: CompactString,
82    pub encounter_id: i32,
83    #[cfg_attr(feature = "schema", schemars(with = "String"))]
84    #[cfg_attr(feature = "wasm", tsify(type = "string"))]
85    pub encounter_name: CompactString,
86    /// Decoded `Difficulty.ID`s from `DifficultyMask` (bit N = ID N+1); empty Vec means all difficulties (mask -1 or 0).
87    pub difficulty_ids: Vec<i32>,
88}
89
90#[derive(Clone, CopyInsert, Debug, Deserialize, Serialize)]
91#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
92#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
93#[cfg_attr(feature = "wasm", tsify(into_wasm_abi, from_wasm_abi))]
94pub struct ItemDataFlat {
95    pub id: i32,
96    #[cfg_attr(feature = "schema", schemars(with = "String"))]
97    #[cfg_attr(feature = "wasm", tsify(type = "string"))]
98    pub name: CompactString,
99    pub description: String,
100    #[cfg_attr(feature = "schema", schemars(with = "String"))]
101    #[cfg_attr(feature = "wasm", tsify(type = "string"))]
102    pub file_name: CompactString,
103    pub item_level: i32,
104    pub quality: i32,
105    pub required_level: i32,
106    pub binding: i32,
107    pub buy_price: i32,
108    pub sell_price: i32,
109    pub max_count: i32,
110    pub stackable: i32,
111    pub speed: i32,
112
113    pub class_id: i32,
114    pub subclass_id: i32,
115    pub inventory_type: i32,
116    #[copy(json)]
117    pub classification: Option<ItemClassification>,
118
119    #[copy(json)]
120    pub stats: Vec<ItemStat>,
121    #[copy(json)]
122    pub effects: Vec<ItemEffect>,
123
124    pub sockets: Vec<i32>,
125    pub socket_bonus_enchant_id: i32,
126
127    pub flags: Vec<i32>,
128
129    pub allowable_class: i32,
130    pub allowable_race: i64,
131
132    pub expansion_id: i32,
133    pub item_set_id: i32,
134    #[copy(json)]
135    pub set_info: Option<ItemSetInfo>,
136
137    #[copy(json)]
138    pub drop_sources: Vec<ItemDropSource>,
139
140    pub dmg_variance: f32,
141    pub gem_properties: i32,
142    pub modified_crafting_reagent_item_id: i32,
143}
144
145impl Default for ItemDataFlat {
146    fn default() -> Self {
147        Self {
148            id: 0,
149            name: CompactString::default(),
150            description: String::new(),
151            file_name: CompactString::const_new("inv_misc_questionmark"),
152            item_level: 0,
153            quality: 0,
154            required_level: 0,
155            binding: 0,
156            buy_price: 0,
157            sell_price: 0,
158            max_count: 0,
159            stackable: 1,
160            speed: 0,
161            class_id: 0,
162            subclass_id: 0,
163            inventory_type: 0,
164            classification: None,
165            stats: Vec::new(),
166            effects: Vec::new(),
167            sockets: Vec::new(),
168            socket_bonus_enchant_id: 0,
169            flags: Vec::new(),
170            allowable_class: -1,
171            allowable_race: -1,
172            expansion_id: 0,
173            item_set_id: 0,
174            set_info: None,
175            drop_sources: Vec::new(),
176            dmg_variance: 0.0,
177            gem_properties: 0,
178            modified_crafting_reagent_item_id: 0,
179        }
180    }
181}