From 9a8b6047c867bacbea18ec7e046f30e70c731c19 Mon Sep 17 00:00:00 2001 From: Greenlamp Date: Wed, 22 May 2024 01:49:43 +0200 Subject: [PATCH] eslint done --- src/battle-scene.ts | 15 +++++---------- src/battle.ts | 4 +--- src/data/ability.ts | 22 ++++++++++------------ src/data/arena-tag.ts | 4 +++- src/data/battle-anims.ts | 11 ++++++----- src/data/berry.ts | 1 - src/data/biomes.ts | 2 ++ src/data/egg.ts | 3 --- src/data/move.ts | 24 ++++++++++++------------ src/data/pokemon-evolutions.ts | 4 ++-- src/data/pokemon-species.ts | 6 ++---- src/data/trainer-names.ts | 4 ++++ src/field/pokemon.ts | 18 ++++++++---------- src/field/trainer.ts | 7 ++----- src/inputs-controller.ts | 2 +- 15 files changed, 58 insertions(+), 69 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 9a8a8365af6..d8588af3e2b 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -1,8 +1,8 @@ import Phaser from 'phaser'; -import UI, { Mode } from './ui/ui'; +import UI from './ui/ui'; import { NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, MessagePhase, TurnInitPhase, ReturnPhase, LevelCapPhase, ShowTrainerPhase, LoginPhase, MovePhase, TitlePhase, SwitchPhase } from './phases'; import Pokemon, { PlayerPokemon, EnemyPokemon } from './field/pokemon'; -import PokemonSpecies, { PokemonSpeciesFilter, allSpecies, getPokemonSpecies, initSpecies, speciesStarters } from './data/pokemon-species'; +import PokemonSpecies, { PokemonSpeciesFilter, allSpecies, getPokemonSpecies, initSpecies } from './data/pokemon-species'; import * as Utils from './utils'; import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier, ModifierPredicate, DoubleBattleChanceBoosterModifier, FusePokemonModifier, PokemonFormChangeItemModifier, TerastallizeModifier, overrideModifiers, overrideHeldItems } from './modifier/modifier'; import { PokeballType } from './data/pokeball'; @@ -12,7 +12,6 @@ import { initGameSpeed } from './system/game-speed'; import { Biome } from './data/enums/biome'; import { Arena, ArenaBase } from './field/arena'; import { GameData, PlayerGender } from './system/game-data'; -import StarterSelectUiHandler from './ui/starter-select-ui-handler'; import { TextStyle, addTextObject } from './ui/text'; import { Moves } from './data/enums/moves'; import { allMoves } from './data/move'; @@ -20,7 +19,6 @@ import { initMoves } from './data/move'; import { ModifierPoolType, getDefaultModifierTypeForTier, getEnemyModifierTypesForWave, getLuckString, getLuckTextTint, getModifierPoolForType, getPartyLuckValue } from './modifier/modifier-type'; import AbilityBar from './ui/ability-bar'; import { BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, IncrementMovePriorityAbAttr, applyAbAttrs, initAbilities } from './data/ability'; -import { Abilities } from './data/enums/abilities'; import { allAbilities } from './data/ability'; import Battle, { BattleType, FixedBattleConfig, fixedBattles } from './battle'; import { GameMode, GameModes, gameModes } from './game-mode'; @@ -33,9 +31,6 @@ import TrainerData from './system/trainer-data'; import SoundFade from 'phaser3-rex-plugins/plugins/soundfade'; import { pokemonPrevolutions } from './data/pokemon-evolutions'; import PokeballTray from './ui/pokeball-tray'; -import { Setting, settingOptions } from './system/settings'; -import SettingsUiHandler from './ui/settings-ui-handler'; -import MessageUiHandler from './ui/message-ui-handler'; import { Species } from './data/enums/species'; import InvertPostFX from './pipelines/invert'; import { Achv, ModifierAchv, MoneyAchv, achvs } from './system/achv'; @@ -653,7 +648,7 @@ export default class BattleScene extends SceneBase { const icon = this.add.sprite(0, 0, pokemon.getIconAtlasKey(ignoreOverride)); icon.setFrame(pokemon.getIconId(true)); // Temporary fix to show pokemon's default icon if variant icon doesn't exist - if (icon.frame.name != pokemon.getIconId(true)) { + if (icon.frame.name !== pokemon.getIconId(true)) { console.log(`${pokemon.name}'s variant icon does not exist. Replacing with default.`); const temp = pokemon.shiny; pokemon.shiny = false; @@ -921,7 +916,7 @@ export default class BattleScene extends SceneBase { const resetArenaState = isNewBiome || this.currentBattle.battleType === BattleType.TRAINER || this.currentBattle.battleSpec === BattleSpec.FINAL_BOSS; this.getEnemyParty().forEach(enemyPokemon => enemyPokemon.destroy()); this.trySpreadPokerus(); - if (!isNewBiome && (newWaveIndex % 10) == 5) + if (!isNewBiome && (newWaveIndex % 10) === 5) this.arena.updatePoolsForTimeOfDay(); if (resetArenaState) { this.arena.removeAllTags(); @@ -1791,7 +1786,7 @@ export default class BattleScene extends SceneBase { const modifierChance = this.gameMode.getEnemyModifierChance(isBoss); let pokemonModifierChance = modifierChance; if (this.currentBattle.battleType === BattleType.TRAINER) - pokemonModifierChance = Math.ceil(pokemonModifierChance * this.currentBattle.trainer.getPartyMemberModifierChanceMultiplier(i)); + pokemonModifierChance = Math.ceil(pokemonModifierChance * this.currentBattle.trainer.getPartyMemberModifierChanceMultiplier(i)); // eslint-disable-line let count = 0; for (let c = 0; c < chances; c++) { if (!Utils.randSeedInt(modifierChance)) diff --git a/src/battle.ts b/src/battle.ts index b66159cf9cc..ef6af27062e 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -10,7 +10,6 @@ import { GameMode } from './game-mode'; import { BattleSpec } from './enums/battle-spec'; import { PlayerGender } from './system/game-data'; import { MoneyMultiplierModifier, PokemonHeldItemModifier } from './modifier/modifier'; -import { MoneyAchv } from './system/achv'; import { PokeballType } from './data/pokeball'; export enum BattleType { @@ -221,7 +220,6 @@ export default class Battle { randSeedInt(scene: BattleScene, range: integer, min: integer = 0): integer { if (range <= 1) return min; - let ret: integer; const tempRngCounter = scene.rngCounter; const tempSeedOverride = scene.rngSeedOverride; const state = Phaser.Math.RND.state(); @@ -233,7 +231,7 @@ export default class Battle { } scene.rngCounter = this.rngCounter++; scene.rngSeedOverride = this.battleSeed; - ret = Utils.randSeedInt(range, min); + const ret = Utils.randSeedInt(range, min); this.battleSeedState = Phaser.Math.RND.state(); Phaser.Math.RND.state(state); scene.rngCounter = tempRngCounter; diff --git a/src/data/ability.ts b/src/data/ability.ts index c3c51c0d4cf..5815bb3e5be 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -9,7 +9,7 @@ import { BattlerTag } from './battler-tags'; import { BattlerTagType } from './enums/battler-tag-type'; import { StatusEffect, getStatusEffectDescriptor, getStatusEffectHealText } from './status-effect'; import { Gender } from './gender'; -import Move, { AttackMove, MoveCategory, MoveFlags, MoveTarget, RecoilAttr, StatusMoveTypeImmunityAttr, FlinchAttr, OneHitKOAttr, HitHealAttr, StrengthSapHealAttr, allMoves, StatusMove, VariablePowerAttr, applyMoveAttrs, IncrementMovePriorityAttr } from './move'; +import Move, { AttackMove, MoveCategory, MoveFlags, MoveTarget, StatusMoveTypeImmunityAttr, FlinchAttr, OneHitKOAttr, HitHealAttr, StrengthSapHealAttr, allMoves, StatusMove, VariablePowerAttr, applyMoveAttrs, IncrementMovePriorityAttr } from './move'; import { ArenaTagSide, ArenaTrapTag } from './arena-tag'; import { ArenaTagType } from './enums/arena-tag-type'; import { Stat } from './pokemon-stat'; @@ -20,9 +20,7 @@ import { SpeciesFormChangeManualTrigger } from './pokemon-forms'; import { Abilities } from './enums/abilities'; import i18next, { Localizable } from '#app/plugins/i18n.js'; import { Command } from '../ui/command-ui-handler'; -import Battle from '#app/battle.js'; -import { ability } from '#app/locales/en/ability.js'; -import { PokeballType, getPokeballName } from './pokeball'; +import { getPokeballName } from './pokeball'; export class Ability implements Localizable { public id: Abilities; @@ -453,7 +451,7 @@ export class PostDefendAbAttr extends AbAttr { export class PostDefendDisguiseAbAttr extends PostDefendAbAttr { applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean { - if (pokemon.formIndex == 0 && pokemon.battleData.hitCount != 0 && (move.getMove().category == MoveCategory.SPECIAL || move.getMove().category == MoveCategory.PHYSICAL)) { + if (pokemon.formIndex === 0 && pokemon.battleData.hitCount !== 0 && (move.getMove().category === MoveCategory.SPECIAL || move.getMove().category === MoveCategory.PHYSICAL)) { const recoilDamage = Math.ceil((pokemon.getMaxHp() / 8) - attacker.turnData.damageDealt); if (!recoilDamage) @@ -956,7 +954,7 @@ export class MoveTypeChangePowerMultiplierAbAttr extends VariableMoveTypeAbAttr apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { const type = (args[0] as Utils.IntegerHolder); - if (type.value == this.matchType) { + if (type.value === this.matchType) { type.value = this.newType; (args[1] as Utils.NumberHolder).value *= this.powerMultiplier; return true; @@ -1181,7 +1179,7 @@ export class PostAttackApplyStatusEffectAbAttr extends PostAttackAbAttr { } applyPostAttack(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean { - if (pokemon != attacker && (!this.contactRequired || move.getMove().checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon)) && pokemon.randSeedInt(100) < this.chance && !pokemon.status) { + if (pokemon !== attacker && (!this.contactRequired || move.getMove().checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon)) && pokemon.randSeedInt(100) < this.chance && !pokemon.status) { const effect = this.effects.length === 1 ? this.effects[0] : this.effects[pokemon.randSeedInt(this.effects.length)]; return attacker.trySetStatus(effect, true, pokemon); } @@ -1211,7 +1209,7 @@ export class PostAttackApplyBattlerTagAbAttr extends PostAttackAbAttr { } applyPostAttack(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean { - if (pokemon != attacker && (!this.contactRequired || move.getMove().checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon)) && pokemon.randSeedInt(100) < this.chance(attacker, pokemon, move) && !pokemon.status) { + if (pokemon !== attacker && (!this.contactRequired || move.getMove().checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon)) && pokemon.randSeedInt(100) < this.chance(attacker, pokemon, move) && !pokemon.status) { const effect = this.effects.length === 1 ? this.effects[0] : this.effects[pokemon.randSeedInt(this.effects.length)]; @@ -2327,7 +2325,7 @@ export class FetchBallAbAttr extends PostTurnAbAttr { */ applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean { const lastUsed = pokemon.scene.currentBattle.lastUsedPokeball; - if(lastUsed != null && pokemon.isPlayer) { + if(lastUsed !== null && pokemon.isPlayer) { pokemon.scene.pokeballCounts[lastUsed]++; pokemon.scene.currentBattle.lastUsedPokeball = null; pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` found a\n${getPokeballName(lastUsed)}!`)); @@ -3161,8 +3159,8 @@ export function initAbilities() { new Ability(Abilities.TRUANT, 3) .attr(PostSummonAddBattlerTagAbAttr, BattlerTagType.TRUANT, 1, false), new Ability(Abilities.HUSTLE, 3) - .attr(BattleStatMultiplierAbAttr, BattleStat.ATK, 1.5, (user, target, move) => move.category == MoveCategory.PHYSICAL) - .attr(BattleStatMultiplierAbAttr, BattleStat.ACC, 0.8, (user, target, move) => move.category == MoveCategory.PHYSICAL), + .attr(BattleStatMultiplierAbAttr, BattleStat.ATK, 1.5, (user, target, move) => move.category === MoveCategory.PHYSICAL) + .attr(BattleStatMultiplierAbAttr, BattleStat.ACC, 0.8, (user, target, move) => move.category === MoveCategory.PHYSICAL), new Ability(Abilities.CUTE_CHARM, 3) .attr(PostDefendContactApplyTagChanceAbAttr, 30, BattlerTagType.INFATUATED), new Ability(Abilities.PLUS, 3) @@ -3599,7 +3597,7 @@ export function initAbilities() { .attr(UnsuppressableAbilityAbAttr) .attr(NoFusionAbilityAbAttr), new Ability(Abilities.DISGUISE, 7) - .attr(PreDefendMovePowerToOneAbAttr, (target, user, move) => target.formIndex == 0 && target.getAttackTypeEffectiveness(move.type, user) > 0) + .attr(PreDefendMovePowerToOneAbAttr, (target, user, move) => target.formIndex === 0 && target.getAttackTypeEffectiveness(move.type, user) > 0) .attr(PostSummonFormChangeAbAttr, p => p.battleData.hitCount === 0 ? 0 : 1) .attr(PostBattleInitFormChangeAbAttr, p => p.battleData.hitCount === 0 ? 0 : 1) .attr(PostDefendFormChangeAbAttr, p => p.battleData.hitCount === 0 ? 0 : 1) diff --git a/src/data/arena-tag.ts b/src/data/arena-tag.ts index d8874e6717f..498571771be 100644 --- a/src/data/arena-tag.ts +++ b/src/data/arena-tag.ts @@ -427,7 +427,9 @@ class StickyWebTag extends ArenaTrapTag { onAdd(arena: Arena): void { super.onAdd(arena); - + + // does not seem to be used anywhere + // eslint-disable-next-line @typescript-eslint/no-unused-vars const source = arena.scene.getPokemonById(this.sourceId); arena.scene.queueMessage(`A ${this.getMoveName()} has been laid out on the ground around the opposing team!`); } diff --git a/src/data/battle-anims.ts b/src/data/battle-anims.ts index 131a73c05e3..2cc423db876 100644 --- a/src/data/battle-anims.ts +++ b/src/data/battle-anims.ts @@ -4,9 +4,8 @@ import { AttackMove, ChargeAttr, DelayedAttackAttr, MoveFlags, SelfStatusMove, a import Pokemon from '../field/pokemon'; import * as Utils from '../utils'; import { BattlerIndex } from '../battle'; -import stringify, { Element } from 'json-stable-stringify'; +import { Element } from 'json-stable-stringify'; import { Moves } from './enums/moves'; -import { getTypeRgb } from './type'; //import fs from 'vite-plugin-fs/browser'; export enum AnimFrameTarget { @@ -795,8 +794,7 @@ export abstract class BattleAnim { const sprites = spriteCache[isUser ? AnimFrameTarget.USER : AnimFrameTarget.TARGET]; const spriteSource = isUser ? userSprite : targetSprite; if ((isUser ? u : t) === sprites.length) { - let sprite: Phaser.GameObjects.Sprite; - sprite = scene.addPokemonSprite(isUser ? user : target, 0, 0, spriteSource.texture, spriteSource.frame.name, true); + const sprite = scene.addPokemonSprite(isUser ? user : target, 0, 0, spriteSource.texture, spriteSource.frame.name, true); [ 'spriteColors', 'fusionSpriteColors' ].map(k => sprite.pipelineData[k] = (isUser ? user : target).getSprite().pipelineData[k]); sprite.setPipelineData('spriteKey', (isUser ? user : target).getBattleSpriteKey()); sprite.setPipelineData('shiny', (isUser ? user : target).shiny); @@ -1151,6 +1149,8 @@ export async function populateAnims() { } } + // used in commented code + // eslint-disable-next-line @typescript-eslint/no-unused-vars const animReplacer = (k, v) => { if (k === 'id' && !v) return undefined; @@ -1165,9 +1165,10 @@ export async function populateAnims() { const animFrameProps = [ 'x', 'y', 'zoomX', 'zoomY', 'angle', 'mirror', 'visible', 'blendType', 'target', 'graphicFrame', 'opacity', 'color', 'tone', 'flash', 'locked', 'priority', 'focus' ]; const propSets = [ animConfigProps, animFrameProps ]; + // used in commented code + // eslint-disable-next-line @typescript-eslint/no-unused-vars const animComparator = (a: Element, b: Element) => { let props: string[]; - const p = 0; for (let p = 0; p < propSets.length; p++) { props = propSets[p]; const ai = props.indexOf(a.key); diff --git a/src/data/berry.ts b/src/data/berry.ts index 698557f8518..beeaee75860 100644 --- a/src/data/berry.ts +++ b/src/data/berry.ts @@ -1,7 +1,6 @@ import { PokemonHealPhase, StatChangePhase } from '../phases'; import { getPokemonMessage } from '../messages'; import Pokemon, { HitResult } from '../field/pokemon'; -import { getBattleStatName } from './battle-stat'; import { BattleStat } from './battle-stat'; import { BattlerTagType } from './enums/battler-tag-type'; import { getStatusEffectHealText } from './status-effect'; diff --git a/src/data/biomes.ts b/src/data/biomes.ts index 2eab9e3ce45..8d4b2cbee87 100644 --- a/src/data/biomes.ts +++ b/src/data/biomes.ts @@ -7794,6 +7794,8 @@ export const biomeTrainerPools: BiomeTrainerPools = { //outputPools(); }); + // used in a commented code + // eslint-disable-next-line @typescript-eslint/no-unused-vars function outputPools() { const pokemonOutput = {}; const trainerOutput = {}; diff --git a/src/data/egg.ts b/src/data/egg.ts index 1c5f75b143e..cefb1f7c693 100644 --- a/src/data/egg.ts +++ b/src/data/egg.ts @@ -1,5 +1,3 @@ -import { Type } from './type'; -import * as Utils from '../utils'; import BattleScene from '../battle-scene'; import { Species } from './enums/species'; import { getPokemonSpecies, speciesStarters } from './pokemon-species'; @@ -98,7 +96,6 @@ export function getLegendaryGachaSpeciesForTimestamp(scene: BattleScene, timesta // 86400000 is the number of miliseconds in one day const timeDate = new Date(timestamp); - const dayDate = new Date(Date.UTC(timeDate.getUTCFullYear(), timeDate.getUTCMonth(), timeDate.getUTCDate())); const dayTimestamp = timeDate.getTime(); // Timestamp of current week const offset = Math.floor(Math.floor(dayTimestamp / 86400000) / legendarySpecies.length); // Cycle number const index = Math.floor(dayTimestamp / 86400000) % legendarySpecies.length; // Index within cycle diff --git a/src/data/move.ts b/src/data/move.ts index 83bc946bd0a..24f6b3d4857 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1,6 +1,6 @@ import { Moves } from './enums/moves'; import { ChargeAnim, MoveChargeAnim, initMoveAnim, loadMoveAnimAssets } from './battle-anims'; -import { BattleEndPhase, MoveEffectPhase, MovePhase, NewBattlePhase, PartyStatusCurePhase, PokemonHealPhase, StatChangePhase, SwitchSummonPhase, ToggleDoublePositionPhase } from '../phases'; +import { BattleEndPhase, MovePhase, NewBattlePhase, PartyStatusCurePhase, PokemonHealPhase, StatChangePhase, SwitchSummonPhase } from '../phases'; import { BattleStat, getBattleStatName } from './battle-stat'; import { EncoreTag } from './battler-tags'; import { BattlerTagType } from './enums/battler-tag-type'; @@ -12,7 +12,7 @@ import * as Utils from '../utils'; import { WeatherType } from './weather'; import { ArenaTagSide, ArenaTrapTag } from './arena-tag'; import { ArenaTagType } from './enums/arena-tag-type'; -import { UnswappableAbilityAbAttr, UncopiableAbilityAbAttr, UnsuppressableAbilityAbAttr, NoTransformAbilityAbAttr, BlockRecoilDamageAttr, BlockOneHitKOAbAttr, IgnoreContactAbAttr, MaxMultiHitAbAttr, applyAbAttrs, BlockNonDirectDamageAbAttr, applyPreSwitchOutAbAttrs, PreSwitchOutAbAttr, applyPostDefendAbAttrs, PostDefendContactApplyStatusEffectAbAttr, MoveAbilityBypassAbAttr, ReverseDrainAbAttr, FieldPreventExplosiveMovesAbAttr, ForceSwitchOutImmunityAbAttr, PreventBerryUseAbAttr, BlockItemTheftAbAttr } from './ability'; +import { UnswappableAbilityAbAttr, UncopiableAbilityAbAttr, UnsuppressableAbilityAbAttr, BlockRecoilDamageAttr, BlockOneHitKOAbAttr, IgnoreContactAbAttr, MaxMultiHitAbAttr, applyAbAttrs, BlockNonDirectDamageAbAttr, applyPreSwitchOutAbAttrs, PreSwitchOutAbAttr, applyPostDefendAbAttrs, PostDefendContactApplyStatusEffectAbAttr, MoveAbilityBypassAbAttr, ReverseDrainAbAttr, FieldPreventExplosiveMovesAbAttr, ForceSwitchOutImmunityAbAttr, BlockItemTheftAbAttr } from './ability'; import { Abilities } from './enums/abilities'; import { allAbilities } from './ability'; import { PokemonHeldItemModifier, BerryModifier, PreserveBerryModifier } from '../modifier/modifier'; @@ -25,7 +25,7 @@ import { ModifierPoolType } from '#app/modifier/modifier-type'; import { Command } from '../ui/command-ui-handler'; import { Biome } from './enums/biome'; import i18next, { Localizable } from '../plugins/i18n'; -import { BerryType, BerryEffectFunc, getBerryEffectFunc } from './berry'; +import { getBerryEffectFunc } from './berry'; export enum MoveCategory { PHYSICAL, @@ -1296,7 +1296,7 @@ export class ChangeMultiHitTypeAttr extends MoveAttr { export class WaterShurikenMultiHitTypeAttr extends ChangeMultiHitTypeAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - if (user.species.speciesId == Species.GRENINJA && user.hasAbility(Abilities.BATTLE_BOND) && user.formIndex == 2) { + if (user.species.speciesId === Species.GRENINJA && user.hasAbility(Abilities.BATTLE_BOND) && user.formIndex === 2) { (args[0] as Utils.IntegerHolder).value = MultiHitType._3; return true; } @@ -1549,7 +1549,7 @@ export class StealEatBerryAttr extends EatBerryAttr { const cancelled = new Utils.BooleanHolder(false); applyAbAttrs(BlockItemTheftAbAttr, target, cancelled); // check for abilities that block item theft - if(cancelled.value == true) + if(cancelled.value === true) return false; const heldBerries = this.getTargetHeldBerries(target).filter(i => i.getTransferrable(false)); @@ -1557,7 +1557,7 @@ export class StealEatBerryAttr extends EatBerryAttr { if (heldBerries.length) { // if the target has berries, pick a random berry and steal it this.chosenBerry = heldBerries[user.randSeedInt(heldBerries.length)]; - if (this.chosenBerry.stackCount == 1) // remove modifier if its the last berry + if (this.chosenBerry.stackCount === 1) // remove modifier if its the last berry target.scene.removeModifier(this.chosenBerry, !target.isPlayer()); target.scene.updateModifiers(target.isPlayer()); @@ -2643,7 +2643,7 @@ export class KnockOffPowerAttr extends VariablePowerAttr { export class WaterShurikenPowerAttr extends VariablePowerAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - if (user.species.speciesId == Species.GRENINJA && user.hasAbility(Abilities.BATTLE_BOND) && user.formIndex == 2) { + if (user.species.speciesId === Species.GRENINJA && user.hasAbility(Abilities.BATTLE_BOND) && user.formIndex === 2) { (args[0] as Utils.IntegerHolder).value = 20; return true; } @@ -3838,7 +3838,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr { const switchOutTarget = (this.user ? user : target); const player = switchOutTarget instanceof PlayerPokemon; - if (!this.user && move.category == MoveCategory.STATUS && (target.hasAbilityWithAttr(ForceSwitchOutImmunityAbAttr) || target.isMax())) + if (!this.user && move.category === MoveCategory.STATUS && (target.hasAbilityWithAttr(ForceSwitchOutImmunityAbAttr) || target.isMax())) return false; if (!player && !user.scene.currentBattle.battleType) { @@ -3882,7 +3882,7 @@ export class RemoveTypeAttr extends MoveEffectAttr { if (!super.apply(user, target, move, args)) return false; - if(user.isTerastallized && user.getTeraType() == this.removedType) // active tera types cannot be removed + if(user.isTerastallized && user.getTeraType() === this.removedType) // active tera types cannot be removed return false; const userTypes = user.getTypes(true); @@ -6711,7 +6711,7 @@ export function initMoves() { .bitingMove() .attr(RemoveScreensAttr), new AttackMove(Moves.STOMPING_TANTRUM, Type.GROUND, MoveCategory.PHYSICAL, 75, 100, 10, -1, 0, 7) - .attr(MovePowerMultiplierAttr, (user, target, move) => user.getLastXMoves(2)[1]?.result == MoveResult.MISS || user.getLastXMoves(2)[1]?.result == MoveResult.FAIL ? 2 : 1), + .attr(MovePowerMultiplierAttr, (user, target, move) => user.getLastXMoves(2)[1]?.result === MoveResult.MISS || user.getLastXMoves(2)[1]?.result === MoveResult.FAIL ? 2 : 1), new AttackMove(Moves.SHADOW_BONE, Type.GHOST, MoveCategory.PHYSICAL, 85, 100, 10, 20, 0, 7) .attr(StatChangeAttr, BattleStat.DEF, -1) .makesContact(false), @@ -7270,7 +7270,7 @@ export function initMoves() { .recklessMove(), new AttackMove(Moves.LAST_RESPECTS, Type.GHOST, MoveCategory.PHYSICAL, 50, 100, 10, -1, 0, 9) .attr(MovePowerMultiplierAttr, (user, target, move) => { - return user.scene.getParty().reduce((acc, pokemonInParty) => acc + (pokemonInParty.status?.effect == StatusEffect.FAINT ? 1 : 0), + return user.scene.getParty().reduce((acc, pokemonInParty) => acc + (pokemonInParty.status?.effect === StatusEffect.FAINT ? 1 : 0), 1,); }) .makesContact(false), @@ -7472,7 +7472,7 @@ export function initMoves() { .soundBased() .partial(), new AttackMove(Moves.TEMPER_FLARE, Type.FIRE, MoveCategory.PHYSICAL, 75, 100, 10, -1, 0, 9) - .attr(MovePowerMultiplierAttr, (user, target, move) => user.getLastXMoves(2)[1]?.result == MoveResult.MISS || user.getLastXMoves(2)[1]?.result == MoveResult.FAIL ? 2 : 1), + .attr(MovePowerMultiplierAttr, (user, target, move) => user.getLastXMoves(2)[1]?.result === MoveResult.MISS || user.getLastXMoves(2)[1]?.result === MoveResult.FAIL ? 2 : 1), new AttackMove(Moves.SUPERCELL_SLAM, Type.ELECTRIC, MoveCategory.PHYSICAL, 100, 95, 15, -1, 0, 9) .attr(MissEffectAttr, crashDamageFunc) .attr(NoEffectAttr, crashDamageFunc) diff --git a/src/data/pokemon-evolutions.ts b/src/data/pokemon-evolutions.ts index d9f2152585e..62824b5e94e 100644 --- a/src/data/pokemon-evolutions.ts +++ b/src/data/pokemon-evolutions.ts @@ -1,5 +1,5 @@ import { Gender } from './gender'; -import { AttackTypeBoosterModifier, FlinchChanceModifier } from '../modifier/modifier'; +import { FlinchChanceModifier } from '../modifier/modifier'; import { Moves } from './enums/moves'; import { PokeballType } from './pokeball'; import Pokemon from '../field/pokemon'; @@ -1254,7 +1254,7 @@ export const pokemonEvolutions: PokemonEvolutions = { new SpeciesEvolution(Species.CLOYSTER, 1, EvolutionItem.WATER_STONE, null, SpeciesWildEvolutionDelay.LONG) ], [Species.EXEGGCUTE]: [ - new SpeciesEvolution(Species.ALOLA_EXEGGUTOR, 1, EvolutionItem.LEAF_STONE, new SpeciesEvolutionCondition(p => p.scene.arena.biomeType === Biome.ISLAND || p.scene.arena.biomeType == Biome.BEACH), SpeciesWildEvolutionDelay.LONG), + new SpeciesEvolution(Species.ALOLA_EXEGGUTOR, 1, EvolutionItem.LEAF_STONE, new SpeciesEvolutionCondition(p => p.scene.arena.biomeType === Biome.ISLAND || p.scene.arena.biomeType === Biome.BEACH), SpeciesWildEvolutionDelay.LONG), new SpeciesEvolution(Species.EXEGGUTOR, 1, EvolutionItem.LEAF_STONE, null, SpeciesWildEvolutionDelay.LONG) ], [Species.TANGELA]: [ diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index f4ea08d15cc..aa6872e3928 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -231,10 +231,9 @@ export abstract class PokemonSpeciesForm { const baseSpriteKey = `${showGenderDiffs ? 'female__' : ''}${this.speciesId}${formSpriteKey ? `-${formSpriteKey}` : ''}`; - let variantSet: VariantSet; let config = variantData; `${back ? 'back__' : ''}${baseSpriteKey}`.split('__').map(p => config ? config = config[p] : null); - variantSet = config as VariantSet; + const variantSet = config as VariantSet; return `${back ? 'back__' : ''}${shiny && (!variantSet || (!variant && !variantSet[variant || 0])) ? 'shiny__' : ''}${baseSpriteKey}${shiny && variantSet && variantSet[variant || 0] === 2 ? `_${variant + 1}` : ''}`; } @@ -395,10 +394,9 @@ export abstract class PokemonSpeciesForm { const useExpSprite = scene.experimentalSprites && scene.hasExpSprite(spriteKey); if (useExpSprite) spritePath = `exp/${spritePath}`; - let variantSet: VariantSet; let config = variantData; spritePath.split('/').map(p => config ? config = config[p] : null); - variantSet = config as VariantSet; + const variantSet = config as VariantSet; if (variantSet && variantSet[variant] === 1) { const populateVariantColors = (key: string): Promise => { return new Promise(resolve => { diff --git a/src/data/trainer-names.ts b/src/data/trainer-names.ts index 4ef5ef1811b..07044bbbc8c 100644 --- a/src/data/trainer-names.ts +++ b/src/data/trainer-names.ts @@ -19,6 +19,8 @@ interface TrainerNameConfigs { [key: integer]: TrainerNameConfig } +// used in a commented code +// eslint-disable-next-line @typescript-eslint/no-unused-vars const trainerNameConfigs: TrainerNameConfigs = { [TrainerType.ACE_TRAINER]: new TrainerNameConfig(TrainerType.ACE_TRAINER), [TrainerType.ARTIST]: new TrainerNameConfig(TrainerType.ARTIST), @@ -121,6 +123,8 @@ export const trainerNamePools = { [TrainerType.HEX_MANIAC]: ['Kindra','Patricia','Tammy','Tasha','Valerie','Alaina','Kathleen','Leah','Makie','Sylvia','Anina','Arachna','Carrie','Desdemona','Josette','Luna','Melanie','Osanna','Raziah'], }; +// function used in a commented code +// eslint-disable-next-line @typescript-eslint/no-unused-vars function fetchAndPopulateTrainerNames(url: string, parser: DOMParser, trainerNames: Set, femaleTrainerNames: Set, forceFemale: boolean = false) { return new Promise(resolve => { fetch(`https://bulbapedia.bulbagarden.net/wiki/${url}_(Trainer_class)`) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 81be09d2b5b..4bd8300780b 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -17,7 +17,7 @@ import { initMoveAnim, loadMoveAnimAssets } from '../data/battle-anims'; import { Status, StatusEffect, getRandomStatus } from '../data/status-effect'; import { pokemonEvolutions, pokemonPrevolutions, SpeciesFormEvolution, SpeciesEvolutionCondition, FusionSpeciesFormEvolution } from '../data/pokemon-evolutions'; import { reverseCompatibleTms, tmSpecies, tmPoolTiers } from '../data/tms'; -import { DamagePhase, FaintPhase, LearnMovePhase, ObtainStatusEffectPhase, StatChangePhase, SwitchPhase, SwitchSummonPhase, ToggleDoublePositionPhase } from '../phases'; +import { DamagePhase, FaintPhase, LearnMovePhase, ObtainStatusEffectPhase, StatChangePhase, SwitchSummonPhase, ToggleDoublePositionPhase } from '../phases'; import { BattleStat } from '../data/battle-stat'; import { BattlerTag, BattlerTagLapseType, EncoreTag, HelpingHandTag, HighestStatBoostTag, TypeBoostTag, getBattlerTag } from '../data/battler-tags'; import { BattlerTagType } from '../data/enums/battler-tag-type'; @@ -27,10 +27,10 @@ import { TempBattleStat } from '../data/temp-battle-stat'; import { ArenaTagSide, WeakenMoveScreenTag, WeakenMoveTypeTag } from '../data/arena-tag'; import { ArenaTagType } from '../data/enums/arena-tag-type'; import { Biome } from '../data/enums/biome'; -import { Ability, AbAttr, BattleStatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, FieldVariableMovePowerAbAttr, IgnoreOpponentStatChangesAbAttr, MoveImmunityAbAttr, MoveTypeChangeAttr, NonSuperEffectiveImmunityAbAttr, PreApplyBattlerTagAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, ReduceStatusEffectDurationAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, VariableMoveTypeAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyBattleStatMultiplierAbAttrs, applyPostDefendAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr } from '../data/ability'; +import { Ability, AbAttr, BattleStatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, FieldVariableMovePowerAbAttr, IgnoreOpponentStatChangesAbAttr, MoveImmunityAbAttr, MoveTypeChangeAttr, PreApplyBattlerTagAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, ReduceStatusEffectDurationAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, VariableMoveTypeAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyBattleStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr } from '../data/ability'; import { Abilities } from '#app/data/enums/abilities'; import PokemonData from '../system/pokemon-data'; -import Battle, { BattlerIndex } from '../battle'; +import { BattlerIndex } from '../battle'; import { BattleSpec } from '../enums/battle-spec'; import { Mode } from '../ui/ui'; import PartyUiHandler, { PartyOption, PartyUiMode } from '../ui/party-ui-handler'; @@ -321,11 +321,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const populateVariantColors = (key: string, back: boolean = false): Promise => { return new Promise(resolve => { const battleSpritePath = this.getBattleSpriteAtlasPath(back, ignoreOverride).replace('variant/', '').replace(/_[1-3]$/, ''); - let variantSet: VariantSet; let config = variantData; const useExpSprite = this.scene.experimentalSprites && this.scene.hasExpSprite(this.getBattleSpriteKey(back, ignoreOverride)); battleSpritePath.split('/').map(p => config ? config = config[p] : null); - variantSet = config as VariantSet; + const variantSet = config as VariantSet; if (variantSet && variantSet[this.variant] === 1) { if (variantColorCache.hasOwnProperty(key)) return resolve(); @@ -778,7 +777,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (includeTeraType) { const teraType = this.getTeraType(); - if (teraType != Type.UNKNOWN) + if (teraType !== Type.UNKNOWN) types.push(teraType); } @@ -1611,7 +1610,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (!result) { if (!typeMultiplier.value) - result = move.id == Moves.SHEER_COLD ? HitResult.IMMUNE : HitResult.NO_EFFECT; + result = move.id === Moves.SHEER_COLD ? HitResult.IMMUNE : HitResult.NO_EFFECT; else { const oneHitKo = new Utils.BooleanHolder(false); applyMoveAttrs(OneHitKOAttr, source, this, move, oneHitKo); @@ -1913,7 +1912,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const scene = sceneOverride || this.scene; const cry = this.getSpeciesForm().cry(scene, soundConfig); let duration = cry.totalDuration * 1000; - if (this.fusionSpecies && this.getSpeciesForm() != this.getFusionSpeciesForm()) { + if (this.fusionSpecies && this.getSpeciesForm() !== this.getFusionSpeciesForm()) { let fusionCry = this.getFusionSpeciesForm().cry(scene, soundConfig, true); duration = Math.min(duration, fusionCry.totalDuration * 1000); fusionCry.destroy(); @@ -1932,11 +1931,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } faintCry(callback: Function): void { - if (this.fusionSpecies && this.getSpeciesForm() != this.getFusionSpeciesForm()) + if (this.fusionSpecies && this.getSpeciesForm() !== this.getFusionSpeciesForm()) return this.fusionFaintCry(callback); const key = this.getSpeciesForm().getCryKey(this.formIndex); - let i = 0; let rate = 0.85; const cry = this.scene.playSound(key, { rate: rate }) as AnySound; const sprite = this.getSprite(); diff --git a/src/field/trainer.ts b/src/field/trainer.ts index f5bcdb24665..87519f08439 100644 --- a/src/field/trainer.ts +++ b/src/field/trainer.ts @@ -8,8 +8,7 @@ import { EnemyPokemon } from './pokemon'; import * as Utils from '../utils'; import { PersistentModifier } from '../modifier/modifier'; import { trainerNamePools } from '../data/trainer-names'; -import { ArenaTagType } from '#app/data/enums/arena-tag-type'; -import { ArenaTag, ArenaTagSide, ArenaTrapTag } from '#app/data/arena-tag'; +import { ArenaTagSide, ArenaTrapTag } from '#app/data/arena-tag'; import {getIsInitialized, initI18n} from '#app/plugins/i18n'; import i18next from 'i18next'; @@ -320,7 +319,6 @@ export default class Trainer extends Phaser.GameObjects.Container { const partyMemberScores = nonFaintedPartyMembers.map(p => { const playerField = this.scene.getPlayerField(); let score = 0; - let ret: [integer, integer]; for (const playerPokemon of playerField) { score += p.getMatchupScore(playerPokemon); if (playerPokemon.species.legendary) @@ -329,8 +327,7 @@ export default class Trainer extends Phaser.GameObjects.Container { score /= playerField.length; if (forSwitch && !p.isOnField()) this.scene.arena.findTagsOnSide(t => t instanceof ArenaTrapTag, ArenaTagSide.ENEMY).map(t => score *= (t as ArenaTrapTag).getMatchupScoreMultiplier(p)); - ret = [ party.indexOf(p), score ]; - return ret; + return [ party.indexOf(p), score ]; }); return partyMemberScores; diff --git a/src/inputs-controller.ts b/src/inputs-controller.ts index 336f2d00006..3c9a0d12d2b 100644 --- a/src/inputs-controller.ts +++ b/src/inputs-controller.ts @@ -215,7 +215,7 @@ export class InputsController { refreshGamepads(): void { // Sometimes, gamepads are undefined. For some reason. this.gamepads = this.scene.input.gamepad.gamepads.filter(function (el) { - return el != null; + return el !== null; }); for (const [index, thisGamepad] of this.gamepads.entries()) {