compress alias definitions

This commit is contained in:
endernon 2025-01-11 20:00:49 +00:00
parent 0588b2a6a3
commit 25b29da736

View file

@ -8,63 +8,35 @@ use std::fs;
// structs for the json parsing // structs for the json parsing
#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] #[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub struct Jsonconfig { pub struct Jsonconfig {
// not a thing to be encoded, this just toggles debug prints. Also settable using --debug
#[serde(alias = "Debug")] #[serde(alias = "Debug")]
pub debug: Option<bool>, // not a thing to be encoded, this just toggles debug prints. Also settable using --debug #[serde(alias = "DEBUG")]
#[serde(alias = "itemtype")] pub debug: Option<bool>,
#[serde(alias = "ITEM_TYPE")] #[serde(alias = "itemtype", alias = "ITEM_TYPE", alias = "ITEMTYPE", alias = "Item_Type", alias = "Item_type", alias = "ItemType", alias = "Itemtype")]
#[serde(alias = "ITEMTYPE")]
#[serde(alias = "Item_Type")]
#[serde(alias = "Item_type")]
#[serde(alias = "ItemType")]
#[serde(alias = "Itemtype")]
// Item Types (Gear, Tome, Charm, Crafted Gear, Crafted Consum) // Item Types (Gear, Tome, Charm, Crafted Gear, Crafted Consum)
pub item_type: ItemTypeDeser, pub item_type: ItemTypeDeser,
#[serde(alias = "craftedtype")] #[serde(alias = "craftedtype", alias = "CRAFTED_TYPE", alias = "CRAFTEDTYPE", alias = "Crafted_Type", alias = "Crafted_type", alias = "CraftedType", alias = "Craftedtype")]
#[serde(alias = "CRAFTED_TYPE")]
#[serde(alias = "CRAFTEDTYPE")]
#[serde(alias = "Crafted_Type")]
#[serde(alias = "Crafted_type")]
#[serde(alias = "CraftedType")]
#[serde(alias = "Craftedtype")]
// Crafted type for Crafted item types // Crafted type for Crafted item types
pub crafted_type: Option<String>, pub crafted_type: Option<String>,
#[serde(alias = "Name")] #[serde(alias = "Name", alias = "NAME")]
#[serde(alias = "NAME")]
// name of item // name of item
pub name: Option<String>, pub name: Option<String>,
#[serde(alias = "Durability")] #[serde(alias = "Durability", alias = "DURABILITY", alias = "Dura", alias = "DURA")]
#[serde(alias = "DURABILITY")]
#[serde(alias = "Dura")]
#[serde(alias = "DURA")]
// durability data (Crafted Gear) // durability data (Crafted Gear)
pub durability: Option<Durability>, pub durability: Option<Durability>,
#[serde(alias = "Requirements")] #[serde(alias = "Requirements", alias = "REQUIREMENTS")]
#[serde(alias = "REQUIREMENTS")]
// requirements data (Crafted Gear, Crafted // requirements data (Crafted Gear, Crafted
pub requirements: Option<RequirementsDeser>, pub requirements: Option<RequirementsDeser>,
#[serde(alias = "Shiny")] #[serde(alias = "Shiny", alias = "SHINY")]
#[serde(alias = "SHINY")]
// shiny data // shiny data
pub shiny: Option<Shinyjson>, pub shiny: Option<Shinyjson>,
#[serde(alias = "Ids")] #[serde(alias = "Ids", alias = "IDS", alias = "identifications", alias = "Identifications", alias = "IDENTIFICATIONS")]
#[serde(alias = "IDS")]
#[serde(alias = "identifications")]
#[serde(alias = "Identifications")]
#[serde(alias = "IDENTIFICATIONS")]
// identifications // identifications
pub ids: Option<Vec<Identificationer>>, pub ids: Option<Vec<Identificationer>>,
#[serde(alias = "Powders")] #[serde(alias = "Powders", alias = "POWDERS", alias = "powder", alias = "Powder", alias = "POWDER")]
#[serde(alias = "POWDERS")]
#[serde(alias = "powder")]
#[serde(alias = "Powder")]
#[serde(alias = "POWDER")]
// powders stuff // powders stuff
pub powders: Option<Vec<PowderFr>>, pub powders: Option<Vec<PowderFr>>,
#[serde(alias = "Rerolls")] #[serde(alias = "Rerolls", alias = "REROLLS", alias = "reroll", alias = "Reroll", alias = "REROLL")]
#[serde(alias = "REROLLS")]
#[serde(alias = "reroll")]
#[serde(alias = "Reroll")]
#[serde(alias = "REROLL")]
pub rerolls: Option<u8>, pub rerolls: Option<u8>,
} }
// reimplementing this because it doesnt have Deserialize. // reimplementing this because it doesnt have Deserialize.
@ -97,25 +69,15 @@ impl From<ClassDeser> for ClassType {
} }
#[derive(Deserialize, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone)] #[derive(Deserialize, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone)]
pub struct SkillPointDeser { pub struct SkillPointDeser {
#[serde(alias = "Str")] #[serde(alias = "Str", alias = "str", alias = "strength")]
#[serde(alias = "str")]
#[serde(alias = "strength")]
pub strength: Option<i32>, pub strength: Option<i32>,
#[serde(alias = "Dex")] #[serde(alias = "Dex", alias = "dex", alias = "dexterity")]
#[serde(alias = "dex")]
#[serde(alias = "dexterity")]
pub dexterity: Option<i32>, pub dexterity: Option<i32>,
#[serde(alias = "Def")] #[serde(alias = "Def", alias = "def", alias = "defense")]
#[serde(alias = "def")]
#[serde(alias = "defense")]
pub defense: Option<i32>, pub defense: Option<i32>,
#[serde(alias = "Int")] #[serde(alias = "Int", alias = "int", alias = "intelligence")]
#[serde(alias = "int")]
#[serde(alias = "intelligence")]
pub intelligence: Option<i32>, pub intelligence: Option<i32>,
#[serde(alias = "Agi")] #[serde(alias = "Agi", alias = "agi", alias = "agility")]
#[serde(alias = "agi")]
#[serde(alias = "agility")]
pub agility: Option<i32>, pub agility: Option<i32>,
} }
@ -224,13 +186,9 @@ pub enum ItemTypeDeser {
Tome = 1, Tome = 1,
#[serde(alias = "charm")] #[serde(alias = "charm")]
Charm = 2, Charm = 2,
#[serde(alias = "craftedgear")] #[serde(alias = "craftedgear", alias = "cgear", alias = "CGear")]
#[serde(alias = "cgear")]
#[serde(alias = "CGear")]
CraftedGear = 3, CraftedGear = 3,
#[serde(alias = "craftedconsu")] #[serde(alias = "craftedconsu", alias = "cconsu", alias = "CConsu")]
#[serde(alias = "cconsu")]
#[serde(alias = "CConsu")]
CraftedConsu = 4, CraftedConsu = 4,
} }
impl From<ItemTypeDeser> for ItemType { impl From<ItemTypeDeser> for ItemType {