From 2c003854e973d193adda93db31f5543ec03cd1de Mon Sep 17 00:00:00 2001 From: Madi Simpson Date: Sat, 4 May 2024 18:45:37 -0700 Subject: [PATCH] terrain: psychic terrain doesn't block priority moves on the user's side (#470) --- src/data/terrain.ts | 7 ++++--- src/field/arena.ts | 4 ++-- src/phases.ts | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/data/terrain.ts b/src/data/terrain.ts index 48ffc1c68..c0328d98d 100644 --- a/src/data/terrain.ts +++ b/src/data/terrain.ts @@ -4,6 +4,7 @@ import { Type } from "./type"; import * as Utils from "../utils"; import { IncrementMovePriorityAbAttr, applyAbAttrs } from "./ability"; import { ProtectAttr } from "./move"; +import { BattlerIndex } from "#app/battle.js"; export enum TerrainType { NONE, @@ -48,13 +49,13 @@ export class Terrain { return 1; } - isMoveTerrainCancelled(user: Pokemon, move: Move): boolean { + isMoveTerrainCancelled(user: Pokemon, targets: BattlerIndex[], move: Move): boolean { switch (this.terrainType) { case TerrainType.PSYCHIC: - if (!move.getAttrs(ProtectAttr).length){ + if (!move.getAttrs(ProtectAttr).length) { const priority = new Utils.IntegerHolder(move.priority); applyAbAttrs(IncrementMovePriorityAbAttr, user, null, move, priority); - return priority.value > 0; + return priority.value > 0 && user.getOpponents().filter(o => targets.includes(o.getBattlerIndex())).length > 0; } } diff --git a/src/field/arena.ts b/src/field/arena.ts index 5b14560d4..6026560c1 100644 --- a/src/field/arena.ts +++ b/src/field/arena.ts @@ -336,8 +336,8 @@ export class Arena { return this.weather && !this.weather.isEffectSuppressed(this.scene) && this.weather.isMoveWeatherCancelled(move); } - isMoveTerrainCancelled(user: Pokemon, move: Move) { - return this.terrain && this.terrain.isMoveTerrainCancelled(user, move); + isMoveTerrainCancelled(user: Pokemon, targets: BattlerIndex[], move: Move) { + return this.terrain && this.terrain.isMoveTerrainCancelled(user, targets, move); } getTerrainType() : TerrainType { diff --git a/src/phases.ts b/src/phases.ts index e65e76daa..17c48bf41 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2280,7 +2280,7 @@ export class MovePhase extends BattlePhase { let failedText = null; if (success && this.scene.arena.isMoveWeatherCancelled(this.move.getMove())) success = false; - else if (success && this.scene.arena.isMoveTerrainCancelled(this.pokemon, this.move.getMove())) { + else if (success && this.scene.arena.isMoveTerrainCancelled(this.pokemon, this.targets, this.move.getMove())) { success = false; failedText = getTerrainBlockMessage(targets[0], this.scene.arena.terrain.terrainType); }