crafted types gaming
This commit is contained in:
parent
a29295d878
commit
e3278243c0
5 changed files with 370 additions and 20 deletions
282
config_crafted.json
Normal file
282
config_crafted.json
Normal file
|
@ -0,0 +1,282 @@
|
|||
{
|
||||
"READMEFIRST": [
|
||||
"Refer to config.md to understand how to apply the data shown here.",
|
||||
"There are also some values you cannot increase beyond a limit."
|
||||
],
|
||||
"name":"Singularity",
|
||||
"item_type": "craftedgear",
|
||||
"crafted_type": "potiosn",
|
||||
"shiny": {
|
||||
"key": "playersKilled",
|
||||
"value": 9223372036854775807
|
||||
},
|
||||
"ids": [
|
||||
{"id": "mainAttackDamage","base": 320,"roll": 69},
|
||||
{"id": "healthRegenRaw", "base":250 , "roll":130 },
|
||||
{"id": "rawDexterity", "base":35 },
|
||||
{"id": "walkSpeed", "base":-40 , "roll":69},
|
||||
{"id": "mainAttackDamage", "base":15, "roll":130 },
|
||||
{"id": "rawMainAttackDamage", "base":444 , "roll":130 },
|
||||
{"id": "rawSpellDamage", "base":222 , "roll":130 },
|
||||
{"id": "spellDamage", "base":10 , "roll":130 }
|
||||
],
|
||||
"powders": [
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"},
|
||||
{"type":"E"},
|
||||
{"type":"T"},
|
||||
{"type":"W"},
|
||||
{"type":"F"},
|
||||
{"type":"A"}
|
||||
|
||||
],
|
||||
"rerolls": 255
|
||||
}
|
|
@ -1,11 +1,6 @@
|
|||
use crate::jsonstruct::{
|
||||
FuncParams, Identificationer, ItemTypeDeser, Powder, Shinyjson, Shinystruct,
|
||||
};
|
||||
use crate::jsonstruct::{CraftedTypesFr, FuncParams, Identificationer, ItemTypeDeser, Powder, Shinyjson, Shinystruct};
|
||||
use idmangler_lib::types::{Element, ItemType, RollType, Stat};
|
||||
use idmangler_lib::{
|
||||
DataEncoder, EndData, IdentificationData, NameData, PowderData, RerollData, ShinyData,
|
||||
StartData, TypeData,
|
||||
};
|
||||
use idmangler_lib::{CustomGearTypeData, CustomConsumableTypeData, DataEncoder, EndData, IdentificationData, NameData, PowderData, RerollData, ShinyData, StartData, TypeData};
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub fn encode_startdata(general_params: &mut FuncParams) {
|
||||
|
@ -20,17 +15,28 @@ pub fn encode_typedata(general_params: &mut FuncParams, item_type_deser: ItemTyp
|
|||
.encode(general_params.fr_ver, general_params.fr_out)
|
||||
.unwrap();
|
||||
}
|
||||
pub fn encode_typedata_custom(general_params: &mut FuncParams, crafted_type: &str) {
|
||||
let frfr_type = CraftedTypesFr::try_from(crafted_type);
|
||||
match frfr_type.unwrap() {
|
||||
CraftedTypesFr::Gear(a) => {
|
||||
CustomGearTypeData(a)
|
||||
.encode(general_params.fr_ver, general_params.fr_out)
|
||||
.unwrap()
|
||||
},
|
||||
CraftedTypesFr::Consu(a) => {
|
||||
CustomConsumableTypeData(a)
|
||||
.encode(general_params.fr_ver, general_params.fr_out)
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn encode_namedata(general_params: &mut FuncParams, real_name: &str) {
|
||||
// ENCODE: NameData
|
||||
NameData(real_name.trim().to_string())
|
||||
.encode(general_params.fr_ver, general_params.fr_out)
|
||||
.unwrap();
|
||||
}
|
||||
pub fn encode_ids(
|
||||
general_params: &mut FuncParams,
|
||||
real_ids: Vec<Identificationer>,
|
||||
idsmap: HashMap<String, u8>,
|
||||
) {
|
||||
pub fn encode_ids(general_params: &mut FuncParams, real_ids: Vec<Identificationer>, idsmap: HashMap<String, u8>) {
|
||||
let mut idvec = Vec::new();
|
||||
for eachid in real_ids {
|
||||
let id_id = idsmap.get(eachid.id.trim());
|
||||
|
@ -108,11 +114,7 @@ pub fn encode_reroll(general_params: &mut FuncParams, rerollcount: u8) {
|
|||
}
|
||||
}
|
||||
}
|
||||
pub fn encode_shiny(
|
||||
general_params: &mut FuncParams,
|
||||
shiny: Shinyjson,
|
||||
json_shiny: Vec<Shinystruct>,
|
||||
) {
|
||||
pub fn encode_shiny(general_params: &mut FuncParams, shiny: Shinyjson, json_shiny: Vec<Shinystruct>) {
|
||||
let mut realshinykey: u8;
|
||||
let _shinykey = &shiny.key;
|
||||
let shinyvalue = shiny.value;
|
||||
|
|
|
@ -45,7 +45,15 @@ pub enum Errorfr {
|
|||
|
||||
/// Name value was not found in json
|
||||
#[error(
|
||||
"Error 3.4: \"name\" field was not found in the json (required for Gear, Tome, Charm)."
|
||||
"Error 4.1: \"name\" field was not found in the json (required for Gear, Tome, Charm)."
|
||||
)]
|
||||
JsonNotFoundName,
|
||||
|
||||
/// unable to find the crafted_type field
|
||||
#[error("Error 4.2: Invalid \"crafted_type\" field")]
|
||||
JsonNotFoundCraftedType,
|
||||
|
||||
/// invalid crafted_type field
|
||||
#[error("Error 4.3: Invalid \"crafted_type\" field")]
|
||||
JsonInvalidCraftedType,
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ use crate::errorfr::Errorfr;
|
|||
use idmangler_lib::types::{ItemType, TransformVersion, ConsumableType, GearType};
|
||||
use serde::Deserialize;
|
||||
use std::fs;
|
||||
use idmangler_lib::types::{ConsumableType::*,GearType::*};
|
||||
use crate::jsonstruct::CraftedTypesFr::{Consu, Gear};
|
||||
|
||||
// structs for the json parsing
|
||||
#[derive(Deserialize)]
|
||||
|
@ -19,11 +21,43 @@ pub struct Jsonconfig {
|
|||
pub powders: Option<Vec<Powder>>,
|
||||
pub rerolls: Option<u8>,
|
||||
}
|
||||
#[derive(Deserialize)]
|
||||
pub enum CraftedType {
|
||||
pub enum CraftedTypesFr {
|
||||
Gear(GearType),
|
||||
Consu(ConsumableType)
|
||||
}
|
||||
impl TryFrom<&str> for CraftedTypesFr {
|
||||
type Error = Errorfr;
|
||||
|
||||
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
||||
match value.to_lowercase().as_str() {
|
||||
// consu types
|
||||
"potion" | "pot" => Ok(Consu(Potion)),
|
||||
"food" | "meal" => Ok(Consu(Food)),
|
||||
"scroll" | "paper" => Ok(Consu(Scroll)),
|
||||
// 5 weapon types
|
||||
"spear" => Ok(Gear(Spear)),
|
||||
"wand" => Ok(Gear(Wand)),
|
||||
"dagger" => Ok(Gear(Dagger)),
|
||||
"bow" => Ok(Gear(Bow)),
|
||||
"relik" => Ok(Gear(Relik)),
|
||||
// 4 armour types
|
||||
"helmet" | "hat" => Ok(Gear(Helmet)),
|
||||
"chestplate" | "shirt" | "chest" | "cp" => Ok(Gear(Chestplate)),
|
||||
"leggings" | "legs" | "pants" => Ok(Gear(Leggings)),
|
||||
"boots" | "shoes" => Ok(Gear(Boots)),
|
||||
// 4 accessory types
|
||||
"ring" => Ok(Gear(Ring)),
|
||||
"bracelet" => Ok(Gear(Bracelet)),
|
||||
"necklace" => Ok(Gear(Necklace)),
|
||||
// General gear types (FALLBACK) (don't use these if not necessary)
|
||||
"weapon" => Ok(Gear(Weapon)),
|
||||
"accessory" => Ok(Gear(Accessory)),
|
||||
// fallback error return
|
||||
_ => Err(Errorfr::JsonInvalidCraftedType)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct Shinystruct {
|
||||
pub id: u8,
|
||||
|
@ -58,10 +92,19 @@ pub struct FuncParams<'a> {
|
|||
#[repr(u8)]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash, Debug, Deserialize)]
|
||||
pub enum ItemTypeDeser {
|
||||
#[serde(alias = "gear")]
|
||||
Gear = 0,
|
||||
#[serde(alias = "tome")]
|
||||
Tome = 1,
|
||||
#[serde(alias = "charm")]
|
||||
Charm = 2,
|
||||
#[serde(alias = "craftedgear")]
|
||||
#[serde(alias = "cgear")]
|
||||
#[serde(alias = "CGear")]
|
||||
CraftedGear = 3,
|
||||
#[serde(alias = "craftedconsu")]
|
||||
#[serde(alias = "cconsu")]
|
||||
#[serde(alias = "CConsu")]
|
||||
CraftedConsu = 4,
|
||||
}
|
||||
impl From<ItemTypeDeser> for ItemType {
|
||||
|
|
15
src/main.rs
15
src/main.rs
|
@ -15,6 +15,7 @@ use crate::jsonstruct::*;
|
|||
|
||||
use clap::Parser;
|
||||
use reqwest::Url;
|
||||
use crate::errorfr::Errorfr::JsonNotFoundCraftedType;
|
||||
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
#[command(version, about, long_about = None, arg_required_else_help(true))]
|
||||
|
@ -124,6 +125,20 @@ fn cook(
|
|||
encode_startdata(&mut fr_params);
|
||||
encode_typedata(&mut fr_params, json_config.item_type);
|
||||
|
||||
// ENCODE: CustomGearTypeData / CustomConsumableTypeData
|
||||
match json_config.item_type {
|
||||
ItemTypeDeser::CraftedGear | ItemTypeDeser::CraftedConsu => {
|
||||
if let Some(real_crafted_type) = json_config.crafted_type {
|
||||
encode_typedata_custom(&mut fr_params, &*real_crafted_type)
|
||||
}
|
||||
else {
|
||||
return Err(JsonNotFoundCraftedType)
|
||||
}
|
||||
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// ENCODE: NameData, if ItemType is Gear, Tome, Charm
|
||||
match json_config.item_type {
|
||||
ItemTypeDeser::Gear | ItemTypeDeser::Tome | ItemTypeDeser::Charm => {
|
||||
|
|
Loading…
Add table
Reference in a new issue