cool tree
This commit is contained in:
parent
116fd90232
commit
862ee83356
8 changed files with 56 additions and 62 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -650,6 +650,7 @@ dependencies = [
|
||||||
"idmangler-lib",
|
"idmangler-lib",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"serde_json5",
|
"serde_json5",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
|
@ -12,5 +12,6 @@ clap = { version = "4.5.20", features = ["derive"] }
|
||||||
idmangler-lib = { version = "0.5.0", features = ["serde"] }
|
idmangler-lib = { version = "0.5.0", features = ["serde"] }
|
||||||
reqwest = { version = "0.12.9", features = ["blocking", "json"] }
|
reqwest = { version = "0.12.9", features = ["blocking", "json"] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde_json = "1.0.135"
|
||||||
serde_json5 = "0.1.0"
|
serde_json5 = "0.1.0"
|
||||||
thiserror = "2.0.9"
|
thiserror = "2.0.9"
|
||||||
|
|
|
@ -251,6 +251,6 @@ impl FuncParams<'_> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn encode_damagedata(&mut self) -> Result<(), Errorfr> {
|
pub fn encode_damagedata(&mut self) -> Result<(), Errorfr> {
|
||||||
Ok(())
|
todo!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,12 @@ 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.5: 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.6: gear.json is corrupt. It's only required for the \"perfect mode\" item gen. \nYou should run \"--download Gear\" or \"--download All\".\n{0:?}")]
|
||||||
GearJsonCorrupt,
|
GearJsonCorrupt(serde_json5::Error),
|
||||||
|
|
||||||
/// could not download the file
|
/// could not download the file
|
||||||
#[error("Error 3.1: Download request failed. Check your network settings.")]
|
#[error("Error 3.1: Download request failed. Check your network settings.")]
|
||||||
|
|
|
@ -1,50 +1,24 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
// the struct for each item in Hashmap<String, GearJson> gear.json. its a big ass pain
|
// the struct for the stuff I need in in Hashmap<String, GearJson> gear.json. its a big ass pain
|
||||||
#[derive(Deserialize, PartialEq, Eq, Debug)]
|
#[derive(Deserialize, PartialEq, Eq, Debug)]
|
||||||
pub struct GearJsonItem {
|
pub struct GearJsonItem {
|
||||||
attackSpeed: Option<String>,
|
identifications: Option<
|
||||||
averageDps: Option<i16>,
|
HashMap<
|
||||||
base: HashMap<String, ItemId>,
|
String, GearJsonItemInner
|
||||||
dropMeta: Option<dropMeta>,
|
>
|
||||||
dropRestriction: Option<String>,
|
>
|
||||||
icon: Icon,
|
|
||||||
identifications: Option<HashMap<String, i16>>,
|
|
||||||
identified: Option<bool>,
|
|
||||||
internalName: String,
|
|
||||||
lore: Option<String>,
|
|
||||||
powderSlots: Option<u8>,
|
|
||||||
rarity: String,
|
|
||||||
restrictions: Option<String>,
|
|
||||||
r#type: String,
|
|
||||||
weaponType: Option<String>,
|
|
||||||
armourMaterial: Option<String>,
|
|
||||||
armourType: Option<String>,
|
|
||||||
}
|
}
|
||||||
#[derive(Deserialize, PartialEq, Eq, Debug)]
|
#[derive(Deserialize, PartialEq, Eq, Debug)]
|
||||||
pub struct ItemId {
|
#[serde(untagged)]
|
||||||
max: i8,
|
pub enum GearJsonItemInner {
|
||||||
min: i8,
|
r#Struct(GearJsonItemInnerStruct),
|
||||||
raw: i8,
|
r#Int(i32)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, PartialEq, Eq, Debug)]
|
#[derive(Deserialize, PartialEq, Eq, Debug)]
|
||||||
pub struct dropMeta {
|
pub struct GearJsonItemInnerStruct {
|
||||||
coordinates: [i64; 3],
|
max: i16,
|
||||||
name: String,
|
min: i16,
|
||||||
r#type: String,
|
raw: i16
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, PartialEq, Eq, Debug)]
|
|
||||||
pub struct Icon {
|
|
||||||
format: String,
|
|
||||||
value: IconValue,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, PartialEq, Eq, Debug)]
|
|
||||||
pub struct IconValue {
|
|
||||||
customModelData: i16,
|
|
||||||
id: String,
|
|
||||||
name: String,
|
|
||||||
}
|
|
|
@ -8,16 +8,25 @@ use std::fs;
|
||||||
|
|
||||||
pub fn load_idkeys(executable_path: &str) -> Result<HashMap<String, u8>, Errorfr> {
|
pub fn load_idkeys(executable_path: &str) -> Result<HashMap<String, u8>, Errorfr> {
|
||||||
// id_keys.json
|
// id_keys.json
|
||||||
serde_json5::from_reader(&mut fs::File::open(executable_path.to_owned() + "/data/id_keys.json").map_err(|_| Errorfr::IDMapJsonMissing)?).map_err(|_| Errorfr::IDMapJsonCorrupt)
|
serde_json5::from_reader(
|
||||||
|
&mut fs::File::open(executable_path.to_owned() + "/data/id_keys.json")
|
||||||
|
.map_err(|_| Errorfr::IDMapJsonMissing)?)
|
||||||
|
.map_err(|_| Errorfr::IDMapJsonCorrupt)
|
||||||
}
|
}
|
||||||
pub fn load_shinystats(executable_path: &str) -> Result<Vec<Shinystruct>, Errorfr> {
|
pub fn load_shinystats(executable_path: &str) -> Result<Vec<Shinystruct>, Errorfr> {
|
||||||
// shiny_stats.json
|
// shiny_stats.json
|
||||||
serde_json5::from_reader(&mut fs::File::open(executable_path.to_owned() + "/data/shiny_stats.json").map_err(|_| Errorfr::ShinyJsonMissing)?).map_err(|_| Errorfr::ShinyJsonCorrupt)
|
serde_json5::from_reader(
|
||||||
|
&mut fs::File::open(executable_path.to_owned() + "/data/shiny_stats.json")
|
||||||
|
.map_err(|_| Errorfr::ShinyJsonMissing)?)
|
||||||
|
.map_err(|_| Errorfr::ShinyJsonCorrupt)
|
||||||
}
|
}
|
||||||
|
|
||||||
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> {
|
||||||
// gear.json (ONLY FOR PERFECT ITEM FUNCTION GEN)
|
// gear.json (ONLY FOR PERFECT ITEM FUNCTION GEN)
|
||||||
serde_json5::from_reader(&mut fs::File::open(executable_path.to_owned() + "/data/gear.json").map_err(|_| Errorfr::GearJsonMissing)?).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)
|
||||||
}
|
}
|
||||||
pub fn dl_json_fr(dlvalue: &String, executable_path: &str) {
|
pub fn dl_json_fr(dlvalue: &String, executable_path: &str) {
|
||||||
let jsons = DownloadJsons::from(dlvalue.clone());
|
let jsons = DownloadJsons::from(dlvalue.clone());
|
||||||
|
|
|
@ -243,5 +243,7 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
33
src/main.rs
33
src/main.rs
|
@ -33,10 +33,7 @@ struct Args {
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
perfect: Option<String>,
|
perfect: Option<String>,
|
||||||
}
|
}
|
||||||
pub enum PerfectStatus {
|
|
||||||
None,
|
|
||||||
Some(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
fn dl_json(url: Url, savename: String) -> Result<(), Errorfr> {
|
fn dl_json(url: Url, savename: String) -> Result<(), Errorfr> {
|
||||||
let resp = reqwest::blocking::get(url).map_err(|_| Errorfr::JsonDlReqFail)?;
|
let resp = reqwest::blocking::get(url).map_err(|_| Errorfr::JsonDlReqFail)?;
|
||||||
|
@ -71,6 +68,13 @@ fn main() {
|
||||||
Ok(loaded_idkeys) => {
|
Ok(loaded_idkeys) => {
|
||||||
match load_shinystats(executable_path) {
|
match load_shinystats(executable_path) {
|
||||||
Ok(loaded_shinystats) => {
|
Ok(loaded_shinystats) => {
|
||||||
|
|
||||||
|
// check if perfect status and change name if so. otherwise blank yep
|
||||||
|
let mut namefr: String = "".to_string();
|
||||||
|
if let Some(t1) = args.perfect {
|
||||||
|
namefr = t1
|
||||||
|
}
|
||||||
|
|
||||||
match load_jsonconfig(t) {
|
match load_jsonconfig(t) {
|
||||||
Ok(loaded_config) => {
|
Ok(loaded_config) => {
|
||||||
// debug mode on if in the loaded config
|
// debug mode on if in the loaded config
|
||||||
|
@ -86,15 +90,11 @@ fn main() {
|
||||||
let ver = EncodingVersion::Version1;
|
let ver = EncodingVersion::Version1;
|
||||||
|
|
||||||
let mut loaded_config_clone = loaded_config.clone();
|
let mut loaded_config_clone = loaded_config.clone();
|
||||||
// check if perfect status and change name if so. otherwise blank yep
|
|
||||||
let mut namefr: String = "".to_string();
|
|
||||||
if let Some(t1) = args.perfect {
|
|
||||||
namefr = 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_clone, loaded_idkeys, loaded_shinystats, namefr);
|
let cooking = cook(&mut out, &debug_mode, ver, &mut loaded_config_clone, loaded_idkeys, loaded_shinystats, namefr, executable_path);
|
||||||
if let Err(e) = cooking {
|
if let Err(e) = cooking {
|
||||||
println!("{}", e); // print error if there is an error
|
println!("{}", e); // print error if there is an error
|
||||||
} else {
|
} else {
|
||||||
|
@ -113,7 +113,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cook(out: &mut Vec<u8>, debug_mode: &bool, ver: EncodingVersion, json_config: &mut Jsonconfig, idsmap: HashMap<String, u8>, json_shiny: Vec<Shinystruct>, namefr: String) -> Result<String, Errorfr> {
|
fn cook(out: &mut Vec<u8>, debug_mode: &bool, ver: EncodingVersion, json_config: &mut Jsonconfig, idsmap: HashMap<String, u8>, json_shiny: Vec<Shinystruct>, namefr: String, executable_path: &str) -> Result<String, Errorfr> {
|
||||||
let mut fr_params = FuncParams {
|
let mut fr_params = FuncParams {
|
||||||
fr_out: out,
|
fr_out: out,
|
||||||
fr_debug_mode: debug_mode,
|
fr_debug_mode: debug_mode,
|
||||||
|
@ -139,7 +139,10 @@ fn cook(out: &mut Vec<u8>, debug_mode: &bool, ver: EncodingVersion, json_config:
|
||||||
// ENCODE: NameData, if ItemType is Gear, Tome, Charm
|
// ENCODE: NameData, if ItemType is Gear, Tome, Charm
|
||||||
match json_config.item_type {
|
match json_config.item_type {
|
||||||
ItemTypeDeser::Gear | ItemTypeDeser::Tome | ItemTypeDeser::Charm => {
|
ItemTypeDeser::Gear | ItemTypeDeser::Tome | ItemTypeDeser::Charm => {
|
||||||
if let Some(real_name) = &json_config.name {
|
if namefr != *"" {
|
||||||
|
fr_params.encode_namedata(&namefr)?
|
||||||
|
}
|
||||||
|
else if let Some(real_name) = &json_config.name {
|
||||||
fr_params.encode_namedata(real_name)?
|
fr_params.encode_namedata(real_name)?
|
||||||
} else {
|
} else {
|
||||||
return Err(Errorfr::JsonNotFoundName);
|
return Err(Errorfr::JsonNotFoundName);
|
||||||
|
@ -151,7 +154,11 @@ fn cook(out: &mut Vec<u8>, debug_mode: &bool, ver: EncodingVersion, json_config:
|
||||||
// ENCODE: IdentificationData
|
// ENCODE: IdentificationData
|
||||||
match json_config.item_type {
|
match json_config.item_type {
|
||||||
ItemTypeDeser::Gear | ItemTypeDeser::Tome | ItemTypeDeser::Charm => {
|
ItemTypeDeser::Gear | ItemTypeDeser::Tome | ItemTypeDeser::Charm => {
|
||||||
if let Some(real_ids) = &json_config.ids {
|
if namefr != *"" {
|
||||||
|
println!("cool tree");
|
||||||
|
let fr_gear = load_gear(executable_path)?;
|
||||||
|
}
|
||||||
|
else if let Some(real_ids) = &json_config.ids {
|
||||||
fr_params.encode_iddata(real_ids, idsmap)?
|
fr_params.encode_iddata(real_ids, idsmap)?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue