From 9cee9f4bfb66f7f737e79dc6293cdf9eb11430fc Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 26 Mar 2019 13:02:23 +1100 Subject: [PATCH 1/2] add skills to events --- server/WORKLOG.md | 2 ++ server/src/cryp.rs | 17 +++++++++++++++-- server/src/game.rs | 24 ++++++++++++------------ server/src/skill.rs | 38 +++++++++++++++++++------------------- 4 files changed, 48 insertions(+), 33 deletions(-) diff --git a/server/WORKLOG.md b/server/WORKLOG.md index 2acc618f..ad812a5f 100644 --- a/server/WORKLOG.md +++ b/server/WORKLOG.md @@ -22,6 +22,8 @@ ensure all skills impl Skill::Slay -> red attack with bonus somethingorother for blue / maim no healing Hatred -> damage received converted into bonus dmg +change inversion to several events + make parry semi-aggressive constants change to ownership pattern diff --git a/server/src/cryp.rs b/server/src/cryp.rs index 43df7cbf..bf0b850e 100644 --- a/server/src/cryp.rs +++ b/server/src/cryp.rs @@ -439,8 +439,10 @@ impl Cryp { } pub fn recharge(&mut self) -> Event { - if let Some(immunity) = self.immune(Skill::Recharge) { + let skill = Skill::Recharge; + if let Some(immunity) = self.immune(skill) { return Event::Immunity { + skill, immunity, }; } @@ -451,13 +453,14 @@ impl Cryp { let blue = self.blue_shield.max.saturating_sub(self.blue_shield.value); self.blue_shield.value = self.blue_shield.max; - Event::Recharge { red, blue } + Event::Recharge { red, blue, skill } } pub fn deal_green_damage(&mut self, skill: Skill, amount: u64) -> Event { if let Some(immunity) = self.immune(skill) { return Event::Immunity { immunity, + skill, }; } @@ -480,6 +483,7 @@ impl Cryp { let overhealing = modified_healing - healing; return Event::Healing { + skill, amount: healing, overhealing, }; @@ -491,6 +495,7 @@ impl Cryp { let delta = current_hp - self.hp(); return Event::Inversion { + skill, damage: delta, healing: 0, recharge: 0, @@ -503,6 +508,7 @@ impl Cryp { pub fn deal_red_damage(&mut self, skill: Skill, amount: u64) -> Event { if let Some(immunity) = self.immune(skill) { return Event::Immunity { + skill, immunity, }; } @@ -534,6 +540,7 @@ impl Cryp { let delta = current_hp - self.hp(); return Event::Damage { + skill, amount: delta, mitigation, category: Category::RedDamage, @@ -554,6 +561,7 @@ impl Cryp { damage: 0, healing, recharge, + skill, category: Category::RedDamage, }; } @@ -563,6 +571,7 @@ impl Cryp { pub fn deal_blue_damage(&mut self, skill: Skill, amount: u64) -> Event { if let Some(immunity) = self.immune(skill) { return Event::Immunity { + skill, immunity, }; } @@ -587,6 +596,7 @@ impl Cryp { let delta = current_hp - self.hp(); return Event::Damage { + skill, amount: delta, mitigation, category: Category::BlueDamage, @@ -604,6 +614,7 @@ impl Cryp { let recharge = self.blue_shield.value - current_shield; return Event::Inversion { + skill, damage: 0, healing, recharge, @@ -616,6 +627,7 @@ impl Cryp { pub fn add_effect(&mut self, skill: Skill, effect: CrypEffect) -> Event { if let Some(immunity) = self.immune(skill) { return Event::Immunity { + skill, immunity, }; } @@ -624,6 +636,7 @@ impl Cryp { let result = Event::Effect { effect: effect.effect, duration: effect.effect.duration(), + skill, }; // println!("{:?} {:?} adding effect", self.name, effect.effect); diff --git a/server/src/game.rs b/server/src/game.rs index c6e53cdc..9a8dfefa 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -435,7 +435,7 @@ impl Game { resolutions.reverse(); while let Some(resolution) = resolutions.pop() { // fixme for mash - self.log_resolution(cast.speed, cast.skill, &resolution); + self.log_resolution(cast.speed, &resolution); // the results go into the resolutions self.resolved.push(resolution); } @@ -490,33 +490,33 @@ impl Game { self } - fn log_resolution(&mut self, speed: u64, skill: Skill, resolution: &Resolution) -> &mut Game { + fn log_resolution(&mut self, speed: u64, resolution: &Resolution) -> &mut Game { let Resolution { source, target, event } = resolution; match event { Event::Ko => self.log.push(format!("{:} KO!", target.name)), - Event::Disable { disable } => + Event::Disable { skill, disable } => self.log.push(format!("{:} {:?} {:} disabled {:?}", source.name, skill, target.name, disable)), - Event::Immunity { immunity } => + Event::Immunity { skill, immunity } => self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}", speed, source.name, skill, target.name, immunity)), - Event::TargetKo => + Event::TargetKo { skill } => self.log.push(format!("[{:}] {:} {:?} {:} - target is KO", speed, source.name, skill, target.name)), - Event::Damage { amount, mitigation, category: _ } => + Event::Damage { skill, amount, mitigation, category: _ } => self.log.push(format!("[{:}] {:} {:?} {:} {:} ({:} mitigated)", speed, source.name, skill, target.name, amount, mitigation)), - Event::Healing { amount, overhealing } => + Event::Healing { skill, amount, overhealing } => self.log.push(format!("[{:}] {:} {:?} {:} {:} ({:}OH)", speed, source.name, skill, target.name, amount, overhealing)), - Event::Inversion { healing, damage, recharge, category: _ } => { + Event::Inversion { skill, healing, damage, recharge, category: _ } => { match *healing > 0 { true => self.log.push(format!("[{:}] {:} {:?} {:} INVERTED {:} ({:} recharge)", speed, source.name, skill, target.name, healing, recharge)), @@ -525,7 +525,7 @@ impl Game { } }, - Event::Effect { effect, duration } => + Event::Effect { skill, effect, duration } => self.log.push(format!("[{:}] {:} {:?} {:} {:?} {:}T", speed, source.name, skill, target.name, effect, duration)), @@ -533,11 +533,11 @@ impl Game { self.log.push(format!("[{:}] {:?} removed {:} {:?}", speed, source.name, target.name, effect)), - Event::Recharge { red, blue } => + Event::Recharge { skill, red, blue } => self.log.push(format!("[{:}] {:} {:?} {:} {:}R {:}B", speed, source.name, skill, target.name, red, blue)), - Event::Evasion { skill: _, evasion_rating } => + Event::Evasion { skill, evasion_rating } => self.log.push(format!("[{:}] {:} {:?} {:} evaded ({:}%)", speed, source.name, skill, target.name, evasion_rating)), @@ -1150,7 +1150,7 @@ mod tests { let Resolution { source, target: _, event } = r; match source.id == x_cryp.id { true => match event { - Event::Effect { effect, duration } => { + Event::Effect { effect, duration, skill: _ } => { assert!(*effect == Effect::Ruin); assert!(*duration == 1); true diff --git a/server/src/skill.rs b/server/src/skill.rs index 9e13ba88..4ad51cdf 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -72,16 +72,16 @@ impl Resolution { #[derive(Debug,Clone,PartialEq,Serialize,Deserialize)] pub enum Event { - TargetKo, - Disable { disable: Disable }, - Immunity { immunity: Immunity }, - Damage { amount: u64, mitigation: u64, category: Category }, - Healing { amount: u64, overhealing: u64 }, - Recharge { red: u64, blue: u64 }, - Inversion { healing: u64, damage: u64, recharge: u64, category: Category }, - Effect { effect: Effect, duration: u8 }, - Removal { effect: Effect }, - Evasion { skill: Skill, evasion_rating: u64 }, + Disable { skill: Skill, disable: Disable }, + Immunity { skill: Skill, immunity: Immunity }, + Damage { skill: Skill, amount: u64, mitigation: u64, category: Category }, + Healing { skill: Skill, amount: u64, overhealing: u64 }, + Recharge { skill: Skill, red: u64, blue: u64 }, + Inversion { skill: Skill, healing: u64, damage: u64, recharge: u64, category: Category }, + Effect { skill: Skill, effect: Effect, duration: u8 }, + Removal { effect: Effect }, + Evasion { skill: Skill, evasion_rating: u64 }, + TargetKo { skill: Skill }, Ko, Incomplete, @@ -616,12 +616,12 @@ impl Skill { let mut results = vec![]; if let Some(disable) = source.disabled(*self) { - results.push(Resolution::new(source, target).event(Event::Disable { disable })); + results.push(Resolution::new(source, target).event(Event::Disable { disable, skill: *self })); return results; } if target.is_ko() { - results.push(Resolution::new(source, target).event(Event::TargetKo)); + results.push(Resolution::new(source, target).event(Event::TargetKo { skill: *self })); return results; } @@ -700,7 +700,7 @@ impl Skill { results = match target.affected(Effect::Corrupt) { true => match results.iter().any(|r| match r.event { - Event::Damage { amount: _, mitigation: _, category: _ } => true, + Event::Damage { amount: _, mitigation: _, category: _, skill: _ } => true, _ => false, }) { true => corruption(target, source, results), @@ -976,7 +976,7 @@ fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) - results.push(Resolution::new(source, target).event(siphon_damage.clone())); match siphon_damage { - Event::Damage { amount, mitigation: _, category: _, } => { + Event::Damage { amount, mitigation: _, category: _, skill: _ } => { results.push(Resolution::new(source, source).event(source.deal_green_damage(Skill::Heal, amount))); }, _ => panic!("siphon tick damage not dealt {:?}", siphon_damage), @@ -1087,7 +1087,7 @@ mod tests { let Resolution { source: _, target: _, event } = results.remove(0); match event { - Event::Damage { amount, mitigation: _, category: _ } => assert_eq!(amount, 50), + Event::Damage { amount, mitigation: _, category: _, skill: _ } => assert_eq!(amount, 50), _ => panic!("not damage"), }; } @@ -1110,7 +1110,7 @@ mod tests { let Resolution { source: _, target: _, event } = results.remove(0); match event { - Event::Damage { amount, mitigation: _, category: _ } => assert_eq!(amount, 1023), + Event::Damage { amount, mitigation: _, category: _, skill: _ } => assert_eq!(amount, 1023), _ => panic!("not damage"), }; } @@ -1141,7 +1141,7 @@ mod tests { let Resolution { source: _, target: _, event } = results.remove(0); match event { - Event::Inversion { damage: _, healing: _, recharge, category: _ } => assert_eq!(recharge, 64), + Event::Inversion { damage: _, healing: _, recharge, category: _, skill: _ } => assert_eq!(recharge, 64), _ => panic!("not inversion"), }; } @@ -1163,7 +1163,7 @@ mod tests { let Resolution { source: _, target: _, event } = results.remove(0); match event { - Event::Damage { amount, mitigation: _, category: _ } => assert_eq!(amount, 256), + Event::Damage { amount, mitigation: _, category: _, skill: _ } => assert_eq!(amount, 256), _ => panic!("not damage"), }; } @@ -1226,7 +1226,7 @@ mod tests { let Resolution { source: _, target: _, event } = results.remove(0); match event { - Event::Recharge { red, blue } => { + Event::Recharge { red, blue, skill: _ } => { assert!(red == 5); assert!(blue == 5); } From 55d5ea09ac3b858449836c8f720aa47a6830ac79 Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 26 Mar 2019 14:21:06 +1100 Subject: [PATCH 2/2] dmg returns vec of events now to clean up log --- server/src/cryp.rs | 110 ++++++++++++++++++++++++++++---------------- server/src/game.rs | 11 ++--- server/src/skill.rs | 88 ++++++++++++++++++++++++----------- 3 files changed, 135 insertions(+), 74 deletions(-) diff --git a/server/src/cryp.rs b/server/src/cryp.rs index bf0b850e..e28fe464 100644 --- a/server/src/cryp.rs +++ b/server/src/cryp.rs @@ -456,12 +456,14 @@ impl Cryp { Event::Recharge { red, blue, skill } } - pub fn deal_green_damage(&mut self, skill: Skill, amount: u64) -> Event { + pub fn deal_green_damage(&mut self, skill: Skill, amount: u64) -> Vec { + let mut events = vec![]; if let Some(immunity) = self.immune(skill) { - return Event::Immunity { + events.push(Event::Immunity { immunity, skill, - }; + }); + return events; } let healing_mods = self.effects.iter() @@ -471,46 +473,52 @@ impl Cryp { // println!("{:?}", healing_mods); - let modified_healing = healing_mods.iter().fold(amount, |acc, m| m.apply(acc)); + let modified_green_damage = healing_mods.iter().fold(amount, |acc, m| m.apply(acc)); match self.affected(Effect::Invert) { false => { let current_hp = self.hp(); - self.hp.increase(modified_healing); + self.hp.increase(modified_green_damage); let new_hp = self.hp.value; let healing = new_hp - current_hp; - let overhealing = modified_healing - healing; + let overhealing = modified_green_damage - healing; - return Event::Healing { + events.push(Event::Healing { skill, amount: healing, overhealing, - }; + }); }, true => { + events.push(Event::Inversion { skill }); + // there is no green shield (yet) let current_hp = self.hp(); - self.reduce_hp(modified_healing); + self.reduce_hp(modified_green_damage); let delta = current_hp - self.hp(); - return Event::Inversion { + events.push(Event::Damage { skill, - damage: delta, - healing: 0, - recharge: 0, + amount: delta, + mitigation: 0, category: Category::GreenDamage, - }; + }); } } + + return events; } - pub fn deal_red_damage(&mut self, skill: Skill, amount: u64) -> Event { + pub fn deal_red_damage(&mut self, skill: Skill, amount: u64) -> Vec { + let mut events = vec![]; + if let Some(immunity) = self.immune(skill) { - return Event::Immunity { + events.push(Event::Immunity { skill, immunity, - }; + }); + return events; } let red_damage_mods = self.effects.iter() @@ -539,14 +547,16 @@ impl Cryp { self.reduce_hp(remainder); let delta = current_hp - self.hp(); - return Event::Damage { + events.push(Event::Damage { skill, amount: delta, mitigation, category: Category::RedDamage, - }; + }); }, true => { + events.push(Event::Inversion { skill }); + let current_hp = self.hp(); self.hp.increase(modified_damage); let new_hp = self.hp.value; @@ -557,23 +567,32 @@ impl Cryp { self.red_shield.increase(overhealing); let recharge = self.red_shield.value - current_shield; - return Event::Inversion { - damage: 0, - healing, - recharge, - skill, - category: Category::RedDamage, - }; + if healing > 0 { + events.push(Event::Healing { + skill, + amount: healing, + overhealing: overhealing - recharge, + }); + } + + if recharge > 0 { + events.push(Event::Recharge { red: recharge, blue: 0, skill }); + } } - } + }; + + return events; } - pub fn deal_blue_damage(&mut self, skill: Skill, amount: u64) -> Event { + pub fn deal_blue_damage(&mut self, skill: Skill, amount: u64) -> Vec { + let mut events = vec![]; + if let Some(immunity) = self.immune(skill) { - return Event::Immunity { + events.push(Event::Immunity { skill, immunity, - }; + }); + return events; } let blue_damage_mods = self.effects.iter() @@ -582,6 +601,7 @@ impl Cryp { .collect::>(); // println!("{:?}", blue_damage_mods); + let modified_damage = blue_damage_mods.iter().fold(amount, |acc, m| m.apply(acc)); match self.affected(Effect::Invert) { @@ -589,20 +609,24 @@ impl Cryp { let remainder = modified_damage.saturating_sub(self.blue_shield.value); let mitigation = modified_damage.saturating_sub(remainder); + // reduce blue_shield by mitigation amount self.blue_shield.reduce(mitigation); + // deal remainder to hp let current_hp = self.hp(); self.reduce_hp(remainder); let delta = current_hp - self.hp(); - return Event::Damage { + events.push(Event::Damage { skill, amount: delta, mitigation, category: Category::BlueDamage, - }; + }); }, true => { + events.push(Event::Inversion { skill }); + let current_hp = self.hp(); self.hp.increase(modified_damage); let new_hp = self.hp.value; @@ -613,15 +637,21 @@ impl Cryp { self.blue_shield.increase(overhealing); let recharge = self.blue_shield.value - current_shield; - return Event::Inversion { - skill, - damage: 0, - healing, - recharge, - category: Category::BlueDamage, - }; + if healing > 0 { + events.push(Event::Healing { + skill, + amount: healing, + overhealing, + }); + } + + if recharge > 0 { + events.push(Event::Recharge { red: 0, blue: recharge, skill }); + } } - } + }; + + return events; } pub fn add_effect(&mut self, skill: Skill, effect: CrypEffect) -> Event { diff --git a/server/src/game.rs b/server/src/game.rs index 9a8dfefa..3c7475b1 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -516,14 +516,9 @@ impl Game { self.log.push(format!("[{:}] {:} {:?} {:} {:} ({:}OH)", speed, source.name, skill, target.name, amount, overhealing)), - Event::Inversion { skill, healing, damage, recharge, category: _ } => { - match *healing > 0 { - true => self.log.push(format!("[{:}] {:} {:?} {:} INVERTED {:} ({:} recharge)", - speed, source.name, skill, target.name, healing, recharge)), - false => self.log.push(format!("[{:}] {:} {:?} {:} INVERTED {:}", - speed, source.name, skill, target.name, damage)), - } - }, + Event::Inversion { skill } => + self.log.push(format!("[{:}] {:} {:?} {:} INVERTED", + speed, source.name, skill, target.name)), Event::Effect { skill, effect, duration } => self.log.push(format!("[{:}] {:} {:?} {:} {:?} {:}T", diff --git a/server/src/skill.rs b/server/src/skill.rs index 4ad51cdf..bc4977c8 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -77,7 +77,7 @@ pub enum Event { Damage { skill: Skill, amount: u64, mitigation: u64, category: Category }, Healing { skill: Skill, amount: u64, overhealing: u64 }, Recharge { skill: Skill, red: u64, blue: u64 }, - Inversion { skill: Skill, healing: u64, damage: u64, recharge: u64, category: Category }, + Inversion { skill: Skill }, Effect { skill: Skill, effect: Effect, duration: u8 }, Removal { effect: Effect }, Evasion { skill: Skill, evasion_rating: u64 }, @@ -746,16 +746,32 @@ impl Skill { } fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - results.push(Resolution::new(source, target).event(target.deal_red_damage(Skill::TestTouch, 0))); + target.deal_red_damage(Skill::TestTouch, 0) + .into_iter() + .for_each(|e| results.push(Resolution::new(source, target).event(e))); + return results; } fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { let amount = source.red_damage(); - results.push(Resolution::new(source, target).event(target.deal_red_damage(Skill::Attack, amount))); + target.deal_red_damage(Skill::Attack, amount) + .into_iter() + .for_each(|e| results.push(Resolution::new(source, target).event(e))); + return results; } +fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { + let amount = source.red_damage(); + target.deal_red_damage(Skill::Strike, amount) + .into_iter() + .for_each(|e| results.push(Resolution::new(source, target).event(e))); + + return results; +} + + fn stun(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { let effect = CrypEffect { effect: Effect::Stun, duration: Effect::Stun.duration(), tick: None }; results.push(Resolution::new(source, target).event(target.add_effect(Skill::Stun, effect))); @@ -799,7 +815,9 @@ fn strangle(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> R fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { let amount = source.red_damage(); - results.push(Resolution::new(source, target).event(target.deal_red_damage(Skill::StrangleTick, amount))); + target.deal_red_damage(Skill::StrangleTick, amount) + .into_iter() + .for_each(|e| results.push(Resolution::new(source, target).event(e))); // remove immunity if target ko if target.is_ko() { @@ -841,7 +859,9 @@ fn empower(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Re fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { let amount = source.green_damage(); - results.push(Resolution::new(source, target).event(target.deal_green_damage(Skill::Heal, amount))); + target.deal_green_damage(Skill::Heal, amount) + .into_iter() + .for_each(|e| results.push(Resolution::new(source, target).event(e))); return results; } @@ -857,13 +877,17 @@ fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { let amount = source.green_damage().wrapping_div(2); - results.push(Resolution::new(source, target).event(target.deal_green_damage(Skill::TriageTick, amount))); + target.deal_green_damage(Skill::TriageTick, amount) + .into_iter() + .for_each(|e| results.push(Resolution::new(source, target).event(e))); return results; } fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { let amount = source.blue_damage(); - results.push(Resolution::new(source, target).event(target.deal_blue_damage(Skill::Blast, amount))); + target.deal_blue_damage(Skill::Blast, amount) + .into_iter() + .for_each(|e| results.push(Resolution::new(source, target).event(e))); return results; } @@ -897,7 +921,9 @@ fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Reso fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { let amount = source.blue_damage(); - results.push(Resolution::new(source, target).event(target.deal_blue_damage(Skill::DecayTick, amount))); + target.deal_blue_damage(Skill::DecayTick, amount) + .into_iter() + .for_each(|e| results.push(Resolution::new(source, target).event(e))); return results; } @@ -921,7 +947,9 @@ fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> 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))); + target.deal_blue_damage(Skill::CorruptionTick, amount) + .into_iter() + .for_each(|e| results.push(Resolution::new(source, target).event(e))); return results; } @@ -972,14 +1000,20 @@ fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { let amount = source.blue_damage(); - let siphon_damage = target.deal_blue_damage(Skill::SiphonTick, amount); - results.push(Resolution::new(source, target).event(siphon_damage.clone())); + let siphon_events = target.deal_blue_damage(Skill::SiphonTick, amount); - match siphon_damage { - Event::Damage { amount, mitigation: _, category: _, skill: _ } => { - results.push(Resolution::new(source, source).event(source.deal_green_damage(Skill::Heal, amount))); - }, - _ => panic!("siphon tick damage not dealt {:?}", siphon_damage), + for e in siphon_events { + match e { + Event::Damage { amount, mitigation: _, category: _, skill: _ } => { + let dmg = source.deal_green_damage(Skill::Siphon, amount); + for e in dmg { + results.push(Resolution::new(source, target).event(e)); + }; + }, + _ => (), + } + + results.push(Resolution::new(source, target).event(e)); } return results; @@ -1025,13 +1059,6 @@ fn banish(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res return results; } -fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let _amount = source.red_damage(); - results.push(Resolution::new(source, target).event(target.deal_red_damage(Skill::Attack, u64::max_value()))); - return results; -} - - #[cfg(test)] mod tests { use skill::*; @@ -1139,11 +1166,20 @@ mod tests { let mut results = attack(&mut x, &mut y, vec![]); assert!(y.hp() == 1024); - let Resolution { source: _, target: _, event } = results.remove(0); - match event { - Event::Inversion { damage: _, healing: _, recharge, category: _, skill: _ } => assert_eq!(recharge, 64), + match results.remove(0).event { + Event::Inversion { skill } => assert_eq!(skill, Skill::Attack), _ => panic!("not inversion"), }; + + match results.remove(0).event { + Event::Healing { skill: _, overhealing: _, amount } => assert_eq!(amount, 256), + _ => panic!("not healing from inversion"), + }; + + match results.remove(0).event { + Event::Recharge { skill: _, red, blue: _ } => assert_eq!(red, 64), + _ => panic!("not recharge from inversion"), + }; } #[test]