fix tick tests

This commit is contained in:
ntr 2020-01-03 11:13:08 +10:00
parent 640263df87
commit 69c7ddf213
3 changed files with 38 additions and 29 deletions

View File

@ -75,38 +75,19 @@ impl Effect {
match self {
Effect::Banish => true,
// delete sustain immunitiy???
/*Effect::Sustain => [
Skill::Stun,
Skill::Silence,
Skill::SilencePlus,
Skill::SilencePlusPlus,
Skill::Ruin,
Skill::RuinPlus,
Skill::RuinPlusPlus,
Skill::Restrict,
Skill::RestrictPlus,
Skill::RestrictPlusPlus
].contains(&skill),*/
// these provide immunity for the ticks
// the base skills will still resolve
// but they have early return checks
// to ensure the effect is reapplied but damage is not
Effect::Siphoned => [
Skill::Siphon,
Skill::SiphonPlus,
Skill::SiphonPlusPlus,
Skill::SiphonTick,
].contains(&skill),
Effect::Decayed => [
Skill::Decay,
Skill::DecayPlus,
Skill::DecayPlusPlus,
Skill::DecayTick,
].contains(&skill),
Effect::Triaged => [
Skill::Triage,
Skill::TriagePlus,
Skill::TriagePlusPlus,
Skill::TriageTick,
].contains(&skill),

View File

@ -388,6 +388,11 @@ impl Game {
let mut sorted = self.stack.clone();
sorted.iter_mut()
.for_each(|s| {
// we do not modify the speed of ticks
// as they are considered to be pinned to the speed
// that they were initially cast
if !s.skill.is_tick() {
let caster = self.construct_by_id(s.source).unwrap();
let speed = caster.skill_speed(s.skill);
@ -452,7 +457,15 @@ impl Game {
self.skill_phase_start(r_animation_ms)
}
fn modify_cast(&self, cast: Cast) -> Vec<Cast> {
fn modify_cast(&self, mut cast: Cast) -> Vec<Cast> {
// reassign the speeds based on the caster
// for test purposes
if !cast.skill.is_tick() {
let speed = self.construct(cast.source).skill_speed(cast.skill);
cast.speed = speed;
}
let target_player = self.players.iter()
.find(|t| t.constructs.iter().any(|c| c.id == cast.target))
.unwrap();
@ -499,11 +512,11 @@ impl Game {
}
let casts = self.modify_cast(cast);
let castable = casts.clone()
.into_iter()
let castable = casts
.iter()
.any(|c| !self.construct(c.target).is_ko() && !self.construct(c.target).immune(c.skill).is_some());
if castable {
self.action(cast, Action::Cast);
if cast.skill.aoe() {
@ -639,11 +652,14 @@ impl Game {
Value::TickDamage { construct, effect } =>
self.construct(construct).stat(Stat::TickDamage(effect)),
// Skills { construct: Uuid, colour: Colour },
}
}
pub fn affected(&self, construct: Uuid, effect: Effect) -> bool {
self.construct(construct).affected(effect)
}
fn cast(&mut self, cast: Cast) -> Event {
Event::Cast { construct: cast.source, player: cast.player, target: cast.target, skill: cast.skill, direction: self.direction(cast) }
}
@ -840,6 +856,7 @@ pub enum Value {
Removals { construct: Uuid },
DamageReceived { construct: Uuid, colour: Colour },
TickDamage { construct: Uuid, effect: Effect },
// Affected { construct: Uuid, effect: Effect }, // not an int :(
}
#[derive(Debug,Clone,PartialEq)]
@ -2127,6 +2144,8 @@ mod tests {
let last = game.resolutions.len() - 1;
let resolutions = &game.resolutions[last];
println!("{:#?}", resolutions);
let damage_events = resolutions.iter().filter(|r| match r.event {
Event::Damage { construct: _, colour: _, amount: _, mitigation: _, display: _ } => true,
_ => false,

View File

@ -989,6 +989,10 @@ fn siphon(cast: Cast, game: &mut Game, values: Siphon) {
}
);
// should only reapply the dot if they have already been hit by the dmg
// from either this or the tick
if game.affected(cast.target, Effect::Siphoned) { return; }
game.action(cast,
Action::Damage {
construct: cast.target,
@ -1580,6 +1584,8 @@ fn decay(cast: Cast, game: &mut Game, values: Decay) {
}
);
if game.affected(cast.target, Effect::Decayed) { return; }
game.action(cast,
Action::Effect {
construct: cast.target,
@ -2194,6 +2200,9 @@ fn triage(cast: Cast, game: &mut Game, values: Triage) {
Some(EffectMeta::CastTick { source: cast.source, target: cast.target, skill: Skill::TriageTick, speed: cast.speed, amount }) },
}
);
if game.affected(cast.target, Effect::Triaged) { return; }
game.action(cast,
Action::Heal {
construct: cast.target,