[P2] Syrup Bomb effect is removed when user leaves the field (#4606)
* Syrup Bomb's effect expires when the move user leaves the field * Add test * Remove check for the affected pokemon being switched out
This commit is contained in:
parent
6ad5ba972c
commit
5d0b361320
|
@ -2640,16 +2640,16 @@ export class ImprisonTag extends MoveRestrictionBattlerTag {
|
|||
/**
|
||||
* Battler Tag that applies the effects of Syrup Bomb to the target Pokemon.
|
||||
* For three turns, starting from the turn of hit, at the end of each turn, the target Pokemon's speed will decrease by 1.
|
||||
* The tag can also expire by taking the target Pokemon off the field.
|
||||
* The tag can also expire by taking the target Pokemon off the field, or the Pokemon that originally used the move.
|
||||
*/
|
||||
export class SyrupBombTag extends BattlerTag {
|
||||
constructor() {
|
||||
super(BattlerTagType.SYRUP_BOMB, BattlerTagLapseType.TURN_END, 3, Moves.SYRUP_BOMB);
|
||||
constructor(sourceId: number) {
|
||||
super(BattlerTagType.SYRUP_BOMB, BattlerTagLapseType.TURN_END, 3, Moves.SYRUP_BOMB, sourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the Syrup Bomb battler tag to the target Pokemon.
|
||||
* @param {Pokemon} pokemon the target Pokemon
|
||||
* @param pokemon - The target {@linkcode Pokemon}
|
||||
*/
|
||||
override onAdd(pokemon: Pokemon) {
|
||||
super.onAdd(pokemon);
|
||||
|
@ -2658,15 +2658,16 @@ export class SyrupBombTag extends BattlerTag {
|
|||
|
||||
/**
|
||||
* Applies the single-stage speed down to the target Pokemon and decrements the tag's turn count
|
||||
* @param {Pokemon} pokemon the target Pokemon
|
||||
* @param {BattlerTagLapseType} _lapseType
|
||||
* @returns `true` if the turnCount is still greater than 0 | `false` if the turnCount is 0 or the target Pokemon has been removed from the field
|
||||
* @param pokemon - The target {@linkcode Pokemon}
|
||||
* @param _lapseType - N/A
|
||||
* @returns `true` if the `turnCount` is still greater than `0`; `false` if the `turnCount` is `0` or the target or source Pokemon has been removed from the field
|
||||
*/
|
||||
override lapse(pokemon: Pokemon, _lapseType: BattlerTagLapseType): boolean {
|
||||
if (!pokemon.isActive(true)) {
|
||||
if (this.sourceId && !pokemon.scene.getPokemonById(this.sourceId)?.isActive(true)) {
|
||||
return false;
|
||||
}
|
||||
pokemon.scene.queueMessage(i18next.t("battlerTags:syrupBombLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); // Custom message in lieu of an animation in mainline
|
||||
// Custom message in lieu of an animation in mainline
|
||||
pokemon.scene.queueMessage(i18next.t("battlerTags:syrupBombLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }));
|
||||
pokemon.scene.unshiftPhase(new StatStageChangePhase(
|
||||
pokemon.scene, pokemon.getBattlerIndex(), true,
|
||||
[ Stat.SPD ], -1, true, false, true
|
||||
|
@ -2677,12 +2678,8 @@ export class SyrupBombTag extends BattlerTag {
|
|||
|
||||
/**
|
||||
* Retrieves a {@linkcode BattlerTag} based on the provided tag type, turn count, source move, and source ID.
|
||||
*
|
||||
* @param {BattlerTagType} tagType the type of the {@linkcode BattlerTagType}.
|
||||
* @param turnCount the turn count.
|
||||
* @param {Moves} sourceMove the source {@linkcode Moves}.
|
||||
* @param sourceId the source ID.
|
||||
* @returns {BattlerTag} the corresponding {@linkcode BattlerTag} object.
|
||||
* @param sourceId - The ID of the pokemon adding the tag
|
||||
* @returns The corresponding {@linkcode BattlerTag} object.
|
||||
*/
|
||||
export function getBattlerTag(tagType: BattlerTagType, turnCount: number, sourceMove: Moves, sourceId: number): BattlerTag {
|
||||
switch (tagType) {
|
||||
|
@ -2851,7 +2848,7 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: number, source
|
|||
case BattlerTagType.IMPRISON:
|
||||
return new ImprisonTag(sourceId);
|
||||
case BattlerTagType.SYRUP_BOMB:
|
||||
return new SyrupBombTag();
|
||||
return new SyrupBombTag(sourceId);
|
||||
case BattlerTagType.NONE:
|
||||
default:
|
||||
return new BattlerTag(tagType, BattlerTagLapseType.CUSTOM, turnCount, sourceMove, sourceId);
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { allMoves } from "#app/data/move";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
|
@ -7,7 +6,7 @@ import { Stat } from "#enums/stat";
|
|||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
|
||||
describe("Moves - SYRUP BOMB", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
|
@ -26,20 +25,21 @@ describe("Moves - SYRUP BOMB", () => {
|
|||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.starterSpecies(Species.MAGIKARP)
|
||||
.battleType("single")
|
||||
.enemySpecies(Species.SNORLAX)
|
||||
.enemyAbility(Abilities.BALL_FETCH)
|
||||
.ability(Abilities.BALL_FETCH)
|
||||
.startingLevel(30)
|
||||
.enemyLevel(100)
|
||||
.moveset([ Moves.SYRUP_BOMB, Moves.SPLASH ])
|
||||
.enemyMoveset(Moves.SPLASH);
|
||||
vi.spyOn(allMoves[Moves.SYRUP_BOMB], "accuracy", "get").mockReturnValue(100);
|
||||
});
|
||||
|
||||
//Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/syrup_bomb_(move)
|
||||
|
||||
it("decreases the target Pokemon's speed stat once per turn for 3 turns",
|
||||
async () => {
|
||||
await game.startBattle([ Species.MAGIKARP ]);
|
||||
await game.classicMode.startBattle([ Species.MAGIKARP ]);
|
||||
|
||||
const targetPokemon = game.scene.getEnemyPokemon()!;
|
||||
expect(targetPokemon.getStatStage(Stat.SPD)).toBe(0);
|
||||
|
@ -66,7 +66,7 @@ describe("Moves - SYRUP BOMB", () => {
|
|||
it("does not affect Pokemon with the ability Bulletproof",
|
||||
async () => {
|
||||
game.override.enemyAbility(Abilities.BULLETPROOF);
|
||||
await game.startBattle([ Species.MAGIKARP ]);
|
||||
await game.classicMode.startBattle([ Species.MAGIKARP ]);
|
||||
|
||||
const targetPokemon = game.scene.getEnemyPokemon()!;
|
||||
|
||||
|
@ -79,4 +79,18 @@ describe("Moves - SYRUP BOMB", () => {
|
|||
expect(targetPokemon.getStatStage(Stat.SPD)).toBe(0);
|
||||
}
|
||||
);
|
||||
|
||||
it("stops lowering the target's speed if the user leaves the field", async () => {
|
||||
await game.classicMode.startBattle([ Species.FEEBAS, Species.MILOTIC ]);
|
||||
|
||||
game.move.select(Moves.SYRUP_BOMB);
|
||||
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||
await game.move.forceHit();
|
||||
await game.toNextTurn();
|
||||
|
||||
game.doSwitchPokemon(1);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(game.scene.getEnemyPokemon()!.getStatStage(Stat.SPD)).toBe(-1);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue