mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 17:12:44 +02:00
Moved terrain messages to terrain.ts
, made status failures use correct text
This commit is contained in:
parent
dd2f475ded
commit
77f6befb70
@ -2856,6 +2856,11 @@ export default class BattleScene extends SceneBase {
|
|||||||
promptDelay?: number | null,
|
promptDelay?: number | null,
|
||||||
defer?: boolean | null,
|
defer?: boolean | null,
|
||||||
) {
|
) {
|
||||||
|
// don't display empty strings
|
||||||
|
if (!message) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const phase = new MessagePhase(message, callbackDelay, prompt, promptDelay);
|
const phase = new MessagePhase(message, callbackDelay, prompt, promptDelay);
|
||||||
if (!defer) {
|
if (!defer) {
|
||||||
// adds to the end of PhaseQueuePrepend
|
// adds to the end of PhaseQueuePrepend
|
||||||
|
@ -4,6 +4,7 @@ import { PokemonType } from "#enums/pokemon-type";
|
|||||||
import { ProtectAttr } from "./moves/move";
|
import { ProtectAttr } from "./moves/move";
|
||||||
import type { BattlerIndex } from "#app/battle";
|
import type { BattlerIndex } from "#app/battle";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
import { getPokemonNameWithAffix } from "#app/messages";
|
||||||
|
|
||||||
export enum TerrainType {
|
export enum TerrainType {
|
||||||
NONE,
|
NONE,
|
||||||
@ -97,3 +98,70 @@ export function getTerrainColor(terrainType: TerrainType): [number, number, numb
|
|||||||
|
|
||||||
return [0, 0, 0];
|
return [0, 0, 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the message associated with a terrain effect starting.
|
||||||
|
* @param terrainType - The {@linkcode TerrainType} starting.
|
||||||
|
* @returns A string containing the appropriate terrain start text.
|
||||||
|
*/
|
||||||
|
export function getTerrainStartMessage(terrainType: TerrainType): string {
|
||||||
|
switch (terrainType) {
|
||||||
|
case TerrainType.MISTY:
|
||||||
|
return i18next.t("terrain:mistyStartMessage");
|
||||||
|
case TerrainType.ELECTRIC:
|
||||||
|
return i18next.t("terrain:electricStartMessage");
|
||||||
|
case TerrainType.GRASSY:
|
||||||
|
return i18next.t("terrain:grassyStartMessage");
|
||||||
|
case TerrainType.PSYCHIC:
|
||||||
|
return i18next.t("terrain:psychicStartMessage");
|
||||||
|
default:
|
||||||
|
console.warn(`${terrainType} unexpectedly provided as terrain type to getTerrainStartMessage!`);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the message associated with a terrain effect ceasing to exist.
|
||||||
|
* @param terrainType - The {@linkcode TerrainType} being cleared.
|
||||||
|
* @returns A string containing the appropriate terrain clear text.
|
||||||
|
*/
|
||||||
|
export function getTerrainClearMessage(terrainType: TerrainType): string {
|
||||||
|
switch (terrainType) {
|
||||||
|
case TerrainType.MISTY:
|
||||||
|
return i18next.t("terrain:mistyClearMessage");
|
||||||
|
case TerrainType.ELECTRIC:
|
||||||
|
return i18next.t("terrain:electricClearMessage");
|
||||||
|
case TerrainType.GRASSY:
|
||||||
|
return i18next.t("terrain:grassyClearMessage");
|
||||||
|
case TerrainType.PSYCHIC:
|
||||||
|
return i18next.t("terrain:psychicClearMessage");
|
||||||
|
default:
|
||||||
|
console.warn(`${terrainType} unexpectedly provided as terrain type to getTerrainClearMessage!`);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the message associated with a terrain-induced move/effect blockage.
|
||||||
|
* @param pokemon - The {@linkcode Pokemon} being protected.
|
||||||
|
* @param terrainType - The {@linkcode TerrainType} in question
|
||||||
|
* @returns A string containing the appropriate terrain block text.
|
||||||
|
*/
|
||||||
|
export function getTerrainBlockMessage(pokemon: Pokemon, terrainType: TerrainType): string {
|
||||||
|
switch (terrainType) {
|
||||||
|
case TerrainType.MISTY:
|
||||||
|
return i18next.t("terrain:mistyBlockMessage", {
|
||||||
|
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
||||||
|
});
|
||||||
|
case TerrainType.ELECTRIC:
|
||||||
|
case TerrainType.GRASSY:
|
||||||
|
case TerrainType.PSYCHIC:
|
||||||
|
return i18next.t("terrain:defaultBlockMessage", {
|
||||||
|
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
||||||
|
terrainName: getTerrainName(terrainType),
|
||||||
|
});
|
||||||
|
default:
|
||||||
|
console.warn(`${terrainType} unexpectedly provided as terrain type to getTerrainBlockMessage!`);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -7,7 +7,6 @@ import type Move from "./moves/move";
|
|||||||
import { AttackMove } from "./moves/move";
|
import { AttackMove } from "./moves/move";
|
||||||
import { randSeedInt } from "#app/utils/common";
|
import { randSeedInt } from "#app/utils/common";
|
||||||
import { SuppressWeatherEffectAbAttr } from "./abilities/ability";
|
import { SuppressWeatherEffectAbAttr } from "./abilities/ability";
|
||||||
import { TerrainType, getTerrainName } from "./terrain";
|
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
import type { Arena } from "#app/field/arena";
|
import type { Arena } from "#app/field/arena";
|
||||||
@ -236,50 +235,6 @@ export function getWeatherBlockMessage(weatherType: WeatherType): string {
|
|||||||
return i18next.t("weather:defaultEffectMessage");
|
return i18next.t("weather:defaultEffectMessage");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTerrainStartMessage(terrainType: TerrainType): string | null {
|
|
||||||
switch (terrainType) {
|
|
||||||
case TerrainType.MISTY:
|
|
||||||
return i18next.t("terrain:mistyStartMessage");
|
|
||||||
case TerrainType.ELECTRIC:
|
|
||||||
return i18next.t("terrain:electricStartMessage");
|
|
||||||
case TerrainType.GRASSY:
|
|
||||||
return i18next.t("terrain:grassyStartMessage");
|
|
||||||
case TerrainType.PSYCHIC:
|
|
||||||
return i18next.t("terrain:psychicStartMessage");
|
|
||||||
default:
|
|
||||||
console.warn("getTerrainStartMessage not defined. Using default null");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getTerrainClearMessage(terrainType: TerrainType): string | null {
|
|
||||||
switch (terrainType) {
|
|
||||||
case TerrainType.MISTY:
|
|
||||||
return i18next.t("terrain:mistyClearMessage");
|
|
||||||
case TerrainType.ELECTRIC:
|
|
||||||
return i18next.t("terrain:electricClearMessage");
|
|
||||||
case TerrainType.GRASSY:
|
|
||||||
return i18next.t("terrain:grassyClearMessage");
|
|
||||||
case TerrainType.PSYCHIC:
|
|
||||||
return i18next.t("terrain:psychicClearMessage");
|
|
||||||
default:
|
|
||||||
console.warn("getTerrainClearMessage not defined. Using default null");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getTerrainBlockMessage(pokemon: Pokemon, terrainType: TerrainType): string {
|
|
||||||
if (terrainType === TerrainType.MISTY) {
|
|
||||||
return i18next.t("terrain:mistyBlockMessage", {
|
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return i18next.t("terrain:defaultBlockMessage", {
|
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
|
||||||
terrainName: getTerrainName(terrainType),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface WeatherPoolEntry {
|
export interface WeatherPoolEntry {
|
||||||
weatherType: WeatherType;
|
weatherType: WeatherType;
|
||||||
weight: number;
|
weight: number;
|
||||||
|
@ -5,8 +5,6 @@ import { randSeedInt, NumberHolder, isNullOrUndefined, type Constructor } from "
|
|||||||
import type PokemonSpecies from "#app/data/pokemon-species";
|
import type PokemonSpecies from "#app/data/pokemon-species";
|
||||||
import { getPokemonSpecies } from "#app/data/pokemon-species";
|
import { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||||
import {
|
import {
|
||||||
getTerrainClearMessage,
|
|
||||||
getTerrainStartMessage,
|
|
||||||
getWeatherClearMessage,
|
getWeatherClearMessage,
|
||||||
getWeatherStartMessage,
|
getWeatherStartMessage,
|
||||||
getLegendaryWeatherContinuesMessage,
|
getLegendaryWeatherContinuesMessage,
|
||||||
@ -18,7 +16,7 @@ import type Move from "#app/data/moves/move";
|
|||||||
import type { ArenaTag } from "#app/data/arena-tag";
|
import type { ArenaTag } from "#app/data/arena-tag";
|
||||||
import { ArenaTagSide, ArenaTrapTag, getArenaTag } from "#app/data/arena-tag";
|
import { ArenaTagSide, ArenaTrapTag, getArenaTag } from "#app/data/arena-tag";
|
||||||
import type { BattlerIndex } from "#app/battle";
|
import type { BattlerIndex } from "#app/battle";
|
||||||
import { Terrain, TerrainType } from "#app/data/terrain";
|
import { Terrain, TerrainType, getTerrainClearMessage, getTerrainStartMessage } from "#app/data/terrain";
|
||||||
import {
|
import {
|
||||||
applyAbAttrs,
|
applyAbAttrs,
|
||||||
applyPostTerrainChangeAbAttrs,
|
applyPostTerrainChangeAbAttrs,
|
||||||
@ -433,9 +431,9 @@ export class Arena {
|
|||||||
if (!ignoreAnim) {
|
if (!ignoreAnim) {
|
||||||
globalScene.unshiftPhase(new CommonAnimPhase(undefined, undefined, CommonAnim.MISTY_TERRAIN + (terrain - 1)));
|
globalScene.unshiftPhase(new CommonAnimPhase(undefined, undefined, CommonAnim.MISTY_TERRAIN + (terrain - 1)));
|
||||||
}
|
}
|
||||||
globalScene.queueMessage(getTerrainStartMessage(terrain)!); // TODO: is this bang correct?
|
globalScene.queueMessage(getTerrainStartMessage(terrain));
|
||||||
} else {
|
} else {
|
||||||
globalScene.queueMessage(getTerrainClearMessage(oldTerrainType)!); // TODO: is this bang correct?
|
globalScene.queueMessage(getTerrainClearMessage(oldTerrainType));
|
||||||
}
|
}
|
||||||
|
|
||||||
globalScene
|
globalScene
|
||||||
|
@ -257,6 +257,7 @@ import { MoveFlags } from "#enums/MoveFlags";
|
|||||||
import { timedEventManager } from "#app/global-event-manager";
|
import { timedEventManager } from "#app/global-event-manager";
|
||||||
import { loadMoveAnimations } from "#app/sprites/pokemon-asset-loader";
|
import { loadMoveAnimations } from "#app/sprites/pokemon-asset-loader";
|
||||||
import { ResetStatusPhase } from "#app/phases/reset-status-phase";
|
import { ResetStatusPhase } from "#app/phases/reset-status-phase";
|
||||||
|
import { getTerrainBlockMessage } from "#app/data/terrain";
|
||||||
|
|
||||||
export enum LearnMoveSituation {
|
export enum LearnMoveSituation {
|
||||||
MISC,
|
MISC,
|
||||||
@ -4612,16 +4613,33 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
queueImmuneMessage(quiet: boolean, effect?: StatusEffect): void {
|
/**
|
||||||
if (!effect || quiet) {
|
* Display an immunity message for a failed status application.
|
||||||
|
* @param quiet - Whether to suppress message and return early
|
||||||
|
* @param reason - The reason for the terrain blockage -
|
||||||
|
* can be "overlap" (already has same status), "other" (generic fail message)
|
||||||
|
* or a {@linkcode TerrainType} for terrain-based blockages.
|
||||||
|
*/
|
||||||
|
private queueImmuneMessage(quiet: boolean, reason: "overlap" | "other" | TerrainType = "other"): void {
|
||||||
|
if (quiet) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const message =
|
|
||||||
effect && this.status?.effect === effect
|
let message = "";
|
||||||
? getStatusEffectOverlapText(effect ?? StatusEffect.NONE, getPokemonNameWithAffix(this))
|
if (reason === "overlap" && this) {
|
||||||
: i18next.t("abilityTriggers:moveImmunity", {
|
// "XYZ is already XXX!"
|
||||||
|
message = getStatusEffectOverlapText(this.status?.effect ?? StatusEffect.NONE, getPokemonNameWithAffix(this));
|
||||||
|
} else if (typeof reason === "number") {
|
||||||
|
// "XYZ was protected by the XXX terrain!" /
|
||||||
|
// "XYZ surrounds itself with a protective mist!"
|
||||||
|
message = getTerrainBlockMessage(this, reason);
|
||||||
|
} else {
|
||||||
|
// "It doesn't affect XXX!"
|
||||||
|
message = i18next.t("abilityTriggers:moveImmunity", {
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(this),
|
pokemonNameWithAffix: getPokemonNameWithAffix(this),
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
globalScene.queueMessage(message);
|
globalScene.queueMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4643,11 +4661,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
): boolean {
|
): boolean {
|
||||||
if (effect !== StatusEffect.FAINT) {
|
if (effect !== StatusEffect.FAINT) {
|
||||||
if (overrideStatus ? this.status?.effect === effect : this.status) {
|
if (overrideStatus ? this.status?.effect === effect : this.status) {
|
||||||
this.queueImmuneMessage(quiet, effect);
|
this.queueImmuneMessage(quiet, overrideStatus ? "overlap" : "other"); // having different status displays generic fail message
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.isGrounded() && !ignoreField && globalScene.arena.terrain?.terrainType === TerrainType.MISTY) {
|
if (this.isGrounded() && !ignoreField && globalScene.arena.terrain?.terrainType === TerrainType.MISTY) {
|
||||||
this.queueImmuneMessage(quiet, effect);
|
this.queueImmuneMessage(quiet, TerrainType.MISTY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4678,7 +4696,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
|
|
||||||
if (this.isOfType(PokemonType.POISON) || this.isOfType(PokemonType.STEEL)) {
|
if (this.isOfType(PokemonType.POISON) || this.isOfType(PokemonType.STEEL)) {
|
||||||
if (poisonImmunity.includes(true)) {
|
if (poisonImmunity.includes(true)) {
|
||||||
this.queueImmuneMessage(quiet, effect);
|
this.queueImmuneMessage(quiet);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4686,13 +4704,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
case StatusEffect.PARALYSIS:
|
case StatusEffect.PARALYSIS:
|
||||||
if (this.isOfType(PokemonType.ELECTRIC)) {
|
if (this.isOfType(PokemonType.ELECTRIC)) {
|
||||||
this.queueImmuneMessage(quiet, effect);
|
this.queueImmuneMessage(quiet);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case StatusEffect.SLEEP:
|
case StatusEffect.SLEEP:
|
||||||
if (this.isGrounded() && globalScene.arena.terrain?.terrainType === TerrainType.ELECTRIC) {
|
if (this.isGrounded() && globalScene.arena.terrain?.terrainType === TerrainType.ELECTRIC) {
|
||||||
this.queueImmuneMessage(quiet, effect);
|
this.queueImmuneMessage(quiet, TerrainType.ELECTRIC);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -4703,13 +4721,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
globalScene?.arena?.weather?.weatherType &&
|
globalScene?.arena?.weather?.weatherType &&
|
||||||
[WeatherType.SUNNY, WeatherType.HARSH_SUN].includes(globalScene.arena.weather.weatherType))
|
[WeatherType.SUNNY, WeatherType.HARSH_SUN].includes(globalScene.arena.weather.weatherType))
|
||||||
) {
|
) {
|
||||||
this.queueImmuneMessage(quiet, effect);
|
this.queueImmuneMessage(quiet);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case StatusEffect.BURN:
|
case StatusEffect.BURN:
|
||||||
if (this.isOfType(PokemonType.FIRE)) {
|
if (this.isOfType(PokemonType.FIRE)) {
|
||||||
this.queueImmuneMessage(quiet, effect);
|
this.queueImmuneMessage(quiet);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -6702,7 +6720,6 @@ export class EnemyPokemon extends Pokemon {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show or hide the type effectiveness multiplier window
|
* Show or hide the type effectiveness multiplier window
|
||||||
* Passing undefined will hide the window
|
* Passing undefined will hide the window
|
||||||
|
@ -43,7 +43,9 @@ import { WeatherType } from "#enums/weather-type";
|
|||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
const overrides = {} satisfies Partial<InstanceType<OverridesType>>;
|
const overrides = {
|
||||||
|
MOVESET_OVERRIDE: [Moves.WHIRLWIND, Moves.BATON_PASS, Moves.DRAGON_TAIL, Moves.CIRCLE_THROW]
|
||||||
|
} satisfies Partial<InstanceType<OverridesType>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If you need to add Overrides values for local testing do that inside {@linkcode overrides}
|
* If you need to add Overrides values for local testing do that inside {@linkcode overrides}
|
||||||
|
@ -31,7 +31,7 @@ import { MoveFlags } from "#enums/MoveFlags";
|
|||||||
import { SpeciesFormChangePreMoveTrigger } from "#app/data/pokemon-forms";
|
import { SpeciesFormChangePreMoveTrigger } from "#app/data/pokemon-forms";
|
||||||
import { getStatusEffectActivationText, getStatusEffectHealText } from "#app/data/status-effect";
|
import { getStatusEffectActivationText, getStatusEffectHealText } from "#app/data/status-effect";
|
||||||
import { PokemonType } from "#enums/pokemon-type";
|
import { PokemonType } from "#enums/pokemon-type";
|
||||||
import { getTerrainBlockMessage, getWeatherBlockMessage } from "#app/data/weather";
|
import { getWeatherBlockMessage } from "#app/data/weather";
|
||||||
import { MoveUsedEvent } from "#app/events/battle-scene";
|
import { MoveUsedEvent } from "#app/events/battle-scene";
|
||||||
import type { PokemonMove } from "#app/field/pokemon";
|
import type { PokemonMove } from "#app/field/pokemon";
|
||||||
import type Pokemon from "#app/field/pokemon";
|
import type Pokemon from "#app/field/pokemon";
|
||||||
@ -50,6 +50,7 @@ import { BattlerTagType } from "#enums/battler-tag-type";
|
|||||||
import { Moves } from "#enums/moves";
|
import { Moves } from "#enums/moves";
|
||||||
import { StatusEffect } from "#enums/status-effect";
|
import { StatusEffect } from "#enums/status-effect";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
import { getTerrainBlockMessage } from "#app/data/terrain";
|
||||||
|
|
||||||
export class MovePhase extends BattlePhase {
|
export class MovePhase extends BattlePhase {
|
||||||
protected _pokemon: Pokemon;
|
protected _pokemon: Pokemon;
|
||||||
|
Loading…
Reference in New Issue
Block a user