resolution result iteration
This commit is contained in:
parent
3c2a7dbd45
commit
436c4dc4ac
@ -74,13 +74,40 @@ function animatePhase(scene, game, resolution, cb) {
|
|||||||
|
|
||||||
// Target cryp takes damage
|
// Target cryp takes damage
|
||||||
scene.time.delayedCall(ANIMATION_DURATION, () => {
|
scene.time.delayedCall(ANIMATION_DURATION, () => {
|
||||||
const combatTick = resolution.resolution.results[0][1];
|
// ew
|
||||||
const damage = combatTick.category === 'PhysHeal' ? combatTick.amount * -1 : combatTick.amount;
|
const { resolution: { results } } = resolution;
|
||||||
targetSpawn.takeDamage(damage);
|
|
||||||
scene.registry.set('gameLog', scene.registry.get('gameLog') + 1);
|
|
||||||
|
|
||||||
|
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
|
// Move cryps back
|
||||||
scene.time.delayedCall(DAMAGE_TICK, () => {
|
|
||||||
if (moveSourceOrig) scene.tweens.add(moveSourceOrig);
|
if (moveSourceOrig) scene.tweens.add(moveSourceOrig);
|
||||||
scene.tweens.add(moveTargetOrig);
|
scene.tweens.add(moveTargetOrig);
|
||||||
|
|
||||||
|
|||||||
@ -186,7 +186,7 @@ function createSocket(events) {
|
|||||||
|
|
||||||
if (!account) events.loginPrompt();
|
if (!account) events.loginPrompt();
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
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;
|
return true;
|
||||||
|
|||||||
@ -412,6 +412,9 @@ impl Game {
|
|||||||
ResolutionResult::Damage { amount, category: _, immunity: _ } => {
|
ResolutionResult::Damage { amount, category: _, immunity: _ } => {
|
||||||
self.log.push(format!("{:?} {:?} {:?} {:?}", source.name, cast.skill, target.name, amount));
|
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: _ } => {
|
ResolutionResult::Effect { effect, duration, immunity: _ } => {
|
||||||
self.log.push(format!("{:?} {:?} {:?} {:?} {:?}T", source.name, cast.skill, target.name, effect, duration));
|
self.log.push(format!("{:?} {:?} {:?} {:?} {:?}T", source.name, cast.skill, target.name, effect, duration));
|
||||||
},
|
},
|
||||||
|
|||||||
@ -82,6 +82,7 @@ impl Disable {
|
|||||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||||
pub enum ResolutionResult {
|
pub enum ResolutionResult {
|
||||||
Damage { amount: u64, category: Category , immunity: Immunity },
|
Damage { amount: u64, category: Category , immunity: Immunity },
|
||||||
|
Healing { amount: u64, category: Category , immunity: Immunity },
|
||||||
Effect { effect: Effect, duration: u8, immunity: Immunity },
|
Effect { effect: Effect, duration: u8, immunity: Immunity },
|
||||||
Removal { effect: Effect, immunity: Immunity },
|
Removal { effect: Effect, immunity: Immunity },
|
||||||
}
|
}
|
||||||
@ -148,10 +149,9 @@ pub enum Effect {
|
|||||||
impl Effect {
|
impl Effect {
|
||||||
pub fn immune(&self, skill: Skill) -> bool {
|
pub fn immune(&self, skill: Skill) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Effect::Block => match skill {
|
Effect::Block => match skill.category() {
|
||||||
Skill::Stun |
|
Category::Spell => false,
|
||||||
Skill::TestStun |
|
Category::Physical => true,
|
||||||
Skill::Attack => true,
|
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
Effect::Shield => match skill.category() {
|
Effect::Shield => match skill.category() {
|
||||||
@ -455,12 +455,12 @@ impl Skill {
|
|||||||
// Preservation
|
// Preservation
|
||||||
// -----------------
|
// -----------------
|
||||||
Skill::Heal => Category::Physical,
|
Skill::Heal => Category::Physical,
|
||||||
Skill::Triage => Category::Physical, // hot
|
Skill::Triage => Category::Spell, // hot
|
||||||
Skill::TriageTick => Category::Physical, // hot
|
Skill::TriageTick => Category::Spell, // hot
|
||||||
Skill::Throw => Category::Physical, // no dmg stun, adds vulnerable
|
Skill::Throw => Category::Physical, // no dmg stun, adds vulnerable
|
||||||
Skill::Charm => Category::Physical,
|
Skill::Charm => Category::Spell,
|
||||||
Skill::Calm => Category::Physical,
|
Skill::Calm => Category::Physical,
|
||||||
Skill::Rez => Category::Physical,
|
Skill::Rez => Category::Spell,
|
||||||
|
|
||||||
// -----------------
|
// -----------------
|
||||||
// Destruction
|
// Destruction
|
||||||
@ -852,7 +852,7 @@ fn heal(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resol
|
|||||||
let immunity = target.immune(Skill::Heal);
|
let immunity = target.immune(Skill::Heal);
|
||||||
let immune = immunity.immune;
|
let immune = immunity.immune;
|
||||||
|
|
||||||
let heal_result = ResolutionResult::Damage {
|
let heal_result = ResolutionResult::Healing {
|
||||||
amount,
|
amount,
|
||||||
category: Category::PhysHeal,
|
category: Category::PhysHeal,
|
||||||
immunity,
|
immunity,
|
||||||
@ -898,7 +898,7 @@ fn triage_tick(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -
|
|||||||
let immunity = target.immune(Skill::TriageTick);
|
let immunity = target.immune(Skill::TriageTick);
|
||||||
let immune = immunity.immune;
|
let immune = immunity.immune;
|
||||||
|
|
||||||
let heal_result = ResolutionResult::Damage {
|
let heal_result = ResolutionResult::Healing {
|
||||||
amount,
|
amount,
|
||||||
category: Category::PhysHeal,
|
category: Category::PhysHeal,
|
||||||
immunity,
|
immunity,
|
||||||
@ -1074,7 +1074,7 @@ fn drain_tick(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) ->
|
|||||||
immunity: immunity.clone(),
|
immunity: immunity.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let drain_tick_heal_result = ResolutionResult::Damage {
|
let drain_tick_heal_result = ResolutionResult::Healing {
|
||||||
amount,
|
amount,
|
||||||
category: Category::SpellHeal,
|
category: Category::SpellHeal,
|
||||||
immunity,
|
immunity,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user