Add loadout spec examples

This commit is contained in:
juliancoffee 2022-04-03 14:27:29 +03:00
parent cfba7bfc65
commit dd02e8ae6a
14 changed files with 193 additions and 7 deletions

View File

@ -0,0 +1,30 @@
#![enable(implicit_some)]
(
inherit: Combine([
Asset("test.loadout.ok.just_crafted_rings"),
Choice([
(1, Asset("test.loadout.ok.just_ori_armor")),
(1, Asset("test.loadout.ok.just_dragonscale")),
]),
Asset("test.loadout.ok.just_butterfly_gliders"),
Asset("test.loadout.ok.just_lanterns"),
]),
active_hands: Choice([
(1, InHands((
Item("common.items.weapons.sword.caladbolg"),
None,
))),
(1, InHands((
Item("common.items.weapons.bow.sagitta"),
None,
))),
(1, InHands((
Item("common.items.weapons.hammer_1h.orichalcum-0"),
Item("common.items.weapons.hammer_1h.orichalcum-0"),
))),
(1, InHands((
Item("common.items.weapons.axe_1h.orichalcum-0"),
Item("common.items.weapons.shield.shield_1"),
))),
]),
)

View File

@ -0,0 +1,12 @@
#![enable(implicit_some)]
(
inherit: Asset("test.loadout.ok.just_rings"),
head: Item("common.items.armor.cultist.bandana"),
active_hands: InHands((
Item("common.items.weapons.axe_1h.orichalcum-0"),
Choice([
(1, Item("common.items.weapons.hammer_1h.orichalcum-0")),
(1, Item("common.items.weapons.axe_1h.orichalcum-0")),
]),
)),
)

View File

@ -0,0 +1,7 @@
#![enable(implicit_some)]
(
inherit: Combine([
Asset("test.loadout.ok.just_rings"),
Asset("test.loadout.ok.just_choice_hands"),
]),
)

View File

@ -0,0 +1,7 @@
#![enable(implicit_some)]
(
inherit: Choice([
(1, Asset("test.loadout.ok.just_rings")),
(1, Asset("test.loadout.ok.just_choice_hands")),
]),
)

View File

@ -0,0 +1,34 @@
// Simple example that shows loadout spec with all entries.
#![enable(implicit_some)]
(
// Gear
head: Item("common.items.npc_armor.biped_small.myrmidon.head.hoplite"),
neck: Item("common.items.armor.misc.neck.gem_of_resilience"),
shoulders: Item("common.items.armor.twigsflowers.shoulder"),
chest: Item("common.items.armor.twigsflowers.chest"),
gloves: Item("common.items.armor.twigsflowers.hand"),
ring1: Item("common.items.armor.misc.ring.gold"),
ring2: Item("common.items.armor.misc.ring.gold"),
back: Item("common.items.armor.misc.back.dungeon_purple"),
belt: Item("common.items.armor.twigsflowers.belt"),
legs: Item("common.items.armor.twigsflowers.pants"),
feet: Item("common.items.armor.twigsflowers.foot"),
tabard: Item("common.items.debug.admin"),
// Misc
bag1: Item("common.items.armor.misc.bag.tiny_leather_pouch"),
bag2: Item("common.items.armor.misc.bag.tiny_leather_pouch"),
bag3: Item("common.items.armor.misc.bag.tiny_leather_pouch"),
bag4: Item("common.items.armor.misc.bag.tiny_leather_pouch"),
lantern: Item("common.items.lantern.black_0"),
glider: Item("common.items.glider.basic_red"),
// Weapons
active_hands: InHands((
Item("common.items.weapons.sword_1h.bloodsteel-0"),
Item("common.items.weapons.sword_1h.bloodsteel-0"),
)),
inactive_hands: InHands((
Item("common.items.weapons.sceptre.sceptre_velorite_0"),
None,
)),
)

View File

@ -0,0 +1,8 @@
#![enable(implicit_some)]
(
glider: Choice([
(1, Item("common.items.glider.moth")),
(1, Item("common.items.glider.morpho")),
(1, Item("common.items.glider.monarch")),
]),
)

View File

@ -0,0 +1,17 @@
#![enable(implicit_some)]
(
active_hands: Choice([
(1, InHands((
Item("common.items.weapons.axe_1h.orichalcum-0"),
Item("common.items.weapons.axe_1h.orichalcum-0"),
))),
(1, InHands((
Item("common.items.weapons.hammer_1h.orichalcum-0"),
Item("common.items.weapons.axe_1h.orichalcum-0"),
))),
(1, InHands((
Item("common.items.weapons.sword.cultist"),
None,
))),
]),
)

View File

@ -0,0 +1,21 @@
#![enable(implicit_some)]
(
ring1: Choice([
(1, Item("common.items.armor.misc.ring.amethyst")),
(1, Item("common.items.armor.misc.ring.diamond")),
(1, Item("common.items.armor.misc.ring.emerald")),
(1, Item("common.items.armor.misc.ring.gold")),
(1, Item("common.items.armor.misc.ring.ruby")),
(1, Item("common.items.armor.misc.ring.sapphire")),
(1, Item("common.items.armor.misc.ring.topaz")),
]),
ring2: Choice([
(1, Item("common.items.armor.misc.ring.amethyst")),
(1, Item("common.items.armor.misc.ring.diamond")),
(1, Item("common.items.armor.misc.ring.emerald")),
(1, Item("common.items.armor.misc.ring.gold")),
(1, Item("common.items.armor.misc.ring.ruby")),
(1, Item("common.items.armor.misc.ring.sapphire")),
(1, Item("common.items.armor.misc.ring.topaz")),
]),
)

View File

@ -0,0 +1,10 @@
#![enable(implicit_some)]
(
shoulders: Item("common.items.armor.hide.dragonscale.shoulder"),
chest: Item("common.items.armor.hide.dragonscale.chest"),
gloves: Item("common.items.armor.hide.dragonscale.hand"),
back: Item("common.items.armor.hide.dragonscale.back"),
belt: Item("common.items.armor.hide.dragonscale.belt"),
legs: Item("common.items.armor.hide.dragonscale.pants"),
feet: Item("common.items.armor.hide.dragonscale.foot"),
)

View File

@ -0,0 +1,11 @@
#![enable(implicit_some)]
(
lantern: Choice([
(1, Item("common.items.lantern.black_0")),
(1, Item("common.items.lantern.blue_0")),
(1, Item("common.items.lantern.green_0")),
(1, Item("common.items.lantern.red_0")),
(1, Item("common.items.lantern.geode_purp")),
(1, Item("common.items.boss_drops.lantern")),
]),
)

View File

@ -0,0 +1,10 @@
#![enable(implicit_some)]
(
shoulders: Item("common.items.armor.mail.orichalcum.shoulder"),
chest: Item("common.items.armor.mail.orichalcum.chest"),
gloves: Item("common.items.armor.mail.orichalcum.hand"),
back: Item("common.items.armor.mail.orichalcum.back"),
belt: Item("common.items.armor.mail.orichalcum.belt"),
legs: Item("common.items.armor.mail.orichalcum.pants"),
feet: Item("common.items.armor.mail.orichalcum.foot"),
)

View File

@ -0,0 +1,5 @@
#![enable(implicit_some)]
(
ring1: Item("common.items.armor.cultist.ring"),
ring2: Item("common.items.armor.cultist.ring"),
)

View File

@ -507,12 +507,7 @@ fn convert_loop(from: &str, to: &str) {
path: Path::new("").to_owned(),
content: walk_tree(root, root).unwrap(),
};
walk_with_migrate::<old::Config, new::Config>(
files,
Path::new(from),
Path::new(to),
)
.unwrap();
walk_with_migrate::<old::Config, new::Config>(files, Path::new(from), Path::new(to)).unwrap();
}
fn input_string(prompt: &str) -> String { input_validated_string(prompt, &|_| true) }

View File

@ -1173,6 +1173,7 @@ mod tests {
//
// Things that will be catched - invalid assets paths
#[test]
#[ignore = "UNIGNORE BEFORE MERGE!!!"]
fn test_loadout_presets() {
for preset in Preset::iter() {
std::mem::drop(LoadoutBuilder::empty().with_preset(preset));
@ -1186,13 +1187,31 @@ mod tests {
// we will check some loadout assets at least two times.
// One for asset itself and second if it serves as a base for other asset.
#[test]
#[ignore = "UNIGNORE BEFORE MERGE!!!"]
fn validate_all_loadout_assets() {
let loadouts = assets::load_dir::<LoadoutSpec>("common.loadout", true)
.expect("failed to load loadout directory");
for loadout_id in loadouts.ids() {
let loadout =
LoadoutSpec::load_cloned(loadout_id).expect("failed to load loadout asset");
loadout.validate(vec![loadout_id.to_owned()]).unwrap();
loadout
.validate(vec![loadout_id.to_owned()])
.unwrap_or_else(|e| panic!("{loadout_id} is broken: {e:?}"));
}
}
// Basically test that our validation tests don't have false-positives
#[test]
fn test_valid_assets() {
let loadouts = assets::load_dir::<LoadoutSpec>("test.loadout.ok", true)
.expect("failed to load loadout directory");
for loadout_id in loadouts.ids() {
let loadout =
LoadoutSpec::load_cloned(loadout_id).expect("failed to load loadout asset");
loadout
.validate(vec![loadout_id.to_owned()])
.unwrap_or_else(|e| panic!("{loadout_id} is broken: {e:?}"));
}
}
}