This commit is contained in:
PrabbyDD 2024-12-20 23:41:58 -08:00 committed by GitHub
commit 0c7c9f01ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 423 additions and 9 deletions

View File

@ -83,6 +83,9 @@ export default class Battle {
public battleSeed: string = Utils.randomString(16, true);
private battleSeedState: string | null = null;
public moneyScattered: number = 0;
/** Primarily for double battles, keeps track of last enemy and player pokemon that triggered its ability or used a move */
public lastEnemyInvolved: number;
public lastPlayerInvolved: number;
public lastUsedPokeball: PokeballType | null = null;
/** The number of times a Pokemon on the player's side has fainted this battle */
public playerFaints: number = 0;

View File

@ -2744,6 +2744,44 @@ export class PreStatStageChangeAbAttr extends AbAttr {
}
}
/**
* Reflect all {@linkcode BattleStat} reductions caused by other Pokémon's moves and Abilities.
* Currently only applies to Mirror Armor.
*/
export class ReflectStatStageChangeAbAttr extends PreStatStageChangeAbAttr {
/** {@linkcode BattleStat} to reflect */
private reflectedStat? : BattleStat;
/**
* Apply the {@linkcode ReflectStatStageChangeAbAttr} to an interaction
* @param _pokemon The user pokemon
* @param _passive N/A
* @param simulated `true` if the ability is being simulated by the AI
* @param stat the {@linkcode BattleStat} being affected
* @param cancelled The {@linkcode Utils.BooleanHolder} that will be set to true due to reflection
* @param args
* @returns true because it reflects any stat being lowered
*/
applyPreStatStageChange(_pokemon: Pokemon, _passive: boolean, simulated: boolean, stat: BattleStat, cancelled: Utils.BooleanHolder, args: any[]): boolean {
const attacker: Pokemon = args[0];
const stages = args[1];
this.reflectedStat = stat;
if (!simulated) {
attacker.scene.unshiftPhase(new StatStageChangePhase(attacker.scene, attacker.getBattlerIndex(), false, [ stat ], stages, true, false, true, null, true));
}
cancelled.value = true;
return true;
}
getTriggerMessage(pokemon: Pokemon, abilityName: string, ..._args: any[]): string {
return i18next.t("abilityTriggers:protectStat", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName,
statName: this.reflectedStat ? i18next.t(getStatKey(this.reflectedStat)) : i18next.t("battle:stats")
});
}
}
/**
* Protect one or all {@linkcode BattleStat} from reductions caused by other Pokémon's moves and Abilities
*/
@ -6109,8 +6147,8 @@ export function initAbilities() {
new Ability(Abilities.PROPELLER_TAIL, 8)
.attr(BlockRedirectAbAttr),
new Ability(Abilities.MIRROR_ARMOR, 8)
.ignorable()
.unimplemented(),
.attr(ReflectStatStageChangeAbAttr)
.ignorable(),
/**
* Right now, the logic is attached to Surf and Dive moves. Ideally, the post-defend/hit should be an
* ability attribute but the current implementation of move effects for BattlerTag does not support this- in the case

View File

@ -911,7 +911,7 @@ class StickyWebTag extends ArenaTrapTag {
if (!cancelled.value) {
pokemon.scene.queueMessage(i18next.t("arenaTag:stickyWebActivateTrap", { pokemonName: pokemon.getNameToRender() }));
const stages = new NumberHolder(-1);
pokemon.scene.unshiftPhase(new StatStageChangePhase(pokemon.scene, pokemon.getBattlerIndex(), false, [ Stat.SPD ], stages.value));
pokemon.scene.unshiftPhase(new StatStageChangePhase(pokemon.scene, pokemon.getBattlerIndex(), false, [ Stat.SPD ], stages.value, true, false, true, null, false, true));
return true;
}
}

View File

@ -8733,8 +8733,8 @@ export function initMoves() {
new StatusMove(Moves.WILL_O_WISP, Type.FIRE, 85, 15, -1, 0, 3)
.attr(StatusEffectAttr, StatusEffect.BURN),
new StatusMove(Moves.MEMENTO, Type.DARK, 100, 10, -1, 0, 3)
.attr(SacrificialAttrOnHit)
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK ], -2),
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK ], -2)
.attr(SacrificialAttrOnHit),
new AttackMove(Moves.FACADE, Type.NORMAL, MoveCategory.PHYSICAL, 70, 100, 20, -1, 0, 3)
.attr(MovePowerMultiplierAttr, (user, target, move) => user.status
&& (user.status.effect === StatusEffect.BURN || user.status.effect === StatusEffect.POISON || user.status.effect === StatusEffect.TOXIC || user.status.effect === StatusEffect.PARALYSIS) ? 2 : 1)

View File

@ -92,6 +92,13 @@ export class MoveEffectPhase extends PokemonPhase {
return super.end();
}
/** If an enemy used this move, set this as last enemy that used move or ability */
if (!user.isPlayer()) {
this.scene.currentBattle.lastEnemyInvolved = this.fieldIndex;
} else {
this.scene.currentBattle.lastPlayerInvolved = this.fieldIndex;
}
const isDelayedAttack = this.move.getMove().hasAttr(DelayedAttackAttr);
/** If the user was somehow removed from the field and it's not a delayed attack, end this phase */
if (!user.isOnField()) {

View File

@ -17,6 +17,14 @@ export class ShowAbilityPhase extends PokemonPhase {
const pokemon = this.getPokemon();
if (pokemon) {
if (!pokemon.isPlayer()) {
/** If its an enemy pokemon, list it as last enemy to use ability or move */
this.scene.currentBattle.lastEnemyInvolved = pokemon.getBattlerIndex() % 2;
} else {
this.scene.currentBattle.lastPlayerInvolved = pokemon.getBattlerIndex() % 2;
}
this.scene.abilityBar.showAbility(pokemon, this.passive);
if (pokemon?.battleData) {

View File

@ -1,7 +1,7 @@
import { BattlerIndex } from "#app/battle";
import BattleScene from "#app/battle-scene";
import { applyAbAttrs, applyPostStatStageChangeAbAttrs, applyPreStatStageChangeAbAttrs, PostStatStageChangeAbAttr, ProtectStatAbAttr, StatStageChangeCopyAbAttr, StatStageChangeMultiplierAbAttr } from "#app/data/ability";
import { ArenaTagSide, MistTag } from "#app/data/arena-tag";
import { applyAbAttrs, applyPostStatStageChangeAbAttrs, applyPreStatStageChangeAbAttrs, PostStatStageChangeAbAttr, ProtectStatAbAttr, ReflectStatStageChangeAbAttr, StatStageChangeCopyAbAttr, StatStageChangeMultiplierAbAttr } from "#app/data/ability";
import { ArenaTag, ArenaTagSide, MistTag } from "#app/data/arena-tag";
import Pokemon from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages";
import { ResetNegativeStatStageModifier } from "#app/modifier/modifier";
@ -10,6 +10,8 @@ import { NumberHolder, BooleanHolder } from "#app/utils";
import i18next from "i18next";
import { PokemonPhase } from "./pokemon-phase";
import { Stat, type BattleStat, getStatKey, getStatStageChangeDescriptionKey } from "#enums/stat";
import { OctolockTag } from "#app/data/battler-tags";
import { ArenaTagType } from "#app/enums/arena-tag-type";
export type StatStageChangeCallback = (target: Pokemon | null, changed: BattleStat[], relativeChanges: number[]) => void;
@ -21,9 +23,11 @@ export class StatStageChangePhase extends PokemonPhase {
private ignoreAbilities: boolean;
private canBeCopied: boolean;
private onChange: StatStageChangeCallback | null;
private comingFromMirrorArmorUser: boolean;
private comingFromStickyWeb: boolean;
constructor(scene: BattleScene, battlerIndex: BattlerIndex, selfTarget: boolean, stats: BattleStat[], stages: integer, showMessage: boolean = true, ignoreAbilities: boolean = false, canBeCopied: boolean = true, onChange: StatStageChangeCallback | null = null) {
constructor(scene: BattleScene, battlerIndex: BattlerIndex, selfTarget: boolean, stats: BattleStat[], stages: integer, showMessage: boolean = true, ignoreAbilities: boolean = false, canBeCopied: boolean = true, onChange: StatStageChangeCallback | null = null, comingFromMirrorArmorUser: boolean = false, comingFromStickyWeb: boolean = false) {
super(scene, battlerIndex);
this.selfTarget = selfTarget;
@ -33,6 +37,8 @@ export class StatStageChangePhase extends PokemonPhase {
this.ignoreAbilities = ignoreAbilities;
this.canBeCopied = canBeCopied;
this.onChange = onChange;
this.comingFromMirrorArmorUser = comingFromMirrorArmorUser;
this.comingFromStickyWeb = comingFromStickyWeb;
}
start() {
@ -41,12 +47,44 @@ export class StatStageChangePhase extends PokemonPhase {
if (this.stats.length > 1) {
for (let i = 0; i < this.stats.length; i++) {
const stat = [ this.stats[i] ];
this.scene.unshiftPhase(new StatStageChangePhase(this.scene, this.battlerIndex, this.selfTarget, stat, this.stages, this.showMessage, this.ignoreAbilities, this.canBeCopied, this.onChange));
this.scene.unshiftPhase(new StatStageChangePhase(this.scene, this.battlerIndex, this.selfTarget, stat, this.stages, this.showMessage, this.ignoreAbilities, this.canBeCopied, this.onChange, this.comingFromMirrorArmorUser));
}
return this.end();
}
const pokemon = this.getPokemon();
let opponentPokemon: Pokemon | undefined;
/** Gets the position of last enemy or player pokemon that used ability or move, primarily for double battles involving Mirror Armor */
if (pokemon.isPlayer()) {
/** If this SSCP is not from sticky web, then we find the opponent pokemon that last did something */
if (!this.comingFromStickyWeb) {
opponentPokemon = this.scene.getEnemyField()[this.scene.currentBattle.lastEnemyInvolved];
} else {
/** If this SSCP is from sticky web, then check if pokemon that last sucessfully used sticky web is on field */
const stickyTagID = this.scene.arena.findTagsOnSide(
(t: ArenaTag) => t.tagType === ArenaTagType.STICKY_WEB,
ArenaTagSide.PLAYER)[0].sourceId;
this.scene.getEnemyField().forEach((e) => {
if (e.id === stickyTagID) {
opponentPokemon = e;
}
});
}
} else {
if (!this.comingFromStickyWeb) {
opponentPokemon = this.scene.getPlayerField()[this.scene.currentBattle.lastPlayerInvolved];
} else {
const stickyTagID = this.scene.arena.findTagsOnSide(
(t: ArenaTag) => t.tagType === ArenaTagType.STICKY_WEB,
ArenaTagSide.ENEMY)[0].sourceId;
this.scene.getPlayerField().forEach((e) => {
if (e.id === stickyTagID) {
opponentPokemon = e;
}
});
}
}
if (!pokemon.isActive(true)) {
return this.end();
@ -70,6 +108,11 @@ export class StatStageChangePhase extends PokemonPhase {
if (!cancelled.value && !this.selfTarget && stages.value < 0) {
applyPreStatStageChangeAbAttrs(ProtectStatAbAttr, pokemon, stat, cancelled, simulate);
/** Potential stat reflection due to Mirror Armor, does not apply to Octolock end of turn effect */
if (opponentPokemon !== undefined && !pokemon.findTag(t => t instanceof OctolockTag) && !this.comingFromMirrorArmorUser) {
applyPreStatStageChangeAbAttrs(ReflectStatStageChangeAbAttr, pokemon, stat, cancelled, simulate, opponentPokemon, this.stages);
}
}
// If one stat stage decrease is cancelled, simulate the rest of the applications

View File

@ -0,0 +1,315 @@
import { Stat } from "#enums/stat";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { BattlerIndex } from "#app/battle";
// TODO: When Magic Bounce is implemented, make a test for its interaction with mirror guard, use screech
describe("Ability - Mirror Armor", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override.battleType("single")
.enemySpecies(Species.RATTATA)
.enemyMoveset([ Moves.SPLASH, Moves.STICKY_WEB, Moves.TICKLE, Moves.OCTOLOCK ])
.enemyAbility(Abilities.BALL_FETCH)
.startingLevel(2000)
.moveset([ Moves.SPLASH, Moves.STICKY_WEB, Moves.TICKLE, Moves.OCTOLOCK ])
.ability(Abilities.BALL_FETCH);
});
it("Player side + single battle Intimidate - opponent loses stats", async () => {
game.override.ability(Abilities.MIRROR_ARMOR);
game.override.enemyAbility(Abilities.INTIMIDATE);
await game.classicMode.startBattle([ Species.BULBASAUR ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const userPokemon = game.scene.getPlayerPokemon()!;
// Enemy has intimidate, enemy should lose -1 atk
game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER);
await game.toNextTurn();
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(-1);
expect(userPokemon.getStatStage(Stat.ATK)).toBe(0);
}, 20000);
it("Enemy side + single battle Intimidate - player loses stats", async () => {
game.override.enemyAbility(Abilities.MIRROR_ARMOR);
game.override.ability(Abilities.INTIMIDATE);
await game.classicMode.startBattle([ Species.BULBASAUR ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const userPokemon = game.scene.getPlayerPokemon()!;
// Enemy has intimidate, enemy should lose -1 atk
game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER);
await game.toNextTurn();
expect(userPokemon.getStatStage(Stat.ATK)).toBe(-1);
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0);
}, 20000);
it("Player side + double battle Intimidate - opponents each lose -2 atk", async () => {
game.override.battleType("double");
game.override.ability(Abilities.MIRROR_ARMOR);
game.override.enemyAbility(Abilities.INTIMIDATE);
await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER ]);
const [ enemy1, enemy2 ] = game.scene.getEnemyField();
const [ player1, player2 ] = game.scene.getPlayerField();
// Enemy has intimidate, enemy should lose -2 atk each
game.move.select(Moves.SPLASH);
game.move.select(Moves.SPLASH, 1);
await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER);
await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER_2);
await game.toNextTurn();
expect(enemy1.getStatStage(Stat.ATK)).toBe(-2);
expect(enemy2.getStatStage(Stat.ATK)).toBe(-2);
expect(player1.getStatStage(Stat.ATK)).toBe(0);
expect(player2.getStatStage(Stat.ATK)).toBe(0);
}, 20000);
it("Enemy side + double battle Intimidate - players each lose -2 atk", async () => {
game.override.battleType("double");
game.override.enemyAbility(Abilities.MIRROR_ARMOR);
game.override.ability(Abilities.INTIMIDATE);
await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER ]);
const [ enemy1, enemy2 ] = game.scene.getEnemyField();
const [ player1, player2 ] = game.scene.getPlayerField();
// Enemy has intimidate, enemy should lose -1 atk
game.move.select(Moves.SPLASH);
game.move.select(Moves.SPLASH, 1);
await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER);
await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER_2);
await game.toNextTurn();
expect(enemy1.getStatStage(Stat.ATK)).toBe(0);
expect(enemy2.getStatStage(Stat.ATK)).toBe(0);
expect(player1.getStatStage(Stat.ATK)).toBe(-2);
expect(player2.getStatStage(Stat.ATK)).toBe(-2);
}, 20000);
it("Player side + single battle Intimidate + Tickle - opponent loses stats", async () => {
game.override.ability(Abilities.MIRROR_ARMOR);
game.override.enemyAbility(Abilities.INTIMIDATE);
await game.classicMode.startBattle([ Species.BULBASAUR ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const userPokemon = game.scene.getPlayerPokemon()!;
// Enemy has intimidate and uses tickle, enemy receives -2 atk and -1 defense
game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.TICKLE, BattlerIndex.PLAYER);
await game.toNextTurn();
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(-1);
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(-2);
expect(userPokemon.getStatStage(Stat.ATK)).toBe(0);
expect(userPokemon.getStatStage(Stat.DEF)).toBe(0);
}, 20000);
it("Player side + double battle Intimidate + Tickle - opponents each lose -3 atk, -1 def", async () => {
game.override.battleType("double");
game.override.ability(Abilities.MIRROR_ARMOR);
game.override.enemyAbility(Abilities.INTIMIDATE);
await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER ]);
const [ enemy1, enemy2 ] = game.scene.getEnemyField();
const [ player1, player2 ] = game.scene.getPlayerField();
game.move.select(Moves.SPLASH);
game.move.select(Moves.SPLASH, 1);
await game.forceEnemyMove(Moves.TICKLE, BattlerIndex.PLAYER);
await game.forceEnemyMove(Moves.TICKLE, BattlerIndex.PLAYER_2);
await game.toNextTurn();
expect(player1.getStatStage(Stat.ATK)).toBe(0);
expect(player1.getStatStage(Stat.DEF)).toBe(0);
expect(player2.getStatStage(Stat.ATK)).toBe(0);
expect(player2.getStatStage(Stat.DEF)).toBe(0);
expect(enemy1.getStatStage(Stat.ATK)).toBe(-3);
expect(enemy1.getStatStage(Stat.DEF)).toBe(-1);
expect(enemy2.getStatStage(Stat.ATK)).toBe(-3);
expect(enemy2.getStatStage(Stat.DEF)).toBe(-1);
}, 20000);
it("Enemy side + single battle Intimidate + Tickle - player loses stats", async () => {
game.override.enemyAbility(Abilities.MIRROR_ARMOR);
game.override.ability(Abilities.INTIMIDATE);
await game.classicMode.startBattle([ Species.BULBASAUR ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const userPokemon = game.scene.getPlayerPokemon()!;
// Enemy has intimidate and uses tickle, enemy receives -2 atk and -1 defense
game.move.select(Moves.TICKLE);
await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER);
await game.toNextTurn();
expect(userPokemon.getStatStage(Stat.DEF)).toBe(-1);
expect(userPokemon.getStatStage(Stat.ATK)).toBe(-2);
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0);
}, 20000);
it("Player side + single battle Intimidate + oppoenent has white smoke - no one loses stats", async () => {
game.override.enemyAbility(Abilities.WHITE_SMOKE);
game.override.ability(Abilities.MIRROR_ARMOR);
await game.classicMode.startBattle([ Species.BULBASAUR ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const userPokemon = game.scene.getPlayerPokemon()!;
// Enemy has intimidate and uses tickle, enemy has white smoke, no one loses stats
game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.TICKLE, BattlerIndex.PLAYER);
await game.toNextTurn();
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0);
expect(userPokemon.getStatStage(Stat.ATK)).toBe(0);
expect(userPokemon.getStatStage(Stat.DEF)).toBe(0);
}, 20000);
it("Enemy side + single battle Intimidate + player has white smoke - no one loses stats", async () => {
game.override.ability(Abilities.WHITE_SMOKE);
game.override.enemyAbility(Abilities.MIRROR_ARMOR);
await game.classicMode.startBattle([ Species.BULBASAUR ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const userPokemon = game.scene.getPlayerPokemon()!;
// Enemy has intimidate and uses tickle, enemy has white smoke, no one loses stats
game.move.select(Moves.TICKLE);
await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER);
await game.toNextTurn();
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0);
expect(userPokemon.getStatStage(Stat.ATK)).toBe(0);
expect(userPokemon.getStatStage(Stat.DEF)).toBe(0);
}, 20000);
it("Player side + single battle + opponent uses octolock - does not interact with mirror armor, player loses stats", async () => {
game.override.ability(Abilities.MIRROR_ARMOR);
await game.classicMode.startBattle([ Species.BULBASAUR ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const userPokemon = game.scene.getPlayerPokemon()!;
// Enemy uses octolock, player loses stats at end of turn
game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.OCTOLOCK, BattlerIndex.PLAYER);
await game.toNextTurn();
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(0);
expect(userPokemon.getStatStage(Stat.DEF)).toBe(-1);
expect(userPokemon.getStatStage(Stat.SPDEF)).toBe(-1);
}, 20000);
it("Enemy side + single battle + player uses octolock - does not interact with mirror armor, opponent loses stats", async () => {
game.override.enemyAbility(Abilities.MIRROR_ARMOR);
await game.classicMode.startBattle([ Species.BULBASAUR ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const userPokemon = game.scene.getPlayerPokemon()!;
// Player uses octolock, enemy loses stats at end of turn
game.move.select(Moves.OCTOLOCK);
await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER);
await game.toNextTurn();
expect(userPokemon.getStatStage(Stat.DEF)).toBe(0);
expect(userPokemon.getStatStage(Stat.SPDEF)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(-1);
expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(-1);
}, 20000);
it("Both sides have mirror armor - does not loop, player loses attack", async () => {
game.override.enemyAbility(Abilities.MIRROR_ARMOR);
game.override.ability(Abilities.MIRROR_ARMOR);
game.override.ability(Abilities.INTIMIDATE);
await game.classicMode.startBattle([ Species.BULBASAUR ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const userPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER);
await game.toNextTurn();
expect(userPokemon.getStatStage(Stat.ATK)).toBe(-1);
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0);
}, 20000);
it("Single battle + sticky web applied player side - player switches out and enemy should lose -1 speed", async () => {
game.override.ability(Abilities.MIRROR_ARMOR);
await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const userPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.STICKY_WEB, BattlerIndex.PLAYER);
await game.toNextTurn();
game.doSwitchPokemon(1);
await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER);
await game.toNextTurn();
expect(userPokemon.getStatStage(Stat.SPD)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.SPD)).toBe(-1);
}, 20000);
it("Double battle + sticky web applied player side - player switches out and enemy 1 should lose -1 speed", async () => {
game.override.battleType("double");
game.override.ability(Abilities.MIRROR_ARMOR);
await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]);
const [ enemy1, enemy2 ] = game.scene.getEnemyField();
const [ player1, player2 ] = game.scene.getPlayerField();
game.move.select(Moves.SPLASH);
game.move.select(Moves.SPLASH, 1);
await game.forceEnemyMove(Moves.STICKY_WEB, BattlerIndex.PLAYER);
await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER_2);
await game.toNextTurn();
game.doSwitchPokemon(2);
game.move.select(Moves.SPLASH, 1);
await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER);
await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER_2);
await game.toNextTurn();
expect(enemy1.getStatStage(Stat.SPD)).toBe(-1);
expect(enemy2.getStatStage(Stat.SPD)).toBe(0);
expect(player1.getStatStage(Stat.SPD)).toBe(0);
expect(player2.getStatStage(Stat.SPD)).toBe(0);
}, 20000);
});