wowlab_parsers/parsers/transform/
mod.rs1#[cfg(feature = "dbc")]
2pub(crate) fn transform_all<I, T, E, F>(ids: I, label: &'static str, mut f: F) -> Vec<T>
3where
4 I: IntoIterator<Item = i32>,
5 E: std::fmt::Display,
6 F: FnMut(i32) -> Result<T, E>,
7{
8 ids.into_iter()
9 .filter_map(|id| {
10 f(id)
11 .inspect_err(|error| {
12 tracing::warn!(id, label, error = %error, "failed to transform rows");
13 })
14 .ok()
15 })
16 .collect()
17}
18
19#[cfg(feature = "dbc")]
20mod assisted;
21#[cfg(feature = "dbc")]
22mod creature;
23#[cfg(feature = "dbc")]
24mod expansion_trait;
25#[cfg(all(test, feature = "dbc"))]
26mod fixtures;
27#[cfg(feature = "dbc")]
28mod gametable;
29#[cfg(feature = "dbc")]
30mod global;
31#[cfg(feature = "dbc")]
32mod item;
33#[cfg(feature = "dbc")]
34mod loot;
35#[cfg(feature = "dbc")]
36mod racial;
37#[cfg(feature = "dbc")]
38mod rotation_overlay;
39#[cfg(feature = "dbc")]
40mod scaling;
41#[cfg(feature = "dbc")]
42mod spec;
43mod spell;
44#[cfg(feature = "dbc")]
45mod r#trait;
46
47#[cfg(feature = "dbc")]
48use wowlab_types::{
49 constants::DEFAULT_ICON_FILENAME,
50 data::{SpellDataFlat, TraitTreeFlat},
51};
52
53#[cfg(feature = "dbc")]
54use super::dbc::DbcData;
55
56#[rustfmt::skip]
57#[cfg(feature = "dbc")]
58pub use assisted::{
59 assisted_spell_overrides, transform_assisted_rotation, transform_assisted_rotations,
60};
61#[rustfmt::skip]
62#[cfg(feature = "dbc")]
63pub use creature::{
64 transform_all_content_tuning_x_difficulty, transform_all_content_tuning_x_expected,
65 transform_all_content_tunings, transform_all_creature_difficulties, transform_all_creatures,
66};
67#[rustfmt::skip]
68#[cfg(feature = "dbc")]
69pub use expansion_trait::{
70 MIDNIGHT_EXPANSION_ID, OMNIUM_SYSTEM, OMNIUM_TRAIT_TREE_ID, transform_all_expansion_trait_trees,
71};
72#[rustfmt::skip]
73#[cfg(feature = "dbc")]
74pub use gametable::{
75 transform_armor_mitigation_by_lvl, transform_base_mp, transform_base_profession_ratings,
76 transform_challenge_mode_damage, transform_challenge_mode_health, transform_combat_ratings,
77 transform_combat_ratings_mult_by_ilvl, transform_hp_per_sta,
78 transform_item_socket_cost_per_level, transform_npc_damage_by_class, transform_npc_total_hp,
79 transform_profession_ratings, transform_spell_scaling, transform_stamina_mult_by_ilvl,
80};
81#[rustfmt::skip]
82#[cfg(feature = "dbc")]
83pub use global::{
84 transform_all_classes, transform_all_global_colors, transform_all_global_strings,
85 transform_class, transform_global_color, transform_global_string,
86};
87#[rustfmt::skip]
88#[cfg(feature = "dbc")]
89pub use item::{transform_all_items, transform_item};
90#[rustfmt::skip]
91#[cfg(feature = "dbc")]
92pub use loot::{
93 transform_all_challenge_mode_item_bonus_overrides, transform_all_crafted_products,
94 transform_all_currencies, transform_all_currency_categories, transform_all_delves_seasons,
95 transform_all_difficulties, transform_all_item_bonus_list_groups,
96 transform_all_item_bonus_sequence_spells, transform_all_item_conversions,
97 transform_all_item_drop_scaling, transform_all_item_group_ilvl_scaling_entries,
98 transform_all_item_level_selector_qualities, transform_all_item_level_selector_quality_sets,
99 transform_all_item_level_selectors, transform_all_journal_instances,
100 transform_all_journal_tiers, transform_all_mythic_plus_seasons, transform_all_professions,
101 transform_all_pvp_seasons, transform_all_pvp_tiers,
102};
103#[rustfmt::skip]
104#[cfg(feature = "dbc")]
105pub use racial::transform_all_racial_spells;
106#[rustfmt::skip]
107#[cfg(feature = "dbc")]
108pub use rotation_overlay::{RotationOverlayError, apply_rotation_overlay};
109#[rustfmt::skip]
110#[cfg(feature = "dbc")]
111pub use scaling::{
112 transform_all_armor_location, transform_all_cooldown_sets, transform_all_curve_points,
113 transform_all_curves, transform_all_enchantments, transform_all_expected_stat_mods,
114 transform_all_expected_stats, transform_all_gem_properties, transform_all_item_armor_quality,
115 transform_all_item_armor_shield, transform_all_item_armor_total, transform_all_item_bonuses,
116 transform_all_item_damage_scaling, transform_all_item_offset_curves,
117 transform_all_item_scaling_configs, transform_all_item_squish_eras,
118 transform_all_permanent_enchants, transform_all_power_types, transform_all_rand_prop_points,
119 transform_all_specialization_spells,
120};
121#[rustfmt::skip]
122#[cfg(feature = "dbc")]
123pub use spec::{transform_all_specs, transform_spec};
124#[rustfmt::skip]
125pub use spell::SpellKnowledgeContext;
126#[rustfmt::skip]
127#[cfg(feature = "dbc")]
128pub use spell::transform_spell;
129
130#[rustfmt::skip]
131#[cfg(feature = "dbc")]
132pub use r#trait::transform_trait_tree;
133
134#[cfg(feature = "dbc")]
135pub(crate) fn resolve_icon_file_name(dbc: &DbcData, icon_file_data_id: i32) -> String {
136 if icon_file_data_id > 0 {
137 dbc.manifest_interface_data
138 .get(&icon_file_data_id)
139 .map_or_else(
140 || DEFAULT_ICON_FILENAME.to_string(),
141 |m| m.FileName.to_lowercase().replace(".blp", ""),
142 )
143 } else {
144 DEFAULT_ICON_FILENAME.to_string()
145 }
146}
147
148#[cfg(feature = "dbc")]
150#[must_use]
151pub fn transform_all_spells(dbc: &DbcData) -> Vec<SpellDataFlat> {
152 transform_all(dbc.spell_name.keys().copied(), "spell", |spell_id| {
153 transform_spell(dbc, spell_id, None)
154 })
155}
156
157#[cfg(feature = "dbc")]
159#[must_use]
160pub fn transform_all_trait_trees(dbc: &DbcData) -> Vec<TraitTreeFlat> {
161 transform_all(
162 dbc.chr_specialization.keys().copied(),
163 "trait tree",
164 |spec_id| transform_trait_tree(dbc, spec_id),
165 )
166}