mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 16:26:25 +00:00
[Bug] Fix Make It Rain not applying effect on KO (#2670)
This commit is contained in:
parent
aa0d01f419
commit
b2048148c9
@ -5513,11 +5513,21 @@ const userSleptOrComatoseCondition: MoveConditionFunc = (user: Pokemon, target:
|
||||
|
||||
const targetSleptOrComatoseCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => target.status?.effect === StatusEffect.SLEEP || target.hasAbility(Abilities.COMATOSE);
|
||||
|
||||
/**
|
||||
* Condition to apply effects only upon applying the move to its last target.
|
||||
* Currently only used for Make It Rain.
|
||||
* @param {Pokemon} user The user of the move.
|
||||
* @param {Pokemon} target The current target of the move.
|
||||
* @param {Move} move The move to which this condition applies.
|
||||
* @returns true if the target is the last target to which the move applies.
|
||||
*/
|
||||
const lastTargetOnlyCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => {
|
||||
const effectPhase = user.scene.getCurrentPhase();
|
||||
const targetIndex = target.getFieldIndex() + (target.isPlayer() ? 0 : BattlerIndex.ENEMY);
|
||||
|
||||
if (effectPhase instanceof MoveEffectPhase) {
|
||||
return target === effectPhase.getTargets().at(-1);
|
||||
const activeTargets = effectPhase.getTargets();
|
||||
return (activeTargets.length === 0 || targetIndex >= activeTargets.at(-1).getBattlerIndex());
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
@ -6,6 +6,7 @@ import { Species } from "#enums/species";
|
||||
import {
|
||||
CommandPhase,
|
||||
MoveEndPhase,
|
||||
StatChangePhase,
|
||||
} from "#app/phases";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
|
||||
@ -57,4 +58,25 @@ describe("Moves - Make It Rain", () => {
|
||||
|
||||
expect(playerPokemon[0].summonData.battleStats[BattleStat.SPATK]).toBe(-1);
|
||||
});
|
||||
|
||||
it("should apply effects even if the target faints", async () => {
|
||||
vi.spyOn(overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(1); // ensures the enemy will faint
|
||||
vi.spyOn(overrides, "DOUBLE_BATTLE_OVERRIDE", "get").mockReturnValue(false);
|
||||
vi.spyOn(overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
||||
|
||||
await game.startBattle([Species.CHARIZARD]);
|
||||
|
||||
const playerPokemon = game.scene.getPlayerPokemon();
|
||||
expect(playerPokemon).toBeDefined();
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon();
|
||||
expect(enemyPokemon).toBeDefined();
|
||||
|
||||
game.doAttack(getMovePosition(game.scene, 0, Moves.MAKE_IT_RAIN));
|
||||
|
||||
await game.phaseInterceptor.to(StatChangePhase);
|
||||
|
||||
expect(enemyPokemon.isFainted()).toBe(true);
|
||||
expect(playerPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(-1);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user