Fixup tests and broken assumptions
This commit is contained in:
parent
d4e8374ae9
commit
3a66e04171
|
@ -1444,7 +1444,6 @@ export default class BattleScene extends SceneBase {
|
|||
|
||||
this.executeWithSeedOffset(
|
||||
() => {
|
||||
console.log(`Starting a new battle with ${BattleType[newBattleType]} and double: ${newDouble}`);
|
||||
this.currentBattle = new Battle(this.gameMode, newWaveIndex, newBattleType, newTrainer, newDouble);
|
||||
},
|
||||
newWaveIndex << 3,
|
||||
|
|
|
@ -47,6 +47,7 @@ import { PokemonAnimType } from "#enums/pokemon-anim-type";
|
|||
import { StatusEffect } from "#enums/status-effect";
|
||||
import { WeatherType } from "#enums/weather-type";
|
||||
import { PokemonTransformPhase } from "#app/phases/pokemon-transform-phase";
|
||||
import { TrainerVariant } from "#app/field/trainer";
|
||||
|
||||
export class Ability implements Localizable {
|
||||
public id: Abilities;
|
||||
|
@ -5573,8 +5574,8 @@ class ForceSwitchOutHelper {
|
|||
|
||||
const party = player ? globalScene.getPlayerParty() : globalScene.getEnemyParty();
|
||||
return (!player && globalScene.currentBattle.battleType === BattleType.WILD)
|
||||
|| party.filter(p => p.isAllowedInBattle()
|
||||
&& (player || (p as EnemyPokemon).trainerSlot === (switchOutTarget as EnemyPokemon).trainerSlot)).length > globalScene.currentBattle.getBattlerCount();
|
||||
|| party.filter(p => p.isAllowedInBattle() && !p.isOnField()
|
||||
&& (player || (p as EnemyPokemon).trainerSlot === (switchOutTarget as EnemyPokemon).trainerSlot)).length > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6233,10 +6233,8 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
// Check if the move category is not STATUS or if the switch out condition is not met
|
||||
if (!this.getSwitchOutCondition()(user, target, move)) {
|
||||
console.log("=========== Switch out condition was false!===========");
|
||||
return false;
|
||||
}
|
||||
console.log("=========== Switch out condition was true!===========");
|
||||
|
||||
/** The {@linkcode Pokemon} to be switched out with this effect */
|
||||
const switchOutTarget = this.selfSwitch ? user : target;
|
||||
|
@ -6379,7 +6377,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||
}
|
||||
|
||||
getCondition(): MoveConditionFunc {
|
||||
return (user, target, move) => (move.category !== MoveCategory.STATUS || this.getSwitchOutCondition()(user, target, move));
|
||||
return (user, target, move) => (move.category !== MoveCategory.STATUS || this.getSwitchOutCondition(true)(user, target, move));
|
||||
}
|
||||
|
||||
getFailedText(_user: Pokemon, target: Pokemon, _move: Move): string | undefined {
|
||||
|
@ -6390,7 +6388,13 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||
}
|
||||
}
|
||||
|
||||
getSwitchOutCondition(): MoveConditionFunc {
|
||||
|
||||
/**
|
||||
* Check if the switch out conditions are met.
|
||||
*
|
||||
* @param preliminary - Whether to check for failure conditions that occur before the hit check (defaults to false)
|
||||
*/
|
||||
getSwitchOutCondition(preliminary = false): MoveConditionFunc {
|
||||
return (user, target, move) => {
|
||||
const switchOutTarget = (this.selfSwitch ? user : target);
|
||||
const player = switchOutTarget instanceof PlayerPokemon;
|
||||
|
@ -6418,22 +6422,21 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||
}
|
||||
}
|
||||
|
||||
if (preliminary) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!player && globalScene.currentBattle.battleType === BattleType.WILD) {
|
||||
// Prevent wild pokemon fr
|
||||
return !(this.isBatonPass()
|
||||
// Don't allow boss waves of wild pokemon to flee
|
||||
&& globalScene.currentBattle.waveIndex % 10 === 0
|
||||
// Don't allow wild mons to flee with U-turn et al.
|
||||
&& this.selfSwitch && move.category !== MoveCategory.STATUS)
|
||||
// wild pokemon cannot switch out with baton pass.
|
||||
return !this.isBatonPass()
|
||||
&& globalScene.currentBattle.waveIndex % 10 !== 0
|
||||
// Don't allow wild mons to flee with U-turn et al.
|
||||
&& !(this.selfSwitch && MoveCategory.STATUS !== move.category);
|
||||
}
|
||||
|
||||
const party = player ? globalScene.getPlayerParty() : globalScene.getEnemyParty();
|
||||
// Determine if this is a
|
||||
const currentBattle = globalScene.currentBattle;
|
||||
// If the trainer battle is a partner, then they can switch out as long as they have at least one pokemon in the back
|
||||
const MIN_BATTLE_COUNT = (!player && currentBattle.trainer?.variant === TrainerVariant.DOUBLE) ? 1 : currentBattle.getBattlerCount();
|
||||
return party.filter(p => p.isAllowedInBattle()
|
||||
&& (player || (p as EnemyPokemon).trainerSlot === (switchOutTarget as EnemyPokemon).trainerSlot)).length > MIN_BATTLE_COUNT;
|
||||
return party.filter(p => p.isAllowedInBattle() && !p.isOnField()
|
||||
&& (player || (p as EnemyPokemon).trainerSlot === (switchOutTarget as EnemyPokemon).trainerSlot)).length > 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -180,12 +180,15 @@ describe("Moves - Whirlwind", () => {
|
|||
|
||||
game.move.select(Moves.SPLASH);
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.forceEnemyMove(Moves.LUNAR_DANCE);
|
||||
await game.forceEnemyMove(Moves.MEMENTO);
|
||||
await game.forceEnemyMove(Moves.SPLASH);
|
||||
await game.toNextTurn();
|
||||
|
||||
// Get the enemy pokemon id so we can check if is the same after switch.
|
||||
const enemy_id = game.scene.getEnemyPokemon()!.id;
|
||||
|
||||
// Hit the enemy that fainted with whirlwind.
|
||||
game.move.select(Moves.WHIRLWIND, 0, BattlerIndex.ENEMY_2);
|
||||
game.move.select(Moves.WHIRLWIND, 0, BattlerIndex.ENEMY);
|
||||
game.move.select(Moves.SPLASH, 1);
|
||||
|
||||
await game.forceEnemyMove(Moves.SPLASH);
|
||||
|
@ -194,6 +197,22 @@ describe("Moves - Whirlwind", () => {
|
|||
await game.toNextTurn();
|
||||
|
||||
// Expect the enemy pokemon to not have switched out.
|
||||
expect(game.scene.getPlayerPokemon()!.getLastXMoves(1)[0].result).toBe(MoveResult.FAIL);
|
||||
expect(game.scene.getEnemyPokemon()!.id).toBe(enemy_id);
|
||||
});
|
||||
|
||||
it("should force a wild pokemon to flee", async () => {
|
||||
game.override
|
||||
.battleType(BattleType.WILD)
|
||||
.moveset([Moves.WHIRLWIND, Moves.SPLASH])
|
||||
.enemyMoveset(Moves.SPLASH)
|
||||
.ability(Abilities.BALL_FETCH);
|
||||
await game.classicMode.startBattle([Species.MAGIKARP]);
|
||||
|
||||
const user = game.scene.getPlayerPokemon()!;
|
||||
|
||||
game.move.select(Moves.WHIRLWIND);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
expect(user.getLastXMoves(1)[0].result).toBe(MoveResult.SUCCESS);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue