tick immunities for all

This commit is contained in:
ntr 2019-12-11 15:12:51 +10:00
parent c1655c9496
commit 5e8d6a62af
3 changed files with 43 additions and 15 deletions

View File

@ -7,7 +7,7 @@ use failure::Error;
use failure::err_msg;
use skill::{Skill, Cast};
use game::{Colour, Disable, Event, EventConstruct};
use game::{Colour, Disable, Immunity, Event, EventConstruct};
use effect::{Cooldown, Effect};
use spec::{Spec};
use item::{Item};
@ -954,7 +954,7 @@ impl Construct {
let skill = match meta {
Some(EffectMeta::CastOnHit(s)) => s,
_ => panic!("no electrify skill"),
_ => panic!("no electrify skill {:?}", meta),
};
casts.push(Cast::new(self.id, self.account, cast.source, *skill));
@ -979,7 +979,7 @@ impl Construct {
let skill = match meta {
Some(EffectMeta::CastOnHit(s)) => s,
_ => panic!("no counter skill"),
_ => panic!("no counter skill {:?}", meta),
};
casts.push(Cast::new(self.id, self.account, cast.source, *skill));

View File

@ -87,10 +87,32 @@ impl Effect {
].contains(&skill),
Effect::Siphoned => [
Skill::Siphon,
Skill::SiphonPlus,
Skill::SiphonPlusPlus,
Skill::SiphonTick,
Skill::SiphonTickPlus,
Skill::SiphonTickPlusPlus,
].contains(&skill),
Effect::Decayed => [
Skill::Decay,
Skill::DecayPlus,
Skill::DecayPlusPlus,
Skill::DecayTick,
Skill::DecayTickPlus,
Skill::DecayTickPlusPlus,
].contains(&skill),
Effect::Triaged => [
Skill::Triage,
Skill::TriagePlus,
Skill::TriagePlusPlus,
Skill::TriageTick,
Skill::TriageTickPlus,
Skill::TriageTickPlusPlus,
].contains(&skill),
_ => false,
}
}

View File

@ -17,6 +17,10 @@ use util::{IntPct};
use player::{Player};
use instance::{TimeControl};
pub type Disable = Vec<Effect>;
pub type Immunity = Vec<Effect>;
pub type Direction = (i8, i8);
#[derive(Debug,Clone,Serialize,Deserialize)]
pub struct Game {
pub id: Uuid,
@ -173,8 +177,6 @@ impl Game {
}
self.phase = Phase::Skill;
self.resolutions.push(vec![]);
self.phase_start = Utc::now()
.checked_add_signed(Duration::milliseconds(resolution_animation_ms))
.expect("could not set phase start");
@ -394,6 +396,7 @@ impl Game {
panic!("game not in skill phase");
}
self.phase = Phase::Resolve;
self.resolutions.push(vec![]);
// self.log.push("<Resolve Phase>".to_string());
self.resolve_stack()
@ -528,6 +531,11 @@ impl Game {
return self;
}
if let Some(immunity) = self.construct(cast.target).immune(cast.skill) {
self.add_resolution(&cast, &Event::Immune { construct: cast.target, effects: immunity });
return self;
}
if self.construct(cast.target).affected(Effect::Reflect) && cast.skill.colours().contains(&Colour::Blue) && !cast.skill.is_tick() {
self.add_resolution(&cast, &Event::Reflection { construct: cast.target });
@ -923,9 +931,6 @@ impl Resolution {
}
}
pub type Disable = Vec<Effect>;
pub type Direction = (i8, i8);
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
pub enum Event {
Cast { construct: Uuid, player: Uuid, direction: Direction },
@ -940,6 +945,7 @@ pub enum Event {
Inversion { construct: Uuid },
Reflection { construct: Uuid },
Disable { construct: Uuid, effects: Vec<Effect> },
Immune { construct: Uuid, effects: Vec<Effect> },
TargetKo { construct: Uuid },
Ko { construct: Uuid },
@ -1011,6 +1017,7 @@ impl Event {
Event::TargetKo { construct: _ } |
Event::Disable { construct: _, effects: _ } |
Event::Immune { construct: _, effects: _ } |
Event::Forfeit() => Animation::Skip,
}
}
@ -1100,7 +1107,8 @@ mod tests {
assert!(game.can_start());
return game.start();
game = game.start();
return game.resolve_phase_start();
}
fn create_2v2_test_game() -> Game {
@ -1146,7 +1154,8 @@ mod tests {
assert!(game.can_start());
return game.start();
game = game.start();
return game.resolve_phase_start();
}
// #[test]
@ -1813,17 +1822,14 @@ mod tests {
// que ota?
game.resolve(Cast::new(source, player_id, target, Skill::Siphon));
game = game.resolve_phase_start();
let last = game.resolutions.len() - 2;
let last = game.resolutions.len() - 1;
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);
}