Add optional mode for debug prints

This commit is contained in:
endernon 2024-09-14 20:52:06 +01:00
parent 9e2d94c625
commit fd7bc7acc8
3 changed files with 62 additions and 21 deletions

View file

@ -1,6 +1,9 @@
# idmangler-cli # idmangler-cli
Basically this generates fake items by loading from a json. Effectively a wrapper for [zatzou's idmangler-lib](https://github.com/Zatzou/idmangler-lib). Basically this generates fake items by loading from a json. Effectively a wrapper for [zatzou's idmangler-lib](https://github.com/Zatzou/idmangler-lib).
Any bugs? DM endernon on discord.
## How to get the program ## How to get the program
### Option 1: prebuilt ### Option 1: prebuilt
Go to the [releases tab](https://git.frfrnocap.men/endernon/idmangler-cli/releases) Go to the [releases tab](https://git.frfrnocap.men/endernon/idmangler-cli/releases)

View file

@ -3,10 +3,10 @@
"Refer to config.md to understand how to apply the data shown here.", "Refer to config.md to understand how to apply the data shown here.",
"There are also some values you cannot increase beyond a limit." "There are also some values you cannot increase beyond a limit."
], ],
"debug":true, "debug":false,
"name":"Singularity", "name":"Singularity",
"shiny": { "shiny": {
"key": "raidsWon", "key": "lootrunsCompleted",
"value": 69 "value": 69
}, },
"ids": [ "ids": [
@ -16,7 +16,7 @@
{"id": "walkSpeed", "base":-40 , "roll":69}, {"id": "walkSpeed", "base":-40 , "roll":69},
{"id": "mainAttackDamage", "base":15, "roll":130 }, {"id": "mainAttackDamage", "base":15, "roll":130 },
{"id": "rawMainAttackDamage", "base":444 , "roll":130 }, {"id": "rawMainAttackDamage", "base":444 , "roll":130 },
{"id": "rawSpellDamage", "base":222 , "roll":30 }, {"id": "rawSpellDamage", "base":222 , "roll":130 },
{"id": "spellDamage", "base":10 , "roll":130 } {"id": "spellDamage", "base":10 , "roll":130 }
], ],
"powder_limit": 255, "powder_limit": 255,

View file

@ -60,6 +60,8 @@ fn main() {
// enable fancypanic when building for release // enable fancypanic when building for release
// fancypanic(); // fancypanic();
// newest json reading code // newest json reading code
let json_config: jsonconfig = serde_json::from_reader( let json_config: jsonconfig = serde_json::from_reader(
fs::File::open("config.json").expect(ERROR[1])) fs::File::open("config.json").expect(ERROR[1]))
@ -72,7 +74,13 @@ fn main() {
.expect(ERROR[6]); .expect(ERROR[6]);
// println!("{:?}",idsmap.get("airDamage")); // println!("{:?}",idsmap.get("airDamage"));
let mut debugMode = false;
if let Some(debuggering) = json_config.debug {
if debuggering == true {
debugMode = true;
println!("Debug mode enabled");
}
};
let mut out = Vec::new(); let mut out = Vec::new();
let ver = TransformVersion::Version1; let ver = TransformVersion::Version1;
@ -140,38 +148,60 @@ fn main() {
for _i in 0..powderamount { for _i in 0..powderamount {
powdervec.push((Powders::EARTH,powdertier)) powdervec.push((Powders::EARTH,powdertier))
} }
if debugMode {
println!("Powder type: Earth");
}
}, },
'T' | 't' => { 'T' | 't' => {
for _i in 0..powderamount { for _i in 0..powderamount {
powdervec.push((Powders::THUNDER,powdertier)) powdervec.push((Powders::THUNDER,powdertier))
} }
if debugMode {
println!("Powder type: Thunder");
}
}, },
'W' | 'w' => { 'W' | 'w' => {
for _i in 0..powderamount { for _i in 0..powderamount {
powdervec.push((Powders::WATER,powdertier)) powdervec.push((Powders::WATER,powdertier))
} }
if debugMode {
println!("Powder type: Water");
}
}, },
'F' | 'f' => { 'F' | 'f' => {
for _i in 0..powderamount { for _i in 0..powderamount {
powdervec.push((Powders::FIRE,powdertier)) powdervec.push((Powders::FIRE,powdertier))
} }
if debugMode {
println!("Powder type: Fire");
}
}, },
'A' | 'a' => { 'A' | 'a' => {
for _i in 0..powderamount { for _i in 0..powderamount {
powdervec.push((Powders::AIR,powdertier)) powdervec.push((Powders::AIR,powdertier))
} }
if debugMode {
println!("Powder type: Air");
}
}, },
_ => { _ => {
for _i in 0..powderamount { for _i in 0..powderamount {
powdervec.push((Powders::THUNDER,powdertier)) powdervec.push((Powders::THUNDER,powdertier))
} }
if debugMode {
println!("Powder type: Broken, fallback Thunder");
}
} }
}; };
// println!("tier {}",powdertier); if debugMode {
// println!("amount {}",powderamount); println!("Powder tier: {}",powdertier);
println!("Powder amount: {}",powderamount);
}
}
if debugMode {
println!("Powders Vec: {:?}",powdervec);
} }
// println!("{:?}",powdervec);
// old powder data encode kinda, takes data from new encode // old powder data encode kinda, takes data from new encode
PowderData { PowderData {
@ -186,6 +216,9 @@ fn main() {
Some(i) => { Some(i) => {
if i != 0 { if i != 0 {
RerollData(i).encode(ver, &mut out).unwrap(); RerollData(i).encode(ver, &mut out).unwrap();
if debugMode {
println!("Rerolls: {}",i)
}
} }
}, },
None => pass() None => pass()
@ -199,11 +232,16 @@ fn main() {
for i in json_shiny { for i in json_shiny {
if i.key == shiny.key { if i.key == shiny.key {
realshinykey = i.id; realshinykey = i.id;
// println!("shiny key {}",shiny.key); if debugMode {
println!("shiny key {}", shiny.key);
} }
} }
// println!("realshinykey: {}",realshinykey); }
// println!("shinyvalue: {}",shinyvalue); if debugMode {
println!("realshinykey: {}", realshinykey);
println!("shinyvalue: {}", shinyvalue);
}
ShinyData { ShinyData {
id: realshinykey, id: realshinykey,
val: shinyvalue as i64, //- 0b0100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000, val: shinyvalue as i64, //- 0b0100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000,