Skip to main content

wowlab_parsers/parsers/transform/loot/
currency.rs

1use wowlab_types::data::{Currency, CurrencyCategory};
2
3use crate::parsers::dbc::DbcData;
4
5/// 1:1 transform of `CurrencyTypes` rows joined with `CurrencyCategory.Name_lang`.
6#[must_use]
7pub fn transform_all_currencies(dbc: &DbcData) -> Vec<Currency> {
8    dbc.currency_types
9        .values()
10        .map(|row| {
11            let category_name = dbc
12                .currency_category
13                .get(&row.CategoryID)
14                .and_then(|c| c.Name_lang.clone())
15                .unwrap_or_default();
16
17            Currency {
18                id: row.ID,
19                name: row.Name_lang.clone().unwrap_or_default(),
20                category_id: row.CategoryID,
21                category_name,
22                icon_file_id: row.InventoryIconFileID,
23                max_qty: row.MaxQty,
24                max_earnable_per_week: row.MaxEarnablePerWeek,
25                quality: row.Quality,
26                order_index: row.OrderIndex,
27                flags: row.Flags_0,
28            }
29        })
30        .collect()
31}
32
33/// 1:1 transform of `CurrencyCategory` rows.
34#[must_use]
35pub fn transform_all_currency_categories(dbc: &DbcData) -> Vec<CurrencyCategory> {
36    dbc.currency_category
37        .values()
38        .map(|row| CurrencyCategory {
39            id: row.ID,
40            name: row.Name_lang.clone().unwrap_or_default(),
41            flags: row.Flags,
42            expansion_id: row.ExpansionID,
43            parent_category_id: row.ParentCategoryID,
44        })
45        .collect()
46}