mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added test for each recipe being reachable. Made new recipes reachable.
This commit is contained in:
parent
b40a14ae62
commit
c2604ef527
@ -7094,11 +7094,13 @@
|
|||||||
Simple("common.items.recipes.equipment.moderate"): "recipe-equipment-moderate",
|
Simple("common.items.recipes.equipment.moderate"): "recipe-equipment-moderate",
|
||||||
Simple("common.items.recipes.equipment.advanced"): "recipe-equipment-advanced",
|
Simple("common.items.recipes.equipment.advanced"): "recipe-equipment-advanced",
|
||||||
Simple("common.items.recipes.unique.abyssal_gorget"): "recipe-unique-abyssal_gorget",
|
Simple("common.items.recipes.unique.abyssal_gorget"): "recipe-unique-abyssal_gorget",
|
||||||
|
Simple("common.items.recipes.unique.abyssal_ring"): "recipe-unique-abyssal_ring",
|
||||||
Simple("common.items.recipes.unique.mindflayer_spellbag"): "recipe-unique-mindflayer_spellbag",
|
Simple("common.items.recipes.unique.mindflayer_spellbag"): "recipe-unique-mindflayer_spellbag",
|
||||||
Simple("common.items.recipes.unique.polaris"): "recipe-unique-polaris",
|
Simple("common.items.recipes.unique.polaris"): "recipe-unique-polaris",
|
||||||
Simple("common.items.recipes.unique.seashell_necklace"): "recipe-unique-seashell_necklace",
|
Simple("common.items.recipes.unique.seashell_necklace"): "recipe-unique-seashell_necklace",
|
||||||
Simple("common.items.recipes.unique.troll_hide_pack"): "recipe-unique-troll_hide_pack",
|
Simple("common.items.recipes.unique.troll_hide_pack"): "recipe-unique-troll_hide_pack",
|
||||||
Simple("common.items.recipes.unique.winged_coronet"): "recipe-unique-winged_coronet",
|
Simple("common.items.recipes.unique.winged_coronet"): "recipe-unique-winged_coronet",
|
||||||
|
Simple("common.items.recipes.unique.delvers_lamp"): "recipe-unique-delvers_lamp",
|
||||||
Simple("common.items.recipes.charms"): "recipe-charms",
|
Simple("common.items.recipes.charms"): "recipe-charms",
|
||||||
Simple("common.items.recipes.explosives"): "recipe-explosives",
|
Simple("common.items.recipes.explosives"): "recipe-explosives",
|
||||||
Simple("common.items.recipes.food"): "recipe-food",
|
Simple("common.items.recipes.food"): "recipe-food",
|
||||||
|
@ -11,6 +11,7 @@ ItemDef(
|
|||||||
"orichalcum_hands",
|
"orichalcum_hands",
|
||||||
"orichalcum_pants",
|
"orichalcum_pants",
|
||||||
"orichalcum_shoulder",
|
"orichalcum_shoulder",
|
||||||
|
"orichalcum_head",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
quality: Common,
|
quality: Common,
|
||||||
|
@ -56,6 +56,7 @@ ItemDef(
|
|||||||
"healing_sceptre",
|
"healing_sceptre",
|
||||||
"bronze_weapons",
|
"bronze_weapons",
|
||||||
"wood_weapons",
|
"wood_weapons",
|
||||||
|
"shield",
|
||||||
// Materials
|
// Materials
|
||||||
"tin_ingot",
|
"tin_ingot",
|
||||||
"copper_ingot",
|
"copper_ingot",
|
||||||
|
11
assets/common/items/recipes/unique/abyssal_ring.ron
Normal file
11
assets/common/items/recipes/unique/abyssal_ring.ron
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
ItemDef(
|
||||||
|
legacy_name: "",
|
||||||
|
legacy_description: "",
|
||||||
|
kind: RecipeGroup(
|
||||||
|
recipes: [
|
||||||
|
"abyssal_ring",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
quality: Common,
|
||||||
|
tags: [],
|
||||||
|
)
|
11
assets/common/items/recipes/unique/delvers_lamp.ron
Normal file
11
assets/common/items/recipes/unique/delvers_lamp.ron
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
ItemDef(
|
||||||
|
legacy_name: "",
|
||||||
|
legacy_description: "",
|
||||||
|
kind: RecipeGroup(
|
||||||
|
recipes: [
|
||||||
|
"delvers_lamp",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
quality: Common,
|
||||||
|
tags: [],
|
||||||
|
)
|
@ -5,4 +5,5 @@
|
|||||||
(2.0, Item("common.items.consumable.potion_minor")),
|
(2.0, Item("common.items.consumable.potion_minor")),
|
||||||
// Gold
|
// Gold
|
||||||
(2.0, MultiDrop(Item("common.items.utility.coins"), 25, 50)),
|
(2.0, MultiDrop(Item("common.items.utility.coins"), 25, 50)),
|
||||||
|
(0.5, Item("common.items.recipes.unique.delvers_lamp")),
|
||||||
]
|
]
|
@ -6,6 +6,7 @@
|
|||||||
(0.5, Item("common.items.crafting_ing.pearl")),
|
(0.5, Item("common.items.crafting_ing.pearl")),
|
||||||
(0.25, Item("common.items.recipes.unique.seashell_necklace")),
|
(0.25, Item("common.items.recipes.unique.seashell_necklace")),
|
||||||
(0.25, Item("common.items.recipes.unique.winged_coronet")),
|
(0.25, Item("common.items.recipes.unique.winged_coronet")),
|
||||||
|
(0.25, Item("common.items.recipes.unique.abyssal_ring")),
|
||||||
]),
|
]),
|
||||||
Lottery([
|
Lottery([
|
||||||
(0.6, Nothing),
|
(0.6, Nothing),
|
||||||
|
@ -38,6 +38,8 @@ recipe-equipment-advanced = Advanced Equipment Recipes
|
|||||||
.desc = Advanced Equipment Recipes
|
.desc = Advanced Equipment Recipes
|
||||||
recipe-unique-abyssal_gorget = Abyssal Gorget Recipe
|
recipe-unique-abyssal_gorget = Abyssal Gorget Recipe
|
||||||
.desc = Abyssal Gorget Recipe
|
.desc = Abyssal Gorget Recipe
|
||||||
|
recipe-unique-abyssal_ring = Abyssal Ring Recipe
|
||||||
|
.desc = Abyssal Ring Recipe
|
||||||
recipe-unique-mindflayer_spellbag = Mindflayer Spellbag Recipe
|
recipe-unique-mindflayer_spellbag = Mindflayer Spellbag Recipe
|
||||||
.desc = Mindflayer Spellbag Recipe
|
.desc = Mindflayer Spellbag Recipe
|
||||||
recipe-unique-polaris = Polaris Recipe
|
recipe-unique-polaris = Polaris Recipe
|
||||||
@ -48,6 +50,8 @@ recipe-unique-troll_hide_pack = Troll Hide Pack Recipe
|
|||||||
.desc = Troll Hide Pack Recipe
|
.desc = Troll Hide Pack Recipe
|
||||||
recipe-unique-winged_coronet = Winged Coronet Recipe
|
recipe-unique-winged_coronet = Winged Coronet Recipe
|
||||||
.desc = Winged Coronet Recipe
|
.desc = Winged Coronet Recipe
|
||||||
|
recipe-unique-delvers_lamp = Delver's Lamp Recipe
|
||||||
|
.desc = Delver's Lamp Recipe
|
||||||
recipe-charms = Charms Recipes
|
recipe-charms = Charms Recipes
|
||||||
.desc = Charms Recipes
|
.desc = Charms Recipes
|
||||||
recipe-explosives = Explosives Recipes
|
recipe-explosives = Explosives Recipes
|
||||||
|
@ -89,28 +89,69 @@ mod tests {
|
|||||||
comp::item::{Item, ItemKind},
|
comp::item::{Item, ItemKind},
|
||||||
recipe::{complete_recipe_book, default_component_recipe_book},
|
recipe::{complete_recipe_book, default_component_recipe_book},
|
||||||
};
|
};
|
||||||
|
use hashbrown::HashSet;
|
||||||
|
|
||||||
fn valid_recipe(recipe: &str) -> bool {
|
fn load_recipe_items() -> Vec<Item> {
|
||||||
|
Item::new_from_asset_glob("common.items.recipes.*").expect("The directory should exist")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn load_recipe_list() -> HashSet<String> {
|
||||||
let recipe_book = complete_recipe_book();
|
let recipe_book = complete_recipe_book();
|
||||||
let component_recipe_book = default_component_recipe_book();
|
let component_recipe_book = default_component_recipe_book();
|
||||||
|
|
||||||
recipe_book.read().keys().any(|key| key == recipe)
|
recipe_book
|
||||||
|| component_recipe_book
|
.read()
|
||||||
|
.keys()
|
||||||
|
.cloned()
|
||||||
|
.chain(
|
||||||
|
component_recipe_book
|
||||||
.read()
|
.read()
|
||||||
.iter()
|
.iter()
|
||||||
.any(|(_, cr)| cr.recipe_book_key == recipe)
|
.map(|(_, cr)| &cr.recipe_book_key)
|
||||||
|
.cloned(),
|
||||||
|
)
|
||||||
|
.collect::<HashSet<_>>()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn valid_recipe(recipe: &str) -> bool {
|
||||||
|
let recipe_list = load_recipe_list();
|
||||||
|
recipe_list.contains(recipe)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Verify that all recipes in recipe items point to a valid recipe
|
/// Verify that all recipes in recipe items point to a valid recipe
|
||||||
#[test]
|
#[test]
|
||||||
fn validate_recipes() {
|
fn validate_recipes() {
|
||||||
let groups = Item::new_from_asset_glob("common.items.recipes.*")
|
let recipe_items = load_recipe_items();
|
||||||
.expect("The directory should exist");
|
for item in recipe_items {
|
||||||
for group in groups {
|
let ItemKind::RecipeGroup { recipes } = &*item.kind() else {
|
||||||
let ItemKind::RecipeGroup { recipes } = &*group.kind() else {
|
|
||||||
panic!("Expected item to be of kind RecipeGroup")
|
panic!("Expected item to be of kind RecipeGroup")
|
||||||
};
|
};
|
||||||
assert!(recipes.iter().all(|r| valid_recipe(r)));
|
assert!(recipes.iter().all(|r| valid_recipe(r)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Verify that all recipes are contained in a recipe item
|
||||||
|
#[test]
|
||||||
|
fn recipes_reachable() {
|
||||||
|
let recipe_items = load_recipe_items();
|
||||||
|
let reachable_recipes = recipe_items
|
||||||
|
.iter()
|
||||||
|
.flat_map(|i| {
|
||||||
|
if let ItemKind::RecipeGroup { recipes } = &*i.kind() {
|
||||||
|
recipes.to_vec()
|
||||||
|
} else {
|
||||||
|
Vec::new()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<HashSet<_>>();
|
||||||
|
|
||||||
|
let recipe_list = load_recipe_list();
|
||||||
|
|
||||||
|
for recipe in recipe_list.iter() {
|
||||||
|
assert!(
|
||||||
|
reachable_recipes.contains(recipe),
|
||||||
|
"{recipe} was not found in a recipe item"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user