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
This commit is contained in:
Greenlamp2 2024-05-24 02:19:20 +02:00 committed by GitHub
parent e2be6ba002
commit 622885767d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 77 additions and 75 deletions

View File

@ -26,7 +26,9 @@
"no-trailing-spaces": ["error", { // Disallows trailing whitespace at the end of lines "no-trailing-spaces": ["error", { // Disallows trailing whitespace at the end of lines
"skipBlankLines": false, // Enforces the rule even on blank lines "skipBlankLines": false, // Enforces the rule even on blank lines
"ignoreComments": false // Enforces the rule on lines containing comments "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
} }
} }
] ]

View File

@ -254,7 +254,7 @@ export class PreDefendFullHpEndureAbAttr extends PreDefendAbAttr {
applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, cancelled: Utils.BooleanHolder, args: any[]): boolean { applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, cancelled: Utils.BooleanHolder, args: any[]): boolean {
if (pokemon.hp === pokemon.getMaxHp() && if (pokemon.hp === pokemon.getMaxHp() &&
pokemon.getMaxHp() > 1 && //Checks if pokemon has wonder_guard (which forces 1hp) 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); return pokemon.addTag(BattlerTagType.STURDY, 1);
} }
@ -499,11 +499,11 @@ export class FieldPriorityMoveImmunityAbAttr extends PreDefendAbAttr {
applyMoveAttrs(IncrementMovePriorityAttr,attacker,null,move.getMove(),attackPriority); applyMoveAttrs(IncrementMovePriorityAttr,attacker,null,move.getMove(),attackPriority);
applyAbAttrs(IncrementMovePriorityAbAttr, 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; return false;
} }
if(attackPriority.value > 0 && !move.getMove().isMultiTarget()) { if (attackPriority.value > 0 && !move.getMove().isMultiTarget()) {
cancelled.value = true; cancelled.value = true;
return true; return true;
} }
@ -955,7 +955,7 @@ export class MoveTypeChangePowerMultiplierAbAttr extends VariableMoveTypeAbAttr
private newType: Type; private newType: Type;
private powerMultiplier: number; private powerMultiplier: number;
constructor(matchType: Type, newType: Type, powerMultiplier: number){ constructor(matchType: Type, newType: Type, powerMultiplier: number) {
super(true); super(true);
this.matchType = matchType; this.matchType = matchType;
this.newType = newType; this.newType = newType;
@ -986,7 +986,7 @@ export class MoveTypeChangeAttr extends PreAttackAbAttr {
private powerMultiplier: number; private powerMultiplier: number;
private condition: PokemonAttackCondition; private condition: PokemonAttackCondition;
constructor(newType: Type, powerMultiplier: number, condition: PokemonAttackCondition){ constructor(newType: Type, powerMultiplier: number, condition: PokemonAttackCondition) {
super(true); super(true);
this.newType = newType; this.newType = newType;
this.powerMultiplier = powerMultiplier; this.powerMultiplier = powerMultiplier;
@ -1015,7 +1015,7 @@ export class DamageBoostAbAttr extends PreAttackAbAttr {
private damageMultiplier: number; private damageMultiplier: number;
private condition: PokemonAttackCondition; private condition: PokemonAttackCondition;
constructor(damageMultiplier: number, condition: PokemonAttackCondition){ constructor(damageMultiplier: number, condition: PokemonAttackCondition) {
super(true); super(true);
this.damageMultiplier = damageMultiplier; this.damageMultiplier = damageMultiplier;
this.condition = condition; this.condition = condition;
@ -1860,7 +1860,7 @@ export class MultCritAbAttr extends AbAttr {
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
const critMult = args[0] as Utils.NumberHolder; const critMult = args[0] as Utils.NumberHolder;
if (critMult.value > 1){ if (critMult.value > 1) {
critMult.value *= this.multAmount; critMult.value *= this.multAmount;
return true; return true;
} }
@ -1892,7 +1892,7 @@ export class ConditionalCritAbAttr extends AbAttr {
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
const target = (args[1] as Pokemon); const target = (args[1] as Pokemon);
const move = (args[2] as Move); const move = (args[2] as Move);
if(!this.condition(pokemon,target,move)) { if (!this.condition(pokemon,target,move)) {
return false; return false;
} }
@ -2410,8 +2410,8 @@ export class PostTurnHurtIfSleepingAbAttr extends PostTurnAbAttr {
*/ */
applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise<boolean> { applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise<boolean> {
let hadEffect: boolean = false; let hadEffect: boolean = false;
for(const opp of pokemon.getOpponents()) { for (const opp of pokemon.getOpponents()) {
if(opp.status !== undefined && opp.status.effect === StatusEffect.SLEEP) { if (opp.status !== undefined && opp.status.effect === StatusEffect.SLEEP) {
opp.damageAndUpdate(Math.floor(Math.max(1, opp.getMaxHp() / 8)), HitResult.OTHER); opp.damageAndUpdate(Math.floor(Math.max(1, opp.getMaxHp() / 8)), HitResult.OTHER);
pokemon.scene.queueMessage(i18next.t("abilityTriggers:badDreams", {pokemonName: `${getPokemonPrefix(opp)}${opp.name}`})); pokemon.scene.queueMessage(i18next.t("abilityTriggers:badDreams", {pokemonName: `${getPokemonPrefix(opp)}${opp.name}`}));
hadEffect = true; hadEffect = true;
@ -2440,7 +2440,7 @@ export class FetchBallAbAttr extends PostTurnAbAttr {
*/ */
applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean { applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean {
const lastUsed = pokemon.scene.currentBattle.lastUsedPokeball; const lastUsed = pokemon.scene.currentBattle.lastUsedPokeball;
if(lastUsed !== null && pokemon.isPlayer) { if (lastUsed !== null && pokemon.isPlayer) {
pokemon.scene.pokeballCounts[lastUsed]++; pokemon.scene.pokeballCounts[lastUsed]++;
pokemon.scene.currentBattle.lastUsedPokeball = null; pokemon.scene.currentBattle.lastUsedPokeball = null;
pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` found a\n${getPokeballName(lastUsed)}!`)); 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 * @returns if enemy Pokemon is trapped or not
*/ */
applyCheckTrapped(pokemon: Pokemon, passive: boolean, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, args: any[]): boolean { 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; trapped.value = false;
return false; return false;
} }

View File

@ -236,7 +236,7 @@ export async function printPokemon() {
let generationIndex = 0; let generationIndex = 0;
if (!region) { if (!region) {
while (++generationIndex < 9 && dexId > generationDexNumbers[generationIndex]){} while (++generationIndex < 9 && dexId > generationDexNumbers[generationIndex]) {}
} else { } else {
generationIndex = regionalForms.indexOf(region.toLowerCase()) + 6; generationIndex = regionalForms.indexOf(region.toLowerCase()) + 6;
} }

View File

@ -178,7 +178,7 @@ export class FlinchedTag extends BattlerTag {
} }
export class InterruptedTag extends BattlerTag { export class InterruptedTag extends BattlerTag {
constructor(sourceMove: Moves){ constructor(sourceMove: Moves) {
super(BattlerTagType.INTERRUPTED, BattlerTagLapseType.PRE_MOVE, 0, sourceMove); super(BattlerTagType.INTERRUPTED, BattlerTagLapseType.PRE_MOVE, 0, sourceMove);
} }
@ -585,7 +585,7 @@ export class MinimizeTag extends BattlerTag {
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
//If a pokemon dynamaxes they lose minimized status //If a pokemon dynamaxes they lose minimized status
if(pokemon.isMax()){ if (pokemon.isMax()) {
return false; return false;
} }
return lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType); return lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType);

View File

@ -137,7 +137,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
pokemon.battleData.berriesEaten.push(berryType); 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); 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); ppRestoreMove.ppUsed = Math.max(ppRestoreMove.ppUsed - 10, 0);
pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` restored PP to its move ${ppRestoreMove.getName()}\nusing its ${getBerryName(berryType)}!`)); pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` restored PP to its move ${ppRestoreMove.getName()}\nusing its ${getBerryName(berryType)}!`));
} }

View File

@ -923,7 +923,7 @@ export class HalfSacrificialAttr extends MoveEffectAttr {
const cancelled = new Utils.BooleanHolder(false); const cancelled = new Utils.BooleanHolder(false);
// Check to see if the Pokemon has an ability that blocks non-direct damage // Check to see if the Pokemon has an ability that blocks non-direct damage
applyAbAttrs(BlockNonDirectDamageAbAttr, user, cancelled); applyAbAttrs(BlockNonDirectDamageAbAttr, user, cancelled);
if (!cancelled.value){ if (!cancelled.value) {
user.damageAndUpdate(Math.ceil(user.getMaxHp()/2), HitResult.OTHER, false, true, true); 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 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 */ /** The {@linkcode WeatherType} this move ignores */
public weather: WeatherType; public weather: WeatherType;
constructor(weather: WeatherType){ constructor(weather: WeatherType) {
super(); super();
this.weather = weather; this.weather = weather;
} }
@ -1542,9 +1542,9 @@ export class EatBerryAttr extends MoveEffectAttr {
return false; 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); const heldBerries = this.getTargetHeldBerries(target);
if(heldBerries.length <= 0) { if (heldBerries.length <= 0) {
return false; return false;
} }
this.chosenBerry = heldBerries[user.randSeedInt(heldBerries.length)]; this.chosenBerry = heldBerries[user.randSeedInt(heldBerries.length)];
@ -1555,7 +1555,7 @@ export class EatBerryAttr extends MoveEffectAttr {
const preserve = new Utils.BooleanHolder(false); const preserve = new Utils.BooleanHolder(false);
target.scene.applyModifiers(PreserveBerryModifier, target.isPlayer(), target, preserve); 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) { if (!--this.chosenBerry.stackCount) {
target.scene.removeModifier(this.chosenBerry, !target.isPlayer()); target.scene.removeModifier(this.chosenBerry, !target.isPlayer());
} }
@ -1592,7 +1592,7 @@ export class StealEatBerryAttr extends EatBerryAttr {
const cancelled = new Utils.BooleanHolder(false); const cancelled = new Utils.BooleanHolder(false);
applyAbAttrs(BlockItemTheftAbAttr, target, cancelled); // check for abilities that block item theft applyAbAttrs(BlockItemTheftAbAttr, target, cancelled); // check for abilities that block item theft
if(cancelled.value === true) { if (cancelled.value === true) {
return false; return false;
} }
@ -2012,7 +2012,7 @@ export class PostVictoryStatChangeAttr extends MoveAttr {
this.showMessage = showMessage; this.showMessage = showMessage;
} }
applyPostVictory(user: Pokemon, target: Pokemon, move: Move): void { 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; return false;
} }
const statChangeAttr = new StatChangeAttr(this.stats, this.levels, this.showMessage); const statChangeAttr = new StatChangeAttr(this.stats, this.levels, this.showMessage);
@ -2257,7 +2257,7 @@ export class LessPPMorePowerAttr extends VariablePowerAttr {
let ppRemains = ppMax - ppUsed; let ppRemains = ppMax - ppUsed;
/** Reduce to 0 to avoid negative numbers if user has 1PP before attack and target has Ability.PRESSURE */ /** 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; ppRemains = 0;
} }
@ -2713,7 +2713,7 @@ export class PresentPowerAttr extends VariablePowerAttr {
export class KnockOffPowerAttr extends VariablePowerAttr { export class KnockOffPowerAttr extends VariablePowerAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { 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; (args[0] as Utils.NumberHolder).value *= 1.5;
return true; return true;
} }
@ -2744,7 +2744,7 @@ export class VariableAtkAttr extends MoveAttr {
} }
export class TargetAtkUserAtkAttr extends VariableAtkAttr { export class TargetAtkUserAtkAttr extends VariableAtkAttr {
constructor(){ constructor() {
super(); super();
} }
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { 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 * @returns true if the function succeeds
*/ */
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { 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; const accuracy = args[0] as Utils.NumberHolder;
accuracy.value = -1; accuracy.value = -1;
@ -3086,7 +3086,7 @@ export class TerrainPulseTypeAttr extends VariableMoveTypeAttr {
* @returns true if the function succeeds * @returns true if the function succeeds
*/ */
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if(!user.isGrounded) { if (!user.isGrounded) {
return false; return false;
} }
@ -3140,7 +3140,7 @@ export class MatchUserTypeAttr extends VariableMoveTypeAttr {
const userTypes = user.getTypes(true); 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(); const nonTeraTypes = user.getTypes();
type.value = nonTeraTypes[0]; type.value = nonTeraTypes[0];
return true; return true;
@ -3594,7 +3594,7 @@ export class ProtectAttr extends AddBattlerTagAttr {
while (moveHistory.length) { while (moveHistory.length) {
turnMove = moveHistory.shift(); 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; break;
} }
timesUsed++; timesUsed++;
@ -3746,7 +3746,7 @@ export class RemoveArenaTrapAttr extends MoveEffectAttr {
return false; return false;
} }
if(this.targetBothSides){ if (this.targetBothSides) {
user.scene.arena.removeTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.PLAYER); user.scene.arena.removeTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.PLAYER);
user.scene.arena.removeTagOnSide(ArenaTagType.TOXIC_SPIKES, ArenaTagSide.PLAYER); user.scene.arena.removeTagOnSide(ArenaTagType.TOXIC_SPIKES, ArenaTagSide.PLAYER);
user.scene.arena.removeTagOnSide(ArenaTagType.STEALTH_ROCK, ArenaTagSide.PLAYER); user.scene.arena.removeTagOnSide(ArenaTagType.STEALTH_ROCK, ArenaTagSide.PLAYER);
@ -3782,7 +3782,7 @@ export class RemoveScreensAttr extends MoveEffectAttr {
return false; return false;
} }
if(this.targetBothSides){ if (this.targetBothSides) {
user.scene.arena.removeTagOnSide(ArenaTagType.REFLECT, ArenaTagSide.PLAYER); user.scene.arena.removeTagOnSide(ArenaTagType.REFLECT, ArenaTagSide.PLAYER);
user.scene.arena.removeTagOnSide(ArenaTagType.LIGHT_SCREEN, ArenaTagSide.PLAYER); user.scene.arena.removeTagOnSide(ArenaTagType.LIGHT_SCREEN, ArenaTagSide.PLAYER);
user.scene.arena.removeTagOnSide(ArenaTagType.AURORA_VEIL, 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.REFLECT, ArenaTagSide.ENEMY);
user.scene.arena.removeTagOnSide(ArenaTagType.LIGHT_SCREEN, ArenaTagSide.ENEMY); user.scene.arena.removeTagOnSide(ArenaTagType.LIGHT_SCREEN, ArenaTagSide.ENEMY);
user.scene.arena.removeTagOnSide(ArenaTagType.AURORA_VEIL, 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.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.LIGHT_SCREEN, target.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY);
user.scene.arena.removeTagOnSide(ArenaTagType.AURORA_VEIL, 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<boolean> { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
return new Promise(resolve => { return new Promise(resolve => {
// If user is player, checks if the user has fainted pokemon // 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.scene.getParty().findIndex(p => p.isFainted())>-1) {
(user as PlayerPokemon).revivalBlessing().then(() => { (user as PlayerPokemon).revivalBlessing().then(() => {
resolve(true); resolve(true);
}); });
// If user is enemy, checks that it is a trainer, and it has fainted non-boss pokemon in party // 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.hasTrainer()
&& user.scene.getEnemyParty().findIndex(p => p.isFainted() && !p.isBoss()) > -1) { && user.scene.getEnemyParty().findIndex(p => p.isFainted() && !p.isBoss()) > -1) {
// Selects a random fainted pokemon // 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())); 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); 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(); const allyPokemon = user.getAlly();
if(slotIndex<=1) { if (slotIndex<=1) {
user.scene.unshiftPhase(new SwitchSummonPhase(user.scene, pokemon.getFieldIndex(), slotIndex, false, false, false)); 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)); 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 { 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; return 20;
} }
@ -3994,7 +3994,7 @@ export class RemoveTypeAttr extends MoveEffectAttr {
return false; 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; return false;
} }
@ -4804,7 +4804,7 @@ export class FirstMoveCondition extends MoveCondition {
export class hitsSameTypeAttr extends VariableMoveTypeMultiplierAttr { export class hitsSameTypeAttr extends VariableMoveTypeMultiplierAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
const multiplier = args[0] as Utils.NumberHolder; 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; multiplier.value = 0;
return true; return true;
} }

View File

@ -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 { 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]); let ret = Utils.toReadableString(Nature[nature]);
//Translating nature //Translating nature
if(i18next.exists("nature:" + ret)){ if (i18next.exists("nature:" + ret)) {
ret = i18next.t("nature:" + ret as any); ret = i18next.t("nature:" + ret as any);
} }
if (includeStatEffects) { if (includeStatEffects) {

View File

@ -549,7 +549,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
try { try {
sprite.play(key); sprite.play(key);
tintSprite.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); console.error(`Couldn't play animation for '${key}'!\nIs the image for this Pokemon missing?\n`, error);
return false; return false;
@ -1330,10 +1330,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
break; break;
} }
let weight = levelMove[0]; let weight = levelMove[0];
if (weight === 0){ // Evo Moves if (weight === 0) { // Evo Moves
weight = 50; 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; weight = 40;
} }
if (allMoves[levelMove[1]].name.endsWith(" (N)")) { 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]; 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]); movePool.push([moveId, 30]);
} }
if (this.fusionSpecies) { if (this.fusionSpecies) {
@ -1390,14 +1390,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
} }
} }
const moveId = speciesEggMoves[this.fusionSpecies.getRootSpeciesId()][3]; 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]); 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(SacrificialAttr).length);
} }
movePool = movePool.filter(m => !allMoves[m[0]].getAttrs(SacrificialAttrOnHit).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) { 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); 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 (isPhysical && source.status && source.status.effect === StatusEffect.BURN) {
if(!move.getAttrs(BypassBurnDamageReductionAttr).length) { if (!move.getAttrs(BypassBurnDamageReductionAttr).length) {
const burnDamageReductionCancelled = new Utils.BooleanHolder(false); const burnDamageReductionCancelled = new Utils.BooleanHolder(false);
applyAbAttrs(BypassBurnDamageReductionAbAttr, source, burnDamageReductionCancelled); applyAbAttrs(BypassBurnDamageReductionAbAttr, source, burnDamageReductionCancelled);
if (!burnDamageReductionCancelled.value) { if (!burnDamageReductionCancelled.value) {
@ -1878,7 +1878,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
const surviveDamage = new Utils.BooleanHolder(false); const surviveDamage = new Utils.BooleanHolder(false);
if (!preventEndure && this.hp - damage <= 0) { 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); surviveDamage.value = this.lapseTag(BattlerTagType.ENDURING);
} else if (this.hp > 1 && this.getTag(BattlerTagType.STURDY)) { } else if (this.hp > 1 && this.getTag(BattlerTagType.STURDY)) {
surviveDamage.value = this.lapseTag(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.formIndex = Math.max(this.species.forms.findIndex(f => f.formKey === formChange.formKey), 0);
this.generateName(); this.generateName();
const abilityCount = this.getSpeciesForm().getAbilityCount(); const abilityCount = this.getSpeciesForm().getAbilityCount();
if (this.abilityIndex >= abilityCount){// Shouldn't happen if (this.abilityIndex >= abilityCount) {// Shouldn't happen
this.abilityIndex = abilityCount - 1; this.abilityIndex = abilityCount - 1;
} }
this.scene.gameData.setPokemonSeen(this, false); this.scene.gameData.setPokemonSeen(this, false);
@ -2920,9 +2920,9 @@ export class PlayerPokemon extends Pokemon {
revivalBlessing(): Promise<void> { revivalBlessing(): Promise<void> {
return new Promise(resolve => { return new Promise(resolve => {
this.scene.ui.setMode(Mode.PARTY, PartyUiMode.REVIVAL_BLESSING, this.getFieldIndex(), (slotIndex:integer, option: PartyOption) => { 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]; const pokemon = this.scene.getParty()[slotIndex];
if(!pokemon || !pokemon.isFainted()) { if (!pokemon || !pokemon.isFainted()) {
resolve(); 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())); 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); 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(); const allyPokemon = this.getAlly();
if(slotIndex<=1) { if (slotIndex<=1) {
// Revived ally pokemon // Revived ally pokemon
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, pokemon.getFieldIndex(), slotIndex, false, false, true)); this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, pokemon.getFieldIndex(), slotIndex, false, false, true));
this.scene.unshiftPhase(new ToggleDoublePositionPhase(this.scene, 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 // 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 SwitchSummonPhase(this.scene, allyPokemon.getFieldIndex(), slotIndex, false, false, true));
this.scene.unshiftPhase(new ToggleDoublePositionPhase(this.scene, true)); this.scene.unshiftPhase(new ToggleDoublePositionPhase(this.scene, true));
@ -2992,12 +2992,12 @@ export class PlayerPokemon extends Pokemon {
this.generateName(); this.generateName();
if (!isFusion) { if (!isFusion) {
const abilityCount = this.getSpeciesForm().getAbilityCount(); const abilityCount = this.getSpeciesForm().getAbilityCount();
if (this.abilityIndex >= abilityCount){ // Shouldn't happen if (this.abilityIndex >= abilityCount) { // Shouldn't happen
this.abilityIndex = abilityCount - 1; this.abilityIndex = abilityCount - 1;
} }
} else { } else {
const abilityCount = this.getFusionSpeciesForm().getAbilityCount(); const abilityCount = this.getFusionSpeciesForm().getAbilityCount();
if (this.fusionAbilityIndex >= abilityCount){// Shouldn't happen if (this.fusionAbilityIndex >= abilityCount) {// Shouldn't happen
this.fusionAbilityIndex = abilityCount - 1; this.fusionAbilityIndex = abilityCount - 1;
} }
} }

View File

@ -1802,7 +1802,7 @@ export class CommandPhase extends FieldPhase {
console.log(moveTargets, playerPokemon.name); console.log(moveTargets, playerPokemon.name);
if (moveTargets.targets.length <= 1 || moveTargets.multiple) { if (moveTargets.targets.length <= 1 || moveTargets.multiple) {
turnCommand.move.targets = moveTargets.targets; 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; turnCommand.move.targets = playerPokemon.getMoveQueue()[0].targets;
} else { } else {
this.scene.unshiftPhase(new SelectTargetPhase(this.scene, this.fieldIndex)); 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; this.scene.currentBattle.turnCommands[this.fieldIndex - 1].skip = true;
} }
} else if (trapTag) { } 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; success = true;
this.scene.currentBattle.turnCommands[this.fieldIndex] = isSwitch this.scene.currentBattle.turnCommands[this.fieldIndex] = isSwitch
? { command: Command.POKEMON, cursor: cursor, args: args } ? { command: Command.POKEMON, cursor: cursor, args: args }
@ -2578,7 +2578,7 @@ export class MovePhase extends BattlePhase {
showMoveText(): void { showMoveText(): void {
if (this.move.getMove().getAttrs(ChargeAttr).length) { if (this.move.getMove().getAttrs(ChargeAttr).length) {
const lastMove = this.pokemon.getLastXMoves() as TurnMove[]; 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); this.scene.queueMessage(getPokemonMessage(this.pokemon, ` used\n${this.move.getName()}!`), 500);
return; return;
} }

View File

@ -908,7 +908,7 @@ export class GameData {
v = []; v = [];
} }
for (const md of 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); md.stackCount = Math.min(md.stackCount, 4);
} }
ret.push(new PersistentModifierData(md, player)); ret.push(new PersistentModifierData(md, player));

View File

@ -79,7 +79,7 @@ describe("check if every variant's sprite are correctly set", () => {
} }
} else if (!mlist.hasOwnProperty(name)) { } else if (!mlist.hasOwnProperty(name)) {
errors.push(`named - missing key ${name} in masterlist for ${trimmedFilePath}`); errors.push(`named - missing key ${name} in masterlist for ${trimmedFilePath}`);
}else { } else {
const raw = fs.readFileSync(filePath, {encoding: "utf8", flag: "r"}); const raw = fs.readFileSync(filePath, {encoding: "utf8", flag: "r"});
const data = JSON.parse(raw); const data = JSON.parse(raw);
for (const key of Object.keys(data)) { for (const key of Object.keys(data)) {

View File

@ -3,7 +3,7 @@ const path = require("path");
export function getAppRootDir () { export function getAppRootDir () {
let currentDir = __dirname; let currentDir = __dirname;
while(!fs.existsSync(path.join(currentDir, "package.json"))) { while (!fs.existsSync(path.join(currentDir, "package.json"))) {
currentDir = path.join(currentDir, ".."); currentDir = path.join(currentDir, "..");
} }
return currentDir; return currentDir;

View File

@ -107,7 +107,7 @@ export default class PartyUiHandler extends MessageUiHandler {
}; };
public static FilterFainted = (pokemon: PlayerPokemon) => { public static FilterFainted = (pokemon: PlayerPokemon) => {
if(!pokemon.isFainted()) { if (!pokemon.isFainted()) {
return `${pokemon.name} still has energy\nto battle!`; return `${pokemon.name} still has energy\nto battle!`;
} }
return null; return null;
@ -423,13 +423,13 @@ export default class PartyUiHandler extends MessageUiHandler {
} }
break; break;
case Button.RIGHT: case Button.RIGHT:
if (slotCount === battlerCount){ if (slotCount === battlerCount) {
success = this.setCursor(6); success = this.setCursor(6);
break; 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); success = this.setCursor(2);
break; 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); success = this.setCursor(this.lastCursor < 6 ? this.lastCursor || battlerCount : battlerCount);
break; break;
} }
@ -717,7 +717,7 @@ export default class PartyUiHandler extends MessageUiHandler {
case PartyOption.MOVE_3: case PartyOption.MOVE_3:
case PartyOption.MOVE_4: case PartyOption.MOVE_4:
const move = pokemon.moveset[option - PartyOption.MOVE_1]; const move = pokemon.moveset[option - PartyOption.MOVE_1];
if(this.showMovePp) { if (this.showMovePp) {
const maxPP = move.getMovePp(); const maxPP = move.getMovePp();
const currPP = maxPP - move.ppUsed; const currPP = maxPP - move.ppUsed;
optionName = `${move.getName()} ${currPP}/${maxPP}`; optionName = `${move.getName()} ${currPP}/${maxPP}`;

View File

@ -1392,7 +1392,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
//Growth translate //Growth translate
let growthReadable = Utils.toReadableString(GrowthRate[species.growthRate]); let growthReadable = Utils.toReadableString(GrowthRate[species.growthRate]);
const growthAux = growthReadable.replace(" ", "_"); const growthAux = growthReadable.replace(" ", "_");
if(i18next.exists("growth:" + growthAux)){ if (i18next.exists("growth:" + growthAux)) {
growthReadable = i18next.t("growth:"+ growthAux as any); growthReadable = i18next.t("growth:"+ growthAux as any);
} }
this.pokemonGrowthRateText.setText(growthReadable); this.pokemonGrowthRateText.setText(growthReadable);

View File

@ -310,7 +310,7 @@ export default class SummaryUiHandler extends UiHandler {
this.splicedIcon.on("pointerout", () => (this.scene as BattleScene).ui.hideTooltip()); 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); this.championRibbon.setVisible(true);
} else { } else {
this.championRibbon.setVisible(false); this.championRibbon.setVisible(false);
@ -450,7 +450,7 @@ export default class SummaryUiHandler extends UiHandler {
case Button.LEFT: case Button.LEFT:
this.moveSelect = false; this.moveSelect = false;
this.setCursor(Page.STATS); this.setCursor(Page.STATS);
if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE){ if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) {
this.hideMoveEffect(); this.hideMoveEffect();
this.destroyBlinkCursor(); this.destroyBlinkCursor();
success = true; success = true;
@ -623,7 +623,7 @@ export default class SummaryUiHandler extends UiHandler {
x: forward ? "-=214" : "+=214", x: forward ? "-=214" : "+=214",
duration: 250, duration: 250,
onComplete: () => { onComplete: () => {
if (forward){ if (forward) {
this.populatePageContainer(this.summaryPageContainer); this.populatePageContainer(this.summaryPageContainer);
if (this.cursor===Page.MOVES) { if (this.cursor===Page.MOVES) {
this.moveCursorObj = null; this.moveCursorObj = null;
@ -1022,7 +1022,7 @@ export default class SummaryUiHandler extends UiHandler {
this.hideMoveEffect(); this.hideMoveEffect();
} }
destroyBlinkCursor(){ destroyBlinkCursor() {
if (this.moveCursorBlinkTimer) { if (this.moveCursorBlinkTimer) {
this.moveCursorBlinkTimer.destroy(); this.moveCursorBlinkTimer.destroy();
this.moveCursorBlinkTimer = null; this.moveCursorBlinkTimer = null;