ran rustfmt because people told me to
This commit is contained in:
parent
85fd671a65
commit
04ad18f538
2 changed files with 57 additions and 88 deletions
95
src/main.rs
95
src/main.rs
|
@ -1,35 +1,21 @@
|
|||
use idmangler_lib::{
|
||||
|
||||
EndData, IdentificationData, NameData,
|
||||
PowderData, RerollData, ShinyData, StartData,
|
||||
TypeData, DataEncoder,
|
||||
|
||||
encoding::{encode_string},
|
||||
encoding::encode_string,
|
||||
types::{
|
||||
ItemType,
|
||||
Powders,
|
||||
{RollType, Stat},
|
||||
TransformVersion,
|
||||
ItemType, Powders, TransformVersion, {RollType, Stat},
|
||||
},
|
||||
DataEncoder, EndData, IdentificationData, NameData, PowderData, RerollData, ShinyData,
|
||||
StartData, TypeData,
|
||||
};
|
||||
|
||||
use serde_json;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::panic;
|
||||
use std::env;
|
||||
use std::string::ToString;
|
||||
use serde_json;
|
||||
mod structures;
|
||||
use crate::structures::*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
|
@ -51,8 +37,6 @@ fn main() {
|
|||
// fancypanic();
|
||||
let args = Args::parse();
|
||||
|
||||
|
||||
|
||||
let mut debugMode = false;
|
||||
if args.debugmode == true {
|
||||
debugMode = true;
|
||||
|
@ -63,21 +47,16 @@ fn main() {
|
|||
configpath = configpathargs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// newest json reading code
|
||||
let json_config: jsonconfig = serde_json::from_reader(
|
||||
fs::File::open(configpath).expect(ERROR[1]))
|
||||
.expect(ERROR[2]);
|
||||
let idsmap: HashMap<String, u8> = serde_json::from_reader(
|
||||
fs::File::open("id_keys.json").expect(ERROR[3]))
|
||||
.expect(ERROR[4]);
|
||||
let json_shiny: Vec<shinystruct> = serde_json::from_reader(
|
||||
fs::File::open("shiny_stats.json").expect(ERROR[5]))
|
||||
let json_config: jsonconfig =
|
||||
serde_json::from_reader(fs::File::open(configpath).expect(ERROR[1])).expect(ERROR[2]);
|
||||
let idsmap: HashMap<String, u8> =
|
||||
serde_json::from_reader(fs::File::open("id_keys.json").expect(ERROR[3])).expect(ERROR[4]);
|
||||
let json_shiny: Vec<shinystruct> =
|
||||
serde_json::from_reader(fs::File::open("shiny_stats.json").expect(ERROR[5]))
|
||||
.expect(ERROR[6]);
|
||||
// println!("{:?}",idsmap.get("airDamage"));
|
||||
|
||||
|
||||
let mut out = Vec::new();
|
||||
let ver = TransformVersion::Version1;
|
||||
|
||||
|
@ -89,7 +68,6 @@ fn main() {
|
|||
.encode(ver, &mut out)
|
||||
.unwrap();
|
||||
|
||||
|
||||
// json identification data handling
|
||||
let mut idvec = Vec::new();
|
||||
for eachid in json_config.ids {
|
||||
|
@ -121,21 +99,14 @@ fn main() {
|
|||
.encode(ver, &mut out)
|
||||
.unwrap();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// json powder data handling
|
||||
let mut powdervec = Vec::new();
|
||||
for eachpowder in json_config.powders {
|
||||
let powdertier = eachpowder.tier; // get the powder tier
|
||||
let powderamount:u8 = match eachpowder.amount { // get amount of powder if exists, otherwise 1
|
||||
Some(amount) => {
|
||||
amount
|
||||
},// good,
|
||||
None => {
|
||||
1
|
||||
}// bad,
|
||||
let powderamount: u8 = match eachpowder.amount {
|
||||
// get amount of powder if exists, otherwise 1
|
||||
Some(amount) => amount, // good,
|
||||
None => 1, // bad,
|
||||
};
|
||||
// match for the powder type
|
||||
// no need to return to variable or i'll need to rematch AGAIN
|
||||
|
@ -147,7 +118,7 @@ fn main() {
|
|||
if debugMode {
|
||||
println!("Powder type: Earth");
|
||||
}
|
||||
},
|
||||
}
|
||||
'T' | 't' => {
|
||||
for _i in 0..powderamount {
|
||||
powdervec.push((Powders::THUNDER, powdertier))
|
||||
|
@ -155,7 +126,7 @@ fn main() {
|
|||
if debugMode {
|
||||
println!("Powder type: Thunder");
|
||||
}
|
||||
},
|
||||
}
|
||||
'W' | 'w' => {
|
||||
for _i in 0..powderamount {
|
||||
powdervec.push((Powders::WATER, powdertier))
|
||||
|
@ -163,7 +134,7 @@ fn main() {
|
|||
if debugMode {
|
||||
println!("Powder type: Water");
|
||||
}
|
||||
},
|
||||
}
|
||||
'F' | 'f' => {
|
||||
for _i in 0..powderamount {
|
||||
powdervec.push((Powders::FIRE, powdertier))
|
||||
|
@ -171,7 +142,7 @@ fn main() {
|
|||
if debugMode {
|
||||
println!("Powder type: Fire");
|
||||
}
|
||||
},
|
||||
}
|
||||
'A' | 'a' => {
|
||||
for _i in 0..powderamount {
|
||||
powdervec.push((Powders::AIR, powdertier))
|
||||
|
@ -179,7 +150,7 @@ fn main() {
|
|||
if debugMode {
|
||||
println!("Powder type: Air");
|
||||
}
|
||||
},
|
||||
}
|
||||
_ => {
|
||||
for _i in 0..powderamount {
|
||||
powdervec.push((Powders::THUNDER, powdertier))
|
||||
|
@ -207,7 +178,6 @@ fn main() {
|
|||
.encode(ver, &mut out)
|
||||
.unwrap();
|
||||
|
||||
|
||||
match json_config.rerolls {
|
||||
Some(i) => {
|
||||
if i != 0 {
|
||||
|
@ -216,8 +186,8 @@ fn main() {
|
|||
println!("Rerolls: {}", i)
|
||||
}
|
||||
}
|
||||
},
|
||||
None => pass()
|
||||
}
|
||||
None => pass(),
|
||||
}
|
||||
|
||||
let mut realshinykey: u8;
|
||||
|
@ -249,16 +219,11 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// prints (Water,6) 255 times
|
||||
// println!("{:?}",vec![(Powders::WATER, 6); 255]);
|
||||
|
||||
EndData.encode(ver, &mut out).unwrap();
|
||||
|
||||
|
||||
|
||||
// final string print
|
||||
println!("{}", encode_string(&out));
|
||||
|
||||
|
@ -278,17 +243,21 @@ fn main() {
|
|||
// println!("{:#?}", out);
|
||||
}
|
||||
|
||||
|
||||
fn fancypanic() {
|
||||
panic::set_hook(Box::new(|panic_info| {
|
||||
let panic_msg = format!("{panic_info}");
|
||||
println!("{}", panic_msg.lines().skip(1).next().unwrap_or("HOW DID YOU BREAK THE PANIC HANDLER???"));
|
||||
println!(
|
||||
"{}",
|
||||
panic_msg
|
||||
.lines()
|
||||
.skip(1)
|
||||
.next()
|
||||
.unwrap_or("HOW DID YOU BREAK THE PANIC HANDLER???")
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
fn pass() {
|
||||
|
||||
}
|
||||
fn pass() {}
|
||||
|
||||
const ERROR: [&'static str; 7] = [
|
||||
"Error 0: what did you even do to get this? ",
|
||||
|
|
|
@ -4,13 +4,13 @@ use serde::Deserialize;
|
|||
pub struct Powder {
|
||||
pub r#type: char,
|
||||
pub tier: u8,
|
||||
pub amount: Option<u8>
|
||||
pub amount: Option<u8>,
|
||||
}
|
||||
#[derive(Deserialize)]
|
||||
pub struct Identificationer {
|
||||
pub id: String,
|
||||
pub base: i32,
|
||||
pub roll: Option<u8>
|
||||
pub roll: Option<u8>,
|
||||
}
|
||||
#[derive(Deserialize)]
|
||||
pub struct jsonconfig {
|
||||
|
@ -20,16 +20,16 @@ pub struct jsonconfig {
|
|||
pub ids: Vec<Identificationer>,
|
||||
pub powder_limit: u8,
|
||||
pub powders: Vec<Powder>,
|
||||
pub rerolls:Option<u8>
|
||||
pub rerolls: Option<u8>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct shinystruct {
|
||||
pub id: u8,
|
||||
pub key:String
|
||||
pub key: String,
|
||||
}
|
||||
#[derive(Deserialize)]
|
||||
pub struct shinyjson {
|
||||
pub key: String,
|
||||
pub value: i64
|
||||
pub value: i64,
|
||||
}
|
Loading…
Reference in a new issue