From 969d54dd2e96df98212ce3f92d0c10dd6f504fba Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 4 Jul 2023 12:51:28 -0400 Subject: [PATCH] Fix crash for edge case with double battles --- src/battle-phases.ts | 2 ++ src/battle-scene.ts | 22 +++++++++++----------- src/data/move.ts | 4 ++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/battle-phases.ts b/src/battle-phases.ts index 07733276e..57dacf54d 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -1749,6 +1749,8 @@ export class FaintPhase extends PokemonPhase { this.scene.unshiftPhase(new GameOverPhase(this.scene)); else if (nonFaintedPartyMemberCount >= this.scene.currentBattle.getBattlerCount()) this.scene.unshiftPhase(new SwitchPhase(this.scene, this.fieldIndex, true, false)); + else if (nonFaintedPartyMemberCount === 1 && this.scene.currentBattle.double) + this.scene.unshiftPhase(new ToggleDoublePositionPhase(this.scene, false)); } else this.scene.unshiftPhase(new VictoryPhase(this.scene, this.battlerIndex)); diff --git a/src/battle-scene.ts b/src/battle-scene.ts index a20c358df..2e0da342e 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -361,17 +361,6 @@ export default class BattleScene extends Phaser.Scene { field.add(a); }); - if (this.quickStart) { - for (let s = 0; s < 3; s++) { - const playerSpecies = getPokemonSpecies((getPokemonSpecies(s === 0 ? Species.TORCHIC : s === 1 ? Species.TREECKO : Species.MUDKIP)).getSpeciesForLevel(startingLevel, true)); - const playerPokemon = new PlayerPokemon(this, playerSpecies, startingLevel, 0, 0); - playerPokemon.setVisible(false); - loadPokemonAssets.push(playerPokemon.loadAssets()); - - this.party.push(playerPokemon); - } - } - const trainerPbFrameNames = this.anims.generateFrameNames('trainer_m_pb', { zeroPad: 2, start: 1, end: 12 }); this.anims.create({ key: 'trainer_m_pb', @@ -396,6 +385,17 @@ export default class BattleScene extends Phaser.Scene { this.reset(); + if (this.quickStart) { + for (let s = 0; s < 3; s++) { + const playerSpecies = this.randomSpecies(startingWave, startingLevel, false); + const playerPokemon = new PlayerPokemon(this, playerSpecies, startingLevel, 0, 0); + playerPokemon.setVisible(false); + this.party.push(playerPokemon); + + loadPokemonAssets.push(playerPokemon.loadAssets()); + } + } + const ui = new UI(this); this.uiContainer.add(ui); diff --git a/src/data/move.ts b/src/data/move.ts index db5dbc751..ab81fe4d3 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -2581,7 +2581,7 @@ export function initMoves() { .attr(StealHeldItemAttr), new StatusMove(Moves.SPIDER_WEB, "Spider Web", Type.BUG, -1, 10, -1, "Opponent cannot escape/switch.", -1, 0, 2) .attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, 1, true), - new SelfStatusMove(Moves.MIND_READER, "Mind Reader", Type.NORMAL, -1, 5, -1, "User's next attack is guaranteed to hit.", -1, 0, 2) + new StatusMove(Moves.MIND_READER, "Mind Reader", Type.NORMAL, -1, 5, -1, "User's next attack is guaranteed to hit.", -1, 0, 2) .attr(IgnoreAccuracyAttr), new StatusMove(Moves.NIGHTMARE, "Nightmare", Type.GHOST, 100, 15, -1, "The sleeping opponent loses 25% of its max HP each turn.", -1, 0, 2) .attr(AddBattlerTagAttr, BattlerTagType.NIGHTMARE) @@ -2643,7 +2643,7 @@ export function initMoves() { new AttackMove(Moves.BONE_RUSH, "Bone Rush", Type.GROUND, MoveCategory.PHYSICAL, 25, 90, 10, -1, "Hits 2-5 times in one turn.", -1, 0, 2) .attr(MultiHitAttr) .makesContact(false), - new SelfStatusMove(Moves.LOCK_ON, "Lock-On", Type.NORMAL, -1, 5, -1, "User's next attack is guaranteed to hit.", -1, 0, 2) + new StatusMove(Moves.LOCK_ON, "Lock-On", Type.NORMAL, -1, 5, -1, "User's next attack is guaranteed to hit.", -1, 0, 2) .attr(IgnoreAccuracyAttr), new AttackMove(Moves.OUTRAGE, "Outrage", Type.DRAGON, MoveCategory.PHYSICAL, 120, 100, 10, 156, "User attacks for 2-3 turns but then becomes confused.", -1, 0, 2) .attr(FrenzyAttr)