corruption

This commit is contained in:
ntr 2019-03-25 18:15:34 +11:00
parent 27c7023f61
commit 94f49651db
5 changed files with 128 additions and 29 deletions

View File

@ -23,7 +23,6 @@ ensure all skills impl
Hatred -> damage received converted into bonus dmg
on attack
Skill::Taunt -> redirect incomnig attacks to self
Skill::Toxic -> apply debuff to attackers
make parry semi-aggressive

View File

@ -163,7 +163,6 @@ pub struct Cryp {
pub specs: Vec<Spec>,
pub colours: Colours,
pub name: String,
pub ko_logged: bool,
}
impl Cryp {
@ -185,7 +184,6 @@ impl Cryp {
specs: vec![],
colours: Colours::new(),
name: String::new(),
ko_logged: false,
};
}

View File

@ -492,6 +492,9 @@ impl Game {
fn log_resolution(&mut self, speed: u64, skill: Skill, resolution: &Resolution) -> &mut Game {
let Resolution { source, target, event } = resolution;
match event {
Event::Ko =>
self.log.push(format!("{:} KO!", target.name)),
Event::Disable { disable } =>
self.log.push(format!("{:} {:?} {:} disabled {:?}",
source.name, skill, target.name, disable)),
@ -501,7 +504,7 @@ impl Game {
speed, source.name, skill, target.name, immunity)),
Event::TargetKo =>
self.log.push(format!("[{:}] {:} {:?} {:} - KO",
self.log.push(format!("[{:}] {:} {:?} {:} - target is KO",
speed, source.name, skill, target.name)),
Event::Damage { amount, mitigation, category: _ } =>

View File

@ -82,6 +82,7 @@ pub enum Event {
Effect { effect: Effect, duration: u8 },
Removal { effect: Effect },
Evasion { skill: Skill, evasion_rating: u64 },
Ko,
Incomplete,
}
@ -127,6 +128,11 @@ pub enum Effect {
Amplify,
Silence,
// corrupt is the buff that applies
// corruption the dmg debuff
Corrupt,
Corruption,
// magic immunity
Shield,
@ -261,6 +267,9 @@ impl Effect {
Effect::Amplify => Category::BlueBuff,
Effect::Silence => Category::BlueDebuff,
Effect::Corrupt => Category::BlueBuff,
Effect::Corruption => Category::BlueDebuff,
// magic immunity
Effect::Shield => Category::BlueBuff,
Effect::Invert => Category::GreenBuff,
@ -308,6 +317,9 @@ impl Effect {
Effect::Amplify => 2,
Effect::Silence => 2,
Effect::Corrupt => 2,
Effect::Corruption => 3,
Effect::Shield => 2,
Effect::Triage => 3,
@ -358,7 +370,6 @@ pub enum Skill {
Slay,
Clutch,
Taunt,
Toxic,
Invert,
Strangle,
@ -390,6 +401,11 @@ pub enum Skill {
SiphonTick,
Curse,
Corrupt,
Corruption,
CorruptionTick,
// -----------------
// Purity
// -----------------
@ -453,7 +469,10 @@ impl Skill {
Skill::StrangleTick => None,
Skill::Clutch => Some(2),
Skill::Taunt => Some(1),
Skill::Toxic => Some(1),
Skill::Corrupt => Some(1),
Skill::Corruption => None,
Skill::CorruptionTick => None,
// -----------------
// Test
@ -530,13 +549,15 @@ impl Skill {
// WRONG
Skill::Recharge => Category::Blue,
Skill::Reflect => Category::Blue,
Skill::Recharge => Category::Green,
Skill::Reflect => Category::Green,
Skill::Ruin => Category::Blue,
Skill::Slay => Category::Blue,
Skill::Slay => Category::Red,
Skill::Taunt => Category::Red,
Skill::Toxic => Category::Blue,
Skill::Corrupt => Category::Blue,
Skill::Corruption => Category::Blue,
Skill::CorruptionTick => Category::Blue,
// -----------------
// Test
@ -554,6 +575,7 @@ impl Skill {
Skill::TriageTick => true,
Skill::DecayTick => true,
Skill::SiphonTick => true,
Skill::CorruptionTick => true,
_ => false,
}
}
@ -621,20 +643,7 @@ impl Skill {
// false => (),
// }
// if target.is_ko() && !target.ko_logged {
// self.log.push(format!("{:} KO", target.name));
// target.effects.clear();
// target.ko_logged = true;
// }
// if source.is_ko() && !source.ko_logged {
// self.log.push(format!("{:} KO", source.name));
// source.effects.clear();
// source.ko_logged = true;
// }
match self {
results = match self {
Skill::Amplify => amplify(source, target, results), // increase magic damage
Skill::Attack => attack(source, target, results),
Skill::Banish => banish(source, target, results), // TODO prevent all actions
@ -671,7 +680,10 @@ impl Skill {
Skill::Ruin => ruin(source, target, results),
Skill::Slay => unimplemented!(),
Skill::Taunt => taunt(source, target, results),
Skill::Toxic => unimplemented!(),
Skill::Corrupt => corrupt(source, target, results),
Skill::Corruption => panic!("corruption should not be castable"),
Skill::CorruptionTick => corruption_tick(source, target, results),
// -----------------
// Test
@ -681,7 +693,29 @@ impl Skill {
Skill::TestBlock => block(source, target, results),
Skill::TestParry => parry(source, target, results),
Skill::TestSiphon => siphon(source, target, results),
};
// if any event dealt damage to target cryp
// hit them with corruption
results = match target.affected(Effect::Corrupt) {
true => match results.iter().any(|r|
match r.event {
Event::Damage { amount: _, mitigation: _, category: _ } => true,
_ => false,
}) {
true => corruption(target, source, results),
false => results,
},
false => results,
};
// i don't think we need to check the source being ko
if target.is_ko() {
results.push(Resolution::new(source, target).event(Event::Ko));
target.effects.clear();
}
return results;
}
pub fn self_targeting(&self) -> bool {
@ -689,6 +723,9 @@ impl Skill {
Skill::Block => true,
Skill::Parry => true,
Skill::Clutch => true,
Skill::Taunt => true,
Skill::Corrupt => true,
Skill::TestBlock => true,
Skill::TestParry => true,
_ => false,
@ -864,6 +901,30 @@ fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) ->
return results;
}
// corrupt is the buff effect
// when attacked it runs corruption and applies a debuff
fn corrupt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect { effect: Effect::Corrupt, duration: Effect::Corrupt.duration(), tick: None };
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Corrupt, effect)));
return results;;
}
fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect {
effect: Effect::Corruption,
duration: Effect::Corruption.duration(),
tick: Some(Cast::new_tick(source, target, Skill::CorruptionTick)),
};
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Corruption, effect)));
return corruption_tick(source, target, results);
}
fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.blue_damage() / 2;
results.push(Resolution::new(source, target).event(target.deal_blue_damage(Skill::CorruptionTick, amount)));
return results;
}
fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect { effect: Effect::Ruin, duration: Effect::Ruin.duration(), tick: None };
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Ruin, effect)));
@ -1107,6 +1168,43 @@ 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, vec![]);
assert!(y.affected(Effect::Reflect));
let mut results = Skill::Attack.resolve(&mut x, &mut y);
assert!(x.hp() == 768);
let Resolution { source: _, target: _, event } = results.remove(0);
match event {
Event::Damage { amount, mitigation: _, category: _ } => assert_eq!(amount, 256),
_ => panic!("not damage"),
};
} #[test]
fn corrupt_test() {
let mut x = Cryp::new()
.named(&"muji".to_string());
let mut y = Cryp::new()
.named(&"camel".to_string());
corrupt(&mut y.clone(), &mut y, vec![]);
assert!(y.affected(Effect::Corrupt));
let _results = Skill::Attack.resolve(&mut x, &mut y);
assert!(x.affected(Effect::Corruption));
}
#[test]
fn triage_test() {
let mut x = Cryp::new()
@ -1249,7 +1347,7 @@ mod tests {
// Siphon,
// SiphonTick,
// Curse,
// Plague, // aoe dot
// Corrupt, // aoe dot
// Ruin, // aoe
// // -----------------

View File

@ -89,7 +89,7 @@ pub enum Var {
Clutch,
Taunt,
Throw,
Toxic,
Corrupt,
Triage,
@ -206,7 +206,7 @@ impl Var {
Var::Clutch => Some(Skill::Clutch),
Var::Taunt => Some(Skill::Taunt),
Var::Throw => Some(Skill::Throw),
// Var::Toxic => Some(Skill::Toxic),
Var::Corrupt => Some(Skill::Corrupt),
Var::Triage => Some(Skill::Triage),
_ => None,
}
@ -275,6 +275,7 @@ impl From<Skill> for Var {
Skill::Taunt => Var::Taunt,
Skill::Throw => Var::Throw,
Skill::Triage => Var::Triage,
Skill::Corrupt => Var::Corrupt,
Skill::TestTouch => Var::TestTouch,
Skill::TestStun => Var::TestStun,
@ -334,7 +335,7 @@ fn get_combos() -> Vec<Combo> {
Combo { units: vec![Var::Block, Var::Red, Var::Red], var: Var::Parry },
Combo { units: vec![Var::Block, Var::Green, Var::Green], var: Var::Reflect },
Combo { units: vec![Var::Block, Var::Blue, Var::Blue], var: Var::Toxic },
Combo { units: vec![Var::Block, Var::Blue, Var::Blue], var: Var::Corrupt },
Combo { units: vec![Var::Block, Var::Red, Var::Green], var: Var::Taunt },
Combo { units: vec![Var::Block, Var::Green, Var::Blue], var: Var::Shield },
Combo { units: vec![Var::Block, Var::Red, Var::Blue], var: Var::Recharge },