diff --git a/core/src/game.rs b/core/src/game.rs index 19e1ce58..e7c6b391 100644 --- a/core/src/game.rs +++ b/core/src/game.rs @@ -159,8 +159,6 @@ impl Game { } pub fn start(self) -> Game { - // self.log.push("Game starting...".to_string()); - // both forfeit ddue to no skills if self.finished() { return self.finish(); @@ -170,6 +168,11 @@ impl Game { } fn skill_phase_start(mut self, resolution_animation_ms: i64) -> Game { + if ![Phase::Start, Phase::Resolve].contains(&self.phase) { + panic!("game not in Resolve or start phase"); + } + self.phase = Phase::Skill; + self.resolutions.push(vec![]); self.phase_start = Utc::now() @@ -179,12 +182,14 @@ impl Game { self.phase_end = self.time_control.game_phase_end(resolution_animation_ms); for player in self.players.iter_mut() { + // everything disabled or forfeiting etc if player.skills_required() == 0 { continue; } player.set_ready(false); + // displayed on client for construct in player.constructs.iter_mut() { for i in 0..construct.skills.len() { if let Some(_d) = construct.disabled(construct.skills[i].skill) { @@ -197,17 +202,8 @@ impl Game { } } - // self.log.push("".to_string()); - - if ![Phase::Start, Phase::Resolve].contains(&self.phase) { - panic!("game not in Resolve or start phase"); - } - - self.phase = Phase::Skill; - self.pve_add_skills(); - - if self.skill_phase_finished() { + if self.skill_phase_finished() { // pve game where both bots will have readied up return self.resolve_phase_start() } @@ -1789,12 +1785,17 @@ mod tests { let target = game.players[1].constructs[0].id; game.resolve(Cast::new(source, player_id, target, Skill::Siphon)); - game = game.resolve_phase_start(); let last = game.resolutions.len() - 1; let resolutions = &game.resolutions[last]; - println!("{:?}", resolutions); + // siphon should + // apply effect // damage target // heal source + assert!(resolutions.iter().any(|r| match r.event { + Event::Effect { construct, effect, duration: _, display: _ } => + construct == target && effect == Effect::Siphon, + _ => false, + })); assert!(resolutions.iter().any(|r| match r.event { Event::Damage { construct, colour, amount, mitigation: _, display: _ } => @@ -1803,10 +1804,27 @@ mod tests { })); assert!(resolutions.iter().any(|r| match r.event { - Event::Healing { construct, colour, amount, overhealing: _, display: _ } => - construct == source && amount > 0 && colour == Colour::Green, + Event::Healing { construct, colour, amount: _, overhealing: _, display: _ } => + construct == source && colour == Colour::Green, _ => false, })); + + game = game.resolve_phase_start(); + + // que ota? + game.resolve(Cast::new(source, player_id, target, Skill::Siphon)); + game = game.resolve_phase_start(); + + let last = game.resolutions.len() - 2; + let resolutions = &game.resolutions[last]; + + println!("{:#?}", game.resolutions); + + let damage_events = resolutions.iter().filter(|r| match r.event { + Event::Damage { construct, colour, amount, mitigation: _, display: _ } => true, + _ => false, + }).count(); + assert_eq!(damage_events, 1); } #[test] diff --git a/core/src/skill.rs b/core/src/skill.rs index 390d1ff0..db4f0f30 100644 --- a/core/src/skill.rs +++ b/core/src/skill.rs @@ -727,6 +727,11 @@ impl Cast { colour: Colour::Blue, values: vec![Value::Stat { construct: self.source, stat: Stat::BluePower, mult: self.skill.multiplier() }], }, + Action::Heal { + construct: self.source, + colour: Colour::Green, + values: vec![Value::DamageReceived { construct: self.target, colour: Colour::Blue, mult: 100 }], + }, ], Skill::SiphonPlus => vec![ Action::Effect { @@ -739,6 +744,11 @@ impl Cast { colour: Colour::Blue, values: vec![Value::Stat { construct: self.source, stat: Stat::BluePower, mult: self.skill.multiplier() }], }, + Action::Heal { + construct: self.source, + colour: Colour::Green, + values: vec![Value::DamageReceived { construct: self.target, colour: Colour::Blue, mult: 100 }], + }, ], Skill::SiphonPlusPlus => vec![ Action::Effect { @@ -751,6 +761,11 @@ impl Cast { colour: Colour::Blue, values: vec![Value::Stat { construct: self.source, stat: Stat::BluePower, mult: self.skill.multiplier() }], }, + Action::Heal { + construct: self.source, + colour: Colour::Green, + values: vec![Value::DamageReceived { construct: self.target, colour: Colour::Blue, mult: 100 }], + }, ], Skill::SiphonTick | Skill::SiphonTickPlus |