Syrup Bomb + Tests

This commit is contained in:
frutescens 2024-09-25 18:46:44 -07:00
parent a6a61b2984
commit 4f0af296b1
5 changed files with 107 additions and 4 deletions

View File

@ -2589,6 +2589,29 @@ export class ImprisonTag extends MoveRestrictionBattlerTag {
}
}
export class SyrupBombTag extends BattlerTag {
constructor() {
super(BattlerTagType.SYRUP_BOMB, BattlerTagLapseType.TURN_END, 3, Moves.SYRUP_BOMB);
}
override onAdd(pokemon: Pokemon) {
if (Utils.isNullOrUndefined(pokemon.getTag(BattlerTagType.SYRUP_BOMB))) {
super.onAdd(pokemon);
pokemon.scene.queueMessage(i18next.t("battlerTags:syrupBombOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }));
}
}
override lapse(pokemon: Pokemon, _lapseType: BattlerTagLapseType): boolean {
if (!pokemon.isActive(true)) {
return false;
}
pokemon.scene.unshiftPhase(new StatStageChangePhase(
pokemon.scene, pokemon.getBattlerIndex(), true,
[Stat.SPD], -1, true, false, true
));
return --this.turnCount > 0;
}
}
/**
* Retrieves a {@linkcode BattlerTag} based on the provided tag type, turn count, source move, and source ID.
@ -2763,6 +2786,8 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: number, source
return new TauntTag();
case BattlerTagType.IMPRISON:
return new ImprisonTag(sourceId);
case BattlerTagType.SYRUP_BOMB:
return new SyrupBombTag();
case BattlerTagType.NONE:
default:
return new BattlerTag(tagType, BattlerTagLapseType.CUSTOM, turnCount, sourceMove, sourceId);

View File

@ -9584,9 +9584,8 @@ export function initMoves() {
.target(MoveTarget.ALL_NEAR_ENEMIES)
.triageMove(),
new AttackMove(Moves.SYRUP_BOMB, Type.GRASS, MoveCategory.SPECIAL, 60, 85, 10, -1, 0, 9)
.attr(StatStageChangeAttr, [ Stat.SPD ], -1) //Temporary
.ballBombMove()
.partial(),
.attr(AddBattlerTagAttr, BattlerTagType.SYRUP_BOMB, false, false, 3)
.ballBombMove(),
new AttackMove(Moves.IVY_CUDGEL, Type.GRASS, MoveCategory.PHYSICAL, 100, 100, 10, -1, 0, 9)
.attr(IvyCudgelTypeAttr)
.attr(HighCritAttr)

View File

@ -85,4 +85,5 @@ export enum BattlerTagType {
TORMENT = "TORMENT",
TAUNT = "TAUNT",
IMPRISON = "IMPRISON",
SYRUP_BOMB = "SYRUP_BOMB"
}

View File

@ -78,5 +78,6 @@
"tormentOnAdd": "{{pokemonNameWithAffix}} was subjected to torment!",
"tauntOnAdd": "{{pokemonNameWithAffix}} fell for the taunt!",
"imprisonOnAdd": "{{pokemonNameWithAffix}} sealed the opponents move(s)!",
"autotomizeOnAdd": "{{pokemonNameWithAffix}} became nimble!"
"autotomizeOnAdd": "{{pokemonNameWithAffix}} became nimble!",
"syrupBombOnAdd": "{{pokemonNameWithAffix}} got covered in sticky, candy syrup!"
}

View File

@ -0,0 +1,77 @@
import { allMoves } from "#app/data/move";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { Abilities } from "#enums/abilities";
import { BattlerTagType } from "#enums/battler-tag-types";
import { Stat } from "#enums/stat";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
describe("Moves - SYRUP BOMB", () => {
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
.starterSpecies(Species.MAGIKARP)
.enemySpecies(Species.SNORLAX)
.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)
test("decreases the target Pokemon's speed stat once per turn for 3 turns",
async() => {
await game.startBattle([Species.MAGIKARP]);
const targetPokemon = game.scene.getEnemyPokemon()!;
expect(targetPokemon.getStatStage(Stat.SPD)).toBe(0);
game.move.select(Moves.SYRUP_BOMB);
await game.toNextTurn();
expect(targetPokemon.getTag(BattlerTagType.SYRUP_BOMB)).toBeDefined();
expect(targetPokemon.getStatStage(Stat.SPD)).toBe(-1);
game.move.select(Moves.SPLASH);
await game.toNextTurn();
expect(targetPokemon.getTag(BattlerTagType.SYRUP_BOMB)).toBeDefined();
expect(targetPokemon.getStatStage(Stat.SPD)).toBe(-2);
game.move.select(Moves.SPLASH);
await game.toNextTurn();
expect(targetPokemon.getTag(BattlerTagType.SYRUP_BOMB)).toBeUndefined();
expect(targetPokemon.getStatStage(Stat.SPD)).toBe(-3);
}
);
test("does not affect Pokemon with the ability Bulletproof",
async() => {
game.override.enemyAbility(Abilities.BULLETPROOF);
await game.startBattle([Species.MAGIKARP]);
const targetPokemon = game.scene.getEnemyPokemon()!;
game.move.select(Moves.SYRUP_BOMB);
await game.toNextTurn();
expect(targetPokemon.getMaxHp()).toBe(targetPokemon.hp);
expect(targetPokemon.getTag(BattlerTagType.SYRUP_BOMB)).toBeUndefined();
expect(targetPokemon.getStatStage(Stat.SPD)).toBe(0);
}
);
});