diff --git a/package.json b/package.json index 5c8f00670..31b56fc98 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "vite-plugin-fs": "^1.0.0-beta.6" }, "dependencies": { - "phaser": "^3.61.0-beta.2", + "phaser": "^3.70.0", "phaser3-rex-plugins": "^1.1.84" } } diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 65e4cf92d..2132a75f6 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -973,13 +973,13 @@ export default class BattleScene extends Phaser.Scene { : this.getBgmLoopPoint(bgmName); let loaded = false; const playNewBgm = () => { - if (bgmName === null && this.bgm && !this.bgm.pendingRemove) { + if (bgmName === null && this.bgm) { this.bgm.play({ volume: this.masterVolume * this.bgmVolume }); return; } - if (this.bgm && !this.bgm.pendingRemove && this.bgm.isPlaying) + if (this.bgm && this.bgm.isPlaying) this.bgm.stop(); this.bgm = this.sound.add(bgmName, { loop: true }); this.bgm.play({ @@ -995,7 +995,7 @@ export default class BattleScene extends Phaser.Scene { }); if (fadeOut) { const onBgmFaded = () => { - if (loaded && (!this.bgm.isPlaying || this.bgm.pendingRemove)) + if (loaded && !this.bgm.isPlaying) playNewBgm(); }; this.time.delayedCall(this.fadeOutBgm(500, true) ? 750 : 250, onBgmFaded); @@ -1005,7 +1005,7 @@ export default class BattleScene extends Phaser.Scene { } pauseBgm(): boolean { - if (this.bgm && !this.bgm.pendingRemove && this.bgm.isPlaying) { + if (this.bgm && this.bgm.isPlaying) { this.bgm.pause(); return true; } @@ -1013,7 +1013,7 @@ export default class BattleScene extends Phaser.Scene { } resumeBgm(): boolean { - if (this.bgm && !this.bgm.pendingRemove && this.bgm.isPaused) { + if (this.bgm && this.bgm.isPaused) { this.bgm.resume(); return true; } diff --git a/src/pokemon.ts b/src/pokemon.ts index ccc6fbc6e..cbfc7f50d 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -1088,8 +1088,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (cry && !cry.pendingRemove) { rate *= 0.99; cry.setRate(rate); - } - else { + } else { faintCryTimer.destroy(); faintCryTimer = null; if (callback) diff --git a/src/trainer.ts b/src/trainer.ts index 5feea41dd..a7a88efe4 100644 --- a/src/trainer.ts +++ b/src/trainer.ts @@ -13,7 +13,12 @@ export default class Trainer extends Phaser.GameObjects.Container { super(scene, -72, 80); this.config = trainerConfigs[trainerType]; this.female = female; - this.partyTemplateIndex = Math.min(partyTemplateIndex !== undefined ? partyTemplateIndex : Phaser.Math.RND.weightedPick(this.config.partyTemplates.map((_, i) => i)), this.config.partyTemplates.length - 1); + this.partyTemplateIndex = Math.min(partyTemplateIndex !== undefined ? partyTemplateIndex : Phaser.Math.RND.weightedPick(this.config.partyTemplates.map((_, i) => i)), + this.config.partyTemplates.length - 1); + + // TODO: Remove when Phaser weightedPick bug is fixed + if (isNaN(this.partyTemplateIndex)) + this.partyTemplateIndex = this.config.partyTemplates.length - 1; console.log(Object.keys(trainerPartyTemplates)[Object.values(trainerPartyTemplates).indexOf(this.getPartyTemplate())]); diff --git a/src/ui/modifier-select-ui-handler.ts b/src/ui/modifier-select-ui-handler.ts index 4a6a8408e..e8ed74602 100644 --- a/src/ui/modifier-select-ui-handler.ts +++ b/src/ui/modifier-select-ui-handler.ts @@ -255,23 +255,22 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { onComplete: () => options.forEach(o => o.destroy()) }); - if (this.transferButtonContainer.visible) { - this.scene.tweens.add({ - targets: [ this.rerollButtonContainer, this.transferButtonContainer ], - alpha: 0, - duration: 250, - ease: 'Cubic.easeIn', - onComplete: () => { - if (!this.options.length) { - this.rerollButtonContainer.setVisible(false); - this.transferButtonContainer.setVisible(false); - } else { - this.rerollButtonContainer.setAlpha(1); - this.transferButtonContainer.setAlpha(1); + [ this.rerollButtonContainer, this.transferButtonContainer ].forEach(container => { + if (container.visible) { + this.scene.tweens.add({ + targets: container, + alpha: 0, + duration: 250, + ease: 'Cubic.easeIn', + onComplete: () => { + if (!this.options.length) + container.setVisible(false); + else + container.setAlpha(1); } - } - }) - } + }); + } + }); } eraseCursor() { diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 29547ff99..0303759d0 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -221,7 +221,7 @@ export default class PartyUiHandler extends MessageUiHandler { let filterResult: string; if (option !== PartyOption.TRANSFER && option !== PartyOption.SPLICE) { filterResult = (this.selectFilter as PokemonSelectFilter)(pokemon); - if (option === PartyOption.TRANSFER && filterResult === null && this.partyUiMode === PartyUiMode.MOVE_MODIFIER) + if (filterResult === null && this.partyUiMode === PartyUiMode.MOVE_MODIFIER) filterResult = this.moveSelectFilter(pokemon.moveset[this.optionsCursor]); } else { const transferPokemon = this.scene.getParty()[this.transferCursor];