make skill resolution a regular function
This commit is contained in:
parent
9bd19ee79d
commit
24767b9c86
@ -11,7 +11,6 @@ use account::{Account};
|
|||||||
use rpc::{CrypSpawnParams};
|
use rpc::{CrypSpawnParams};
|
||||||
use skill::{Skill, Cooldown, Effect, Cast, Category, Immunity, Disable, Event};
|
use skill::{Skill, Cooldown, Effect, Cast, Category, Immunity, Disable, Event};
|
||||||
use spec::{Spec};
|
use spec::{Spec};
|
||||||
use game::{Log};
|
|
||||||
use vbox::Var;
|
use vbox::Var;
|
||||||
|
|
||||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||||
@ -61,13 +60,35 @@ impl CrypSkill {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||||
|
pub enum EffectMeta {
|
||||||
|
TickAmount(u64),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||||
pub struct CrypEffect {
|
pub struct CrypEffect {
|
||||||
pub effect: Effect,
|
pub effect: Effect,
|
||||||
pub duration: u8,
|
pub duration: u8,
|
||||||
|
pub meta: Option<EffectMeta>,
|
||||||
pub tick: Option<Cast>,
|
pub tick: Option<Cast>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl CrypEffect {
|
||||||
|
pub fn new(effect: Effect) -> CrypEffect {
|
||||||
|
CrypEffect { effect, duration: effect.duration(), meta: None, tick: None }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_tick(mut self, tick: Cast) -> CrypEffect {
|
||||||
|
self.tick = Some(tick);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_meta(mut self, meta: EffectMeta) -> CrypEffect {
|
||||||
|
self.meta = Some(meta);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||||
pub enum Stat {
|
pub enum Stat {
|
||||||
Str,
|
Str,
|
||||||
|
|||||||
@ -10,12 +10,10 @@ 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, Effect, Cast, Resolution, Event};
|
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};
|
||||||
|
|
||||||
pub type Log = Vec<String>;
|
|
||||||
|
|
||||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||||
pub struct Team {
|
pub struct Team {
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
@ -417,10 +415,10 @@ impl Game {
|
|||||||
|
|
||||||
// temp vec of this round's resolving skills
|
// temp vec of this round's resolving skills
|
||||||
// because need to check cooldown use before pushing them into the complete list
|
// because need to check cooldown use before pushing them into the complete list
|
||||||
let mut resolving = vec![];
|
let mut casts = vec![];
|
||||||
|
|
||||||
while let Some(cast) = self.stack.pop() {
|
while let Some(cast) = self.stack.pop() {
|
||||||
// println!("{:} resolving ", cast);
|
// println!("{:} casts ", cast);
|
||||||
|
|
||||||
let mut resolutions = vec![];
|
let mut resolutions = vec![];
|
||||||
let mut source = self.cryp_by_id(cast.source_cryp_id).unwrap().clone();
|
let mut source = self.cryp_by_id(cast.source_cryp_id).unwrap().clone();
|
||||||
@ -429,12 +427,11 @@ impl Game {
|
|||||||
for target_id in targets {
|
for target_id in targets {
|
||||||
// let mut source = game.cryp_by_id(self.source_cryp_id).unwrap();
|
// let mut source = game.cryp_by_id(self.source_cryp_id).unwrap();
|
||||||
let mut target = self.cryp_by_id(target_id).unwrap();
|
let mut target = self.cryp_by_id(target_id).unwrap();
|
||||||
resolutions = cast.skill.resolve(&mut source, target, resolutions);
|
resolutions = resolve(cast.skill, &mut source, target, resolutions);
|
||||||
}
|
}
|
||||||
|
|
||||||
resolutions.reverse();
|
resolutions.reverse();
|
||||||
while let Some(resolution) = resolutions.pop() {
|
while let Some(resolution) = resolutions.pop() {
|
||||||
// fixme for mash
|
|
||||||
self.log_resolution(cast.speed, &resolution);
|
self.log_resolution(cast.speed, &resolution);
|
||||||
// the results go into the resolutions
|
// the results go into the resolutions
|
||||||
self.resolved.push(resolution);
|
self.resolved.push(resolution);
|
||||||
@ -442,16 +439,16 @@ impl Game {
|
|||||||
|
|
||||||
// the cast itself goes into this temp vec
|
// the cast itself goes into this temp vec
|
||||||
// to handle cooldowns
|
// to handle cooldowns
|
||||||
resolving.push(cast);
|
casts.push(cast);
|
||||||
|
|
||||||
// sort the stack again in case speeds have changed
|
// sort the stack again in case speeds have changed
|
||||||
self.stack_sort_speed();
|
self.stack_sort_speed();
|
||||||
};
|
};
|
||||||
|
|
||||||
// println!("{:#?}", self.resolving);
|
// println!("{:#?}", self.casts);
|
||||||
|
|
||||||
// handle cooldowns and statuses
|
// handle cooldowns and statuses
|
||||||
self.progress_durations(&resolving);
|
self.progress_durations(&casts);
|
||||||
|
|
||||||
if self.finished() {
|
if self.finished() {
|
||||||
return self.finish()
|
return self.finish()
|
||||||
|
|||||||
@ -3,7 +3,116 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
use cryp::{Cryp, CrypEffect, Stat};
|
use cryp::{Cryp, CrypEffect, Stat};
|
||||||
use vbox::{Var};
|
use vbox::{Var};
|
||||||
use game::{Game};
|
|
||||||
|
pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutions: Vec<Resolution>) -> Resolutions {
|
||||||
|
let mut rng = thread_rng();
|
||||||
|
let _base: u64 = rng.gen();
|
||||||
|
|
||||||
|
if let Some(disable) = source.disabled(skill) {
|
||||||
|
resolutions.push(Resolution::new(source, target).event(Event::Disable { disable, skill }));
|
||||||
|
return resolutions;
|
||||||
|
}
|
||||||
|
|
||||||
|
if target.is_ko() {
|
||||||
|
resolutions.push(Resolution::new(source, target).event(Event::TargetKo { skill }));
|
||||||
|
return resolutions;
|
||||||
|
}
|
||||||
|
|
||||||
|
if target.affected(Effect::Reflect) {
|
||||||
|
// guard against overflow
|
||||||
|
if source.affected(Effect::Reflect) {
|
||||||
|
return resolutions;
|
||||||
|
}
|
||||||
|
resolutions.push(Resolution::new(source, target).event(Event::Reflection { skill }));
|
||||||
|
return resolve(skill, target, source, resolutions);
|
||||||
|
}
|
||||||
|
|
||||||
|
// match self.category() == Category::Red {
|
||||||
|
// true => {
|
||||||
|
// if let Some(evasion) = target.evade(*self) {
|
||||||
|
// resolutions.push(evasion);
|
||||||
|
// return Event;
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// false => (),
|
||||||
|
// }
|
||||||
|
|
||||||
|
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::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), // todo prevent casting
|
||||||
|
Skill::Invert => invert(source, target, resolutions), // todo prevent casting
|
||||||
|
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::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::Slow => slow(source, target, resolutions), // speed slow
|
||||||
|
Skill::Snare => snare(source, target, resolutions), // TODO prevent physical moves
|
||||||
|
Skill::Strike => strike(source, target, resolutions),
|
||||||
|
Skill::Stun => stun(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::Clutch => clutch(source, target, resolutions),
|
||||||
|
Skill::Strangle => strangle(source, target, resolutions),
|
||||||
|
Skill::StrangleTick => strangle_tick(source, target, resolutions),
|
||||||
|
|
||||||
|
Skill::Reflect => reflect(source, target, resolutions),
|
||||||
|
Skill::Ruin => ruin(source, target, resolutions),
|
||||||
|
Skill::Slay => unimplemented!(),
|
||||||
|
Skill::Taunt => taunt(source, target, resolutions),
|
||||||
|
|
||||||
|
Skill::Corrupt => corrupt(source, target, resolutions),
|
||||||
|
Skill::Corruption => panic!("corruption should not be castable"),
|
||||||
|
Skill::CorruptionTick => corruption_tick(source, target, resolutions),
|
||||||
|
|
||||||
|
// -----------------
|
||||||
|
// 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),
|
||||||
|
};
|
||||||
|
|
||||||
|
// if any event dealt damage to target cryp
|
||||||
|
// hit them with corruption
|
||||||
|
resolutions = match target.affected(Effect::Corrupt) {
|
||||||
|
true => match resolutions.iter().any(|r|
|
||||||
|
match r.event {
|
||||||
|
Event::Damage { amount: _, mitigation: _, category: _, skill: _ } => true,
|
||||||
|
_ => false,
|
||||||
|
}) {
|
||||||
|
true => corruption(target, source, resolutions),
|
||||||
|
false => resolutions,
|
||||||
|
},
|
||||||
|
false => resolutions,
|
||||||
|
};
|
||||||
|
|
||||||
|
// i don't think we need to check the source being ko
|
||||||
|
if target.is_ko() {
|
||||||
|
resolutions.push(Resolution::new(source, target).event(Event::Ko));
|
||||||
|
target.effects.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolutions;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||||
pub struct Cast {
|
pub struct Cast {
|
||||||
@ -447,7 +556,7 @@ impl Skill {
|
|||||||
Skill::Throw => Some(1), // no damage stun, adds vulnerable
|
Skill::Throw => Some(1), // no damage stun, adds vulnerable
|
||||||
Skill::Blast => None,
|
Skill::Blast => None,
|
||||||
Skill::Amplify => Some(1),
|
Skill::Amplify => Some(1),
|
||||||
Skill::Invert => Some(1),
|
Skill::Invert => Some(2),
|
||||||
Skill::Decay => None, // dot
|
Skill::Decay => None, // dot
|
||||||
Skill::DecayTick => None,
|
Skill::DecayTick => None,
|
||||||
Skill::Siphon => Some(1),
|
Skill::Siphon => Some(1),
|
||||||
@ -459,7 +568,7 @@ impl Skill {
|
|||||||
Skill::Purify => None,
|
Skill::Purify => None,
|
||||||
Skill::Purge => None,
|
Skill::Purge => None,
|
||||||
Skill::Banish => Some(1),
|
Skill::Banish => Some(1),
|
||||||
Skill::Hex => None,
|
Skill::Hex => Some(1),
|
||||||
Skill::Haste => None,
|
Skill::Haste => None,
|
||||||
Skill::Slow => None,
|
Skill::Slow => None,
|
||||||
Skill::Reflect => Some(2),
|
Skill::Reflect => Some(2),
|
||||||
@ -610,114 +719,6 @@ impl Skill {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resolve(&self, source: &mut Cryp, target: &mut Cryp, mut resolutions: Vec<Resolution>) -> Resolutions {
|
|
||||||
let mut rng = thread_rng();
|
|
||||||
let _base: u64 = rng.gen();
|
|
||||||
|
|
||||||
if let Some(disable) = source.disabled(*self) {
|
|
||||||
resolutions.push(Resolution::new(source, target).event(Event::Disable { disable, skill: *self }));
|
|
||||||
return resolutions;
|
|
||||||
}
|
|
||||||
|
|
||||||
if target.is_ko() {
|
|
||||||
resolutions.push(Resolution::new(source, target).event(Event::TargetKo { skill: *self }));
|
|
||||||
return resolutions;
|
|
||||||
}
|
|
||||||
|
|
||||||
if target.affected(Effect::Reflect) {
|
|
||||||
// guard against overflow
|
|
||||||
if source.affected(Effect::Reflect) {
|
|
||||||
return resolutions;
|
|
||||||
}
|
|
||||||
resolutions.push(Resolution::new(source, target).event(Event::Reflection { skill: *self }));
|
|
||||||
return self.resolve(target, source, resolutions);
|
|
||||||
}
|
|
||||||
|
|
||||||
// match self.category() == Category::Red {
|
|
||||||
// true => {
|
|
||||||
// if let Some(evasion) = target.evade(*self) {
|
|
||||||
// resolutions.push(evasion);
|
|
||||||
// return Event;
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// false => (),
|
|
||||||
// }
|
|
||||||
|
|
||||||
resolutions = match self {
|
|
||||||
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::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), // todo prevent casting
|
|
||||||
Skill::Invert => invert(source, target, resolutions), // todo prevent casting
|
|
||||||
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::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::Slow => slow(source, target, resolutions), // speed slow
|
|
||||||
Skill::Snare => snare(source, target, resolutions), // TODO prevent physical moves
|
|
||||||
Skill::Strike => strike(source, target, resolutions),
|
|
||||||
Skill::Stun => stun(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::Clutch => clutch(source, target, resolutions),
|
|
||||||
Skill::Strangle => strangle(source, target, resolutions),
|
|
||||||
Skill::StrangleTick => strangle_tick(source, target, resolutions),
|
|
||||||
|
|
||||||
Skill::Reflect => reflect(source, target, resolutions),
|
|
||||||
Skill::Ruin => ruin(source, target, resolutions),
|
|
||||||
Skill::Slay => unimplemented!(),
|
|
||||||
Skill::Taunt => taunt(source, target, resolutions),
|
|
||||||
|
|
||||||
Skill::Corrupt => corrupt(source, target, resolutions),
|
|
||||||
Skill::Corruption => panic!("corruption should not be castable"),
|
|
||||||
Skill::CorruptionTick => corruption_tick(source, target, resolutions),
|
|
||||||
|
|
||||||
// -----------------
|
|
||||||
// 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),
|
|
||||||
};
|
|
||||||
|
|
||||||
// if any event dealt damage to target cryp
|
|
||||||
// hit them with corruption
|
|
||||||
resolutions = match target.affected(Effect::Corrupt) {
|
|
||||||
true => match resolutions.iter().any(|r|
|
|
||||||
match r.event {
|
|
||||||
Event::Damage { amount: _, mitigation: _, category: _, skill: _ } => true,
|
|
||||||
_ => false,
|
|
||||||
}) {
|
|
||||||
true => corruption(target, source, resolutions),
|
|
||||||
false => resolutions,
|
|
||||||
},
|
|
||||||
false => resolutions,
|
|
||||||
};
|
|
||||||
|
|
||||||
// i don't think we need to check the source being ko
|
|
||||||
if target.is_ko() {
|
|
||||||
resolutions.push(Resolution::new(source, target).event(Event::Ko));
|
|
||||||
target.effects.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
return resolutions;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn self_targeting(&self) -> bool {
|
pub fn self_targeting(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Skill::Block => true,
|
Skill::Block => true,
|
||||||
@ -773,26 +774,26 @@ fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res
|
|||||||
|
|
||||||
|
|
||||||
fn stun(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn stun(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let effect = CrypEffect { effect: Effect::Stun, duration: Effect::Stun.duration(), tick: None };
|
let effect = CrypEffect::new(Effect::Stun);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Stun, effect)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Stun, effect)));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clutch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn clutch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let effect = CrypEffect { effect: Effect::Clutch, duration: Effect::Clutch.duration(), tick: None };
|
let effect = CrypEffect::new(Effect::Clutch);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Clutch, effect)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Clutch, effect)));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn taunt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn taunt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let effect = CrypEffect { effect: Effect::Taunt, duration: Effect::Taunt.duration(), tick: None };
|
let effect = CrypEffect::new(Effect::Taunt);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Taunt, effect)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Taunt, effect)));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn throw(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn throw(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let stun = CrypEffect { effect: Effect::Stun, duration: Effect::Stun.duration(), tick: None };
|
let stun = CrypEffect::new(Effect::Stun);
|
||||||
let vulnerable = CrypEffect { effect: Effect::Vulnerable, duration: Effect::Vulnerable.duration(), tick: None };
|
let vulnerable = CrypEffect::new(Effect::Vulnerable);
|
||||||
|
|
||||||
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, 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::Throw, vulnerable)));
|
||||||
@ -801,12 +802,10 @@ fn throw(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Reso
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn strangle(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn strangle(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let target_stun = CrypEffect {
|
let target_stun = CrypEffect::new(Effect::Strangle)
|
||||||
effect: Effect::Strangle,
|
.set_tick(Cast::new_tick(source, target, Skill::StrangleTick));
|
||||||
duration: Effect::Strangle.duration(),
|
|
||||||
tick: Some(Cast::new_tick(source, target, Skill::StrangleTick))
|
let attacker_immunity = CrypEffect::new(Effect::Strangling);
|
||||||
};
|
|
||||||
let attacker_immunity = CrypEffect { effect: Effect::Strangling, duration: Effect::Strangling.duration(), tick: None };
|
|
||||||
|
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Strangle, target_stun)));
|
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)));
|
results.push(Resolution::new(source, source).event(source.add_effect(Skill::Strangle, attacker_immunity)));
|
||||||
@ -833,26 +832,25 @@ fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn block(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn block(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let block = CrypEffect { effect: Effect::Block, duration: Effect::Block.duration(), tick: None };
|
let block = CrypEffect::new(Effect::Block);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Block, block)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Block, block)));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let effect = CrypEffect { effect: Effect::Parry, duration: Effect::Parry.duration(), tick: None };
|
let effect = CrypEffect::new(Effect::Parry);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Parry, effect)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Parry, effect)));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn snare(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn snare(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let snare = CrypEffect { effect: Effect::Snare, duration: Effect::Snare.duration(), tick: None };
|
let snare = CrypEffect::new(Effect::Snare);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Snare, snare)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Snare, snare)));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn empower(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn empower(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let empower = CrypEffect { effect: Effect::Empower, duration: Effect::Empower.duration(), tick: None };
|
let empower = CrypEffect::new(Effect::Empower);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Empower, empower)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Empower, empower)));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
@ -866,11 +864,9 @@ fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resol
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let effect = CrypEffect {
|
let effect = CrypEffect::new(Effect::Triage)
|
||||||
effect: Effect::Triage,
|
.set_tick(Cast::new_tick(source, target, Skill::TriageTick));
|
||||||
duration: Effect::Triage.duration(),
|
|
||||||
tick: Some(Cast::new_tick(source, target, Skill::TriageTick)),
|
|
||||||
};
|
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Triage, effect)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Triage, effect)));
|
||||||
return triage_tick(source, target, results);
|
return triage_tick(source, target, results);
|
||||||
}
|
}
|
||||||
@ -892,29 +888,27 @@ fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Reso
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn amplify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn amplify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let amplify = CrypEffect { effect: Effect::Amplify, duration: Effect::Amplify.duration(), tick: None };
|
let amplify = CrypEffect::new(Effect::Amplify);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Amplify, amplify)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Amplify, amplify)));
|
||||||
return results;;
|
return results;;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn haste(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn haste(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let effect = CrypEffect { effect: Effect::Haste, duration: Effect::Haste.duration(), tick: None };
|
let effect = CrypEffect::new(Effect::Haste);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Haste, effect)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Haste, effect)));
|
||||||
return results;;
|
return results;;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn slow(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn slow(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let effect = CrypEffect { effect: Effect::Slow, duration: Effect::Slow.duration(), tick: None };
|
let effect = CrypEffect::new(Effect::Slow);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Slow, effect)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Slow, effect)));
|
||||||
return results;;
|
return results;;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let decay = CrypEffect {
|
let decay = CrypEffect::new(Effect::Decay)
|
||||||
effect: Effect::Decay,
|
.set_tick(Cast::new_tick(source, target, Skill::DecayTick));
|
||||||
duration: Effect::Decay.duration(),
|
|
||||||
tick: Some(Cast::new_tick(source, target, Skill::DecayTick)),
|
|
||||||
};
|
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Decay, decay)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Decay, decay)));
|
||||||
return decay_tick(source, target, results);
|
return decay_tick(source, target, results);
|
||||||
}
|
}
|
||||||
@ -930,17 +924,15 @@ fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) ->
|
|||||||
// corrupt is the buff effect
|
// corrupt is the buff effect
|
||||||
// when attacked it runs corruption and applies a debuff
|
// when attacked it runs corruption and applies a debuff
|
||||||
fn corrupt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn corrupt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let effect = CrypEffect { effect: Effect::Corrupt, duration: Effect::Corrupt.duration(), tick: None };
|
let effect = CrypEffect::new(Effect::Corrupt);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Corrupt, effect)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Corrupt, effect)));
|
||||||
return results;;
|
return results;;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let effect = CrypEffect {
|
let effect = CrypEffect::new(Effect::Corruption)
|
||||||
effect: Effect::Corruption,
|
.set_tick(Cast::new_tick(source, target, Skill::CorruptionTick));
|
||||||
duration: Effect::Corruption.duration(),
|
|
||||||
tick: Some(Cast::new_tick(source, target, Skill::CorruptionTick)),
|
|
||||||
};
|
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Corruption, effect)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Corruption, effect)));
|
||||||
return corruption_tick(source, target, results);
|
return corruption_tick(source, target, results);
|
||||||
}
|
}
|
||||||
@ -954,31 +946,31 @@ fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolution
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let effect = CrypEffect { effect: Effect::Ruin, duration: Effect::Ruin.duration(), tick: None };
|
let effect = CrypEffect::new(Effect::Ruin);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Ruin, effect)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Ruin, effect)));
|
||||||
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 { effect: Effect::Hex, duration: Effect::Hex.duration(), tick: None };
|
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 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 { effect: Effect::Curse, duration: Effect::Curse.duration(), tick: None };
|
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)));
|
||||||
return results;;
|
return results;;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn invert(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn invert(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let effect = CrypEffect { effect: Effect::Invert, duration: Effect::Invert.duration(), tick: None };
|
let effect = CrypEffect::new(Effect::Invert);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Invert, effect)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Invert, effect)));
|
||||||
return results;;
|
return results;;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reflect(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn reflect(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let effect = CrypEffect { effect: Effect::Reflect, duration: Effect::Reflect.duration(), tick: None };
|
let effect = CrypEffect::new(Effect::Reflect);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Reflect, effect)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Reflect, effect)));
|
||||||
return results;;
|
return results;;
|
||||||
}
|
}
|
||||||
@ -989,11 +981,9 @@ fn recharge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> R
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let siphon = CrypEffect {
|
let siphon = CrypEffect::new(Effect::Siphon)
|
||||||
effect: Effect::Siphon,
|
.set_tick(Cast::new_tick(source, target, Skill::SiphonTick));
|
||||||
duration: Effect::Siphon.duration(),
|
|
||||||
tick: Some(Cast::new_tick(source, target, Skill::SiphonTick)),
|
|
||||||
};
|
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Siphon, siphon)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Siphon, siphon)));
|
||||||
return siphon_tick(source, target, results);
|
return siphon_tick(source, target, results);
|
||||||
}
|
}
|
||||||
@ -1020,13 +1010,13 @@ fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn shield(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn shield(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let shield = CrypEffect { effect: Effect::Shield, duration: Effect::Shield.duration(), tick: None };
|
let shield = CrypEffect::new(Effect::Shield);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Shield, shield)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Shield, shield)));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let silence = CrypEffect { effect: Effect::Silence, duration: Effect::Silence.duration(), tick: None };
|
let silence = CrypEffect::new(Effect::Silence);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Silence, silence)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Silence, silence)));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
@ -1054,7 +1044,7 @@ fn purify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn banish(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
fn banish(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
|
||||||
let banish = CrypEffect { effect: Effect::Banish, duration: Effect::Banish.duration(), tick: None };
|
let banish = CrypEffect::new(Effect::Banish);
|
||||||
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Banish, banish)));
|
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Banish, banish)));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
@ -1194,7 +1184,7 @@ mod tests {
|
|||||||
assert!(y.affected(Effect::Reflect));
|
assert!(y.affected(Effect::Reflect));
|
||||||
|
|
||||||
let mut results = vec![];
|
let mut results = vec![];
|
||||||
results = Skill::Attack.resolve(&mut x, &mut y, results);
|
results = resolve(Skill::Attack, &mut x, &mut y, results);
|
||||||
|
|
||||||
assert!(x.hp() == 768);
|
assert!(x.hp() == 768);
|
||||||
|
|
||||||
@ -1222,7 +1212,7 @@ mod tests {
|
|||||||
corrupt(&mut y.clone(), &mut y, vec![]);
|
corrupt(&mut y.clone(), &mut y, vec![]);
|
||||||
assert!(y.affected(Effect::Corrupt));
|
assert!(y.affected(Effect::Corrupt));
|
||||||
|
|
||||||
Skill::Attack.resolve(&mut x, &mut y, vec![]);
|
resolve(Skill::Attack, &mut x, &mut y, vec![]);
|
||||||
|
|
||||||
assert!(x.affected(Effect::Corruption));
|
assert!(x.affected(Effect::Corruption));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
use rand::prelude::*;
|
|
||||||
|
|
||||||
use cryp::{Stat, Colours};
|
use cryp::{Stat, Colours};
|
||||||
|
|
||||||
#[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)]
|
#[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user