mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-07 16:09:27 +02:00
[Bug] Unblock priority spread under Psychic Terrain (#6136)
Unblock priority spread under Psychic Terrain Co-authored-by: Acelynn Zhang <acelynnzhang@Acelynns-MacBook-Pro.local>
This commit is contained in:
parent
3940abbeaf
commit
6211fbd471
@ -27,6 +27,28 @@ export function isFieldTargeted(move: Move): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether a move is a spread move.
|
||||
*
|
||||
* @param move - The {@linkcode Move} to check
|
||||
* @returns Whether {@linkcode move} is spread-targeted.
|
||||
* @remarks
|
||||
* Examples include:
|
||||
* - Moves targeting all adjacent Pokemon (like Surf)
|
||||
* - Moves targeting all adjacent enemies (like Air Cutter)
|
||||
*/
|
||||
|
||||
export function isSpreadMove(move: Move): boolean {
|
||||
switch (move.moveTarget) {
|
||||
case MoveTarget.ALL_ENEMIES:
|
||||
case MoveTarget.ALL_NEAR_ENEMIES:
|
||||
case MoveTarget.ALL_OTHERS:
|
||||
case MoveTarget.ALL_NEAR_OTHERS:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getMoveTargets(user: Pokemon, move: MoveId, replaceTarget?: MoveTarget): MoveTargetSet {
|
||||
const variableTarget = new NumberHolder(0);
|
||||
user.getOpponents(false).forEach(p => applyMoveAttrs("VariableTargetAttr", user, p, allMoves[move], variableTarget));
|
||||
|
@ -3,6 +3,7 @@ import type { BattlerIndex } from "#enums/battler-index";
|
||||
import { PokemonType } from "#enums/pokemon-type";
|
||||
import type { Pokemon } from "#field/pokemon";
|
||||
import type { Move } from "#moves/move";
|
||||
import { isFieldTargeted, isSpreadMove } from "#moves/move-utils";
|
||||
import i18next from "i18next";
|
||||
|
||||
export enum TerrainType {
|
||||
@ -60,13 +61,19 @@ export class Terrain {
|
||||
isMoveTerrainCancelled(user: Pokemon, targets: BattlerIndex[], move: Move): boolean {
|
||||
switch (this.terrainType) {
|
||||
case TerrainType.PSYCHIC:
|
||||
if (!move.hasAttr("ProtectAttr")) {
|
||||
// Cancels move if the move has positive priority and targets a Pokemon grounded on the Psychic Terrain
|
||||
return (
|
||||
move.getPriority(user) > 0 &&
|
||||
user.getOpponents(true).some(o => targets.includes(o.getBattlerIndex()) && o.isGrounded())
|
||||
);
|
||||
}
|
||||
// Cf https://bulbapedia.bulbagarden.net/wiki/Psychic_Terrain_(move)#Generation_VII
|
||||
// Psychic terrain will only cancel a move if it:
|
||||
return (
|
||||
// ... is neither spread nor field-targeted,
|
||||
!isFieldTargeted(move) &&
|
||||
!isSpreadMove(move) &&
|
||||
// .. has positive final priority,
|
||||
move.getPriority(user) > 0 &&
|
||||
// ...and is targeting at least 1 grounded opponent
|
||||
user
|
||||
.getOpponents(true)
|
||||
.some(o => targets.includes(o.getBattlerIndex()) && o.isGrounded())
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
59
test/arena/psychic-terrain.test.ts
Normal file
59
test/arena/psychic-terrain.test.ts
Normal file
@ -0,0 +1,59 @@
|
||||
import { AbilityId } from "#enums/ability-id";
|
||||
import { MoveId } from "#enums/move-id";
|
||||
import { SpeciesId } from "#enums/species-id";
|
||||
import { StatusEffect } from "#enums/status-effect";
|
||||
import { WeatherType } from "#enums/weather-type";
|
||||
import { GameManager } from "#test/test-utils/game-manager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
|
||||
describe("Arena - Psychic Terrain", () => {
|
||||
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
|
||||
.battleStyle("single")
|
||||
.criticalHits(false)
|
||||
.enemyLevel(1)
|
||||
.enemySpecies(SpeciesId.SHUCKLE)
|
||||
.enemyAbility(AbilityId.STURDY)
|
||||
.enemyMoveset(MoveId.SPLASH)
|
||||
.moveset([MoveId.PSYCHIC_TERRAIN, MoveId.RAIN_DANCE, MoveId.DARK_VOID])
|
||||
.ability(AbilityId.NO_GUARD);
|
||||
});
|
||||
|
||||
it("Dark Void with Prankster is not blocked", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
|
||||
|
||||
game.move.select(MoveId.PSYCHIC_TERRAIN);
|
||||
await game.toNextTurn();
|
||||
|
||||
game.move.select(MoveId.DARK_VOID);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.SLEEP);
|
||||
});
|
||||
|
||||
it("Rain Dance with Prankster is not blocked", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
|
||||
|
||||
game.move.select(MoveId.PSYCHIC_TERRAIN);
|
||||
await game.toNextTurn();
|
||||
|
||||
game.move.select(MoveId.RAIN_DANCE);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.RAIN);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user