diff --git a/assets/common/loadouts/dungeon/tier-0/gnarling.ron b/assets/common/loadouts/dungeon/tier-0/gnarling.ron index a3d4ca6e17..9d73cdefdb 100644 --- a/assets/common/loadouts/dungeon/tier-0/gnarling.ron +++ b/assets/common/loadouts/dungeon/tier-0/gnarling.ron @@ -1,8 +1,8 @@ ({ - "head": Item("common.items.npc_armor.biped_small.gnarling.head.gnarling"), - "feet": Item("common.items.npc_armor.biped_small.gnarling.foot.gnarling"), - "hands": Item("common.items.npc_armor.biped_small.gnarling.hand.gnarling"), - "chest": Item("common.items.npc_armor.biped_small.gnarling.chest.gnarling"), - "pants": Item("common.items.npc_armor.biped_small.gnarling.pants.gnarling"), - "belt": Item("common.items.npc_armor.biped_small.gnarling.tail.gnarling"), + Armor(Head): Item("common.items.npc_armor.biped_small.gnarling.head.gnarling"), + Armor(Feet): Item("common.items.npc_armor.biped_small.gnarling.foot.gnarling"), + Armor(Hands): Item("common.items.npc_armor.biped_small.gnarling.hand.gnarling"), + Armor(Chest): Item("common.items.npc_armor.biped_small.gnarling.chest.gnarling"), + Armor(Legs): Item("common.items.npc_armor.biped_small.gnarling.pants.gnarling"), + Armor(Belt): Item("common.items.npc_armor.biped_small.gnarling.tail.gnarling"), }) diff --git a/assets/common/loadouts/dungeon/tier-1/adlet_bow.ron b/assets/common/loadouts/dungeon/tier-1/adlet_bow.ron index a01505224c..6e41a40ee7 100644 --- a/assets/common/loadouts/dungeon/tier-1/adlet_bow.ron +++ b/assets/common/loadouts/dungeon/tier-1/adlet_bow.ron @@ -1,8 +1,8 @@ ({ - "head": Item("common.items.npc_armor.biped_small.adlet.head.adlet_bow"), - "hands": Item("common.items.npc_armor.biped_small.adlet.hand.adlet_bow"), - "feet": Item("common.items.npc_armor.biped_small.adlet.foot.adlet"), - "chest": Item("common.items.npc_armor.biped_small.adlet.chest.adlet_bow"), - "pants": Item("common.items.npc_armor.biped_small.adlet.pants.adlet_bow"), - "belt": Item("common.items.npc_armor.biped_small.adlet.tail.adlet"), + Armor(Head): Item("common.items.npc_armor.biped_small.adlet.head.adlet_bow"), + Armor(Hands): Item("common.items.npc_armor.biped_small.adlet.hand.adlet_bow"), + Armor(Feet): Item("common.items.npc_armor.biped_small.adlet.foot.adlet"), + Armor(Chest): Item("common.items.npc_armor.biped_small.adlet.chest.adlet_bow"), + Armor(Legs): Item("common.items.npc_armor.biped_small.adlet.pants.adlet_bow"), + Armor(Belt): Item("common.items.npc_armor.biped_small.adlet.tail.adlet"), }) diff --git a/assets/common/loadouts/dungeon/tier-1/adlet_spear.ron b/assets/common/loadouts/dungeon/tier-1/adlet_spear.ron index c02a246b04..3cc2d10f4d 100644 --- a/assets/common/loadouts/dungeon/tier-1/adlet_spear.ron +++ b/assets/common/loadouts/dungeon/tier-1/adlet_spear.ron @@ -1,8 +1,8 @@ ({ - "head": Item("common.items.npc_armor.biped_small.adlet.head.adlet_spear"), - "hands": Item("common.items.npc_armor.biped_small.adlet.hand.adlet_spear"), - "feet": Item("common.items.npc_armor.biped_small.adlet.foot.adlet"), - "chest": Item("common.items.npc_armor.biped_small.adlet.chest.adlet_spear"), - "pants": Item("common.items.npc_armor.biped_small.adlet.pants.adlet_spear"), - "belt": Item("common.items.npc_armor.biped_small.adlet.tail.adlet"), + Armor(Head): Item("common.items.npc_armor.biped_small.adlet.head.adlet_spear"), + Armor(Hands): Item("common.items.npc_armor.biped_small.adlet.hand.adlet_spear"), + Armor(Feet): Item("common.items.npc_armor.biped_small.adlet.foot.adlet"), + Armor(Chest): Item("common.items.npc_armor.biped_small.adlet.chest.adlet_spear"), + Armor(Legs): Item("common.items.npc_armor.biped_small.adlet.pants.adlet_spear"), + Armor(Belt): Item("common.items.npc_armor.biped_small.adlet.tail.adlet"), }) diff --git a/assets/common/loadouts/dungeon/tier-2/sahagin.ron b/assets/common/loadouts/dungeon/tier-2/sahagin.ron index 3a26362fc8..e7be4c0458 100644 --- a/assets/common/loadouts/dungeon/tier-2/sahagin.ron +++ b/assets/common/loadouts/dungeon/tier-2/sahagin.ron @@ -1,8 +1,8 @@ ({ - "head": Item("common.items.npc_armor.biped_small.sahagin.head.sahagin"), - "feet": Item("common.items.npc_armor.biped_small.sahagin.foot.sahagin"), - "hands": Item("common.items.npc_armor.biped_small.sahagin.hand.sahagin"), - "chest": Item("common.items.npc_armor.biped_small.sahagin.chest.sahagin"), - "pants": Item("common.items.npc_armor.biped_small.sahagin.pants.sahagin"), - "belt": Item("common.items.npc_armor.biped_small.sahagin.tail.sahagin"), + Armor(Head): Item("common.items.npc_armor.biped_small.sahagin.head.sahagin"), + Armor(Feet): Item("common.items.npc_armor.biped_small.sahagin.foot.sahagin"), + Armor(Hands): Item("common.items.npc_armor.biped_small.sahagin.hand.sahagin"), + Armor(Chest): Item("common.items.npc_armor.biped_small.sahagin.chest.sahagin"), + Armor(Legs): Item("common.items.npc_armor.biped_small.sahagin.pants.sahagin"), + Armor(Belt): Item("common.items.npc_armor.biped_small.sahagin.tail.sahagin"), }) diff --git a/assets/common/loadouts/dungeon/tier-3/haniwa.ron b/assets/common/loadouts/dungeon/tier-3/haniwa.ron index b2b9aa90e1..92c9e142a5 100644 --- a/assets/common/loadouts/dungeon/tier-3/haniwa.ron +++ b/assets/common/loadouts/dungeon/tier-3/haniwa.ron @@ -1,7 +1,7 @@ ({ - "head": Item("common.items.npc_armor.biped_small.haniwa.head.haniwa"), - "feet": Item("common.items.npc_armor.biped_small.haniwa.foot.haniwa"), - "hands": Item("common.items.npc_armor.biped_small.haniwa.hand.haniwa"), - "chest": Item("common.items.npc_armor.biped_small.haniwa.chest.haniwa"), - "pants": Item("common.items.npc_armor.biped_small.haniwa.pants.haniwa"), + Armor(Head): Item("common.items.npc_armor.biped_small.haniwa.head.haniwa"), + Armor(Feet): Item("common.items.npc_armor.biped_small.haniwa.foot.haniwa"), + Armor(Hands): Item("common.items.npc_armor.biped_small.haniwa.hand.haniwa"), + Armor(Chest): Item("common.items.npc_armor.biped_small.haniwa.chest.haniwa"), + Armor(Legs): Item("common.items.npc_armor.biped_small.haniwa.pants.haniwa"), }) diff --git a/assets/common/loadouts/dungeon/tier-4/myrmidon.ron b/assets/common/loadouts/dungeon/tier-4/myrmidon.ron index 565b91d416..fb4867b283 100644 --- a/assets/common/loadouts/dungeon/tier-4/myrmidon.ron +++ b/assets/common/loadouts/dungeon/tier-4/myrmidon.ron @@ -1,8 +1,8 @@ ({ - "head": Item("common.items.npc_armor.biped_small.myrmidon.head.myrmidon"), - "feet": Item("common.items.npc_armor.biped_small.myrmidon.foot.myrmidon"), - "hands": Item("common.items.npc_armor.biped_small.myrmidon.hand.myrmidon"), - "chest": Item("common.items.npc_armor.biped_small.myrmidon.chest.myrmidon"), - "pants": Item("common.items.npc_armor.biped_small.myrmidon.pants.myrmidon"), - "belt": Item("common.items.npc_armor.biped_small.myrmidon.tail.myrmidon"), + Armor(Head): Item("common.items.npc_armor.biped_small.myrmidon.head.myrmidon"), + Armor(Feet): Item("common.items.npc_armor.biped_small.myrmidon.foot.myrmidon"), + Armor(Hands): Item("common.items.npc_armor.biped_small.myrmidon.hand.myrmidon"), + Armor(Chest): Item("common.items.npc_armor.biped_small.myrmidon.chest.myrmidon"), + Armor(Legs): Item("common.items.npc_armor.biped_small.myrmidon.pants.myrmidon"), + Armor(Belt): Item("common.items.npc_armor.biped_small.myrmidon.tail.myrmidon"), }) diff --git a/assets/common/loadouts/dungeon/tier-5/beastmaster.ron b/assets/common/loadouts/dungeon/tier-5/beastmaster.ron index 87dd7fbba1..f1fe6b3175 100644 --- a/assets/common/loadouts/dungeon/tier-5/beastmaster.ron +++ b/assets/common/loadouts/dungeon/tier-5/beastmaster.ron @@ -1,17 +1,17 @@ ({ - "shoulder": Item("common.items.armor.ferocious.shoulder"), - "chest": Item("common.items.armor.ferocious.chest"), - "belt": Item("common.items.armor.ferocious.belt"), - "hands": Item("common.items.armor.ferocious.hand"), - "pants": Item("common.items.armor.ferocious.pants"), - "feet": Item("common.items.armor.ferocious.foot"), + Armor(Shoulders): Item("common.items.armor.ferocious.shoulder"), + Armor(Chest): Item("common.items.armor.ferocious.chest"), + Armor(Belt): Item("common.items.armor.ferocious.belt"), + Armor(Hands): Item("common.items.armor.ferocious.hand"), + Armor(Legs): Item("common.items.armor.ferocious.pants"), + Armor(Feet): Item("common.items.armor.ferocious.foot"), - "back": Item("common.items.armor.ferocious.back"), + Armor(Back): Item("common.items.armor.ferocious.back"), - "lantern": Choice([ + Lantern: Choice([ (1.0, Some(Item("common.items.lantern.black_0"))), (2.0, None), ]), - "glider": Item("common.items.glider.glider_blue"), + Glider: Item("common.items.glider.glider_blue"), }) diff --git a/assets/common/loadouts/dungeon/tier-5/husk.ron b/assets/common/loadouts/dungeon/tier-5/husk.ron index 9d5a3f6d83..feb981ad79 100644 --- a/assets/common/loadouts/dungeon/tier-5/husk.ron +++ b/assets/common/loadouts/dungeon/tier-5/husk.ron @@ -1,7 +1,7 @@ ({ - "head": Item("common.items.npc_armor.biped_small.husk.head.husk"), - "feet": Item("common.items.npc_armor.biped_small.husk.foot.husk"), - "hands": Item("common.items.npc_armor.biped_small.husk.hand.husk"), - "chest": Item("common.items.npc_armor.biped_small.husk.chest.husk"), - "pants": Item("common.items.npc_armor.biped_small.husk.pants.husk"), + Armor(Head): Item("common.items.npc_armor.biped_small.husk.head.husk"), + Armor(Feet): Item("common.items.npc_armor.biped_small.husk.foot.husk"), + Armor(Hands): Item("common.items.npc_armor.biped_small.husk.hand.husk"), + Armor(Chest): Item("common.items.npc_armor.biped_small.husk.chest.husk"), + Armor(Legs): Item("common.items.npc_armor.biped_small.husk.pants.husk"), }) diff --git a/assets/common/loadouts/dungeon/tier-5/warlock.ron b/assets/common/loadouts/dungeon/tier-5/warlock.ron index ea04930ce3..bcc428fbda 100644 --- a/assets/common/loadouts/dungeon/tier-5/warlock.ron +++ b/assets/common/loadouts/dungeon/tier-5/warlock.ron @@ -1,17 +1,17 @@ ({ - "shoulder": Item("common.items.armor.warlock.shoulder"), - "chest": Item("common.items.armor.warlock.chest"), - "belt": Item("common.items.armor.warlock.belt"), - "hands": Item("common.items.armor.warlock.hand"), - "pants": Item("common.items.armor.warlock.pants"), - "feet": Item("common.items.armor.warlock.foot"), + Armor(Shoulders): Item("common.items.armor.warlock.shoulder"), + Armor(Chest): Item("common.items.armor.warlock.chest"), + Armor(Belt): Item("common.items.armor.warlock.belt"), + Armor(Hands): Item("common.items.armor.warlock.hand"), + Armor(Legs): Item("common.items.armor.warlock.pants"), + Armor(Feet): Item("common.items.armor.warlock.foot"), - "back": Item("common.items.armor.warlock.back"), + Armor(Back): Item("common.items.armor.warlock.back"), - "lantern": Choice([ + Lantern: Choice([ (1.0, Some(Item("common.items.lantern.black_0"))), (2.0, None), ]), - "glider": Item("common.items.glider.glider_purp"), + Glider: Item("common.items.glider.glider_purp"), }) diff --git a/assets/common/loadouts/dungeon/tier-5/warlord.ron b/assets/common/loadouts/dungeon/tier-5/warlord.ron index 66b65cc8ae..2d83fef3fa 100644 --- a/assets/common/loadouts/dungeon/tier-5/warlord.ron +++ b/assets/common/loadouts/dungeon/tier-5/warlord.ron @@ -1,17 +1,17 @@ ({ - "shoulder": Item("common.items.armor.warlord.shoulder"), - "chest": Item("common.items.armor.warlord.chest"), - "belt": Item("common.items.armor.warlord.belt"), - "hands": Item("common.items.armor.warlord.hand"), - "pants": Item("common.items.armor.warlord.pants"), - "feet": Item("common.items.armor.warlord.foot"), + Armor(Shoulders): Item("common.items.armor.warlord.shoulder"), + Armor(Chest): Item("common.items.armor.warlord.chest"), + Armor(Belt): Item("common.items.armor.warlord.belt"), + Armor(Hands): Item("common.items.armor.warlord.hand"), + Armor(Legs): Item("common.items.armor.warlord.pants"), + Armor(Feet): Item("common.items.armor.warlord.foot"), - "back": Item("common.items.armor.warlord.back"), + Armor(Back): Item("common.items.armor.warlord.back"), - "lantern": Choice([ + Lantern: Choice([ (1.0, Some(Item("common.items.lantern.black_0"))), (2.0, None), ]), - "glider": Item("common.items.glider.glider_purp"), + Glider: Item("common.items.glider.glider_purp"), }) diff --git a/assets/common/loadouts/village/guard.ron b/assets/common/loadouts/village/guard.ron index afeb440bf9..9280fd9a65 100644 --- a/assets/common/loadouts/village/guard.ron +++ b/assets/common/loadouts/village/guard.ron @@ -1,12 +1,12 @@ ({ - "shoulder": Item("common.items.armor.leather_plate.shoulder"), - "chest": Item("common.items.armor.leather_plate.chest"), - "belt": Item("common.items.armor.leather_plate.belt"), - "hands": Item("common.items.armor.leather_plate.hand"), - "pants": Item("common.items.armor.leather_plate.pants"), - "feet": Item("common.items.armor.leather_plate.foot"), + Armor(Shoulders): Item("common.items.armor.leather_plate.shoulder"), + Armor(Chest): Item("common.items.armor.leather_plate.chest"), + Armor(Belt): Item("common.items.armor.leather_plate.belt"), + Armor(Hands): Item("common.items.armor.leather_plate.hand"), + Armor(Legs): Item("common.items.armor.leather_plate.pants"), + Armor(Feet): Item("common.items.armor.leather_plate.foot"), - "lantern": Choice([ + Lantern: Choice([ (1.0, Some(Item("common.items.lantern.black_0"))), (2.0, None), ]), diff --git a/assets/common/loadouts/village/merchant.ron b/assets/common/loadouts/village/merchant.ron index 6deb75c0a3..7bbe20362f 100644 --- a/assets/common/loadouts/village/merchant.ron +++ b/assets/common/loadouts/village/merchant.ron @@ -1,13 +1,13 @@ ({ - "shoulder": Item("common.items.armor.twigsflowers.shoulder"), - "chest": Item("common.items.armor.twigsflowers.chest"), - "hands": Item("common.items.armor.twigsflowers.hand"), - "pants": Item("common.items.armor.twigsflowers.pants"), - "feet": Item("common.items.armor.twigsflowers.foot"), - "belt": Item("common.items.armor.twigsflowers.belt"), + Armor(Shoulders): Item("common.items.armor.twigsflowers.shoulder"), + Armor(Chest): Item("common.items.armor.twigsflowers.chest"), + Armor(Hands): Item("common.items.armor.twigsflowers.hand"), + Armor(Legs): Item("common.items.armor.twigsflowers.pants"), + Armor(Feet): Item("common.items.armor.twigsflowers.foot"), + Armor(Belt): Item("common.items.armor.twigsflowers.belt"), - "lantern": Item("common.items.lantern.black_0"), - "neck": Item("common.items.armor.misc.neck.plain_1"), - "ring1": Item("common.items.armor.misc.ring.gold"), - "ring2": Item("common.items.armor.misc.ring.gold"), + Lantern: Item("common.items.lantern.black_0"), + Armor(Neck): Item("common.items.armor.misc.neck.plain_1"), + Armor(Ring1): Item("common.items.armor.misc.ring.gold"), + Armor(Ring2): Item("common.items.armor.misc.ring.gold"), }) diff --git a/assets/common/loadouts/village/villager.ron b/assets/common/loadouts/village/villager.ron index fb520a56e3..4be54001f5 100644 --- a/assets/common/loadouts/village/villager.ron +++ b/assets/common/loadouts/village/villager.ron @@ -1,5 +1,5 @@ ({ - "chest": Choice([ + Armor(Chest): Choice([ (1.0, Some(Item("common.items.armor.misc.chest.worker_green_0"))), (1.0, Some(Item("common.items.armor.misc.chest.worker_green_1"))), (1.0, Some(Item("common.items.armor.misc.chest.worker_red_0"))), @@ -12,10 +12,10 @@ (1.0, Some(Item("common.items.armor.misc.chest.worker_orange_1"))), ]), - "belt": Item("common.items.armor.swift.belt"), - "pants": Item("common.items.armor.misc.pants.worker_blue"), + Armor(Belt): Item("common.items.armor.swift.belt"), + Armor(Legs): Item("common.items.armor.misc.pants.worker_blue"), - "feet": Choice([ + Armor(Feet): Choice([ (1.0, Some(Item("common.items.armor.swift.foot"))), (1.0, Some(Item("common.items.armor.misc.foot.sandals"))), ]), diff --git a/common/src/comp/inventory/loadout_builder.rs b/common/src/comp/inventory/loadout_builder.rs index 1b7bf161bb..70fa635638 100644 --- a/common/src/comp/inventory/loadout_builder.rs +++ b/common/src/comp/inventory/loadout_builder.rs @@ -401,9 +401,9 @@ impl LoadoutBuilder { loadout = loadout.glider(Some(item)); }, EquipSlot::Armor(slot @ ArmorSlot::Bag1) - | EquipSlot::Armor(slot @ ArmorSlot::Bag2) - | EquipSlot::Armor(slot @ ArmorSlot::Bag3) - | EquipSlot::Armor(slot @ ArmorSlot::Bag4) => { + | EquipSlot::Armor(slot @ ArmorSlot::Bag2) + | EquipSlot::Armor(slot @ ArmorSlot::Bag3) + | EquipSlot::Armor(slot @ ArmorSlot::Bag4) => { loadout = loadout.bag(slot, Some(item)); }, }; @@ -760,16 +760,16 @@ impl LoadoutBuilder { #[cfg(test)] mod tests { use super::*; - use crate::comp::{self, Body}; + use crate::{ + assets::{AssetExt, Error}, + comp::{self, Body}, + }; use rand::thread_rng; use strum::IntoEnumIterator; // Testing all configs in loadout with weapons of different toolkinds // // Things that will be catched - invalid assets paths - // FIXME: if item is used in some branch of rng test may miss it - // TODO: as of now there is no rng generation of items. - // Validate assets for all possible branches #[test] fn test_loadout_configs() { let test_weapons = vec![ @@ -852,5 +852,62 @@ mod tests { } #[test] - fn test_loadout_assets() { LoadoutBuilder::from_asset_expect("common.loadouts.test"); } + fn test_loadout_asset() { LoadoutBuilder::from_asset_expect("common.loadouts.test"); } + + #[test] + fn test_all_loadout_assets() { + #[derive(Clone)] + struct LoadoutsList(Vec); + impl assets::Compound for LoadoutsList { + fn load( + cache: &assets::AssetCache, + specifier: &str, + ) -> Result { + let list = cache + .load::(specifier)? + .read() + .iter() + .map(|spec| LoadoutSpec::load_cloned(spec)) + .collect::>()?; + + Ok(LoadoutsList(list)) + } + } + + // It just load everything that could + // TODO: add some checks, e.g. that Armor(Head) key correspond + // to Item with ItemKind Head(_) + fn validate_asset(loadout: LoadoutSpec) { + let spec = loadout.0.clone(); + for (key, specifier) in spec { + match specifier { + ItemSpec::Item(specifier) => { + Item::new_from_asset_expect(&specifier); + }, + ItemSpec::Choice(ref items) => { + for item in items { + match item { + (_, Some(ItemSpec::Item(specifier))) => { + Item::new_from_asset_expect(&specifier); + }, + (_, None) => {}, + (_, _) => { + panic!( + "\n\nChoice of Choice is unimplemented. (Search for \n{:?}: \ + {:#?})\n\n", + key, specifier, + ); + }, + }; + } + }, + }; + } + } + + let loadouts = LoadoutsList::load_expect_cloned("common.loadouts.*").0; + for loadout in loadouts { + validate_asset(loadout); + } + } }