very gross ko logging and resolutions
This commit is contained in:
parent
f49e00f0da
commit
ea2064e7c1
@ -63,6 +63,11 @@ function animatePhase(scene, game, resolution, cb) {
|
|||||||
moveSourceBattle, moveSourceOrig, moveTargetBattle, moveTargetOrig,
|
moveSourceBattle, moveSourceOrig, moveTargetBattle, moveTargetOrig,
|
||||||
} = calculateTweenParams(sourceSpawn, targetSpawn, account);
|
} = calculateTweenParams(sourceSpawn, targetSpawn, account);
|
||||||
|
|
||||||
|
// ew
|
||||||
|
const { resolution: { results } } = resolution;
|
||||||
|
|
||||||
|
if (results.len === 0) return cb();
|
||||||
|
|
||||||
// Move cryps into posistion
|
// Move cryps into posistion
|
||||||
if (moveSourceBattle) scene.tweens.add(moveSourceBattle);
|
if (moveSourceBattle) scene.tweens.add(moveSourceBattle);
|
||||||
scene.tweens.add(moveTargetBattle);
|
scene.tweens.add(moveTargetBattle);
|
||||||
@ -74,9 +79,6 @@ function animatePhase(scene, game, resolution, cb) {
|
|||||||
|
|
||||||
// Target cryp takes damage
|
// Target cryp takes damage
|
||||||
scene.time.delayedCall(ANIMATION_DURATION, () => {
|
scene.time.delayedCall(ANIMATION_DURATION, () => {
|
||||||
// ew
|
|
||||||
const { resolution: { results } } = resolution;
|
|
||||||
|
|
||||||
eachSeries(results,
|
eachSeries(results,
|
||||||
(result, tickCb) => {
|
(result, tickCb) => {
|
||||||
// touch
|
// touch
|
||||||
|
|||||||
@ -84,6 +84,7 @@ pub struct Cryp {
|
|||||||
pub skills: Vec<CrypSkill>,
|
pub skills: Vec<CrypSkill>,
|
||||||
pub effects: Vec<CrypEffect>,
|
pub effects: Vec<CrypEffect>,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
pub ko_logged: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_lvl(lvl: u8) -> u8 {
|
fn check_lvl(lvl: u8) -> u8 {
|
||||||
@ -105,7 +106,8 @@ impl Cryp {
|
|||||||
xp: 0,
|
xp: 0,
|
||||||
skills: vec![CrypSkill::new(Skill::Attack)],
|
skills: vec![CrypSkill::new(Skill::Attack)],
|
||||||
effects: vec![],
|
effects: vec![],
|
||||||
name: String::new()
|
name: String::new(),
|
||||||
|
ko_logged: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +208,7 @@ impl Cryp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn disabled(&self, skill: Skill) -> Disable {
|
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]};
|
return Disable { disabled: true, effects: vec![Effect::Ko]};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
|
use rand::distributions::Alphanumeric;
|
||||||
|
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ use failure::err_msg;
|
|||||||
use account::Account;
|
use account::Account;
|
||||||
use rpc::{GameStateParams, GameSkillParams, GamePveParams, GamePvpParams, GameTargetParams, GameJoinParams};
|
use rpc::{GameStateParams, GameSkillParams, GamePveParams, GamePvpParams, GameTargetParams, GameJoinParams};
|
||||||
use cryp::{Cryp, cryp_get};
|
use cryp::{Cryp, cryp_get};
|
||||||
use skill::{Skill, Cast, ResolutionResult};
|
use skill::{Skill, Cast, Effect, ResolutionResult};
|
||||||
|
|
||||||
pub type Log = Vec<String>;
|
pub type Log = Vec<String>;
|
||||||
|
|
||||||
@ -235,9 +236,9 @@ impl Game {
|
|||||||
return Err(err_msg("abiltity on cooldown"));
|
return Err(err_msg("abiltity on cooldown"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if skill.self_targeting() && target_team_id.is_some() {
|
// if skill.self_targeting() && target_team_id.is_some() {
|
||||||
return Err(err_msg("skill is self targeting"));
|
// return Err(err_msg("skill is self targeting"));
|
||||||
}
|
// }
|
||||||
|
|
||||||
if !skill.self_targeting() && target_team_id.is_none() {
|
if !skill.self_targeting() && target_team_id.is_none() {
|
||||||
return Err(err_msg("skill requires a target"));
|
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
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,6 +469,18 @@ impl Game {
|
|||||||
|
|
||||||
self.resolved.push(skill.clone());
|
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 source);
|
||||||
self.update_cryp(&mut target);
|
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))?;
|
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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@ -699,6 +702,11 @@ pub fn game_update(game: &Game, tx: &mut Transaction) -> Result<(), Error> {
|
|||||||
fn generate_mob(lvl: u8) -> Cryp {
|
fn generate_mob(lvl: u8) -> Cryp {
|
||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
|
|
||||||
|
let name: String = iter::repeat(())
|
||||||
|
.map(|()| rng.sample(Alphanumeric))
|
||||||
|
.take(8)
|
||||||
|
.collect();
|
||||||
|
|
||||||
// rng panics on min == max
|
// rng panics on min == max
|
||||||
// let mob_lvl: u8 = match lvl {
|
// let mob_lvl: u8 = match lvl {
|
||||||
// 1 => 1,
|
// 1 => 1,
|
||||||
@ -706,7 +714,7 @@ fn generate_mob(lvl: u8) -> Cryp {
|
|||||||
// };
|
// };
|
||||||
|
|
||||||
return Cryp::new()
|
return Cryp::new()
|
||||||
.named(&"bamboo basher".to_string())
|
.named(&name)
|
||||||
.level(lvl)
|
.level(lvl)
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
|
|||||||
@ -172,6 +172,10 @@ impl Effect {
|
|||||||
Category::Physical => false,
|
Category::Physical => false,
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
|
Effect::Ko => match skill.category() {
|
||||||
|
Category::SpellTick => false,
|
||||||
|
_ => true,
|
||||||
|
},
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,11 +252,13 @@ pub enum Category {
|
|||||||
PhysDmg,
|
PhysDmg,
|
||||||
PhysDebuff,
|
PhysDebuff,
|
||||||
PhysBuff,
|
PhysBuff,
|
||||||
|
PhysTick,
|
||||||
Spell,
|
Spell,
|
||||||
SpellDmg,
|
SpellDmg,
|
||||||
SpellHeal,
|
SpellHeal,
|
||||||
SpellDebuff,
|
SpellDebuff,
|
||||||
SpellBuff,
|
SpellBuff,
|
||||||
|
SpellTick,
|
||||||
Ko,
|
Ko,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,7 +462,7 @@ impl Skill {
|
|||||||
// -----------------
|
// -----------------
|
||||||
Skill::Heal => Category::Physical,
|
Skill::Heal => Category::Physical,
|
||||||
Skill::Triage => Category::Spell, // hot
|
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::Throw => Category::Physical, // no dmg stun, adds vulnerable
|
||||||
Skill::Charm => Category::Spell,
|
Skill::Charm => Category::Spell,
|
||||||
Skill::Calm => Category::Physical,
|
Skill::Calm => Category::Physical,
|
||||||
@ -468,9 +474,9 @@ impl Skill {
|
|||||||
Skill::Blast => Category::Spell,
|
Skill::Blast => Category::Spell,
|
||||||
Skill::Amplify => Category::Spell,
|
Skill::Amplify => Category::Spell,
|
||||||
Skill::Decay => Category::Spell, // dot
|
Skill::Decay => Category::Spell, // dot
|
||||||
Skill::DecayTick => Category::Spell, // hot
|
Skill::DecayTick => Category::SpellTick, // hot
|
||||||
Skill::Drain => Category::Spell,
|
Skill::Drain => Category::Spell,
|
||||||
Skill::DrainTick => Category::Spell, // hot
|
Skill::DrainTick => Category::SpellTick, // hot
|
||||||
Skill::Curse => Category::Spell,
|
Skill::Curse => Category::Spell,
|
||||||
Skill::Plague => Category::Spell, // aoe dot
|
Skill::Plague => Category::Spell, // aoe dot
|
||||||
Skill::Ruin => Category::Spell, // aoe
|
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 {
|
pub fn speed(&self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
Skill::Attack => 5,
|
Skill::Attack => 5,
|
||||||
@ -598,6 +613,10 @@ impl Skill {
|
|||||||
|
|
||||||
let resolution = Resolution { skill: *self, results: vec![], disable: cryp.disabled(*self) };
|
let resolution = Resolution { skill: *self, results: vec![], disable: cryp.disabled(*self) };
|
||||||
|
|
||||||
|
if target.is_ko() {
|
||||||
|
return resolution;
|
||||||
|
}
|
||||||
|
|
||||||
if resolution.disable.disabled {
|
if resolution.disable.disabled {
|
||||||
return resolution;
|
return resolution;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user