mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Make ItemSpec and Hands untagged
This commit is contained in:
parent
13324700ba
commit
11bf16e3d7
@ -9,22 +9,22 @@
|
||||
Asset("test.loadout.ok.just_butterfly_gliders"),
|
||||
Asset("test.loadout.ok.just_lanterns"),
|
||||
]),
|
||||
active_hands: Choice([
|
||||
(1, InHands((
|
||||
Item("common.items.weapons.sword.caladbolg"),
|
||||
active_hands: [
|
||||
(1, (
|
||||
"common.items.weapons.sword.caladbolg",
|
||||
None,
|
||||
))),
|
||||
(1, InHands((
|
||||
Item("common.items.weapons.bow.sagitta"),
|
||||
)),
|
||||
(1, (
|
||||
"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"),
|
||||
))),
|
||||
]),
|
||||
)),
|
||||
(1, (
|
||||
"common.items.weapons.hammer_1h.orichalcum-0",
|
||||
"common.items.weapons.hammer_1h.orichalcum-0",
|
||||
)),
|
||||
(1, (
|
||||
"common.items.weapons.axe_1h.orichalcum-0",
|
||||
"common.items.weapons.shield.shield_1",
|
||||
)),
|
||||
],
|
||||
)
|
||||
|
@ -1,12 +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")),
|
||||
]),
|
||||
)),
|
||||
head: "common.items.armor.cultist.bandana",
|
||||
active_hands: (
|
||||
"common.items.weapons.axe_1h.orichalcum-0",
|
||||
[
|
||||
(1, "common.items.weapons.hammer_1h.orichalcum-0"),
|
||||
(1, "common.items.weapons.axe_1h.orichalcum-0"),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
@ -3,32 +3,32 @@
|
||||
#![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"),
|
||||
head: "common.items.npc_armor.biped_small.myrmidon.head.hoplite",
|
||||
neck: "common.items.armor.misc.neck.gem_of_resilience",
|
||||
shoulders: "common.items.armor.twigsflowers.shoulder",
|
||||
chest: "common.items.armor.twigsflowers.chest",
|
||||
gloves: "common.items.armor.twigsflowers.hand",
|
||||
ring1: "common.items.armor.misc.ring.gold",
|
||||
ring2: "common.items.armor.misc.ring.gold",
|
||||
back: "common.items.armor.misc.back.dungeon_purple",
|
||||
belt: "common.items.armor.twigsflowers.belt",
|
||||
legs: "common.items.armor.twigsflowers.pants",
|
||||
feet: "common.items.armor.twigsflowers.foot",
|
||||
tabard: "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"),
|
||||
bag1: "common.items.armor.misc.bag.tiny_leather_pouch",
|
||||
bag2: "common.items.armor.misc.bag.tiny_leather_pouch",
|
||||
bag3: "common.items.armor.misc.bag.tiny_leather_pouch",
|
||||
bag4: "common.items.armor.misc.bag.tiny_leather_pouch",
|
||||
lantern: "common.items.lantern.black_0",
|
||||
glider: "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"),
|
||||
active_hands: (
|
||||
"common.items.weapons.sword_1h.bloodsteel-0",
|
||||
"common.items.weapons.sword_1h.bloodsteel-0",
|
||||
),
|
||||
inactive_hands: (
|
||||
"common.items.weapons.sceptre.sceptre_velorite_0",
|
||||
None,
|
||||
)),
|
||||
),
|
||||
)
|
||||
|
@ -1,8 +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")),
|
||||
]),
|
||||
glider: [
|
||||
(1, "common.items.glider.moth"),
|
||||
(1, "common.items.glider.morpho"),
|
||||
(1, "common.items.glider.monarch"),
|
||||
],
|
||||
)
|
||||
|
@ -1,17 +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"),
|
||||
active_hands: [
|
||||
(1, (
|
||||
"common.items.weapons.axe_1h.orichalcum-0",
|
||||
"common.items.weapons.axe_1h.orichalcum-0",
|
||||
)),
|
||||
(1, (
|
||||
"common.items.weapons.hammer_1h.orichalcum-0",
|
||||
"common.items.weapons.axe_1h.orichalcum-0",
|
||||
)),
|
||||
(1, (
|
||||
"common.items.weapons.sword.cultist",
|
||||
None,
|
||||
))),
|
||||
]),
|
||||
)),
|
||||
],
|
||||
)
|
||||
|
@ -1,21 +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")),
|
||||
]),
|
||||
ring1: [
|
||||
(1, "common.items.armor.misc.ring.amethyst"),
|
||||
(1, "common.items.armor.misc.ring.diamond"),
|
||||
(1, "common.items.armor.misc.ring.emerald"),
|
||||
(1, "common.items.armor.misc.ring.gold"),
|
||||
(1, "common.items.armor.misc.ring.ruby"),
|
||||
(1, "common.items.armor.misc.ring.sapphire"),
|
||||
(1, "common.items.armor.misc.ring.topaz"),
|
||||
],
|
||||
ring2: [
|
||||
(1, "common.items.armor.misc.ring.amethyst"),
|
||||
(1, "common.items.armor.misc.ring.diamond"),
|
||||
(1, "common.items.armor.misc.ring.emerald"),
|
||||
(1, "common.items.armor.misc.ring.gold"),
|
||||
(1, "common.items.armor.misc.ring.ruby"),
|
||||
(1, "common.items.armor.misc.ring.sapphire"),
|
||||
(1, "common.items.armor.misc.ring.topaz"),
|
||||
],
|
||||
)
|
||||
|
@ -1,10 +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"),
|
||||
shoulders: "common.items.armor.hide.dragonscale.shoulder",
|
||||
chest: "common.items.armor.hide.dragonscale.chest",
|
||||
gloves: "common.items.armor.hide.dragonscale.hand",
|
||||
back: "common.items.armor.hide.dragonscale.back",
|
||||
belt: "common.items.armor.hide.dragonscale.belt",
|
||||
legs: "common.items.armor.hide.dragonscale.pants",
|
||||
feet: "common.items.armor.hide.dragonscale.foot",
|
||||
)
|
||||
|
@ -1,11 +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")),
|
||||
]),
|
||||
lantern: [
|
||||
(1, "common.items.lantern.black_0"),
|
||||
(1, "common.items.lantern.blue_0"),
|
||||
(1, "common.items.lantern.green_0"),
|
||||
(1, "common.items.lantern.red_0"),
|
||||
(1, "common.items.lantern.geode_purp"),
|
||||
(1, "common.items.boss_drops.lantern"),
|
||||
],
|
||||
)
|
||||
|
@ -1,10 +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"),
|
||||
shoulders: "common.items.armor.mail.orichalcum.shoulder",
|
||||
chest: "common.items.armor.mail.orichalcum.chest",
|
||||
gloves: "common.items.armor.mail.orichalcum.hand",
|
||||
back: "common.items.armor.mail.orichalcum.back",
|
||||
belt: "common.items.armor.mail.orichalcum.belt",
|
||||
legs: "common.items.armor.mail.orichalcum.pants",
|
||||
feet: "common.items.armor.mail.orichalcum.foot",
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
#![enable(implicit_some)]
|
||||
(
|
||||
ring1: Item("common.items.armor.cultist.ring"),
|
||||
ring2: Item("common.items.armor.cultist.ring"),
|
||||
ring1: "common.items.armor.cultist.ring",
|
||||
ring2: "common.items.armor.cultist.ring",
|
||||
)
|
||||
|
@ -56,12 +56,14 @@ mod loadout_v2 {
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
#[serde(untagged)]
|
||||
pub enum ItemSpecNew {
|
||||
Item(String),
|
||||
Choice(Vec<(Weight, Option<ItemSpecNew>)>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
#[serde(untagged)]
|
||||
pub enum Hands {
|
||||
/// Allows to specify one pair
|
||||
// TODO: add link to tests with example
|
||||
|
@ -36,15 +36,8 @@ pub enum ValidationError {
|
||||
Loop(Vec<String>),
|
||||
}
|
||||
|
||||
// TODO: serde un-tag?
|
||||
// <https://serde.rs/enum-representations.html>
|
||||
//
|
||||
// Pros:
|
||||
// + less noise
|
||||
//
|
||||
// Cons:
|
||||
// - limits us to using different types for each variant
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(untagged)]
|
||||
enum ItemSpec {
|
||||
Item(String),
|
||||
Choice(Vec<(Weight, Option<ItemSpec>)>),
|
||||
@ -93,6 +86,7 @@ impl ItemSpec {
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(untagged)]
|
||||
enum Hands {
|
||||
/// Allows to specify one pair
|
||||
// TODO: add link to tests with example
|
||||
|
Loading…
Reference in New Issue
Block a user