Fixed resolutions with new format

This commit is contained in:
Mashy 2019-03-25 15:08:12 +10:00
parent d2669cfb9e
commit df76d50a4e
2 changed files with 33 additions and 50 deletions

View File

@ -7,15 +7,15 @@ const {
} = require('./constants');
function findResolutionCryps(scene, group, resolution, game) {
const sourceCryp = game.teams.find(t => t.cryps.find(c => c.id === resolution.source_cryp_id))
.cryps.find(c => c.id === resolution.source_cryp_id);
const sourceSpawn = group.children.entries.find(c => c.cryp.id === resolution.source.id);
const sourceSpawn = group.children.entries.find(c => c.cryp.id === sourceCryp.id);
/* const sourceCryp = game.teams.find(t => t.cryps.find(c => c.id === resolution.source_cryp_id))
.cryps.find(c => c.id === resolution.source_cryp_id);
const targetCryp = game.teams.find(t => t.cryps.find(c => c.id === resolution.target_cryp_id))
.cryps.find(c => c.id === resolution.target_cryp_id);
const targetSpawn = group.children.entries.find(c => c.cryp.id === targetCryp.id);
*/
const targetSpawn = group.children.entries.find(c => c.cryp.id === resolution.target.id);
return { sourceSpawn, targetSpawn };
}
@ -46,8 +46,8 @@ function calculateTweenParams(sourceSpawn, targetSpawn, account) {
function animatePhase(scene, game, resolution, cb) {
// return early for disabled skills
if (resolution.resolutions.length === 0) return cb();
// if (events[0] === 'Disable') return cb();
if (resolution.length === 0) return cb();
if (resolution.event[0] === 'Disable') return cb();
const group = scene.scene.get('CombatCryps').cryps;
const animations = new CombatAnimations(scene);
@ -55,7 +55,6 @@ function animatePhase(scene, game, resolution, cb) {
// Find cryps, targets
const { sourceSpawn, targetSpawn } = findResolutionCryps(scene, group, resolution, game);
const {
moveSourceBattle, moveSourceOrig, moveTargetBattle, moveTargetOrig,
} = calculateTweenParams(sourceSpawn, targetSpawn, account);
@ -73,42 +72,27 @@ function animatePhase(scene, game, resolution, cb) {
return scene.time.delayedCall(MOVE_CREEP, () => {
const isAlly = sourceSpawn.cryp.account === account.id;
// animate animation
animations.getSkill(resolution.skill, isAlly, castLocation);
// Target cryp takes damage
scene.time.delayedCall(ANIMATION_DURATION, () => {
console.log(resolution.resolutions);
eachSeries(resolution.resolutions, (events, tickCb) => {
// touch
if (!resolution.resolutions.length) return tickCb();
if (events.event[0] === 'Damage') {
targetSpawn.takeDamage(events.event[1].amount);
if (resolution.event[0] === 'Damage') {
targetSpawn.takeDamage(resolution.event[1]);
scene.registry.set('gameLog', scene.registry.get('gameLog') + 1);
return setTimeout(tickCb, DAMAGE_TICK);
}
if (events.event[0] === 'Healing') {
targetSpawn.takeHealing(events.event[1].amount);
if (resolution.event[0] === 'Healing') {
targetSpawn.takeHealing(resolution.event[1]);
scene.registry.set('gameLog', scene.registry.get('gameLog') + 1);
return setTimeout(tickCb, DAMAGE_TICK);
}
if (events.event[0] === 'Effect') {
targetSpawn.effects.addEffect(events.event[0]);
console.log('target has new effect', events.event[1].effect);
return setTimeout(tickCb, DAMAGE_TICK);
if (resolution.event[0] === 'Effect') {
targetSpawn.effects.addEffect(resolution.event[1]);
console.log('target has new effect', resolution.event[1].effect);
}
if (events.event[0] === 'Removal') {
targetSpawn.effects.removeEffect(events.event[1].effect);
console.log('target effect removed', events.event[1].effect);
return setTimeout(tickCb, DAMAGE_TICK);
if (resolution.event[0] === 'Removal') {
targetSpawn.effects.removeEffect(resolution.event[1].effect);
console.log('target effect removed', resolution.event[1].effect);
}
// unhandled result type
return tickCb();
},
(err) => {
// Move cryps back
if (moveSourceOrig) scene.tweens.add(moveSourceOrig);
scene.tweens.add(moveTargetOrig);
@ -119,7 +103,6 @@ function animatePhase(scene, game, resolution, cb) {
});
});
});
});
}
function renderResolutions(scene, game, resolutions) {

View File

@ -27,19 +27,19 @@ class StatBar extends Phaser.GameObjects.Graphics {
if (type === 'HP') {
this.val = this.crypObj.cryp.hp.value;
this.max = this.crypObj.cryp.hp.value;
this.max = this.crypObj.cryp.hp.max;
this.margin = 0;
} else if (type === 'Red Shield') {
this.val = this.crypObj.cryp.red_shield.value;
this.max = this.crypObj.cryp.red_shield.value;
this.max = this.crypObj.cryp.red_shield.max;
this.margin = 1;
} else if (type === 'Blue Shield') {
this.val = this.crypObj.cryp.blue_shield.value;
this.max = this.crypObj.cryp.blue_shield.value;
this.max = this.crypObj.cryp.blue_shield.max;
this.margin = 2;
} else if (type === 'Evasion') {
this.val = this.crypObj.cryp.evasion.value;
this.max = this.crypObj.cryp.evasion.value;
this.max = this.crypObj.cryp.evasion.max;
this.margin = 3;
}
const { statTextX, statTextY } = statTextCoord(cryp.team, cryp.iter, this.margin);