From 77d8139437df49282c9f199620a0c84bd2253e9f Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 30 Apr 2024 12:37:34 -0400 Subject: [PATCH] Fixes for Wish implementation --- src/data/arena-tag.ts | 29 +++++++++++++++++------------ src/data/enums/arena-tag-type.ts | 4 ++-- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/data/arena-tag.ts b/src/data/arena-tag.ts index 95041501535..a879c68d4ce 100644 --- a/src/data/arena-tag.ts +++ b/src/data/arena-tag.ts @@ -1,10 +1,10 @@ import { Arena } from "../field/arena"; import { Type } from "./type"; import * as Utils from "../utils"; -import { MoveCategory, StatChangeAttr, allMoves } from "./move"; +import { MoveCategory, allMoves } from "./move"; import { getPokemonMessage } from "../messages"; import Pokemon, { HitResult, PokemonMove } from "../field/pokemon"; -import {MoveEffectPhase, PokemonHealPhase, StatChangePhase} from "../phases"; +import { MoveEffectPhase, PokemonHealPhase, StatChangePhase} from "../phases"; import { StatusEffect } from "./status-effect"; import { BattlerIndex } from "../battle"; import { Moves } from "./enums/moves"; @@ -147,22 +147,27 @@ class AuroraVeilTag extends WeakenMoveScreenTag { } class WishTag extends ArenaTag { - private slot: BattlerIndex; - private userName: string; - private health: number; + private battlerIndex: BattlerIndex; + private triggerMessage: string; + private healHp: number; + constructor(turnCount: integer, sourceId: integer, side: ArenaTagSide) { super(ArenaTagType.WISH, turnCount, Moves.WISH, sourceId, side); } + onAdd(arena: Arena): void { - const mon = arena.scene.getPokemonById(this.sourceId); - this.slot = mon.getBattlerIndex(); - this.userName = mon.name; - this.health = mon.getMaxHp() / 2; + const user = arena.scene.getPokemonById(this.sourceId); + this.battlerIndex = user.getBattlerIndex(); + this.triggerMessage = getPokemonMessage(user, '\'s wish\ncame true!'); + this.healHp = Math.max(Math.floor(user.getMaxHp() / 2), 1); } + onRemove(arena: Arena): void { - const target = arena.scene.getField()[this.slot]; - arena.scene.unshiftPhase(new PokemonHealPhase(target.scene, target.getBattlerIndex(), - Math.max(Math.floor(this.health), 1), this.userName + '\'s wish\ncame true!', true, false)); + const target = arena.scene.getField()[this.battlerIndex]; + if (target?.isActive(true)) { + arena.scene.queueMessage(this.triggerMessage); + arena.scene.unshiftPhase(new PokemonHealPhase(target.scene, target.getBattlerIndex(), this.healHp, null, true, false)); + } } } diff --git a/src/data/enums/arena-tag-type.ts b/src/data/enums/arena-tag-type.ts index c4492012710..8478b6f3f57 100644 --- a/src/data/enums/arena-tag-type.ts +++ b/src/data/enums/arena-tag-type.ts @@ -8,12 +8,12 @@ export enum ArenaTagType { MIST = "MIST", FUTURE_SIGHT = "FUTURE_SIGHT", DOOM_DESIRE = "DOOM_DESIRE", + WISH = "WISH", STEALTH_ROCK = "STEALTH_ROCK", STICKY_WEB = "STICKY_WEB", TRICK_ROOM = "TRICK_ROOM", GRAVITY = "GRAVITY", REFLECT = "REFLECT", LIGHT_SCREEN = "LIGHT_SCREEN", - AURORA_VEIL = "AURORA_VEIL", - WISH = "WISH" + AURORA_VEIL = "AURORA_VEIL" }