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 * tutorial
* demo registration
* handle unserializable cryps * handle unserializable cryps
* Global rolls * Global rolls

View File

@ -159,6 +159,11 @@ impl Effect {
Category::Physical => false, Category::Physical => false,
_ => false, _ => false,
}, },
Effect::Evasion => match skill.category() {
Category::Spell => false,
Category::Physical => evade_roll(),
_ => false,
},
Effect::Banish => true, Effect::Banish => true,
_ => false, _ => false,
} }
@ -627,7 +632,7 @@ impl Skill {
// Nature // Nature
// ----------------- // -----------------
Skill::Block => block(cryp, target, resolution), Skill::Block => block(cryp, target, resolution),
Skill::Evade => panic!("nyi"), // Skill::Evade => evade(cryp, target, resolution),
Skill::Parry => panic!("nyi"), // avoid all dmg Skill::Parry => panic!("nyi"), // avoid all dmg
Skill::Snare => snare(cryp, target, resolution), // TODO prevent physical moves 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; 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 { 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 snare = CrypEffect { effect: Effect::Snare, duration: Skill::Snare.duration(), tick: None };
let immunity = target.immune(Skill::Snare); let immunity = target.immune(Skill::Snare);