Merge branch 'multipliers'

This commit is contained in:
Mashy 2019-05-01 15:53:16 +10:00
commit 2987d56f9e
4 changed files with 319 additions and 262 deletions

View File

@ -75,8 +75,8 @@ pub struct CrypEffect {
}
impl CrypEffect {
pub fn new(effect: Effect) -> CrypEffect {
CrypEffect { effect, duration: effect.duration(), meta: None, tick: None }
pub fn new(effect: Effect, duration: u8) -> CrypEffect {
CrypEffect { effect, duration, meta: None, tick: None }
}
pub fn set_tick(mut self, tick: Cast) -> CrypEffect {
@ -702,7 +702,7 @@ impl Cryp {
// todo modified durations cause of buffs
let result = Event::Effect {
effect: effect.effect,
duration: effect.effect.duration(),
duration: effect.duration,
skill,
};

View File

@ -1085,8 +1085,8 @@ mod tests {
let x_cryp = x_player.cryps[0].clone();
let y_cryp = y_player.cryps[0].clone();
game.player_by_id(y_player.id).unwrap().cryp_by_id(y_cryp.id).unwrap().red_damage.force(u64::max_value());
game.player_by_id(y_player.id).unwrap().cryp_by_id(y_cryp.id).unwrap().speed.force(u64::max_value());
game.player_by_id(y_player.id).unwrap().cryp_by_id(y_cryp.id).unwrap().red_damage.force(1000000000);
game.player_by_id(y_player.id).unwrap().cryp_by_id(y_cryp.id).unwrap().speed.force(1000000000);
// just in case
// remove all mitigation

View File

@ -1,6 +1,7 @@
use rand::{thread_rng, Rng};
use uuid::Uuid;
use util::{IntPct};
use cryp::{Cryp, CrypEffect, EffectMeta, Stat};
use vbox::{Var};
@ -35,55 +36,59 @@ pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutio
// }
resolutions = match skill {
Skill::Amplify => amplify(source, target, resolutions), // increase magic damage
Skill::Attack => attack(source, target, resolutions),
Skill::Banish => banish(source, target, resolutions), // TODO prevent all actions
Skill::Blast => blast(source, target, resolutions),
Skill::Block => block(source, target, resolutions),
Skill::Clutch => clutch(source, target, resolutions),
Skill::Corrupt => corrupt(source, target, resolutions),
Skill::CorruptionTick => corruption_tick(source, target, resolutions),
Skill::Curse => curse(source, target, resolutions),
Skill::Decay => decay(source, target, resolutions), // dot
Skill::DecayTick => decay_tick(source, target, resolutions), // dot
Skill::Empower => empower(source, target, resolutions), // increased phys damage
Skill::Haste => haste(source, target, resolutions), // speed slow
Skill::Heal => heal(source, target, resolutions),
Skill::Hex => hex(source, target, resolutions),
Skill::Hostility => hostility(source, target, resolutions),
Skill::Invert => invert(source, target, resolutions),
Skill::Injure => injure(source, target, resolutions),
Skill::Parry => parry(source, target, resolutions),
Skill::Purge => purge(source, target, resolutions), // dispel all buffs
Skill::Purify => purify(source, target, resolutions), // dispel all debuffs
Skill::Recharge => recharge(source, target, resolutions), // target is immune to magic damage and fx
Skill::Reflect => reflect(source, target, resolutions),
Skill::Amplify => amplify(source, target, resolutions, Skill::Amplify), // increase magic damage
Skill::Attack => attack(source, target, resolutions, Skill::Attack),
Skill::Banish => banish(source, target, resolutions, Skill::Banish), // TODO prevent all actions
Skill::Blast => blast(source, target, resolutions, Skill::Blast),
Skill::Block => block(source, target, resolutions, Skill::Block),
Skill::Clutch => clutch(source, target, resolutions, Skill::Clutch),
Skill::Corrupt => corrupt(source, target, resolutions, Skill::Corrupt),
Skill::CorruptionTick => corruption_tick(source, target, resolutions, Skill::CorruptionTick),
Skill::Curse => curse(source, target, resolutions, Skill::Curse),
Skill::Decay => decay(source, target, resolutions, Skill::Decay), // dot
Skill::DecayTick => decay_tick(source, target, resolutions, Skill::DecayTick), // dot
Skill::Empower => empower(source, target, resolutions, Skill::Empower), // increased phys damage
Skill::Haste => haste(source, target, resolutions, Skill::Haste), // speed slow
Skill::Heal => heal(source, target, resolutions, Skill::Heal),
Skill::Hex => hex(source, target, resolutions, Skill::Hex),
Skill::Hostility => hostility(source, target, resolutions, Skill::Hostility),
Skill::Invert => invert(source, target, resolutions, Skill::Invert),
Skill::Injure => injure(source, target, resolutions, Skill::Injure),
Skill::Parry => parry(source, target, resolutions, Skill::Parry),
Skill::Purge => purge(source, target, resolutions, Skill::Purge), // dispel all buffs
Skill::Purify => purify(source, target, resolutions, Skill::Purify), // dispel all debuffs
Skill::Recharge => recharge(source, target, resolutions, Skill::Recharge), // target is immune to magic damage and fx
Skill::Reflect => reflect(source, target, resolutions, Skill::Reflect),
Skill::Riposte => panic!("riposte should not be caste"),
Skill::Ruin => ruin(source, target, resolutions),
Skill::Shield => shield(source, target, resolutions), // target is immune to magic damage and fx
Skill::Silence => silence(source, target, resolutions), // target cannot cast spells
Skill::Siphon => siphon(source, target, resolutions),
Skill::SiphonTick => siphon_tick(source, target, resolutions), // hot
Skill::Ruin => ruin(source, target, resolutions, Skill::Ruin),
Skill::Shield => shield(source, target, resolutions, Skill::Shield), // target is immune to magic damage and fx
Skill::Silence => silence(source, target, resolutions, Skill::Silence), // target cannot cast spells
Skill::Siphon => siphon(source, target, resolutions, Skill::Siphon),
Skill::SiphonTick => siphon_tick(source, target, resolutions, Skill::SiphonTick), // hot
Skill::Slay => unimplemented!(),
Skill::Slow => slow(source, target, resolutions), // speed slow
Skill::Snare => snare(source, target, resolutions),
Skill::Strangle => strangle(source, target, resolutions),
Skill::StrangleTick => strangle_tick(source, target, resolutions),
Skill::Strike => strike(source, target, resolutions),
Skill::Stun => stun(source, target, resolutions),
Skill::Taunt => taunt(source, target, resolutions),
Skill::Throw => throw(source, target, resolutions), // no damage stun, adds vulnerable
Skill::Triage => triage(source, target, resolutions), // hot
Skill::TriageTick => triage_tick(source, target, resolutions), // hot
Skill::Slow => slow(source, target, resolutions, Skill::Slow), // speed slow
Skill::Snare => snare(source, target, resolutions, Skill::Snare),
Skill::Strangle => strangle(source, target, resolutions, Skill::Strangle),
Skill::StrangleTick => strangle_tick(source, target, resolutions, Skill::StrangleTick),
Skill::Strike => strike(source, target, resolutions, Skill::Strike),
Skill::StrikeII => strike(source, target, resolutions, Skill::StrikeII),
Skill::StrikeIII => strike(source, target, resolutions, Skill::StrikeIII),
Skill::Stun => stun(source, target, resolutions, Skill::Stun),
Skill::Taunt => taunt(source, target, resolutions, Skill::Taunt),
Skill::Throw => throw(source, target, resolutions, Skill::Throw), // no damage stun, adds vulnerable
Skill::Triage => triage(source, target, resolutions, Skill::Triage), // hot
Skill::TriageTick => triage_tick(source, target, resolutions, Skill::TriageTick), // hot
// -----------------
// Test
// -----------------
Skill::TestTouch => touch(source, target, resolutions),
Skill::TestStun => stun(source, target, resolutions),
Skill::TestBlock => block(source, target, resolutions),
Skill::TestParry => parry(source, target, resolutions),
Skill::TestSiphon => siphon(source, target, resolutions),
Skill::TestTouch => touch(source, target, resolutions, Skill::TestTouch),
Skill::TestStun => stun(source, target, resolutions, Skill::Stun),
Skill::TestBlock => block(source, target, resolutions, Skill::Block),
Skill::TestParry => parry(source, target, resolutions, Skill::Parry),
Skill::TestSiphon => siphon(source, target, resolutions, Skill::Siphon),
};
// if any event dealt damage to target cryp
@ -96,15 +101,15 @@ pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutio
match r.event {
Event::Damage { amount, skill, mitigation: _, colour: _ } => {
if target.affected(Effect::Corrupt) {
resolutions = corruption(target, source, resolutions);
resolutions = corruption(target, source, resolutions, Skill::Corrupt);
}
if target.affected(Effect::Hostility) {
resolutions = hatred(source, target, resolutions, skill, amount);
resolutions = hatred(source, target, resolutions, skill, amount, Skill::Hostility);
}
},
Event::Immunity { skill: _, immunity } => match immunity.contains(&Effect::Parry) {
true => resolutions = riposte(target, source, resolutions),
true => resolutions = riposte(target, source, resolutions, Skill::Riposte),
false => (),
},
_ => (),
@ -428,58 +433,6 @@ impl Effect {
Effect::Ko => Category::Ko,
}
}
pub fn duration(&self) -> u8 {
match self {
Effect::Block => 1,
Effect::Parry => 1,
Effect::Clutch => 1,
Effect::Reflect => 1,
Effect::Injured => 2,
Effect::Strangle => 2,
Effect::Strangling => 2,
Effect::Stun => 1,
Effect::Vulnerable => 2,
Effect::Snare => 2,
Effect::Taunt => 1,
Effect::Empower => 2,
Effect::Invert => 1,
Effect::Hex => 2,
Effect::Ruin => 1,
Effect::Curse => 2,
Effect::Banish => 1,
Effect::Slow => 2,
Effect::Haste => 2,
Effect::Amplify => 2,
Effect::Silence => 2,
Effect::Hostility => 2,
Effect::Hatred => 5,
Effect::Corrupt => 2,
Effect::Corruption => 3,
Effect::Shield => 2,
Effect::Triage => 3,
Effect::Decay => 3,
Effect::Siphon => 2,
_ => {
println!("{:?} does not have a duration", self);
return 1;
},
}
}
}
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
@ -527,6 +480,8 @@ pub enum Skill {
StrangleTick,
Strike,
StrikeII,
StrikeIII,
Stun,
// Evade, // actively evade
@ -584,10 +539,92 @@ pub enum Skill {
}
impl Skill {
pub fn multiplier(&self) -> u64 {
match self {
Skill::Attack => 100, // 1.0 to pass tests
Skill::Strike => 110,
Skill::StrikeII => 130,
Skill::StrikeIII => 150,
Skill::StrangleTick => 30,
Skill::Riposte => 100,
Skill::Heal => 100, // 1.0 to pass tests
Skill::TriageTick => 65,
Skill::Blast => 130,
Skill::CorruptionTick => 80,
Skill::DecayTick => 60,
Skill::SiphonTick => 100, // 1.0 to pass tests
_ => 100,
}
}
pub fn duration(&self) -> u8 {
match self {
Skill::Block => 1,
Skill::Parry => 1,
Skill::Clutch => 1,
Skill::Reflect => 1,
Skill::Injure => 2,
Skill::Strangle => 2,
Skill::Stun => 2,
Skill::Throw => 2,
Skill::Snare => 2,
Skill::Taunt => 1,
Skill::Empower => 2,
Skill::Invert => 1,
Skill::Hex => 2,
Skill::Ruin => 1,
Skill::Curse => 2,
Skill::Banish => 1,
Skill::Slow => 2,
Skill::Haste => 2,
Skill::Amplify => 2,
Skill::Silence => 2,
Skill::Hostility => 2, // Primary Buff
Skill::Corrupt => 2, // Primary Buff
Skill::Shield => 2,
Skill::Triage => 3,
Skill::Decay => 3,
Skill::Siphon => 2,
_ => {
println!("{:?} does not have a duration", self);
return 1;
},
}
}
pub fn secondary_duration(&self) -> u8 {
match self {
Skill::Hostility => 5, // Increased dmg buff
Skill::Corrupt => 3, // Damage over time
Skill::Throw => 3, // Inc dmg taken debuff
_ => {
println!("{:?} does not have a secondary duration", self);
return 1;
},
}
}
pub fn base_cd(&self) -> Cooldown {
match self {
Skill::Attack => None,
Skill::Strike => None,
Skill::StrikeII => None,
Skill::StrikeIII => None,
Skill::Block => None, // reduce damage
Skill::Parry => None, // avoid all damage
Skill::Riposte => None, // used on parry
@ -644,6 +681,8 @@ impl Skill {
match self {
Skill::Attack => Category::Red,
Skill::Strike => Category::Red,
Skill::StrikeII => Category::Red,
Skill::StrikeIII => Category::Red,
Skill::Injure => Category::Red,
Skill::Strangle => Category::Red,
Skill::StrangleTick => Category::Red,
@ -688,6 +727,7 @@ impl Skill {
// -----------------
// Test
// -----------------
Skill::TestTouch => Category::Red,
Skill::TestStun => Category::Red,
Skill::TestParry => Category::Red,
@ -718,6 +758,8 @@ impl Skill {
Skill::TestSiphon => 10,
Skill::Strike => u8::max_value(),
Skill::StrikeII => Skill::Strike.speed(),
Skill::StrikeIII => Skill::Strike.speed(),
Skill::SiphonTick => Var::from(Skill::Siphon).speed(),
Skill::DecayTick => Var::from(Skill::Decay).speed(),
@ -777,85 +819,85 @@ impl Skill {
}
}
fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
target.deal_red_damage(Skill::TestTouch, 0)
fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
target.deal_red_damage(skill, 0)
.into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e)));
return results;
}
fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.red_damage();
target.deal_red_damage(Skill::Attack, amount)
fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.red_damage().pct(skill.multiplier());
target.deal_red_damage(skill, amount)
.into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e)));
return results;
}
fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.red_damage();
target.deal_red_damage(Skill::Strike, amount)
fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.red_damage().pct(skill.multiplier());
target.deal_red_damage(skill, amount)
.into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e)));
return results;
}
fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.red_damage();
target.deal_red_damage(Skill::Injure, amount)
fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.red_damage().pct(skill.multiplier());
target.deal_red_damage(skill, amount)
.into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e)));
let effect = CrypEffect::new(Effect::Injured);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Injure, effect)));
let effect = CrypEffect::new(Effect::Injured, 2);
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;
}
fn stun(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect::new(Effect::Stun);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Stun, effect)));
fn stun(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Stun, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;
}
fn clutch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect::new(Effect::Clutch);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Clutch, effect)));
fn clutch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Clutch, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;
}
fn taunt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect::new(Effect::Taunt);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Taunt, effect)));
fn taunt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Taunt, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;
}
fn throw(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let stun = CrypEffect::new(Effect::Stun);
let vulnerable = CrypEffect::new(Effect::Vulnerable);
fn throw(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let stun = CrypEffect::new(Effect::Stun, skill.duration());
let vulnerable = CrypEffect::new(Effect::Vulnerable, skill.secondary_duration());
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Throw, stun)));
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Throw, vulnerable)));
results.push(Resolution::new(source, target).event(target.add_effect(skill, stun)));
results.push(Resolution::new(source, target).event(target.add_effect(skill, vulnerable)));
return results;
}
fn strangle(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let target_stun = CrypEffect::new(Effect::Strangle)
fn strangle(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let target_stun = CrypEffect::new(Effect::Strangle, skill.duration())
.set_tick(Cast::new_tick(source, target, Skill::StrangleTick));
let attacker_immunity = CrypEffect::new(Effect::Strangling);
let attacker_immunity = CrypEffect::new(Effect::Strangling, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Strangle, target_stun)));
results.push(Resolution::new(source, source).event(source.add_effect(Skill::Strangle, attacker_immunity)));
return strangle_tick(source, target, results);
results.push(Resolution::new(source, target).event(target.add_effect(skill, target_stun)));
results.push(Resolution::new(source, source).event(source.add_effect(skill, attacker_immunity)));
return strangle_tick(source, target, results, Skill::StrangleTick);
}
fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.red_damage();
target.deal_red_damage(Skill::StrangleTick, amount)
fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.red_damage().pct(skill.multiplier());
target.deal_red_damage(skill, amount)
.into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e)));
@ -872,100 +914,100 @@ fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions)
return results;
}
fn block(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let block = CrypEffect::new(Effect::Block);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Block, block)));
fn block(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let block = CrypEffect::new(Effect::Block, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, block)));
return results;
}
fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect::new(Effect::Parry);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Parry, effect)));
fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Parry, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;
}
fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.red_damage();
target.deal_red_damage(Skill::Riposte, amount)
fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.red_damage().pct(skill.multiplier());
target.deal_red_damage(skill, amount)
.into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e)));
return results;
}
fn snare(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let snare = CrypEffect::new(Effect::Snare);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Snare, snare)));
fn snare(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let snare = CrypEffect::new(Effect::Snare, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, snare)));
return results;
}
fn empower(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let empower = CrypEffect::new(Effect::Empower);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Empower, empower)));
fn empower(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let empower = CrypEffect::new(Effect::Empower, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, empower)));
return results;
}
fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.green_damage();
target.deal_green_damage(Skill::Heal, amount)
fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.green_damage().pct(skill.multiplier());
target.deal_green_damage(skill, amount)
.into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e)));
return results;
}
fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect::new(Effect::Triage)
fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Triage, skill.duration())
.set_tick(Cast::new_tick(source, target, Skill::TriageTick));
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Triage, effect)));
return triage_tick(source, target, results);
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return triage_tick(source, target, results, Skill::TriageTick);
}
fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.green_damage().wrapping_div(2);
fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.green_damage().pct(skill.multiplier());
target.deal_green_damage(Skill::TriageTick, amount)
.into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e)));
return results;
}
fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.blue_damage();
target.deal_blue_damage(Skill::Blast, amount)
fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.blue_damage().pct(skill.multiplier());
target.deal_blue_damage(skill, amount)
.into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e)));
return results;
}
fn amplify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amplify = CrypEffect::new(Effect::Amplify);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Amplify, amplify)));
fn amplify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amplify = CrypEffect::new(Effect::Amplify, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, amplify)));
return results;;
}
fn haste(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect::new(Effect::Haste);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Haste, effect)));
fn haste(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Haste, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;;
}
fn slow(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect::new(Effect::Slow);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Slow, effect)));
fn slow(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Slow, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;;
}
fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let decay = CrypEffect::new(Effect::Decay)
fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let decay = CrypEffect::new(Effect::Decay, skill.duration())
.set_tick(Cast::new_tick(source, target, Skill::DecayTick));
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Decay, decay)));
return decay_tick(source, target, results);
results.push(Resolution::new(source, target).event(target.add_effect(skill, decay)));
return decay_tick(source, target, results, Skill::DecayTick);
}
fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.blue_damage() / 2;
target.deal_blue_damage(Skill::DecayTick, amount)
fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.blue_damage().pct(skill.multiplier());
target.deal_blue_damage(skill, amount)
.into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e)));
return results;
@ -973,88 +1015,88 @@ fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) ->
// corrupt is the buff effect
// when attacked it runs corruption and applies a debuff
fn corrupt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect::new(Effect::Corrupt);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Corrupt, effect)));
fn corrupt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Corrupt, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;;
}
fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect::new(Effect::Corruption)
fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Corruption, skill.secondary_duration())
.set_tick(Cast::new_tick(source, target, Skill::CorruptionTick));
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Corrupt, effect)));
return corruption_tick(source, target, results);
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return corruption_tick(source, target, results, Skill::CorruptionTick);
}
fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.blue_damage() / 2;
target.deal_blue_damage(Skill::CorruptionTick, amount)
fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.blue_damage().pct(skill.multiplier());
target.deal_blue_damage(skill, amount)
.into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e)));
return results;
}
fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect::new(Effect::Ruin);
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 {
let hex = CrypEffect::new(Effect::Hex);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Hex, hex)));
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));
fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Ruin, skill.duration());
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 {
let curse = CrypEffect::new(Effect::Curse);
fn hex(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let hex = CrypEffect::new(Effect::Hex, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, hex)));
return results;;
}
fn hostility(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Hostility, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;;
}
fn hatred(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, reflect_skill: Skill, amount: u64, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Hatred, skill.secondary_duration())
.set_meta(EffectMeta::AddedDamage(amount));
results.push(Resolution::new(source, target).event(target.add_effect(reflect_skill, effect)));
return results;;
}
fn curse(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let curse = CrypEffect::new(Effect::Curse, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Curse, curse)));
return results;;
}
fn invert(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect::new(Effect::Invert);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Invert, effect)));
fn invert(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Invert, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;;
}
fn reflect(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let effect = CrypEffect::new(Effect::Reflect);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Reflect, effect)));
fn reflect(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Reflect, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;;
}
fn recharge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
fn recharge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
results.push(Resolution::new(source, target).event(target.recharge()));
return results;
}
fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let siphon = CrypEffect::new(Effect::Siphon)
fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let siphon = CrypEffect::new(Effect::Siphon, skill.duration())
.set_tick(Cast::new_tick(source, target, Skill::SiphonTick));
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Siphon, siphon)));
return siphon_tick(source, target, results);
results.push(Resolution::new(source, target).event(target.add_effect(skill, siphon)));
return siphon_tick(source, target, results, Skill::SiphonTick);
}
fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.blue_damage();
fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = source.blue_damage().pct(skill.multiplier());
let siphon_events = target.deal_blue_damage(Skill::SiphonTick, amount);
for e in siphon_events {
@ -1074,19 +1116,19 @@ fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -
return results;
}
fn shield(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let shield = CrypEffect::new(Effect::Shield);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Shield, shield)));
fn shield(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let shield = CrypEffect::new(Effect::Shield, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, shield)));
return results;
}
fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let silence = CrypEffect::new(Effect::Silence);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Silence, silence)));
fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let silence = CrypEffect::new(Effect::Silence, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, silence)));
return results;
}
fn purge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
fn purge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
while let Some(i) = target.effects
.iter()
.position(|ce| [Category::Buff, Category::Buff].contains(&ce.effect.category())) {
@ -1097,7 +1139,7 @@ fn purge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Reso
return results;
}
fn purify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
fn purify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
while let Some(i) = target.effects
.iter()
.position(|ce| [Category::Debuff, Category::Debuff].contains(&ce.effect.category())) {
@ -1108,9 +1150,9 @@ fn purify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res
return results;
}
fn banish(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let banish = CrypEffect::new(Effect::Banish);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Banish, banish)));
fn banish(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let banish = CrypEffect::new(Effect::Banish, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, banish)));
return results;
}
@ -1130,7 +1172,7 @@ mod tests {
x.deal_red_damage(Skill::Attack, 5);
heal(&mut y, &mut x, vec![]);
heal(&mut y, &mut x, vec![], Skill::Heal);
}
#[test]
@ -1141,7 +1183,7 @@ mod tests {
let mut y = Cryp::new()
.named(&"camel".to_string());
decay(&mut x, &mut y, vec![]);
decay(&mut x, &mut y, vec![], Skill::Decay);
assert!(y.effects.iter().any(|e| e.effect == Effect::Decay));
@ -1162,10 +1204,10 @@ mod tests {
x.red_damage.force(100);
y.green_life.force(500);
block(&mut y.clone(), &mut y, vec![]);
block(&mut y.clone(), &mut y, vec![], Skill::Block);
assert!(y.effects.iter().any(|e| e.effect == Effect::Block));
let mut results = attack(&mut x, &mut y, vec![]);
let mut results = attack(&mut x, &mut y, vec![], Skill::Attack);
let Resolution { source: _, target: _, event } = results.remove(0);
match event {
@ -1182,12 +1224,12 @@ mod tests {
let mut y = Cryp::new()
.named(&"camel".to_string());
x.red_damage.force(u64::max_value());
x.red_damage.force(10000000000000); // multiplication of int max will cause overflow
clutch(&mut y.clone(), &mut y, vec![]);
clutch(&mut y.clone(), &mut y, vec![], Skill::Clutch);
assert!(y.affected(Effect::Clutch));
let mut results = attack(&mut x, &mut y, vec![]);
let mut results = attack(&mut x, &mut y, vec![], Skill::Attack);
assert!(y.green_life() == 1);
let Resolution { source: _, target: _, event } = results.remove(0);
@ -1223,15 +1265,15 @@ mod tests {
y.red_life.reduce(64);
x.red_damage.force(256 + 64);
invert(&mut y.clone(), &mut y, vec![]);
invert(&mut y.clone(), &mut y, vec![], Skill::Invert);
assert!(y.affected(Effect::Invert));
// heal should deal green damage
heal(&mut x, &mut y, vec![]);
heal(&mut x, &mut y, vec![], Skill::Heal);
assert!(y.green_life() == 768);
// attack should heal and recharge red shield
let mut results = attack(&mut x, &mut y, vec![]);
let mut results = attack(&mut x, &mut y, vec![], Skill::Attack);
assert!(y.green_life() == 1024);
match results.remove(0).event {
@ -1258,7 +1300,7 @@ mod tests {
let mut y = Cryp::new()
.named(&"camel".to_string());
reflect(&mut y.clone(), &mut y, vec![]);
reflect(&mut y.clone(), &mut y, vec![], Skill::Reflect);
assert!(y.affected(Effect::Reflect));
let mut results = vec![];
@ -1326,7 +1368,7 @@ mod tests {
let mut y = Cryp::new()
.named(&"camel".to_string());
corrupt(&mut y.clone(), &mut y, vec![]);
corrupt(&mut y.clone(), &mut y, vec![], Skill::Corrupt);
assert!(y.affected(Effect::Corrupt));
resolve(Skill::Attack, &mut x, &mut y, vec![]);
@ -1342,7 +1384,7 @@ mod tests {
let mut y = Cryp::new()
.named(&"camel".to_string());
hostility(&mut y.clone(), &mut y, vec![]);
hostility(&mut y.clone(), &mut y, vec![], Skill::Hostility);
assert!(y.affected(Effect::Hostility));
resolve(Skill::Attack, &mut x, &mut y, vec![]);
@ -1376,7 +1418,7 @@ mod tests {
y.deal_red_damage(Skill::Attack, 5);
let prev_hp = y.green_life();
triage(&mut x, &mut y, vec![]);
triage(&mut x, &mut y, vec![], Skill::Triage);
assert!(y.effects.iter().any(|e| e.effect == Effect::Triage));
assert!(y.green_life() > prev_hp);
@ -1396,7 +1438,7 @@ mod tests {
y.deal_red_damage(Skill::Attack, 5);
y.deal_blue_damage(Skill::Blast, 5);
let mut results = recharge(&mut x, &mut y, vec![]);
let mut results = recharge(&mut x, &mut y, vec![], Skill::Recharge);
let Resolution { source: _, target: _, event } = results.remove(0);
match event {
@ -1414,7 +1456,7 @@ mod tests {
let mut x = Cryp::new()
.named(&"muji".to_string());
silence(&mut x.clone(), &mut x, vec![]);
silence(&mut x.clone(), &mut x, vec![], Skill::Silence);
assert!(x.effects.iter().any(|e| e.effect == Effect::Silence));
assert!(x.disabled(Skill::Silence).is_some());
}
@ -1426,7 +1468,7 @@ mod tests {
x.blue_damage.force(50);
amplify(&mut x.clone(), &mut x, vec![]);
amplify(&mut x.clone(), &mut x, vec![], Skill::Amplify);
assert!(x.effects.iter().any(|e| e.effect == Effect::Amplify));
assert_eq!(x.blue_damage(), 100);
}
@ -1436,10 +1478,10 @@ mod tests {
let mut x = Cryp::new()
.named(&"muji".to_string());
decay(&mut x.clone(), &mut x, vec![]);
decay(&mut x.clone(), &mut x, vec![], Skill::Decay);
assert!(x.effects.iter().any(|e| e.effect == Effect::Decay));
purify(&mut x.clone(), &mut x, vec![]);
purify(&mut x.clone(), &mut x, vec![], Skill::Purify);
assert!(!x.effects.iter().any(|e| e.effect == Effect::Decay));
}
}

View File

@ -86,6 +86,8 @@ pub enum Var {
Snare,
Strangle,
Strike,
StrikeII,
StrikeIII,
Siphon,
Clutch,
Taunt,
@ -115,7 +117,13 @@ impl Var {
Var::Red => count.red += 1,
Var::Blue => count.blue += 1,
Var::Green => count.green += 1,
_ => (),
_ => {
let mut combo_count = Colours::new();
unit.colours(&mut combo_count);
count.red += combo_count.red;
count.blue += combo_count.blue;
count.green += combo_count.green;
}
}),
None => (),
}
@ -206,6 +214,8 @@ impl Var {
Var::Snare => Some(Skill::Snare),
Var::Strangle => Some(Skill::Strangle),
Var::Strike => Some(Skill::Strike),
Var::StrikeII => Some(Skill::StrikeII),
Var::StrikeIII => Some(Skill::StrikeIII),
Var::Clutch => Some(Skill::Clutch),
Var::Taunt => Some(Skill::Taunt),
Var::Throw => Some(Skill::Throw),
@ -276,6 +286,8 @@ impl From<Skill> for Var {
Skill::Snare => Var::Snare,
Skill::Strangle => Var::Strangle,
Skill::Strike => Var::Strike,
Skill::StrikeII => Var::StrikeII,
Skill::StrikeIII => Var::StrikeIII,
Skill::Stun => Var::Stun,
Skill::Taunt => Var::Taunt,
Skill::Throw => Var::Throw,
@ -349,7 +361,7 @@ fn get_combos() -> Vec<Combo> {
Combo { units: vec![Var::Block, Var::Green, Var::Green], var: Var::Reflect },
Combo { units: vec![Var::Block, Var::Blue, Var::Blue], var: Var::Corrupt },
Combo { units: vec![Var::Block, Var::Red, Var::Green], var: Var::Taunt },
Combo { units: vec![Var::Block, Var::Green, Var::Blue], var: Var::Life },
Combo { units: vec![Var::Block, Var::Green, Var::Blue], var: Var::Recharge }, // was life before (clash)
Combo { units: vec![Var::Block, Var::Red, Var::Blue], var: Var::Recharge },
Combo { units: vec![Var::Stun, Var::Red, Var::Red], var: Var::Strangle },
@ -360,6 +372,9 @@ fn get_combos() -> Vec<Combo> {
Combo { units: vec![Var::Stun, Var::Red, Var::Blue], var: Var::Hex },
Combo { units: vec![Var::Attack, Var::Red, Var::Red], var: Var::Strike },
Combo { units: vec![Var::Strike, Var::Strike, Var::Strike], var: Var::StrikeII },
Combo { units: vec![Var::StrikeII, Var::StrikeII, Var::StrikeII], var: Var::StrikeIII },
Combo { units: vec![Var::Attack, Var::Green, Var::Green], var: Var::Heal },
Combo { units: vec![Var::Attack, Var::Blue, Var::Blue], var: Var::Blast },
Combo { units: vec![Var::Attack, Var::Red, Var::Green], var: Var::Purify },