actually calculating and comparing data

This commit is contained in:
Zynh0722 2024-02-02 00:05:02 -08:00
parent 9c2049ed5e
commit 6e1170b3ed
3 changed files with 25 additions and 7 deletions

View file

@ -22,12 +22,12 @@ pub enum DpsRole {
pub struct JobStats { pub struct JobStats {
pub role: Role, pub role: Role,
pub is_blue_mage: bool, pub is_blue_mage: bool,
pub level: u8, pub level: usize,
pub starting_level: u8, pub starting_level: usize,
pub name: String, pub name: String,
} }
fn get_starting_level(name: &str) -> anyhow::Result<u8> { fn get_starting_level(name: &str) -> anyhow::Result<usize> {
match name { match name {
"Paladin" | "Warrior" | "Monk" | "Dragoon" | "Ninja" | "White Mage" | "Scholar" "Paladin" | "Warrior" | "Monk" | "Dragoon" | "Ninja" | "White Mage" | "Scholar"
| "Black Mage" | "Bard" | "Summoner" | "Blue Mage" | "Carpenter" | "Blacksmith" | "Black Mage" | "Bard" | "Summoner" | "Blue Mage" | "Carpenter" | "Blacksmith"

View file

@ -1,7 +1,7 @@
mod compile_data; mod compile_data;
mod raw_data; mod raw_data;
use crate::compile_data::JobStats; use crate::compile_data::{JobStats, Role};
use crate::raw_data::RawJobStats; use crate::raw_data::RawJobStats;
use std::fs::File; use std::fs::File;
@ -14,9 +14,27 @@ fn get_job_stats(lodestone_id: usize) -> anyhow::Result<Vec<JobStats>> {
} }
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {
let stats = get_job_stats(29932586)?; let id = 29932586;
let stats = get_job_stats(id)?;
println!("{stats:#?}"); let total_dowm_earned_levels = stats
.iter()
.filter(|j| matches!(j.role, Role::Tank | Role::Healer | Role::Dps(_)))
.filter(|j| j.name != "Scholar")
.fold(0usize, |acc, j| acc + j.level - j.starting_level);
println!("{total_dowm_earned_levels} levels for {id}");
let id = 44540671;
let stats = get_job_stats(id)?;
let total_dowm_earned_levels = stats
.iter()
.filter(|j| matches!(j.role, Role::Tank | Role::Healer | Role::Dps(_)))
.filter(|j| j.name != "Scholar")
.fold(0usize, |acc, j| acc + j.level - j.starting_level);
println!("{total_dowm_earned_levels} levels for {id}");
Ok(()) Ok(())
} }

View file

@ -4,7 +4,7 @@ use serde::Deserialize;
pub struct RawJobStats { pub struct RawJobStats {
// TODO: is specialized // TODO: is specialized
#[serde(rename = "Level")] #[serde(rename = "Level")]
pub level: u8, pub level: usize,
/// I'm annoyed I need to parse this entire structure /// I'm annoyed I need to parse this entire structure
/// However the class/job dichotamy means the name /// However the class/job dichotamy means the name
/// field in this parent struct is tainted /// field in this parent struct is tainted