This commit is contained in:
ntr 2018-12-16 15:52:56 +11:00
parent 0883d7233c
commit 92c6da39bf
2 changed files with 31 additions and 3 deletions

View File

@ -11,8 +11,6 @@ strangle
* tutorial
* demo registration
* handle unserializable cryps
* Global rolls

View File

@ -159,6 +159,11 @@ impl Effect {
Category::Physical => false,
_ => false,
},
Effect::Evasion => match skill.category() {
Category::Spell => false,
Category::Physical => evade_roll(),
_ => false,
},
Effect::Banish => true,
_ => false,
}
@ -627,7 +632,7 @@ impl Skill {
// Nature
// -----------------
Skill::Block => block(cryp, target, resolution),
Skill::Evade => panic!("nyi"), //
Skill::Evade => evade(cryp, target, resolution),
Skill::Parry => panic!("nyi"), // avoid all dmg
Skill::Snare => snare(cryp, target, resolution), // TODO prevent physical moves
@ -825,6 +830,31 @@ fn block(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Res
return resolution;
}
fn evade(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution {
let evade = CrypEffect { effect: Effect::Evasion, duration: Skill::Evade.duration(), tick: None };
let immunity = target.immune(Skill::Evade);
let immune = immunity.immune;
let result = ResolutionResult::Effect {
effect: evade.effect,
duration: evade.duration,
immunity,
};
resolution.results.push(result);
if !immune {
target.effects.push(evade);
}
return resolution;
}
fn evade_roll() -> bool {
let mut rng = thread_rng();
return rng.gen_bool(0.5);
}
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);