hatred/hostility

This commit is contained in:
ntr 2019-03-26 19:00:38 +11:00
parent 26ab281fdb
commit 52edc38cba
3 changed files with 73 additions and 14 deletions

View File

@ -9,7 +9,7 @@ use failure::err_msg;
use account::Account; use account::Account;
use rpc::{GameStateParams, GameSkillParams}; use rpc::{GameStateParams, GameSkillParams};
use cryp::{Cryp, EffectMeta}; use cryp::{Cryp};
use skill::{Skill, Effect, Cast, Resolution, Event, resolve}; use skill::{Skill, Effect, Cast, Resolution, Event, resolve};
use player::{Player}; use player::{Player};
use instance::{instance_game_finished, global_game_finished}; use instance::{instance_game_finished, global_game_finished};

View File

@ -75,6 +75,8 @@ pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutio
Skill::Slay => unimplemented!(), Skill::Slay => unimplemented!(),
Skill::Taunt => taunt(source, target, resolutions), Skill::Taunt => taunt(source, target, resolutions),
Skill::Hostility => hostility(source, target, resolutions),
Skill::Corrupt => corrupt(source, target, resolutions), Skill::Corrupt => corrupt(source, target, resolutions),
Skill::Corruption => panic!("corruption should not be castable"), Skill::Corruption => panic!("corruption should not be castable"),
Skill::CorruptionTick => corruption_tick(source, target, resolutions), Skill::CorruptionTick => corruption_tick(source, target, resolutions),
@ -91,16 +93,24 @@ pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutio
// if any event dealt damage to target cryp // if any event dealt damage to target cryp
// hit them with corruption // hit them with corruption
resolutions = match target.affected(Effect::Corrupt) {
true => match resolutions.iter().any(|r| // on damage events
// todo not sure if this fucks up with multiple calls to resolve
// have to think
for r in resolutions.clone() {
match r.event { match r.event {
Event::Damage { amount: _, mitigation: _, category: _, skill: _ } => true, Event::Damage { amount, skill, mitigation: _, category: _ } => {
_ => false, if target.affected(Effect::Corrupt) {
}) { resolutions = corruption(target, source, resolutions);
true => corruption(target, source, resolutions), }
false => resolutions,
if target.affected(Effect::Hostility) {
resolutions = hatred(target, source, resolutions, skill, amount);
}
}, },
false => resolutions, _ => (),
}
}; };
// i don't think we need to check the source being ko // i don't think we need to check the source being ko
@ -221,7 +231,6 @@ pub enum Effect {
Empower, Empower,
Taunt, Taunt,
Hatred,
Invert, Invert,
Strangle, Strangle,
@ -244,6 +253,11 @@ pub enum Effect {
Corrupt, Corrupt,
Corruption, Corruption,
// hostility is the buff
// hatred is the increased damage
Hostility,
Hatred,
// magic immunity // magic immunity
Shield, Shield,
@ -384,6 +398,8 @@ impl Effect {
Effect::Corrupt => Category::BlueBuff, Effect::Corrupt => Category::BlueBuff,
Effect::Corruption => Category::BlueDebuff, Effect::Corruption => Category::BlueDebuff,
Effect::Hostility => Category::BlueBuff,
// magic immunity // magic immunity
Effect::Shield => Category::BlueBuff, Effect::Shield => Category::BlueBuff,
Effect::Invert => Category::GreenBuff, Effect::Invert => Category::GreenBuff,
@ -431,6 +447,9 @@ impl Effect {
Effect::Amplify => 2, Effect::Amplify => 2,
Effect::Silence => 2, Effect::Silence => 2,
Effect::Hostility => 2,
Effect::Hatred => 5,
Effect::Corrupt => 2, Effect::Corrupt => 2,
Effect::Corruption => 3, Effect::Corruption => 3,
@ -515,6 +534,8 @@ pub enum Skill {
SiphonTick, SiphonTick,
Curse, Curse,
Hostility,
Corrupt, Corrupt,
Corruption, Corruption,
CorruptionTick, CorruptionTick,
@ -588,6 +609,8 @@ impl Skill {
Skill::Corruption => None, Skill::Corruption => None,
Skill::CorruptionTick => None, Skill::CorruptionTick => None,
Skill::Hostility => Some(1),
// ----------------- // -----------------
// Test // Test
// ----------------- // -----------------
@ -669,6 +692,8 @@ impl Skill {
Skill::Slay => Category::Red, Skill::Slay => Category::Red,
Skill::Taunt => Category::Red, Skill::Taunt => Category::Red,
Skill::Hostility => Category::Blue,
Skill::Corrupt => Category::Blue, Skill::Corrupt => Category::Blue,
Skill::Corruption => Category::Blue, Skill::Corruption => Category::Blue,
Skill::CorruptionTick => Category::Blue, Skill::CorruptionTick => Category::Blue,
@ -955,12 +980,27 @@ fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resol
return results;; 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::new(Effect::Hex); let hex = CrypEffect::new(Effect::Hex);
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)));
return results;; return results;;
} }
fn hostility(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect::new(Effect::Hostility);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Hostility, effect)));
return results;;
}
fn hatred(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill, amount: u64) -> Resolutions {
let effect = CrypEffect::new(Effect::Hatred)
.set_meta(EffectMeta::AddedDamage(amount));
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;;
}
fn curse(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn curse(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let curse = CrypEffect::new(Effect::Curse); let curse = CrypEffect::new(Effect::Curse);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Curse, curse))); results.push(Resolution::new(source, target).event(target.add_effect(Skill::Curse, curse)));
@ -1221,6 +1261,22 @@ mod tests {
assert!(x.affected(Effect::Corruption)); assert!(x.affected(Effect::Corruption));
} }
#[test]
fn hatred_test() {
let mut x = Cryp::new()
.named(&"muji".to_string());
let mut y = Cryp::new()
.named(&"camel".to_string());
hostility(&mut y.clone(), &mut y, vec![]);
assert!(y.affected(Effect::Hostility));
resolve(Skill::Attack, &mut x, &mut y, vec![]);
assert!(x.affected(Effect::Hatred));
}
#[test] #[test]
fn triage_test() { fn triage_test() {
let mut x = Cryp::new() let mut x = Cryp::new()

View File

@ -68,6 +68,7 @@ pub enum Var {
Curse, Curse,
Decay, Decay,
Empower, Empower,
Hostility,
Haste, Haste,
Heal, Heal,
Hex, Hex,
@ -189,6 +190,7 @@ impl Var {
Var::Haste => Some(Skill::Haste), Var::Haste => Some(Skill::Haste),
Var::Heal => Some(Skill::Heal), Var::Heal => Some(Skill::Heal),
Var::Hex => Some(Skill::Hex), Var::Hex => Some(Skill::Hex),
Var::Hostility => Some(Skill::Hostility),
Var::Invert => Some(Skill::Invert), Var::Invert => Some(Skill::Invert),
Var::Parry => Some(Skill::Parry), Var::Parry => Some(Skill::Parry),
Var::Purge => Some(Skill::Purge), Var::Purge => Some(Skill::Purge),
@ -255,6 +257,7 @@ impl From<Skill> for Var {
Skill::Decay => Var::Decay, Skill::Decay => Var::Decay,
Skill::Empower => Var::Empower, Skill::Empower => Var::Empower,
Skill::Haste => Var::Haste, Skill::Haste => Var::Haste,
Skill::Hostility => Var::Hostility,
Skill::Heal => Var::Heal, Skill::Heal => Var::Heal,
Skill::Hex => Var::Hex, Skill::Hex => Var::Hex,
Skill::Invert => Var::Invert, Skill::Invert => Var::Invert,