let me cook
This commit is contained in:
parent
fe7ec985f2
commit
7d4dcfa2b9
5 changed files with 18 additions and 56 deletions
|
@ -2,10 +2,7 @@ use crate::errorfr::Errorfr;
|
||||||
use crate::jsonstruct::{CraftedTypesFr, Durability, FuncParams, Identificationer, ItemTypeDeser, PowderFr, RequirementsDeser, Shinyjson, Shinystruct};
|
use crate::jsonstruct::{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, RequirementsData, RerollData, ShinyData, StartData, TypeData},
|
||||||
CraftedConsumableTypeData, CraftedGearTypeData, DurabilityData, EndData, IdentificationData, NameData, PowderData, RequirementsData, RerollData,
|
|
||||||
ShinyData, StartData, TypeData,
|
|
||||||
},
|
|
||||||
types::{ClassType, Element, ItemType, Powder, RollType, SkillType, Stat},
|
types::{ClassType, Element, ItemType, Powder, RollType, SkillType, Stat},
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -242,12 +239,7 @@ impl FuncParams<'_> {
|
||||||
dbg!(&shinyvalue);
|
dbg!(&shinyvalue);
|
||||||
}
|
}
|
||||||
// ENCODE: ShinyData (if applicable)
|
// ENCODE: ShinyData (if applicable)
|
||||||
ShinyData {
|
ShinyData { id: realshinykey, val: shinyvalue }.encode(self.fr_ver, self.fr_out).unwrap();
|
||||||
id: realshinykey,
|
|
||||||
val: shinyvalue,
|
|
||||||
}
|
|
||||||
.encode(self.fr_ver, self.fr_out)
|
|
||||||
.unwrap();
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn encode_enddata(&mut self) -> Result<(), Errorfr> {
|
pub fn encode_enddata(&mut self) -> Result<(), Errorfr> {
|
||||||
|
|
|
@ -28,15 +28,11 @@ pub enum Errorfr {
|
||||||
ShinyJsonCorrupt,
|
ShinyJsonCorrupt,
|
||||||
|
|
||||||
/// gear json is missing
|
/// gear json is missing
|
||||||
#[error(
|
#[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 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("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 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
|
||||||
|
|
|
@ -8,20 +8,17 @@ 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)?)
|
serde_json5::from_reader(&mut fs::File::open(executable_path.to_owned() + "/data/id_keys.json").map_err(|_| Errorfr::IDMapJsonMissing)?).map_err(|_| Errorfr::IDMapJsonCorrupt)
|
||||||
.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)?)
|
serde_json5::from_reader(&mut fs::File::open(executable_path.to_owned() + "/data/shiny_stats.json").map_err(|_| Errorfr::ShinyJsonMissing)?).map_err(|_| Errorfr::ShinyJsonCorrupt)
|
||||||
.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> {
|
||||||
// shiny_stats.json
|
// shiny_stats.json
|
||||||
let a: Result<HashMap<String, gearjson::GearJsonItem>, Errorfr> =
|
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)?)
|
serde_json5::from_reader(&mut fs::File::open(executable_path.to_owned() + "/data/gear.json").map_err(|_| Errorfr::GearJsonMissing)?).map_err(|_| Errorfr::GearJsonCorrupt);
|
||||||
.map_err(|_| Errorfr::GearJsonCorrupt);
|
|
||||||
|
|
||||||
a
|
a
|
||||||
}
|
}
|
||||||
|
@ -33,9 +30,7 @@ pub fn dl_json_fr(dlvalue: &String, executable_path: &str) {
|
||||||
|
|
||||||
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().unwrap(),
|
||||||
.parse()
|
|
||||||
.unwrap(),
|
|
||||||
format!("{}{}", executable_path, "/data/shiny_stats.json"),
|
format!("{}{}", executable_path, "/data/shiny_stats.json"),
|
||||||
) {
|
) {
|
||||||
// error handling below
|
// error handling below
|
||||||
|
@ -44,9 +39,7 @@ pub fn dl_json_fr(dlvalue: &String, executable_path: &str) {
|
||||||
}
|
}
|
||||||
if jsons == DownloadJsons::All || jsons == DownloadJsons::IdKeys {
|
if jsons == DownloadJsons::All || jsons == DownloadJsons::IdKeys {
|
||||||
if let Err(e) = dl_json(
|
if let Err(e) = dl_json(
|
||||||
"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().unwrap(),
|
||||||
.parse()
|
|
||||||
.unwrap(),
|
|
||||||
format!("{}{}", executable_path, "/data/id_keys.json"),
|
format!("{}{}", executable_path, "/data/id_keys.json"),
|
||||||
) {
|
) {
|
||||||
// error handling below
|
// error handling below
|
||||||
|
@ -55,9 +48,7 @@ pub fn dl_json_fr(dlvalue: &String, executable_path: &str) {
|
||||||
}
|
}
|
||||||
if jsons == DownloadJsons::All || jsons == DownloadJsons::Gear {
|
if jsons == DownloadJsons::All || jsons == DownloadJsons::Gear {
|
||||||
if let Err(e) = dl_json(
|
if let Err(e) = dl_json(
|
||||||
"https://raw.githubusercontent.com/Wynntils/Static-Storage/main/Reference/gear.json"
|
"https://raw.githubusercontent.com/Wynntils/Static-Storage/main/Reference/gear.json".parse().unwrap(),
|
||||||
.parse()
|
|
||||||
.unwrap(),
|
|
||||||
format!("{}{}", executable_path, "/data/gear.json"),
|
format!("{}{}", executable_path, "/data/gear.json"),
|
||||||
) {
|
) {
|
||||||
// error handling below
|
// error handling below
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
use crate::errorfr::Errorfr;
|
use crate::errorfr::Errorfr;
|
||||||
use crate::jsonstruct::CraftedTypesFr::{Consu, Gear};
|
use crate::jsonstruct::CraftedTypesFr::{Consu, Gear};
|
||||||
use idmangler_lib::types::{
|
use idmangler_lib::types::{AttackSpeed, ClassType, ConsumableType, ConsumableType::*, CraftedGearType, CraftedGearType::*, EncodingVersion, ItemType, SkillType};
|
||||||
AttackSpeed, ClassType, ConsumableType, ConsumableType::*, CraftedGearType, CraftedGearType::*, EncodingVersion, ItemType, SkillType,
|
|
||||||
};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
|
@ -14,15 +12,7 @@ pub struct Jsonconfig {
|
||||||
pub debug: Option<bool>,
|
pub debug: Option<bool>,
|
||||||
|
|
||||||
// Item Types (Gear, Tome, Charm, Crafted Gear, Crafted Consum)
|
// Item Types (Gear, Tome, Charm, Crafted Gear, Crafted Consum)
|
||||||
#[serde(
|
#[serde(alias = "itemtype", alias = "ITEM_TYPE", alias = "ITEMTYPE", alias = "Item_Type", alias = "Item_type", alias = "ItemType", alias = "Itemtype")]
|
||||||
alias = "itemtype",
|
|
||||||
alias = "ITEM_TYPE",
|
|
||||||
alias = "ITEMTYPE",
|
|
||||||
alias = "Item_Type",
|
|
||||||
alias = "Item_type",
|
|
||||||
alias = "ItemType",
|
|
||||||
alias = "Itemtype"
|
|
||||||
)]
|
|
||||||
pub item_type: ItemTypeDeser,
|
pub item_type: ItemTypeDeser,
|
||||||
|
|
||||||
// Crafted type for Crafted item types
|
// Crafted type for Crafted item types
|
||||||
|
|
19
src/main.rs
19
src/main.rs
|
@ -85,15 +85,16 @@ fn main() {
|
||||||
// create necessary variables
|
// create necessary variables
|
||||||
let ver = EncodingVersion::Version1;
|
let ver = EncodingVersion::Version1;
|
||||||
|
|
||||||
let mut loaded_config_borrow = loaded_config.clone();
|
let mut loaded_config_clone = loaded_config.clone();
|
||||||
// check if perfect status
|
// check if perfect status and change name if so. otherwise blank yep
|
||||||
|
let mut namefr: String = "".to_string();
|
||||||
if let Some(t1) = args.perfect {
|
if let Some(t1) = args.perfect {
|
||||||
loaded_config_borrow.name = Some(t1)
|
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_borrow, loaded_idkeys, loaded_shinystats);
|
let cooking = cook(&mut out, &debug_mode, ver, &mut loaded_config_clone, loaded_idkeys, loaded_shinystats, namefr);
|
||||||
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 {
|
||||||
|
@ -112,9 +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>, json_shiny: Vec<Shinystruct>, namefr: String) -> Result<String, Errorfr> {
|
||||||
out: &mut Vec<u8>, debug_mode: &bool, ver: EncodingVersion, json_config: &mut Jsonconfig, idsmap: HashMap<String, u8>, json_shiny: Vec<Shinystruct>,
|
|
||||||
) -> 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,
|
||||||
|
@ -233,9 +232,3 @@ fn cook(
|
||||||
|
|
||||||
Ok(final_string)
|
Ok(final_string)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cook_perfect(
|
|
||||||
out: &mut Vec<u8>, debug_mode: &bool, ver: EncodingVersion, json_config: &Jsonconfig, idsmap: HashMap<String, u8>, json_shiny: Vec<Shinystruct>,
|
|
||||||
) -> Result<String, Errorfr> {
|
|
||||||
Ok("fr".parse().unwrap())
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue