Handedness of weapons affects power and speed.

This commit is contained in:
Sam 2021-02-12 16:01:49 -05:00
parent 582c3f8459
commit fc01e9ea68
2 changed files with 19 additions and 8 deletions

View File

@ -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,

View File

@ -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<T> {
impl AbilitySet<CharacterAbility> {
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))
}
}