From fc01e9ea6865b361de5a061dbe683d7803ed99a3 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 12 Feb 2021 16:01:49 -0500 Subject: [PATCH] Handedness of weapons affects power and speed. --- .../items/weapons/hammer/bronze_hammer-1.ron | 2 +- common/src/comp/inventory/item/tool.rs | 25 +++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/assets/common/items/weapons/hammer/bronze_hammer-1.ron b/assets/common/items/weapons/hammer/bronze_hammer-1.ron index 278fa804a2..e8f040fee9 100644 --- a/assets/common/items/weapons/hammer/bronze_hammer-1.ron +++ b/assets/common/items/weapons/hammer/bronze_hammer-1.ron @@ -3,7 +3,7 @@ ItemDef( description: "The entire head of this club is forged from bronze alloy.", kind: Tool(( kind: Hammer, - hands: TwoHand, + hands: OneHand, stats: ( equip_time_millis: 500, power: 1.0, diff --git a/common/src/comp/inventory/item/tool.rs b/common/src/comp/inventory/item/tool.rs index f7d1809bd8..d473aa3a53 100644 --- a/common/src/comp/inventory/item/tool.rs +++ b/common/src/comp/inventory/item/tool.rs @@ -41,6 +41,22 @@ pub struct Stats { speed: f32, } +impl From<&Tool> for Stats { + fn from(tool: &Tool) -> Self { + let raw_stats = tool.stats; + let (power, speed) = match tool.hands { + Hands::OneHand => (0.67, 1.33), + Hands::TwoHand => (1.5, 0.75), + }; + Self { + equip_time_millis: raw_stats.equip_time_millis, + power: raw_stats.power * power, + poise_strength: raw_stats.poise_strength, + speed: raw_stats.speed * speed, + } + } +} + #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Tool { pub kind: ToolKind, @@ -118,13 +134,8 @@ pub struct AbilitySet { impl AbilitySet { pub fn modified_by_tool(self, tool: &Tool) -> Self { - self.map(|a| { - a.adjusted_by_stats( - tool.base_power(), - tool.base_poise_strength(), - tool.base_speed(), - ) - }) + let stats: Stats = tool.into(); + self.map(|a| a.adjusted_by_stats(stats.power, stats.poise_strength, stats.speed)) } }