mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-04 07:22:19 +02:00
Apply kev's suggestions from code review
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
parent
5b13d7d9ba
commit
50a5611837
@ -1,4 +1,12 @@
|
||||
import type { AttackMove, StatusMove, SelfStatusMove, MoveAttrConstructorMap, MoveAttr } from "#app/data/moves/move";
|
||||
import type {
|
||||
AttackMove,
|
||||
StatusMove,
|
||||
SelfStatusMove,
|
||||
ChargingAttackMove,
|
||||
ChargingSelfStatusMove,
|
||||
MoveAttrConstructorMap,
|
||||
MoveAttr,
|
||||
} from "#app/data/moves/move";
|
||||
|
||||
export type MoveAttrFilter = (attr: MoveAttr) => boolean;
|
||||
|
||||
@ -11,6 +19,9 @@ export type MoveClassMap = {
|
||||
AttackMove: typeof AttackMove;
|
||||
StatusMove: typeof StatusMove;
|
||||
SelfStatusMove: typeof SelfStatusMove;
|
||||
ChargingAttackMove: typeof ChargingAttackMove;
|
||||
ChargingSelfStatusMove: typeof ChargingSelfStatusMove;
|
||||
ChargeMove: typeof ChargingAttackMove | typeof ChargingSelfStatusMove;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -26,3 +37,5 @@ export type MoveAttrMap = {
|
||||
* Union type of all move attribute names as strings.
|
||||
*/
|
||||
export type MoveAttrString = keyof MoveAttrMap;
|
||||
|
||||
export type ChargingMove = ChargingAttackMove | ChargingSelfStatusMove;
|
||||
|
@ -2,10 +2,10 @@
|
||||
* Module holding functions to apply move attributes.
|
||||
* Must not import anything that is not a type.
|
||||
*/
|
||||
import type { MoveAttrString } from "#app/@types/move-types";
|
||||
import type Pokemon from "#app/field/pokemon";
|
||||
import type { default as Move, ChargingMove, MoveAttr } from "./move";
|
||||
import type { MoveAttrFilter } from "#app/@types/move-types";
|
||||
import type { default as Move, MoveAttr } from "./move";
|
||||
import type { ChargingMove } from "#app/@types/move-types";
|
||||
import type { MoveAttrFilter, MoveAttrString } from "#app/@types/move-types";
|
||||
|
||||
function applyMoveAttrsInternal(
|
||||
attrFilter: MoveAttrFilter,
|
||||
|
@ -123,14 +123,14 @@ import { MoveEffectTrigger } from "#enums/MoveEffectTrigger";
|
||||
import { MultiHitType } from "#enums/MultiHitType";
|
||||
import { invalidAssistMoves, invalidCopycatMoves, invalidMetronomeMoves, invalidMirrorMoveMoves, invalidSleepTalkMoves } from "./invalid-moves";
|
||||
import { SelectBiomePhase } from "#app/phases/select-biome-phase";
|
||||
import { MoveAttrMap, MoveAttrString, MoveClass, MoveClassMap } from "#app/@types/move-types";
|
||||
import { ChargingMove, MoveAttrMap, MoveAttrString, MoveClass, MoveClassMap } from "#app/@types/move-types";
|
||||
import { applyMoveAttrs } from "./apply-attrs";
|
||||
import { frenzyMissFunc, getMoveTargets } from "./move-utils";
|
||||
|
||||
type MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => boolean;
|
||||
export type UserMoveConditionFunc = (user: Pokemon, move: Move) => boolean;
|
||||
|
||||
export default class Move implements Localizable {
|
||||
export default abstract class Move implements Localizable {
|
||||
public id: MoveId;
|
||||
public name: string;
|
||||
private _type: PokemonType;
|
||||
@ -153,12 +153,10 @@ export default class Move implements Localizable {
|
||||
/**
|
||||
* Check if the move is of the given subclass without requiring `instanceof`.
|
||||
*
|
||||
* @param moveSort - The string name of the move to check against
|
||||
* @param moveKind - The string name of the move to check against
|
||||
* @returns Whether this move is of the provided type.
|
||||
*/
|
||||
public is<K extends keyof MoveClassMap>(moveSort: K): this is MoveClassMap[K] {
|
||||
return false;
|
||||
}
|
||||
public abstract is<K extends keyof MoveClassMap>(moveKind: K): this is MoveClassMap[K];
|
||||
|
||||
constructor(id: MoveId, type: PokemonType, category: MoveCategory, defaultMoveTarget: MoveTarget, power: number, accuracy: number, pp: number, chance: number, priority: number, generation: number) {
|
||||
this.id = id;
|
||||
@ -978,8 +976,8 @@ export default class Move implements Localizable {
|
||||
}
|
||||
|
||||
export class AttackMove extends Move {
|
||||
override is<K extends keyof MoveClassMap>(moveSort: K): this is MoveClassMap[K] {
|
||||
return moveSort === "AttackMove" || super.is(moveSort);
|
||||
override is<K extends keyof MoveClassMap>(moveKind: K): this is MoveClassMap[K] {
|
||||
return moveKind === "AttackMove";
|
||||
}
|
||||
constructor(id: MoveId, type: PokemonType, category: MoveCategory, power: number, accuracy: number, pp: number, chance: number, priority: number, generation: number) {
|
||||
super(id, type, category, MoveTarget.NEAR_OTHER, power, accuracy, pp, chance, priority, generation);
|
||||
@ -1031,8 +1029,9 @@ export class StatusMove extends Move {
|
||||
constructor(id: MoveId, type: PokemonType, accuracy: number, pp: number, chance: number, priority: number, generation: number) {
|
||||
super(id, type, MoveCategory.STATUS, MoveTarget.NEAR_OTHER, -1, accuracy, pp, chance, priority, generation);
|
||||
}
|
||||
override is<K extends keyof MoveClassMap>(moveSort: K): this is MoveClassMap[K] {
|
||||
return moveSort === "StatusMove" || super.is(moveSort);
|
||||
|
||||
override is<K extends keyof MoveClassMap>(moveKind: K): this is MoveClassMap[K] {
|
||||
return moveKind === "StatusMove";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1040,14 +1039,15 @@ export class SelfStatusMove extends Move {
|
||||
constructor(id: MoveId, type: PokemonType, accuracy: number, pp: number, chance: number, priority: number, generation: number) {
|
||||
super(id, type, MoveCategory.STATUS, MoveTarget.USER, -1, accuracy, pp, chance, priority, generation);
|
||||
}
|
||||
override is<K extends keyof MoveClassMap>(moveSort: K): this is MoveClassMap[K] {
|
||||
return moveSort === "SelfStatusMove" || super.is(moveSort);
|
||||
|
||||
override is<K extends keyof MoveClassMap>(moveKind: K): this is MoveClassMap[K] {
|
||||
return moveKind === "SelfStatusMove";
|
||||
}
|
||||
}
|
||||
|
||||
type SubMove = new (...args: any[]) => Move;
|
||||
|
||||
function ChargeMove<TBase extends SubMove>(Base: TBase) {
|
||||
function ChargeMove<TBase extends SubMove>(Base: TBase, nameAppend: string) {
|
||||
return class extends Base {
|
||||
/** The animation to play during the move's charging phase */
|
||||
public readonly chargeAnim: ChargeAnim = ChargeAnim[`${MoveId[this.id]}_CHARGING`];
|
||||
@ -1061,6 +1061,11 @@ function ChargeMove<TBase extends SubMove>(Base: TBase) {
|
||||
return true;
|
||||
}
|
||||
|
||||
override is<K extends keyof MoveClassMap>(moveKind: K): this is MoveClassMap[K] {
|
||||
// Anything subclassing this is a charge move.
|
||||
return moveKind === "ChargeMove" || moveKind === nameAppend;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text to be displayed during this move's charging phase.
|
||||
* References to the user Pokemon should be written as "{USER}", and
|
||||
@ -1127,11 +1132,8 @@ function ChargeMove<TBase extends SubMove>(Base: TBase) {
|
||||
};
|
||||
}
|
||||
|
||||
export class ChargingAttackMove extends ChargeMove(AttackMove) {}
|
||||
export class ChargingSelfStatusMove extends ChargeMove(SelfStatusMove) {}
|
||||
|
||||
export type ChargingMove = ChargingAttackMove | ChargingSelfStatusMove;
|
||||
|
||||
export class ChargingAttackMove extends ChargeMove(AttackMove, "ChargingAttackMove") {}
|
||||
export class ChargingSelfStatusMove extends ChargeMove(SelfStatusMove, "ChargingSelfStatusMove") {}
|
||||
|
||||
/**
|
||||
* Base class defining all {@linkcode Move} Attributes
|
||||
|
@ -17,7 +17,6 @@ import type Move from "./move";
|
||||
* @see {@linkcode getPpRatio} - returns the current PP amount / max PP amount.
|
||||
* @see {@linkcode getName} - returns name of {@linkcode Move}.
|
||||
**/
|
||||
|
||||
export class PokemonMove {
|
||||
public moveId: MoveId;
|
||||
public ppUsed: number;
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
export enum FieldPosition {
|
||||
CENTER,
|
||||
LEFT,
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
export enum FormChangeItem {
|
||||
NONE,
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
export enum GameModes {
|
||||
CLASSIC,
|
||||
ENDLESS,
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
export enum HitResult {
|
||||
EFFECTIVE = 1,
|
||||
SUPER_EFFECTIVE,
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
export enum LearnMoveType {
|
||||
/** For learning a move via level-up, evolution, or other non-item-based event */
|
||||
LEARN_MOVE,
|
||||
|
@ -1,15 +1,16 @@
|
||||
|
||||
export enum AnimFrameTarget {
|
||||
USER,
|
||||
TARGET,
|
||||
GRAPHIC
|
||||
}
|
||||
|
||||
export enum AnimFocus {
|
||||
TARGET = 1,
|
||||
USER,
|
||||
USER_TARGET,
|
||||
SCREEN
|
||||
}
|
||||
|
||||
export enum AnimBlendType {
|
||||
NORMAL,
|
||||
ADD,
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
export enum MoveResult {
|
||||
PENDING,
|
||||
SUCCESS,
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
export enum TrainerVariant {
|
||||
DEFAULT,
|
||||
FEMALE,
|
||||
|
Loading…
Reference in New Issue
Block a user