fix ruin cooldown
This commit is contained in:
parent
16488ee0ee
commit
9a5a93ce24
@ -435,12 +435,14 @@ impl Construct {
|
||||
}
|
||||
|
||||
pub fn skill_set_cd(&mut self, skill: Skill) -> &mut Construct {
|
||||
// println!("{:?} {:?} skill cooldown set", self.name, skill);
|
||||
|
||||
// tests force resolve some skills
|
||||
// which cause the game to attempt to put them on cd
|
||||
// even though the construct doesn't know the skill
|
||||
if let Some(i) = self.skills.iter().position(|s| s.skill == skill) {
|
||||
self.skills.remove(i);
|
||||
self.skills.push(ConstructSkill::new(skill));
|
||||
self.skills.insert(i, ConstructSkill::new(skill));
|
||||
}
|
||||
|
||||
self
|
||||
|
||||
@ -508,14 +508,14 @@ impl Game {
|
||||
self.resolve(Cast { skill, ..cast });
|
||||
}
|
||||
|
||||
// for aoe events send the source / target animations before each set of casts
|
||||
if cast.skill.cast_animation() {
|
||||
self.action(cast, Action::Cast);
|
||||
}
|
||||
|
||||
if cast.skill.aoe() {
|
||||
if cast.skill.cast_animation() {
|
||||
let event = self.cast(cast);
|
||||
self.add_resolution(&cast, &event);
|
||||
}
|
||||
let event = self.hit_aoe(cast);
|
||||
self.add_resolution(&cast, &event);
|
||||
self.action(cast, Action::HitAoe);
|
||||
} else {
|
||||
self.action(cast, Action::Hit);
|
||||
}
|
||||
|
||||
let casts = self.modify_cast(cast);
|
||||
@ -559,6 +559,7 @@ impl Game {
|
||||
let new_events = match action {
|
||||
Action::Cast => vec![self.cast(cast)],
|
||||
Action::Hit => vec![self.hit(cast)],
|
||||
Action::HitAoe => vec![self.hit_aoe(cast)],
|
||||
|
||||
Action::Damage { construct, amount, colour } => self.damage(construct, amount, colour),
|
||||
Action::Heal { construct, amount, colour } => self.heal(construct, amount, colour),
|
||||
@ -848,6 +849,7 @@ pub enum Value {
|
||||
#[derive(Debug,Clone,PartialEq)]
|
||||
pub enum Action {
|
||||
Hit,
|
||||
HitAoe,
|
||||
Cast,
|
||||
Heal { construct: Uuid, amount: usize, colour: Colour },
|
||||
Damage { construct: Uuid, amount: usize, colour: Colour },
|
||||
@ -1033,6 +1035,7 @@ mod tests {
|
||||
.learn(Skill::Siphon)
|
||||
.learn(Skill::Amplify)
|
||||
.learn(Skill::Stun)
|
||||
.learn(Skill::Ruin)
|
||||
.learn(Skill::Block)
|
||||
.learn(Skill::Sleep)
|
||||
.learn(Skill::Decay);
|
||||
@ -1251,6 +1254,31 @@ mod tests {
|
||||
assert!(game.player_by_id(y_player.id).unwrap().constructs[0].skill_on_cd(Skill::Block).is_none());
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn ruin_cooldown_test() {
|
||||
let mut game = create_test_game();
|
||||
|
||||
let x_player = game.players[0].clone();
|
||||
let y_player = game.players[1].clone();
|
||||
|
||||
let x_construct = x_player.constructs[0].clone();
|
||||
let y_construct = y_player.constructs[0].clone();
|
||||
|
||||
while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Ruin).is_some() {
|
||||
game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns();
|
||||
}
|
||||
|
||||
game.add_skill(x_player.id, x_construct.id, y_construct.id, Skill::Ruin).unwrap();
|
||||
|
||||
game.player_ready(x_player.id).unwrap();
|
||||
game.player_ready(y_player.id).unwrap();
|
||||
|
||||
game = game.resolve_phase_start();
|
||||
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Ruin).is_some());
|
||||
}
|
||||
|
||||
// #[cfg(test)]
|
||||
// mod tests {
|
||||
// use skill::*;
|
||||
@ -1595,55 +1623,6 @@ mod tests {
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
#[test]
|
||||
fn sleep_cooldown_test() {
|
||||
let mut game = create_test_game();
|
||||
|
||||
let x_player = game.players[0].clone();
|
||||
let y_player = game.players[1].clone();
|
||||
|
||||
let x_construct = x_player.constructs[0].clone();
|
||||
let y_construct = y_player.constructs[0].clone();
|
||||
|
||||
|
||||
for _n in 1..10 {
|
||||
// should auto progress back to skill phase
|
||||
assert!(game.phase == Phase::Skill);
|
||||
|
||||
// Sleep 2T CD
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Decay).is_none());
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Sleep).is_some());
|
||||
|
||||
game.player_ready(x_player.id).unwrap();
|
||||
game.player_ready(y_player.id).unwrap();
|
||||
game = game.resolve_phase_start();
|
||||
|
||||
// Sleep 1T CD
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Decay).is_none());
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Sleep).is_some());
|
||||
|
||||
game.add_skill(x_player.id, x_construct.id, y_construct.id, Skill::Decay).unwrap();
|
||||
// game.add_skill(x_player.id, x_construct.id, y_construct.id, Skill::Attack).unwrap();
|
||||
game.player_ready(x_player.id).unwrap();
|
||||
game.player_ready(y_player.id).unwrap();
|
||||
game = game.resolve_phase_start();
|
||||
|
||||
// Sleep 0T CD (we use it here)
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Decay).is_none());
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Sleep).is_none());
|
||||
|
||||
game.add_skill(x_player.id, x_construct.id, y_construct.id, Skill::Sleep).unwrap();
|
||||
game.player_ready(x_player.id).unwrap();
|
||||
game.player_ready(y_player.id).unwrap();
|
||||
game = game.resolve_phase_start();
|
||||
|
||||
// Sleep back to 2T CD
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Decay).is_none());
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Sleep).is_some());
|
||||
}
|
||||
}
|
||||
|
||||
// #[test]
|
||||
// fn counter_test() {
|
||||
// let mut game = create_test_game();
|
||||
|
||||
@ -716,7 +716,7 @@ impl Item {
|
||||
Item::HealPlusPlus |
|
||||
Item::Triage |
|
||||
Item::TriagePlus |
|
||||
Item::TriagePlusPlus |
|
||||
Item::TriagePlusPlus |
|
||||
Item::Break |
|
||||
Item::BreakPlus |
|
||||
Item::BreakPlusPlus |
|
||||
@ -735,7 +735,7 @@ impl Item {
|
||||
Item::Invert |
|
||||
Item::InvertPlus |
|
||||
Item::InvertPlusPlus |
|
||||
Item::Decay |
|
||||
Item::Decay |
|
||||
Item::DecayPlus |
|
||||
Item::DecayPlusPlus |
|
||||
Item::Siphon|
|
||||
@ -817,7 +817,7 @@ impl Item {
|
||||
|
||||
Item::AmplifyPlus => vec![Item::Amplify, Item::Amplify],
|
||||
Item::AmplifyPlusPlus => vec![Item::AmplifyPlus, Item::AmplifyPlus],
|
||||
|
||||
|
||||
Item::HastePlus => vec![Item::Haste, Item::Haste],
|
||||
Item::HastePlusPlus => vec![Item::HastePlus, Item::HastePlus],
|
||||
|
||||
@ -832,9 +832,9 @@ impl Item {
|
||||
Item::Curse => vec![Item::Debuff, Item::Red, Item::Blue],
|
||||
Item::Decay => vec![Item::Debuff, Item::Green, Item::Blue],
|
||||
|
||||
Item::PurgePlus => vec![Item::Purge, Item::Purge],
|
||||
Item::PurgePlus => vec![Item::Purge, Item::Purge],
|
||||
Item::PurgePlusPlus => vec![Item::PurgePlus, Item::PurgePlus],
|
||||
|
||||
|
||||
Item::InvertPlus => vec![Item::Invert, Item::Invert],
|
||||
Item::InvertPlusPlus => vec![Item::InvertPlus, Item::InvertPlus],
|
||||
|
||||
@ -843,10 +843,10 @@ impl Item {
|
||||
|
||||
Item::SilencePlus => vec![Item::Silence, Item::Silence],
|
||||
Item::SilencePlusPlus => vec![Item::SilencePlus, Item::SilencePlus],
|
||||
|
||||
|
||||
Item::CursePlus => vec![Item::Curse, Item::Curse],
|
||||
Item::CursePlusPlus => vec![Item::CursePlus, Item::CursePlus],
|
||||
|
||||
|
||||
Item::DecayPlus => vec![Item::Decay, Item::Decay],
|
||||
Item::DecayPlusPlus => vec![Item::DecayPlus, Item::DecayPlus],
|
||||
|
||||
@ -1427,20 +1427,13 @@ mod tests {
|
||||
assert_eq!(Item::StrikePlus.components(), vec![
|
||||
Item::Red, Item::Red, Item::Attack,
|
||||
Item::Red, Item::Red, Item::Attack,
|
||||
Item::Red, Item::Red, Item::Attack,
|
||||
]);
|
||||
assert_eq!(Item::StrikePlusPlus.components(), vec![
|
||||
Item::Red, Item::Red, Item::Attack,
|
||||
Item::Red, Item::Red, Item::Attack,
|
||||
Item::Red, Item::Red, Item::Attack,
|
||||
|
||||
Item::Red, Item::Red, Item::Attack,
|
||||
Item::Red, Item::Red, Item::Attack,
|
||||
Item::Red, Item::Red, Item::Attack,
|
||||
|
||||
Item::Red, Item::Red, Item::Attack,
|
||||
Item::Red, Item::Red, Item::Attack,
|
||||
Item::Red, Item::Red, Item::Attack,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
@ -42,13 +42,6 @@ impl Cast {
|
||||
}
|
||||
|
||||
pub fn resolve(self, game: &mut Game) {
|
||||
if !self.skill.aoe() {
|
||||
if self.skill.cast_animation() {
|
||||
game.action(self, Action::Cast);
|
||||
}
|
||||
game.action(self, Action::Hit);
|
||||
}
|
||||
|
||||
match self.skill {
|
||||
Skill::Attack => attack(self, game, Attack::Base),
|
||||
Skill::Block => block(self, game, Block::Base),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user