From f11db0d6d8bb1a50beebbe40f017729641742517 Mon Sep 17 00:00:00 2001 From: flx-sta <50131232+flx-sta@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:03:08 -0700 Subject: [PATCH] fix after-you issues - fix i18n interpolation ot state "target name" and not "pokemon name" as the target takes the offer, not the user - fix some tsdocs - add override to apply - update scene.findPhase to be able to use generic types. Add tsdocs --- src/battle-scene.ts | 10 ++++++++-- src/data/move.ts | 20 ++++++++++++-------- src/locales/de/move-trigger.json | 3 ++- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 9123a213f4c..50ac1019278 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -2193,8 +2193,14 @@ export default class BattleScene extends SceneBase { return true; } - findPhase(phaseFilter: (phase: Phase) => boolean): Phase | undefined { - return this.phaseQueue.find(phaseFilter); + /** + * Find a specific {@linkcode Phase} in the phase queue. + * + * @param phaseFilter filter function to use to find the wanted phase + * @returns the found phase or undefined if none found + */ + findPhase

(phaseFilter: (phase: P) => boolean): P | undefined { + return this.phaseQueue.find(phaseFilter) as P; } tryReplacePhase(phaseFilter: (phase: Phase) => boolean, phase: Phase): boolean { diff --git a/src/data/move.ts b/src/data/move.ts index d886f4272d3..b55717f40e2 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -6217,23 +6217,27 @@ export class VariableTargetAttr extends MoveAttr { } } +/** + * Attribute for {@linkcode Moves.AFTER_YOU} + * + * [After You - Move | Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/After_You_(move)) + */ export class AfterYouAttr extends MoveEffectAttr { /** * Allows the target of this move to act right after the user. + * * @param user {@linkcode Pokemon} that is using the move. * @param target {@linkcode Pokemon} that will move right after this move is used. * @param move {@linkcode Move} {@linkcode Moves.AFTER_YOU} - * @param {any[]} args N/A + * @param _args N/A * @returns true */ - apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - user.scene.queueMessage(i18next.t("moveTriggers:afterYou", {pokemonName: getPokemonNameWithAffix(target)})); + override apply(user: Pokemon, target: Pokemon, _move: Move, _args: any[]): boolean { + user.scene.queueMessage(i18next.t("moveTriggers:afterYou", {targetName: getPokemonNameWithAffix(target)})); - /* Will find next acting phase of the targeted pokémon, - delete it and queue it next on successful delete. */ - - const nextAttackPhase: MovePhase = target.scene.findPhase((phase: MovePhase) => phase.pokemon === target) as MovePhase; - if (target.scene.tryRemovePhase((phase: MovePhase) => phase.pokemon === target)) { + //Will find next acting phase of the targeted pokémon, delete it and queue it next on successful delete. + const nextAttackPhase = target.scene.findPhase((phase) => phase.pokemon === target); + if (nextAttackPhase && target.scene.tryRemovePhase((phase: MovePhase) => phase.pokemon === target)) { target.scene.prependToPhase(new MovePhase(target.scene, target, [...nextAttackPhase.targets], nextAttackPhase.move), MovePhase); } diff --git a/src/locales/de/move-trigger.json b/src/locales/de/move-trigger.json index 61283c9e62e..ca5aeb192dd 100644 --- a/src/locales/de/move-trigger.json +++ b/src/locales/de/move-trigger.json @@ -66,5 +66,6 @@ "revivalBlessing": "{{pokemonName}} ist wieder fit und kampfbereit!", "swapArenaTags": "{{pokemonName}} hat die Effekte, die auf den beiden Seiten des Kampffeldes wirken, miteinander getauscht!", "exposedMove": "{{pokemonName}} erkennt {{targetPokemonName}}!", - "safeguard": "{{targetName}} wird durch Bodyguard geschützt!" + "safeguard": "{{targetName}} wird durch Bodyguard geschützt!", + "afterYou": "{{targetName}} took the kind offer!" }