A very smol Rust library that I made specifically for (de)serialising a special-sauce format of RON that represents pre-BB MapleStory jobs. https://codeberg.org/deer/rangifer_diary/src/branch/master/068/README.md
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
deer 3a5e9636d7 Clone, Copy 2 months ago
src Clone, Copy 2 months ago
.gitignore Initial commit 2 months ago
.rustfmt.toml Initial commit 2 months ago
Cargo.toml from_reader 2 months ago
LICENSE-APACHE Initial commit 2 months ago
LICENSE-MIT Initial commit 2 months ago
README.md Initial commit 2 months ago

README.md

maple_jobs

A very smol Rust library that I made specifically for (de)serialising a special-sauce format of RON that represents pre-BB MapleStory jobs.

sample usage

let ron_file_contents = r#"
{
    "not a real job": Job(
        classes: [Beginner, EvanBeginner, Spearman, DualBlade],
        location: MapleIsland,
        stats: Stats(
            primary: [STR, MAXMP],
            secondary: [LUK],
            constraints: [
                [Less(DEX)],
                [Ful(STR), Ful(LUK)],
            ],
        ),
        weaponry: Weaponry(
            allowed: WepTypes([Spear, OneHandedMace]),
            canonical: WepIds([132_2003, 132_2006]),
        ),
        ammo: true,
        skills: Some([]),
    ),
}
"#;

// Deserialise from a string
let jobs = maple_jobs::from_str(ron_file_contents).unwrap();

// Construct the same in-memory structure, but explicitly
use maple_jobs::job::{
    Class,
    Job,
    Location,
    Stat,
    StatConstraint,
    Stats,
    Weaponry,
    WepSet,
    WepType,
};
use std::{collections::HashMap, convert::TryInto};

let mut jobs_explicit = HashMap::with_capacity(1);
jobs_explicit.insert(
    "not a real job".to_owned(),
    Job {
        classes: vec![
            Class::Beginner,
            2001.try_into().unwrap(),
            Class::Spearman,
            Class::DualBlade,
        ],
        location: Location::MapleIsland,
        stats: Stats {
            primary: vec![Stat::STR, Stat::MAXMP],
            secondary: vec![Stat::LUK],
            constraints: vec![
                vec![StatConstraint::Less(Stat::DEX)],
                vec![
                    StatConstraint::Ful(Stat::STR),
                    StatConstraint::Ful(Stat::LUK),
                ],
            ],
        },
        weaponry: Weaponry {
            allowed: WepSet::WepTypes(vec![
                WepType::Spear,
                132.try_into().unwrap(),
            ]),
            canonical: WepSet::WepIds(vec![132_2003, 132_2006]),
        },
        ammo: true,
        skills: Some(Vec::new()),
    },
);

// Test for equality
assert_eq!(jobs, jobs_explicit);

Apache 2.0, or MIT, at your option.