[P2] Fix Battle Bond continuing to affect Water Shuriken after Greninja returns to base form (#4602)
* [Bug] Fix Battle Bond continuing to buff Water Shuriken after Greninja returns to base form * Test cleanup * PR feedback * Update test to use getMultiHitType() * PR Feedback
This commit is contained in:
parent
51894d46c2
commit
64147e4414
|
@ -1938,12 +1938,21 @@ export class IncrementMovePriorityAttr extends MoveAttr {
|
|||
* @see {@linkcode apply}
|
||||
*/
|
||||
export class MultiHitAttr extends MoveAttr {
|
||||
/** This move's intrinsic multi-hit type. It should never be modified. */
|
||||
private readonly intrinsicMultiHitType: MultiHitType;
|
||||
/** This move's current multi-hit type. It may be temporarily modified by abilities (e.g., Battle Bond). */
|
||||
private multiHitType: MultiHitType;
|
||||
|
||||
constructor(multiHitType?: MultiHitType) {
|
||||
super();
|
||||
|
||||
this.multiHitType = multiHitType !== undefined ? multiHitType : MultiHitType._2_TO_5;
|
||||
this.intrinsicMultiHitType = multiHitType !== undefined ? multiHitType : MultiHitType._2_TO_5;
|
||||
this.multiHitType = this.intrinsicMultiHitType;
|
||||
}
|
||||
|
||||
// Currently used by `battle_bond.test.ts`
|
||||
getMultiHitType(): MultiHitType {
|
||||
return this.multiHitType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1957,7 +1966,7 @@ export class MultiHitAttr extends MoveAttr {
|
|||
* @returns True
|
||||
*/
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
const hitType = new Utils.NumberHolder(this.multiHitType);
|
||||
const hitType = new Utils.NumberHolder(this.intrinsicMultiHitType);
|
||||
applyMoveAttrs(ChangeMultiHitTypeAttr, user, target, move, hitType);
|
||||
this.multiHitType = hitType.value;
|
||||
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
import { allMoves, MultiHitAttr, MultiHitType } from "#app/data/move";
|
||||
import { Status, StatusEffect } from "#app/data/status-effect";
|
||||
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
|
||||
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
|
||||
describe("Abilities - BATTLE BOND", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
|
||||
const baseForm = 1;
|
||||
const ashForm = 2;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({
|
||||
type: Phaser.HEADLESS,
|
||||
|
@ -24,40 +26,68 @@ describe("Abilities - BATTLE BOND", () => {
|
|||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
const moveToUse = Moves.SPLASH;
|
||||
game.override.battleType("single");
|
||||
game.override.ability(Abilities.BATTLE_BOND);
|
||||
game.override.moveset([ moveToUse ]);
|
||||
game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]);
|
||||
game.override.battleType("single")
|
||||
.startingWave(4) // Leads to arena reset on Wave 5 trainer battle
|
||||
.ability(Abilities.BATTLE_BOND)
|
||||
.starterForms({ [Species.GRENINJA]: ashForm, })
|
||||
.moveset([ Moves.SPLASH, Moves.WATER_SHURIKEN ])
|
||||
.enemySpecies(Species.BULBASAUR)
|
||||
.enemyMoveset(Moves.SPLASH)
|
||||
.startingLevel(100) // Avoid levelling up
|
||||
.enemyLevel(1000); // Avoid opponent dying before `doKillOpponents()`
|
||||
});
|
||||
|
||||
test(
|
||||
"check if fainted pokemon switches to base form on arena reset",
|
||||
async () => {
|
||||
const baseForm = 1;
|
||||
const ashForm = 2;
|
||||
game.override.startingWave(4);
|
||||
game.override.starterForms({
|
||||
[Species.GRENINJA]: ashForm,
|
||||
});
|
||||
it("check if fainted pokemon switches to base form on arena reset", async () => {
|
||||
await game.classicMode.startBattle([ Species.MAGIKARP, Species.GRENINJA ]);
|
||||
|
||||
await game.startBattle([ Species.MAGIKARP, Species.GRENINJA ]);
|
||||
const greninja = game.scene.getParty()[1];
|
||||
expect(greninja.formIndex).toBe(ashForm);
|
||||
|
||||
const greninja = game.scene.getParty().find((p) => p.species.speciesId === Species.GRENINJA);
|
||||
expect(greninja).toBeDefined();
|
||||
expect(greninja!.formIndex).toBe(ashForm);
|
||||
greninja.hp = 0;
|
||||
greninja.status = new Status(StatusEffect.FAINT);
|
||||
expect(greninja.isFainted()).toBe(true);
|
||||
|
||||
greninja!.hp = 0;
|
||||
greninja!.status = new Status(StatusEffect.FAINT);
|
||||
expect(greninja!.isFainted()).toBe(true);
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.doKillOpponents();
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
game.doSelectModifier();
|
||||
await game.phaseInterceptor.to("QuietFormChangePhase");
|
||||
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.doKillOpponents();
|
||||
await game.phaseInterceptor.to(TurnEndPhase);
|
||||
game.doSelectModifier();
|
||||
await game.phaseInterceptor.to(QuietFormChangePhase);
|
||||
expect(greninja.formIndex).toBe(baseForm);
|
||||
});
|
||||
|
||||
expect(greninja!.formIndex).toBe(baseForm);
|
||||
},
|
||||
);
|
||||
it("should not keep buffing Water Shuriken after Greninja switches to base form", async () => {
|
||||
await game.classicMode.startBattle([ Species.GRENINJA ]);
|
||||
|
||||
const waterShuriken = allMoves[Moves.WATER_SHURIKEN];
|
||||
vi.spyOn(waterShuriken, "calculateBattlePower");
|
||||
|
||||
let actualMultiHitType: MultiHitType | null = null;
|
||||
const multiHitAttr = waterShuriken.getAttrs(MultiHitAttr)[0];
|
||||
vi.spyOn(multiHitAttr, "getHitCount").mockImplementation(() => {
|
||||
actualMultiHitType = multiHitAttr.getMultiHitType();
|
||||
return 3;
|
||||
});
|
||||
|
||||
// Wave 4: Use Water Shuriken in Ash form
|
||||
let expectedBattlePower = 20;
|
||||
let expectedMultiHitType = MultiHitType._3;
|
||||
|
||||
game.move.select(Moves.WATER_SHURIKEN);
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(waterShuriken.calculateBattlePower).toHaveLastReturnedWith(expectedBattlePower);
|
||||
expect(actualMultiHitType).toBe(expectedMultiHitType);
|
||||
|
||||
await game.doKillOpponents();
|
||||
await game.toNextWave();
|
||||
|
||||
// Wave 5: Use Water Shuriken in base form
|
||||
expectedBattlePower = 15;
|
||||
expectedMultiHitType = MultiHitType._2_TO_5;
|
||||
|
||||
game.move.select(Moves.WATER_SHURIKEN);
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(waterShuriken.calculateBattlePower).toHaveLastReturnedWith(expectedBattlePower);
|
||||
expect(actualMultiHitType).toBe(expectedMultiHitType);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue