resolutions now affected by status effects

This commit is contained in:
ntr 2018-12-04 19:17:43 +11:00
parent aa2ecc4ce6
commit 6ad1ff2d3b
5 changed files with 141 additions and 93 deletions

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>cryps.gg - mnml pvp tbs</title>
<title>cryps.gg - mnml pvp atbs</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script defer src="https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>

View File

@ -9,6 +9,8 @@
* Global rolls
* notifications
* skills
* check cryp status when resolving skills
* ko / stun / silence etc prevent effect

View File

@ -9,7 +9,7 @@ use failure::err_msg;
use account::Account;
use rpc::{CrypSpawnParams, CrypLearnParams, CrypForgetParams};
use skill::{Skill, Cooldown, Effect, Cast, Immunity};
use skill::{Skill, Cooldown, Effect, Cast, Immunity, Disable};
use game::{Log};
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
@ -179,7 +179,6 @@ impl Cryp {
}
pub fn immune(&self, skill: Skill) -> Immunity {
if self.is_ko() {
return Immunity { immune: true, effects: vec![Effect::Ko]};
}
@ -196,12 +195,30 @@ impl Cryp {
return Immunity { immune: false, effects: vec![]};
}
pub fn disabled(&self, skill: Skill) -> Disable {
if self.is_ko() {
return Disable { disabled: true, effects: vec![Effect::Ko]};
}
let disables = self.effects.iter()
.filter(|e| e.effect.disables_skill(skill))
.map(|e| e.effect)
.collect::<Vec<Effect>>();
if disables.len() > 0 {
return Disable { disabled: true, effects: disables};
}
return Disable { disabled: false, effects: vec![]};
}
pub fn is_stunned(&self) -> bool {
self.effects.iter().any(|s| s.effect == Effect::Stun)
}
pub fn available_skills(&self) -> Vec<&CrypSkill> {
self.skills.iter().filter(|s| !s.skill.disabled(self)).collect()
self.skills.iter().filter(|s| !self.disabled(s.skill).disabled).collect()
}
pub fn knows(&self, skill: Skill) -> bool {

View File

@ -244,7 +244,8 @@ impl Game {
}
// check here as well so uncastable spells don't go on the stack
if skill.disabled(&cryp) {
let check = cryp.disabled(skill);
if check.disabled {
return Err(err_msg("cryp cannot cast that skill"));
}
}
@ -1010,6 +1011,7 @@ mod tests {
game.resolve_phase_start();
// resolution should have been prevented by KO
println!("{:#?}", game);
assert!(!game.team_by_id(y_team.id).cryps[0].is_stunned());
assert!(game.phase == Phase::Finish);
}

View File

@ -1,7 +1,6 @@
use rand::{thread_rng, Rng};
use uuid::Uuid;
use game::{Log};
use cryp::{Cryp, CrypEffect, Stat};
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
@ -30,7 +29,7 @@ impl Cast {
target_cryp_id,
target_team_id,
skill,
resolution: Resolution { skill, results: vec![] },
resolution: Resolution::new(skill),
};
}
@ -62,6 +61,24 @@ pub struct Immunity {
pub effects: Vec<Effect>
}
impl Immunity {
fn new() -> Immunity {
Immunity { immune: false, effects: vec![] }
}
}
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
pub struct Disable {
pub disabled: bool,
pub effects: Vec<Effect>
}
impl Disable {
fn new() -> Disable {
Disable { disabled: false, effects: vec![] }
}
}
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
pub enum ResolutionResult {
Damage { amount: u64, category: Category , immunity: Immunity },
@ -72,9 +89,16 @@ pub enum ResolutionResult {
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
pub struct Resolution {
pub skill: Skill,
pub disable: Disable,
pub results: Vec<ResolutionResult>,
}
impl Resolution {
fn new(skill: Skill) -> Resolution {
Resolution { skill, results: vec![], disable: Disable::new() }
}
}
pub type Cooldown = Option<u8>;
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
@ -570,22 +594,28 @@ impl Skill {
pub fn resolve(&self, cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
let mut rng = thread_rng();
let base: u64 = rng.gen();
let _base: u64 = rng.gen();
let resolution = Resolution { skill: *self, results: vec![], disable: cryp.disabled(*self) };
if resolution.disable.disabled {
return resolution;
}
match self {
Skill::Attack => attack(cryp, target),
Skill::Attack => attack(cryp, target, resolution),
// -----------------
// Nature
// -----------------
Skill::Block => block(cryp, target),
Skill::Block => block(cryp, target, resolution),
Skill::Evade => panic!("nyi"), //
Skill::Parry => panic!("nyi"), // avoid all dmg
Skill::Snare => snare(cryp, target), // TODO prevent physical moves
Skill::Snare => snare(cryp, target, resolution), // TODO prevent physical moves
Skill::Paralyse => panic!("nyi"), // no physical moves
Skill::Strangle => panic!("nyi"), // no physical moves
Skill::Stun => stun(cryp, target),
Skill::Stun => stun(cryp, target, resolution),
Skill::Evasion => panic!("nyi"), // additional layer of dmg avoidance
// -----------------
@ -600,10 +630,10 @@ impl Skill {
// -----------------
// Preservation
// -----------------
Skill::Heal => heal(cryp, target),
Skill::Triage => triage(cryp, target), // hot
Skill::TriageTick => triage_tick(cryp, target), // hot
Skill::Throw => throw(cryp, target), // no dmg stun, adds vulnerable
Skill::Heal => heal(cryp, target, resolution),
Skill::Triage => triage(cryp, target, resolution), // hot
Skill::TriageTick => triage_tick(cryp, target, resolution), // hot
Skill::Throw => throw(cryp, target, resolution), // no dmg stun, adds vulnerable
Skill::Charm => panic!("nyi"), // target casts random spell on teammate
Skill::Calm => panic!("nyi"), // physical fear, taunt removal
Skill::Rez => panic!("nyi"),
@ -611,13 +641,13 @@ impl Skill {
// -----------------
// Destruction
// -----------------
Skill::Blast => blast(cryp, target),
Skill::Amplify => amplify(cryp, target), // increase magic dmg
Skill::Decay => decay(cryp, target), // dot
Skill::DecayTick => decay_tick(cryp, target), // hot
Skill::Drain => drain(cryp, target),
Skill::DrainTick => drain_tick(cryp, target), // hot
Skill::Curse => curse(cryp, target),
Skill::Blast => blast(cryp, target, resolution),
Skill::Amplify => amplify(cryp, target, resolution), // increase magic dmg
Skill::Decay => decay(cryp, target, resolution), // dot
Skill::DecayTick => decay_tick(cryp, target, resolution), // hot
Skill::Drain => drain(cryp, target, resolution),
Skill::DrainTick => drain_tick(cryp, target, resolution), // hot
Skill::Curse => curse(cryp, target, resolution),
Skill::Plague => panic!("nyi"), // dot that spreads every turn
Skill::Ruin => panic!("nyi"), // aoe version of blast
@ -625,19 +655,19 @@ impl Skill {
// Purity
// -----------------
// Skill::Precision => panic!("nyi"),
Skill::Empower => empower(cryp, target), // increased phys dmg
Skill::Empower => empower(cryp, target, resolution), // increased phys dmg
Skill::Slay => panic!("nyi"), // phys dmg mult by target magic dmg
Skill::Shield => shield(cryp, target), // target is immune to magic dmg and fx
Skill::Silence => silence(cryp, target), // target cannot cast spells
Skill::Shield => shield(cryp, target, resolution), // target is immune to magic dmg and fx
Skill::Silence => silence(cryp, target, resolution), // target cannot cast spells
Skill::Inquiry => panic!("nyi"), //
Skill::Purify => purify(cryp, target), // dispel all debuffs
Skill::Purge => purge(cryp, target), // dispel all buffs
Skill::Purify => purify(cryp, target, resolution), // dispel all debuffs
Skill::Purge => purge(cryp, target, resolution), // dispel all buffs
// -----------------
// Chaos
// -----------------
Skill::Banish => banish(cryp, target), // TODO prevent all actions
Skill::Hex => hex(cryp, target), // todo prevent casting
Skill::Banish => banish(cryp, target, resolution), // TODO prevent all actions
Skill::Hex => hex(cryp, target, resolution), // todo prevent casting
Skill::Fear => panic!("nyi"), // cast random spell on self
Skill::Taunt => panic!("nyi"), // target forced to attack
Skill::Pause => panic!("nyi"), // speed slow
@ -645,10 +675,10 @@ impl Skill {
// -----------------
// Test
// -----------------
Skill::TestTouch => Resolution { skill: Skill::TestTouch, results: vec![] },
Skill::TestStun => stun(cryp, target),
Skill::TestBlock => block(cryp, target),
Skill::TestDrain => drain(cryp, target),
Skill::TestTouch => Resolution { skill: Skill::TestTouch, results: vec![], disable: Disable::new() },
Skill::TestStun => stun(cryp, target, resolution),
Skill::TestBlock => block(cryp, target, resolution),
Skill::TestDrain => drain(cryp, target, resolution),
}
}
@ -683,13 +713,9 @@ impl Skill {
_ => false,
}
}
pub fn disabled(&self, cryp: &Cryp) -> bool {
cryp.effects.iter().any(|e| e.effect.disables_skill(*self))
}
}
fn attack(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn attack(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let amount = cryp.phys_dmg();
let immunity = target.immune(Skill::Attack);
let immune = immunity.immune;
@ -700,7 +726,7 @@ fn attack(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Attack, results: vec![attack_result] };
resolution.results.push(attack_result);
if !immune {
target.deal_phys_dmg(amount);
@ -710,7 +736,7 @@ fn attack(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;
}
fn stun(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn stun(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let stun = CrypEffect { effect: Effect::Stun, duration: Skill::Stun.duration(), tick: None };
let immunity = target.immune(Skill::Stun);
let immune = immunity.immune;
@ -721,7 +747,7 @@ fn stun(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Stun, results: vec![attack_result] };
resolution.results.push(attack_result);
if !immune {
target.effects.push(stun);
@ -730,7 +756,7 @@ fn stun(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;
}
fn throw(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn throw(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let stun = CrypEffect { effect: Effect::Stun, duration: Skill::Stun.duration(), tick: None };
let vulnerable = CrypEffect { effect: Effect::Vulnerable, duration: Skill::Stun.duration(), tick: None };
let immunity = target.immune(Skill::Throw);
@ -748,7 +774,8 @@ fn throw(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Throw, results: vec![stun_result, vulnerable_result] };
resolution.results.push(stun_result);
resolution.results.push(vulnerable_result);
if !immune {
target.effects.push(stun);
@ -759,7 +786,7 @@ fn throw(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
}
fn block(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn block(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let block = CrypEffect { effect: Effect::Block, duration: Skill::Block.duration(), tick: None };
let immunity = target.immune(Skill::Block);
let immune = immunity.immune;
@ -770,7 +797,7 @@ fn block(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Block, results: vec![block_result] };
resolution.results.push(block_result);
if !immune {
target.effects.push(block);
@ -779,7 +806,7 @@ fn block(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;
}
fn snare(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn snare(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let snare = CrypEffect { effect: Effect::Snare, duration: Skill::Snare.duration(), tick: None };
let immunity = target.immune(Skill::Snare);
let immune = immunity.immune;
@ -790,7 +817,7 @@ fn snare(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Snare, results: vec![snare_result] };
resolution.results.push(snare_result);
if !immune {
target.effects.push(snare);
@ -799,7 +826,7 @@ fn snare(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;
}
fn empower(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn empower(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let empower = CrypEffect { effect: Effect::Empower, duration: Skill::Empower.duration(), tick: None };
let immunity = target.immune(Skill::Empower);
let immune = immunity.immune;
@ -810,7 +837,7 @@ fn empower(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Empower, results: vec![snare_result] };
resolution.results.push(snare_result);
if !immune {
target.effects.push(empower);
@ -820,7 +847,7 @@ fn empower(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
}
// TODO put overhealing back
fn heal(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn heal(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let amount = cryp.phys_dmg();
let immunity = target.immune(Skill::Heal);
let immune = immunity.immune;
@ -831,7 +858,7 @@ fn heal(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Heal, results: vec![heal_result] };
resolution.results.push(heal_result);
if !immune {
let (_healing, _overhealing) = target.heal(amount);
@ -842,7 +869,7 @@ fn heal(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
}
fn triage(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn triage(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let triage = CrypEffect {
effect: Effect::Triage,
duration: Skill::Triage.duration(),
@ -857,7 +884,7 @@ fn triage(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Triage, results: vec![snare_result] };
resolution.results.push(snare_result);
if !immune {
target.effects.push(triage);
@ -866,7 +893,7 @@ fn triage(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;
}
fn triage_tick(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn triage_tick(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let amount = cryp.spell_dmg().wrapping_div(2);
let immunity = target.immune(Skill::TriageTick);
let immune = immunity.immune;
@ -877,7 +904,7 @@ fn triage_tick(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::TriageTick, results: vec![heal_result] };
resolution.results.push(heal_result);
if !immune {
let (_healing, _overhealing) = target.heal(amount);
@ -887,7 +914,7 @@ fn triage_tick(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;
}
fn blast(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn blast(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let amount = cryp.spell_dmg();
let immunity = target.immune(Skill::Blast);
let immune = immunity.immune;
@ -898,7 +925,7 @@ fn blast(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Blast, results: vec![blast_result] };
resolution.results.push(blast_result);
if !immune {
target.deal_spell_dmg(amount);
@ -907,7 +934,7 @@ fn blast(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;
}
fn amplify(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn amplify(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let amplify = CrypEffect { effect: Effect::Amplify, duration: Skill::Amplify.duration(), tick: None };
let immunity = target.immune(Skill::Amplify);
let immune = immunity.immune;
@ -918,7 +945,7 @@ fn amplify(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Amplify, results: vec![amplify_result] };
resolution.results.push(amplify_result);
if !immune {
target.effects.push(amplify);
@ -927,7 +954,7 @@ fn amplify(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;;
}
fn decay(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn decay(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let decay = CrypEffect {
effect: Effect::Decay,
duration: Skill::Decay.duration(),
@ -942,7 +969,7 @@ fn decay(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Decay, results: vec![decay_result] };
resolution.results.push(decay_result);
if !immune {
target.effects.push(decay);
@ -951,7 +978,7 @@ fn decay(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;
}
fn decay_tick(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn decay_tick(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let amount = cryp.spell_dmg();
let immunity = target.immune(Skill::DecayTick);
let immune = immunity.immune;
@ -962,7 +989,7 @@ fn decay_tick(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::DecayTick, results: vec![decay_tick_result] };
resolution.results.push(decay_tick_result);
if !immune {
target.deal_spell_dmg(amount);
@ -971,7 +998,7 @@ fn decay_tick(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;
}
fn hex(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn hex(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let hex = CrypEffect { effect: Effect::Hex, duration: Skill::Hex.duration(), tick: None };
let immunity = target.immune(Skill::Hex);
let immune = immunity.immune;
@ -982,7 +1009,7 @@ fn hex(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Hex, results: vec![hex_result] };
resolution.results.push(hex_result);
if !immune {
target.effects.push(hex);
@ -991,7 +1018,7 @@ fn hex(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;;
}
fn curse(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn curse(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let curse = CrypEffect { effect: Effect::Curse, duration: Skill::Curse.duration(), tick: None };
let immunity = target.immune(Skill::Curse);
let immune = immunity.immune;
@ -1002,7 +1029,7 @@ fn curse(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Curse, results: vec![curse_result] };
resolution.results.push(curse_result);
if !immune {
target.effects.push(curse);
@ -1011,7 +1038,7 @@ fn curse(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;;
}
fn drain(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn drain(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let drain = CrypEffect {
effect: Effect::Drain,
duration: Skill::Drain.duration(),
@ -1026,7 +1053,7 @@ fn drain(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Drain, results: vec![drain_result] };
resolution.results.push(drain_result);
if !immune {
target.effects.push(drain);
@ -1036,7 +1063,7 @@ fn drain(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
}
// TODO is fukt
fn drain_tick(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn drain_tick(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let amount = cryp.spell_dmg().wrapping_div(2);
let immunity = target.immune(Skill::DrainTick);
let immune = immunity.immune;
@ -1054,7 +1081,8 @@ fn drain_tick(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
};
let resolution = Resolution { skill: Skill::DrainTick, results: vec![drain_tick_dmg_result, drain_tick_heal_result] };
resolution.results.push(drain_tick_dmg_result);
resolution.results.push(drain_tick_heal_result);
if !immune {
// need to saturate amount and check caster immunity to healing
@ -1065,7 +1093,7 @@ fn drain_tick(cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;
}
fn shield(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn shield(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let shield = CrypEffect { effect: Effect::Shield, duration: Skill::Shield.duration(), tick: None };
let immunity = target.immune(Skill::Shield);
let immune = immunity.immune;
@ -1076,7 +1104,7 @@ fn shield(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Shield, results: vec![shield_result] };
resolution.results.push(shield_result);
if !immune {
target.effects.push(shield);
@ -1085,7 +1113,7 @@ fn shield(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;
}
fn silence(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn silence(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let silence = CrypEffect { effect: Effect::Silence, duration: Skill::Silence.duration(), tick: None };
let immunity = target.immune(Skill::Silence);
let immune = immunity.immune;
@ -1096,7 +1124,7 @@ fn silence(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Silence, results: vec![silence_result] };
resolution.results.push(silence_result);
if !immune {
target.effects.push(silence);
@ -1105,12 +1133,10 @@ fn silence(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;
}
fn purge(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn purge(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let immunity = target.immune(Skill::Purge);
let immune = immunity.immune;
let mut resolution = Resolution { skill: Skill::Silence, results: vec![] };
if !immune {
for (i, ce) in target.effects.clone().iter_mut().enumerate() {
if ce.effect.category() == Category::SpellBuff {
@ -1123,12 +1149,10 @@ fn purge(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;
}
fn purify(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn purify(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let immunity = target.immune(Skill::Purify);
let immune = immunity.immune;
let mut resolution = Resolution { skill: Skill::Silence, results: vec![] };
if !immune {
for (i, ce) in target.effects.clone().iter_mut().enumerate() {
if ce.effect.category() == Category::SpellDebuff {
@ -1141,7 +1165,7 @@ fn purify(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
return resolution;
}
fn banish(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
fn banish(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let banish = CrypEffect { effect: Effect::Banish, duration: Skill::Banish.duration(), tick: None };
let immunity = target.immune(Skill::Banish);
let immune = immunity.immune;
@ -1152,7 +1176,7 @@ fn banish(_cryp: &mut Cryp, target: &mut Cryp) -> Resolution {
immunity,
};
let resolution = Resolution { skill: Skill::Banish, results: vec![banish_result] };
resolution.results.push(banish_result);
if !immune {
target.effects.push(banish);
@ -1182,7 +1206,7 @@ mod tests {
x.deal_phys_dmg(5);
heal(&mut y, &mut x);
heal(&mut y, &mut x, Resolution::new(Skill::Heal));
}
#[test]
@ -1198,7 +1222,7 @@ mod tests {
.create();
let mut log = vec![];
decay(&mut x, &mut y);
decay(&mut x, &mut y, Resolution::new(Skill::Triage));
assert!(y.effects.iter().any(|e| e.effect == Effect::Decay));
@ -1224,11 +1248,14 @@ mod tests {
y.deal_phys_dmg(5);
let prev_hp = y.hp();
triage(&mut x, &mut y);
let res = Resolution::new(Skill::Triage);
triage(&mut x, &mut y, res);
assert!(y.effects.iter().any(|e| e.effect == Effect::Triage));
triage_tick(&mut x, &mut y);
let res = Resolution::new(Skill::TriageTick);
triage_tick(&mut x, &mut y, res);
assert!(y.hp() > prev_hp);
}
@ -1239,9 +1266,9 @@ mod tests {
.level(8)
.create();
silence(&mut x.clone(), &mut x);
silence(&mut x.clone(), &mut x, Resolution::new(Skill::Silence));
assert!(x.effects.iter().any(|e| e.effect == Effect::Silence));
assert!(Skill::Decay.disabled(&x));
assert!(x.disabled(Skill::Silence).disabled);
}
#[test]
@ -1253,7 +1280,7 @@ mod tests {
x.spell_dmg.set(50);
amplify(&mut x.clone(), &mut x);
amplify(&mut x.clone(), &mut x, Resolution::new(Skill::Amplify));
assert!(x.effects.iter().any(|e| e.effect == Effect::Amplify));
assert_eq!(x.spell_dmg(), 100);
}
@ -1265,10 +1292,10 @@ mod tests {
.level(8)
.create();
decay(&mut x.clone(), &mut x);
decay(&mut x.clone(), &mut x, Resolution::new(Skill::Decay));
assert!(x.effects.iter().any(|e| e.effect == Effect::Decay));
purify(&mut x.clone(), &mut x);
purify(&mut x.clone(), &mut x, Resolution::new(Skill::Purify));
assert!(!x.effects.iter().any(|e| e.effect == Effect::Decay));
}
}