From 622885767d9216949729069b69987c6c907a5ee0 Mon Sep 17 00:00:00 2001 From: Greenlamp2 <44787002+Greenlamp2@users.noreply.github.com> Date: Fri, 24 May 2024 02:19:20 +0200 Subject: [PATCH] Enforce Consistent Spacing with ESLint's space-before-blocks and keyword-spacing Rules (#1308) * added rule no-trailing-spaces * added rule space-before-block * added rule keyword spacing --- .eslintrc | 4 ++- src/data/ability.ts | 24 +++++++------- src/data/api.ts | 2 +- src/data/battler-tags.ts | 4 +-- src/data/berry.ts | 2 +- src/data/move.ts | 50 ++++++++++++++--------------- src/data/nature.ts | 2 +- src/field/pokemon.ts | 32 +++++++++--------- src/phases.ts | 6 ++-- src/system/game-data.ts | 2 +- src/test/pokemonSprite.test.ts | 2 +- src/test/testUtils.ts | 2 +- src/ui/party-ui-handler.ts | 10 +++--- src/ui/starter-select-ui-handler.ts | 2 +- src/ui/summary-ui-handler.ts | 8 ++--- 15 files changed, 77 insertions(+), 75 deletions(-) diff --git a/.eslintrc b/.eslintrc index 86a5399b378..e1f6ba9ee32 100644 --- a/.eslintrc +++ b/.eslintrc @@ -26,7 +26,9 @@ "no-trailing-spaces": ["error", { // Disallows trailing whitespace at the end of lines "skipBlankLines": false, // Enforces the rule even on blank lines "ignoreComments": false // Enforces the rule on lines containing comments - }] + }], + "space-before-blocks": ["error", "always"], // Enforces a space before blocks + "keyword-spacing": ["error", { "before": true, "after": true }] // Enforces spacing before and after keywords } } ] diff --git a/src/data/ability.ts b/src/data/ability.ts index b26fbcbfed8..70c1279b9d9 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -254,7 +254,7 @@ export class PreDefendFullHpEndureAbAttr extends PreDefendAbAttr { applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (pokemon.hp === pokemon.getMaxHp() && pokemon.getMaxHp() > 1 && //Checks if pokemon has wonder_guard (which forces 1hp) - (args[0] as Utils.NumberHolder).value >= pokemon.hp){ //Damage >= hp + (args[0] as Utils.NumberHolder).value >= pokemon.hp) { //Damage >= hp return pokemon.addTag(BattlerTagType.STURDY, 1); } @@ -499,11 +499,11 @@ export class FieldPriorityMoveImmunityAbAttr extends PreDefendAbAttr { applyMoveAttrs(IncrementMovePriorityAttr,attacker,null,move.getMove(),attackPriority); applyAbAttrs(IncrementMovePriorityAbAttr, attacker, null, move.getMove(), attackPriority); - if(move.getMove().moveTarget===MoveTarget.USER) { + if (move.getMove().moveTarget===MoveTarget.USER) { return false; } - if(attackPriority.value > 0 && !move.getMove().isMultiTarget()) { + if (attackPriority.value > 0 && !move.getMove().isMultiTarget()) { cancelled.value = true; return true; } @@ -955,7 +955,7 @@ export class MoveTypeChangePowerMultiplierAbAttr extends VariableMoveTypeAbAttr private newType: Type; private powerMultiplier: number; - constructor(matchType: Type, newType: Type, powerMultiplier: number){ + constructor(matchType: Type, newType: Type, powerMultiplier: number) { super(true); this.matchType = matchType; this.newType = newType; @@ -986,7 +986,7 @@ export class MoveTypeChangeAttr extends PreAttackAbAttr { private powerMultiplier: number; private condition: PokemonAttackCondition; - constructor(newType: Type, powerMultiplier: number, condition: PokemonAttackCondition){ + constructor(newType: Type, powerMultiplier: number, condition: PokemonAttackCondition) { super(true); this.newType = newType; this.powerMultiplier = powerMultiplier; @@ -1015,7 +1015,7 @@ export class DamageBoostAbAttr extends PreAttackAbAttr { private damageMultiplier: number; private condition: PokemonAttackCondition; - constructor(damageMultiplier: number, condition: PokemonAttackCondition){ + constructor(damageMultiplier: number, condition: PokemonAttackCondition) { super(true); this.damageMultiplier = damageMultiplier; this.condition = condition; @@ -1860,7 +1860,7 @@ export class MultCritAbAttr extends AbAttr { apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { const critMult = args[0] as Utils.NumberHolder; - if (critMult.value > 1){ + if (critMult.value > 1) { critMult.value *= this.multAmount; return true; } @@ -1892,7 +1892,7 @@ export class ConditionalCritAbAttr extends AbAttr { apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { const target = (args[1] as Pokemon); const move = (args[2] as Move); - if(!this.condition(pokemon,target,move)) { + if (!this.condition(pokemon,target,move)) { return false; } @@ -2410,8 +2410,8 @@ export class PostTurnHurtIfSleepingAbAttr extends PostTurnAbAttr { */ applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { let hadEffect: boolean = false; - for(const opp of pokemon.getOpponents()) { - if(opp.status !== undefined && opp.status.effect === StatusEffect.SLEEP) { + for (const opp of pokemon.getOpponents()) { + if (opp.status !== undefined && opp.status.effect === StatusEffect.SLEEP) { opp.damageAndUpdate(Math.floor(Math.max(1, opp.getMaxHp() / 8)), HitResult.OTHER); pokemon.scene.queueMessage(i18next.t("abilityTriggers:badDreams", {pokemonName: `${getPokemonPrefix(opp)}${opp.name}`})); hadEffect = true; @@ -2440,7 +2440,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)}!`)); @@ -2575,7 +2575,7 @@ export class ArenaTrapAbAttr extends CheckTrappedAbAttr { * @returns if enemy Pokemon is trapped or not */ applyCheckTrapped(pokemon: Pokemon, passive: boolean, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, args: any[]): boolean { - if (otherPokemon.getTypes().includes(Type.GHOST)){ + if (otherPokemon.getTypes().includes(Type.GHOST)) { trapped.value = false; return false; } diff --git a/src/data/api.ts b/src/data/api.ts index 3e31f55fed0..2a88fc8d410 100644 --- a/src/data/api.ts +++ b/src/data/api.ts @@ -236,7 +236,7 @@ export async function printPokemon() { let generationIndex = 0; if (!region) { - while (++generationIndex < 9 && dexId > generationDexNumbers[generationIndex]){} + while (++generationIndex < 9 && dexId > generationDexNumbers[generationIndex]) {} } else { generationIndex = regionalForms.indexOf(region.toLowerCase()) + 6; } diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 5a01e01f704..13f1ae2cf7c 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -178,7 +178,7 @@ export class FlinchedTag extends BattlerTag { } export class InterruptedTag extends BattlerTag { - constructor(sourceMove: Moves){ + constructor(sourceMove: Moves) { super(BattlerTagType.INTERRUPTED, BattlerTagLapseType.PRE_MOVE, 0, sourceMove); } @@ -585,7 +585,7 @@ export class MinimizeTag extends BattlerTag { lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { //If a pokemon dynamaxes they lose minimized status - if(pokemon.isMax()){ + if (pokemon.isMax()) { return false; } return lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType); diff --git a/src/data/berry.ts b/src/data/berry.ts index 1a2ceb17fa8..e832ab0a43e 100644 --- a/src/data/berry.ts +++ b/src/data/berry.ts @@ -137,7 +137,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc { pokemon.battleData.berriesEaten.push(berryType); } const ppRestoreMove = pokemon.getMoveset().find(m => !m.getPpRatio()) ? pokemon.getMoveset().find(m => !m.getPpRatio()) : pokemon.getMoveset().find(m => m.getPpRatio() < 1); - if(ppRestoreMove !== undefined){ + if (ppRestoreMove !== undefined) { ppRestoreMove.ppUsed = Math.max(ppRestoreMove.ppUsed - 10, 0); pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` restored PP to its move ${ppRestoreMove.getName()}\nusing its ${getBerryName(berryType)}!`)); } diff --git a/src/data/move.ts b/src/data/move.ts index 736e047e485..34ae05dbd33 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -923,7 +923,7 @@ export class HalfSacrificialAttr extends MoveEffectAttr { const cancelled = new Utils.BooleanHolder(false); // Check to see if the Pokemon has an ability that blocks non-direct damage applyAbAttrs(BlockNonDirectDamageAbAttr, user, cancelled); - if (!cancelled.value){ + if (!cancelled.value) { user.damageAndUpdate(Math.ceil(user.getMaxHp()/2), HitResult.OTHER, false, true, true); user.scene.queueMessage(getPokemonMessage(user, " cut its own HP to power up its move!")); // Queue recoil message } @@ -1054,7 +1054,7 @@ export class IgnoreWeatherTypeDebuffAttr extends MoveAttr { /** The {@linkcode WeatherType} this move ignores */ public weather: WeatherType; - constructor(weather: WeatherType){ + constructor(weather: WeatherType) { super(); this.weather = weather; } @@ -1542,9 +1542,9 @@ export class EatBerryAttr extends MoveEffectAttr { return false; } - if(this.chosenBerry === undefined) { // if no berry has been provided, pick a random berry from their inventory + if (this.chosenBerry === undefined) { // if no berry has been provided, pick a random berry from their inventory const heldBerries = this.getTargetHeldBerries(target); - if(heldBerries.length <= 0) { + if (heldBerries.length <= 0) { return false; } this.chosenBerry = heldBerries[user.randSeedInt(heldBerries.length)]; @@ -1555,7 +1555,7 @@ export class EatBerryAttr extends MoveEffectAttr { const preserve = new Utils.BooleanHolder(false); target.scene.applyModifiers(PreserveBerryModifier, target.isPlayer(), target, preserve); - if (!preserve.value){ // remove the eaten berry if not preserved + if (!preserve.value) { // remove the eaten berry if not preserved if (!--this.chosenBerry.stackCount) { target.scene.removeModifier(this.chosenBerry, !target.isPlayer()); } @@ -1592,7 +1592,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; } @@ -2012,7 +2012,7 @@ export class PostVictoryStatChangeAttr extends MoveAttr { this.showMessage = showMessage; } applyPostVictory(user: Pokemon, target: Pokemon, move: Move): void { - if(this.condition && !this.condition(user, target, move)) { + if (this.condition && !this.condition(user, target, move)) { return false; } const statChangeAttr = new StatChangeAttr(this.stats, this.levels, this.showMessage); @@ -2257,7 +2257,7 @@ export class LessPPMorePowerAttr extends VariablePowerAttr { let ppRemains = ppMax - ppUsed; /** Reduce to 0 to avoid negative numbers if user has 1PP before attack and target has Ability.PRESSURE */ - if(ppRemains < 0) { + if (ppRemains < 0) { ppRemains = 0; } @@ -2713,7 +2713,7 @@ export class PresentPowerAttr extends VariablePowerAttr { export class KnockOffPowerAttr extends VariablePowerAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - if(target.getHeldItems().length > 0){ + if (target.getHeldItems().length > 0) { (args[0] as Utils.NumberHolder).value *= 1.5; return true; } @@ -2744,7 +2744,7 @@ export class VariableAtkAttr extends MoveAttr { } export class TargetAtkUserAtkAttr extends VariableAtkAttr { - constructor(){ + constructor() { super(); } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { @@ -2831,7 +2831,7 @@ export class MinimizeAccuracyAttr extends VariableAccuracyAttr { * @returns true if the function succeeds */ apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - if (target.getTag(BattlerTagType.MINIMIZED)){ + if (target.getTag(BattlerTagType.MINIMIZED)) { const accuracy = args[0] as Utils.NumberHolder; accuracy.value = -1; @@ -3086,7 +3086,7 @@ export class TerrainPulseTypeAttr extends VariableMoveTypeAttr { * @returns true if the function succeeds */ apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - if(!user.isGrounded) { + if (!user.isGrounded) { return false; } @@ -3140,7 +3140,7 @@ export class MatchUserTypeAttr extends VariableMoveTypeAttr { const userTypes = user.getTypes(true); - if(userTypes.includes(Type.STELLAR)) { // will not change to stellar type + if (userTypes.includes(Type.STELLAR)) { // will not change to stellar type const nonTeraTypes = user.getTypes(); type.value = nonTeraTypes[0]; return true; @@ -3594,7 +3594,7 @@ export class ProtectAttr extends AddBattlerTagAttr { while (moveHistory.length) { turnMove = moveHistory.shift(); - if(!allMoves[turnMove.move].getAttrs(ProtectAttr).length || turnMove.result !== MoveResult.SUCCESS) { + if (!allMoves[turnMove.move].getAttrs(ProtectAttr).length || turnMove.result !== MoveResult.SUCCESS) { break; } timesUsed++; @@ -3746,7 +3746,7 @@ export class RemoveArenaTrapAttr extends MoveEffectAttr { return false; } - if(this.targetBothSides){ + if (this.targetBothSides) { user.scene.arena.removeTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.PLAYER); user.scene.arena.removeTagOnSide(ArenaTagType.TOXIC_SPIKES, ArenaTagSide.PLAYER); user.scene.arena.removeTagOnSide(ArenaTagType.STEALTH_ROCK, ArenaTagSide.PLAYER); @@ -3782,7 +3782,7 @@ export class RemoveScreensAttr extends MoveEffectAttr { return false; } - if(this.targetBothSides){ + if (this.targetBothSides) { user.scene.arena.removeTagOnSide(ArenaTagType.REFLECT, ArenaTagSide.PLAYER); user.scene.arena.removeTagOnSide(ArenaTagType.LIGHT_SCREEN, ArenaTagSide.PLAYER); user.scene.arena.removeTagOnSide(ArenaTagType.AURORA_VEIL, ArenaTagSide.PLAYER); @@ -3790,7 +3790,7 @@ export class RemoveScreensAttr extends MoveEffectAttr { user.scene.arena.removeTagOnSide(ArenaTagType.REFLECT, ArenaTagSide.ENEMY); user.scene.arena.removeTagOnSide(ArenaTagType.LIGHT_SCREEN, ArenaTagSide.ENEMY); user.scene.arena.removeTagOnSide(ArenaTagType.AURORA_VEIL, ArenaTagSide.ENEMY); - } else{ + } else { user.scene.arena.removeTagOnSide(ArenaTagType.REFLECT, target.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY); user.scene.arena.removeTagOnSide(ArenaTagType.LIGHT_SCREEN, target.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY); user.scene.arena.removeTagOnSide(ArenaTagType.AURORA_VEIL, target.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY); @@ -3821,13 +3821,13 @@ export class RevivalBlessingAttr extends MoveEffectAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise { return new Promise(resolve => { // If user is player, checks if the user has fainted pokemon - if(user instanceof PlayerPokemon + if (user instanceof PlayerPokemon && user.scene.getParty().findIndex(p => p.isFainted())>-1) { (user as PlayerPokemon).revivalBlessing().then(() => { resolve(true); }); // If user is enemy, checks that it is a trainer, and it has fainted non-boss pokemon in party - } else if(user instanceof EnemyPokemon + } else if (user instanceof EnemyPokemon && user.hasTrainer() && user.scene.getEnemyParty().findIndex(p => p.isFainted() && !p.isBoss()) > -1) { // Selects a random fainted pokemon @@ -3838,11 +3838,11 @@ export class RevivalBlessingAttr extends MoveEffectAttr { pokemon.heal(Math.min(Math.max(Math.ceil(Math.floor(0.5 * pokemon.getMaxHp())), 1), pokemon.getMaxHp())); user.scene.queueMessage(`${pokemon.name} was revived!`,0,true); - if(user.scene.currentBattle.double && user.scene.getEnemyParty().length > 1) { + if (user.scene.currentBattle.double && user.scene.getEnemyParty().length > 1) { const allyPokemon = user.getAlly(); - if(slotIndex<=1) { + if (slotIndex<=1) { user.scene.unshiftPhase(new SwitchSummonPhase(user.scene, pokemon.getFieldIndex(), slotIndex, false, false, false)); - } else if(allyPokemon.isFainted()){ + } else if (allyPokemon.isFainted()) { user.scene.unshiftPhase(new SwitchSummonPhase(user.scene, allyPokemon.getFieldIndex(), slotIndex, false, false,false)); } } @@ -3855,7 +3855,7 @@ export class RevivalBlessingAttr extends MoveEffectAttr { } getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer { - if(user.hasTrainer() && user.scene.getEnemyParty().findIndex(p => p.isFainted() && !p.isBoss()) > -1) { + if (user.hasTrainer() && user.scene.getEnemyParty().findIndex(p => p.isFainted() && !p.isBoss()) > -1) { return 20; } @@ -3994,7 +3994,7 @@ export class RemoveTypeAttr extends MoveEffectAttr { 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; } @@ -4804,7 +4804,7 @@ export class FirstMoveCondition extends MoveCondition { export class hitsSameTypeAttr extends VariableMoveTypeMultiplierAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { const multiplier = args[0] as Utils.NumberHolder; - if (!user.getTypes().some(type => target.getTypes().includes(type))){ + if (!user.getTypes().some(type => target.getTypes().includes(type))) { multiplier.value = 0; return true; } diff --git a/src/data/nature.ts b/src/data/nature.ts index 4e1a22c36b0..c9709d5ee4c 100644 --- a/src/data/nature.ts +++ b/src/data/nature.ts @@ -35,7 +35,7 @@ export enum Nature { export function getNatureName(nature: Nature, includeStatEffects: boolean = false, forStarterSelect: boolean = false, ignoreBBCode: boolean = false, uiTheme: UiTheme = UiTheme.DEFAULT): string { let ret = Utils.toReadableString(Nature[nature]); //Translating nature - if(i18next.exists("nature:" + ret)){ + if (i18next.exists("nature:" + ret)) { ret = i18next.t("nature:" + ret as any); } if (includeStatEffects) { diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 72651d3a76e..9f081d73134 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -549,7 +549,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { try { sprite.play(key); tintSprite.play(key); - } catch(error: unknown) { + } catch (error: unknown) { console.error(`Couldn't play animation for '${key}'!\nIs the image for this Pokemon missing?\n`, error); return false; @@ -1330,10 +1330,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { break; } let weight = levelMove[0]; - if (weight === 0){ // Evo Moves + if (weight === 0) { // Evo Moves weight = 50; } - if (weight === 1 && allMoves[levelMove[1]].power >= 80){ // Assume level 1 moves with 80+ BP are "move reminder" moves and bump their weight + if (weight === 1 && allMoves[levelMove[1]].power >= 80) { // Assume level 1 moves with 80+ BP are "move reminder" moves and bump their weight weight = 40; } if (allMoves[levelMove[1]].name.endsWith(" (N)")) { @@ -1379,7 +1379,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } const moveId = speciesEggMoves[this.species.getRootSpeciesId()][3]; - if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)") && !this.isBoss()){ // No rare egg moves before e4 + if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)") && !this.isBoss()) { // No rare egg moves before e4 movePool.push([moveId, 30]); } if (this.fusionSpecies) { @@ -1390,14 +1390,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } const moveId = speciesEggMoves[this.fusionSpecies.getRootSpeciesId()][3]; - if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)") && !this.isBoss()){// No rare egg moves before e4 + if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)") && !this.isBoss()) {// No rare egg moves before e4 movePool.push([moveId, 30]); } } } } - if (this.isBoss()){ // Bosses never get self ko moves + if (this.isBoss()) { // Bosses never get self ko moves movePool = movePool.filter(m => !allMoves[m[0]].getAttrs(SacrificialAttr).length); } movePool = movePool.filter(m => !allMoves[m[0]].getAttrs(SacrificialAttrOnHit).length); @@ -1717,7 +1717,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (!isTypeImmune) { damage.value = Math.ceil(((((2 * source.level / 5 + 2) * power.value * sourceAtk.value / targetDef.value) / 50) + 2) * stabMultiplier.value * typeMultiplier.value * arenaAttackTypeMultiplier.value * screenMultiplier.value * ((this.scene.randBattleSeedInt(15) + 85) / 100) * criticalMultiplier.value); if (isPhysical && source.status && source.status.effect === StatusEffect.BURN) { - if(!move.getAttrs(BypassBurnDamageReductionAttr).length) { + if (!move.getAttrs(BypassBurnDamageReductionAttr).length) { const burnDamageReductionCancelled = new Utils.BooleanHolder(false); applyAbAttrs(BypassBurnDamageReductionAbAttr, source, burnDamageReductionCancelled); if (!burnDamageReductionCancelled.value) { @@ -1878,7 +1878,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const surviveDamage = new Utils.BooleanHolder(false); if (!preventEndure && this.hp - damage <= 0) { - if(this.hp >= 1 && this.getTag(BattlerTagType.ENDURING)) { + if (this.hp >= 1 && this.getTag(BattlerTagType.ENDURING)) { surviveDamage.value = this.lapseTag(BattlerTagType.ENDURING); } else if (this.hp > 1 && this.getTag(BattlerTagType.STURDY)) { surviveDamage.value = this.lapseTag(BattlerTagType.STURDY); @@ -2072,7 +2072,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.formIndex = Math.max(this.species.forms.findIndex(f => f.formKey === formChange.formKey), 0); this.generateName(); const abilityCount = this.getSpeciesForm().getAbilityCount(); - if (this.abilityIndex >= abilityCount){// Shouldn't happen + if (this.abilityIndex >= abilityCount) {// Shouldn't happen this.abilityIndex = abilityCount - 1; } this.scene.gameData.setPokemonSeen(this, false); @@ -2920,9 +2920,9 @@ export class PlayerPokemon extends Pokemon { revivalBlessing(): Promise { return new Promise(resolve => { this.scene.ui.setMode(Mode.PARTY, PartyUiMode.REVIVAL_BLESSING, this.getFieldIndex(), (slotIndex:integer, option: PartyOption) => { - if(slotIndex >= 0 && slotIndex<6) { + if (slotIndex >= 0 && slotIndex<6) { const pokemon = this.scene.getParty()[slotIndex]; - if(!pokemon || !pokemon.isFainted()) { + if (!pokemon || !pokemon.isFainted()) { resolve(); } @@ -2931,13 +2931,13 @@ export class PlayerPokemon extends Pokemon { pokemon.heal(Math.min(Math.max(Math.ceil(Math.floor(0.5 * pokemon.getMaxHp())), 1), pokemon.getMaxHp())); this.scene.queueMessage(`${pokemon.name} was revived!`,0,true); - if(this.scene.currentBattle.double && this.scene.getParty().length > 1) { + if (this.scene.currentBattle.double && this.scene.getParty().length > 1) { const allyPokemon = this.getAlly(); - if(slotIndex<=1) { + if (slotIndex<=1) { // Revived ally pokemon this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, pokemon.getFieldIndex(), slotIndex, false, false, true)); this.scene.unshiftPhase(new ToggleDoublePositionPhase(this.scene, true)); - } else if(allyPokemon.isFainted()) { + } else if (allyPokemon.isFainted()) { // Revived party pokemon, and ally pokemon is fainted this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, allyPokemon.getFieldIndex(), slotIndex, false, false, true)); this.scene.unshiftPhase(new ToggleDoublePositionPhase(this.scene, true)); @@ -2992,12 +2992,12 @@ export class PlayerPokemon extends Pokemon { this.generateName(); if (!isFusion) { const abilityCount = this.getSpeciesForm().getAbilityCount(); - if (this.abilityIndex >= abilityCount){ // Shouldn't happen + if (this.abilityIndex >= abilityCount) { // Shouldn't happen this.abilityIndex = abilityCount - 1; } } else { const abilityCount = this.getFusionSpeciesForm().getAbilityCount(); - if (this.fusionAbilityIndex >= abilityCount){// Shouldn't happen + if (this.fusionAbilityIndex >= abilityCount) {// Shouldn't happen this.fusionAbilityIndex = abilityCount - 1; } } diff --git a/src/phases.ts b/src/phases.ts index a82d7865b02..3189e670ebf 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1802,7 +1802,7 @@ export class CommandPhase extends FieldPhase { console.log(moveTargets, playerPokemon.name); if (moveTargets.targets.length <= 1 || moveTargets.multiple) { turnCommand.move.targets = moveTargets.targets; - } else if(playerPokemon.getTag(BattlerTagType.CHARGING) && playerPokemon.getMoveQueue().length >= 1) { + } else if (playerPokemon.getTag(BattlerTagType.CHARGING) && playerPokemon.getMoveQueue().length >= 1) { turnCommand.move.targets = playerPokemon.getMoveQueue()[0].targets; } else { this.scene.unshiftPhase(new SelectTargetPhase(this.scene, this.fieldIndex)); @@ -1902,7 +1902,7 @@ export class CommandPhase extends FieldPhase { this.scene.currentBattle.turnCommands[this.fieldIndex - 1].skip = true; } } else if (trapTag) { - if(trapTag.sourceMove === Moves.INGRAIN && this.scene.getPokemonById(trapTag.sourceId).isOfType(Type.GHOST)) { + if (trapTag.sourceMove === Moves.INGRAIN && this.scene.getPokemonById(trapTag.sourceId).isOfType(Type.GHOST)) { success = true; this.scene.currentBattle.turnCommands[this.fieldIndex] = isSwitch ? { command: Command.POKEMON, cursor: cursor, args: args } @@ -2578,7 +2578,7 @@ export class MovePhase extends BattlePhase { showMoveText(): void { if (this.move.getMove().getAttrs(ChargeAttr).length) { const lastMove = this.pokemon.getLastXMoves() as TurnMove[]; - if (!lastMove.length || lastMove[0].move !== this.move.getMove().id || lastMove[0].result !== MoveResult.OTHER){ + if (!lastMove.length || lastMove[0].move !== this.move.getMove().id || lastMove[0].result !== MoveResult.OTHER) { this.scene.queueMessage(getPokemonMessage(this.pokemon, ` used\n${this.move.getName()}!`), 500); return; } diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 0df3f96fa7e..5bc0df19aa2 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -908,7 +908,7 @@ export class GameData { v = []; } for (const md of v) { - if(md?.className === "ExpBalanceModifier") { // Temporarily limit EXP Balance until it gets reworked + if (md?.className === "ExpBalanceModifier") { // Temporarily limit EXP Balance until it gets reworked md.stackCount = Math.min(md.stackCount, 4); } ret.push(new PersistentModifierData(md, player)); diff --git a/src/test/pokemonSprite.test.ts b/src/test/pokemonSprite.test.ts index 264977ecec2..abb6cff483f 100644 --- a/src/test/pokemonSprite.test.ts +++ b/src/test/pokemonSprite.test.ts @@ -79,7 +79,7 @@ describe("check if every variant's sprite are correctly set", () => { } } else if (!mlist.hasOwnProperty(name)) { errors.push(`named - missing key ${name} in masterlist for ${trimmedFilePath}`); - }else { + } else { const raw = fs.readFileSync(filePath, {encoding: "utf8", flag: "r"}); const data = JSON.parse(raw); for (const key of Object.keys(data)) { diff --git a/src/test/testUtils.ts b/src/test/testUtils.ts index 481efbed032..f3ee634cd76 100644 --- a/src/test/testUtils.ts +++ b/src/test/testUtils.ts @@ -3,7 +3,7 @@ const path = require("path"); export function getAppRootDir () { let currentDir = __dirname; - while(!fs.existsSync(path.join(currentDir, "package.json"))) { + while (!fs.existsSync(path.join(currentDir, "package.json"))) { currentDir = path.join(currentDir, ".."); } return currentDir; diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index c56bb0f3cc1..cc5fe54818b 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -107,7 +107,7 @@ export default class PartyUiHandler extends MessageUiHandler { }; public static FilterFainted = (pokemon: PlayerPokemon) => { - if(!pokemon.isFainted()) { + if (!pokemon.isFainted()) { return `${pokemon.name} still has energy\nto battle!`; } return null; @@ -423,13 +423,13 @@ export default class PartyUiHandler extends MessageUiHandler { } break; case Button.RIGHT: - if (slotCount === battlerCount){ + if (slotCount === battlerCount) { success = this.setCursor(6); break; - } else if (battlerCount >= 2 && slotCount > battlerCount && this.getCursor() === 0 && this.lastCursor === 1){ + } else if (battlerCount >= 2 && slotCount > battlerCount && this.getCursor() === 0 && this.lastCursor === 1) { success = this.setCursor(2); break; - } else if (slotCount > battlerCount && this.cursor < battlerCount){ + } else if (slotCount > battlerCount && this.cursor < battlerCount) { success = this.setCursor(this.lastCursor < 6 ? this.lastCursor || battlerCount : battlerCount); break; } @@ -717,7 +717,7 @@ export default class PartyUiHandler extends MessageUiHandler { case PartyOption.MOVE_3: case PartyOption.MOVE_4: const move = pokemon.moveset[option - PartyOption.MOVE_1]; - if(this.showMovePp) { + if (this.showMovePp) { const maxPP = move.getMovePp(); const currPP = maxPP - move.ppUsed; optionName = `${move.getName()} ${currPP}/${maxPP}`; diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index b09928b724f..a8bc760287f 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -1392,7 +1392,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { //Growth translate let growthReadable = Utils.toReadableString(GrowthRate[species.growthRate]); const growthAux = growthReadable.replace(" ", "_"); - if(i18next.exists("growth:" + growthAux)){ + if (i18next.exists("growth:" + growthAux)) { growthReadable = i18next.t("growth:"+ growthAux as any); } this.pokemonGrowthRateText.setText(growthReadable); diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index 1057a7f3b73..a34de7d84f0 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -310,7 +310,7 @@ export default class SummaryUiHandler extends UiHandler { this.splicedIcon.on("pointerout", () => (this.scene as BattleScene).ui.hideTooltip()); } - if(this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId()].classicWinCount > 0 && this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId(true)].classicWinCount > 0) { + if (this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId()].classicWinCount > 0 && this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId(true)].classicWinCount > 0) { this.championRibbon.setVisible(true); } else { this.championRibbon.setVisible(false); @@ -450,7 +450,7 @@ export default class SummaryUiHandler extends UiHandler { case Button.LEFT: this.moveSelect = false; this.setCursor(Page.STATS); - if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE){ + if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) { this.hideMoveEffect(); this.destroyBlinkCursor(); success = true; @@ -623,7 +623,7 @@ export default class SummaryUiHandler extends UiHandler { x: forward ? "-=214" : "+=214", duration: 250, onComplete: () => { - if (forward){ + if (forward) { this.populatePageContainer(this.summaryPageContainer); if (this.cursor===Page.MOVES) { this.moveCursorObj = null; @@ -1022,7 +1022,7 @@ export default class SummaryUiHandler extends UiHandler { this.hideMoveEffect(); } - destroyBlinkCursor(){ + destroyBlinkCursor() { if (this.moveCursorBlinkTimer) { this.moveCursorBlinkTimer.destroy(); this.moveCursorBlinkTimer = null;