mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-15 03:49:33 +02:00
Fiexd embarassing bug
This commit is contained in:
parent
d010f90651
commit
40a9256983
@ -809,7 +809,6 @@ export class BattleScene extends SceneBase {
|
||||
* Used for switch out logic checks.
|
||||
* @param pokemon - A {@linkcode Pokemon} on the desired side of the field, used to infer the side and trainer slot (as applicable)
|
||||
* @returns An array containing the **INDICES** of all {@linkcode Pokemon} in reserve able to be switched into.
|
||||
* @overload
|
||||
*/
|
||||
public getBackupPartyMemberIndices(pokemon: Pokemon): number[];
|
||||
/**
|
||||
@ -819,7 +818,6 @@ export class BattleScene extends SceneBase {
|
||||
* Used for switch out logic checks.
|
||||
* @param player - Whether to search the player (`true`) or enemy (`false`) party; default `true`
|
||||
* @returns An array containing the **INDICES** of all {@linkcode Pokemon} in reserve able to be switched into.
|
||||
* @overload
|
||||
*/
|
||||
public getBackupPartyMemberIndices(player: true): number[];
|
||||
/**
|
||||
@ -831,10 +829,8 @@ export class BattleScene extends SceneBase {
|
||||
* @param trainerSlot - The {@linkcode TrainerSlot | trainer slot} to check against for enemy trainers;
|
||||
* used to verify ownership in multi battles
|
||||
* @returns An array containing the **INDICES** of all {@linkcode Pokemon} in reserve able to be switched into.
|
||||
* @overload
|
||||
*/
|
||||
public getBackupPartyMemberIndices(player: false, trainerSlot: TrainerSlot): number[];
|
||||
|
||||
public getBackupPartyMemberIndices(player: boolean | Pokemon, trainerSlot?: number): number[] {
|
||||
// Note: We return the indices instead of the actual Pokemon because `SwitchSummonPhase` and co. take an index instead of a pokemon.
|
||||
// If this is ever changed, this can be replaced with a simpler version involving `filter` and conditional type annotations.
|
||||
|
@ -183,7 +183,7 @@ export class ForceSwitchOutHelper implements ForceSwitchOutHelperArgs {
|
||||
switchOutTarget.getFieldIndex(),
|
||||
summonIndex,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -510,6 +510,10 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
|
||||
abstract initBattleInfo(): void;
|
||||
|
||||
/**
|
||||
* Return whether this Pokemon is currently partaking in battle on field.
|
||||
* @returns Whether this Pokemon is on field.
|
||||
*/
|
||||
isOnField(): boolean {
|
||||
if (!globalScene) {
|
||||
return false;
|
||||
|
@ -33,11 +33,7 @@ export class SwitchSummonPhase extends SummonPhase {
|
||||
super(fieldIndex, player);
|
||||
|
||||
this.switchType = switchType;
|
||||
// -1 = "use trainer switch logic"
|
||||
this.slotIndex =
|
||||
slotIndex > -1
|
||||
? slotIndex
|
||||
: globalScene.currentBattle.trainer!.getNextSummonIndex(this.getTrainerSlotFromFieldIndex());
|
||||
this.slotIndex = slotIndex;
|
||||
this.doReturn = doReturn;
|
||||
}
|
||||
|
||||
@ -48,12 +44,19 @@ export class SwitchSummonPhase extends SummonPhase {
|
||||
super.start();
|
||||
}
|
||||
|
||||
override preSummon(): void {
|
||||
preSummon(): void {
|
||||
const switchOutPokemon = this.getPokemon();
|
||||
|
||||
if (!this.player && globalScene.currentBattle.trainer) {
|
||||
this.showEnemyTrainer(this.getTrainerSlotFromFieldIndex());
|
||||
globalScene.pbTrayEnemy.showPbTray(globalScene.getEnemyParty());
|
||||
if (!this.player) {
|
||||
if (this.slotIndex === -1) {
|
||||
//@ts-expect-error
|
||||
this.slotIndex = globalScene.currentBattle.trainer?.getNextSummonIndex(this.getTrainerSlotFromFieldIndex()); // TODO: what would be the default trainer-slot fallback?
|
||||
}
|
||||
// TODO: This should always be -1
|
||||
if (this.slotIndex > -1) {
|
||||
this.showEnemyTrainer(this.getTrainerSlotFromFieldIndex());
|
||||
globalScene.pbTrayEnemy.showPbTray(globalScene.getEnemyParty());
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
@ -120,7 +123,7 @@ export class SwitchSummonPhase extends SummonPhase {
|
||||
}
|
||||
|
||||
switchAndSummon() {
|
||||
const party = this.player ? this.getParty() : globalScene.getEnemyParty();
|
||||
const party = this.getParty();
|
||||
const switchedInPokemon: Pokemon | undefined = party[this.slotIndex];
|
||||
this.lastPokemon = this.getPokemon();
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { SubstituteTag } from "#app/data/battler-tags";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
import { splitArray } from "#app/utils/array";
|
||||
import { toDmgValue } from "#app/utils/common";
|
||||
import { AbilityId } from "#enums/ability-id";
|
||||
import { BattleType } from "#enums/battle-type";
|
||||
@ -14,6 +13,7 @@ import { SpeciesId } from "#enums/species-id";
|
||||
import { Stat } from "#enums/stat";
|
||||
import { TrainerSlot } from "#enums/trainer-slot";
|
||||
import { TrainerType } from "#enums/trainer-type";
|
||||
import { splitArray } from "#test/test-utils/array-utils";
|
||||
import { GameManager } from "#test/test-utils/game-manager";
|
||||
import i18next from "i18next";
|
||||
import Phaser from "phaser";
|
||||
@ -42,7 +42,8 @@ describe("Moves - Switching Moves", () => {
|
||||
.enemySpecies(SpeciesId.WAILORD)
|
||||
.enemyAbility(AbilityId.STURDY)
|
||||
.enemyMoveset(MoveId.SPLASH)
|
||||
.criticalHits(false);
|
||||
.criticalHits(false)
|
||||
.randomTrainer({ trainerType: TrainerType.ACEROLA, alwaysDouble: false });
|
||||
});
|
||||
|
||||
describe("Force Switch Moves", () => {
|
||||
@ -57,7 +58,7 @@ describe("Moves - Switching Moves", () => {
|
||||
|
||||
const enemy = game.field.getEnemyPokemon();
|
||||
game.move.use(move);
|
||||
await game.toNextTurn();
|
||||
await game.toEndOfTurn();
|
||||
|
||||
const newEnemy = game.field.getEnemyPokemon();
|
||||
expect(newEnemy).not.toBe(enemy);
|
||||
|
@ -24,7 +24,6 @@ export function splitArray<T>(
|
||||
predicate: (value: T, index: number, array: T[]) => unknown,
|
||||
thisArg?: unknown,
|
||||
): [matches: T[], nonMatches: T[]];
|
||||
|
||||
export function splitArray<T>(
|
||||
arr: T[],
|
||||
predicate: (value: T, index: number, array: T[]) => unknown,
|
Loading…
Reference in New Issue
Block a user