mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-23 23:13:42 +02:00
[Misc] Cleaned up implementation of ChargeMove
mixin (#6466)
Co-authored-by: Wlowscha <54003515+Wlowscha@users.noreply.github.com>
This commit is contained in:
parent
1a06010820
commit
669ed76daf
@ -93,6 +93,7 @@ import { getEnumValues } from "#utils/enums";
|
|||||||
import { toCamelCase, toTitleCase } from "#utils/strings";
|
import { toCamelCase, toTitleCase } from "#utils/strings";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { applyChallenges } from "#utils/challenge-utils";
|
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}.
|
* 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
|
type SubMove = AbstractConstructor<Move>
|
||||||
// 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];
|
|
||||||
};
|
|
||||||
|
|
||||||
function ChargeMove<TBase extends SubMove>(Base: TBase, nameAppend: string) {
|
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 */
|
/** The animation to play during the move's charging phase */
|
||||||
public readonly chargeAnim: ChargeAnim = ChargeAnim[`${MoveId[this.id]}_CHARGING`];
|
public readonly chargeAnim: ChargeAnim = ChargeAnim[`${MoveId[this.id]}_CHARGING`];
|
||||||
/** The message to show during the move's charging phase */
|
/** 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 this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
return Charging;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ChargingAttackMove extends ChargeMove(AttackMove, "ChargingAttackMove") {}
|
export class ChargingAttackMove extends ChargeMove(AttackMove, "ChargingAttackMove") {}
|
||||||
|
Loading…
Reference in New Issue
Block a user