very gross ko logging and resolutions

This commit is contained in:
ntr 2018-12-11 22:33:32 +11:00
parent f49e00f0da
commit ea2064e7c1
4 changed files with 55 additions and 24 deletions

View File

@ -63,6 +63,11 @@ function animatePhase(scene, game, resolution, cb) {
moveSourceBattle, moveSourceOrig, moveTargetBattle, moveTargetOrig,
} = calculateTweenParams(sourceSpawn, targetSpawn, account);
// ew
const { resolution: { results } } = resolution;
if (results.len === 0) return cb();
// Move cryps into posistion
if (moveSourceBattle) scene.tweens.add(moveSourceBattle);
scene.tweens.add(moveTargetBattle);
@ -74,9 +79,6 @@ function animatePhase(scene, game, resolution, cb) {
// Target cryp takes damage
scene.time.delayedCall(ANIMATION_DURATION, () => {
// ew
const { resolution: { results } } = resolution;
eachSeries(results,
(result, tickCb) => {
// touch

View File

@ -84,6 +84,7 @@ pub struct Cryp {
pub skills: Vec<CrypSkill>,
pub effects: Vec<CrypEffect>,
pub name: String,
pub ko_logged: bool,
}
fn check_lvl(lvl: u8) -> u8 {
@ -105,7 +106,8 @@ impl Cryp {
xp: 0,
skills: vec![CrypSkill::new(Skill::Attack)],
effects: vec![],
name: String::new()
name: String::new(),
ko_logged: false,
};
}
@ -206,7 +208,7 @@ impl Cryp {
}
pub fn disabled(&self, skill: Skill) -> Disable {
if self.is_ko() {
if self.is_ko() && !skill.ko_castable() {
return Disable { disabled: true, effects: vec![Effect::Ko]};
}

View File

@ -1,5 +1,6 @@
use uuid::Uuid;
use rand::prelude::*;
use rand::distributions::Alphanumeric;
use std::iter;
@ -12,7 +13,7 @@ use failure::err_msg;
use account::Account;
use rpc::{GameStateParams, GameSkillParams, GamePveParams, GamePvpParams, GameTargetParams, GameJoinParams};
use cryp::{Cryp, cryp_get};
use skill::{Skill, Cast, ResolutionResult};
use skill::{Skill, Cast, Effect, ResolutionResult};
pub type Log = Vec<String>;
@ -235,9 +236,9 @@ impl Game {
return Err(err_msg("abiltity on cooldown"));
}
if skill.self_targeting() && target_team_id.is_some() {
return Err(err_msg("skill is self targeting"));
}
// if skill.self_targeting() && target_team_id.is_some() {
// return Err(err_msg("skill is self targeting"));
// }
if !skill.self_targeting() && target_team_id.is_none() {
return Err(err_msg("skill requires a target"));
@ -432,16 +433,6 @@ impl Game {
}
}
if target.is_ko() {
self.log.push(format!("{:} KO", target.name));
target.effects.clear();
}
if source.is_ko() {
self.log.push(format!("{:} KO", source.name));
source.effects.clear();
}
self
}
@ -478,6 +469,18 @@ impl Game {
self.resolved.push(skill.clone());
if target.is_ko() && !target.ko_logged {
self.log.push(format!("{:} KO", target.name));
target.effects.clear();
target.ko_logged = true;
}
if source.is_ko() && !source.ko_logged {
self.log.push(format!("{:} KO", source.name));
source.effects.clear();
source.ko_logged = true;
}
self.update_cryp(&mut source);
self.update_cryp(&mut target);
@ -691,7 +694,7 @@ pub fn game_update(game: &Game, tx: &mut Transaction) -> Result<(), Error> {
result.iter().next().ok_or(format_err!("game {:?} could not be written", game))?;
println!("{:} wrote game", game.id);
// println!("{:} wrote game", game.id);
return Ok(());
}
@ -699,6 +702,11 @@ pub fn game_update(game: &Game, tx: &mut Transaction) -> Result<(), Error> {
fn generate_mob(lvl: u8) -> Cryp {
let mut rng = thread_rng();
let name: String = iter::repeat(())
.map(|()| rng.sample(Alphanumeric))
.take(8)
.collect();
// rng panics on min == max
// let mob_lvl: u8 = match lvl {
// 1 => 1,
@ -706,7 +714,7 @@ fn generate_mob(lvl: u8) -> Cryp {
// };
return Cryp::new()
.named(&"bamboo basher".to_string())
.named(&name)
.level(lvl)
.create();

View File

@ -172,6 +172,10 @@ impl Effect {
Category::Physical => false,
_ => false,
},
Effect::Ko => match skill.category() {
Category::SpellTick => false,
_ => true,
},
_ => false,
}
}
@ -248,11 +252,13 @@ pub enum Category {
PhysDmg,
PhysDebuff,
PhysBuff,
PhysTick,
Spell,
SpellDmg,
SpellHeal,
SpellDebuff,
SpellBuff,
SpellTick,
Ko,
}
@ -456,7 +462,7 @@ impl Skill {
// -----------------
Skill::Heal => Category::Physical,
Skill::Triage => Category::Spell, // hot
Skill::TriageTick => Category::Spell, // hot
Skill::TriageTick => Category::SpellTick, // hot
Skill::Throw => Category::Physical, // no dmg stun, adds vulnerable
Skill::Charm => Category::Spell,
Skill::Calm => Category::Physical,
@ -468,9 +474,9 @@ impl Skill {
Skill::Blast => Category::Spell,
Skill::Amplify => Category::Spell,
Skill::Decay => Category::Spell, // dot
Skill::DecayTick => Category::Spell, // hot
Skill::DecayTick => Category::SpellTick, // hot
Skill::Drain => Category::Spell,
Skill::DrainTick => Category::Spell, // hot
Skill::DrainTick => Category::SpellTick, // hot
Skill::Curse => Category::Spell,
Skill::Plague => Category::Spell, // aoe dot
Skill::Ruin => Category::Spell, // aoe
@ -507,6 +513,15 @@ impl Skill {
}
}
pub fn ko_castable(&self) -> bool {
match self {
Skill::TriageTick => true,
Skill::DecayTick => true,
Skill::DrainTick => true,
_ => false,
}
}
pub fn speed(&self) -> u8 {
match self {
Skill::Attack => 5,
@ -598,6 +613,10 @@ impl Skill {
let resolution = Resolution { skill: *self, results: vec![], disable: cryp.disabled(*self) };
if target.is_ko() {
return resolution;
}
if resolution.disable.disabled {
return resolution;
}