2024-06-13 22:44:23 +00:00
|
|
|
import { BattleSpec } from "#enums/battle-spec";
|
2024-03-01 01:08:50 +00:00
|
|
|
import Pokemon from "./field/pokemon";
|
2024-06-06 13:36:12 +00:00
|
|
|
import i18next from "./plugins/i18n";
|
2023-04-15 05:32:16 +00:00
|
|
|
|
2024-06-06 13:36:12 +00:00
|
|
|
/**
|
|
|
|
* Builds a message by concatenating the Pokemon name with its potential affix and the given text
|
|
|
|
* @param pokemon {@linkcode Pokemon} name and battle context will be retrieved from this instance for {@linkcode getPokemonNameWithAffix}
|
|
|
|
* @param {string} content any text
|
|
|
|
* @returns {string} ex: "Wild Gengar fainted!", "Ectoplasma sauvage est K.O!"
|
|
|
|
* @see {@linkcode getPokemonNameWithAffix} for the Pokemon's name and potentiel affix
|
|
|
|
*/
|
2023-04-15 05:32:16 +00:00
|
|
|
export function getPokemonMessage(pokemon: Pokemon, content: string): string {
|
2024-06-06 13:36:12 +00:00
|
|
|
return `${getPokemonNameWithAffix(pokemon)}${content}`;
|
2024-04-09 16:42:18 +00:00
|
|
|
}
|
|
|
|
|
2024-06-06 13:36:12 +00:00
|
|
|
/**
|
|
|
|
* Retrieves the Pokemon's name, potentially with an affix indicating its role (wild or foe) in the current battle context, translated
|
|
|
|
* @param pokemon {@linkcode Pokemon} name and battle context will be retrieved from this instance
|
|
|
|
* @returns {string} ex: "Wild Gengar", "Ectoplasma sauvage"
|
|
|
|
*/
|
|
|
|
export function getPokemonNameWithAffix(pokemon: Pokemon): string {
|
2024-01-13 17:24:24 +00:00
|
|
|
switch (pokemon.scene.currentBattle.battleSpec) {
|
2024-05-23 15:03:10 +00:00
|
|
|
case BattleSpec.DEFAULT:
|
2024-06-06 13:36:12 +00:00
|
|
|
return !pokemon.isPlayer()
|
|
|
|
? pokemon.hasTrainer()
|
|
|
|
? i18next.t("battle:foePokemonWithAffix", {
|
|
|
|
pokemonName: pokemon.name,
|
|
|
|
})
|
|
|
|
: i18next.t("battle:wildPokemonWithAffix", {
|
|
|
|
pokemonName: pokemon.name,
|
|
|
|
})
|
|
|
|
: pokemon.name;
|
2024-05-23 15:03:10 +00:00
|
|
|
case BattleSpec.FINAL_BOSS:
|
2024-06-06 13:36:12 +00:00
|
|
|
return !pokemon.isPlayer()
|
|
|
|
? i18next.t("battle:foePokemonWithAffix", { pokemonName: pokemon.name })
|
|
|
|
: pokemon.name;
|
|
|
|
default:
|
|
|
|
return pokemon.name;
|
2024-01-13 17:24:24 +00:00
|
|
|
}
|
2024-05-23 15:03:10 +00:00
|
|
|
}
|