apply biome formatting

This commit is contained in:
Bertie690 2025-08-23 00:25:04 -04:00 committed by Sirz Benjie
parent 495dd9cabe
commit 2bffccd7f9
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E
29 changed files with 538 additions and 507 deletions

View File

@ -67,7 +67,11 @@
"useJsonImportAttributes": "off" // "Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. ts(2823)"
},
"style": {
"noNegationElse": "warn", // TODO: Promote to error eventually
"noNegationElse": {
"level": "warn", // TODO: Promote to error eventually
"fix": "none", // duplicates else blocks
"options": {}
},
// TODO: Fix all instances of this and promote to `error` - this and enums are the 2 things
// barring us from `esModuleInterop`
"noParameterProperties": "warn",
@ -140,7 +144,14 @@
}
}
},
"useUnifiedTypeSignatures": "error",
// TODO: Wait until the rule gets options for ignoring doc comments and/or different parameter names,
// and THEN enable it codebase-wide
"useUnifiedTypeSignatures": {
"level": "info",
"fix": "none",
"options": {}
},
"useGroupedAccessorPairs": "error",
"useObjectSpread": "error",
"useNumericSeparators": "off" // TODO: Consider enabling?

View File

@ -129,7 +129,7 @@ async function scrapeTrainerNames(classes) {
reason = `Server produced error code of ${+errCode}`;
}
throw new Error(
chalk.red.bold(`Failed to parse URL for ${chalk.hex("#7fff00")(`\"${trainerClass}\"`)}!\nReason: ${reason}`),
chalk.red.bold(`Failed to parse URL for ${chalk.hex("#7fff00")(`"${trainerClass}"`)}!\nReason: ${reason}`),
);
}
}),
@ -191,9 +191,7 @@ async function doFetch(trainerClass, seenClasses) {
const [female, counterpartURLs] = checkGenderAndType(document);
const names = fetchNames(trainerListHeader, female);
if (names === INVALID_URL) {
return Promise.reject(
new Error(chalk.red.bold(`URL \"${classURL}\" did not correspond to a valid trainer class!`)),
);
return Promise.reject(new Error(chalk.red.bold(`URL "${classURL}" did not correspond to a valid trainer class!`)));
}
// Recurse into all unseen gender counterparts' URLs, using the first male name we find
@ -285,7 +283,7 @@ async function promptExisting(outFile) {
{
type: "confirm",
name: "continue",
message: `File ${chalk.blue(outFile)} already exists!` + "\nDo you want to replace it?",
message: `File ${chalk.blue(outFile)} already exists!\nDo you want to replace it?`,
default: false,
},
])

View File

@ -3154,7 +3154,7 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr {
// If none are eligible to copy, it will not activate.
const targets = user.getOpponents().filter(opp => user.canTransformInto(opp));
if (targets.length === 0) {
return undefined;
return;
}
const mon = targets[user.randBattleSeedInt(targets.length)];

View File

@ -765,9 +765,10 @@ export abstract class EntryHazardTag extends SerializableArenaTag {
const source = this.getSourcePokemon();
if (!source) {
console.warn(
"Failed to get source Pokemon for AernaTrapTag on add message!" +
`\nTag type: ${this.tagType}` +
`\nPID: ${this.sourceId}`,
// biome-ignore lint/complexity/noUselessStringConcat: Rule bugs out with operator linebreaks set to `before`
"Failed to get source Pokemon for AernaTrapTag on add message!"
+ `\nTag type: ${this.tagType}`
+ `\nPID: ${this.sourceId}`,
);
return;
}

View File

@ -503,7 +503,12 @@ export const speciesEggMoves = {
[SpeciesId.GALAR_ZIGZAGOON]: [MoveId.CEASELESS_EDGE, MoveId.FACADE, MoveId.PARTING_SHOT, MoveId.EXTREME_SPEED],
[SpeciesId.GALAR_DARUMAKA]: [MoveId.ICE_SPINNER, MoveId.ZING_ZAP, MoveId.DRAIN_PUNCH, MoveId.PYRO_BALL],
[SpeciesId.GALAR_YAMASK]: [MoveId.STRENGTH_SAP, MoveId.DIRE_CLAW, MoveId.THOUSAND_WAVES, MoveId.SPECTRAL_THIEF],
[SpeciesId.GALAR_STUNFISK]: [ MoveId.SPIKY_SHIELD, MoveId.THOUSAND_ARROWS, MoveId.STRENGTH_SAP, MoveId.DOUBLE_IRON_BASH ],
[SpeciesId.GALAR_STUNFISK]: [
MoveId.SPIKY_SHIELD,
MoveId.THOUSAND_ARROWS,
MoveId.STRENGTH_SAP,
MoveId.DOUBLE_IRON_BASH,
],
[SpeciesId.HISUI_GROWLITHE]: [MoveId.WAVE_CRASH, MoveId.HEAD_SMASH, MoveId.VOLT_TACKLE, MoveId.DRAGON_DANCE],
[SpeciesId.HISUI_VOLTORB]: [MoveId.FROST_BREATH, MoveId.NASTY_PLOT, MoveId.APPLE_ACID, MoveId.ELECTRO_DRIFT],
[SpeciesId.HISUI_QWILFISH]: [MoveId.CEASELESS_EDGE, MoveId.BANEFUL_BUNKER, MoveId.RECOVER, MoveId.FISHIOUS_REND],

View File

@ -78,7 +78,7 @@ export enum EvolutionItem {
}
const tyrogueMoves = [MoveId.LOW_SWEEP, MoveId.MACH_PUNCH, MoveId.RAPID_SPIN] as const;
type TyrogueMove = typeof tyrogueMoves[number];
type TyrogueMove = (typeof tyrogueMoves)[number];
/**
* Pokemon Evolution tuple type consisting of:
@ -203,7 +203,10 @@ export class SpeciesEvolutionCondition {
case EvoCondKey.WEATHER:
return cond.weather.includes(globalScene.arena.getWeatherType());
case EvoCondKey.TYROGUE:
return pokemon.getMoveset(true).find(m => (tyrogueMoves as readonly MoveId[]) .includes(m.moveId))?.moveId === cond.move;
return (
pokemon.getMoveset(true).find(m => (tyrogueMoves as readonly MoveId[]).includes(m.moveId))?.moveId
=== cond.move
);
case EvoCondKey.NATURE:
return cond.nature.includes(pokemon.getNature());
case EvoCondKey.RANDOM_FORM: {
@ -513,7 +516,13 @@ export const pokemonEvolutions: PokemonEvolutions = {
[SpeciesId.RALTS]: [new SpeciesEvolution(SpeciesId.KIRLIA, 20, null, null)],
[SpeciesId.KIRLIA]: [
new SpeciesEvolution(SpeciesId.GARDEVOIR, 30, null, null),
new SpeciesEvolution(SpeciesId.GALLADE, 1, EvolutionItem.DAWN_STONE, {key: EvoCondKey.GENDER, gender: Gender.MALE}, SpeciesWildEvolutionDelay.LONG),
new SpeciesEvolution(
SpeciesId.GALLADE,
1,
EvolutionItem.DAWN_STONE,
{ key: EvoCondKey.GENDER, gender: Gender.MALE },
SpeciesWildEvolutionDelay.LONG,
),
],
[SpeciesId.SURSKIT]: [new SpeciesEvolution(SpeciesId.MASQUERAIN, 22, null, null)],
[SpeciesId.SHROOMISH]: [new SpeciesEvolution(SpeciesId.BRELOOM, 23, null, null)],
@ -548,7 +557,13 @@ export const pokemonEvolutions: PokemonEvolutions = {
[SpeciesId.DUSKULL]: [new SpeciesEvolution(SpeciesId.DUSCLOPS, 37, null, null)],
[SpeciesId.SNORUNT]: [
new SpeciesEvolution(SpeciesId.GLALIE, 42, null, null),
new SpeciesEvolution(SpeciesId.FROSLASS, 1, EvolutionItem.DAWN_STONE, {key: EvoCondKey.GENDER, gender: Gender.FEMALE}, SpeciesWildEvolutionDelay.LONG),
new SpeciesEvolution(
SpeciesId.FROSLASS,
1,
EvolutionItem.DAWN_STONE,
{ key: EvoCondKey.GENDER, gender: Gender.FEMALE },
SpeciesWildEvolutionDelay.LONG,
),
],
[SpeciesId.SPHEAL]: [new SpeciesEvolution(SpeciesId.SEALEO, 32, null, null)],
[SpeciesId.SEALEO]: [new SpeciesEvolution(SpeciesId.WALREIN, 44, null, null)],

View File

@ -823,11 +823,11 @@ export class FreshStartChallenge extends Challenge {
// Remove natures except for the default ones
const neutralNaturesAttr =
(1 << (Nature.HARDY + 1)) |
(1 << (Nature.DOCILE + 1)) |
(1 << (Nature.SERIOUS + 1)) |
(1 << (Nature.BASHFUL + 1)) |
(1 << (Nature.QUIRKY + 1));
(1 << (Nature.HARDY + 1))
| (1 << (Nature.DOCILE + 1))
| (1 << (Nature.SERIOUS + 1))
| (1 << (Nature.BASHFUL + 1))
| (1 << (Nature.QUIRKY + 1));
dexEntry.natureAttr &= neutralNaturesAttr;
// Cap all ivs at 15

View File

@ -220,7 +220,7 @@ export class MysteryEncounterOptionBuilder implements Partial<IMysteryEncounterO
requirement: EncounterSceneRequirement,
): this & Required<Pick<IMysteryEncounterOption, "requirements">> {
if (requirement instanceof EncounterPokemonRequirement) {
Error("Incorrectly added pokemon requirement as scene requirement.");
new Error("Incorrectly added pokemon requirement as scene requirement.");
}
this.requirements.push(requirement);
@ -265,7 +265,7 @@ export class MysteryEncounterOptionBuilder implements Partial<IMysteryEncounterO
requirement: EncounterPokemonRequirement,
): this & Required<Pick<IMysteryEncounterOption, "primaryPokemonRequirements">> {
if (requirement instanceof EncounterSceneRequirement) {
Error("Incorrectly added scene requirement as pokemon requirement.");
new Error("Incorrectly added scene requirement as pokemon requirement.");
}
this.primaryPokemonRequirements.push(requirement);
@ -315,7 +315,7 @@ export class MysteryEncounterOptionBuilder implements Partial<IMysteryEncounterO
excludePrimaryFromSecondaryRequirements = true,
): this & Required<Pick<IMysteryEncounterOption, "secondaryPokemonRequirements">> {
if (requirement instanceof EncounterSceneRequirement) {
Error("Incorrectly added scene requirement as pokemon requirement.");
new Error("Incorrectly added scene requirement as pokemon requirement.");
}
this.secondaryPokemonRequirements.push(requirement);

View File

@ -821,7 +821,7 @@ export class MysteryEncounterBuilder implements Partial<IMysteryEncounter> {
requirement: EncounterSceneRequirement,
): this & Required<Pick<IMysteryEncounter, "requirements">> {
if (requirement instanceof EncounterPokemonRequirement) {
Error("Incorrectly added pokemon requirement as scene requirement.");
new Error("Incorrectly added pokemon requirement as scene requirement.");
}
this.requirements.push(requirement);
return this;
@ -864,7 +864,7 @@ export class MysteryEncounterBuilder implements Partial<IMysteryEncounter> {
requirement: EncounterPokemonRequirement,
): this & Required<Pick<IMysteryEncounter, "primaryPokemonRequirements">> {
if (requirement instanceof EncounterSceneRequirement) {
Error("Incorrectly added scene requirement as pokemon requirement.");
new Error("Incorrectly added scene requirement as pokemon requirement.");
}
this.primaryPokemonRequirements.push(requirement);
@ -917,7 +917,7 @@ export class MysteryEncounterBuilder implements Partial<IMysteryEncounter> {
excludePrimaryFromSecondaryRequirements = false,
): this & Required<Pick<IMysteryEncounter, "secondaryPokemonRequirements">> {
if (requirement instanceof EncounterSceneRequirement) {
Error("Incorrectly added scene requirement as pokemon requirement.");
new Error("Incorrectly added scene requirement as pokemon requirement.");
}
this.secondaryPokemonRequirements.push(requirement);

View File

@ -53,8 +53,8 @@ const SEASONAL_WEIGHT_MULTIPLIER = 15;
//#region Common Messages
const commonSplashMessages = [
...Array(BATTLES_WON_WEIGHT_MULTIPLIER).fill("battlesWon"),
...Array(POKEMON_NAMES_WEIGHT_MULTIPLIER).fill("underratedPokemon"),
...new Array(BATTLES_WON_WEIGHT_MULTIPLIER).fill("battlesWon"),
...new Array(POKEMON_NAMES_WEIGHT_MULTIPLIER).fill("underratedPokemon"),
"joinTheDiscord",
"infiniteLevels",
"everythingIsStackable",
@ -333,7 +333,7 @@ export function getSplashMessages(): string[] {
if (now >= startDate && now <= endDate) {
console.log(`Adding ${messages.length} ${name} splash messages (weight: x${SEASONAL_WEIGHT_MULTIPLIER})`);
for (const message of messages) {
const weightedMessage = Array(SEASONAL_WEIGHT_MULTIPLIER).fill(message);
const weightedMessage = new Array(SEASONAL_WEIGHT_MULTIPLIER).fill(message);
splashMessages.push(...weightedMessage);
}
}

View File

@ -286,7 +286,7 @@ export function getTypeDamageMultiplierColor(
case 0.5:
return "#FE8E00";
case 1:
return undefined;
return;
case 2:
return "#4AA500";
case 4:
@ -306,7 +306,7 @@ export function getTypeDamageMultiplierColor(
case 0.5:
return "#0093FF";
case 1:
return undefined;
return;
case 2:
return "#FE8E00";
case 4:

View File

@ -315,7 +315,7 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
super(globalScene, x, y);
if (!species.isObtainable() && this.isPlayer()) {
throw `Cannot create a player Pokemon for species "${species.getName(formIndex)}"`;
throw new Error(`Cannot create a player Pokemon for species "${species.getName(formIndex)}"`);
}
this.species = species;
@ -4114,7 +4114,7 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
isCritical = false,
ignoreSegments = false,
ignoreFaintPhase = false,
source = undefined,
source,
}: {
result?: DamageResult;
isCritical?: boolean;
@ -5100,11 +5100,9 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
const lastStatus = this.status?.effect;
this.status = null;
this.setFrameRate(10);
if (lastStatus === StatusEffect.SLEEP) {
if (this.getTag(BattlerTagType.NIGHTMARE)) {
if (lastStatus === StatusEffect.SLEEP && this.getTag(BattlerTagType.NIGHTMARE)) {
this.lapseTag(BattlerTagType.NIGHTMARE);
}
}
if (confusion && this.getTag(BattlerTagType.CONFUSED)) {
this.lapseTag(BattlerTagType.CONFUSED);
}
@ -5797,9 +5795,8 @@ export class PlayerPokemon extends Pokemon {
if (!dataSource) {
if (
globalScene.gameMode.isDaily ||
// Keldeo is excluded due to crashes involving its signature move and the associated form change
(Overrides.STARTER_SPECIES_OVERRIDE && Overrides.STARTER_SPECIES_OVERRIDE !== SpeciesId.KELDEO)
globalScene.gameMode.isDaily // Keldeo is excluded due to crashes involving its signature move and the associated form change
|| (Overrides.STARTER_SPECIES_OVERRIDE && Overrides.STARTER_SPECIES_OVERRIDE !== SpeciesId.KELDEO)
) {
this.generateAndPopulateMoveset();
} else {

View File

@ -54,8 +54,8 @@ export class Trainer extends Phaser.GameObjects.Container {
) {
super(globalScene, -72, 80);
this.config =
trainerConfigOverride ??
(trainerConfigs.hasOwnProperty(trainerType)
trainerConfigOverride
?? (trainerConfigs.hasOwnProperty(trainerType)
? trainerConfigs[trainerType]
: trainerConfigs[TrainerType.ACE_TRAINER]);

View File

@ -458,10 +458,9 @@ export class CommandPhase extends FieldPhase {
if (cursor < numBallTypes) {
const targetPokemon = globalScene.getEnemyPokemon(false);
if (
targetPokemon?.isBoss() &&
targetPokemon?.bossSegmentIndex >= 1 &&
// TODO: Decouple this hardcoded exception for wonder guard and just check the target...
!targetPokemon?.hasAbility(AbilityId.WONDER_GUARD, false, true)
targetPokemon?.isBoss()
&& targetPokemon?.bossSegmentIndex >= 1 // TODO: Decouple this hardcoded exception for wonder guard and just check the target...
&& !targetPokemon?.hasAbility(AbilityId.WONDER_GUARD, false, true)
) {
// When facing the final boss, it must be weakened unless a Master Ball is used AND no challenges are active.
// The message is customized for the final boss.

View File

@ -92,7 +92,7 @@ export class MoveEffectPhase extends PokemonPhase {
}
this.targets = targets;
this.hitChecks = Array(this.targets.length).fill([HitCheckResult.PENDING, 0]);
this.hitChecks = new Array(this.targets.length).fill([HitCheckResult.PENDING, 0]);
}
/**

View File

@ -244,11 +244,11 @@ export class TitlePhase extends Phase {
regenerateModifierPoolThresholds(party, ModifierPoolType.DAILY_STARTER);
const modifiers: Modifier[] = Array(3)
const modifiers: Modifier[] = new Array(3)
.fill(null)
.map(() => modifierTypes.EXP_SHARE().withIdFromFunc(modifierTypes.EXP_SHARE).newModifier())
.concat(
Array(3)
new Array(3)
.fill(null)
.map(() => modifierTypes.GOLDEN_EXP_CHARM().withIdFromFunc(modifierTypes.GOLDEN_EXP_CHARM).newModifier()),
)

View File

@ -226,8 +226,8 @@ export class TurnStartPhase extends FieldPhase {
// TODO: This seems somewhat dubious
const move =
pokemon.getMoveset().find(m => m.moveId === queuedMove.move && m.ppUsed < m.getMovePp()) ??
new PokemonMove(queuedMove.move);
pokemon.getMoveset().find(m => m.moveId === queuedMove.move && m.ppUsed < m.getMovePp())
?? new PokemonMove(queuedMove.move);
if (move.getMove().hasAttr("MoveHeaderAttr")) {
globalScene.phaseManager.unshiftNew("MoveHeaderPhase", pokemon, move);

View File

@ -519,9 +519,9 @@ export const achvs = {
"reviver_seed",
100,
c =>
c instanceof FreshStartChallenge &&
c.value === 1 &&
!globalScene.gameMode.challenges.some(
c instanceof FreshStartChallenge
&& c.value === 1
&& !globalScene.gameMode.challenges.some(
c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0,
),
),

View File

@ -103,23 +103,23 @@ export class UiInputs {
getActionsKeyUp(): ActionKeys {
const actions: ActionKeys = {
[Button.UP]: () => undefined,
[Button.DOWN]: () => undefined,
[Button.LEFT]: () => undefined,
[Button.RIGHT]: () => undefined,
[Button.SUBMIT]: () => undefined,
[Button.ACTION]: () => undefined,
[Button.CANCEL]: () => undefined,
[Button.MENU]: () => undefined,
[Button.UP]: () => {},
[Button.DOWN]: () => {},
[Button.LEFT]: () => {},
[Button.RIGHT]: () => {},
[Button.SUBMIT]: () => {},
[Button.ACTION]: () => {},
[Button.CANCEL]: () => {},
[Button.MENU]: () => {},
[Button.STATS]: () => this.buttonStats(false),
[Button.CYCLE_SHINY]: () => undefined,
[Button.CYCLE_FORM]: () => undefined,
[Button.CYCLE_GENDER]: () => undefined,
[Button.CYCLE_ABILITY]: () => undefined,
[Button.CYCLE_NATURE]: () => undefined,
[Button.CYCLE_SHINY]: () => {},
[Button.CYCLE_FORM]: () => {},
[Button.CYCLE_GENDER]: () => {},
[Button.CYCLE_ABILITY]: () => {},
[Button.CYCLE_NATURE]: () => {},
[Button.CYCLE_TERA]: () => this.buttonInfo(false),
[Button.SPEED_UP]: () => undefined,
[Button.SLOW_DOWN]: () => undefined,
[Button.SPEED_UP]: () => {},
[Button.SLOW_DOWN]: () => {},
};
return actions;
}

View File

@ -70,7 +70,7 @@ export class BaseStatsOverlay extends Phaser.GameObjects.Container implements In
show(values: number[], total: number): boolean {
for (let i = 0; i < 6; i++) {
this.statsLabels[i].setText(
i18next.t(`pokemonInfo:stat.${toCamelCase(shortStats[i])}Shortened`) + ": " + `${values[i]}`,
i18next.t(`pokemonInfo:stat.${toCamelCase(shortStats[i])}Shortened`) + `: ${values[i]}`,
);
// This accounts for base stats up to 200, might not be enough.
// TODO: change color based on value.

View File

@ -1506,14 +1506,14 @@ export class PokedexPageUiHandler extends MessageUiHandler {
this.biomes.map(b => {
options.push({
label:
i18next.t(`biome:${toCamelCase(BiomeId[b.biome])}`) +
" - " +
i18next.t(`biome:${toCamelCase(BiomePoolTier[b.tier])}`) +
(b.tod.length === 1 && b.tod[0] === -1
i18next.t(`biome:${toCamelCase(BiomeId[b.biome])}`)
+ " - "
+ i18next.t(`biome:${toCamelCase(BiomePoolTier[b.tier])}`)
+ (b.tod.length === 1 && b.tod[0] === -1
? ""
: " (" +
b.tod.map(tod => i18next.t(`biome:${toCamelCase(TimeOfDay[tod])}`)).join(", ") +
")"),
: " ("
+ b.tod.map(tod => i18next.t(`biome:${toCamelCase(TimeOfDay[tod])}`)).join(", ")
+ ")"),
handler: () => false,
});
});
@ -1527,14 +1527,14 @@ export class PokedexPageUiHandler extends MessageUiHandler {
this.preBiomes.map(b => {
options.push({
label:
i18next.t(`biome:${toCamelCase(BiomeId[b.biome])}`) +
" - " +
i18next.t(`biome:${toCamelCase(BiomePoolTier[b.tier])}`) +
(b.tod.length === 1 && b.tod[0] === -1
i18next.t(`biome:${toCamelCase(BiomeId[b.biome])}`)
+ " - "
+ i18next.t(`biome:${toCamelCase(BiomePoolTier[b.tier])}`)
+ (b.tod.length === 1 && b.tod[0] === -1
? ""
: " (" +
b.tod.map(tod => i18next.t(`biome:${toCamelCase(TimeOfDay[tod])}`)).join(", ") +
")"),
: " ("
+ b.tod.map(tod => i18next.t(`biome:${toCamelCase(TimeOfDay[tod])}`)).join(", ")
+ ")"),
handler: () => false,
});
});

View File

@ -525,7 +525,7 @@ export class EggGachaUiHandler extends MessageUiHandler {
}
const eggSprite = globalScene.add.sprite(127, 75, "egg", `egg_${eggs[i].getKey()}`).setScale(0.5);
gachaContainer.addAt(eggSprite, 2);
// biome-ignore lint/nursery/noAwaitInLoop: The point of this loop is to play the animations, one after another
// biome-ignore lint/performance/noAwaitInLoops: The point of this loop is to play the animations, one after another
await this.doPullAnim(eggSprite, i).finally(() => gachaContainer.remove(eggSprite, true));
}

View File

@ -372,12 +372,12 @@ export class FightUiHandler extends UiHandler implements InfoToggle {
*/
private getMoveColor(pokemon: Pokemon, pokemonMove: PokemonMove): string | undefined {
if (!globalScene.typeHints) {
return undefined;
return;
}
const opponents = pokemon.getOpponents();
if (opponents.length <= 0) {
return undefined;
return;
}
const moveColors = opponents
@ -394,7 +394,7 @@ export class FightUiHandler extends UiHandler implements InfoToggle {
.sort((a, b) => b - a)
.map(effectiveness => {
if (pokemonMove.getMove().category === MoveCategory.STATUS && effectiveness !== 0) {
return undefined;
return;
}
return getTypeDamageMultiplierColor(effectiveness ?? 0, "offense");
});

View File

@ -595,9 +595,9 @@ export class PartyUiHandler extends MessageUiHandler {
matchingModifiers.push(
globalScene.findModifier(
m =>
m.is("PokemonHeldItemModifier") &&
m.pokemonId === newPokemon.id &&
m.matchType(allItems[this.transferOptionCursor]),
m.is("PokemonHeldItemModifier")
&& m.pokemonId === newPokemon.id
&& m.matchType(allItems[this.transferOptionCursor]),
) as PokemonHeldItemModifier | undefined,
);
}
@ -860,9 +860,9 @@ export class PartyUiHandler extends MessageUiHandler {
// This is only relevant for PartyUiMode.CHECK
// TODO: This risks hitting the other options (.MOVE_i and ALL) so does it? Do we need an extra check?
if (
option >= PartyOption.FORM_CHANGE_ITEM &&
globalScene.phaseManager.getCurrentPhase().is("SelectModifierPhase") &&
this.partyUiMode === PartyUiMode.CHECK
option >= PartyOption.FORM_CHANGE_ITEM
&& globalScene.phaseManager.getCurrentPhase().is("SelectModifierPhase")
&& this.partyUiMode === PartyUiMode.CHECK
) {
const formChangeItemModifiers = this.getFormChangeItemsModifiers(pokemon);
const modifier = formChangeItemModifiers[option - PartyOption.FORM_CHANGE_ITEM];
@ -912,8 +912,8 @@ export class PartyUiHandler extends MessageUiHandler {
// This is used when switching out using the Pokemon command (possibly holding a Baton held item). In this case there is no callback.
if (
(option === PartyOption.PASS_BATON || option === PartyOption.SEND_OUT) &&
this.partyUiMode === PartyUiMode.SWITCH
(option === PartyOption.PASS_BATON || option === PartyOption.SEND_OUT)
&& this.partyUiMode === PartyUiMode.SWITCH
) {
this.clearOptions();
(globalScene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(
@ -935,8 +935,8 @@ export class PartyUiHandler extends MessageUiHandler {
PartyOption.MOVE_3,
PartyOption.MOVE_4,
PartyOption.SELECT,
].includes(option) &&
this.selectCallback
].includes(option)
&& this.selectCallback
) {
this.clearOptions();
const selectCallback = this.selectCallback;
@ -1042,15 +1042,15 @@ export class PartyUiHandler extends MessageUiHandler {
const ui = this.getUi();
if (this.cursor < 6) {
if (
(this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER && !this.transferMode) ||
this.partyUiMode === PartyUiMode.DISCARD
(this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER && !this.transferMode)
|| this.partyUiMode === PartyUiMode.DISCARD
) {
/** Initialize item quantities for the selected Pokemon */
const itemModifiers = globalScene.findModifiers(
m =>
m.is("PokemonHeldItemModifier") &&
m.isTransferable &&
m.pokemonId === globalScene.getPlayerParty()[this.cursor].id,
m.is("PokemonHeldItemModifier")
&& m.isTransferable
&& m.pokemonId === globalScene.getPlayerParty()[this.cursor].id,
) as PokemonHeldItemModifier[];
this.transferQuantities = itemModifiers.map(item => item.getStackCount());
this.transferQuantitiesMax = itemModifiers.map(item => item.getStackCount());
@ -1092,8 +1092,8 @@ export class PartyUiHandler extends MessageUiHandler {
private processPartyCancelInput(): boolean {
const ui = this.getUi();
if (
(this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER || this.partyUiMode === PartyUiMode.SPLICE) &&
this.transferMode
(this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER || this.partyUiMode === PartyUiMode.SPLICE)
&& this.transferMode
) {
this.clearTransfer();
ui.playSelect();
@ -1366,8 +1366,8 @@ export class PartyUiHandler extends MessageUiHandler {
private allowBatonModifierSwitch(): boolean {
return !!(
this.partyUiMode !== PartyUiMode.FAINT_SWITCH &&
globalScene.findModifier(
this.partyUiMode !== PartyUiMode.FAINT_SWITCH
&& globalScene.findModifier(
m => m.is("SwitchEffectTransferModifier") && m.pokemonId === globalScene.getPlayerField()[this.fieldIndex].id,
)
);
@ -1378,9 +1378,9 @@ export class PartyUiHandler extends MessageUiHandler {
private isBatonPassMove(): boolean {
const lastMove: TurnMove | undefined = globalScene.getPlayerField()[this.fieldIndex].getLastXMoves()[0];
return (
this.partyUiMode === PartyUiMode.FAINT_SWITCH &&
lastMove?.result === MoveResult.SUCCESS &&
allMoves[lastMove.move].getAttrs("ForceSwitchOutAttr")[0]?.isBatonPass()
this.partyUiMode === PartyUiMode.FAINT_SWITCH
&& lastMove?.result === MoveResult.SUCCESS
&& allMoves[lastMove.move].getAttrs("ForceSwitchOutAttr")[0]?.isBatonPass()
);
}
@ -1426,8 +1426,10 @@ export class PartyUiHandler extends MessageUiHandler {
this.options.push(PartyOption.RENAME);
if (
pokemonEvolutions.hasOwnProperty(pokemon.species.speciesId) ||
(pokemon.isFusion() && pokemon.fusionSpecies && pokemonEvolutions.hasOwnProperty(pokemon.fusionSpecies.speciesId))
pokemonEvolutions.hasOwnProperty(pokemon.species.speciesId)
|| (pokemon.isFusion()
&& pokemon.fusionSpecies
&& pokemonEvolutions.hasOwnProperty(pokemon.fusionSpecies.speciesId))
) {
this.options.push(PartyOption.UNPAUSE_EVOLUTION);
}
@ -1621,10 +1623,10 @@ export class PartyUiHandler extends MessageUiHandler {
} else if (option === PartyOption.SCROLL_DOWN) {
optionName = "↓";
} else if (
(this.partyUiMode !== PartyUiMode.REMEMBER_MOVE_MODIFIER &&
(this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER || this.transferMode) &&
this.partyUiMode !== PartyUiMode.DISCARD) ||
option === PartyOption.CANCEL
(this.partyUiMode !== PartyUiMode.REMEMBER_MOVE_MODIFIER
&& (this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER || this.transferMode)
&& this.partyUiMode !== PartyUiMode.DISCARD)
|| option === PartyOption.CANCEL
) {
switch (option) {
case PartyOption.MOVE_1:
@ -1686,11 +1688,11 @@ export class PartyUiHandler extends MessageUiHandler {
const itemModifiers = this.getItemModifiers(pokemon);
const itemModifier = itemModifiers[option];
if (
this.isItemManageMode() &&
this.transferQuantitiesMax[option] > 1 &&
!this.transferMode &&
itemModifier !== undefined &&
itemModifier.type.name === optionName
this.isItemManageMode()
&& this.transferQuantitiesMax[option] > 1
&& !this.transferMode
&& itemModifier !== undefined
&& itemModifier.type.name === optionName
) {
let amountText = ` (${this.transferQuantities[option]})`;
@ -1832,9 +1834,9 @@ export class PartyUiHandler extends MessageUiHandler {
getOptionsCursorWithScroll(): number {
return (
this.optionsCursor +
this.optionsScrollCursor +
(this.options && this.options[0] === PartyOption.SCROLL_UP ? -1 : 0)
this.optionsCursor
+ this.optionsScrollCursor
+ (this.options && this.options[0] === PartyOption.SCROLL_UP ? -1 : 0)
);
}

View File

@ -689,25 +689,25 @@ export class RunInfoUiHandler extends UiHandler {
*/
private challengeParser(): string[] {
const rules: string[] = [];
for (const challenge of this.runInfo.challenges) {
if (challenge.value === 0) {
for (const chal of this.runInfo.challenges) {
if (chal.value === 0) {
continue;
}
switch (challenge.id) {
switch (chal.id) {
case Challenges.SINGLE_GENERATION:
rules.push(i18next.t(`runHistory:challengeMonoGen${challenge.value}`));
rules.push(i18next.t(`runHistory:challengeMonoGen${chal.value}`));
break;
case Challenges.SINGLE_TYPE: {
const typeRule = PokemonType[challenge.value - 1];
const typeRule = PokemonType[chal.value - 1];
const typeTextColor = `[color=${TypeColor[typeRule]}]`;
const typeShadowColor = `[shadow=${TypeShadow[typeRule]}]`;
const typeText =
typeTextColor +
typeShadowColor +
i18next.t(`pokemonInfo:type.${toCamelCase(typeRule)}`)! +
"[/color]" +
"[/shadow]";
typeTextColor
+ typeShadowColor
+ i18next.t(`pokemonInfo:type.${toCamelCase(typeRule)}`)!
+ "[/color]"
+ "[/shadow]";
rules.push(typeText);
break;
}
@ -715,7 +715,7 @@ export class RunInfoUiHandler extends UiHandler {
rules.push(i18next.t("challenges:inverseBattle.shortName"));
break;
default: {
const localizationKey = toCamelCase(Challenges[challenge.id]);
const localizationKey = toCamelCase(Challenges[chal.id]);
rules.push(i18next.t(`challenges:${localizationKey}.name`));
break;
}

View File

@ -4,7 +4,7 @@ import { CLASSIC_CANDY_FRIENDSHIP_MULTIPLIER } from "#balance/starters";
/** Mock TimedEventManager so that ongoing events don't impact tests */
export class MockTimedEventManager extends TimedEventManager {
override activeEvent() {
return undefined;
return;
}
override isEventActive(): boolean {
return false;

View File

@ -395,7 +395,8 @@ export class PhaseInterceptor {
&& currentPhase === actionForNextPrompt.phaseTarget
&& currentHandler.active
&& (!actionForNextPrompt.awaitingActionInput
|| (actionForNextPrompt.awaitingActionInput && (currentHandler as AwaitableUiHandler)["awaitingActionInput"]))
|| (actionForNextPrompt.awaitingActionInput
&& (currentHandler as AwaitableUiHandler)["awaitingActionInput"]))
) {
const prompt = this.prompts.shift();
if (prompt?.callback) {

View File

@ -70,7 +70,9 @@ describe("UI - Transfer Items", () => {
handler.optionsContainer.list.some(option => (option as BBCodeText).text?.includes("Apicot Berry (2)")),
).toBe(true);
expect(
handler.optionsContainer.list.some(option => RegExp(/Lum Berry\[color.*(2)/).exec((option as BBCodeText).text)),
handler.optionsContainer.list.some(option =>
new RegExp(/Lum Berry\[color.*(2)/).exec((option as BBCodeText).text),
),
).toBe(true);
});