From 981c63b1c2092a92036038696ebc07d4c4d6d56d Mon Sep 17 00:00:00 2001 From: xsn34kzx Date: Thu, 15 Aug 2024 16:10:33 -0400 Subject: [PATCH] Phase Out `BattleStat` (2) --- src/data/ability.ts | 13 ++++---- src/data/battle-stat.ts | 51 ----------------------------- src/data/battler-tags.ts | 12 +++---- src/data/move.ts | 6 ++-- src/data/nature.ts | 7 ++-- src/data/pokemon-stat.ts | 29 ---------------- src/enums/stat.ts | 19 +++++++++++ src/locales/de/pokemon-info.ts | 1 - src/locales/en/pokemon-info.ts | 3 +- src/locales/zh_CN/pokemon-info.ts | 2 +- src/modifier/modifier-type.ts | 6 ++-- src/phases.ts | 24 +++++++++----- src/system/achv.ts | 9 ++--- src/ui/battle-message-ui-handler.ts | 7 ++-- src/ui/stats-container.ts | 14 ++++---- src/ui/summary-ui-handler.ts | 10 +++--- 16 files changed, 74 insertions(+), 139 deletions(-) delete mode 100644 src/data/battle-stat.ts delete mode 100644 src/data/pokemon-stat.ts diff --git a/src/data/ability.ts b/src/data/ability.ts index 91165ff77384..eb9c81539870 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -2,7 +2,6 @@ import Pokemon, { HitResult, PlayerPokemon, PokemonMove } from "../field/pokemon import { Type } from "./type"; import { Constructor } from "#app/utils"; import * as Utils from "../utils"; -import { BattleStat, getBattleStatName } from "./battle-stat"; import { MovePhase, PokemonHealPhase, ShowAbilityPhase, StatChangePhase } from "../phases"; import { getPokemonNameWithAffix } from "../messages"; import { Weather, WeatherType } from "./weather"; @@ -11,7 +10,6 @@ import { StatusEffect, getNonVolatileStatusEffects, getStatusEffectDescriptor, g import { Gender } from "./gender"; import Move, { AttackMove, MoveCategory, MoveFlags, MoveTarget, FlinchAttr, OneHitKOAttr, HitHealAttr, allMoves, StatusMove, SelfStatusMove, VariablePowerAttr, applyMoveAttrs, IncrementMovePriorityAttr, VariableMoveTypeAttr, RandomMovesetMoveAttr, RandomMoveAttr, NaturePowerAttr, CopyMoveAttr, MoveAttr, MultiHitAttr, ChargeAttr, SacrificialAttr, SacrificialAttrOnHit } from "./move"; import { ArenaTagSide, ArenaTrapTag } from "./arena-tag"; -import { Stat, getStatName } from "./pokemon-stat"; import { BerryModifier, PokemonHeldItemModifier } from "../modifier/modifier"; import { TerrainType } from "./terrain"; import { SpeciesFormChangeManualTrigger } from "./pokemon-forms"; @@ -26,6 +24,7 @@ import { ArenaTagType } from "#enums/arena-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import { Stat, BattleStat, getStatKey } from "#app/enums/stat.js"; export class Ability implements Localizable { public id: Abilities; @@ -2473,7 +2472,7 @@ export class ProtectStatAbAttr extends PreStatChangeAbAttr { return i18next.t("abilityTriggers:protectStat", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName, - statName: this.protectedStat ? getBattleStatName(this.protectedStat) : i18next.t("battle:stats") + statName: this.protectedStat ? i18next.t(getStatKey(this.protectedStat)) : i18next.t("battle:stats") }); } } @@ -5300,19 +5299,19 @@ export function initAbilities() { .partial(), new Ability(Abilities.VESSEL_OF_RUIN, 9) .attr(FieldMultiplyBattleStatAbAttr, Stat.SPATK, 0.75) - .attr(PostSummonMessageAbAttr, (user) => i18next.t("abilityTriggers:postSummonVesselOfRuin", { pokemonNameWithAffix: getPokemonNameWithAffix(user), statName: getStatName(Stat.SPATK) })) + .attr(PostSummonMessageAbAttr, (user) => i18next.t("abilityTriggers:postSummonVesselOfRuin", { pokemonNameWithAffix: getPokemonNameWithAffix(user), statName: i18next.t(getStatKey(Stat.SPATK)) })) .ignorable(), new Ability(Abilities.SWORD_OF_RUIN, 9) .attr(FieldMultiplyBattleStatAbAttr, Stat.DEF, 0.75) - .attr(PostSummonMessageAbAttr, (user) => i18next.t("abilityTriggers:postSummonSwordOfRuin", { pokemonNameWithAffix: getPokemonNameWithAffix(user), statName: getStatName(Stat.DEF) })) + .attr(PostSummonMessageAbAttr, (user) => i18next.t("abilityTriggers:postSummonSwordOfRuin", { pokemonNameWithAffix: getPokemonNameWithAffix(user), statName: i18next.t(getStatKey(Stat.DEF)) })) .ignorable(), new Ability(Abilities.TABLETS_OF_RUIN, 9) .attr(FieldMultiplyBattleStatAbAttr, Stat.ATK, 0.75) - .attr(PostSummonMessageAbAttr, (user) => i18next.t("abilityTriggers:postSummonTabletsOfRuin", { pokemonNameWithAffix: getPokemonNameWithAffix(user), statName: getStatName(Stat.ATK) })) + .attr(PostSummonMessageAbAttr, (user) => i18next.t("abilityTriggers:postSummonTabletsOfRuin", { pokemonNameWithAffix: getPokemonNameWithAffix(user), statName: i18next.t(getStatKey(Stat.ATK)) })) .ignorable(), new Ability(Abilities.BEADS_OF_RUIN, 9) .attr(FieldMultiplyBattleStatAbAttr, Stat.SPDEF, 0.75) - .attr(PostSummonMessageAbAttr, (user) => i18next.t("abilityTriggers:postSummonBeadsOfRuin", { pokemonNameWithAffix: getPokemonNameWithAffix(user), statName: getStatName(Stat.SPDEF) })) + .attr(PostSummonMessageAbAttr, (user) => i18next.t("abilityTriggers:postSummonBeadsOfRuin", { pokemonNameWithAffix: getPokemonNameWithAffix(user), statName: i18next.t(getStatKey(Stat.SPDEF)) })) .ignorable(), new Ability(Abilities.ORICHALCUM_PULSE, 9) .attr(PostSummonWeatherChangeAbAttr, WeatherType.SUNNY) diff --git a/src/data/battle-stat.ts b/src/data/battle-stat.ts deleted file mode 100644 index 2c05fff2f7db..000000000000 --- a/src/data/battle-stat.ts +++ /dev/null @@ -1,51 +0,0 @@ -import i18next, { ParseKeys } from "i18next"; - -export enum BattleStat { - ATK, - DEF, - SPATK, - SPDEF, - SPD, - ACC, - EVA, - RAND, - HP -} - -export function getBattleStatName(stat: BattleStat) { - switch (stat) { - case BattleStat.ATK: - return i18next.t("pokemonInfo:Stat.ATK"); - case BattleStat.DEF: - return i18next.t("pokemonInfo:Stat.DEF"); - case BattleStat.SPATK: - return i18next.t("pokemonInfo:Stat.SPATK"); - case BattleStat.SPDEF: - return i18next.t("pokemonInfo:Stat.SPDEF"); - case BattleStat.SPD: - return i18next.t("pokemonInfo:Stat.SPD"); - case BattleStat.ACC: - return i18next.t("pokemonInfo:Stat.ACC"); - case BattleStat.EVA: - return i18next.t("pokemonInfo:Stat.EVA"); - case BattleStat.HP: - return i18next.t("pokemonInfo:Stat.HPStat"); - default: - return "???"; - } -} - -// TODO: BattleStat -export function getBattleStatLevelChangeDescription(pokemonNameWithAffix: string, stats: string, stages: integer, isIncrease: boolean, count: number = 1) { - let key: string; - if (stages === 1) { - key = isIncrease ? "battle:statRose" : "battle:statFell"; - } else if (stages === 2) { - key = isIncrease ? "battle:statSharplyRose" : "battle:statHarshlyFell"; - } else if (stages <= 6) { - key = isIncrease ? "battle:statRoseDrastically" : "battle:statSeverelyFell"; - } else { - key = isIncrease ? "battle:statWontGoAnyHigher" : "battle:statWontGoAnyLower"; - } - return i18next.t(key as ParseKeys, { pokemonNameWithAffix, stats, count }); -} diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 293b57c9ce6a..84acaa36a71f 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -2,7 +2,6 @@ import { ChargeAnim, CommonAnim, CommonBattleAnim, MoveChargeAnim } from "./batt import { CommonAnimPhase, MoveEffectPhase, MovePhase, PokemonHealPhase, ShowAbilityPhase, StatChangeCallback, StatChangePhase } from "../phases"; import { getPokemonNameWithAffix } from "../messages"; import Pokemon, { MoveResult, HitResult } from "../field/pokemon"; -import { Stat, getStatName } from "./pokemon-stat"; import { StatusEffect } from "./status-effect"; import * as Utils from "../utils"; import { ChargeAttr, MoveFlags, allMoves } from "./move"; @@ -10,7 +9,6 @@ import { Type } from "./type"; import { BlockNonDirectDamageAbAttr, FlinchEffectAbAttr, ReverseDrainAbAttr, applyAbAttrs } from "./ability"; import { TerrainType } from "./terrain"; import { WeatherType } from "./weather"; -import { BattleStat } from "./battle-stat"; import { allAbilities } from "./ability"; import { SpeciesFormChangeManualTrigger } from "./pokemon-forms"; import { Abilities } from "#enums/abilities"; @@ -18,7 +16,7 @@ import { BattlerTagType } from "#enums/battler-tag-type"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import i18next from "#app/plugins/i18n.js"; -import { PERMANENT_STATS } from "#app/enums/stat"; +import { Stat, BattleStat, EFFECTIVE_STATS, EffectiveStat, getStatKey } from "#app/enums/stat"; export enum BattlerTagLapseType { FAINT, @@ -1283,10 +1281,10 @@ export class HighestStatBoostTag extends AbilityBattlerTag { onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); - let highestStat: Stat; - PERMANENT_STATS.map(s => pokemon.getEffectiveStat(s)).reduce((highestValue: number, value: number, i: number) => { + let highestStat: EffectiveStat; + EFFECTIVE_STATS.map(s => pokemon.getEffectiveStat(s)).reduce((highestValue: number, value: number, i: number) => { if (value > highestValue) { - highestStat = PERMANENT_STATS[i]; + highestStat = EFFECTIVE_STATS[i]; return value; } return highestValue; @@ -1304,7 +1302,7 @@ export class HighestStatBoostTag extends AbilityBattlerTag { break; } - pokemon.scene.queueMessage(i18next.t("battle:battlerTagsHighestStatBoostOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), statName: getStatName(highestStat) }), null, false, null, true); + pokemon.scene.queueMessage(i18next.t("battle:battlerTagsHighestStatBoostOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), statName: getStatKey(highestStat) }), null, false, null, true); } onRemove(pokemon: Pokemon): void { diff --git a/src/data/move.ts b/src/data/move.ts index 6f8b3cdc1186..f0b86cb88062 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1,6 +1,5 @@ import { ChargeAnim, MoveChargeAnim, initMoveAnim, loadMoveAnimAssets } from "./battle-anims"; import { BattleEndPhase, MoveEndPhase, MovePhase, NewBattlePhase, PartyStatusCurePhase, PokemonHealPhase, StatChangePhase, SwitchPhase, SwitchSummonPhase } from "../phases"; -import { getBattleStatName } from "./battle-stat"; import { EncoreTag, GulpMissileTag, HelpingHandTag, SemiInvulnerableTag, StockpilingTag, TypeBoostTag } from "./battler-tags"; import { getPokemonNameWithAffix } from "../messages"; import Pokemon, { AttackMoveResult, EnemyPokemon, HitResult, MoveResult, PlayerPokemon, PokemonMove, TurnMove } from "../field/pokemon"; @@ -14,7 +13,6 @@ import { UnswappableAbilityAbAttr, UncopiableAbilityAbAttr, UnsuppressableAbilit import { allAbilities } from "./ability"; import { PokemonHeldItemModifier, BerryModifier, PreserveBerryModifier, PokemonMoveAccuracyBoosterModifier, AttackTypeBoosterModifier, PokemonMultiHitModifier } from "../modifier/modifier"; import { BattlerIndex, BattleType } from "../battle"; -import { Stat } from "./pokemon-stat"; import { TerrainType } from "./terrain"; import { ModifierPoolType } from "#app/modifier/modifier-type"; import { Command } from "../ui/command-ui-handler"; @@ -28,7 +26,7 @@ import { Biome } from "#enums/biome"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import { MoveUsedEvent } from "#app/events/battle-scene.js"; -import { BATTLE_STATS, BattleStat, EFFECTIVE_STATS, EffectiveStat } from "#app/enums/stat"; +import { Stat, BATTLE_STATS, BattleStat, EFFECTIVE_STATS, EffectiveStat, getStatKey } from "#app/enums/stat"; export enum MoveCategory { PHYSICAL, @@ -6668,7 +6666,7 @@ export function initMoves() { .attr(ConfuseAttr), new SelfStatusMove(Moves.BELLY_DRUM, Type.NORMAL, -1, 10, -1, 0, 2) .attr(CutHpStatBoostAttr, [ Stat.ATK ], 12, 2, (user) => { - user.scene.queueMessage(i18next.t("moveTriggers:cutOwnHpAndMaximizedStat", {pokemonName: getPokemonNameWithAffix(user), statName: getBattleStatName(BattleStat.ATK)})); // TODO: BattleStats + user.scene.queueMessage(i18next.t("moveTriggers:cutOwnHpAndMaximizedStat", { pokemonName: getPokemonNameWithAffix(user), statName: i18next.t(getStatKey(Stat.ATK)) })); // TODO: BattleStats }), new AttackMove(Moves.SLUDGE_BOMB, Type.POISON, MoveCategory.SPECIAL, 90, 100, 10, 30, 0, 2) .attr(StatusEffectAttr, StatusEffect.POISON) diff --git a/src/data/nature.ts b/src/data/nature.ts index 72e5bb7863c7..3da405ab293b 100644 --- a/src/data/nature.ts +++ b/src/data/nature.ts @@ -1,9 +1,9 @@ -import { Stat, getStatName } from "./pokemon-stat"; import * as Utils from "../utils"; import { TextStyle, getBBCodeFrag } from "../ui/text"; import { Nature } from "#enums/nature"; import { UiTheme } from "#enums/ui-theme"; import i18next from "i18next"; +import { Stat, EFFECTIVE_STATS, getShortenedStatKey } from "#app/enums/stat.js"; export { Nature }; @@ -14,10 +14,9 @@ export function getNatureName(nature: Nature, includeStatEffects: boolean = fals ret = i18next.t("nature:" + ret as any); } if (includeStatEffects) { - const stats = Utils.getEnumValues(Stat).slice(1); let increasedStat: Stat | null = null; let decreasedStat: Stat | null = null; - for (const stat of stats) { + for (const stat of EFFECTIVE_STATS) { const multiplier = getNatureStatMultiplier(nature, stat); if (multiplier > 1) { increasedStat = stat; @@ -28,7 +27,7 @@ export function getNatureName(nature: Nature, includeStatEffects: boolean = fals const textStyle = forStarterSelect ? TextStyle.SUMMARY_ALT : TextStyle.WINDOW; const getTextFrag = !ignoreBBCode ? (text: string, style: TextStyle) => getBBCodeFrag(text, style, uiTheme) : (text: string, style: TextStyle) => text; if (increasedStat && decreasedStat) { - ret = `${getTextFrag(`${ret}${!forStarterSelect ? "\n" : " "}(`, textStyle)}${getTextFrag(`+${getStatName(increasedStat, true)}`, TextStyle.SUMMARY_PINK)}${getTextFrag("/", textStyle)}${getTextFrag(`-${getStatName(decreasedStat, true)}`, TextStyle.SUMMARY_BLUE)}${getTextFrag(")", textStyle)}`; + ret = `${getTextFrag(`${ret}${!forStarterSelect ? "\n" : " "}(`, textStyle)}${getTextFrag(`+${i18next.t(getShortenedStatKey(increasedStat))}`, TextStyle.SUMMARY_PINK)}${getTextFrag("/", textStyle)}${getTextFrag(`-${getShortenedStatKey(decreasedStat)}`, TextStyle.SUMMARY_BLUE)}${getTextFrag(")", textStyle)}`; } else { ret = getTextFrag(`${ret}${!forStarterSelect ? "\n" : " "}(-)`, textStyle); } diff --git a/src/data/pokemon-stat.ts b/src/data/pokemon-stat.ts deleted file mode 100644 index 16570785a62c..000000000000 --- a/src/data/pokemon-stat.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Stat } from "#enums/stat"; -import i18next from "i18next"; - -export { Stat }; - -export function getStatName(stat: Stat, shorten: boolean = false) { - let ret: string = ""; - switch (stat) { - case Stat.HP: - ret = !shorten ? i18next.t("pokemonInfo:Stat.HP") : i18next.t("pokemonInfo:Stat.HPshortened"); - break; - case Stat.ATK: - ret = !shorten ? i18next.t("pokemonInfo:Stat.ATK") : i18next.t("pokemonInfo:Stat.ATKshortened"); - break; - case Stat.DEF: - ret = !shorten ? i18next.t("pokemonInfo:Stat.DEF") : i18next.t("pokemonInfo:Stat.DEFshortened"); - break; - case Stat.SPATK: - ret = !shorten ? i18next.t("pokemonInfo:Stat.SPATK") : i18next.t("pokemonInfo:Stat.SPATKshortened"); - break; - case Stat.SPDEF: - ret = !shorten ? i18next.t("pokemonInfo:Stat.SPDEF") : i18next.t("pokemonInfo:Stat.SPDEFshortened"); - break; - case Stat.SPD: - ret = !shorten ? i18next.t("pokemonInfo:Stat.SPD") : i18next.t("pokemonInfo:Stat.SPDshortened"); - break; - } - return ret; -} diff --git a/src/enums/stat.ts b/src/enums/stat.ts index 01ce4153610a..61a34a24ad4b 100644 --- a/src/enums/stat.ts +++ b/src/enums/stat.ts @@ -28,3 +28,22 @@ export type BattleStat = typeof BATTLE_STATS[number]; export const TEMP_BATTLE_STATS = [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD, Stat.ACC ] as const; export type TempBattleStat = typeof TEMP_BATTLE_STATS[number]; + +export function getStatStageChangeDescriptionKey(stages: integer, isIncrease: boolean) { + if (stages === 1) { + return isIncrease ? "battle:statRose" : "battle:statFell"; + } else if (stages === 2) { + return isIncrease ? "battle:statSharplyRose" : "battle:statHarshlyFell"; + } else if (stages <= 6) { + return isIncrease ? "battle:statRoseDrastically" : "battle:statSeverelyFell"; + } + return isIncrease ? "battle:statWontGoAnyHigher" : "battle:statWontGoAnyLower"; +} + +export function getStatKey(stat: Stat) { + return `pokemonInfo:Stat.${Stat[stat]}`; +} + +export function getShortenedStatKey(stat: PermanentStat) { + return `pokemonInfo:Stat.${Stat[stat]}shortened`; +} diff --git a/src/locales/de/pokemon-info.ts b/src/locales/de/pokemon-info.ts index b926c0c51156..08a23de2b3ae 100644 --- a/src/locales/de/pokemon-info.ts +++ b/src/locales/de/pokemon-info.ts @@ -3,7 +3,6 @@ import { PokemonInfoTranslationEntries } from "#app/interfaces/locales"; export const pokemonInfo: PokemonInfoTranslationEntries = { Stat: { "HP": "KP", - "HPStat": "KP", "HPshortened": "KP", "ATK": "Angriff", "ATKshortened": "Ang", diff --git a/src/locales/en/pokemon-info.ts b/src/locales/en/pokemon-info.ts index 70a06294c761..95325bad2977 100644 --- a/src/locales/en/pokemon-info.ts +++ b/src/locales/en/pokemon-info.ts @@ -3,7 +3,7 @@ import { PokemonInfoTranslationEntries } from "#app/interfaces/locales"; export const pokemonInfo: PokemonInfoTranslationEntries = { Stat: { "HP": "Max. HP", - "HPshortened": "MaxHP", + "HPshortened": "HP", "ATK": "Attack", "ATKshortened": "Atk", "DEF": "Defense", @@ -16,7 +16,6 @@ export const pokemonInfo: PokemonInfoTranslationEntries = { "SPDshortened": "Spd", "ACC": "Accuracy", "EVA": "Evasiveness", - "HPStat": "HP" }, Type: { diff --git a/src/locales/zh_CN/pokemon-info.ts b/src/locales/zh_CN/pokemon-info.ts index f7aaf3a33cb7..84b6e6d03fc9 100644 --- a/src/locales/zh_CN/pokemon-info.ts +++ b/src/locales/zh_CN/pokemon-info.ts @@ -3,7 +3,7 @@ import { PokemonInfoTranslationEntries } from "#app/interfaces/locales"; export const pokemonInfo: PokemonInfoTranslationEntries = { Stat: { "HP": "最大HP", - "HPshortened": "最大HP", + "HPshortened": "HP", "ATK": "攻击", "ATKshortened": "攻击", "DEF": "防御", diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 93ebee3d7a82..f0ef4c73ed61 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -26,7 +26,7 @@ import { BerryType } from "#enums/berry-type"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import { getPokemonNameWithAffix } from "#app/messages.js"; -import { PermanentStat, TEMP_BATTLE_STATS, TempBattleStat, Stat } from "#app/enums/stat"; +import { PermanentStat, TEMP_BATTLE_STATS, TempBattleStat, Stat, getStatKey } from "#app/enums/stat"; const outputModifierData = false; const useMaxWeightForOutput = false; @@ -443,7 +443,7 @@ export class TempStatStageBoosterModifierType extends ModifierType implements Ge } getDescription(_scene: BattleScene): string { - return i18next.t("modifierType:ModifierType.TempStatStageBoosterModifierType.description", { stat: i18next.t(`pokemonInfo:Stat.${Stat[this.stat]}`) }); + return i18next.t("modifierType:ModifierType.TempStatStageBoosterModifierType.description", { stat: i18next.t(getStatKey(this.stat)) }); } getPregenArgs(): any[] { @@ -609,7 +609,7 @@ export class BaseStatBoosterModifierType extends PokemonHeldItemModifierType imp } getDescription(_scene: BattleScene): string { - return i18next.t("modifierType:ModifierType.BaseStatBoosterModifierType.description", { stat: i18next.t(`pokemonInfo:Stat.${Stat[this.stat]}`) }); + return i18next.t("modifierType:ModifierType.BaseStatBoosterModifierType.description", { stat: i18next.t(getStatKey(this.stat)) }); } getPregenArgs(): any[] { diff --git a/src/phases.ts b/src/phases.ts index dc924983adbc..6fe3e19f6c49 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1,10 +1,9 @@ import BattleScene, { bypassLogin } from "./battle-scene"; import { default as Pokemon, PlayerPokemon, EnemyPokemon, PokemonMove, MoveResult, DamageResult, FieldPosition, HitResult, TurnMove } from "./field/pokemon"; import * as Utils from "./utils"; -import { allMoves, applyMoveAttrs, BypassSleepAttr, ChargeAttr, applyFilteredMoveAttrs, HitsTagAttr, MissEffectAttr, MoveAttr, MoveEffectAttr, MoveFlags, MultiHitAttr, OverrideMoveEffectAttr, MoveTarget, getMoveTargets, MoveTargetSet, MoveEffectTrigger, CopyMoveAttr, AttackMove, SelfStatusMove, PreMoveMessageAttr, HealStatusEffectAttr, NoEffectAttr, BypassRedirectAttr, FixedDamageAttr, PostVictoryStatChangeAttr, ForceSwitchOutAttr, VariableTargetAttr, IncrementMovePriorityAttr, MoveHeaderAttr } from "./data/move"; +import { allMoves, applyMoveAttrs, BypassSleepAttr, ChargeAttr, applyFilteredMoveAttrs, HitsTagAttr, MissEffectAttr, MoveAttr, MoveEffectAttr, MoveFlags, MultiHitAttr, OverrideMoveEffectAttr, MoveTarget, getMoveTargets, MoveTargetSet, MoveEffectTrigger, CopyMoveAttr, AttackMove, SelfStatusMove, PreMoveMessageAttr, HealStatusEffectAttr, NoEffectAttr, BypassRedirectAttr, FixedDamageAttr, PostVictoryStatStageChangeAttr, ForceSwitchOutAttr, VariableTargetAttr, IncrementMovePriorityAttr, MoveHeaderAttr } from "./data/move"; import { Mode } from "./ui/ui"; import { Command } from "./ui/command-ui-handler"; -import { Stat } from "./data/pokemon-stat"; import { BerryModifier, ContactHeldItemTransferChanceModifier, EnemyAttackStatusEffectChanceModifier, EnemyPersistentModifier, EnemyStatusEffectHealChanceModifier, EnemyTurnHealModifier, ExpBalanceModifier, ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, FlinchChanceModifier, HealingBoosterModifier, HitHealModifier, LapsingPersistentModifier, MapModifier, Modifier, MultipleParticipantExpBonusModifier, PokemonExpBoosterModifier, PokemonHeldItemModifier, PokemonInstantReviveModifier, SwitchEffectTransferModifier, TurnHealModifier, TurnHeldItemTransferModifier, MoneyMultiplierModifier, MoneyInterestModifier, IvScannerModifier, LapsingPokemonHeldItemModifier, PokemonMultiHitModifier, overrideModifiers, overrideHeldItems, BypassSpeedChanceModifier, TurnStatusEffectModifier, ResetNegativeStatStageModifier } from "./modifier/modifier"; import PartyUiHandler, { PartyOption, PartyUiMode } from "./ui/party-ui-handler"; import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor, PokeballType } from "./data/pokeball"; @@ -14,8 +13,6 @@ import { SummaryUiMode } from "./ui/summary-ui-handler"; import EvolutionSceneHandler from "./ui/evolution-scene-handler"; import { EvolutionPhase } from "./evolution-phase"; import { Phase } from "./phase"; -import { getBattleStatLevelChangeDescription, getBattleStatName } from "./data/battle-stat"; -import { BattleStat } from "./enums/stat"; import { biomeLinks, getBiomeName } from "./data/biomes"; import { ModifierTier } from "./modifier/modifier-tier"; import { FusePokemonModifierType, ModifierPoolType, ModifierType, ModifierTypeFunc, ModifierTypeOption, PokemonModifierType, PokemonMoveModifierType, PokemonPpRestoreModifierType, PokemonPpUpModifierType, RememberMoveModifierType, TmModifierType, getDailyRunStarterModifiers, getEnemyBuffModifierForWave, getModifierType, getPlayerModifierTypeOptions, getPlayerShopModifierTypeOptionsForWave, modifierTypes, regenerateModifierPoolThresholds } from "./modifier/modifier-type"; @@ -67,6 +64,7 @@ import { Species } from "#enums/species"; import { TrainerType } from "#enums/trainer-type"; import { applyChallenges, ChallengeType } from "./data/challenge"; import { pokemonEvolutions } from "./data/pokemon-evolutions"; +import { Stat, BattleStat, getStatKey, getStatStageChangeDescriptionKey } from "#enums/stat"; const { t } = i18next; @@ -3658,11 +3656,19 @@ export class StatChangePhase extends PokemonPhase { // TODO: BattleStat if (relLevelStats.length > 1) { statsFragment = relLevelStats.length >= 5 ? i18next.t("battle:stats") - : `${relLevelStats.slice(0, -1).map(s => getBattleStatName(s)).join(", ")}${relLevelStats.length > 2 ? "," : ""} ${i18next.t("battle:statsAnd")} ${getBattleStatName(relLevelStats[relLevelStats.length - 1])}`; - messages.push(getBattleStatLevelChangeDescription(getPokemonNameWithAffix(this.getPokemon()), statsFragment, Math.abs(parseInt(rl)), levels >= 1,relLevelStats.length)); + : `${relLevelStats.slice(0, -1).map(s => i18next.t(getStatKey(s))).join(", ")}${relLevelStats.length > 2 ? "," : ""} ${i18next.t("battle:statsAnd")} ${i18next.t(getStatKey(relLevelStats[relLevelStats.length - 1]))}`; + messages.push(i18next.t(getStatStageChangeDescriptionKey(Math.abs(parseInt(rl)), levels >= 1), { + pokemonNameWithAffix: getPokemonNameWithAffix(this.getPokemon()), + stats: statsFragment, + count: relLevelStats.length + })); } else { - statsFragment = getBattleStatName(relLevelStats[0]); - messages.push(getBattleStatLevelChangeDescription(getPokemonNameWithAffix(this.getPokemon()), statsFragment, Math.abs(parseInt(rl)), levels >= 1,relLevelStats.length)); + statsFragment = i18next.t(getStatKey(relLevelStats[0])); + messages.push(i18next.t(getStatStageChangeDescriptionKey(Math.abs(parseInt(rl)), levels >= 1), { + pokemonNameWithAffix: getPokemonNameWithAffix(this.getPokemon()), + stats: statsFragment, + count: relLevelStats.length + })); } }); @@ -3986,7 +3992,7 @@ export class FaintPhase extends PokemonPhase { if (defeatSource?.isOnField()) { applyPostVictoryAbAttrs(PostVictoryAbAttr, defeatSource); const pvmove = allMoves[pokemon.turnData.attacksReceived[0].move]; - const pvattrs = pvmove.getAttrs(PostVictoryStatChangeAttr); + const pvattrs = pvmove.getAttrs(PostVictoryStatStageChangeAttr); if (pvattrs.length) { for (const pvattr of pvattrs) { pvattr.applyPostVictory(defeatSource, defeatSource, pvmove); diff --git a/src/system/achv.ts b/src/system/achv.ts index 040a48d9a7ef..660d4f9a319a 100644 --- a/src/system/achv.ts +++ b/src/system/achv.ts @@ -8,6 +8,7 @@ import { PlayerGender } from "#enums/player-gender"; import { ParseKeys } from "i18next"; import { Challenge, FreshStartChallenge, SingleGenerationChallenge, SingleTypeChallenge } from "#app/data/challenge.js"; import { ConditionFn } from "#app/@types/common.js"; +import { getShortenedStatKey, Stat } from "#app/enums/stat.js"; export enum AchvTier { COMMON, @@ -178,13 +179,13 @@ export function getAchievementDescription(localizationKey: string): string { case "10000_DMG": return i18next.t(`${genderPrefix}achv:DamageAchv.description` as ParseKeys, {"damageAmount": achvs._10000_DMG.damageAmount.toLocaleString("en-US")}); case "250_HEAL": - return i18next.t(`${genderPrefix}achv:HealAchv.description` as ParseKeys, {"healAmount": achvs._250_HEAL.healAmount.toLocaleString("en-US"), "HP": i18next.t("pokemonInfo:Stat.HPshortened")}); + return i18next.t(`${genderPrefix}achv:HealAchv.description` as ParseKeys, {"healAmount": achvs._250_HEAL.healAmount.toLocaleString("en-US"), "HP": i18next.t(getShortenedStatKey(Stat.HP)) }); case "1000_HEAL": - return i18next.t(`${genderPrefix}achv:HealAchv.description` as ParseKeys, {"healAmount": achvs._1000_HEAL.healAmount.toLocaleString("en-US"), "HP": i18next.t("pokemonInfo:Stat.HPshortened")}); + return i18next.t(`${genderPrefix}achv:HealAchv.description` as ParseKeys, {"healAmount": achvs._1000_HEAL.healAmount.toLocaleString("en-US"), "HP": i18next.t(getShortenedStatKey(Stat.HP)) }); case "2500_HEAL": - return i18next.t(`${genderPrefix}achv:HealAchv.description` as ParseKeys, {"healAmount": achvs._2500_HEAL.healAmount.toLocaleString("en-US"), "HP": i18next.t("pokemonInfo:Stat.HPshortened")}); + return i18next.t(`${genderPrefix}achv:HealAchv.description` as ParseKeys, {"healAmount": achvs._2500_HEAL.healAmount.toLocaleString("en-US"), "HP": i18next.t(getShortenedStatKey(Stat.HP)) }); case "10000_HEAL": - return i18next.t(`${genderPrefix}achv:HealAchv.description` as ParseKeys, {"healAmount": achvs._10000_HEAL.healAmount.toLocaleString("en-US"), "HP": i18next.t("pokemonInfo:Stat.HPshortened")}); + return i18next.t(`${genderPrefix}achv:HealAchv.description` as ParseKeys, {"healAmount": achvs._10000_HEAL.healAmount.toLocaleString("en-US"), "HP": i18next.t(getShortenedStatKey(Stat.HP)) }); case "LV_100": return i18next.t(`${genderPrefix}achv:LevelAchv.description` as ParseKeys, {"level": achvs.LV_100.level}); case "LV_250": diff --git a/src/ui/battle-message-ui-handler.ts b/src/ui/battle-message-ui-handler.ts index 1c7dfb276300..88efaa389880 100644 --- a/src/ui/battle-message-ui-handler.ts +++ b/src/ui/battle-message-ui-handler.ts @@ -3,11 +3,11 @@ import { addBBCodeTextObject, addTextObject, getTextColor, TextStyle } from "./t import { Mode } from "./ui"; import * as Utils from "../utils"; import MessageUiHandler from "./message-ui-handler"; -import { getStatName, Stat } from "../data/pokemon-stat"; import { addWindow } from "./ui-theme"; import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; import {Button} from "#enums/buttons"; import i18next from "i18next"; +import { Stat, getStatKey, PERMANENT_STATS } from "#app/enums/stat.js"; export default class BattleMessageUiHandler extends MessageUiHandler { private levelUpStatsContainer: Phaser.GameObjects.Container; @@ -98,9 +98,8 @@ export default class BattleMessageUiHandler extends MessageUiHandler { const levelUpStatsLabelsContent = addTextObject(this.scene, (this.scene.game.canvas.width / 6) - 73, -94, "", TextStyle.WINDOW, { maxLines: 6 }); let levelUpStatsLabelText = ""; - const stats = Utils.getEnumValues(Stat); - for (const s of stats) { - levelUpStatsLabelText += `${getStatName(s)}\n`; + for (const s of PERMANENT_STATS) { + levelUpStatsLabelText += `${getStatKey(s)}\n`; } levelUpStatsLabelsContent.text = levelUpStatsLabelText; levelUpStatsLabelsContent.x -= levelUpStatsLabelsContent.displayWidth; diff --git a/src/ui/stats-container.ts b/src/ui/stats-container.ts index b4e799bafc01..5aab5268c863 100644 --- a/src/ui/stats-container.ts +++ b/src/ui/stats-container.ts @@ -1,7 +1,7 @@ import BBCodeText from "phaser3-rex-plugins/plugins/gameobjects/tagtext/bbcodetext/BBCodeText"; import BattleScene from "../battle-scene"; -import { Stat, getStatName } from "../data/pokemon-stat"; import { TextStyle, addBBCodeTextObject, addTextObject, getTextColor } from "./text"; +import { getStatKey, PERMANENT_STATS } from "#app/enums/stat.js"; const ivChartSize = 24; const ivChartStatCoordMultipliers = [[0, -1], [0.825, -0.5], [0.825, 0.5], [-0.825, -0.5], [-0.825, 0.5], [0, 1]]; @@ -53,16 +53,16 @@ export class StatsContainer extends Phaser.GameObjects.Container { this.ivStatValueTexts = []; - new Array(6).fill(null).map((_, i: integer) => { - const statLabel = addTextObject(this.scene, ivChartBg.x + (ivChartSize) * ivChartStatCoordMultipliers[i][0] * 1.325, ivChartBg.y + (ivChartSize) * ivChartStatCoordMultipliers[i][1] * 1.325 - 4 + ivLabelOffset[i], getStatName(i as Stat), TextStyle.TOOLTIP_CONTENT); + for (const s of PERMANENT_STATS) { + const statLabel = addTextObject(this.scene, ivChartBg.x + (ivChartSize) * ivChartStatCoordMultipliers[s][0] * 1.325, ivChartBg.y + (ivChartSize) * ivChartStatCoordMultipliers[s][1] * 1.325 - 4 + ivLabelOffset[s], getStatKey(s), TextStyle.TOOLTIP_CONTENT); statLabel.setOrigin(0.5); - this.ivStatValueTexts[i] = addBBCodeTextObject(this.scene, statLabel.x, statLabel.y + 8, "0", TextStyle.TOOLTIP_CONTENT); - this.ivStatValueTexts[i].setOrigin(0.5); + this.ivStatValueTexts[s] = addBBCodeTextObject(this.scene, statLabel.x, statLabel.y + 8, "0", TextStyle.TOOLTIP_CONTENT); + this.ivStatValueTexts[s].setOrigin(0.5); this.add(statLabel); - this.add(this.ivStatValueTexts[i]); - }); + this.add(this.ivStatValueTexts[s]); + } } updateIvs(ivs: integer[], originalIvs?: integer[]): void { diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index 030e67fcc30b..eb4a14ad81a7 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -11,7 +11,6 @@ import Move, { MoveCategory } from "../data/move"; import { getPokeballAtlasKey } from "../data/pokeball"; import { getGenderColor, getGenderSymbol } from "../data/gender"; import { getLevelRelExp, getLevelTotalExp } from "../data/exp"; -import { Stat, getStatName } from "../data/pokemon-stat"; import { PokemonHeldItemModifier } from "../modifier/modifier"; import { StatusEffect } from "../data/status-effect"; import { getBiomeName } from "../data/biomes"; @@ -23,6 +22,7 @@ import { Ability } from "../data/ability.js"; import i18next from "i18next"; import {modifierSortFunc} from "../modifier/modifier"; import { PlayerGender } from "#enums/player-gender"; +import { Stat, getStatKey, PERMANENT_STATS } from "#app/enums/stat.js"; enum Page { PROFILE, @@ -838,10 +838,8 @@ export default class SummaryUiHandler extends UiHandler { const statsContainer = this.scene.add.container(0, -pageBg.height); pageContainer.add(statsContainer); - const stats = Utils.getEnumValues(Stat) as Stat[]; - - stats.forEach((stat, s) => { - const statName = getStatName(stat); + PERMANENT_STATS.forEach((stat, s) => { + const statName = getStatKey(stat); const rowIndex = s % 3; const colIndex = Math.floor(s / 3); @@ -852,7 +850,7 @@ export default class SummaryUiHandler extends UiHandler { statsContainer.add(statLabel); const statValueText = stat !== Stat.HP - ? Utils.formatStat(this.pokemon?.stats[s]!) // TODO: is this bang correct? + ? Utils.formatStat(this.pokemon?.getStat(stat)!) // TODO: is this bang correct? : `${Utils.formatStat(this.pokemon?.hp!, true)}/${Utils.formatStat(this.pokemon?.getMaxHp()!, true)}`; // TODO: are those bangs correct? const statValue = addTextObject(this.scene, 120 + 88 * colIndex, 56 + 16 * rowIndex, statValueText, TextStyle.WINDOW_ALT);