[Misc] Cleaned up implementation of ChargeMove mixin (#6466)

Co-authored-by: Wlowscha <54003515+Wlowscha@users.noreply.github.com>
This commit is contained in:
Bertie690 2025-09-04 05:01:24 -04:00 committed by GitHub
parent 1a06010820
commit 669ed76daf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<K extends keyof MoveClassMap>(moveKind: K): this is MoveClassMap[K];
};
type SubMove = AbstractConstructor<Move>
function ChargeMove<TBase extends SubMove>(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<TBase extends SubMove>(Base: TBase, nameAppend: string) {
return this;
}
};
return Charging;
}
export class ChargingAttackMove extends ChargeMove(AttackMove, "ChargingAttackMove") {}