Compare commits
No commits in common. "main" and "v0.5.0" have entirely different histories.
9 changed files with 348 additions and 527 deletions
97
Cargo.lock
generated
97
Cargo.lock
generated
|
@ -58,12 +58,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle-wincon"
|
name = "anstyle-wincon"
|
||||||
version = "3.0.7"
|
version = "3.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e"
|
checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"once_cell",
|
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -102,9 +101,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.8.0"
|
version = "2.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
checksum = "1be3f42a67d6d345ecd59f675f3f012d6974981560836e938c22b424b85ce1be"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block-buffer"
|
name = "block-buffer"
|
||||||
|
@ -129,9 +128,9 @@ checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.2.10"
|
version = "1.2.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229"
|
checksum = "ad0cf6e91fde44c773c6ee7ec6bba798504641a8bc2eb7e37a04ffbf4dfaa55a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"shlex",
|
"shlex",
|
||||||
]
|
]
|
||||||
|
@ -144,9 +143,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.5.27"
|
version = "4.5.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "769b0145982b4b48713e01ec42d61614425f27b7058bda7180a3a41f30104796"
|
checksum = "9560b07a799281c7e0958b9296854d6fafd4c5f31444a7e5bb1ad6dde5ccf1bd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
|
@ -154,9 +153,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_builder"
|
name = "clap_builder"
|
||||||
version = "4.5.27"
|
version = "4.5.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7"
|
checksum = "874e0dd3eb68bf99058751ac9712f622e61e6f393a94f7128fa26e3f02f5c7cd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
"anstream",
|
||||||
"anstyle",
|
"anstyle",
|
||||||
|
@ -645,7 +644,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "idmangler-cli"
|
name = "idmangler-cli"
|
||||||
version = "0.5.0"
|
version = "0.4.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"idmangler-lib",
|
"idmangler-lib",
|
||||||
|
@ -658,9 +657,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "idmangler-lib"
|
name = "idmangler-lib"
|
||||||
version = "0.5.1"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e30b87d3d3f2cfd668aa8ca1f8cd0769ee362be94fde59988f9112bc3ef3235d"
|
checksum = "b3289c6bd14bc60ec34cebb05292f1bbf369eace2674e6def4dc0f031b34e344"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
@ -717,9 +716,9 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js-sys"
|
name = "js-sys"
|
||||||
version = "0.3.77"
|
version = "0.3.76"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
|
checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
|
@ -745,9 +744,9 @@ checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.25"
|
version = "0.4.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
|
checksum = "3d6ea2a48c204030ee31a7d7fc72c93294c92fe87ecb1789881c9543516e1a0d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
|
@ -763,9 +762,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
version = "0.8.3"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924"
|
checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"adler2",
|
"adler2",
|
||||||
]
|
]
|
||||||
|
@ -928,9 +927,9 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.93"
|
version = "1.0.92"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
|
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
@ -1062,12 +1061,6 @@ dependencies = [
|
||||||
"untrusted",
|
"untrusted",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustversion"
|
|
||||||
version = "1.0.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.18"
|
version = "1.0.18"
|
||||||
|
@ -1128,9 +1121,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.138"
|
version = "1.0.135"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949"
|
checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"memchr",
|
"memchr",
|
||||||
|
@ -1229,9 +1222,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.96"
|
version = "2.0.95"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80"
|
checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -1295,18 +1288,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "2.0.11"
|
version = "2.0.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc"
|
checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "2.0.11"
|
version = "2.0.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2"
|
checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -1505,21 +1498,20 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.100"
|
version = "0.2.99"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
|
checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustversion",
|
|
||||||
"wasm-bindgen-macro",
|
"wasm-bindgen-macro",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-backend"
|
name = "wasm-bindgen-backend"
|
||||||
version = "0.2.100"
|
version = "0.2.99"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
|
checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
"log",
|
"log",
|
||||||
|
@ -1531,9 +1523,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-futures"
|
name = "wasm-bindgen-futures"
|
||||||
version = "0.4.50"
|
version = "0.4.49"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61"
|
checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
|
@ -1544,9 +1536,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro"
|
name = "wasm-bindgen-macro"
|
||||||
version = "0.2.100"
|
version = "0.2.99"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
|
checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"wasm-bindgen-macro-support",
|
"wasm-bindgen-macro-support",
|
||||||
|
@ -1554,9 +1546,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro-support"
|
name = "wasm-bindgen-macro-support"
|
||||||
version = "0.2.100"
|
version = "0.2.99"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
|
checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -1567,18 +1559,15 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-shared"
|
name = "wasm-bindgen-shared"
|
||||||
version = "0.2.100"
|
version = "0.2.99"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
|
checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6"
|
||||||
dependencies = [
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "web-sys"
|
name = "web-sys"
|
||||||
version = "0.3.77"
|
version = "0.3.76"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2"
|
checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
|
|
12
Cargo.toml
12
Cargo.toml
|
@ -1,17 +1,17 @@
|
||||||
[package]
|
[package]
|
||||||
name = "idmangler-cli"
|
name = "idmangler-cli"
|
||||||
authors = ["endernon"]
|
authors = ["endernon"]
|
||||||
version = "0.5.0"
|
version = "0.4.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
description = "A cli tool to generate fake wynntils items"
|
description = "A cli tool to generate fake wynntils items"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.27", features = ["derive"] }
|
clap = { version = "4.5.20", features = ["derive"] }
|
||||||
idmangler-lib = { version = "0.5.1", features = ["serde"] }
|
idmangler-lib = { version = "0.5.0", features = ["serde"] }
|
||||||
reqwest = { version = "0.12.12", 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.138"
|
serde_json = "1.0.135"
|
||||||
serde_json5 = "0.1.0"
|
serde_json5 = "0.1.0"
|
||||||
thiserror = "2.0.11"
|
thiserror = "2.0.9"
|
||||||
|
|
|
@ -5,7 +5,7 @@ mkdir -p product
|
||||||
|
|
||||||
cp ./target/x86_64-pc-windows-gnu/release/idmangler-cli.exe ./product/idmangler-cli.exe
|
cp ./target/x86_64-pc-windows-gnu/release/idmangler-cli.exe ./product/idmangler-cli.exe
|
||||||
cp ./target/x86_64-unknown-linux-gnu/release/idmangler-cli ./product/idmangler-cli
|
cp ./target/x86_64-unknown-linux-gnu/release/idmangler-cli ./product/idmangler-cli
|
||||||
cp -r ./example_configs ./product/
|
cp -u -p ./example_configs ./product/
|
||||||
|
|
||||||
pkgversion=$(cargo metadata --format-version=1 --no-deps | jq '.packages[] | select(.name == "idmangler-cli") | .version')
|
pkgversion=$(cargo metadata --format-version=1 --no-deps | jq '.packages[] | select(.name == "idmangler-cli") | .version')
|
||||||
echo "package version is:"
|
echo "package version is:"
|
||||||
|
@ -16,5 +16,5 @@ echo "$balls2"
|
||||||
|
|
||||||
cd product
|
cd product
|
||||||
|
|
||||||
zip "idmangler-windows-x64-${balls2}.zip" ./example_configs/ idmangler-cli.exe
|
zip "idmangler-windows-x64-${balls2}.zip" example_configs idmangler-cli.exe
|
||||||
zip "idmangler-linux-x64-${balls2}.zip" ./example_configs/ idmangler-cli
|
zip "idmangler-linux-x64-${balls2}.zip" example_configs idmangler-cli
|
||||||
|
|
279
src/encode.rs
279
src/encode.rs
|
@ -1,157 +1,29 @@
|
||||||
use crate::errorfr::Errorfr;
|
use crate::errorfr::Errorfr;
|
||||||
use crate::jsonstruct::{CraftedTypesFr, DamageDeser, DefenceDeser, Durability, 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::types::EncodingVersion;
|
|
||||||
use idmangler_lib::{
|
use idmangler_lib::{
|
||||||
block::{CraftedConsumableTypeData, CraftedGearTypeData, DamageData, DurabilityData, EndData, IdentificationData, NameData, PowderData, RequirementsData, RerollData, ShinyData, StartData, TypeData},
|
block::{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;
|
||||||
use idmangler_lib::block::DefenseData;
|
|
||||||
|
|
||||||
/// FuncParams struct, used for the three most important parameters for encoding.
|
|
||||||
/// Also, all the encode functions are stored here, seeing as I require these three params most of the time when encoding.
|
|
||||||
#[derive(PartialEq, Eq, Hash, Debug)]
|
|
||||||
pub struct FuncParams<'a> {
|
|
||||||
pub fr_out: &'a mut Vec<u8>,
|
|
||||||
pub fr_debug_mode: &'a bool,
|
|
||||||
pub fr_ver: EncodingVersion,
|
|
||||||
}
|
|
||||||
impl FuncParams<'_> {
|
impl FuncParams<'_> {
|
||||||
/// ENCODE: StartData
|
|
||||||
/// (REQUIRED)
|
|
||||||
pub fn encode_startdata(&mut self) -> Result<(), Errorfr> {
|
pub fn encode_startdata(&mut self) -> Result<(), Errorfr> {
|
||||||
if *self.fr_debug_mode {
|
if *self.fr_debug_mode {
|
||||||
println!("Encoding StartData")
|
println!("Encoding StartData")
|
||||||
}
|
}
|
||||||
|
// ENCODE: StartData
|
||||||
StartData(self.fr_ver).encode(self.fr_ver, self.fr_out).unwrap();
|
StartData(self.fr_ver).encode(self.fr_ver, self.fr_out).unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
/// ENCODE: TypeData
|
pub fn encode_typedata(&mut self, item_type_deser: ItemTypeDeser) -> Result<(), Errorfr> {
|
||||||
/// (REQUIRED)
|
|
||||||
pub fn encode_typedata(&mut self, item_type_deser: &ItemTypeDeser) -> Result<(), Errorfr> {
|
|
||||||
if *self.fr_debug_mode {
|
if *self.fr_debug_mode {
|
||||||
println!("Encoding TypeData: {:?}", item_type_deser);
|
println!("Encoding TypeData: {:?}", item_type_deser);
|
||||||
}
|
}
|
||||||
TypeData(ItemType::from(*item_type_deser)).encode(self.fr_ver, self.fr_out).unwrap();
|
// ENCODE: TypeData
|
||||||
|
TypeData(ItemType::from(item_type_deser)).encode(self.fr_ver, self.fr_out).unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
/// ENCODE: NameData
|
|
||||||
pub fn encode_namedata(&mut self, real_name: &str) -> Result<(), Errorfr> {
|
|
||||||
if *self.fr_debug_mode {
|
|
||||||
println!("Encoding NameData: {:?}", &real_name)
|
|
||||||
}
|
|
||||||
NameData(real_name.trim().to_string()).encode(self.fr_ver, self.fr_out).unwrap();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
/// ENCODE: IdentificationData
|
|
||||||
pub fn encode_iddata(&mut self, real_ids: &Vec<Identificationer>, idsmap: &HashMap<String, u8>) -> Result<(), Errorfr> {
|
|
||||||
let mut idvec = Vec::new();
|
|
||||||
for eachid in real_ids {
|
|
||||||
let id_id = idsmap.get(eachid.id.trim());
|
|
||||||
let id_base = eachid.base;
|
|
||||||
let id_roll = eachid.roll;
|
|
||||||
|
|
||||||
idvec.push(Stat {
|
|
||||||
kind: match id_id {
|
|
||||||
Some(ide) => *ide,
|
|
||||||
None => std::panic!("There is a mismatched ID, and this message has replaced where the line is meant to be"),
|
|
||||||
},
|
|
||||||
base: Some(id_base),
|
|
||||||
roll: match id_roll {
|
|
||||||
Some(rolle) => RollType::Value(rolle),
|
|
||||||
None => RollType::PreIdentified,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if *self.fr_debug_mode {
|
|
||||||
println!("Encoding IdentificationData: {:?}", &idvec)
|
|
||||||
}
|
|
||||||
IdentificationData {
|
|
||||||
identifications: idvec,
|
|
||||||
extended_encoding: true,
|
|
||||||
}
|
|
||||||
.encode(self.fr_ver, self.fr_out)
|
|
||||||
.unwrap();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
/// ENCODE: PowderData
|
|
||||||
pub fn encode_powderdata(&mut self, real_powders: &Vec<PowderFr>) -> Result<(), Errorfr> {
|
|
||||||
let mut powdervec = Vec::new();
|
|
||||||
for eachpowder in real_powders {
|
|
||||||
let powderamount: u8 = eachpowder.amount.unwrap_or(1);
|
|
||||||
// match for the powder type
|
|
||||||
for _ in 0..powderamount {
|
|
||||||
let eletype = match eachpowder.r#type.to_ascii_lowercase() {
|
|
||||||
'e' => Element::Earth,
|
|
||||||
't' => Element::Thunder,
|
|
||||||
'w' => Element::Water,
|
|
||||||
'f' => Element::Fire,
|
|
||||||
'a' => Element::Air,
|
|
||||||
_ => return Err(Errorfr::JsonUnknownPowderElement),
|
|
||||||
};
|
|
||||||
if *self.fr_debug_mode {
|
|
||||||
dbg!(eletype);
|
|
||||||
}
|
|
||||||
powdervec.push(Powder::new(eletype, 6).map_err(|_| Errorfr::JsonUnknownPowderTier)?);
|
|
||||||
// 6 is the tier. Wynntils ONLY really uses tier 6 so theres no point keeping others.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if *self.fr_debug_mode {
|
|
||||||
dbg!(&powdervec);
|
|
||||||
}
|
|
||||||
|
|
||||||
let powderlimitfr: u8 = powdervec.len() as u8; // min of the current number of powders and 255 (if you have over 255 powders stuff breaks)
|
|
||||||
|
|
||||||
PowderData {
|
|
||||||
powder_slots: powderlimitfr,
|
|
||||||
powders: powdervec,
|
|
||||||
}
|
|
||||||
.encode(self.fr_ver, self.fr_out)
|
|
||||||
.unwrap();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
/// ENCODE: RerollData
|
|
||||||
pub fn encode_rerolldata(&mut self, rerollcount: &u8) -> Result<(), Errorfr> {
|
|
||||||
if rerollcount != &0 {
|
|
||||||
RerollData(*rerollcount).encode(self.fr_ver, self.fr_out).unwrap();
|
|
||||||
if *self.fr_debug_mode {
|
|
||||||
dbg!(rerollcount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
/// ENCODE: ShinyData
|
|
||||||
pub fn encode_shinydata(&mut self, shiny: &Shinyjson, json_shiny: &Vec<Shinystruct>) -> Result<(), Errorfr> {
|
|
||||||
let mut realshinykey: u8;
|
|
||||||
let _shinykey = &shiny.key;
|
|
||||||
let shinyvalue = shiny.value;
|
|
||||||
realshinykey = 1;
|
|
||||||
for i in json_shiny {
|
|
||||||
if i.key == shiny.key {
|
|
||||||
realshinykey = i.id;
|
|
||||||
if *self.fr_debug_mode {
|
|
||||||
dbg!(&shiny.key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if *self.fr_debug_mode {
|
|
||||||
dbg!(&realshinykey);
|
|
||||||
dbg!(&shinyvalue);
|
|
||||||
}
|
|
||||||
ShinyData { id: realshinykey, val: shinyvalue }.encode(self.fr_ver, self.fr_out).unwrap();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
/// ENCODE: EndData
|
|
||||||
/// (REQUIRED)
|
|
||||||
pub fn encode_enddata(&mut self) -> Result<(), Errorfr> {
|
|
||||||
if *self.fr_debug_mode {
|
|
||||||
println!("Encoding EndData")
|
|
||||||
}
|
|
||||||
EndData.encode(self.fr_ver, self.fr_out).unwrap();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
/// ENCODE: CraftedConsumableTypeData or CraftedGearTypeData based on Type
|
|
||||||
pub fn encode_typedata_custom(&mut self, crafted_type: &str) -> Result<(), Errorfr> {
|
pub fn encode_typedata_custom(&mut self, 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 {
|
||||||
|
@ -170,21 +42,6 @@ impl FuncParams<'_> {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
/// ENCODE: DamageData
|
|
||||||
/// (CRAFTED ONLY)
|
|
||||||
pub fn encode_damagedata(&mut self, real_damage: &DamageDeser) -> Result<(), Errorfr> {
|
|
||||||
let fr: DamageData = DamageData::try_from(real_damage)?;
|
|
||||||
fr.encode(self.fr_ver, self.fr_out).unwrap();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
/// ENCODE: DefenseData
|
|
||||||
/// (CRAFTED ONLY)
|
|
||||||
pub fn encode_defensedata(&mut self, real_defence: &DefenceDeser) -> Result<(), Errorfr> {
|
|
||||||
DefenseData::from(real_defence).encode(self.fr_ver, self.fr_out).unwrap();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
/// ENCODE: DurabilityData
|
|
||||||
/// (CRAFTED ONLY)
|
|
||||||
pub fn encode_duradata(&mut self, real_dura: &Durability) -> Result<(), Errorfr> {
|
pub fn encode_duradata(&mut self, 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 {
|
||||||
|
@ -245,8 +102,7 @@ impl FuncParams<'_> {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
/// ENCODE: RequirementsData
|
pub fn encode_reqdata(&mut self, real_reqdata: RequirementsDeser) -> Result<(), Errorfr> {
|
||||||
pub fn encode_reqdata(&mut self, real_reqdata: &RequirementsDeser) -> Result<(), Errorfr> {
|
|
||||||
if *self.fr_debug_mode {
|
if *self.fr_debug_mode {
|
||||||
println!("Encoding RequirementData.Level: {:?}", real_reqdata.level.clone())
|
println!("Encoding RequirementData.Level: {:?}", real_reqdata.level.clone())
|
||||||
}
|
}
|
||||||
|
@ -276,4 +132,125 @@ impl FuncParams<'_> {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
pub fn encode_namedata(&mut self, real_name: &str) -> Result<(), Errorfr> {
|
||||||
|
// ENCODE: NameData
|
||||||
|
if *self.fr_debug_mode {
|
||||||
|
println!("Encoding NameData: {:?}", &real_name)
|
||||||
|
}
|
||||||
|
NameData(real_name.trim().to_string()).encode(self.fr_ver, self.fr_out).unwrap();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
pub fn encode_iddata(&mut self, real_ids: &Vec<Identificationer>, idsmap: HashMap<String, u8>) -> Result<(), Errorfr> {
|
||||||
|
let mut idvec = Vec::new();
|
||||||
|
for eachid in real_ids {
|
||||||
|
let id_id = idsmap.get(eachid.id.trim());
|
||||||
|
let id_base = eachid.base;
|
||||||
|
let id_roll = eachid.roll;
|
||||||
|
|
||||||
|
idvec.push(Stat {
|
||||||
|
kind: match id_id {
|
||||||
|
Some(ide) => *ide,
|
||||||
|
None => std::panic!("There is a mismatched ID, and this message has replaced where the line is meant to be"),
|
||||||
|
},
|
||||||
|
base: Some(id_base),
|
||||||
|
roll: match id_roll {
|
||||||
|
Some(rolle) => RollType::Value(rolle),
|
||||||
|
None => RollType::PreIdentified,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// println!("{:?} {:?} {:?}",id_id,id_base,id_roll)
|
||||||
|
}
|
||||||
|
if *self.fr_debug_mode {
|
||||||
|
println!("Encoding IdentificationData: {:?}", &idvec)
|
||||||
|
}
|
||||||
|
// ENCODE: IdentificationsData
|
||||||
|
IdentificationData {
|
||||||
|
identifications: idvec,
|
||||||
|
extended_encoding: true,
|
||||||
|
}
|
||||||
|
.encode(self.fr_ver, self.fr_out)
|
||||||
|
.unwrap();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
pub fn encode_powderdata(&mut self, real_powders: &Vec<PowderFr>) -> Result<(), Errorfr> {
|
||||||
|
let mut powdervec = Vec::new();
|
||||||
|
for eachpowder in real_powders {
|
||||||
|
let powderamount: u8 = eachpowder.amount.unwrap_or(1);
|
||||||
|
// match for the powder type
|
||||||
|
for _ in 0..powderamount {
|
||||||
|
let eletype = match eachpowder.r#type.to_ascii_lowercase() {
|
||||||
|
'e' => Element::Earth,
|
||||||
|
't' => Element::Thunder,
|
||||||
|
'w' => Element::Water,
|
||||||
|
'f' => Element::Fire,
|
||||||
|
'a' => Element::Air,
|
||||||
|
_ => return Err(Errorfr::JsonUnknownPowderElement),
|
||||||
|
};
|
||||||
|
if *self.fr_debug_mode {
|
||||||
|
dbg!(eletype);
|
||||||
|
}
|
||||||
|
powdervec.push(Powder::new(eletype, 6).map_err(|_| Errorfr::JsonUnknownPowderTier)?);
|
||||||
|
// 6 is the tier. Wynntils ONLY really uses tier 6 so theres no point keeping others.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if *self.fr_debug_mode {
|
||||||
|
dbg!(&powdervec);
|
||||||
|
}
|
||||||
|
|
||||||
|
let powderlimitfr: u8 = powdervec.len() as u8; // min of the current number of powders and 255 (if you have over 255 powders stuff breaks)
|
||||||
|
|
||||||
|
// ENCODE: PowderData
|
||||||
|
// only occurs if the powders array is present and the powder limit is also present
|
||||||
|
//
|
||||||
|
PowderData {
|
||||||
|
powder_slots: powderlimitfr,
|
||||||
|
powders: powdervec,
|
||||||
|
}
|
||||||
|
.encode(self.fr_ver, self.fr_out)
|
||||||
|
.unwrap();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
pub fn encode_rerolldata(&mut self, rerollcount: u8) -> Result<(), Errorfr> {
|
||||||
|
if rerollcount != 0 {
|
||||||
|
// ENCODE: RerollData if applicable
|
||||||
|
RerollData(rerollcount).encode(self.fr_ver, self.fr_out).unwrap();
|
||||||
|
if *self.fr_debug_mode {
|
||||||
|
dbg!(rerollcount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
pub fn encode_shinydata(&mut self, shiny: &Shinyjson, json_shiny: &Vec<Shinystruct>) -> Result<(), Errorfr> {
|
||||||
|
let mut realshinykey: u8;
|
||||||
|
let _shinykey = &shiny.key;
|
||||||
|
let shinyvalue = shiny.value;
|
||||||
|
realshinykey = 1;
|
||||||
|
for i in json_shiny {
|
||||||
|
if i.key == shiny.key {
|
||||||
|
realshinykey = i.id;
|
||||||
|
if *self.fr_debug_mode {
|
||||||
|
dbg!(&shiny.key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if *self.fr_debug_mode {
|
||||||
|
dbg!(&realshinykey);
|
||||||
|
dbg!(&shinyvalue);
|
||||||
|
}
|
||||||
|
// ENCODE: ShinyData (if applicable)
|
||||||
|
ShinyData { id: realshinykey, val: shinyvalue }.encode(self.fr_ver, self.fr_out).unwrap();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
pub fn encode_enddata(&mut self) -> Result<(), Errorfr> {
|
||||||
|
if *self.fr_debug_mode {
|
||||||
|
println!("Encoding EndData")
|
||||||
|
}
|
||||||
|
// ENCODE: EndData
|
||||||
|
EndData.encode(self.fr_ver, self.fr_out).unwrap();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
pub fn encode_damagedata(&mut self) -> Result<(), Errorfr> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,6 @@ use thiserror::Error;
|
||||||
/// Errors yep
|
/// Errors yep
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum Errorfr {
|
pub enum Errorfr {
|
||||||
/// Blank error (theres probably a better way but I can't be assed)
|
|
||||||
/// Currently unused and shouldn't be used.
|
|
||||||
#[error("No errors, but if youre seeing this text something is wrong.")]
|
|
||||||
NoErrWhatsoever,
|
|
||||||
|
|
||||||
/// item config json is missing
|
/// item config json is missing
|
||||||
#[error("Error 1.1: item config json is missing.")]
|
#[error("Error 1.1: item config json is missing.")]
|
||||||
ItemJsonMissing,
|
ItemJsonMissing,
|
||||||
|
@ -52,6 +47,7 @@ pub enum Errorfr {
|
||||||
#[error("Error 2.8: unable to create file gear_cache.json.")]
|
#[error("Error 2.8: unable to create file gear_cache.json.")]
|
||||||
GearJsonCacheCreateFail,
|
GearJsonCacheCreateFail,
|
||||||
|
|
||||||
|
|
||||||
/// 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.")]
|
||||||
JsonDlReqFail,
|
JsonDlReqFail,
|
||||||
|
@ -88,27 +84,19 @@ pub enum Errorfr {
|
||||||
#[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,
|
||||||
|
|
||||||
/// Damage was not found but is necessary
|
|
||||||
#[error("Error 4.6: \"damage\" was not found (necessary for Crafted Gear item type)")]
|
|
||||||
JsonNotFoundDmg,
|
|
||||||
|
|
||||||
/// Defence was not found but is necessary
|
|
||||||
#[error("Error 4.7: \"defence\" was not found (necessary for Crafted Gear item type)")]
|
|
||||||
JsonNotFoundDef,
|
|
||||||
|
|
||||||
/// Requirements not found but is necessary
|
/// Requirements not found but is necessary
|
||||||
#[error("Error 4.8: \"requirements\" was not found (necessary for Crafted Gear / Consumable items)")]
|
#[error("Error 4.6: \"requirements\" was not found (necessary for Crafted Gear / Consumable items)")]
|
||||||
JsonNotFoundReqs,
|
JsonNotFoundReqs,
|
||||||
|
|
||||||
/// Unrecognisable Powder tier
|
/// Unrecognisable Powder tier
|
||||||
#[error("Error 4.9: Unknown powder tier")]
|
#[error("Error 4.7: Unknown powder tier")]
|
||||||
JsonUnknownPowderTier,
|
JsonUnknownPowderTier,
|
||||||
|
|
||||||
/// Unrecognisable Powder element
|
/// Unrecognisable Powder element
|
||||||
#[error("Error 4.10: Unknown powder element")]
|
#[error("Error 4.8: Unknown powder element")]
|
||||||
JsonUnknownPowderElement,
|
JsonUnknownPowderElement,
|
||||||
|
|
||||||
/// Unrecognisable item for the Perfect gen function
|
/// Unrecognisable item for the Perfect gen function
|
||||||
#[error("Error 4.11: Unknown item for perfect gen...")]
|
#[error("Error 4.9: Unknown item for perfect gen...")]
|
||||||
PerfectItemNotFound,
|
PerfectItemNotFound,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +1,43 @@
|
||||||
use crate::errorfr::Errorfr;
|
|
||||||
use crate::jsonstruct::Identificationer;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use crate::encode::FuncParams;
|
use crate::errorfr::Errorfr;
|
||||||
|
use crate::jsonstruct::Identificationer;
|
||||||
|
|
||||||
// the struct for the stuff I need in 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, Serialize, PartialEq, Eq, Debug, Clone)]
|
#[derive(Deserialize, Serialize, PartialEq, Eq, Debug, Clone)]
|
||||||
pub struct GearJsonItem {
|
pub struct GearJsonItem {
|
||||||
identifications: Option<HashMap<String, GearJsonItemInner>>,
|
identifications: Option<
|
||||||
|
HashMap<
|
||||||
|
String, GearJsonItemInner
|
||||||
|
>
|
||||||
|
>
|
||||||
}
|
}
|
||||||
#[derive(Deserialize, Serialize, PartialEq, Eq, Debug, Clone)]
|
#[derive(Deserialize, Serialize, PartialEq, Eq, Debug, Clone)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum GearJsonItemInner {
|
pub enum GearJsonItemInner {
|
||||||
r#Struct(GearJsonItemInnerStruct),
|
r#Struct(GearJsonItemInnerStruct),
|
||||||
r#Int(i32),
|
r#Int(i32)
|
||||||
}
|
}
|
||||||
#[derive(Deserialize, Serialize, PartialEq, Eq, Debug, Clone)]
|
#[derive(Deserialize, Serialize, PartialEq, Eq, Debug, Clone)]
|
||||||
pub struct GearJsonItemInnerStruct {
|
pub struct GearJsonItemInnerStruct {
|
||||||
max: i32,
|
max: i32,
|
||||||
min: i32,
|
min: i32,
|
||||||
raw: i32,
|
raw: i32
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Function to generate a perfect item.
|
pub fn gen_perfect(name: &str, frjson: &HashMap<String, GearJsonItem>) -> Result<Vec<Identificationer>, Errorfr> {
|
||||||
/// It returns Result\<Vec\<Identificationer\>, Errorfr\>
|
|
||||||
pub fn gen_perfect(fr_params: &FuncParams, name: &str, frjson: &HashMap<String, GearJsonItem>) -> Result<Vec<Identificationer>, Errorfr> {
|
|
||||||
let mut a: Vec<Identificationer> = Vec::new();
|
let mut a: Vec<Identificationer> = Vec::new();
|
||||||
let name = name.to_lowercase();
|
let name = name.to_lowercase();
|
||||||
match frjson.get(&name) {
|
match frjson.get(&name) {
|
||||||
Some(fr_idents) => {
|
Some(fr_idents) => {
|
||||||
if let Some(fr_identmap) = &fr_idents.identifications {
|
if let Some(fr_identmap) = &fr_idents.identifications {
|
||||||
for i in fr_identmap {
|
for i in fr_identmap {
|
||||||
if *fr_params.fr_debug_mode {
|
|
||||||
println!("{i:?}");
|
println!("{i:?}");
|
||||||
}
|
|
||||||
if let &GearJsonItemInner::Struct(e) = &i.1 {
|
if let &GearJsonItemInner::Struct(e) = &i.1 {
|
||||||
|
|
||||||
// hardcoded list of inverts. Don't question why it's like this, blame whatever the fuck wynncraft was smoking.
|
// hardcoded list of inverts. Don't question why it's like this, blame whatever the fuck wynncraft was smoking.
|
||||||
// I'm going to have to update this list manually too... why the fuck, wynncraft?
|
// I'm going to have to update this list manually too... why the fuck, wynncraft?
|
||||||
let invert_bool: bool = matches!(
|
let invert_bool: bool = matches!(i.0.to_lowercase().as_str(),
|
||||||
i.0.to_lowercase().as_str(),
|
|
||||||
"4thspellcost" |
|
"4thspellcost" |
|
||||||
"3rdspellcost" |
|
"3rdspellcost" |
|
||||||
"2ndspellcost" |
|
"2ndspellcost" |
|
||||||
|
@ -46,51 +45,30 @@ pub fn gen_perfect(fr_params: &FuncParams, name: &str, frjson: &HashMap<String,
|
||||||
"raw4thspellcost" |
|
"raw4thspellcost" |
|
||||||
"raw3rdspellcost" |
|
"raw3rdspellcost" |
|
||||||
"raw2ndspellcost" |
|
"raw2ndspellcost" |
|
||||||
"raw1stspellcost"
|
"raw1stSpellCost");
|
||||||
);
|
|
||||||
|
|
||||||
let ider: Identificationer = Identificationer {
|
let ider: Identificationer = Identificationer {
|
||||||
id: i.0.clone(),
|
id: i.0.clone(),
|
||||||
base: {
|
base: {
|
||||||
if invert_bool {
|
if invert_bool {-e.clone().raw} // invert value if invert mode true
|
||||||
-e.clone().raw
|
else {e.clone().raw} // else regular value
|
||||||
}
|
|
||||||
// invert value if invert mode true
|
|
||||||
else {
|
|
||||||
e.clone().raw
|
|
||||||
} // else regular value
|
|
||||||
},
|
},
|
||||||
roll: Some(match &e.clone().raw {
|
roll: Some(match &e.clone().raw {
|
||||||
fr if fr < &0 => {
|
fr if fr<&0 => 70,
|
||||||
if invert_bool {
|
|
||||||
130
|
|
||||||
}
|
|
||||||
// value 70 if invert mode true
|
|
||||||
else {
|
|
||||||
70
|
|
||||||
} // else value 130
|
|
||||||
},
|
|
||||||
fr if fr>&0 => {
|
fr if fr>&0 => {
|
||||||
if invert_bool {
|
if invert_bool {70} // value 70 if invert mode true
|
||||||
70
|
else {130}// else value 130
|
||||||
}
|
},
|
||||||
// value 70 if invert mode true
|
_ => 0
|
||||||
else {
|
})
|
||||||
130
|
|
||||||
} // else value 130
|
|
||||||
}
|
|
||||||
_ => 0,
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
if *fr_params.fr_debug_mode {
|
|
||||||
println!("ider: {ider:?}");
|
println!("ider: {ider:?}");
|
||||||
}
|
|
||||||
a.push(ider)
|
a.push(ider)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
None => return Err(Errorfr::PerfectItemNotFound),
|
None => return Err(Errorfr::PerfectItemNotFound)
|
||||||
}
|
}
|
||||||
Ok(a)
|
Ok(a)
|
||||||
}
|
}
|
|
@ -1,23 +1,35 @@
|
||||||
use crate::{dl_json, errorfr::Errorfr, gearjson, jsonstruct::Shinystruct};
|
use crate::{dl_json,
|
||||||
|
errorfr::Errorfr,
|
||||||
|
gearjson,
|
||||||
|
jsonstruct::Shinystruct
|
||||||
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fs,
|
fs,
|
||||||
io::{BufReader, Write},
|
io::{BufReader, Write}
|
||||||
};
|
};
|
||||||
|
|
||||||
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_json::from_reader(&mut BufReader::new(&mut fs::File::open(executable_path.to_owned() + "/data/id_keys.json").map_err(|_| Errorfr::IDMapJsonMissing)?)).map_err(Errorfr::IDMapJsonCorrupt)
|
serde_json::from_reader(&mut BufReader::new(
|
||||||
|
&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_json::from_reader(&mut BufReader::new(fs::File::open(executable_path.to_owned() + "/data/shiny_stats.json").map_err(|_| Errorfr::ShinyJsonMissing)?)).map_err(|_| Errorfr::ShinyJsonCorrupt)
|
serde_json::from_reader(&mut BufReader::new(
|
||||||
|
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 parse (ONLY FOR DL gear.json)
|
// gear.json parse (ONLY FOR DL gear.json)
|
||||||
let a: HashMap<String, gearjson::GearJsonItem> =
|
let a: HashMap<String, gearjson::GearJsonItem> = serde_json::from_reader(&mut BufReader::new(
|
||||||
serde_json::from_reader(&mut BufReader::new(fs::File::open(executable_path.to_owned() + "/data/gear.json").map_err(|_| Errorfr::GearJsonMissing)?)).map_err(Errorfr::GearJsonCacheCorrupt)?;
|
fs::File::open(executable_path.to_owned() + "/data/gear.json")
|
||||||
|
.map_err(|_| Errorfr::GearJsonMissing)?))
|
||||||
|
.map_err(Errorfr::GearJsonCacheCorrupt)?;
|
||||||
// parse the original, "a", into lowercase as "b"
|
// parse the original, "a", into lowercase as "b"
|
||||||
let mut b: HashMap<String, gearjson::GearJsonItem> = HashMap::new();
|
let mut b: HashMap<String, gearjson::GearJsonItem> = HashMap::new();
|
||||||
for i in &a {
|
for i in &a {
|
||||||
|
@ -30,8 +42,8 @@ pub fn load_gear(executable_path: &str) -> Result<HashMap<String, gearjson::Gear
|
||||||
pub fn load_gear_cache(executable_path: &str) -> Result<HashMap<String, gearjson::GearJsonItem>, Errorfr> {
|
pub fn load_gear_cache(executable_path: &str) -> Result<HashMap<String, gearjson::GearJsonItem>, Errorfr> {
|
||||||
// gear_cache.json (ONLY FOR PERFECT ITEM FUNCTION GEN)
|
// gear_cache.json (ONLY FOR PERFECT ITEM FUNCTION GEN)
|
||||||
serde_json::from_reader(&mut BufReader::new(
|
serde_json::from_reader(&mut BufReader::new(
|
||||||
fs::File::open(executable_path.to_owned() + "/data/gear_cache.json").map_err(|_| Errorfr::GearJsonCacheMissing)?,
|
fs::File::open(executable_path.to_owned() + "/data/gear_cache.json")
|
||||||
))
|
.map_err(|_| Errorfr::GearJsonCacheMissing)?))
|
||||||
.map_err(Errorfr::GearJsonCorrupt)
|
.map_err(Errorfr::GearJsonCorrupt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,9 +79,12 @@ pub fn dl_json_fr(dlvalue: &String, executable_path: &str) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// error handling below
|
// error handling below
|
||||||
println!("{} Filename: {}", e, dlvalue);
|
println!("{} Filename: {}", e, dlvalue);
|
||||||
}
|
},
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
let frfrnocap = serde_json::to_vec(&load_gear(executable_path).unwrap()).unwrap();
|
let frfrnocap = serde_json::to_vec(
|
||||||
|
&load_gear(executable_path)
|
||||||
|
.unwrap()
|
||||||
|
).unwrap();
|
||||||
let mut outer = fs::File::create(format!("{}{}",executable_path, "/data/gear_cache.json")).map_err(|_| Errorfr::GearJsonCacheCreateFail).unwrap();
|
let mut outer = fs::File::create(format!("{}{}",executable_path, "/data/gear_cache.json")).map_err(|_| Errorfr::GearJsonCacheCreateFail).unwrap();
|
||||||
outer.write_all(&frfrnocap).unwrap();
|
outer.write_all(&frfrnocap).unwrap();
|
||||||
println!("Making gearcache to {}/data/gear_cache.json", executable_path);
|
println!("Making gearcache to {}/data/gear_cache.json", executable_path);
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
use crate::errorfr::Errorfr;
|
use crate::errorfr::Errorfr;
|
||||||
use crate::jsonstruct::CraftedTypesFr::{Consu, Gear};
|
use crate::jsonstruct::CraftedTypesFr::{Consu, Gear};
|
||||||
use idmangler_lib::block::{DamageData, DefenseData};
|
use idmangler_lib::types::{AttackSpeed, ClassType, ConsumableType, ConsumableType::*, CraftedGearType, CraftedGearType::*, EncodingVersion, ItemType, SkillType};
|
||||||
use idmangler_lib::types::{AttackSpeed, ClassType, ConsumableType, ConsumableType::*, CraftedGearType, CraftedGearType::*, Element, ItemType, SkillType};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::ops::Range;
|
|
||||||
|
|
||||||
// structs for the json parsing
|
// structs for the json parsing
|
||||||
#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone)]
|
#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone)]
|
||||||
|
@ -14,13 +12,11 @@ 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(alias = "ITEMTYPE", alias = "ItemType", alias = "Itemtype", alias = "itemtype")]
|
#[serde(alias = "itemtype", alias = "ITEM_TYPE", alias = "ITEMTYPE", alias = "Item_Type", alias = "Item_type", alias = "ItemType", alias = "Itemtype")]
|
||||||
#[serde(alias = "ITEM_TYPE", alias = "Item_Type", alias = "Item_type")]
|
|
||||||
pub item_type: ItemTypeDeser,
|
pub item_type: ItemTypeDeser,
|
||||||
|
|
||||||
// Crafted type for Crafted item types
|
// Crafted type for Crafted item types
|
||||||
#[serde(alias = "CRAFTEDTYPE", alias = "CraftedType", alias = "Craftedtype", alias = "craftedtype")]
|
#[serde(alias = "craftedtype", alias = "CRAFTED_TYPE", alias = "CRAFTEDTYPE", alias = "Crafted_Type", alias = "Crafted_type", alias = "CraftedType", alias = "Craftedtype")]
|
||||||
#[serde(alias = "CRAFTED_TYPE", alias = "Crafted_Type", alias = "Crafted_type")]
|
|
||||||
pub crafted_type: Option<String>,
|
pub crafted_type: Option<String>,
|
||||||
|
|
||||||
// name of item
|
// name of item
|
||||||
|
@ -32,49 +28,46 @@ pub struct Jsonconfig {
|
||||||
pub shiny: Option<Shinyjson>,
|
pub shiny: Option<Shinyjson>,
|
||||||
|
|
||||||
// identifications
|
// identifications
|
||||||
#[serde(alias = "identifications", alias = "Identifications", alias = "IDENTIFICATIONS")]
|
#[serde(alias = "Ids", alias = "IDS", alias = "identifications", alias = "Identifications", alias = "IDENTIFICATIONS")]
|
||||||
#[serde(alias = "Ids", alias = "IDS")]
|
|
||||||
pub ids: Option<Vec<Identificationer>>,
|
pub ids: Option<Vec<Identificationer>>,
|
||||||
|
|
||||||
// powders stuff
|
// powders stuff
|
||||||
#[serde(alias = "powder", alias = "Powder", alias = "POWDER")]
|
#[serde(alias = "Powders", alias = "POWDERS", alias = "powder", alias = "Powder", alias = "POWDER")]
|
||||||
#[serde(alias = "Powders", alias = "POWDERS")]
|
|
||||||
pub powders: Option<Vec<PowderFr>>,
|
pub powders: Option<Vec<PowderFr>>,
|
||||||
|
|
||||||
// rerolls
|
// rerolls
|
||||||
#[serde(alias = "reroll", alias = "Reroll", alias = "REROLL")]
|
#[serde(alias = "Rerolls", alias = "REROLLS", alias = "reroll", alias = "Reroll", alias = "REROLL")]
|
||||||
#[serde(alias = "Rerolls", alias = "REROLLS")]
|
|
||||||
pub rerolls: Option<u8>,
|
pub rerolls: Option<u8>,
|
||||||
|
|
||||||
// durability data (Crafted Gear)
|
// durability data (Crafted Gear)
|
||||||
#[serde(alias = "durability", alias = "Durability", alias = "DURABILITY")]
|
#[serde(alias = "durability", alias = "Durability", alias = "DURABILITY", alias = "dura", alias = "Dura", alias = "DURA")]
|
||||||
#[serde(alias = "dura", alias = "Dura", alias = "DURA")]
|
|
||||||
pub crafted_durability: Option<Durability>,
|
pub crafted_durability: Option<Durability>,
|
||||||
|
|
||||||
// requirements data (Crafted)
|
// requirements data (Crafted)
|
||||||
#[serde(alias = "requirement", alias = "Requirement", alias = "REQUIREMENT")]
|
#[serde(alias = "requirement", alias = "Requirement", alias = "REQUIREMENT", alias = "requirements", alias = "Requirements", alias = "REQUIREMENTS")]
|
||||||
#[serde(alias = "requirements", alias = "Requirements", alias = "REQUIREMENTS")]
|
|
||||||
pub crafted_requirements: Option<RequirementsDeser>,
|
pub crafted_requirements: Option<RequirementsDeser>,
|
||||||
|
|
||||||
// identifications (Crafted)
|
// identifications (Crafted)
|
||||||
// to be honest i wish there was a better way instead of too many aliases
|
// to be honest i wish there was a better way instead of too many aliases
|
||||||
#[serde(alias = "CRAFTEDIDS", alias = "CraftedIds", alias = "Craftedids", alias = "craftedids")]
|
#[serde(
|
||||||
#[serde(alias = "CRAFTED_IDS", alias = "Crafted_Ids", alias = "Crafted_ids")]
|
alias = "craftedids",
|
||||||
#[serde(alias = "CRAFTED_IDENTIFICATIONS", alias = "Crafted_Identifications", alias = "Crafted_identifications", alias = "crafted_identifications")]
|
alias = "CRAFTED_IDS",
|
||||||
#[serde(alias = "CRAFTEDIDENTIFICATIONS", alias = "CraftedIdentifications", alias = "Craftedidentifications", alias = "craftedidentifications")]
|
alias = "CRAFTEDIDS",
|
||||||
#[serde(alias = "CIDS", alias = "CIds", alias = "cids")]
|
alias = "Crafted_Ids",
|
||||||
#[serde(alias = "CIDS", alias = "Cids")]
|
alias = "Crafted_ids",
|
||||||
|
alias = "CraftedIds",
|
||||||
|
alias = "Craftedids",
|
||||||
|
alias = "craftedidentifications",
|
||||||
|
alias = "CRAFTED_IDENTIFICATIONS",
|
||||||
|
alias = "CRAFTEDIDENTIFICATIONS",
|
||||||
|
alias = "Crafted_Identifications",
|
||||||
|
alias = "Crafted_identifications",
|
||||||
|
alias = "CraftedIdentifications",
|
||||||
|
alias = "Craftedidentifications"
|
||||||
|
)]
|
||||||
pub crafted_ids: Option<Vec<IdentificationerCrafted>>,
|
pub crafted_ids: Option<Vec<IdentificationerCrafted>>,
|
||||||
|
|
||||||
#[serde(alias = "CRAFTEDDMG", alias = "CraftedDmg", alias = "Crafteddmg", alias = "crafteddmg")]
|
|
||||||
#[serde(alias = "CRAFTED_DMG", alias = "Crafted_Dmg", alias = "Crafted_dmg")]
|
|
||||||
#[serde(alias = "CRAFTED_DAMAGE", alias = "Crafted_Damage", alias = "Crafted_damage", alias = "crafted_damage")]
|
|
||||||
#[serde(alias = "CRAFTEDDAMAGE", alias = "CraftedDamage", alias = "Crafteddamage", alias = "crafteddamage")]
|
|
||||||
#[serde(alias = "DMG", alias = "Dmg", alias = "dmg")]
|
|
||||||
#[serde(alias = "DAMAGE", alias = "Damage", alias = "damage")]
|
|
||||||
pub crafted_damage: Option<DamageDeser>,
|
pub crafted_damage: Option<DamageDeser>,
|
||||||
|
|
||||||
pub crafted_defence: Option<DefenceDeser>
|
|
||||||
}
|
}
|
||||||
// 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.
|
||||||
|
@ -106,15 +99,15 @@ impl From<ClassDeser> for ClassType {
|
||||||
}
|
}
|
||||||
#[derive(Deserialize, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone)]
|
#[derive(Deserialize, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone)]
|
||||||
pub struct SkillPointDeser {
|
pub struct SkillPointDeser {
|
||||||
#[serde(alias = "Str", alias = "str", alias = "Strength")]
|
#[serde(alias = "Str", alias = "str", alias = "strength")]
|
||||||
pub strength: Option<i32>,
|
pub strength: Option<i32>,
|
||||||
#[serde(alias = "Dex", alias = "dex", alias = "Dexterity")]
|
#[serde(alias = "Dex", alias = "dex", alias = "dexterity")]
|
||||||
pub dexterity: Option<i32>,
|
pub dexterity: Option<i32>,
|
||||||
#[serde(alias = "Def", alias = "def", alias = "Defense")]
|
#[serde(alias = "Def", alias = "def", alias = "defense")]
|
||||||
pub defense: Option<i32>,
|
pub defense: Option<i32>,
|
||||||
#[serde(alias = "Int", alias = "int", alias = "Intelligence")]
|
#[serde(alias = "Int", alias = "int", alias = "intelligence")]
|
||||||
pub intelligence: Option<i32>,
|
pub intelligence: Option<i32>,
|
||||||
#[serde(alias = "Agi", alias = "agi", alias = "Agility")]
|
#[serde(alias = "Agi", alias = "agi", alias = "agility")]
|
||||||
pub agility: Option<i32>,
|
pub agility: Option<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,104 +203,17 @@ pub struct Shinyjson {
|
||||||
pub value: i64,
|
pub value: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
// this one isn't even because it can't deser, it's because I want to restructure and add alias for the fields
|
// struct for general parameters for most encode functions
|
||||||
#[derive(Deserialize, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct DamageDeserElement {
|
pub struct FuncParams<'a> {
|
||||||
#[serde(alias = "min", alias = "Min", alias = "MIN")]
|
pub fr_out: &'a mut Vec<u8>,
|
||||||
#[serde(alias = "Lower", alias = "LOWER")]
|
pub fr_debug_mode: &'a bool,
|
||||||
lower: i32,
|
pub fr_ver: EncodingVersion,
|
||||||
#[serde(alias = "max", alias = "Max", alias = "MAX")]
|
|
||||||
#[serde(alias = "Upper", alias = "UPPER")]
|
|
||||||
upper: i32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone)]
|
#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone)]
|
||||||
pub struct DamageDeser {
|
pub struct DamageDeser {
|
||||||
#[serde(alias = "AttackSpeed", alias = "ATTACKSPEED", alias = "attackspeed")]
|
|
||||||
#[serde(alias = "Attack_Speed", alias = "ATTACK_SPEED")]
|
|
||||||
#[serde(alias = "atkspd", alias = "AtkSpd", alias = "ATKSPD")]
|
|
||||||
#[serde(alias = "atk_spd", alias = "Atk_Spd", alias = "ATKSPD")]
|
|
||||||
pub attack_speed: AttackSpeed,
|
pub attack_speed: AttackSpeed,
|
||||||
#[serde(alias = "N", alias = "Neutral", alias = "NEUTRAL")]
|
|
||||||
#[serde(alias = "normal", alias = "Normal", alias = "NORMAL")]
|
|
||||||
pub neutral: Option<DamageDeserElement>,
|
|
||||||
#[serde(alias = "E", alias = "Earth", alias = "EARTH")]
|
|
||||||
pub earth: Option<DamageDeserElement>,
|
|
||||||
#[serde(alias = "T", alias = "Thunder", alias = "THUNDER")]
|
|
||||||
pub thunder: Option<DamageDeserElement>,
|
|
||||||
#[serde(alias = "W", alias = "Water", alias = "WATER")]
|
|
||||||
pub water: Option<DamageDeserElement>,
|
|
||||||
#[serde(alias = "F", alias = "Fire", alias = "FIRE")]
|
|
||||||
pub fire: Option<DamageDeserElement>,
|
|
||||||
#[serde(alias = "A", alias = "Air", alias = "AIR")]
|
|
||||||
pub air: Option<DamageDeserElement>,
|
|
||||||
}
|
|
||||||
impl TryFrom<&DamageDeser> for DamageData {
|
|
||||||
type Error = Errorfr;
|
|
||||||
fn try_from(value: &DamageDeser) -> Result<Self, Self::Error> {
|
|
||||||
let mut damagesfr: Vec<(Option<Element>, Range<i32>)> = Vec::new();
|
|
||||||
if let Some(T) = value.neutral {
|
|
||||||
damagesfr.push((None, Range { start: T.lower, end: T.upper + 1 }))
|
|
||||||
};
|
|
||||||
if let Some(T) = value.earth {
|
|
||||||
damagesfr.push((Some(Element::Earth), Range { start: T.lower, end: T.upper + 1 }))
|
|
||||||
};
|
|
||||||
if let Some(T) = value.thunder {
|
|
||||||
damagesfr.push((Some(Element::Thunder), Range { start: T.lower, end: T.upper + 1 }))
|
|
||||||
};
|
|
||||||
if let Some(T) = value.water {
|
|
||||||
damagesfr.push((Some(Element::Water), Range { start: T.lower, end: T.upper + 1 }))
|
|
||||||
};
|
|
||||||
if let Some(T) = value.fire {
|
|
||||||
damagesfr.push((Some(Element::Fire), Range { start: T.lower, end: T.upper + 1 }))
|
|
||||||
};
|
|
||||||
if let Some(T) = value.air {
|
|
||||||
damagesfr.push((Some(Element::Air), Range { start: T.lower, end: T.upper + 1 }))
|
|
||||||
};
|
|
||||||
Ok(Self {
|
|
||||||
attack_speed: value.attack_speed,
|
|
||||||
damages: damagesfr,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone)]
|
|
||||||
pub struct DefenceDeser {
|
|
||||||
#[serde(alias = "HP", alias = "Hp", alias = "hP", alias = "hp")]
|
|
||||||
#[serde(alias = "Health", alias = "HEALTH")]
|
|
||||||
pub health: i32,
|
|
||||||
#[serde(alias = "E", alias = "Earth", alias = "EARTH")]
|
|
||||||
pub earth: Option<i32>,
|
|
||||||
#[serde(alias = "T", alias = "Thunder", alias = "THUNDER")]
|
|
||||||
pub thunder: Option<i32>,
|
|
||||||
#[serde(alias = "W", alias = "Water", alias = "WATER")]
|
|
||||||
pub water: Option<i32>,
|
|
||||||
#[serde(alias = "F", alias = "Fire", alias = "FIRE")]
|
|
||||||
pub fire: Option<i32>,
|
|
||||||
#[serde(alias = "A", alias = "Air", alias = "AIR")]
|
|
||||||
pub air: Option<i32>,
|
|
||||||
}
|
|
||||||
impl From<&DefenceDeser> for DefenseData {
|
|
||||||
fn from(value: &DefenceDeser) -> Self {
|
|
||||||
let mut defencesfr: Vec<(Element, i32)> = Vec::new();
|
|
||||||
if let Some(T) = value.air {
|
|
||||||
defencesfr.push((Element::Air, T));
|
|
||||||
}
|
|
||||||
if let Some(T) = value.earth {
|
|
||||||
defencesfr.push((Element::Earth, T));
|
|
||||||
}
|
|
||||||
if let Some(T) = value.thunder {
|
|
||||||
defencesfr.push((Element::Thunder, T));
|
|
||||||
}
|
|
||||||
if let Some(T) = value.water {
|
|
||||||
defencesfr.push((Element::Water, T));
|
|
||||||
}
|
|
||||||
if let Some(T) = value.fire {
|
|
||||||
defencesfr.push((Element::Fire, T));
|
|
||||||
}
|
|
||||||
DefenseData {
|
|
||||||
health: value.health,
|
|
||||||
defences: defencesfr
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// I had to clone this and add Deserialize because the original idmangler_lib::types::ItemType does not
|
// I had to clone this and add Deserialize because the original idmangler_lib::types::ItemType does not
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
@ -337,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)
|
||||||
}
|
}
|
||||||
|
|
106
src/main.rs
106
src/main.rs
|
@ -6,15 +6,14 @@ mod errorfr;
|
||||||
mod gearjson;
|
mod gearjson;
|
||||||
mod jsondl;
|
mod jsondl;
|
||||||
mod jsonstruct;
|
mod jsonstruct;
|
||||||
use crate::encode::FuncParams;
|
|
||||||
use crate::errorfr::Errorfr;
|
use crate::errorfr::Errorfr;
|
||||||
use crate::gearjson::gen_perfect;
|
|
||||||
use crate::jsondl::*;
|
use crate::jsondl::*;
|
||||||
use crate::jsonstruct::*;
|
use crate::jsonstruct::*;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use idmangler_lib::{encoding::string::encode_string, types::EncodingVersion};
|
use idmangler_lib::{encoding::string::encode_string, types::EncodingVersion};
|
||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
use std::{collections::HashMap, env, fs, io::Write, path::PathBuf};
|
use std::{collections::HashMap, env, fs, io::Write, path::PathBuf};
|
||||||
|
use crate::gearjson::gen_perfect;
|
||||||
|
|
||||||
#[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))]
|
||||||
|
@ -36,6 +35,7 @@ struct Args {
|
||||||
perfect: Option<String>,
|
perfect: Option<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)?;
|
||||||
let body = resp.text().map_err(|_| Errorfr::JsonDlReqBodyInvalid)?;
|
let body = resp.text().map_err(|_| Errorfr::JsonDlReqBodyInvalid)?;
|
||||||
|
@ -53,8 +53,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main_2() -> Result<(), Errorfr> {
|
fn main_2() -> Result<(), Errorfr> {
|
||||||
let args: &Args = &Args::parse();
|
let args = Args::parse();
|
||||||
let do_not_cook = do_not_cook(args);
|
|
||||||
let mut executable_path = env::current_exe().unwrap();
|
let mut executable_path = env::current_exe().unwrap();
|
||||||
PathBuf::pop(&mut executable_path);
|
PathBuf::pop(&mut executable_path);
|
||||||
let executable_path = executable_path.to_str().unwrap();
|
let executable_path = executable_path.to_str().unwrap();
|
||||||
|
@ -75,14 +74,16 @@ fn main_2() -> Result<(), Errorfr> {
|
||||||
let loaded_config: Jsonconfig = {
|
let loaded_config: Jsonconfig = {
|
||||||
if let Some(t) = &args.config {
|
if let Some(t) = &args.config {
|
||||||
match load_jsonconfig(t) {
|
match load_jsonconfig(t) {
|
||||||
Ok(fr) => Ok(fr),
|
Ok(fr) => {
|
||||||
|
Ok(fr)
|
||||||
|
}
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if !do_not_cook {
|
|
||||||
println!("no config path provided, fallback to empty.");
|
|
||||||
}
|
}
|
||||||
Ok(Jsonconfig {
|
else {
|
||||||
|
println!("no config path provided, fallback to empty.");
|
||||||
|
Ok(
|
||||||
|
Jsonconfig {
|
||||||
debug: Some(false),
|
debug: Some(false),
|
||||||
item_type: ItemTypeDeser::Gear,
|
item_type: ItemTypeDeser::Gear,
|
||||||
crafted_type: None,
|
crafted_type: None,
|
||||||
|
@ -95,16 +96,16 @@ fn main_2() -> Result<(), Errorfr> {
|
||||||
crafted_requirements: None,
|
crafted_requirements: None,
|
||||||
crafted_ids: None,
|
crafted_ids: None,
|
||||||
crafted_damage: None,
|
crafted_damage: None,
|
||||||
crafted_defence: None,
|
}
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
}?;
|
}?;
|
||||||
let loaded_idkeys = load_idkeys(executable_path)?;
|
let loaded_idkeys = load_idkeys(executable_path)?;
|
||||||
let loaded_shinystats = load_shinystats(executable_path)?;
|
let loaded_shinystats = load_shinystats(executable_path)?;
|
||||||
|
|
||||||
// check if perfect status and change name if so. otherwise blank yep
|
// check if perfect status and change name if so. otherwise blank yep
|
||||||
let mut namefr: &str = "";
|
let mut namefr: String = "".to_string();
|
||||||
if let Some(t1) = &args.perfect {
|
if let Some(t1) = args.perfect {
|
||||||
namefr = t1
|
namefr = t1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,9 +115,6 @@ fn main_2() -> Result<(), Errorfr> {
|
||||||
debug_mode = true
|
debug_mode = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !do_not_cook {
|
|
||||||
|
|
||||||
// main program everything starts here fr
|
// main program everything starts here fr
|
||||||
let mut out: Vec<u8> = Vec::new();
|
let mut out: Vec<u8> = Vec::new();
|
||||||
|
|
||||||
|
@ -125,44 +123,30 @@ fn main_2() -> Result<(), Errorfr> {
|
||||||
|
|
||||||
let mut loaded_config_clone = loaded_config.clone();
|
let mut loaded_config_clone = loaded_config.clone();
|
||||||
|
|
||||||
let mut funcparamsfr: FuncParams = FuncParams {
|
|
||||||
fr_out: &mut out,
|
|
||||||
fr_debug_mode: &debug_mode,
|
|
||||||
fr_ver: ver,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// ENCODE: A Lot Of Stuff
|
// ENCODE: A Lot Of Stuff
|
||||||
// Also print any mapped errors
|
// Also print any mapped errors
|
||||||
let cooking = cook(&mut funcparamsfr, &mut loaded_config_clone, loaded_idkeys, loaded_shinystats, namefr, executable_path);
|
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 {
|
||||||
// final string print if there is no error
|
// final string print if there is no error
|
||||||
println!("{}", cooking?)
|
println!("{}", cooking?)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
// Checks for if you should actually do any encoding with the function.
|
|
||||||
// There's a few cases to account for:
|
|
||||||
// - If config flag is passed, then do it
|
|
||||||
// - If perfect flag is passed, then do it
|
|
||||||
// - If only download flag is passed, then don't do it
|
|
||||||
// - If none of these flags are passed then don't do it
|
|
||||||
// - Fallback: try and do it
|
|
||||||
fn do_not_cook(args: &Args) -> bool {
|
|
||||||
if args.config.is_some() {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
else { args.perfect.is_none() }
|
|
||||||
|
|
||||||
}
|
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 {
|
||||||
|
fr_out: out,
|
||||||
|
fr_debug_mode: debug_mode,
|
||||||
|
fr_ver: ver,
|
||||||
|
};
|
||||||
|
|
||||||
fn cook(fr_params: &mut FuncParams, json_config: &mut Jsonconfig, idsmap: HashMap<String, u8>, json_shiny: Vec<Shinystruct>, namefr: &str, executable_path: &str) -> Result<String, Errorfr> {
|
|
||||||
// ENCODE: StartData and TypeData, ALWAYS
|
// ENCODE: StartData and TypeData, ALWAYS
|
||||||
fr_params.encode_startdata()?;
|
fr_params.encode_startdata()?;
|
||||||
fr_params.encode_typedata(&json_config.item_type)?;
|
fr_params.encode_typedata(json_config.item_type)?;
|
||||||
|
|
||||||
// ENCODE: CustomGearTypeData / CustomConsumableTypeData
|
// ENCODE: CustomGearTypeData / CustomConsumableTypeData
|
||||||
match json_config.item_type {
|
match json_config.item_type {
|
||||||
|
@ -179,9 +163,10 @@ fn cook(fr_params: &mut FuncParams, json_config: &mut Jsonconfig, idsmap: HashMa
|
||||||
// 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 !namefr.is_empty() {
|
if namefr != *"" {
|
||||||
fr_params.encode_namedata(namefr)?
|
fr_params.encode_namedata(&namefr)?
|
||||||
} else if let Some(real_name) = &json_config.name {
|
}
|
||||||
|
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);
|
||||||
|
@ -193,13 +178,14 @@ fn cook(fr_params: &mut FuncParams, json_config: &mut Jsonconfig, idsmap: HashMa
|
||||||
// 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 !namefr.is_empty() {
|
if namefr != *"" {
|
||||||
println!("Overriding IDs with perfect ones!");
|
println!("Overriding IDs with perfect ones!");
|
||||||
let fr_gear_cache = load_gear_cache(executable_path)?;
|
let fr_gear_cache = load_gear_cache(executable_path)?;
|
||||||
let resultantvec = gen_perfect(fr_params, namefr, &fr_gear_cache)?;
|
let resultantvec = gen_perfect(&namefr, &fr_gear_cache)?;
|
||||||
fr_params.encode_iddata(&resultantvec, &idsmap)?
|
fr_params.encode_iddata(&resultantvec, idsmap)?
|
||||||
} else if let Some(real_ids) = &json_config.ids {
|
}
|
||||||
fr_params.encode_iddata(real_ids, &idsmap)?
|
else if let Some(real_ids) = &json_config.ids {
|
||||||
|
fr_params.encode_iddata(real_ids, idsmap)?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -217,31 +203,11 @@ fn cook(fr_params: &mut FuncParams, json_config: &mut Jsonconfig, idsmap: HashMa
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ENCODE: DamageData (REQUIRED for CraftedGear)
|
|
||||||
match json_config.item_type {
|
|
||||||
ItemTypeDeser::CraftedGear => {
|
|
||||||
if let Some(real_damagedata) = &json_config.crafted_damage {
|
|
||||||
fr_params.encode_damagedata(real_damagedata)?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ENCODE: DefenseData (REQUIRED for CraftedGear)
|
|
||||||
match json_config.item_type {
|
|
||||||
ItemTypeDeser::CraftedGear => {
|
|
||||||
if let Some(real_defencedata) = &json_config.crafted_defence {
|
|
||||||
fr_params.encode_defensedata(real_defencedata)?
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ENCODE: RequirementsData if ItemType is CraftedGear, CraftedConsu
|
// ENCODE: RequirementsData if ItemType is CraftedGear, CraftedConsu
|
||||||
match json_config.item_type {
|
match json_config.item_type {
|
||||||
ItemTypeDeser::CraftedGear | ItemTypeDeser::CraftedConsu => {
|
ItemTypeDeser::CraftedGear | ItemTypeDeser::CraftedConsu => {
|
||||||
if let Some(real_reqs) = json_config.crafted_requirements {
|
if let Some(real_reqs) = json_config.crafted_requirements {
|
||||||
fr_params.encode_reqdata(&real_reqs)?
|
fr_params.encode_reqdata(real_reqs)?
|
||||||
} else {
|
} else {
|
||||||
return Err(Errorfr::JsonNotFoundReqs);
|
return Err(Errorfr::JsonNotFoundReqs);
|
||||||
}
|
}
|
||||||
|
@ -264,7 +230,7 @@ fn cook(fr_params: &mut FuncParams, json_config: &mut Jsonconfig, idsmap: HashMa
|
||||||
ItemTypeDeser::Gear | ItemTypeDeser::Tome | ItemTypeDeser::Charm => {
|
ItemTypeDeser::Gear | ItemTypeDeser::Tome | ItemTypeDeser::Charm => {
|
||||||
if let Some(rerollcount) = json_config.rerolls {
|
if let Some(rerollcount) = json_config.rerolls {
|
||||||
// rerolldata
|
// rerolldata
|
||||||
fr_params.encode_rerolldata(&rerollcount)?
|
fr_params.encode_rerolldata(rerollcount)?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -283,7 +249,7 @@ fn cook(fr_params: &mut FuncParams, json_config: &mut Jsonconfig, idsmap: HashMa
|
||||||
// ENCODE: EndData, ALWAYS
|
// ENCODE: EndData, ALWAYS
|
||||||
fr_params.encode_enddata()?;
|
fr_params.encode_enddata()?;
|
||||||
|
|
||||||
let mut final_string: String = encode_string(fr_params.fr_out);
|
let mut final_string: String = encode_string(out);
|
||||||
|
|
||||||
// add NameAfter. not actually an encode.
|
// add NameAfter. not actually an encode.
|
||||||
match json_config.item_type {
|
match json_config.item_type {
|
||||||
|
|
Loading…
Add table
Reference in a new issue