logs skip KO

This commit is contained in:
Mashy 2018-12-05 18:42:56 +10:00
parent 91ceaff9ed
commit b98067db86
5 changed files with 19 additions and 12 deletions

1
client/src/scenes/combat.cryps.js Normal file → Executable file
View File

@ -117,6 +117,7 @@ class CombatCryps extends Phaser.Scene {
this.account = this.registry.get('account'); this.account = this.registry.get('account');
this.drawCryps(game); this.drawCryps(game);
this.registry.events.on('changedata', this.updateData, this); this.registry.events.on('changedata', this.updateData, this);
this.registry.set('crypLoaded', true);
} }
updateData(parent, key, data) { updateData(parent, key, data) {

14
client/src/scenes/combat.js Normal file → Executable file
View File

@ -43,7 +43,7 @@ class Combat extends Phaser.Scene {
return ws.sendGameState(game.id); return ws.sendGameState(game.id);
} }
return false; return false;
}, 1000); }, 2000);
return true; return true;
} }
@ -88,17 +88,19 @@ class Combat extends Phaser.Scene {
} }
checkAnimation(game) { checkAnimation(game) {
// do we need to render resolution animations? // Check cryps are loaded and whether game is animating
const isAnimating = this.registry.get('gameAnimating'); const cantAnimate = this.registry.get('gameAnimating') || !this.registry.get('crypLoaded');
if (isAnimating) return false; if (cantAnimate) return false;
if (game.resolved.length !== this.renderedResolves) { if (game.resolved.length !== this.renderedResolves) {
this.registry.set('gameLog', this.registry.get('gameLog') + 1); this.registry.set('gameLog', this.registry.get('gameLog') + 1);
const newResolutions = game.resolved.slice(this.renderedResolves); const newResolutions = game.resolved.slice(this.renderedResolves);
renderResolutions(this, game, this.scene.get('CombatCryps').cryps, newResolutions); renderResolutions(this, game, newResolutions);
this.renderedResolves = game.resolved.length; this.renderedResolves = game.resolved.length;
return true; return true;
} }
this.registry.set('gameLog', game.log.length); if (this.registry.get('gameLog') !== game.log.length) {
this.registry.set('gameLog', game.log.length);
}
return true; return true;
} }
} }

6
client/src/scenes/combat.log.js Normal file → Executable file
View File

@ -31,6 +31,12 @@ class CombatLog extends Phaser.Scene {
updateLog() { updateLog() {
// shallow copy because reverse mutates // shallow copy because reverse mutates
if (this.logData.length > this.logIndex + 1
&& Array.from(this.logData)[this.logIndex].slice(-2) === 'KO') {
this.logIndex += 1;
this.registry.set('gameLog', this.logIndex);
}
// }
this.log.setText(Array.from(this.logData).slice(0, this.logIndex).reverse()); this.log.setText(Array.from(this.logData).slice(0, this.logIndex).reverse());
} }

9
client/src/scenes/combat.render.resolutions.js Normal file → Executable file
View File

@ -28,11 +28,11 @@ function findResolutionCryps(scene, group, resolution, allyTeam, enemyTeam) {
return { allySpawn, enemySpawn, target }; return { allySpawn, enemySpawn, target };
} }
function animatePhase(scene, group, game, resolution, cb) { function animatePhase(scene, game, resolution, cb) {
// Iterate the log // Iterate the log
// return early for disabled skills // return early for disabled skills
if (resolution.resolution.disable.disabled) return cb(); if (resolution.resolution.disable.disabled) return cb();
const group = scene.scene.get('CombatCryps').cryps;
const animations = new CombatAnimations(scene); const animations = new CombatAnimations(scene);
// Find cryps and targets // Find cryps and targets
const tweenParams = (targets, centreSpot, enemy) => { const tweenParams = (targets, centreSpot, enemy) => {
@ -86,12 +86,11 @@ function animatePhase(scene, group, game, resolution, cb) {
}); });
} }
function renderResolutions(scene, game, group, resolutions) { function renderResolutions(scene, game, resolutions) {
scene.registry.set('gameAnimating', true); scene.registry.set('gameAnimating', true);
eachSeries( eachSeries(
resolutions, resolutions,
(resolution, cb) => animatePhase(scene, group, game, resolution, cb), (resolution, cb) => animatePhase(scene, game, resolution, cb),
(err) => { (err) => {
if (err) return console.error(err); if (err) return console.error(err);
scene.registry.set('gameAnimating', false); scene.registry.set('gameAnimating', false);

1
client/src/scenes/combat.skills.js Normal file → Executable file
View File

@ -70,7 +70,6 @@ class CombatSkills extends Phaser.Scene {
renderSkills(game) { renderSkills(game) {
const shouldUpdate = game.phase !== this.phase; const shouldUpdate = game.phase !== this.phase;
if (!shouldUpdate) return false; if (!shouldUpdate) return false;
this.phase = game.phase; this.phase = game.phase;
this.children.list this.children.list