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 {
|
pub fn skill_set_cd(&mut self, skill: Skill) -> &mut Construct {
|
||||||
|
// println!("{:?} {:?} skill cooldown set", self.name, skill);
|
||||||
|
|
||||||
// tests force resolve some skills
|
// tests force resolve some skills
|
||||||
// which cause the game to attempt to put them on cd
|
// which cause the game to attempt to put them on cd
|
||||||
// even though the construct doesn't know the skill
|
// even though the construct doesn't know the skill
|
||||||
if let Some(i) = self.skills.iter().position(|s| s.skill == skill) {
|
if let Some(i) = self.skills.iter().position(|s| s.skill == skill) {
|
||||||
self.skills.remove(i);
|
self.skills.remove(i);
|
||||||
self.skills.push(ConstructSkill::new(skill));
|
self.skills.insert(i, ConstructSkill::new(skill));
|
||||||
}
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
|
|||||||
@ -508,14 +508,14 @@ impl Game {
|
|||||||
self.resolve(Cast { skill, ..cast });
|
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.aoe() {
|
||||||
if cast.skill.cast_animation() {
|
self.action(cast, Action::HitAoe);
|
||||||
let event = self.cast(cast);
|
} else {
|
||||||
self.add_resolution(&cast, &event);
|
self.action(cast, Action::Hit);
|
||||||
}
|
|
||||||
let event = self.hit_aoe(cast);
|
|
||||||
self.add_resolution(&cast, &event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let casts = self.modify_cast(cast);
|
let casts = self.modify_cast(cast);
|
||||||
@ -559,6 +559,7 @@ impl Game {
|
|||||||
let new_events = match action {
|
let new_events = match action {
|
||||||
Action::Cast => vec![self.cast(cast)],
|
Action::Cast => vec![self.cast(cast)],
|
||||||
Action::Hit => vec![self.hit(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::Damage { construct, amount, colour } => self.damage(construct, amount, colour),
|
||||||
Action::Heal { construct, amount, colour } => self.heal(construct, amount, colour),
|
Action::Heal { construct, amount, colour } => self.heal(construct, amount, colour),
|
||||||
@ -848,6 +849,7 @@ pub enum Value {
|
|||||||
#[derive(Debug,Clone,PartialEq)]
|
#[derive(Debug,Clone,PartialEq)]
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
Hit,
|
Hit,
|
||||||
|
HitAoe,
|
||||||
Cast,
|
Cast,
|
||||||
Heal { construct: Uuid, amount: usize, colour: Colour },
|
Heal { construct: Uuid, amount: usize, colour: Colour },
|
||||||
Damage { construct: Uuid, amount: usize, colour: Colour },
|
Damage { construct: Uuid, amount: usize, colour: Colour },
|
||||||
@ -1033,6 +1035,7 @@ mod tests {
|
|||||||
.learn(Skill::Siphon)
|
.learn(Skill::Siphon)
|
||||||
.learn(Skill::Amplify)
|
.learn(Skill::Amplify)
|
||||||
.learn(Skill::Stun)
|
.learn(Skill::Stun)
|
||||||
|
.learn(Skill::Ruin)
|
||||||
.learn(Skill::Block)
|
.learn(Skill::Block)
|
||||||
.learn(Skill::Sleep)
|
.learn(Skill::Sleep)
|
||||||
.learn(Skill::Decay);
|
.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());
|
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)]
|
// #[cfg(test)]
|
||||||
// mod tests {
|
// mod tests {
|
||||||
// use skill::*;
|
// 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]
|
// #[test]
|
||||||
// fn counter_test() {
|
// fn counter_test() {
|
||||||
// let mut game = create_test_game();
|
// let mut game = create_test_game();
|
||||||
|
|||||||
@ -1427,20 +1427,13 @@ mod tests {
|
|||||||
assert_eq!(Item::StrikePlus.components(), vec![
|
assert_eq!(Item::StrikePlus.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,
|
|
||||||
]);
|
]);
|
||||||
assert_eq!(Item::StrikePlusPlus.components(), vec![
|
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,
|
||||||
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) {
|
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 {
|
match self.skill {
|
||||||
Skill::Attack => attack(self, game, Attack::Base),
|
Skill::Attack => attack(self, game, Attack::Base),
|
||||||
Skill::Block => block(self, game, Block::Base),
|
Skill::Block => block(self, game, Block::Base),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user