ruin + test

This commit is contained in:
ntr 2019-03-25 15:39:44 +11:00
parent cff22550f9
commit ab2549219d
5 changed files with 54 additions and 10 deletions

View File

@ -29,9 +29,6 @@ ensure all skills impl
Skill::Taunt -> redirect incomnig attacks to self Skill::Taunt -> redirect incomnig attacks to self
Skill::Toxic -> apply debuff to attackers Skill::Toxic -> apply debuff to attackers
include target name in effect resolution
eg strangle applies buff to self
make parry semi-aggressive make parry semi-aggressive
constants constants
change to ownership pattern change to ownership pattern

View File

@ -293,9 +293,8 @@ impl Cryp {
None None
} }
pub fn is_stunned(&self) -> bool { pub fn is_stunned(&self) -> bool {
self.effects.iter().any(|s| s.effect == Effect::Stun) self.available_skills().len() == 0
} }
pub fn is_inverted(&self) -> bool { pub fn is_inverted(&self) -> bool {

View File

@ -10,7 +10,7 @@ use failure::err_msg;
use account::Account; use account::Account;
use rpc::{GameStateParams, GameSkillParams}; use rpc::{GameStateParams, GameSkillParams};
use cryp::{Cryp}; use cryp::{Cryp};
use skill::{Skill, Cast, Resolution, Event}; use skill::{Skill, Effect, Cast, Resolution, Event};
use player::{Player}; use player::{Player};
use instance::{instance_game_finished, global_game_finished}; use instance::{instance_game_finished, global_game_finished};
@ -1108,6 +1108,43 @@ mod tests {
assert!(game.team_by_id(x_team.id).cryps[0].is_stunned() == false); assert!(game.team_by_id(x_team.id).cryps[0].is_stunned() == false);
} }
#[test]
fn aoe_test() {
let mut game = create_2v2_test_game();
let i_team = game.teams[0].clone();
let x_team = game.teams[1].clone();
let i_cryp = i_team.cryps[0].clone();
let j_cryp = i_team.cryps[1].clone();
let x_cryp = x_team.cryps[0].clone();
let y_cryp = x_team.cryps[1].clone();
game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::Ruin);
while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::Ruin).is_some() {
game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns();
}
game.add_skill(i_team.id, i_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap();
game.add_skill(i_team.id, j_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap();
game.add_skill(x_team.id, x_cryp.id, Some(i_cryp.id), Skill::Ruin).unwrap();
game.add_skill(x_team.id, y_cryp.id, Some(i_cryp.id), Skill::TestTouch).unwrap();
assert!(game.skill_phase_finished());
game = game.resolve_phase_start();
assert!(game.resolved.len() == 2);
let Resolution { source: _, target: _, event } = game.resolved.pop().unwrap();
match event {
Event::Effect { effect, duration } => {
assert!(effect == Effect::Ruin);
assert!(duration == 1);
}
_ => panic!("result was not recharge"),
}
}
#[test] #[test]
fn ko_pve_test() { fn ko_pve_test() {
let mut game = create_2v2_test_game(); let mut game = create_2v2_test_game();

View File

@ -136,6 +136,7 @@ pub enum Effect {
// magic // magic
Hex, Hex,
Ruin,
Curse, Curse,
Banish, Banish,
Slow, Slow,
@ -184,6 +185,7 @@ impl Effect {
match self { match self {
Effect::Stun => true, Effect::Stun => true,
Effect::Hex => true, Effect::Hex => true,
Effect::Ruin => true,
Effect::Banish => true, Effect::Banish => true,
Effect::Strangle => true, Effect::Strangle => true,
Effect::Strangling => skill != Skill::StrangleTick, Effect::Strangling => skill != Skill::StrangleTick,
@ -266,6 +268,7 @@ impl Effect {
// magic // magic
Effect::Hex => Category::BlueDebuff, Effect::Hex => Category::BlueDebuff,
Effect::Ruin => Category::BlueDebuff,
Effect::Curse => Category::BlueDebuff, Effect::Curse => Category::BlueDebuff,
Effect::Banish => Category::BlueDebuff, // todo randomise Effect::Banish => Category::BlueDebuff, // todo randomise
Effect::Slow => Category::BlueDebuff, Effect::Slow => Category::BlueDebuff,
@ -312,6 +315,7 @@ impl Effect {
Effect::Invert => 1, Effect::Invert => 1,
Effect::Hex => 2, Effect::Hex => 2,
Effect::Ruin => 1,
Effect::Curse => 2, Effect::Curse => 2,
Effect::Banish => 1, Effect::Banish => 1,
@ -460,7 +464,7 @@ impl Skill {
Skill::Slow => None, Skill::Slow => None,
Skill::Reflect => Some(2), Skill::Reflect => Some(2),
Skill::Recharge => Some(2), Skill::Recharge => Some(2),
Skill::Ruin => Some(1), Skill::Ruin => Some(3),
Skill::Slay => None, Skill::Slay => None,
Skill::Strangle => Some(2), Skill::Strangle => Some(2),
Skill::StrangleTick => None, Skill::StrangleTick => None,
@ -668,7 +672,7 @@ impl Skill {
Skill::StrangleTick => strangle_tick(source, target, results), Skill::StrangleTick => strangle_tick(source, target, results),
Skill::Reflect => reflect(source, target, results), Skill::Reflect => reflect(source, target, results),
Skill::Ruin => unimplemented!(), Skill::Ruin => ruin(source, target, results),
Skill::Slay => unimplemented!(), Skill::Slay => unimplemented!(),
Skill::Taunt => unimplemented!(), Skill::Taunt => unimplemented!(),
Skill::Toxic => unimplemented!(), Skill::Toxic => unimplemented!(),
@ -853,6 +857,12 @@ fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) ->
return results; return results;
} }
fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect { effect: Effect::Ruin, duration: Effect::Ruin.duration(), tick: None };
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Ruin, effect)));
return results;;
}
fn hex(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn hex(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let hex = CrypEffect { effect: Effect::Hex, duration: Effect::Hex.duration(), tick: None }; let hex = CrypEffect { effect: Effect::Hex, duration: Effect::Hex.duration(), tick: None };
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Hex, hex))); results.push(Resolution::new(source, target).event(target.add_effect(Skill::Hex, hex)));

View File

@ -195,7 +195,7 @@ impl Var {
Var::Purify => Some(Skill::Purify), Var::Purify => Some(Skill::Purify),
Var::Recharge => Some(Skill::Recharge), Var::Recharge => Some(Skill::Recharge),
Var::Reflect => Some(Skill::Reflect), Var::Reflect => Some(Skill::Reflect),
// Var::Ruin => Some(Skill::Ruin), Var::Ruin => Some(Skill::Ruin),
Var::Shield => Some(Skill::Shield), Var::Shield => Some(Skill::Shield),
Var::Silence => Some(Skill::Silence), Var::Silence => Some(Skill::Silence),
// Var::Slay => Some(Skill::Slay), // Var::Slay => Some(Skill::Slay),
@ -273,6 +273,7 @@ impl From<Skill> for Var {
Skill::Decay => Var::Decay, Skill::Decay => Var::Decay,
Skill::Reflect => Var::Reflect, Skill::Reflect => Var::Reflect,
Skill::Recharge => Var::Recharge, Skill::Recharge => Var::Recharge,
Skill::Ruin => Var::Ruin,
Skill::TestTouch => Var::TestTouch, Skill::TestTouch => Var::TestTouch,
Skill::TestStun => Var::TestStun, Skill::TestStun => Var::TestStun,