diff --git a/core/src/construct.rs b/core/src/construct.rs index 03595135..216c2dd0 100644 --- a/core/src/construct.rs +++ b/core/src/construct.rs @@ -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)); diff --git a/core/src/effect.rs b/core/src/effect.rs index 6d44d987..d9d4e7b8 100644 --- a/core/src/effect.rs +++ b/core/src/effect.rs @@ -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, } } diff --git a/core/src/game.rs b/core/src/game.rs index e7c6b391..d5adb9b5 100644 --- a/core/src/game.rs +++ b/core/src/game.rs @@ -17,6 +17,10 @@ use util::{IntPct}; use player::{Player}; use instance::{TimeControl}; +pub type Disable = Vec; +pub type Immunity = Vec; +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("".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; -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 }, + Immune { construct: Uuid, effects: Vec }, 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); }