compiling data!
parent
06e600f5d4
commit
9c2049ed5e
|
@ -1 +1,2 @@
|
||||||
/target
|
/target
|
||||||
|
/data
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
use crate::raw_data::RawJobStats;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Role {
|
||||||
|
Tank,
|
||||||
|
Healer,
|
||||||
|
Doh,
|
||||||
|
Dol,
|
||||||
|
Dps(DpsRole),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum DpsRole {
|
||||||
|
Melee,
|
||||||
|
Ranged,
|
||||||
|
Magic,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct JobStats {
|
||||||
|
pub role: Role,
|
||||||
|
pub is_blue_mage: bool,
|
||||||
|
pub level: u8,
|
||||||
|
pub starting_level: u8,
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_starting_level(name: &str) -> anyhow::Result<u8> {
|
||||||
|
match name {
|
||||||
|
"Paladin" | "Warrior" | "Monk" | "Dragoon" | "Ninja" | "White Mage" | "Scholar"
|
||||||
|
| "Black Mage" | "Bard" | "Summoner" | "Blue Mage" | "Carpenter" | "Blacksmith"
|
||||||
|
| "Armorer" | "Goldsmith" | "Leatherworker" | "Weaver" | "Alchemist" | "Culinarian"
|
||||||
|
| "Miner" | "Botanist" | "Fisher" => Ok(0),
|
||||||
|
"Dark Knight" | "Astrologian" | "Machinist" => Ok(30),
|
||||||
|
"Gunbreaker" | "Dancer" => Ok(60),
|
||||||
|
"Samurai" | "Red Mage" => Ok(50),
|
||||||
|
"Reaper" | "Sage" => Ok(70),
|
||||||
|
_ => Err(anyhow::anyhow!("That's not a class")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<RawJobStats> for JobStats {
|
||||||
|
fn from(raw: RawJobStats) -> Self {
|
||||||
|
let name = raw.unlocked_state.name;
|
||||||
|
JobStats {
|
||||||
|
role: str::parse(&name).unwrap(),
|
||||||
|
is_blue_mage: name == "Blue Mage",
|
||||||
|
starting_level: get_starting_level(&name).unwrap(),
|
||||||
|
level: raw.level,
|
||||||
|
name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromStr for Role {
|
||||||
|
type Err = anyhow::Error;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
use DpsRole::*;
|
||||||
|
use Role::*;
|
||||||
|
|
||||||
|
match s {
|
||||||
|
"Paladin" | "Warrior" | "Dark Knight" | "Gunbreaker" => Ok(Tank),
|
||||||
|
"Monk" | "Dragoon" | "Ninja" | "Samurai" | "Reaper" => Ok(Dps(Melee)),
|
||||||
|
"White Mage" | "Scholar" | "Astrologian" | "Sage" => Ok(Healer),
|
||||||
|
"Bard" | "Machinist" | "Dancer" => Ok(Dps(Ranged)),
|
||||||
|
"Black Mage" => Ok(Dps(Magic)),
|
||||||
|
"Summoner" => Ok(Dps(Magic)),
|
||||||
|
"Red Mage" => Ok(Dps(Magic)),
|
||||||
|
"Blue Mage" => Ok(Dps(Magic)),
|
||||||
|
"Carpenter" | "Blacksmith" | "Armorer" | "Goldsmith" | "Leatherworker" | "Weaver"
|
||||||
|
| "Alchemist" | "Culinarian" => Ok(Doh),
|
||||||
|
"Miner" | "Botanist" | "Fisher" => Ok(Dol),
|
||||||
|
_ => Err(anyhow::anyhow!(
|
||||||
|
"Ooopsie Poopsie, dats not a weal cwass >.<"
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
src/main.rs
18
src/main.rs
|
@ -1,12 +1,22 @@
|
||||||
|
mod compile_data;
|
||||||
mod raw_data;
|
mod raw_data;
|
||||||
use crate::raw_data::JobStats;
|
|
||||||
|
use crate::compile_data::JobStats;
|
||||||
|
use crate::raw_data::RawJobStats;
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn get_job_stats(lodestone_id: usize) -> anyhow::Result<Vec<JobStats>> {
|
||||||
let raw: Vec<JobStats> = serde_json::from_reader(File::open("./29932586.json")?)?;
|
let file = File::open(format!("./data/{lodestone_id}.json"))?;
|
||||||
|
let raw: Vec<RawJobStats> = serde_json::from_reader(file)?;
|
||||||
|
|
||||||
println!("{raw:#?}");
|
Ok(raw.into_iter().map(|r| r.into()).collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() -> anyhow::Result<()> {
|
||||||
|
let stats = get_job_stats(29932586)?;
|
||||||
|
|
||||||
|
println!("{stats:#?}");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct JobStats {
|
pub struct RawJobStats {
|
||||||
// TODO: is specialized
|
// TODO: is specialized
|
||||||
#[serde(rename = "Level")]
|
#[serde(rename = "Level")]
|
||||||
pub level: u8,
|
pub level: u8,
|
||||||
|
|
Loading…
Reference in New Issue