strike speed and strangling unremovable

This commit is contained in:
ntr 2019-06-05 12:44:44 +10:00
parent a8fa6d102e
commit f3636e4e09
3 changed files with 41 additions and 14 deletions

View File

@ -34,10 +34,8 @@
*CLIENT*
reconnect based on time delta
menu footer
fix refresh button
*SERVER*
* std game mode
* time control

View File

@ -202,7 +202,7 @@ impl Item {
}
}
pub fn speed(&self) -> u8 {
pub fn speed(&self) -> u64 {
match self {
Item::Attack => 1,
Item::Stun => 2,

View File

@ -475,6 +475,8 @@ enum EffectCategory {
Buff,
Debuff,
Constant,
Ko,
}
@ -657,8 +659,6 @@ impl Effect {
Effect::Snare => EffectCategory::Debuff,
Effect::Clutch => EffectCategory::Buff,
Effect::Taunt => EffectCategory::Buff,
Effect::Strangle => EffectCategory::Debuff,
Effect::Strangling => EffectCategory::Buff,
// magic
Effect::Hex => EffectCategory::Debuff,
@ -690,6 +690,10 @@ impl Effect {
Effect::Regen => EffectCategory::Buff,
Effect::Siphon => EffectCategory::Debuff,
// can't be purged or purified
Effect::Strangle => EffectCategory::Constant,
Effect::Strangling => EffectCategory::Constant,
// not in game
Effect::Injured => EffectCategory::Debuff,
@ -1324,9 +1328,9 @@ impl Skill {
}
}
pub fn speed(&self) -> u8 {
pub fn speed(&self) -> u64 {
match self {
Skill::StrikeI => u8::max_value(),
Skill::StrikeI => Item::from(Skill::StrikeI).speed().pct(150),
Skill::StrikeII => Skill::StrikeI.speed(),
Skill::StrikeIII => Skill::StrikeI.speed(),
@ -1553,15 +1557,20 @@ fn strangle_tick(source: &mut Construct, target: &mut Construct, mut results: Re
// remove immunity if target ko
if target.is_ko() && !source.is_ko() {
let i = source.effects
if let Some(i) = source.effects
.iter()
.position(|e| e.effect == Effect::Strangling)
.expect("no strangling on construct");
.position(|e| e.effect == Effect::Strangling) {
source.effects.remove(i);
results.push(Resolution::new(source, source)
.event(Event::Removal { effect: Effect::Strangling, construct_effects: target.effects.clone() })
.stages(LogStages::PostOnly));
}
else {
error!("{:?}", results);
println!("{:?}", results);
panic!("no strangling on source");
}
}
return results;
}
@ -2236,4 +2245,24 @@ mod tests {
purify(&mut x.clone(), &mut x, vec![], Skill::PurifyI);
assert!(!x.effects.iter().any(|e| e.effect == Effect::Decay));
}
#[test]
fn strangle_test() {
let mut x = Construct::new()
.named(&"muji".to_string());
let mut y = Construct::new()
.named(&"pretaliation".to_string());
strangle(&mut x, &mut y, vec![], Skill::StrangleI);
assert!(y.effects.iter().any(|e| e.effect == Effect::Strangle));
assert!(x.effects.iter().any(|e| e.effect == Effect::Strangling));
// ensure can't be removed
purify(&mut x, &mut y, vec![], Skill::PurifyI);
assert!(y.effects.iter().any(|e| e.effect == Effect::Strangle));
purge(&mut x.clone(), &mut x, vec![], Skill::PurgeI);
assert!(x.effects.iter().any(|e| e.effect == Effect::Strangling));
}
}