mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 16:26:25 +00:00
[P2] Fix Substitute blocking field effects (#4504)
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
parent
8a8adad7fe
commit
145b80f491
@ -341,7 +341,8 @@ export default class Move implements Localizable {
|
||||
* @returns `true` if the move can bypass the target's Substitute; `false` otherwise.
|
||||
*/
|
||||
hitsSubstitute(user: Pokemon, target: Pokemon | null): boolean {
|
||||
if (this.moveTarget === MoveTarget.USER || !target?.getTag(BattlerTagType.SUBSTITUTE)) {
|
||||
if ([MoveTarget.USER, MoveTarget.USER_SIDE, MoveTarget.ENEMY_SIDE, MoveTarget.BOTH_SIDES].includes(this.moveTarget)
|
||||
|| !target?.getTag(BattlerTagType.SUBSTITUTE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,15 @@
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import { ArenaTagSide } from "#app/data/arena-tag";
|
||||
import { SubstituteTag, TrappedTag } from "#app/data/battler-tags";
|
||||
import { allMoves, StealHeldItemChanceAttr } from "#app/data/move";
|
||||
import { StatusEffect } from "#app/data/status-effect";
|
||||
import { Abilities } from "#app/enums/abilities";
|
||||
import { BattlerTagType } from "#app/enums/battler-tag-type";
|
||||
import { BerryType } from "#app/enums/berry-type";
|
||||
import { Moves } from "#app/enums/moves";
|
||||
import { Species } from "#app/enums/species";
|
||||
import { Stat } from "#app/enums/stat";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { ArenaTagType } from "#enums/arena-tag-type";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { BerryType } from "#enums/berry-type";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import { Stat } from "#enums/stat";
|
||||
import { MoveResult } from "#app/field/pokemon";
|
||||
import { CommandPhase } from "#app/phases/command-phase";
|
||||
import GameManager from "#app/test/utils/gameManager";
|
||||
@ -194,6 +196,71 @@ describe("Moves - Substitute", () => {
|
||||
}
|
||||
);
|
||||
|
||||
it(
|
||||
"shouldn't block moves that target the user's side of the field",
|
||||
async () => {
|
||||
game.override.moveset(Moves.LIGHT_SCREEN);
|
||||
|
||||
await game.classicMode.startBattle([Species.BLASTOISE]);
|
||||
|
||||
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||
vi.spyOn(leadPokemon, "getMoveEffectiveness");
|
||||
|
||||
leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id);
|
||||
|
||||
game.move.select(Moves.LIGHT_SCREEN);
|
||||
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(leadPokemon.getMoveEffectiveness).not.toHaveReturnedWith(0);
|
||||
expect(game.scene.arena.getTagOnSide(ArenaTagType.LIGHT_SCREEN, ArenaTagSide.PLAYER)).toBeDefined();
|
||||
}
|
||||
);
|
||||
|
||||
it(
|
||||
"shouldn't block the opponent from setting hazards",
|
||||
async () => {
|
||||
game.override.enemyMoveset(Moves.STEALTH_ROCK);
|
||||
|
||||
await game.classicMode.startBattle([Species.BLASTOISE]);
|
||||
|
||||
const leadPokemon = game.scene.getPlayerPokemon()!;
|
||||
vi.spyOn(leadPokemon, "getMoveEffectiveness");
|
||||
|
||||
game.move.select(Moves.SUBSTITUTE);
|
||||
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(leadPokemon.getMoveEffectiveness).not.toHaveReturnedWith(0);
|
||||
expect(game.scene.arena.getTagOnSide(ArenaTagType.STEALTH_ROCK, ArenaTagSide.PLAYER)).toBeDefined();
|
||||
}
|
||||
);
|
||||
|
||||
it(
|
||||
"shouldn't block moves that target both sides of the field",
|
||||
async () => {
|
||||
game.override
|
||||
.moveset(Moves.TRICK_ROOM)
|
||||
.enemyMoveset(Moves.GRAVITY);
|
||||
|
||||
await game.classicMode.startBattle([Species.BLASTOISE]);
|
||||
|
||||
const pokemon = game.scene.getField(true);
|
||||
pokemon.forEach(p => {
|
||||
vi.spyOn(p, "getMoveEffectiveness");
|
||||
p.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, p.id);
|
||||
});
|
||||
|
||||
game.move.select(Moves.TRICK_ROOM);
|
||||
|
||||
await game.toNextTurn();
|
||||
|
||||
pokemon.forEach(p => expect(p.getMoveEffectiveness).not.toHaveReturnedWith(0));
|
||||
expect(game.scene.arena.getTag(ArenaTagType.TRICK_ROOM)).toBeDefined();
|
||||
expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined();
|
||||
}
|
||||
);
|
||||
|
||||
it(
|
||||
"should protect the user from flinching",
|
||||
async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user