This commit is contained in:
ntr 2018-11-14 16:10:27 +11:00
parent eb8aa98e42
commit 971c0dd03d
2 changed files with 138 additions and 16 deletions

View File

@ -17,10 +17,13 @@
* skills
* offensive -> choose target ✔
* calculate
* hp increase/decrease
* spell/phys dmg
* private fields for opponents
* cooldowns reduce each turn ✔
* statuses reduce each turn
* teach cyps skills
* teach cyps skills
* can you attack yourself?
* fetch existing battles
* check for game participation

View File

@ -86,6 +86,7 @@ pub enum Effect {
Enslave,
Mesmerise,
Amplify,
Silence,
// magic immunity
Immune,
@ -111,6 +112,22 @@ impl Effect {
_ => false,
}
}
pub fn prevents_casting(&self, skill: Skill) -> bool {
match self {
Effect::Stun => true,
Effect::Silence => match skill.cast_type() {
Damage::Magic => true,
Damage::Physical => false,
},
_ => false,
}
}
}
pub enum Damage {
Physical,
Magic,
}
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
@ -169,13 +186,13 @@ pub enum Skill {
// -----------------
// Purity
// -----------------
Precision,
Inspire,
Slay,
Shield,
Silence,
Inquiry,
Purify,
// Precision,
// -----------------
// Chaos
@ -250,7 +267,7 @@ impl Skill {
// -----------------
// Purity
// -----------------
Skill::Precision => Some(1),
// Skill::Precision => Some(1),
Skill::Inspire => Some(2),
Skill::Slay => Some(1),
Skill::Shield => Some(1),
@ -277,6 +294,90 @@ impl Skill {
}
}
pub fn cast_type(&self) -> Damage {
match self {
Skill::Attack => Damage::Physical,
// -----------------
// Nature
// -----------------
Skill::Block => Damage::Physical, // reduce dmg
Skill::Evade => Damage::Physical,
Skill::Parry => Damage::Physical, // avoid all dmg
Skill::Snare => Damage::Physical,
Skill::Paralyse => Damage::Physical,
Skill::Strangle => Damage::Physical,
// Strangle
Skill::Stun => Damage::Physical,
Skill::Evasion => Damage::Physical, // additional layer of dmg avoidance
// -----------------
// Technology
// -----------------
Skill::Replicate => Damage::Physical,
Skill::Swarm => Damage::Physical,
Skill::Orbit => Damage::Physical,
Skill::Repair => Damage::Physical,
Skill::Scan => Damage::Physical, // track?
// -----------------
// Preservation
// -----------------
Skill::Heal => Damage::Physical,
Skill::Triage => Damage::Physical, // hot
Skill::TriageTick => Damage::Physical, // hot
Skill::Throw => Damage::Physical, // no dmg stun, adds vulnerable
Skill::Charm => Damage::Physical,
Skill::Calm => Damage::Physical,
Skill::Rez => Damage::Physical,
// -----------------
// Destruction
// -----------------
Skill::Blast => Damage::Magic,
Skill::Amplify => Damage::Magic,
Skill::Decay => Damage::Magic, // dot
Skill::DecayTick => Damage::Magic, // hot
Skill::Drain => Damage::Magic,
Skill::DrainTick => Damage::Magic, // hot
Skill::Curse => Damage::Magic,
Skill::Plague => Damage::Magic, // aoe dot
Skill::Ruin => Damage::Magic, // aoe
// -----------------
// Purity
// -----------------
// Skill::Precision => 1,
Skill::Inspire => Damage::Physical,
Skill::Slay => Damage::Physical,
Skill::Shield => Damage::Magic,
Skill::Silence => Damage::Magic,
Skill::Inquiry => Damage::Magic,
Skill::Purify => Damage::Magic,
// -----------------
// Chaos
// -----------------
Skill::Banish => Damage::Magic,
Skill::Hex => Damage::Magic,
Skill::Fear => Damage::Magic,
Skill::Taunt => Damage::Magic,
Skill::Pause => Damage::Magic, // extend durations
// Skill::Lag => 2, //
// -----------------
// Test
// -----------------
Skill::TestTouch => Damage::Physical,
Skill::TestStun => Damage::Physical,
Skill::TestBlock => Damage::Physical,
Skill::TestDrain => Damage::Magic,
}
}
pub fn speed(&self) -> u8 {
match self {
Skill::Attack => 5,
@ -333,7 +434,7 @@ impl Skill {
// -----------------
// Purity
// -----------------
Skill::Precision => 1,
// Skill::Precision => 1,
Skill::Inspire => 2,
Skill::Slay => 1,
Skill::Shield => 1,
@ -409,8 +510,8 @@ impl Skill {
Skill::Triage => triage(cryp, target, log), // hot
Skill::TriageTick => triage_tick(cryp, target, log), // hot
Skill::Throw => throw(cryp, target, log), // no dmg stun, adds vulnerable
Skill::Charm => panic!("nyi"),
Skill::Calm => panic!("nyi"),
Skill::Charm => panic!("nyi"), // cast random spell on teammate
Skill::Calm => panic!("nyi"), // remove fear, taunt
Skill::Rez => panic!("nyi"),
// -----------------
@ -429,11 +530,11 @@ impl Skill {
// -----------------
// Purity
// -----------------
Skill::Precision => panic!("nyi"),
Skill::Inspire => panic!("nyi"),
Skill::Slay => panic!("nyi"),
// Skill::Precision => panic!("nyi"),
Skill::Inspire => panic!("nyi"), // increased phys dmg
Skill::Slay => panic!("nyi"), // phys dmg mult by target magic dmg
Skill::Shield => panic!("nyi"),
Skill::Silence => panic!("nyi"),
Skill::Silence => silence(cryp, target, log),
Skill::Inquiry => panic!("nyi"),
Skill::Purify => panic!("nyi"),
@ -442,7 +543,7 @@ impl Skill {
// -----------------
Skill::Banish => banish(cryp, target, log), // TODO prevent all actions
Skill::Hex => hex(cryp, target, log), // todo prevent casting
Skill::Fear => panic!("nyi"),
Skill::Fear => panic!("nyi"), // cast random spell on self
Skill::Taunt => panic!("nyi"),
Skill::Pause => panic!("nyi"), // speed slow
@ -466,6 +567,8 @@ impl Skill {
Skill::Drain => 3,
Skill::Triage => 3,
Skill::Silence => 3,
Skill::TestBlock => 1,
Skill::TestStun => 2,
_ => panic!("{:?} does not have a duration", self),
@ -481,10 +584,7 @@ impl Skill {
}
pub fn castable(&self, cryp: &Cryp) -> bool {
if cryp.is_stunned() {
return false;
}
true
!cryp.effects.iter().any(|e| e.effect.prevents_casting(*self))
}
}
@ -614,7 +714,6 @@ fn drain(cryp: &mut Cryp, target: &mut Cryp, log: &mut Log) {
log.push(format!("{:?} < {:?} for {:?}T", target.name, effect.effect, effect.duration));
}
// it's fucked
fn drain_tick(cryp: &mut Cryp, target: &mut Cryp, log: &mut Log) {
// damage part
let damage = cryp.spell_dmg.value;
@ -633,6 +732,12 @@ fn drain_tick(cryp: &mut Cryp, target: &mut Cryp, log: &mut Log) {
log.push(format!("{:?} | Drain healing {:?} ({:?} OH)", cryp.name, healing, overhealing));
}
fn silence(_cryp: &mut Cryp, target: &mut Cryp, log: &mut Log) {
let effect = CrypEffect { effect: Effect::Silence, duration: Skill::Silence.duration(), tick: None };
target.effects.push(effect);
log.push(format!("{:?} < {:?} for {:?}T", target.name, effect.effect, effect.duration));
}
fn banish(_cryp: &mut Cryp, target: &mut Cryp, log: &mut Log) {
let effect = CrypEffect { effect: Effect::Banish, duration: Skill::Banish.duration(), tick: None };
target.effects.push(effect);
@ -713,6 +818,20 @@ mod tests {
// y.reduce_effect_durations(&mut log);
// assert!(y.hp.value > prev_hp);
}
#[test]
fn silence_test() {
let mut x = Cryp::new()
.named(&"muji".to_string())
.level(8)
.create();
let mut log = vec![];
silence(&mut x.clone(), &mut x, &mut log);
assert!(x.effects.iter().any(|e| e.effect == Effect::Silence));
assert!(!Skill::Decay.castable(&x));
}
}
// #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]