From 272a3a31f2a64afec19d53d0e737e3e93cb387a5 Mon Sep 17 00:00:00 2001 From: xsn34kzx Date: Wed, 21 Aug 2024 00:48:56 -0400 Subject: [PATCH] Add Move Effect Message to Power & Guard Split --- src/data/move.ts | 45 ++++++++++++++++++++-------------- src/locales/en/move-trigger.ts | 2 ++ 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 53b14e2591c..8e881a211d2 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -5912,37 +5912,46 @@ export class SwapStatAttr extends MoveEffectAttr { /** * Attribute used for status moves, namely Power Split and Guard Split, * that take the average of a user's and target's corresponding - * stats and assign that average back to that stat. + * stats and assign that average back to each corresponding stat. * @extends MoveEffectAttr * @see {@linkcode apply} */ -export class AverageStatAttr extends MoveEffectAttr { - /** The stat to be averaged between the user and the target */ - private stat: EffectiveStat; +export class AverageStatsAttr extends MoveEffectAttr { + /** The stats to be averaged individually between the user and the target */ + private stats: readonly EffectiveStat[]; + private msgKey: string; - constructor(stat: EffectiveStat) { + constructor(stats: readonly EffectiveStat[], msgKey: string) { super(); - this.stat = stat; + this.stats = stats; + this.msgKey = msgKey; } /** - * Takes the average of the user's and target's corresponding current - * {@linkcode stat} values and sets that stat to the average for both + * Takes the average of the user's and target's corresponding {@linkcode stat} + * values and sets those stats to the corresponding average for both * temporarily. * @param user the {@linkcode Pokemon} that used the move * @param target the {@linkcode Pokemon} that the move was used on - * @param _move N/A - * @param _args N/A + * @param move N/A + * @param args N/A * @returns true if attribute application succeeds */ - apply(user: Pokemon, target: Pokemon, _move: Move, _args: any[]): boolean { - const avg = Math.floor((user.getStat(this.stat, false) + target.getStat(this.stat, false)) / 2); + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + if (super.apply(user, target, move, args)) { + for (const s of this.stats) { + const avg = Math.floor((user.getStat(s, false) + target.getStat(s, false)) / 2); - user.setStat(this.stat, avg, false); - target.setStat(this.stat, avg, false); + user.setStat(s, avg, false); + target.setStat(s, avg, false); + } - return true; + user.scene.queueMessage(i18next.t(this.msgKey, { pokemonName: getPokemonNameWithAffix(user) })); + + return true; + } + return false; } } @@ -7600,11 +7609,9 @@ export function initMoves() { .target(MoveTarget.USER_SIDE) .attr(AddArenaTagAttr, ArenaTagType.WIDE_GUARD, 1, true, true), new StatusMove(Moves.GUARD_SPLIT, Type.PSYCHIC, -1, 10, -1, 0, 5) - .attr(AverageStatAttr, Stat.DEF) - .attr(AverageStatAttr, Stat.SPDEF), + .attr(AverageStatsAttr, [ Stat.DEF, Stat.SPDEF ], "moveTriggers:guardSplit"), new StatusMove(Moves.POWER_SPLIT, Type.PSYCHIC, -1, 10, -1, 0, 5) - .attr(AverageStatAttr, Stat.ATK) - .attr(AverageStatAttr, Stat.SPATK), + .attr(AverageStatsAttr, [ Stat.ATK, Stat.SPATK ], "moveTriggers:powerSplit"), new StatusMove(Moves.WONDER_ROOM, Type.PSYCHIC, -1, 10, -1, 0, 5) .ignoresProtect() .target(MoveTarget.BOTH_SIDES) diff --git a/src/locales/en/move-trigger.ts b/src/locales/en/move-trigger.ts index 925d3f11d59..d6bf2544321 100644 --- a/src/locales/en/move-trigger.ts +++ b/src/locales/en/move-trigger.ts @@ -7,6 +7,8 @@ export const moveTriggers: SimpleTranslationEntries = { "switchedStatChanges": "{{pokemonName}} switched stat changes with the target!", "switchedTwoStatChanges": "{{pokemonName}} switched all changes to its {{firstStat}}\nand {{secondStat}} with its target!", "swappedStat": "{{pokemonName}} switched {{stat}} with its target!", + "guardSplit": "{{pokemonName}} shared its guard with the target!", + "powerSplit": "{{pokemonName}} shared its power with the target!", "goingAllOutForAttack": "{{pokemonName}} is going all out for this attack!", "regainedHealth": "{{pokemonName}} regained\nhealth!", "keptGoingAndCrashed": "{{pokemonName}} kept going\nand crashed!",