From 1c3fdf59c7bc939b4445decb43a0d40be7db29f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Korg=C3=B3l?= Date: Sun, 5 Jul 2020 16:00:51 +0200 Subject: [PATCH 1/2] Fix loot table (again) --- assets/common/loot_table.ron | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/common/loot_table.ron b/assets/common/loot_table.ron index 17891fbf7b..61f7d939cd 100644 --- a/assets/common/loot_table.ron +++ b/assets/common/loot_table.ron @@ -7,6 +7,8 @@ // miscellaneous (0.4, "common.items.velorite"), (0.6, "common.items.veloritefrag"), + (0.6, "common.items.cheese"), + (0.6, "common.items.apple"), (1.5, "common.items.potion_minor"), (0.5, "common.items.collar"), (0.5, "common.items.bomb_pile"), @@ -79,7 +81,6 @@ (0.2, "common.items.armor.pants.cloth_blue_0"), (0.2, "common.items.armor.pants.cloth_green_0"), (0.2, "common.items.armor.pants.cloth_purple_0"), - (0.15, "common.items.armor.pants.green_0"), (0.15, "common.items.armor.pants.leather_0"), (0.1, "common.items.armor.pants.steel_0"), (0.05, "common.items.armor.pants.plate_green_0"), From 726aba9997fecae8f2e0c8e02b2ba2013f775cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Korg=C3=B3l?= Date: Sun, 5 Jul 2020 18:49:15 +0200 Subject: [PATCH 2/2] Add a test for the loot table's validity --- common/src/comp/inventory/item/lottery.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/common/src/comp/inventory/item/lottery.rs b/common/src/comp/inventory/item/lottery.rs index ea202aef5d..b1f94769b1 100644 --- a/common/src/comp/inventory/item/lottery.rs +++ b/common/src/comp/inventory/item/lottery.rs @@ -44,4 +44,27 @@ impl Lottery { .unwrap_or_else(|i| i.saturating_sub(1))] .1 } + + pub fn iter(&self) -> impl Iterator { self.items.iter() } +} + +#[cfg(test)] +mod tests { + use crate::{ + assets, + comp::inventory::item::{lottery::Lottery, Item}, + }; + #[test] + fn test_loot_table() { + let test = assets::load_expect::>("common.loot_table"); + let test = test; + + for (_, item) in test.iter() { + assert!( + assets::load::(item).is_ok(), + "Invalid loot table item '{}'", + item + ); + } + } }