cargo fmt
This commit is contained in:
parent
e90124c4df
commit
e11c54cae5
4 changed files with 89 additions and 77 deletions
|
@ -1,8 +1,15 @@
|
||||||
use crate::jsonstruct::{CraftedTypesFr, Durability, FuncParams, Identificationer, ItemTypeDeser, Powder, RequirementsDeser, Shinyjson, Shinystruct};
|
|
||||||
use idmangler_lib::types::{ClassType, Element, ItemType, RollType, SkillType, Stat};
|
|
||||||
use idmangler_lib::{CustomGearTypeData, CustomConsumableTypeData, DataEncoder, EndData, IdentificationData, NameData, PowderData, RequirementsData, RerollData, ShinyData, StartData, TypeData, DurabilityData};
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use crate::errorfr::Errorfr;
|
use crate::errorfr::Errorfr;
|
||||||
|
use crate::jsonstruct::{
|
||||||
|
CraftedTypesFr, Durability, FuncParams, Identificationer, ItemTypeDeser, Powder,
|
||||||
|
RequirementsDeser, Shinyjson, Shinystruct,
|
||||||
|
};
|
||||||
|
use idmangler_lib::types::{ClassType, Element, ItemType, RollType, SkillType, Stat};
|
||||||
|
use idmangler_lib::{
|
||||||
|
CustomConsumableTypeData, CustomGearTypeData, DataEncoder, DurabilityData, EndData,
|
||||||
|
IdentificationData, NameData, PowderData, RequirementsData, RerollData, ShinyData, StartData,
|
||||||
|
TypeData,
|
||||||
|
};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
pub fn encode_startdata(general_params: &mut FuncParams) {
|
pub fn encode_startdata(general_params: &mut FuncParams) {
|
||||||
if *general_params.fr_debug_mode {
|
if *general_params.fr_debug_mode {
|
||||||
|
@ -22,7 +29,10 @@ pub fn encode_typedata(general_params: &mut FuncParams, item_type_deser: ItemTyp
|
||||||
.encode(general_params.fr_ver, general_params.fr_out)
|
.encode(general_params.fr_ver, general_params.fr_out)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
pub fn encode_typedata_custom(general_params: &mut FuncParams, crafted_type: &str) -> Result<(), Errorfr> {
|
pub fn encode_typedata_custom(
|
||||||
|
general_params: &mut FuncParams,
|
||||||
|
crafted_type: &str,
|
||||||
|
) -> Result<(), Errorfr> {
|
||||||
let frfr_type = CraftedTypesFr::try_from(crafted_type)?;
|
let frfr_type = CraftedTypesFr::try_from(crafted_type)?;
|
||||||
match frfr_type {
|
match frfr_type {
|
||||||
CraftedTypesFr::Gear(a) => {
|
CraftedTypesFr::Gear(a) => {
|
||||||
|
@ -32,7 +42,7 @@ pub fn encode_typedata_custom(general_params: &mut FuncParams, crafted_type: &st
|
||||||
CustomGearTypeData(a)
|
CustomGearTypeData(a)
|
||||||
.encode(general_params.fr_ver, general_params.fr_out)
|
.encode(general_params.fr_ver, general_params.fr_out)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
},
|
}
|
||||||
CraftedTypesFr::Consu(a) => {
|
CraftedTypesFr::Consu(a) => {
|
||||||
if *general_params.fr_debug_mode {
|
if *general_params.fr_debug_mode {
|
||||||
println!("Encoding CustomTypeData: Consumable");
|
println!("Encoding CustomTypeData: Consumable");
|
||||||
|
@ -44,23 +54,26 @@ pub fn encode_typedata_custom(general_params: &mut FuncParams, crafted_type: &st
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn encode_duradata(general_params: &mut FuncParams, real_dura: Durability) -> Result<(), Errorfr> {
|
pub fn encode_duradata(
|
||||||
|
general_params: &mut FuncParams,
|
||||||
|
real_dura: Durability,
|
||||||
|
) -> Result<(), Errorfr> {
|
||||||
let effect_strength_fr: u8; // but actually it should be 0 to 100, not 0 to 255. But i dunno how to use u7 data type.
|
let effect_strength_fr: u8; // but actually it should be 0 to 100, not 0 to 255. But i dunno how to use u7 data type.
|
||||||
if let Some(effstr) = real_dura.effect_strength {
|
if let Some(effstr) = real_dura.effect_strength {
|
||||||
if *general_params.fr_debug_mode {
|
if *general_params.fr_debug_mode {
|
||||||
println!("Encoding DurabilityData: Defined");
|
println!("Encoding DurabilityData: Defined");
|
||||||
}
|
}
|
||||||
effect_strength_fr = effstr
|
effect_strength_fr = effstr
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
let current_percentage = real_dura.dura_cur / real_dura.dura_max; // percentage of max durability
|
let current_percentage = real_dura.dura_cur / real_dura.dura_max; // percentage of max durability
|
||||||
if current_percentage > 100 {
|
if current_percentage > 100 {
|
||||||
return Err(Errorfr::JsonDuraOutOfRange)
|
return Err(Errorfr::JsonDuraOutOfRange);
|
||||||
}
|
}
|
||||||
if current_percentage >= 50 { // for 100% dura to 50% dura, the effectiveness is 100%
|
if current_percentage >= 50 {
|
||||||
|
// for 100% dura to 50% dura, the effectiveness is 100%
|
||||||
effect_strength_fr = 100
|
effect_strength_fr = 100
|
||||||
}
|
} else if current_percentage >= 10 {
|
||||||
else if current_percentage >= 10 { // for 50% dura to 10% dura, the effectiveness is 100% to 50%
|
// for 50% dura to 10% dura, the effectiveness is 100% to 50%
|
||||||
// see this answer from Stackoverflow for transcribing range
|
// see this answer from Stackoverflow for transcribing range
|
||||||
// https://stackoverflow.com/a/929107
|
// https://stackoverflow.com/a/929107
|
||||||
|
|
||||||
|
@ -70,36 +83,41 @@ pub fn encode_duradata(general_params: &mut FuncParams, real_dura: Durability) -
|
||||||
let new_range = 50;
|
let new_range = 50;
|
||||||
// NewValue = (((OldValue - OldMin) * NewRange) / OldRange) + NewMin
|
// NewValue = (((OldValue - OldMin) * NewRange) / OldRange) + NewMin
|
||||||
effect_strength_fr = ((((current_percentage - 10) * new_range) / old_range) + 50) as u8
|
effect_strength_fr = ((((current_percentage - 10) * new_range) / old_range) + 50) as u8
|
||||||
}
|
} else if current_percentage >= 0 {
|
||||||
else if current_percentage >= 0 { // for 10% dura to 0% dura, the effectiveness is 50% to 10%
|
// for 10% dura to 0% dura, the effectiveness is 50% to 10%
|
||||||
// old range is 10-0 = 10
|
// old range is 10-0 = 10
|
||||||
let old_range = 10;
|
let old_range = 10;
|
||||||
// new range is 50-10 = 40
|
// new range is 50-10 = 40
|
||||||
let new_range = 40;
|
let new_range = 40;
|
||||||
// NewValue = (((OldValue - OldMin) * NewRange) / OldRange) + NewMin
|
// NewValue = (((OldValue - OldMin) * NewRange) / OldRange) + NewMin
|
||||||
effect_strength_fr = ((((current_percentage) * new_range) / old_range) + 10) as u8
|
effect_strength_fr = ((((current_percentage) * new_range) / old_range) + 10) as u8
|
||||||
}
|
} else {
|
||||||
else {
|
return Err(Errorfr::JsonDuraOutOfRange);
|
||||||
return Err(Errorfr::JsonDuraOutOfRange)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if *general_params.fr_debug_mode {
|
if *general_params.fr_debug_mode {
|
||||||
println!("Encoding DurabilityData.effect_strenght: {}", effect_strength_fr);
|
println!(
|
||||||
|
"Encoding DurabilityData.effect_strenght: {}",
|
||||||
|
effect_strength_fr
|
||||||
|
);
|
||||||
println!("Encoding DurabilityData.current: {}", real_dura.dura_cur);
|
println!("Encoding DurabilityData.current: {}", real_dura.dura_cur);
|
||||||
println!("Encoding DurabilityData.current: {}", real_dura.dura_max);
|
println!("Encoding DurabilityData.current: {}", real_dura.dura_max);
|
||||||
}
|
}
|
||||||
DurabilityData {
|
DurabilityData {
|
||||||
effect_strenght: effect_strength_fr,
|
effect_strenght: effect_strength_fr,
|
||||||
current: real_dura.dura_cur,
|
current: real_dura.dura_cur,
|
||||||
max: real_dura.dura_max
|
max: real_dura.dura_max,
|
||||||
}
|
}
|
||||||
.encode(general_params.fr_ver, general_params.fr_out)
|
.encode(general_params.fr_ver, general_params.fr_out)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn encode_reqdata(general_params: &mut FuncParams, real_reqdata: RequirementsDeser) {
|
pub fn encode_reqdata(general_params: &mut FuncParams, real_reqdata: RequirementsDeser) {
|
||||||
if *general_params.fr_debug_mode {
|
if *general_params.fr_debug_mode {
|
||||||
println!("Encoding RequirementData.Level: {:?}", real_reqdata.level.clone())
|
println!(
|
||||||
|
"Encoding RequirementData.Level: {:?}",
|
||||||
|
real_reqdata.level.clone()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
let mut fr_class: Option<ClassType> = None;
|
let mut fr_class: Option<ClassType> = None;
|
||||||
if let Some(actualclass) = real_reqdata.class {
|
if let Some(actualclass) = real_reqdata.class {
|
||||||
|
@ -107,8 +125,7 @@ pub fn encode_reqdata(general_params: &mut FuncParams, real_reqdata: Requirement
|
||||||
if *general_params.fr_debug_mode {
|
if *general_params.fr_debug_mode {
|
||||||
println!("Encoding RequirementData.Class: {:?}", actualclass.clone())
|
println!("Encoding RequirementData.Class: {:?}", actualclass.clone())
|
||||||
}
|
}
|
||||||
}
|
} else if *general_params.fr_debug_mode {
|
||||||
else if *general_params.fr_debug_mode {
|
|
||||||
println!("Encoding RequirementData.Class: Undefined");
|
println!("Encoding RequirementData.Class: Undefined");
|
||||||
}
|
}
|
||||||
let spvec: Vec<(SkillType, i32)> = Vec::<(SkillType, i32)>::from(real_reqdata.sp);
|
let spvec: Vec<(SkillType, i32)> = Vec::<(SkillType, i32)>::from(real_reqdata.sp);
|
||||||
|
@ -118,10 +135,10 @@ pub fn encode_reqdata(general_params: &mut FuncParams, real_reqdata: Requirement
|
||||||
RequirementsData {
|
RequirementsData {
|
||||||
level: real_reqdata.level,
|
level: real_reqdata.level,
|
||||||
class: fr_class,
|
class: fr_class,
|
||||||
skills: spvec
|
skills: spvec,
|
||||||
}
|
}
|
||||||
.encode(general_params.fr_ver, general_params.fr_out)
|
.encode(general_params.fr_ver, general_params.fr_out)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
pub fn encode_namedata(general_params: &mut FuncParams, real_name: &str) {
|
pub fn encode_namedata(general_params: &mut FuncParams, real_name: &str) {
|
||||||
// ENCODE: NameData
|
// ENCODE: NameData
|
||||||
|
@ -132,7 +149,11 @@ pub fn encode_namedata(general_params: &mut FuncParams, real_name: &str) {
|
||||||
.encode(general_params.fr_ver, general_params.fr_out)
|
.encode(general_params.fr_ver, general_params.fr_out)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
pub fn encode_iddata(general_params: &mut FuncParams, real_ids: Vec<Identificationer>, idsmap: HashMap<String, u8>) {
|
pub fn encode_iddata(
|
||||||
|
general_params: &mut FuncParams,
|
||||||
|
real_ids: Vec<Identificationer>,
|
||||||
|
idsmap: HashMap<String, u8>,
|
||||||
|
) {
|
||||||
let mut idvec = Vec::new();
|
let mut idvec = Vec::new();
|
||||||
for eachid in real_ids {
|
for eachid in real_ids {
|
||||||
let id_id = idsmap.get(eachid.id.trim());
|
let id_id = idsmap.get(eachid.id.trim());
|
||||||
|
@ -213,7 +234,11 @@ pub fn encode_rerolldata(general_params: &mut FuncParams, rerollcount: u8) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn encode_shinydata(general_params: &mut FuncParams, shiny: Shinyjson, json_shiny: Vec<Shinystruct>) {
|
pub fn encode_shinydata(
|
||||||
|
general_params: &mut FuncParams,
|
||||||
|
shiny: Shinyjson,
|
||||||
|
json_shiny: Vec<Shinystruct>,
|
||||||
|
) {
|
||||||
let mut realshinykey: u8;
|
let mut realshinykey: u8;
|
||||||
let _shinykey = &shiny.key;
|
let _shinykey = &shiny.key;
|
||||||
let shinyvalue = shiny.value;
|
let shinyvalue = shiny.value;
|
||||||
|
|
|
@ -64,8 +64,10 @@ pub enum Errorfr {
|
||||||
/// Durability was not found but is necessary
|
/// Durability was not found but is necessary
|
||||||
#[error("Error 4.5: \"Durability\" was not found (necessary for Crafted Gear item type)")]
|
#[error("Error 4.5: \"Durability\" was not found (necessary for Crafted Gear item type)")]
|
||||||
JsonNotFoundDura,
|
JsonNotFoundDura,
|
||||||
|
|
||||||
/// Durability Bad
|
/// Durability Bad
|
||||||
#[error("Error 4.6: \"Requirements\" was not found (necessary for Crafted Gear / Consumable items)")]
|
#[error(
|
||||||
JsonNotFoundReqs
|
"Error 4.6: \"Requirements\" was not found (necessary for Crafted Gear / Consumable items)"
|
||||||
|
)]
|
||||||
|
JsonNotFoundReqs,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
use crate::errorfr::Errorfr;
|
use crate::errorfr::Errorfr;
|
||||||
use idmangler_lib::types::{ItemType, TransformVersion, ConsumableType, GearType};
|
use crate::jsonstruct::CraftedTypesFr::{Consu, Gear};
|
||||||
|
use idmangler_lib::types::{ClassType, ConsumableType::*, GearType::*, SkillType};
|
||||||
|
use idmangler_lib::types::{ConsumableType, GearType, ItemType, TransformVersion};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use idmangler_lib::types::{ConsumableType::*,GearType::*, ClassType, SkillType};
|
|
||||||
use crate::jsonstruct::CraftedTypesFr::{Consu, Gear};
|
|
||||||
|
|
||||||
// structs for the json parsing
|
// structs for the json parsing
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
|
||||||
pub struct Jsonconfig {
|
pub struct Jsonconfig {
|
||||||
pub debug: Option<bool>, // not a thing to be encoded, this just toggles debug prints. Also settable using --debug
|
pub debug: Option<bool>, // not a thing to be encoded, this just toggles debug prints. Also settable using --debug
|
||||||
// Item Types (Gear, Tome, Charm, Crafted Gear, Crafted Consum)
|
// Item Types (Gear, Tome, Charm, Crafted Gear, Crafted Consum)
|
||||||
|
@ -27,26 +26,22 @@ pub struct Jsonconfig {
|
||||||
pub powders: Option<Vec<Powder>>,
|
pub powders: Option<Vec<Powder>>,
|
||||||
pub rerolls: Option<u8>,
|
pub rerolls: Option<u8>,
|
||||||
}
|
}
|
||||||
// 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.
|
||||||
// This avoids confusing end user.
|
// This avoids confusing end user.
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)]
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
|
||||||
#[derive(Clone, Copy)]
|
|
||||||
pub struct RequirementsDeser {
|
pub struct RequirementsDeser {
|
||||||
pub level: u8,
|
pub level: u8,
|
||||||
pub class: Option<ClassDeser>,
|
pub class: Option<ClassDeser>,
|
||||||
pub sp: SkillPointDeser
|
pub sp: SkillPointDeser,
|
||||||
}
|
}
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)]
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
|
||||||
#[derive(Clone, Copy)]
|
|
||||||
pub enum ClassDeser {
|
pub enum ClassDeser {
|
||||||
Archer,
|
Archer,
|
||||||
Warrior,
|
Warrior,
|
||||||
Assassin,
|
Assassin,
|
||||||
Mage,
|
Mage,
|
||||||
Shaman
|
Shaman,
|
||||||
}
|
}
|
||||||
impl From<ClassDeser> for ClassType {
|
impl From<ClassDeser> for ClassType {
|
||||||
fn from(value: ClassDeser) -> Self {
|
fn from(value: ClassDeser) -> Self {
|
||||||
|
@ -55,13 +50,11 @@ impl From<ClassDeser> for ClassType {
|
||||||
ClassDeser::Warrior => ClassType::Warrior,
|
ClassDeser::Warrior => ClassType::Warrior,
|
||||||
ClassDeser::Assassin => ClassType::Assasin,
|
ClassDeser::Assassin => ClassType::Assasin,
|
||||||
ClassDeser::Mage => ClassType::Mage,
|
ClassDeser::Mage => ClassType::Mage,
|
||||||
ClassDeser::Shaman => ClassType::Shaman
|
ClassDeser::Shaman => ClassType::Shaman,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[derive(Deserialize, Copy)]
|
#[derive(Deserialize, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone)]
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct SkillPointDeser {
|
pub struct SkillPointDeser {
|
||||||
#[serde(alias = "Str")]
|
#[serde(alias = "Str")]
|
||||||
#[serde(alias = "str")]
|
#[serde(alias = "str")]
|
||||||
|
@ -82,7 +75,7 @@ pub struct SkillPointDeser {
|
||||||
#[serde(alias = "Agi")]
|
#[serde(alias = "Agi")]
|
||||||
#[serde(alias = "agi")]
|
#[serde(alias = "agi")]
|
||||||
#[serde(alias = "agility")]
|
#[serde(alias = "agility")]
|
||||||
pub agility: Option<i32>
|
pub agility: Option<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SkillPointDeser> for Vec<(SkillType, i32)> {
|
impl From<SkillPointDeser> for Vec<(SkillType, i32)> {
|
||||||
|
@ -109,7 +102,7 @@ impl From<SkillPointDeser> for Vec<(SkillType, i32)> {
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
pub enum CraftedTypesFr {
|
pub enum CraftedTypesFr {
|
||||||
Gear(GearType),
|
Gear(GearType),
|
||||||
Consu(ConsumableType)
|
Consu(ConsumableType),
|
||||||
}
|
}
|
||||||
impl TryFrom<&str> for CraftedTypesFr {
|
impl TryFrom<&str> for CraftedTypesFr {
|
||||||
type Error = Errorfr;
|
type Error = Errorfr;
|
||||||
|
@ -139,39 +132,34 @@ impl TryFrom<&str> for CraftedTypesFr {
|
||||||
"weapon" => Ok(Gear(Weapon)),
|
"weapon" => Ok(Gear(Weapon)),
|
||||||
"accessory" => Ok(Gear(Accessory)),
|
"accessory" => Ok(Gear(Accessory)),
|
||||||
// fallback error return
|
// fallback error return
|
||||||
_ => Err(Errorfr::JsonInvalidCraftedType)
|
_ => Err(Errorfr::JsonInvalidCraftedType),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
|
||||||
pub struct Durability {
|
pub struct Durability {
|
||||||
pub effect_strength: Option<u8>,
|
pub effect_strength: Option<u8>,
|
||||||
pub dura_cur: i32,
|
pub dura_cur: i32,
|
||||||
pub dura_max: i32
|
pub dura_max: i32,
|
||||||
}
|
}
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
|
||||||
pub struct Shinystruct {
|
pub struct Shinystruct {
|
||||||
pub id: u8,
|
pub id: u8,
|
||||||
pub key: String,
|
pub key: String,
|
||||||
}
|
}
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
|
||||||
pub struct Identificationer {
|
pub struct Identificationer {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub base: i32,
|
pub base: i32,
|
||||||
pub roll: Option<u8>,
|
pub roll: Option<u8>,
|
||||||
}
|
}
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
|
||||||
pub struct Powder {
|
pub struct Powder {
|
||||||
pub r#type: char,
|
pub r#type: char,
|
||||||
pub amount: Option<u8>,
|
pub amount: Option<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
|
||||||
pub struct Shinyjson {
|
pub struct Shinyjson {
|
||||||
pub key: String,
|
pub key: String,
|
||||||
pub value: i64,
|
pub value: i64,
|
||||||
|
|
21
src/main.rs
21
src/main.rs
|
@ -13,9 +13,9 @@ use crate::errorfr::Errorfr;
|
||||||
use crate::jsondl::*;
|
use crate::jsondl::*;
|
||||||
use crate::jsonstruct::*;
|
use crate::jsonstruct::*;
|
||||||
|
|
||||||
|
use crate::errorfr::Errorfr::JsonNotFoundCraftedType;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
use crate::errorfr::Errorfr::JsonNotFoundCraftedType;
|
|
||||||
|
|
||||||
#[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))]
|
||||||
|
@ -130,9 +130,8 @@ fn cook(
|
||||||
ItemTypeDeser::CraftedGear | ItemTypeDeser::CraftedConsu => {
|
ItemTypeDeser::CraftedGear | ItemTypeDeser::CraftedConsu => {
|
||||||
if let Some(real_crafted_type) = json_config.crafted_type {
|
if let Some(real_crafted_type) = json_config.crafted_type {
|
||||||
encode_typedata_custom(&mut fr_params, &real_crafted_type)?;
|
encode_typedata_custom(&mut fr_params, &real_crafted_type)?;
|
||||||
}
|
} else {
|
||||||
else {
|
return Err(JsonNotFoundCraftedType);
|
||||||
return Err(JsonNotFoundCraftedType)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -165,11 +164,10 @@ fn cook(
|
||||||
ItemTypeDeser::CraftedGear => {
|
ItemTypeDeser::CraftedGear => {
|
||||||
if let Some(real_dura) = json_config.durability {
|
if let Some(real_dura) = json_config.durability {
|
||||||
encode_duradata(&mut fr_params, real_dura)?;
|
encode_duradata(&mut fr_params, real_dura)?;
|
||||||
|
} else {
|
||||||
|
return Err(Errorfr::JsonNotFoundDura);
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
return Err(Errorfr::JsonNotFoundDura)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,11 +176,10 @@ fn cook(
|
||||||
ItemTypeDeser::CraftedGear | ItemTypeDeser::CraftedConsu => {
|
ItemTypeDeser::CraftedGear | ItemTypeDeser::CraftedConsu => {
|
||||||
if let Some(real_reqs) = json_config.requirements {
|
if let Some(real_reqs) = json_config.requirements {
|
||||||
encode_reqdata(&mut fr_params, real_reqs)
|
encode_reqdata(&mut fr_params, real_reqs)
|
||||||
|
} else {
|
||||||
|
return Err(Errorfr::JsonNotFoundReqs);
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
return Err(Errorfr::JsonNotFoundReqs)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue