From 669ed76daf07214b0254a5a1dc69780871143df7 Mon Sep 17 00:00:00 2001 From: Bertie690 <136088738+Bertie690@users.noreply.github.com> Date: Thu, 4 Sep 2025 05:01:24 -0400 Subject: [PATCH] [Misc] Cleaned up implementation of `ChargeMove` mixin (#6466) Co-authored-by: Wlowscha <54003515+Wlowscha@users.noreply.github.com> --- src/data/moves/move.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/data/moves/move.ts b/src/data/moves/move.ts index 5a22b352e73..36cef4d5e4e 100644 --- a/src/data/moves/move.ts +++ b/src/data/moves/move.ts @@ -93,6 +93,7 @@ import { getEnumValues } from "#utils/enums"; import { toCamelCase, toTitleCase } from "#utils/strings"; import i18next from "i18next"; import { applyChallenges } from "#utils/challenge-utils"; +import type { AbstractConstructor } from "#types/type-helpers"; /** * A function used to conditionally determine execution of a given {@linkcode MoveAttr}. @@ -1055,16 +1056,11 @@ export class SelfStatusMove extends Move { } } -// TODO: Figure out how to improve the signature of this so that -// the `ChargeMove` function knows that the argument `Base` is a specific subclass of move that cannot -// be abstract. -// Right now, I only know how to do this by using the type conjunction (the & operators) -type SubMove = new (...args: any[]) => Move & { - is(moveKind: K): this is MoveClassMap[K]; -}; +type SubMove = AbstractConstructor function ChargeMove(Base: TBase, nameAppend: string) { - return class extends Base { + // NB: This cannot be made into a oneline return + abstract class Charging extends Base { /** The animation to play during the move's charging phase */ public readonly chargeAnim: ChargeAnim = ChargeAnim[`${MoveId[this.id]}_CHARGING`]; /** The message to show during the move's charging phase */ @@ -1141,6 +1137,7 @@ function ChargeMove(Base: TBase, nameAppend: string) { return this; } }; + return Charging; } export class ChargingAttackMove extends ChargeMove(AttackMove, "ChargingAttackMove") {}