chore: format can-learn-move-requirement.ts
This commit is contained in:
parent
d967ac52b6
commit
5aceff6d6c
|
@ -1,7 +1,7 @@
|
||||||
import BattleScene from "#app/battle-scene.js";
|
import BattleScene from "#app/battle-scene";
|
||||||
import { Moves } from "#app/enums/moves.js";
|
import { Moves } from "#app/enums/moves";
|
||||||
import { PlayerPokemon } from "#app/field/pokemon.js";
|
import { PlayerPokemon } from "#app/field/pokemon";
|
||||||
import { isNullOrUndefined } from "#app/utils.js";
|
import { isNullOrUndefined } from "#app/utils";
|
||||||
import { EncounterPokemonRequirement } from "../mystery-encounter-requirements";
|
import { EncounterPokemonRequirement } from "../mystery-encounter-requirements";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,23 +26,11 @@ export class CanLearnMoveRequirement extends EncounterPokemonRequirement {
|
||||||
private readonly excludeEggMoves?: boolean;
|
private readonly excludeEggMoves?: boolean;
|
||||||
private readonly includeFainted?: boolean;
|
private readonly includeFainted?: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(requiredMoves: Moves | Moves[], options: CanlearnMoveRequirementOptions = {}) {
|
||||||
requiredMoves: Moves | Moves[],
|
|
||||||
options: CanlearnMoveRequirementOptions = {}
|
|
||||||
) {
|
|
||||||
super();
|
super();
|
||||||
this.requiredMoves = Array.isArray(requiredMoves)
|
this.requiredMoves = Array.isArray(requiredMoves) ? requiredMoves : [requiredMoves];
|
||||||
? requiredMoves
|
|
||||||
: [requiredMoves];
|
|
||||||
|
|
||||||
const {
|
const { excludeLevelMoves, excludeTmMoves, excludeEggMoves, includeFainted, minNumberOfPokemon, invertQuery } = options;
|
||||||
excludeLevelMoves,
|
|
||||||
excludeTmMoves,
|
|
||||||
excludeEggMoves,
|
|
||||||
includeFainted,
|
|
||||||
minNumberOfPokemon,
|
|
||||||
invertQuery,
|
|
||||||
} = options;
|
|
||||||
|
|
||||||
this.excludeLevelMoves = excludeLevelMoves ?? false;
|
this.excludeLevelMoves = excludeLevelMoves ?? false;
|
||||||
this.excludeTmMoves = excludeTmMoves ?? false;
|
this.excludeTmMoves = excludeTmMoves ?? false;
|
||||||
|
@ -53,11 +41,7 @@ export class CanLearnMoveRequirement extends EncounterPokemonRequirement {
|
||||||
}
|
}
|
||||||
|
|
||||||
override meetsRequirement(scene: BattleScene): boolean {
|
override meetsRequirement(scene: BattleScene): boolean {
|
||||||
const partyPokemon = scene
|
const partyPokemon = scene.getParty().filter((pkm) => (this.includeFainted ? pkm.isAllowed() : pkm.isAllowedInBattle()));
|
||||||
.getParty()
|
|
||||||
.filter((pkm) =>
|
|
||||||
this.includeFainted ? pkm.isAllowed() : pkm.isAllowedInBattle()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isNullOrUndefined(partyPokemon) || this?.requiredMoves?.length < 0) {
|
if (isNullOrUndefined(partyPokemon) || this?.requiredMoves?.length < 0) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -70,25 +54,18 @@ export class CanLearnMoveRequirement extends EncounterPokemonRequirement {
|
||||||
if (!this.invertQuery) {
|
if (!this.invertQuery) {
|
||||||
return partyPokemon.filter((pokemon) =>
|
return partyPokemon.filter((pokemon) =>
|
||||||
// every required move should be included
|
// every required move should be included
|
||||||
this.requiredMoves.every((requiredMove) =>
|
this.requiredMoves.every((requiredMove) => this.getAllPokemonMoves(pokemon).includes(requiredMove))
|
||||||
this.getAllPokemonMoves(pokemon).includes(requiredMove)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return partyPokemon.filter(
|
return partyPokemon.filter(
|
||||||
(pokemon) =>
|
(pokemon) =>
|
||||||
// none of the "required" moves should be included
|
// none of the "required" moves should be included
|
||||||
!this.requiredMoves.some((requiredMove) =>
|
!this.requiredMoves.some((requiredMove) => this.getAllPokemonMoves(pokemon).includes(requiredMove))
|
||||||
this.getAllPokemonMoves(pokemon).includes(requiredMove)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override getDialogueToken(
|
override getDialogueToken(_scene: BattleScene, _pokemon?: PlayerPokemon): [string, string] {
|
||||||
_scene: BattleScene,
|
|
||||||
_pokemon?: PlayerPokemon
|
|
||||||
): [string, string] {
|
|
||||||
return ["requiredMoves", this.requiredMoves.join(", ")];
|
return ["requiredMoves", this.requiredMoves.join(", ")];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue