Merge branch 'master' of ssh://mnml.gg:40022/~/mnml
This commit is contained in:
commit
8456956f8b
@ -204,23 +204,44 @@ impl Item {
|
||||
|
||||
pub fn speed(&self) -> u8 {
|
||||
match self {
|
||||
Item::Red => 3,
|
||||
Item::Green => 2,
|
||||
Item::Blue => 1,
|
||||
|
||||
Item::Attack => 1,
|
||||
Item::Stun => 2,
|
||||
Item::Block => 3,
|
||||
Item::Buff => 4,
|
||||
Item::Buff |
|
||||
Item::Debuff => 4,
|
||||
|
||||
_ => {
|
||||
let combos = get_combos();
|
||||
let combo = combos.iter().find(|c| c.item == *self)
|
||||
.unwrap_or_else(|| panic!("unable to find components for {:?}", self));
|
||||
return combo.components.iter().fold(0, |acc, c| acc + c.speed());
|
||||
},
|
||||
|
||||
let mut colour_speed = 0;
|
||||
let mut skill_speed = 0;
|
||||
let mut component_speed = 0;
|
||||
|
||||
combo.components.iter().for_each(|unit| {
|
||||
colour_speed += match unit {
|
||||
Item::Red => 3,
|
||||
Item::Green => 2,
|
||||
Item::Blue => 1,
|
||||
_ => 0,
|
||||
};
|
||||
skill_speed += match unit {
|
||||
Item::Attack => 1,
|
||||
Item::Stun => 2,
|
||||
Item::Block => 3,
|
||||
Item::Buff |
|
||||
Item::Debuff => 4,
|
||||
_ => 0,
|
||||
};
|
||||
if colour_speed == 0 && skill_speed == 0 {
|
||||
component_speed = unit.speed();
|
||||
}
|
||||
});
|
||||
if component_speed > 0 { return component_speed };
|
||||
return 24 + colour_speed * skill_speed
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub fn effect(&self) -> Option<ItemEffect> {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user