This commit is contained in:
endernon 2025-01-14 18:14:35 +00:00
parent 2a3fcd5820
commit fe7ec985f2
7 changed files with 46 additions and 48 deletions

View file

@ -1,3 +1,3 @@
fn_params_layout = "Compressed" fn_params_layout = "Compressed"
attr_fn_like_width = 140 attr_fn_like_width = 160
max_width = 160 max_width = 200

View file

@ -1,12 +1,10 @@
use crate::errorfr::Errorfr; use crate::errorfr::Errorfr;
use crate::jsonstruct::{ use crate::jsonstruct::{CraftedTypesFr, Durability, FuncParams, Identificationer, ItemTypeDeser, PowderFr, RequirementsDeser, Shinyjson, Shinystruct};
CraftedTypesFr, Durability, FuncParams, Identificationer, ItemTypeDeser, PowderFr, RequirementsDeser, Shinyjson, Shinystruct,
};
use idmangler_lib::encoding::DataEncoder; use idmangler_lib::encoding::DataEncoder;
use idmangler_lib::{ use idmangler_lib::{
block::{ block::{
CraftedConsumableTypeData, CraftedGearTypeData, DurabilityData, EndData, IdentificationData, NameData, PowderData, CraftedConsumableTypeData, CraftedGearTypeData, DurabilityData, EndData, IdentificationData, NameData, PowderData, RequirementsData, RerollData,
RequirementsData, RerollData, ShinyData, StartData, TypeData, ShinyData, StartData, TypeData,
}, },
types::{ClassType, Element, ItemType, Powder, RollType, SkillType, Stat}, types::{ClassType, Element, ItemType, Powder, RollType, SkillType, Stat},
}; };

View file

@ -28,11 +28,15 @@ pub enum Errorfr {
ShinyJsonCorrupt, ShinyJsonCorrupt,
/// gear json is missing /// gear json is missing
#[error("Error 2.3: gear.json is missing. It's only required for the \"perfect mode\" item gen. \nYou should run \"--download Gear\" or \"--download All\".")] #[error(
"Error 2.3: gear.json is missing. It's only required for the \"perfect mode\" item gen. \nYou should run \"--download Gear\" or \"--download All\"."
)]
GearJsonMissing, GearJsonMissing,
/// shiny data json is corrupt /// shiny data json is corrupt
#[error("Error 2.4: gear.json is corrupt. It's only required for the \"perfect mode\" item gen. \nYou should run \"--download Gear\" or \"--download All\".")] #[error(
"Error 2.4: gear.json is corrupt. It's only required for the \"perfect mode\" item gen. \nYou should run \"--download Gear\" or \"--download All\"."
)]
GearJsonCorrupt, GearJsonCorrupt,
/// could not download the file /// could not download the file

View file

@ -1,5 +1,5 @@
use std::collections::HashMap;
use serde::Deserialize; use serde::Deserialize;
use std::collections::HashMap;
// the struct for each item in Hashmap<String, GearJson> gear.json. its a big ass pain // the struct for each item in Hashmap<String, GearJson> gear.json. its a big ass pain
#[derive(Deserialize, PartialEq, Eq, Debug)] #[derive(Deserialize, PartialEq, Eq, Debug)]
@ -20,31 +20,31 @@ pub struct GearJsonItem {
r#type: String, r#type: String,
weaponType: Option<String>, weaponType: Option<String>,
armourMaterial: Option<String>, armourMaterial: Option<String>,
armourType: Option<String> armourType: Option<String>,
} }
#[derive(Deserialize, PartialEq, Eq, Debug)] #[derive(Deserialize, PartialEq, Eq, Debug)]
pub struct ItemId { pub struct ItemId {
max: i8, max: i8,
min: i8, min: i8,
raw: i8 raw: i8,
} }
#[derive(Deserialize, PartialEq, Eq, Debug)] #[derive(Deserialize, PartialEq, Eq, Debug)]
pub struct dropMeta { pub struct dropMeta {
coordinates: [i64; 3], coordinates: [i64; 3],
name: String, name: String,
r#type: String r#type: String,
} }
#[derive(Deserialize, PartialEq, Eq, Debug)] #[derive(Deserialize, PartialEq, Eq, Debug)]
pub struct Icon { pub struct Icon {
format: String, format: String,
value: IconValue value: IconValue,
} }
#[derive(Deserialize, PartialEq, Eq, Debug)] #[derive(Deserialize, PartialEq, Eq, Debug)]
pub struct IconValue { pub struct IconValue {
customModelData: i16, customModelData: i16,
id: String, id: String,
name: String name: String,
} }

View file

@ -1,6 +1,6 @@
use crate::dl_json; use crate::dl_json;
use crate::gearjson;
use crate::errorfr::Errorfr; use crate::errorfr::Errorfr;
use crate::gearjson;
use crate::jsonstruct::Shinystruct; use crate::jsonstruct::Shinystruct;
use serde::Deserialize; use serde::Deserialize;
use std::collections::HashMap; use std::collections::HashMap;
@ -19,9 +19,10 @@ pub fn load_shinystats(executable_path: &str) -> Result<Vec<Shinystruct>, Errorf
pub fn load_gear(executable_path: &str) -> Result<HashMap<String, gearjson::GearJsonItem>, Errorfr> { pub fn load_gear(executable_path: &str) -> Result<HashMap<String, gearjson::GearJsonItem>, Errorfr> {
// shiny_stats.json // shiny_stats.json
let a: Result<HashMap<String, gearjson::GearJsonItem>, Errorfr> = serde_json5::from_reader(&mut fs::File::open(executable_path.to_owned() + "/data/gear.json").map_err(|_| Errorfr::GearJsonMissing)?) let a: Result<HashMap<String, gearjson::GearJsonItem>, Errorfr> =
.map_err(|_| Errorfr::GearJsonCorrupt); serde_json5::from_reader(&mut fs::File::open(executable_path.to_owned() + "/data/gear.json").map_err(|_| Errorfr::GearJsonMissing)?)
.map_err(|_| Errorfr::GearJsonCorrupt);
a a
} }
pub fn dl_json_fr(dlvalue: &String, executable_path: &str) { pub fn dl_json_fr(dlvalue: &String, executable_path: &str) {
@ -29,13 +30,13 @@ pub fn dl_json_fr(dlvalue: &String, executable_path: &str) {
if let Err(e) = fs::create_dir_all(format!("{}{}", executable_path, "/data/")) { if let Err(e) = fs::create_dir_all(format!("{}{}", executable_path, "/data/")) {
println!("Unable to create path. Path: {} ", e) println!("Unable to create path. Path: {} ", e)
} }
if jsons == DownloadJsons::All || jsons == DownloadJsons::ShinyStats { if jsons == DownloadJsons::All || jsons == DownloadJsons::ShinyStats {
if let Err(e) = dl_json( if let Err(e) = dl_json(
"https://raw.githubusercontent.com/Wynntils/Static-Storage/main/Data-Storage/shiny_stats.json" "https://raw.githubusercontent.com/Wynntils/Static-Storage/main/Data-Storage/shiny_stats.json"
.parse() .parse()
.unwrap(), .unwrap(),
format!("{}{}", executable_path, "/data/shiny_stats.json") format!("{}{}", executable_path, "/data/shiny_stats.json"),
) { ) {
// error handling below // error handling below
println!("{} Filename: {}", e, dlvalue) println!("{} Filename: {}", e, dlvalue)
@ -46,7 +47,7 @@ pub fn dl_json_fr(dlvalue: &String, executable_path: &str) {
"https://raw.githubusercontent.com/Wynntils/Static-Storage/main/Reference/id_keys.json" "https://raw.githubusercontent.com/Wynntils/Static-Storage/main/Reference/id_keys.json"
.parse() .parse()
.unwrap(), .unwrap(),
format!("{}{}", executable_path, "/data/id_keys.json") format!("{}{}", executable_path, "/data/id_keys.json"),
) { ) {
// error handling below // error handling below
println!("{} Filename: {}", e, dlvalue) println!("{} Filename: {}", e, dlvalue)
@ -57,7 +58,7 @@ pub fn dl_json_fr(dlvalue: &String, executable_path: &str) {
"https://raw.githubusercontent.com/Wynntils/Static-Storage/main/Reference/gear.json" "https://raw.githubusercontent.com/Wynntils/Static-Storage/main/Reference/gear.json"
.parse() .parse()
.unwrap(), .unwrap(),
format!("{}{}", executable_path, "/data/gear.json") format!("{}{}", executable_path, "/data/gear.json"),
) { ) {
// error handling below // error handling below
println!("{} Filename: {}", e, dlvalue) println!("{} Filename: {}", e, dlvalue)
@ -104,4 +105,3 @@ impl From<String> for DownloadJsons {
} }
} }
} }

View file

@ -1,7 +1,7 @@
use crate::errorfr::Errorfr; use crate::errorfr::Errorfr;
use crate::jsonstruct::CraftedTypesFr::{Consu, Gear}; use crate::jsonstruct::CraftedTypesFr::{Consu, Gear};
use idmangler_lib::{ use idmangler_lib::types::{
types::{ClassType, ConsumableType, ConsumableType::*, CraftedGearType, CraftedGearType::*, EncodingVersion, ItemType, SkillType, AttackSpeed}, AttackSpeed, ClassType, ConsumableType, ConsumableType::*, CraftedGearType, CraftedGearType::*, EncodingVersion, ItemType, SkillType,
}; };
use serde::Deserialize; use serde::Deserialize;
use std::fs; use std::fs;
@ -64,7 +64,7 @@ pub struct Jsonconfig {
// requirements data (Crafted) // requirements data (Crafted)
#[serde(alias = "requirement", alias = "Requirement", alias = "REQUIREMENT", alias = "requirements", alias = "Requirements", alias = "REQUIREMENTS")] #[serde(alias = "requirement", alias = "Requirement", alias = "REQUIREMENT", alias = "requirements", alias = "Requirements", alias = "REQUIREMENTS")]
pub crafted_requirements: Option<RequirementsDeser>, pub crafted_requirements: Option<RequirementsDeser>,
// identifications (Crafted) // identifications (Crafted)
// to be honest i wish there was a better way instead of too many aliases // to be honest i wish there was a better way instead of too many aliases
#[serde( #[serde(
@ -84,8 +84,8 @@ pub struct Jsonconfig {
alias = "Craftedidentifications" alias = "Craftedidentifications"
)] )]
pub crafted_ids: Option<Vec<IdentificationerCrafted>>, pub crafted_ids: Option<Vec<IdentificationerCrafted>>,
pub crafted_damage: Option<DamageDeser> pub crafted_damage: Option<DamageDeser>,
} }
// reimplementing this because it doesnt have Deserialize. // reimplementing this because it doesnt have Deserialize.
// Also, changing the SkillPoint stuff into NOT a vec. // Also, changing the SkillPoint stuff into NOT a vec.
@ -231,7 +231,7 @@ pub struct FuncParams<'a> {
#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone)] #[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone)]
pub struct DamageDeser { pub struct DamageDeser {
pub attack_speed: AttackSpeed pub attack_speed: AttackSpeed,
} }
// I had to clone this and add Deserialize because the original idmangler_lib::types::ItemType does not // I had to clone this and add Deserialize because the original idmangler_lib::types::ItemType does not
#[repr(u8)] #[repr(u8)]
@ -262,4 +262,4 @@ impl From<ItemTypeDeser> for ItemType {
pub fn load_jsonconfig(path: &String) -> Result<Jsonconfig, Errorfr> { pub fn load_jsonconfig(path: &String) -> Result<Jsonconfig, Errorfr> {
serde_json5::from_reader(&mut fs::File::open(path).map_err(|_| Errorfr::ItemJsonMissing)?).map_err(Errorfr::ItemJsonCorrupt) serde_json5::from_reader(&mut fs::File::open(path).map_err(|_| Errorfr::ItemJsonMissing)?).map_err(Errorfr::ItemJsonCorrupt)
} }

View file

@ -1,20 +1,18 @@
#![allow(clippy::single_match)] #![allow(clippy::single_match)]
#![allow(non_camel_case_types, non_snake_case)] #![allow(non_camel_case_types, non_snake_case)]
mod encode; mod encode;
mod errorfr; mod errorfr;
mod gearjson;
mod jsondl; mod jsondl;
mod jsonstruct; mod jsonstruct;
mod gearjson;
use idmangler_lib::{encoding::string::encode_string, types::EncodingVersion};
use std::{collections::HashMap, env, fs, io, path::PathBuf};
use clap::Parser;
use reqwest::Url;
use crate::errorfr::Errorfr; use crate::errorfr::Errorfr;
use crate::jsondl::*; use crate::jsondl::*;
use crate::jsonstruct::*; use crate::jsonstruct::*;
use clap::Parser;
use idmangler_lib::{encoding::string::encode_string, types::EncodingVersion};
use reqwest::Url;
use std::{collections::HashMap, env, fs, io, path::PathBuf};
#[derive(Parser, Debug, Clone)] #[derive(Parser, Debug, Clone)]
#[command(version, about, long_about = None, arg_required_else_help(true))] #[command(version, about, long_about = None, arg_required_else_help(true))]
@ -30,14 +28,14 @@ struct Args {
/// Download jsons (for ease of use) /// Download jsons (for ease of use)
#[arg(short, long)] #[arg(short, long)]
download: Option<String>, download: Option<String>,
/// Function to generate perfect value items /// Function to generate perfect value items
#[arg(long)] #[arg(long)]
perfect: Option<String> perfect: Option<String>,
} }
pub enum PerfectStatus { pub enum PerfectStatus {
None, None,
Some(String) Some(String),
} }
fn dl_json(url: Url, savename: String) -> Result<(), Errorfr> { fn dl_json(url: Url, savename: String) -> Result<(), Errorfr> {
@ -92,7 +90,7 @@ fn main() {
if let Some(t1) = args.perfect { if let Some(t1) = args.perfect {
loaded_config_borrow.name = Some(t1) loaded_config_borrow.name = Some(t1)
} }
// ENCODE: A Lot Of Stuff // ENCODE: A Lot Of Stuff
// Also print any mapped errors // Also print any mapped errors
let cooking = cook(&mut out, &debug_mode, ver, &mut loaded_config_borrow, loaded_idkeys, loaded_shinystats); let cooking = cook(&mut out, &debug_mode, ver, &mut loaded_config_borrow, loaded_idkeys, loaded_shinystats);
@ -115,8 +113,7 @@ fn main() {
} }
fn cook( fn cook(
out: &mut Vec<u8>, debug_mode: &bool, ver: EncodingVersion, json_config: &mut Jsonconfig, idsmap: HashMap<String, u8>, out: &mut Vec<u8>, debug_mode: &bool, ver: EncodingVersion, json_config: &mut Jsonconfig, idsmap: HashMap<String, u8>, json_shiny: Vec<Shinystruct>,
json_shiny: Vec<Shinystruct>,
) -> Result<String, Errorfr> { ) -> Result<String, Errorfr> {
let mut fr_params = FuncParams { let mut fr_params = FuncParams {
fr_out: out, fr_out: out,
@ -238,8 +235,7 @@ fn cook(
} }
fn cook_perfect( fn cook_perfect(
out: &mut Vec<u8>, debug_mode: &bool, ver: EncodingVersion, json_config: &Jsonconfig, idsmap: HashMap<String, u8>, out: &mut Vec<u8>, debug_mode: &bool, ver: EncodingVersion, json_config: &Jsonconfig, idsmap: HashMap<String, u8>, json_shiny: Vec<Shinystruct>,
json_shiny: Vec<Shinystruct>,
) -> Result<String, Errorfr> { ) -> Result<String, Errorfr> {
Ok("fr".parse().unwrap()) Ok("fr".parse().unwrap())
} }