Fixed ruin resolution cast

This commit is contained in:
Mashy
2019-05-08 13:19:51 +10:00
parent af03d37404
commit 54b7757e2a
5 changed files with 28 additions and 24 deletions
+8 -4
View File
@@ -511,6 +511,10 @@ impl Game {
self.log.push(format!("[{:}] {:} {:?} {:} {:?} {:}T",
speed, source.name, skill, target.name, effect, duration)),
Event::AoeSkill { skill } =>
self.log.push(format!("[{:}] {:} {:?} {:}",
speed, source.name, skill, target.name)),
Event::Skill { skill } =>
self.log.push(format!("[{:}] {:} {:?} {:}",
speed, source.name, skill, target.name)),
@@ -1126,11 +1130,11 @@ mod tests {
// should auto progress back to skill phase
assert!(game.phase == Phase::Skill);
assert!(game.player_by_id(y_player.id).unwrap().cryps[0].skill_on_cd(Skill::Stun).is_none());
assert!(game.player_by_id(y_player.id).unwrap().cryps[0].skill_on_cd(Skill::Stun).is_some());
// second round
// now we block and it should go back on cd
let _x_block_id = game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::Stun).unwrap();
// let _x_block_id = game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::Stun).unwrap();
let _y_touch_id = game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap();
game.player_ready(x_player.id).unwrap();
@@ -1138,7 +1142,7 @@ mod tests {
game = game.resolve_phase_start();
assert!(game.player_by_id(x_player.id).unwrap().cryps[0].skill_on_cd(Skill::Stun).is_some());
assert!(game.player_by_id(x_player.id).unwrap().cryps[0].skill_on_cd(Skill::Stun).is_none());
assert!(game.player_by_id(y_player.id).unwrap().cryps[0].skill_on_cd(Skill::Block).is_none());
}
@@ -1320,7 +1324,7 @@ mod tests {
assert!(*duration == 1);
true
},
Event::Skill { skill } => false,
Event::AoeSkill { skill } => false,
_ => panic!("ruin result not effect {:?}", event),
}
false => false,
+8 -4
View File
@@ -20,6 +20,10 @@ pub fn pre_resolve(cast: &Cast, game: &mut Game, mut resolutions: Resolutions) -
let source = game.cryp_by_id(cast.source_cryp_id).unwrap().clone();
let targets = game.get_targets(cast.skill, &source, cast.target_cryp_id);
if (skill.aoe()) { // Send an aoe skill event for anims
resolutions.push(Resolution::new(&source, &game.cryp_by_id(cast.target_cryp_id).unwrap().clone()).event(Event::AoeSkill { skill }));
}
for target_id in targets {
let mut source = game.cryp_by_id(cast.source_cryp_id).unwrap().clone();
let mut target = game.cryp_by_id(target_id).unwrap().clone();
@@ -275,6 +279,7 @@ pub enum Event {
Inversion { skill: Skill },
Reflection { skill: Skill },
Effect { skill: Skill, effect: Effect, duration: u8 },
AoeSkill { skill: Skill },
Skill { skill: Skill },
Removal { effect: Effect },
TargetKo { skill: Skill },
@@ -740,7 +745,7 @@ impl Skill {
Skill::Parry => Some(2), // avoid all damage
Skill::Riposte => None, // used on parry
Skill::Snare => Some(2),
Skill::Stun => Some(1),
Skill::Stun => Some(2),
Skill::Heal => None,
Skill::Triage => None, // hot
Skill::TriageTick => None,
@@ -748,7 +753,7 @@ impl Skill {
Skill::Blast => None,
Skill::Chaos => None,
Skill::Amplify => Some(1),
Skill::Impurity => None,
Skill::Impurity => Some(3),
Skill::ImpureBlast => None,
Skill::Invert => Some(2),
Skill::Decay => Some(1), // dot
@@ -767,7 +772,7 @@ impl Skill {
Skill::Reflect => Some(2),
Skill::Recharge => Some(2),
Skill::Ruin => Some(3),
Skill::Ruin => None,
Skill::Slay => None,
Skill::Sleep => Some(3),
@@ -1222,7 +1227,6 @@ fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolution
}
fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
results.push(Resolution::new(source, target).event(Event::Skill { skill }));
let effect = CrypEffect::new(Effect::Ruin, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;;