resolution result iteration

This commit is contained in:
ntr 2018-12-07 15:27:45 +11:00
parent 3c2a7dbd45
commit 436c4dc4ac
4 changed files with 55 additions and 25 deletions

View File

@ -74,13 +74,40 @@ function animatePhase(scene, game, resolution, cb) {
// Target cryp takes damage
scene.time.delayedCall(ANIMATION_DURATION, () => {
const combatTick = resolution.resolution.results[0][1];
const damage = combatTick.category === 'PhysHeal' ? combatTick.amount * -1 : combatTick.amount;
targetSpawn.takeDamage(damage);
scene.registry.set('gameLog', scene.registry.get('gameLog') + 1);
// ew
const { resolution: { results } } = resolution;
eachSeries(results,
(result, tickCb) => {
// touch
if (!results.length) return tickCb();
const [resultType, values] = result;
if (resultType === 'Damage') {
targetSpawn.takeDamage(values.amount);
scene.registry.set('gameLog', scene.registry.get('gameLog') + 1);
return setTimeout(tickCb, DAMAGE_TICK);
}
if (resultType === 'Healing') {
targetSpawn.takeDamage(values.amount * -1);
scene.registry.set('gameLog', scene.registry.get('gameLog') + 1);
return setTimeout(tickCb, DAMAGE_TICK);
}
if (resultType === 'Effect') {
console.log('target has new effect', values.effect);
return setTimeout(tickCb, DAMAGE_TICK);
}
if (resultType === 'Removal') {
console.log('target effect removed', values.effect);
return setTimeout(tickCb, DAMAGE_TICK);
}
// unhandled result type
return tickCb();
},
(err) => {
// Move cryps back
scene.time.delayedCall(DAMAGE_TICK, () => {
if (moveSourceOrig) scene.tweens.add(moveSourceOrig);
scene.tweens.add(moveTargetOrig);

View File

@ -186,7 +186,7 @@ function createSocket(events) {
if (!account) events.loginPrompt();
if (process.env.NODE_ENV !== 'production') {
send({ method: 'account_login', params: { name: 'ntr', password: 'grepgrepgrep' } });
// send({ method: 'account_login', params: { name: 'ntr', password: 'grepgrepgrep' } });
}
return true;

View File

@ -412,6 +412,9 @@ impl Game {
ResolutionResult::Damage { amount, category: _, immunity: _ } => {
self.log.push(format!("{:?} {:?} {:?} {:?}", source.name, cast.skill, target.name, amount));
},
ResolutionResult::Healing { amount, category: _, immunity: _ } => {
self.log.push(format!("{:?} {:?} {:?} {:?}", source.name, cast.skill, target.name, amount));
},
ResolutionResult::Effect { effect, duration, immunity: _ } => {
self.log.push(format!("{:?} {:?} {:?} {:?} {:?}T", source.name, cast.skill, target.name, effect, duration));
},

View File

@ -82,6 +82,7 @@ impl Disable {
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
pub enum ResolutionResult {
Damage { amount: u64, category: Category , immunity: Immunity },
Healing { amount: u64, category: Category , immunity: Immunity },
Effect { effect: Effect, duration: u8, immunity: Immunity },
Removal { effect: Effect, immunity: Immunity },
}
@ -148,10 +149,9 @@ pub enum Effect {
impl Effect {
pub fn immune(&self, skill: Skill) -> bool {
match self {
Effect::Block => match skill {
Skill::Stun |
Skill::TestStun |
Skill::Attack => true,
Effect::Block => match skill.category() {
Category::Spell => false,
Category::Physical => true,
_ => false,
},
Effect::Shield => match skill.category() {
@ -455,12 +455,12 @@ impl Skill {
// Preservation
// -----------------
Skill::Heal => Category::Physical,
Skill::Triage => Category::Physical, // hot
Skill::TriageTick => Category::Physical, // hot
Skill::Triage => Category::Spell, // hot
Skill::TriageTick => Category::Spell, // hot
Skill::Throw => Category::Physical, // no dmg stun, adds vulnerable
Skill::Charm => Category::Physical,
Skill::Charm => Category::Spell,
Skill::Calm => Category::Physical,
Skill::Rez => Category::Physical,
Skill::Rez => Category::Spell,
// -----------------
// Destruction
@ -852,7 +852,7 @@ fn heal(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resol
let immunity = target.immune(Skill::Heal);
let immune = immunity.immune;
let heal_result = ResolutionResult::Damage {
let heal_result = ResolutionResult::Healing {
amount,
category: Category::PhysHeal,
immunity,
@ -898,7 +898,7 @@ fn triage_tick(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -
let immunity = target.immune(Skill::TriageTick);
let immune = immunity.immune;
let heal_result = ResolutionResult::Damage {
let heal_result = ResolutionResult::Healing {
amount,
category: Category::PhysHeal,
immunity,
@ -1074,7 +1074,7 @@ fn drain_tick(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) ->
immunity: immunity.clone(),
};
let drain_tick_heal_result = ResolutionResult::Damage {
let drain_tick_heal_result = ResolutionResult::Healing {
amount,
category: Category::SpellHeal,
immunity,