From dd2deb971b5b94a765cc5bb73684aa6855e89da4 Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 17 Jul 2024 20:54:28 -0400 Subject: [PATCH] Fix modular weapon parsing --- README.md | 5 +- config/config.toml | 146 ++++++++++++++++++++++++++++++++++++++++++++- src/config.rs | 25 +++----- 3 files changed, 157 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 199c2b8..acc21db 100644 --- a/README.md +++ b/README.md @@ -100,14 +100,15 @@ announcement = "I love cheese! I am at {location}." # The buy_prices and sell_prices tables are required. The keys are item definition IDs and the # values are the price in coins. You may type in-game "/give_item common.items." and press Tab to # explore the item definition IDs. Then just leave off the "common.items." part in this file. - [buy_prices] "food.cheese" = 50 [sell_prices] "consumable.potion_minor" = 150 -# Modular weapons listed by that components: "material|primary|secondary". +# Modular weapons are listed by their components: "material|primary|secondary". The material is +# snake_cased and you can omit the "common.items.modular.weapon.[primary|secondary]" from the +# modular components. "iron|sword.greatsword|sword.long" = 1_000 ``` diff --git a/config/config.toml b/config/config.toml index 20721b5..a8d5cd3 100644 --- a/config/config.toml +++ b/config/config.toml @@ -7,4 +7,148 @@ orientation = 0 [sell_prices] "consumable.potion_minor" = 150 -"iron|sword.greatsword|sword.long" = 1_000 + +# Modular Weapons +## Axes +"orichalcum|axe.axe|axe.long" = 45_000 +"orichalcum|axe.axe|axe.medium" = 45_000 +"orichalcum|axe.axe|axe.short" = 45_000 + +"orichalcum|axe.greataxe|axe.long" = 45_000 + +"orichalcum|axe.poleaxe|axe.long" = 45_000 + +"orichalcum|axe.battleaxe|axe.long" = 45_000 +"orichalcum|axe.battleaxe|axe.medium" = 45_000 +"orichalcum|axe.battleaxe|axe.short" = 45_000 + +"orichalcum|axe.jagged|axe.long" = 45_000 +"orichalcum|axe.jagged|axe.medium" = 45_000 +"orichalcum|axe.jagged|axe.short" = 45_000 + +"orichalcum|axe.labrys|axe.long" = 45_000 + +"orichalcum|axe.ornate|axe.long" = 45_000 +"orichalcum|axe.ornate|axe.medium" = 45_000 +"orichalcum|axe.ornate|axe.short" = 45_000 + +## Swords +"orichalcum|sword.greatsword|sword.long" = 45_000 + +"orichalcum|sword.katana|sword.long" = 45_000 +"orichalcum|sword.katana|sword.medium" = 45_000 +"orichalcum|sword.katana|sword.short" = 45_000 + +"orichalcum|sword.lonsgword|sword.long" = 45_000 + +"orichalcum|sword.ornate|sword.long" = 45_000 +"orichalcum|sword.ornate|sword.medium" = 45_000 +"orichalcum|sword.ornate|sword.short" = 45_000 + +"orichalcum|sword.sabre|sword.long" = 45_000 +"orichalcum|sword.sabre|sword.medium" = 45_000 +"orichalcum|sword.sabre|sword.short" = 45_000 + +"orichalcum|sword.sawblade|sword.long" = 45_000 +"orichalcum|sword.sawblade|sword.medium" = 45_000 +"orichalcum|sword.sawblade|sword.short" = 45_000 + +"orichalcum|sword.zweihander|sword.long" = 45_000 + +## Hammers +"orichalcum|hammer.hammer|hammer.long" = 45_000 +"orichalcum|hammer.hammer|hammer.medium" = 45_000 +"orichalcum|hammer.hammer|hammer.short" = 45_000 + +"orichalcum|hammer.ornate|hammer.long" = 45_000 +"orichalcum|hammer.ornate|hammer.medium" = 45_000 +"orichalcum|hammer.ornate|hammer.short" = 45_000 + +"orichalcum|hammer.greathammer|hammer.long" = 45_000 + +"orichalcum|hammer.maul|hammer.long" = 45_000 + +"orichalcum|hammer.warhammer|hammer.long" = 45_000 +"orichalcum|hammer.warhammer|hammer.medium" = 45_000 +"orichalcum|hammer.warhammer|hammer.short" = 45_000 + +"orichalcum|hammer.spikedmace|hammer.long" = 45_000 +"orichalcum|hammer.spikedmace|hammer.medium" = 45_000 +"orichalcum|hammer.spikedmace|hammer.short" = 45_000 + +"orichalcum|hammer.greatmace|hammer.long" = 45_000 + +## Bows +"eldwood|bow.bow|bow.long" = 20_000 +"eldwood|bow.composite|bow.long" = 20_000 +"eldwood|bow.greatbow|bow.long" = 20_000 +"eldwood|bow.longbow|bow.long" = 20_000 +"eldwood|bow.ornate|bow.long" = 20_000 +"eldwood|bow.shortbow|bow.long" = 20_000 +"eldwood|bow.warbow|bow.long" = 20_000 + +"eldwood|bow.bow|bow.medium" = 20_000 +"eldwood|bow.composite|bow.medium" = 20_000 +"eldwood|bow.greatbow|bow.medium" = 20_000 +"eldwood|bow.longbow|bow.medium" = 20_000 +"eldwood|bow.ornate|bow.medium" = 20_000 +"eldwood|bow.shortbow|bow.medium" = 20_000 +"eldwood|bow.warbow|bow.medium" = 20_000 + +"eldwood|bow.bow|bow.short" = 20_000 +"eldwood|bow.composite|bow.short" = 20_000 +"eldwood|bow.greatbow|bow.short" = 20_000 +"eldwood|bow.longbow|bow.short" = 20_000 +"eldwood|bow.ornate|bow.short" = 20_000 +"eldwood|bow.shortbow|bow.short" = 20_000 +"eldwood|bow.warbow|bow.short" = 20_000 + +## Staffs +"eldwood|staff.brand|staff.heavy" = 20_000 +"eldwood|staff.grandstaff|staff.heavy" = 20_000 +"eldwood|staff.longpole|staff.heavy" = 20_000 +"eldwood|staff.ornate|staff.heavy" = 20_000 +"eldwood|staff.pole|staff.heavy" = 20_000 +"eldwood|staff.rod|staff.heavy" = 20_000 +"eldwood|staff.staff|staff.heavy" = 20_000 + +"eldwood|staff.brand|staff.medium" = 20_000 +"eldwood|staff.grandstaff|staff.medium" = 20_000 +"eldwood|staff.longpole|staff.medium" = 20_000 +"eldwood|staff.ornate|staff.medium" = 20_000 +"eldwood|staff.pole|staff.medium" = 20_000 +"eldwood|staff.rod|staff.medium" = 20_000 +"eldwood|staff.staff|staff.medium" = 20_000 + +"eldwood|staff.brand|staff.light" = 20_000 +"eldwood|staff.grandstaff|staff.light" = 20_000 +"eldwood|staff.longpole|staff.light" = 20_000 +"eldwood|staff.ornate|staff.light" = 20_000 +"eldwood|staff.pole|staff.light" = 20_000 +"eldwood|staff.rod|staff.light" = 20_000 +"eldwood|staff.staff|staff.light" = 20_000 + +## Sceptres +"eldwood|sceptre.arbor|sceptre.heavy" = 20_000 +"eldwood|sceptre.cane|sceptre.heavy" = 20_000 +"eldwood|sceptre.crook|sceptre.heavy" = 20_000 +"eldwood|sceptre.crozier|sceptre.heavy" = 20_000 +"eldwood|sceptre.grandsceptre|sceptre.heavy" = 20_000 +"eldwood|sceptre.ornate|sceptre.heavy" = 20_000 +"eldwood|sceptre.sceptre|sceptre.heavy" = 20_000 + +"eldwood|sceptre.arbor|sceptre.medium" = 20_000 +"eldwood|sceptre.cane|sceptre.medium" = 20_000 +"eldwood|sceptre.crook|sceptre.medium" = 20_000 +"eldwood|sceptre.crozier|sceptre.medium" = 20_000 +"eldwood|sceptre.grandsceptre|sceptre.medium" = 20_000 +"eldwood|sceptre.ornate|sceptre.medium" = 20_000 +"eldwood|sceptre.sceptre|sceptre.medium" = 20_000 + +"eldwood|sceptre.arbor|scpetre.light" = 20_000 +"eldwood|sceptre.cane|scpetre.light" = 20_000 +"eldwood|sceptre.crook|scpetre.light" = 20_000 +"eldwood|sceptre.crozier|scpetre.light" = 20_000 +"eldwood|sceptre.grandsceptre|scpetre.light" = 20_000 +"eldwood|sceptre.ornate|scpetre.light" = 20_000 +"eldwood|sceptre.sceptre|scpetre.light" = 20_000 diff --git a/src/config.rs b/src/config.rs index 84c916e..50152d7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -77,24 +77,17 @@ impl<'de> Visitor<'de> for PriceListVisitor { primary.insert_str(0, "common.items.modular.weapon.primary."); secondary.insert_str(0, "common.items.modular.weapon.secondary."); - let material = ItemDefinitionIdOwned::Simple( - material - .asset_identifier() - .ok_or_else(|| { - de::Error::custom(format!( - "{:?} is not a valid material for modular crafted items", - material - )) - })? - .to_string(), - ); - ItemDefinitionIdOwned::Modular { pseudo_base: "veloren.core.pseudo_items.modular.tool".to_string(), - components: vec![ItemDefinitionIdOwned::Compound { - simple_base: primary, - components: vec![ItemDefinitionIdOwned::Simple(secondary), material], - }], + components: vec![ + ItemDefinitionIdOwned::Compound { + simple_base: primary, + components: vec![ItemDefinitionIdOwned::Simple( + material.asset_identifier().unwrap().to_string(), + )], + }, + ItemDefinitionIdOwned::Simple(secondary), + ], } } [simple] => {