actually calculating and comparing data
This commit is contained in:
parent
9c2049ed5e
commit
6e1170b3ed
3 changed files with 25 additions and 7 deletions
|
@ -22,12 +22,12 @@ pub enum DpsRole {
|
|||
pub struct JobStats {
|
||||
pub role: Role,
|
||||
pub is_blue_mage: bool,
|
||||
pub level: u8,
|
||||
pub starting_level: u8,
|
||||
pub level: usize,
|
||||
pub starting_level: usize,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
fn get_starting_level(name: &str) -> anyhow::Result<u8> {
|
||||
fn get_starting_level(name: &str) -> anyhow::Result<usize> {
|
||||
match name {
|
||||
"Paladin" | "Warrior" | "Monk" | "Dragoon" | "Ninja" | "White Mage" | "Scholar"
|
||||
| "Black Mage" | "Bard" | "Summoner" | "Blue Mage" | "Carpenter" | "Blacksmith"
|
||||
|
|
24
src/main.rs
24
src/main.rs
|
@ -1,7 +1,7 @@
|
|||
mod compile_data;
|
||||
mod raw_data;
|
||||
|
||||
use crate::compile_data::JobStats;
|
||||
use crate::compile_data::{JobStats, Role};
|
||||
use crate::raw_data::RawJobStats;
|
||||
|
||||
use std::fs::File;
|
||||
|
@ -14,9 +14,27 @@ fn get_job_stats(lodestone_id: usize) -> anyhow::Result<Vec<JobStats>> {
|
|||
}
|
||||
|
||||
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(())
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ use serde::Deserialize;
|
|||
pub struct RawJobStats {
|
||||
// TODO: is specialized
|
||||
#[serde(rename = "Level")]
|
||||
pub level: u8,
|
||||
pub level: usize,
|
||||
/// I'm annoyed I need to parse this entire structure
|
||||
/// However the class/job dichotamy means the name
|
||||
/// field in this parent struct is tainted
|
||||
|
|
Loading…
Reference in a new issue