mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-16 04:19:32 +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.
|
* 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)
|
* @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.
|
* @returns An array containing the **INDICES** of all {@linkcode Pokemon} in reserve able to be switched into.
|
||||||
* @overload
|
|
||||||
*/
|
*/
|
||||||
public getBackupPartyMemberIndices(pokemon: Pokemon): number[];
|
public getBackupPartyMemberIndices(pokemon: Pokemon): number[];
|
||||||
/**
|
/**
|
||||||
@ -819,7 +818,6 @@ export class BattleScene extends SceneBase {
|
|||||||
* Used for switch out logic checks.
|
* Used for switch out logic checks.
|
||||||
* @param player - Whether to search the player (`true`) or enemy (`false`) party; default `true`
|
* @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.
|
* @returns An array containing the **INDICES** of all {@linkcode Pokemon} in reserve able to be switched into.
|
||||||
* @overload
|
|
||||||
*/
|
*/
|
||||||
public getBackupPartyMemberIndices(player: true): number[];
|
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;
|
* @param trainerSlot - The {@linkcode TrainerSlot | trainer slot} to check against for enemy trainers;
|
||||||
* used to verify ownership in multi battles
|
* used to verify ownership in multi battles
|
||||||
* @returns An array containing the **INDICES** of all {@linkcode Pokemon} in reserve able to be switched into.
|
* @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: false, trainerSlot: TrainerSlot): number[];
|
||||||
|
|
||||||
public getBackupPartyMemberIndices(player: boolean | Pokemon, trainerSlot?: number): 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.
|
// 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.
|
// 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(),
|
switchOutTarget.getFieldIndex(),
|
||||||
summonIndex,
|
summonIndex,
|
||||||
false,
|
false,
|
||||||
true,
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,6 +510,10 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
|
|
||||||
abstract initBattleInfo(): void;
|
abstract initBattleInfo(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether this Pokemon is currently partaking in battle on field.
|
||||||
|
* @returns Whether this Pokemon is on field.
|
||||||
|
*/
|
||||||
isOnField(): boolean {
|
isOnField(): boolean {
|
||||||
if (!globalScene) {
|
if (!globalScene) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -33,11 +33,7 @@ export class SwitchSummonPhase extends SummonPhase {
|
|||||||
super(fieldIndex, player);
|
super(fieldIndex, player);
|
||||||
|
|
||||||
this.switchType = switchType;
|
this.switchType = switchType;
|
||||||
// -1 = "use trainer switch logic"
|
this.slotIndex = slotIndex;
|
||||||
this.slotIndex =
|
|
||||||
slotIndex > -1
|
|
||||||
? slotIndex
|
|
||||||
: globalScene.currentBattle.trainer!.getNextSummonIndex(this.getTrainerSlotFromFieldIndex());
|
|
||||||
this.doReturn = doReturn;
|
this.doReturn = doReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,13 +44,20 @@ export class SwitchSummonPhase extends SummonPhase {
|
|||||||
super.start();
|
super.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
override preSummon(): void {
|
preSummon(): void {
|
||||||
const switchOutPokemon = this.getPokemon();
|
const switchOutPokemon = this.getPokemon();
|
||||||
|
|
||||||
if (!this.player && globalScene.currentBattle.trainer) {
|
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());
|
this.showEnemyTrainer(this.getTrainerSlotFromFieldIndex());
|
||||||
globalScene.pbTrayEnemy.showPbTray(globalScene.getEnemyParty());
|
globalScene.pbTrayEnemy.showPbTray(globalScene.getEnemyParty());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!this.doReturn ||
|
!this.doReturn ||
|
||||||
@ -120,7 +123,7 @@ export class SwitchSummonPhase extends SummonPhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switchAndSummon() {
|
switchAndSummon() {
|
||||||
const party = this.player ? this.getParty() : globalScene.getEnemyParty();
|
const party = this.getParty();
|
||||||
const switchedInPokemon: Pokemon | undefined = party[this.slotIndex];
|
const switchedInPokemon: Pokemon | undefined = party[this.slotIndex];
|
||||||
this.lastPokemon = this.getPokemon();
|
this.lastPokemon = this.getPokemon();
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { SubstituteTag } from "#app/data/battler-tags";
|
import { SubstituteTag } from "#app/data/battler-tags";
|
||||||
import { getPokemonNameWithAffix } from "#app/messages";
|
import { getPokemonNameWithAffix } from "#app/messages";
|
||||||
import { splitArray } from "#app/utils/array";
|
|
||||||
import { toDmgValue } from "#app/utils/common";
|
import { toDmgValue } from "#app/utils/common";
|
||||||
import { AbilityId } from "#enums/ability-id";
|
import { AbilityId } from "#enums/ability-id";
|
||||||
import { BattleType } from "#enums/battle-type";
|
import { BattleType } from "#enums/battle-type";
|
||||||
@ -14,6 +13,7 @@ import { SpeciesId } from "#enums/species-id";
|
|||||||
import { Stat } from "#enums/stat";
|
import { Stat } from "#enums/stat";
|
||||||
import { TrainerSlot } from "#enums/trainer-slot";
|
import { TrainerSlot } from "#enums/trainer-slot";
|
||||||
import { TrainerType } from "#enums/trainer-type";
|
import { TrainerType } from "#enums/trainer-type";
|
||||||
|
import { splitArray } from "#test/test-utils/array-utils";
|
||||||
import { GameManager } from "#test/test-utils/game-manager";
|
import { GameManager } from "#test/test-utils/game-manager";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
@ -42,7 +42,8 @@ describe("Moves - Switching Moves", () => {
|
|||||||
.enemySpecies(SpeciesId.WAILORD)
|
.enemySpecies(SpeciesId.WAILORD)
|
||||||
.enemyAbility(AbilityId.STURDY)
|
.enemyAbility(AbilityId.STURDY)
|
||||||
.enemyMoveset(MoveId.SPLASH)
|
.enemyMoveset(MoveId.SPLASH)
|
||||||
.criticalHits(false);
|
.criticalHits(false)
|
||||||
|
.randomTrainer({ trainerType: TrainerType.ACEROLA, alwaysDouble: false });
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Force Switch Moves", () => {
|
describe("Force Switch Moves", () => {
|
||||||
@ -57,7 +58,7 @@ describe("Moves - Switching Moves", () => {
|
|||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
const enemy = game.field.getEnemyPokemon();
|
||||||
game.move.use(move);
|
game.move.use(move);
|
||||||
await game.toNextTurn();
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
const newEnemy = game.field.getEnemyPokemon();
|
const newEnemy = game.field.getEnemyPokemon();
|
||||||
expect(newEnemy).not.toBe(enemy);
|
expect(newEnemy).not.toBe(enemy);
|
||||||
|
@ -24,7 +24,6 @@ export function splitArray<T>(
|
|||||||
predicate: (value: T, index: number, array: T[]) => unknown,
|
predicate: (value: T, index: number, array: T[]) => unknown,
|
||||||
thisArg?: unknown,
|
thisArg?: unknown,
|
||||||
): [matches: T[], nonMatches: T[]];
|
): [matches: T[], nonMatches: T[]];
|
||||||
|
|
||||||
export function splitArray<T>(
|
export function splitArray<T>(
|
||||||
arr: T[],
|
arr: T[],
|
||||||
predicate: (value: T, index: number, array: T[]) => unknown,
|
predicate: (value: T, index: number, array: T[]) => unknown,
|
Loading…
Reference in New Issue
Block a user