From b98067db86346456f4b8d1d9f48c0aa400ef619b Mon Sep 17 00:00:00 2001 From: Mashy Date: Wed, 5 Dec 2018 18:42:56 +1000 Subject: [PATCH] logs skip KO --- client/src/scenes/combat.cryps.js | 1 + client/src/scenes/combat.js | 14 ++++++++------ client/src/scenes/combat.log.js | 6 ++++++ client/src/scenes/combat.render.resolutions.js | 9 ++++----- client/src/scenes/combat.skills.js | 1 - 5 files changed, 19 insertions(+), 12 deletions(-) mode change 100644 => 100755 client/src/scenes/combat.cryps.js mode change 100644 => 100755 client/src/scenes/combat.js mode change 100644 => 100755 client/src/scenes/combat.log.js mode change 100644 => 100755 client/src/scenes/combat.render.resolutions.js mode change 100644 => 100755 client/src/scenes/combat.skills.js diff --git a/client/src/scenes/combat.cryps.js b/client/src/scenes/combat.cryps.js old mode 100644 new mode 100755 index 0ca1b9c0..8ca49097 --- a/client/src/scenes/combat.cryps.js +++ b/client/src/scenes/combat.cryps.js @@ -117,6 +117,7 @@ class CombatCryps extends Phaser.Scene { this.account = this.registry.get('account'); this.drawCryps(game); this.registry.events.on('changedata', this.updateData, this); + this.registry.set('crypLoaded', true); } updateData(parent, key, data) { diff --git a/client/src/scenes/combat.js b/client/src/scenes/combat.js old mode 100644 new mode 100755 index fe80bbc1..fcaef867 --- a/client/src/scenes/combat.js +++ b/client/src/scenes/combat.js @@ -43,7 +43,7 @@ class Combat extends Phaser.Scene { return ws.sendGameState(game.id); } return false; - }, 1000); + }, 2000); return true; } @@ -88,17 +88,19 @@ class Combat extends Phaser.Scene { } checkAnimation(game) { - // do we need to render resolution animations? - const isAnimating = this.registry.get('gameAnimating'); - if (isAnimating) return false; + // Check cryps are loaded and whether game is animating + const cantAnimate = this.registry.get('gameAnimating') || !this.registry.get('crypLoaded'); + if (cantAnimate) return false; if (game.resolved.length !== this.renderedResolves) { this.registry.set('gameLog', this.registry.get('gameLog') + 1); 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; 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; } } diff --git a/client/src/scenes/combat.log.js b/client/src/scenes/combat.log.js old mode 100644 new mode 100755 index 0999d755..221a0854 --- a/client/src/scenes/combat.log.js +++ b/client/src/scenes/combat.log.js @@ -31,6 +31,12 @@ class CombatLog extends Phaser.Scene { updateLog() { // 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()); } diff --git a/client/src/scenes/combat.render.resolutions.js b/client/src/scenes/combat.render.resolutions.js old mode 100644 new mode 100755 index 6f905a02..b87ccde8 --- a/client/src/scenes/combat.render.resolutions.js +++ b/client/src/scenes/combat.render.resolutions.js @@ -28,11 +28,11 @@ function findResolutionCryps(scene, group, resolution, allyTeam, enemyTeam) { return { allySpawn, enemySpawn, target }; } -function animatePhase(scene, group, game, resolution, cb) { +function animatePhase(scene, game, resolution, cb) { // Iterate the log // return early for disabled skills if (resolution.resolution.disable.disabled) return cb(); - + const group = scene.scene.get('CombatCryps').cryps; const animations = new CombatAnimations(scene); // Find cryps and targets 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); - eachSeries( resolutions, - (resolution, cb) => animatePhase(scene, group, game, resolution, cb), + (resolution, cb) => animatePhase(scene, game, resolution, cb), (err) => { if (err) return console.error(err); scene.registry.set('gameAnimating', false); diff --git a/client/src/scenes/combat.skills.js b/client/src/scenes/combat.skills.js old mode 100644 new mode 100755 index e52e1469..58b12e1f --- a/client/src/scenes/combat.skills.js +++ b/client/src/scenes/combat.skills.js @@ -70,7 +70,6 @@ class CombatSkills extends Phaser.Scene { renderSkills(game) { const shouldUpdate = game.phase !== this.phase; - if (!shouldUpdate) return false; this.phase = game.phase; this.children.list