Fixed resolutions with new format
This commit is contained in:
parent
d2669cfb9e
commit
df76d50a4e
@ -7,15 +7,15 @@ const {
|
|||||||
} = require('./constants');
|
} = require('./constants');
|
||||||
|
|
||||||
function findResolutionCryps(scene, group, resolution, game) {
|
function findResolutionCryps(scene, group, resolution, game) {
|
||||||
const sourceCryp = game.teams.find(t => t.cryps.find(c => c.id === resolution.source_cryp_id))
|
const sourceSpawn = group.children.entries.find(c => c.cryp.id === resolution.source.id);
|
||||||
.cryps.find(c => c.id === resolution.source_cryp_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))
|
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);
|
.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 };
|
return { sourceSpawn, targetSpawn };
|
||||||
}
|
}
|
||||||
@ -46,8 +46,8 @@ function calculateTweenParams(sourceSpawn, targetSpawn, account) {
|
|||||||
|
|
||||||
function animatePhase(scene, game, resolution, cb) {
|
function animatePhase(scene, game, resolution, cb) {
|
||||||
// return early for disabled skills
|
// return early for disabled skills
|
||||||
if (resolution.resolutions.length === 0) return cb();
|
if (resolution.length === 0) return cb();
|
||||||
// if (events[0] === 'Disable') return cb();
|
if (resolution.event[0] === 'Disable') return cb();
|
||||||
|
|
||||||
const group = scene.scene.get('CombatCryps').cryps;
|
const group = scene.scene.get('CombatCryps').cryps;
|
||||||
const animations = new CombatAnimations(scene);
|
const animations = new CombatAnimations(scene);
|
||||||
@ -55,7 +55,6 @@ function animatePhase(scene, game, resolution, cb) {
|
|||||||
|
|
||||||
// Find cryps, targets
|
// Find cryps, targets
|
||||||
const { sourceSpawn, targetSpawn } = findResolutionCryps(scene, group, resolution, game);
|
const { sourceSpawn, targetSpawn } = findResolutionCryps(scene, group, resolution, game);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
moveSourceBattle, moveSourceOrig, moveTargetBattle, moveTargetOrig,
|
moveSourceBattle, moveSourceOrig, moveTargetBattle, moveTargetOrig,
|
||||||
} = calculateTweenParams(sourceSpawn, targetSpawn, account);
|
} = calculateTweenParams(sourceSpawn, targetSpawn, account);
|
||||||
@ -73,50 +72,34 @@ function animatePhase(scene, game, resolution, cb) {
|
|||||||
|
|
||||||
return scene.time.delayedCall(MOVE_CREEP, () => {
|
return scene.time.delayedCall(MOVE_CREEP, () => {
|
||||||
const isAlly = sourceSpawn.cryp.account === account.id;
|
const isAlly = sourceSpawn.cryp.account === account.id;
|
||||||
|
|
||||||
// animate animation
|
// animate animation
|
||||||
animations.getSkill(resolution.skill, isAlly, castLocation);
|
animations.getSkill(resolution.skill, isAlly, castLocation);
|
||||||
// Target cryp takes damage
|
// Target cryp takes damage
|
||||||
scene.time.delayedCall(ANIMATION_DURATION, () => {
|
scene.time.delayedCall(ANIMATION_DURATION, () => {
|
||||||
console.log(resolution.resolutions);
|
if (resolution.event[0] === 'Damage') {
|
||||||
eachSeries(resolution.resolutions, (events, tickCb) => {
|
targetSpawn.takeDamage(resolution.event[1]);
|
||||||
// touch
|
scene.registry.set('gameLog', scene.registry.get('gameLog') + 1);
|
||||||
if (!resolution.resolutions.length) return tickCb();
|
}
|
||||||
if (events.event[0] === 'Damage') {
|
if (resolution.event[0] === 'Healing') {
|
||||||
targetSpawn.takeDamage(events.event[1].amount);
|
targetSpawn.takeHealing(resolution.event[1]);
|
||||||
scene.registry.set('gameLog', scene.registry.get('gameLog') + 1);
|
scene.registry.set('gameLog', scene.registry.get('gameLog') + 1);
|
||||||
return setTimeout(tickCb, DAMAGE_TICK);
|
}
|
||||||
}
|
if (resolution.event[0] === 'Effect') {
|
||||||
if (events.event[0] === 'Healing') {
|
targetSpawn.effects.addEffect(resolution.event[1]);
|
||||||
targetSpawn.takeHealing(events.event[1].amount);
|
console.log('target has new effect', resolution.event[1].effect);
|
||||||
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 (events.event[0] === 'Removal') {
|
if (resolution.event[0] === 'Removal') {
|
||||||
targetSpawn.effects.removeEffect(events.event[1].effect);
|
targetSpawn.effects.removeEffect(resolution.event[1].effect);
|
||||||
console.log('target effect removed', events.event[1].effect);
|
console.log('target effect removed', resolution.event[1].effect);
|
||||||
return setTimeout(tickCb, DAMAGE_TICK);
|
}
|
||||||
}
|
if (moveSourceOrig) scene.tweens.add(moveSourceOrig);
|
||||||
|
scene.tweens.add(moveTargetOrig);
|
||||||
|
|
||||||
// unhandled result type
|
// all done
|
||||||
return tickCb();
|
scene.time.delayedCall(MOVE_CREEP, () => {
|
||||||
},
|
animations.destroy(true);
|
||||||
(err) => {
|
return cb();
|
||||||
// Move cryps back
|
|
||||||
if (moveSourceOrig) scene.tweens.add(moveSourceOrig);
|
|
||||||
scene.tweens.add(moveTargetOrig);
|
|
||||||
|
|
||||||
// all done
|
|
||||||
scene.time.delayedCall(MOVE_CREEP, () => {
|
|
||||||
animations.destroy(true);
|
|
||||||
return cb();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -27,19 +27,19 @@ class StatBar extends Phaser.GameObjects.Graphics {
|
|||||||
|
|
||||||
if (type === 'HP') {
|
if (type === 'HP') {
|
||||||
this.val = this.crypObj.cryp.hp.value;
|
this.val = this.crypObj.cryp.hp.value;
|
||||||
this.max = this.crypObj.cryp.hp.value;
|
this.max = this.crypObj.cryp.hp.max;
|
||||||
this.margin = 0;
|
this.margin = 0;
|
||||||
} else if (type === 'Red Shield') {
|
} else if (type === 'Red Shield') {
|
||||||
this.val = this.crypObj.cryp.red_shield.value;
|
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;
|
this.margin = 1;
|
||||||
} else if (type === 'Blue Shield') {
|
} else if (type === 'Blue Shield') {
|
||||||
this.val = this.crypObj.cryp.blue_shield.value;
|
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;
|
this.margin = 2;
|
||||||
} else if (type === 'Evasion') {
|
} else if (type === 'Evasion') {
|
||||||
this.val = this.crypObj.cryp.evasion.value;
|
this.val = this.crypObj.cryp.evasion.value;
|
||||||
this.max = this.crypObj.cryp.evasion.value;
|
this.max = this.crypObj.cryp.evasion.max;
|
||||||
this.margin = 3;
|
this.margin = 3;
|
||||||
}
|
}
|
||||||
const { statTextX, statTextY } = statTextCoord(cryp.team, cryp.iter, this.margin);
|
const { statTextX, statTextY } = statTextCoord(cryp.team, cryp.iter, this.margin);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user