1use rustc_hash::{FxHashMap, FxHashSet};
2use serde::{Deserialize, Serialize};
3
4use crate::explicit_type;
5
6pub type THashMap<K, V> = FxHashMap<K, V>;
7pub type THashSet<K> = FxHashSet<K>;
8
9explicit_type!(Weight, u32);
11explicit_type!(AffixTierLevel, u8);
12explicit_type!(EssenceId, u16);
13explicit_type!(AffixId, u16);
14explicit_type!(ItemId, u16);
16explicit_type!(BaseGroupId, u16);
17explicit_type!(BaseItemId, u16);
18explicit_type!(ItemLevel, u8);
19
20#[derive(Clone, Debug, Eq, PartialEq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
21#[repr(u8)]
22#[cfg_attr(feature = "python", pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
23#[cfg_attr(feature = "python", pyo3::prelude::pyclass)]
24#[cfg_attr(
25 feature = "python",
26 pyo3(eq, weakref, from_py_object, frozen, hash, get_all, str)
27)]
28pub enum ItemRarityEnum {
29 Normal = 0,
30 Magic = 1,
31 Rare = 2,
32 Unique = 3,
33}
34
35#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
36#[cfg_attr(feature = "python", pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
37#[cfg_attr(feature = "python", pyo3::prelude::pyclass)]
38#[cfg_attr(
39 feature = "python",
40 pyo3(eq, weakref, from_py_object, frozen, hash, get_all, str)
41)]
42pub enum AffixTierLevelBoundsEnum {
43 Exact,
44 Minimum,
45}
46
47#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Serialize, Deserialize)]
48#[repr(u8)]
49#[cfg_attr(feature = "python", pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
50#[cfg_attr(feature = "python", pyo3::prelude::pyclass)]
51#[cfg_attr(
52 feature = "python",
53 pyo3(eq, weakref, from_py_object, frozen, hash, get_all, str)
54)]
55pub enum AffixClassEnum {
56 Base = 1,
57 Desecrated = 10,
58 Essence = 13,
59}
60
61#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Serialize, Deserialize)]
62#[cfg_attr(feature = "python", pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
63#[cfg_attr(feature = "python", pyo3::prelude::pyclass)]
64#[cfg_attr(
65 feature = "python",
66 pyo3(eq, weakref, from_py_object, frozen, hash, get_all, str)
67)]
68pub enum AffixLocationEnum {
69 Socket,
70 Prefix,
71 Suffix,
72}
73
74#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
75#[cfg_attr(feature = "python", pyo3_stub_gen::derive::gen_stub_pyclass)]
76#[cfg_attr(feature = "python", pyo3::prelude::pyclass)]
77#[cfg_attr(
78 feature = "python",
79 pyo3(eq, weakref, from_py_object, frozen, hash, get_all, str)
80)]
81pub struct AffixTierConstraints {
82 pub tier: AffixTierLevel,
83 pub bounds: AffixTierLevelBoundsEnum,
84}
85
86#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
87#[cfg_attr(feature = "python", pyo3_stub_gen::derive::gen_stub_pyclass)]
88#[cfg_attr(feature = "python", pyo3::prelude::pyclass)]
89#[cfg_attr(
90 feature = "python",
91 pyo3(eq, weakref, from_py_object, frozen, hash, get_all, str)
92)]
93pub struct AffixSpecifier {
94 pub affix: AffixId,
95 pub fractured: bool,
96 pub tier: AffixTierConstraints,
97}
98
99#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
100#[cfg_attr(feature = "python", pyo3_stub_gen::derive::gen_stub_pyclass)]
101#[cfg_attr(feature = "python", pyo3::prelude::pyclass)]
102#[cfg_attr(
103 feature = "python",
104 pyo3(eq, weakref, from_py_object, frozen, hash, get_all, str)
105)]
106pub struct AffixTierLevelMeta {
107 pub weight: Weight,
108 pub min_item_level: ItemLevel,
109}
110
111#[derive(Debug, Clone, Serialize, Deserialize)]
112#[cfg_attr(feature = "python", pyo3_stub_gen::derive::gen_stub_pyclass)]
113#[cfg_attr(feature = "python", pyo3::prelude::pyclass)]
114#[cfg_attr(feature = "python", pyo3(weakref, get_all, str))]
115pub struct AffixDefinition {
116 pub exlusive_groups: THashSet<String>,
119 pub tags: THashSet<u8>,
121 pub description_template: String,
122 pub affix_class: AffixClassEnum,
124 pub affix_location: AffixLocationEnum,
126}
127
128#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
129#[cfg_attr(feature = "python", pyo3_stub_gen::derive::gen_stub_pyclass)]
130#[cfg_attr(feature = "python", pyo3::prelude::pyclass)]
131#[cfg_attr(feature = "python", pyo3(eq, weakref, from_py_object, get_all, str))]
132pub struct EssenceDefinition {
133 pub name_essence: String,
134 pub base_tier_table: THashMap<BaseItemId, THashMap<AffixId, EssenceTierLevelMeta>>,
135 pub corrupt: bool,
136}
137
138#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
139#[cfg_attr(feature = "python", pyo3_stub_gen::derive::gen_stub_pyclass)]
140#[cfg_attr(feature = "python", pyo3::prelude::pyclass)]
141#[cfg_attr(feature = "python", pyo3(eq, weakref, from_py_object, get_all, str))]
142pub struct BaseGroupDefinition {
143 pub name_base_group: String,
144 pub max_affix: u8,
145 pub max_sockets: u8,
146 pub is_rare: bool,
147}
148
149#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
150#[cfg_attr(feature = "python", pyo3_stub_gen::derive::gen_stub_pyclass)]
151#[cfg_attr(feature = "python", pyo3::prelude::pyclass)]
152#[cfg_attr(feature = "python", pyo3(eq, weakref, from_py_object, get_all, str))]
153pub struct EssenceTierLevelMeta {
154 pub id: String, pub min_item_level: ItemLevel,
159}
160
161#[cfg(feature = "python")]
164crate::derive_DebugDisplay!(
165 AffixDefinition,
166 EssenceDefinition,
167 EssenceTierLevelMeta,
168 ItemRarityEnum,
169 AffixTierLevelBoundsEnum,
170 AffixClassEnum,
171 AffixLocationEnum,
172 AffixTierConstraints,
173 AffixSpecifier,
174 AffixTierLevelMeta,
175 BaseGroupDefinition
176);