logs skip KO
This commit is contained in:
parent
91ceaff9ed
commit
b98067db86
1
client/src/scenes/combat.cryps.js
Normal file → Executable file
1
client/src/scenes/combat.cryps.js
Normal file → Executable file
@ -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) {
|
||||
|
||||
12
client/src/scenes/combat.js
Normal file → Executable file
12
client/src/scenes/combat.js
Normal file → Executable file
@ -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;
|
||||
}
|
||||
if (this.registry.get('gameLog') !== game.log.length) {
|
||||
this.registry.set('gameLog', game.log.length);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
6
client/src/scenes/combat.log.js
Normal file → Executable file
6
client/src/scenes/combat.log.js
Normal file → Executable file
@ -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());
|
||||
}
|
||||
|
||||
|
||||
9
client/src/scenes/combat.render.resolutions.js
Normal file → Executable file
9
client/src/scenes/combat.render.resolutions.js
Normal file → Executable file
@ -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);
|
||||
|
||||
1
client/src/scenes/combat.skills.js
Normal file → Executable file
1
client/src/scenes/combat.skills.js
Normal file → Executable file
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user