Fixes for Wish implementation

This commit is contained in:
Flashfyre 2024-04-30 12:37:34 -04:00
parent bed5e4f98f
commit 77d8139437
2 changed files with 19 additions and 14 deletions

View File

@ -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));
}
}
}

View File

@ -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"
}