This commit is contained in:
ntr 2019-03-22 17:20:49 +11:00
parent 10848b1239
commit 8bdf2d576d
4 changed files with 48 additions and 9 deletions

View File

@ -301,6 +301,10 @@ impl Cryp {
self.effects.iter().any(|s| s.effect == Effect::Invert) self.effects.iter().any(|s| s.effect == Effect::Invert)
} }
pub fn is_clutch(&self) -> bool {
self.effects.iter().any(|s| s.effect == Effect::Clutch)
}
pub fn available_skills(&self) -> Vec<&CrypSkill> { pub fn available_skills(&self) -> Vec<&CrypSkill> {
self.skills.iter() self.skills.iter()
.filter(|s| s.cd.is_none()) .filter(|s| s.cd.is_none())
@ -434,6 +438,13 @@ impl Cryp {
self.hp.value self.hp.value
} }
fn reduce_hp(&mut self, amount: u64) {
self.hp.reduce(amount);
if self.is_clutch() && self.hp() == 0 {
self.hp.value = 1;
}
}
pub fn recharge(&mut self) -> ResolutionResult { pub fn recharge(&mut self) -> ResolutionResult {
let immunity = self.immune(Skill::Recharge); let immunity = self.immune(Skill::Recharge);
let immune = immunity.immune; let immune = immunity.immune;
@ -493,7 +504,7 @@ impl Cryp {
}, },
true => { true => {
// there is no green shield (yet) // there is no green shield (yet)
self.hp.reduce(modified_healing); self.reduce_hp(modified_healing);
return ResolutionResult::Inversion { return ResolutionResult::Inversion {
damage: modified_healing, damage: modified_healing,
@ -541,7 +552,7 @@ impl Cryp {
self.red_shield.reduce(mitigation); self.red_shield.reduce(mitigation);
// deal remainder to hp // deal remainder to hp
self.hp.reduce(remainder); self.reduce_hp(remainder);
return ResolutionResult::Damage { return ResolutionResult::Damage {
amount: remainder, amount: remainder,
@ -599,7 +610,7 @@ impl Cryp {
let mitigation = modified_damage.saturating_sub(remainder); let mitigation = modified_damage.saturating_sub(remainder);
self.blue_shield.reduce(mitigation); self.blue_shield.reduce(mitigation);
self.hp.reduce(remainder); self.reduce_hp(remainder);
return ResolutionResult::Damage { return ResolutionResult::Damage {
amount: remainder, amount: remainder,

View File

@ -100,6 +100,7 @@ pub enum Effect {
Fury, Fury,
Blind, Blind,
Snare, Snare,
Clutch,
Empower, Empower,
@ -226,7 +227,7 @@ impl Effect {
Effect::Fury => Category::RedBuff, Effect::Fury => Category::RedBuff,
Effect::Blind => Category::RedDebuff, Effect::Blind => Category::RedDebuff,
Effect::Snare => Category::RedDebuff, Effect::Snare => Category::RedDebuff,
Effect::Clutch => Category::RedBuff,
Effect::Empower => Category::RedBuff, Effect::Empower => Category::RedBuff,
// magic // magic
@ -262,11 +263,13 @@ impl Effect {
Effect::Stun => 2, Effect::Stun => 2,
Effect::Block => 1, Effect::Block => 1,
Effect::Parry => 1, Effect::Parry => 1,
Effect::Clutch => 1,
Effect::Vulnerable => 2, Effect::Vulnerable => 2,
Effect::Snare => 2, Effect::Snare => 2,
Effect::Empower => 2, Effect::Empower => 2,
Effect::Invert => 1,
Effect::Hex => 2, Effect::Hex => 2,
Effect::Curse => 2, Effect::Curse => 2,
@ -498,7 +501,7 @@ impl Skill {
Skill::Ruin => Category::Blue, Skill::Ruin => Category::Blue,
Skill::Slay => Category::Blue, Skill::Slay => Category::Blue,
Skill::Strangle => Category::Blue, Skill::Strangle => Category::Blue,
Skill::Clutch => Category::Blue, Skill::Clutch => Category::Red,
Skill::Taunt => Category::Blue, Skill::Taunt => Category::Blue,
Skill::Toxic => Category::Blue, Skill::Toxic => Category::Blue,
@ -641,12 +644,12 @@ impl Skill {
Skill::Throw => throw(source, target, resolution), // no damage stun, adds vulnerable Skill::Throw => throw(source, target, resolution), // no damage stun, adds vulnerable
Skill::Triage => triage(source, target, resolution), // hot Skill::Triage => triage(source, target, resolution), // hot
Skill::TriageTick => triage_tick(source, target, resolution), // hot Skill::TriageTick => triage_tick(source, target, resolution), // hot
Skill::Clutch => clutch(source, target, resolution),
Skill::Reflect => unimplemented!(), Skill::Reflect => unimplemented!(),
Skill::Ruin => unimplemented!(), Skill::Ruin => unimplemented!(),
Skill::Slay => unimplemented!(), Skill::Slay => unimplemented!(),
Skill::Strangle => unimplemented!(), Skill::Strangle => unimplemented!(),
Skill::Clutch => unimplemented!(),
Skill::Taunt => unimplemented!(), Skill::Taunt => unimplemented!(),
Skill::Toxic => unimplemented!(), Skill::Toxic => unimplemented!(),
@ -665,6 +668,7 @@ impl Skill {
match self { match self {
Skill::Block => true, Skill::Block => true,
Skill::Parry => true, Skill::Parry => true,
Skill::Clutch => true,
Skill::TestBlock => true, Skill::TestBlock => true,
Skill::TestParry => true, Skill::TestParry => true,
_ => false, _ => false,
@ -696,6 +700,12 @@ fn stun(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Reso
return resolution; return resolution;
} }
fn clutch(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let effect = CrypEffect { effect: Effect::Clutch, duration: Effect::Clutch.duration(), tick: None };
resolution.results.push(target.add_effect(Skill::Clutch, effect));
return resolution;
}
fn throw(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution { fn throw(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let stun = CrypEffect { effect: Effect::Stun, duration: Effect::Stun.duration(), tick: None }; let stun = CrypEffect { effect: Effect::Stun, duration: Effect::Stun.duration(), tick: None };
let vulnerable = CrypEffect { effect: Effect::Vulnerable, duration: Effect::Vulnerable.duration(), tick: None }; let vulnerable = CrypEffect { effect: Effect::Vulnerable, duration: Effect::Vulnerable.duration(), tick: None };
@ -961,6 +971,24 @@ mod tests {
}; };
} }
#[test]
fn clutch_test() {
let mut x = Cryp::new()
.named(&"muji".to_string());
let mut y = Cryp::new()
.named(&"camel".to_string());
x.red_damage.force(u64::max_value());
clutch(&mut y.clone(), &mut y, Resolution::new(Skill::Clutch));
assert!(y.is_clutch());
attack(&mut x, &mut y, Resolution::new(Skill::Attack));
assert!(y.hp() == 1);
}
#[test] #[test]
fn invert_test() { fn invert_test() {
let mut x = Cryp::new() let mut x = Cryp::new()

View File

@ -51,7 +51,7 @@ impl Spec {
Spec::GBDI => vec![Stat::GreenDamage, Stat::BlueDamage], Spec::GBDI => vec![Stat::GreenDamage, Stat::BlueDamage],
Spec::RBDI => vec![Stat::RedDamage, Stat::BlueDamage], Spec::RBDI => vec![Stat::RedDamage, Stat::BlueDamage],
Spec::Speed => vec![Stat::Speed], Spec::Speed => vec![Stat::Speed],
Spec::RedSpeedI => vec![Stat::Speed], Spec::RedSpeedI => vec![Stat::Speed],
Spec::BlueSpeedI => vec![Stat::Speed], Spec::BlueSpeedI => vec![Stat::Speed],
Spec::GreenSpeedI => vec![Stat::Speed], Spec::GreenSpeedI => vec![Stat::Speed],

View File

@ -180,7 +180,7 @@ impl Var {
Var::Snare => Some(Skill::Snare), Var::Snare => Some(Skill::Snare),
// Var::Strangle => Some(Skill::Strangle), // Var::Strangle => Some(Skill::Strangle),
Var::Strike => Some(Skill::Strike), Var::Strike => Some(Skill::Strike),
// Var::Clutch => Some(Skill::Clutch), Var::Clutch => Some(Skill::Clutch),
// Var::Taunt => Some(Skill::Taunt), // Var::Taunt => Some(Skill::Taunt),
Var::Throw => Some(Skill::Throw), Var::Throw => Some(Skill::Throw),
// Var::Toxic => Some(Skill::Toxic), // Var::Toxic => Some(Skill::Toxic),
@ -300,7 +300,7 @@ fn get_combos() -> Vec<Combo> {
Combo { units: vec![Var::Attack, Var::Red, Var::Red], var: Var::Strike }, Combo { units: vec![Var::Attack, Var::Red, Var::Red], var: Var::Strike },
Combo { units: vec![Var::Attack, Var::Green, Var::Green], var: Var::Heal }, Combo { units: vec![Var::Attack, Var::Green, Var::Green], var: Var::Heal },
Combo { units: vec![Var::Attack, Var::Blue, Var::Blue], var: Var::Blast }, Combo { units: vec![Var::Attack, Var::Blue, Var::Blue], var: Var::Blast },
// Combo { units: vec![Var::Attack, Var::Red, Var::Green], var: Var::Strike }, // Combo { units: vec![Var::Attack, Var::Red, Var::Green], var: Var::Slay },
Combo { units: vec![Var::Attack, Var::Green, Var::Blue], var: Var::Decay }, Combo { units: vec![Var::Attack, Var::Green, Var::Blue], var: Var::Decay },
// Combo { units: vec![Var::Attack, Var::Red, Var::Blue], var: Var::Blast }, // Combo { units: vec![Var::Attack, Var::Red, Var::Blue], var: Var::Blast },