siphon test wip
This commit is contained in:
parent
88237d3e5e
commit
18784e59ce
@ -159,8 +159,6 @@ impl Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(self) -> Game {
|
pub fn start(self) -> Game {
|
||||||
// self.log.push("Game starting...".to_string());
|
|
||||||
|
|
||||||
// both forfeit ddue to no skills
|
// both forfeit ddue to no skills
|
||||||
if self.finished() {
|
if self.finished() {
|
||||||
return self.finish();
|
return self.finish();
|
||||||
@ -170,6 +168,11 @@ impl Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn skill_phase_start(mut self, resolution_animation_ms: i64) -> 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.resolutions.push(vec![]);
|
||||||
|
|
||||||
self.phase_start = Utc::now()
|
self.phase_start = Utc::now()
|
||||||
@ -179,12 +182,14 @@ impl Game {
|
|||||||
self.phase_end = self.time_control.game_phase_end(resolution_animation_ms);
|
self.phase_end = self.time_control.game_phase_end(resolution_animation_ms);
|
||||||
|
|
||||||
for player in self.players.iter_mut() {
|
for player in self.players.iter_mut() {
|
||||||
|
// everything disabled or forfeiting etc
|
||||||
if player.skills_required() == 0 {
|
if player.skills_required() == 0 {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.set_ready(false);
|
player.set_ready(false);
|
||||||
|
|
||||||
|
// displayed on client
|
||||||
for construct in player.constructs.iter_mut() {
|
for construct in player.constructs.iter_mut() {
|
||||||
for i in 0..construct.skills.len() {
|
for i in 0..construct.skills.len() {
|
||||||
if let Some(_d) = construct.disabled(construct.skills[i].skill) {
|
if let Some(_d) = construct.disabled(construct.skills[i].skill) {
|
||||||
@ -197,17 +202,8 @@ impl Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// self.log.push("<Skill Phase>".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();
|
self.pve_add_skills();
|
||||||
|
if self.skill_phase_finished() { // pve game where both bots will have readied up
|
||||||
if self.skill_phase_finished() {
|
|
||||||
return self.resolve_phase_start()
|
return self.resolve_phase_start()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1789,12 +1785,17 @@ mod tests {
|
|||||||
let target = game.players[1].constructs[0].id;
|
let target = game.players[1].constructs[0].id;
|
||||||
|
|
||||||
game.resolve(Cast::new(source, player_id, target, Skill::Siphon));
|
game.resolve(Cast::new(source, player_id, target, Skill::Siphon));
|
||||||
game = game.resolve_phase_start();
|
|
||||||
|
|
||||||
let last = game.resolutions.len() - 1;
|
let last = game.resolutions.len() - 1;
|
||||||
let resolutions = &game.resolutions[last];
|
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 {
|
assert!(resolutions.iter().any(|r| match r.event {
|
||||||
Event::Damage { construct, colour, amount, mitigation: _, display: _ } =>
|
Event::Damage { construct, colour, amount, mitigation: _, display: _ } =>
|
||||||
@ -1803,10 +1804,27 @@ mod tests {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
assert!(resolutions.iter().any(|r| match r.event {
|
assert!(resolutions.iter().any(|r| match r.event {
|
||||||
Event::Healing { construct, colour, amount, overhealing: _, display: _ } =>
|
Event::Healing { construct, colour, amount: _, overhealing: _, display: _ } =>
|
||||||
construct == source && amount > 0 && colour == Colour::Green,
|
construct == source && colour == Colour::Green,
|
||||||
_ => false,
|
_ => 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]
|
#[test]
|
||||||
|
|||||||
@ -727,6 +727,11 @@ impl Cast {
|
|||||||
colour: Colour::Blue,
|
colour: Colour::Blue,
|
||||||
values: vec![Value::Stat { construct: self.source, stat: Stat::BluePower, mult: self.skill.multiplier() }],
|
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![
|
Skill::SiphonPlus => vec![
|
||||||
Action::Effect {
|
Action::Effect {
|
||||||
@ -739,6 +744,11 @@ impl Cast {
|
|||||||
colour: Colour::Blue,
|
colour: Colour::Blue,
|
||||||
values: vec![Value::Stat { construct: self.source, stat: Stat::BluePower, mult: self.skill.multiplier() }],
|
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![
|
Skill::SiphonPlusPlus => vec![
|
||||||
Action::Effect {
|
Action::Effect {
|
||||||
@ -751,6 +761,11 @@ impl Cast {
|
|||||||
colour: Colour::Blue,
|
colour: Colour::Blue,
|
||||||
values: vec![Value::Stat { construct: self.source, stat: Stat::BluePower, mult: self.skill.multiplier() }],
|
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::SiphonTick |
|
||||||
Skill::SiphonTickPlus |
|
Skill::SiphonTickPlus |
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user