This commit is contained in:
ntr 2019-03-24 16:09:28 +11:00
parent eef88568d6
commit 1054833dfd
4 changed files with 57 additions and 6 deletions

View File

@ -17,15 +17,19 @@
## NOW ## NOW
cryp vbox cryp vbox
ensure all skills impl ensure all skills impl
Skill::Reflect -> reflect incoming attacks back to opponent ez
Skill::Ruin -> aoe stun
Skill::Slay -> red attack with bonus somethingorother for blue / maim no healing Skill::Slay -> red attack with bonus somethingorother for blue / maim no healing
aoe
Skill::Ruin -> aoe stun
on attack
Skill::Reflect -> reflect incoming attacks back to opponent
Skill::Taunt -> redirect incomnig attacks to self Skill::Taunt -> redirect incomnig attacks to self
Skill::Toxic -> apply debuff to attackers Skill::Toxic -> apply debuff to attackers
colour speeds colour speeds
ticks apply on first turn
update speed of rest of stack on cryp speed change update speed of rest of stack on cryp speed change
include target name in effect resolution include target name in effect resolution
eg strangle applies buff to self eg strangle applies buff to self

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_reflecting(&self) -> bool {
self.effects.iter().any(|s| s.effect == Effect::Reflect)
}
pub fn is_clutch(&self) -> bool { pub fn is_clutch(&self) -> bool {
self.effects.iter().any(|s| s.effect == Effect::Clutch) self.effects.iter().any(|s| s.effect == Effect::Clutch)
} }

View File

@ -102,6 +102,8 @@ pub enum Effect {
Snare, Snare,
Clutch, Clutch,
Reflect,
Empower, Empower,
Invert, Invert,
@ -244,6 +246,7 @@ impl Effect {
Effect::Banish => Category::BlueDebuff, // todo randomise Effect::Banish => Category::BlueDebuff, // todo randomise
Effect::Slow => Category::BlueDebuff, Effect::Slow => Category::BlueDebuff,
Effect::Haste => Category::BlueBuff, Effect::Haste => Category::BlueBuff,
Effect::Reflect => Category::BlueBuff,
Effect::Enslave => Category::BlueDebuff, Effect::Enslave => Category::BlueDebuff,
Effect::Mesmerise => Category::BlueDebuff, Effect::Mesmerise => Category::BlueDebuff,
Effect::Amplify => Category::BlueBuff, Effect::Amplify => Category::BlueBuff,
@ -273,6 +276,8 @@ impl Effect {
Effect::Parry => 1, Effect::Parry => 1,
Effect::Clutch => 1, Effect::Clutch => 1,
Effect::Reflect => 1,
Effect::Strangle => 2, Effect::Strangle => 2,
Effect::Strangling => 2, Effect::Strangling => 2,
@ -582,7 +587,7 @@ impl Skill {
Skill::Purge => 1, Skill::Purge => 1,
Skill::Recharge => 1, Skill::Recharge => 1,
Skill::Reflect => 1, Skill::Reflect => 5,
Skill::Ruin => 1, Skill::Ruin => 1,
Skill::Slay => 1, Skill::Slay => 1,
Skill::Strangle => 5, Skill::Strangle => 5,
@ -632,6 +637,15 @@ impl Skill {
false => (), false => (),
} }
if target.is_reflecting() {
// guard against overflow
if source.is_reflecting() {
return resolution;
}
let mut copy = source.clone();
return self.resolve(&mut copy, source);
}
match self { match self {
Skill::Amplify => amplify(source, target, resolution), // increase magic damage Skill::Amplify => amplify(source, target, resolution), // increase magic damage
Skill::Attack => attack(source, target, resolution), Skill::Attack => attack(source, target, resolution),
@ -665,7 +679,7 @@ impl Skill {
Skill::Strangle => strangle(source, target, resolution), Skill::Strangle => strangle(source, target, resolution),
Skill::StrangleTick => strangle_tick(source, target, resolution), Skill::StrangleTick => strangle_tick(source, target, resolution),
Skill::Reflect => unimplemented!(), Skill::Reflect => reflect(source, target, resolution),
Skill::Ruin => unimplemented!(), Skill::Ruin => unimplemented!(),
Skill::Slay => unimplemented!(), Skill::Slay => unimplemented!(),
Skill::Taunt => unimplemented!(), Skill::Taunt => unimplemented!(),
@ -868,6 +882,12 @@ fn invert(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Re
return resolution;; return resolution;;
} }
fn reflect(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let effect = CrypEffect { effect: Effect::Reflect, duration: Effect::Reflect.duration(), tick: None };
resolution.results.push(target.add_effect(Skill::Reflect, effect));
return resolution;;
}
fn recharge(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution { fn recharge(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
resolution.results.push(target.recharge()); resolution.results.push(target.recharge());
return resolution; return resolution;
@ -1069,6 +1089,28 @@ mod tests {
}; };
} }
#[test]
fn reflect_test() {
let mut x = Cryp::new()
.named(&"muji".to_string());
let mut y = Cryp::new()
.named(&"camel".to_string());
reflect(&mut y.clone(), &mut y, Resolution::new(Skill::Reflect));
assert!(y.is_reflecting());
// heal should deal green damage
let mut cast = Cast::new(Uuid::nil(), Uuid::nil(), Uuid::nil(), Skill::Attack);
cast.set_resolution(&mut x, &mut y);
assert!(x.hp() == 768);
match cast.resolution.results[0] {
ResolutionResult::Damage { amount, mitigation: _, category: _, immunity: _ } => assert_eq!(amount, 256),
_ => panic!("not damage"),
};
}
#[test] #[test]
fn triage_test() { fn triage_test() {

View File

@ -172,7 +172,7 @@ impl Var {
Var::Purge => Some(Skill::Purge), Var::Purge => Some(Skill::Purge),
Var::Purify => Some(Skill::Purify), Var::Purify => Some(Skill::Purify),
Var::Recharge => Some(Skill::Recharge), Var::Recharge => Some(Skill::Recharge),
// Var::Reflect => Some(Skill::Reflect), Var::Reflect => Some(Skill::Reflect),
// Var::Ruin => Some(Skill::Ruin), // Var::Ruin => Some(Skill::Ruin),
Var::Shield => Some(Skill::Shield), Var::Shield => Some(Skill::Shield),
Var::Silence => Some(Skill::Silence), Var::Silence => Some(Skill::Silence),
@ -249,6 +249,7 @@ impl From<Skill> for Var {
Skill::Throw => Var::Throw, Skill::Throw => Var::Throw,
Skill::Triage => Var::Triage, Skill::Triage => Var::Triage,
Skill::Decay => Var::Decay, Skill::Decay => Var::Decay,
Skill::Reflect => Var::Reflect,
Skill::TestTouch => Var::TestTouch, Skill::TestTouch => Var::TestTouch,
Skill::TestStun => Var::TestStun, Skill::TestStun => Var::TestStun,