mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 17:12:44 +02:00
[Misc] Removed cases of a ? true : false
and useless super
calls from subclasses (#5943)
* Removed cases of `if (a) {return true}' return false` * Removed useless `super.xyz` calls from functions * Fixde missing issur * Use early return in `Pokemon#isOffsetBySubstitute` --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
parent
3ca11e83a6
commit
88e4ab978b
@ -3566,9 +3566,8 @@ export default class BattleScene extends SceneBase {
|
||||
gameMode: this.currentBattle ? this.gameMode.getName() : "Title",
|
||||
biome: this.currentBattle ? getBiomeName(this.arena.biomeType) : "",
|
||||
wave: this.currentBattle?.waveIndex ?? 0,
|
||||
party: this.party
|
||||
? this.party.map(p => {
|
||||
return {
|
||||
party:
|
||||
this.party?.map(p => ({
|
||||
name: p.name,
|
||||
form: p.getFormKey(),
|
||||
types: p.getTypes().map(type => PokemonType[type]),
|
||||
@ -3578,9 +3577,7 @@ export default class BattleScene extends SceneBase {
|
||||
currentHP: p.hp,
|
||||
maxHP: p.getMaxHp(),
|
||||
status: p.status?.effect ? StatusEffect[p.status.effect] : "",
|
||||
};
|
||||
})
|
||||
: [],
|
||||
})) ?? [], // TODO: review if this can be nullish
|
||||
modeChain: this.ui?.getModeChain() ?? [],
|
||||
};
|
||||
(window as any).gameInfo = gameInfo;
|
||||
@ -3963,16 +3960,13 @@ export default class BattleScene extends SceneBase {
|
||||
if (previousEncounter !== null && encounterType === previousEncounter) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
return !(
|
||||
this.mysteryEncounterSaveData.encounteredEvents.length > 0 &&
|
||||
encounterCandidate.maxAllowedEncounters &&
|
||||
encounterCandidate.maxAllowedEncounters > 0 &&
|
||||
this.mysteryEncounterSaveData.encounteredEvents.filter(e => e.type === encounterType).length >=
|
||||
encounterCandidate.maxAllowedEncounters
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
);
|
||||
})
|
||||
.map(m => allMysteryEncounters[m]);
|
||||
// Decrement tier
|
||||
|
@ -197,10 +197,7 @@ export function canIAssignThisKey(config, key) {
|
||||
export function canIOverrideThisSetting(config, settingName) {
|
||||
const key = getKeyWithSettingName(config, settingName);
|
||||
// || isTheLatestBind(config, settingName) no longer needed since action and cancel are protected
|
||||
if (config.blacklist?.includes(key)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !config.blacklist?.includes(key);
|
||||
}
|
||||
|
||||
export function canIDeleteThisKey(config, key) {
|
||||
|
@ -2653,11 +2653,7 @@ export class PostSummonCopyAllyStatsAbAttr extends PostSummonAbAttr {
|
||||
}
|
||||
|
||||
const ally = pokemon.getAlly();
|
||||
if (isNullOrUndefined(ally) || ally.getStatStages().every(s => s === 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !(isNullOrUndefined(ally) || ally.getStatStages().every(s => s === 0));
|
||||
}
|
||||
|
||||
override applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): void {
|
||||
@ -2723,11 +2719,7 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr {
|
||||
}
|
||||
|
||||
// transforming from or into fusion pokemon causes various problems (including crashes and save corruption)
|
||||
if (this.getTarget(targets).fusionSpecies || pokemon.fusionSpecies) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !(this.getTarget(targets).fusionSpecies || pokemon.fusionSpecies);
|
||||
}
|
||||
|
||||
override applyPostSummon(pokemon: Pokemon, _passive: boolean, simulated: boolean, _args: any[]): void {
|
||||
@ -3544,10 +3536,7 @@ export class BlockStatusDamageAbAttr extends AbAttr {
|
||||
}
|
||||
|
||||
override canApply(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean {
|
||||
if (pokemon.status && this.effects.includes(pokemon.status.effect)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !!pokemon.status?.effect && this.effects.includes(pokemon.status.effect);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4803,11 +4792,7 @@ export class PostFaintContactDamageAbAttr extends PostFaintAbAttr {
|
||||
const diedToDirectDamage = move !== undefined && attacker !== undefined && move.doesFlagEffectApply({flag: MoveFlags.MAKES_CONTACT, user: attacker, target: pokemon});
|
||||
const cancelled = new BooleanHolder(false);
|
||||
globalScene.getField(true).map(p => applyAbAttrs(FieldPreventExplosiveMovesAbAttr, p, cancelled, simulated));
|
||||
if (!diedToDirectDamage || cancelled.value || attacker!.hasAbilityWithAttr(BlockNonDirectDamageAbAttr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !(!diedToDirectDamage || cancelled.value || attacker!.hasAbilityWithAttr(BlockNonDirectDamageAbAttr));
|
||||
}
|
||||
|
||||
override applyPostFaint(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker?: Pokemon, move?: Move, hitResult?: HitResult, ...args: any[]): void {
|
||||
@ -6508,12 +6493,7 @@ export function initAbilities() {
|
||||
new Ability(AbilityId.INTIMIDATE, 3)
|
||||
.attr(PostSummonStatStageChangeAbAttr, [ Stat.ATK ], -1, false, true),
|
||||
new Ability(AbilityId.SHADOW_TAG, 3)
|
||||
.attr(ArenaTrapAbAttr, (user, target) => {
|
||||
if (target.hasAbility(AbilityId.SHADOW_TAG)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
.attr(ArenaTrapAbAttr, (_user, target) => !target.hasAbility(AbilityId.SHADOW_TAG)),
|
||||
new Ability(AbilityId.ROUGH_SKIN, 3)
|
||||
.attr(PostDefendContactDamageAbAttr, 8)
|
||||
.bypassFaint(),
|
||||
@ -6573,10 +6553,7 @@ export function initAbilities() {
|
||||
.ignorable(),
|
||||
new Ability(AbilityId.MAGNET_PULL, 3)
|
||||
.attr(ArenaTrapAbAttr, (user, target) => {
|
||||
if (target.getTypes(true).includes(PokemonType.STEEL) || (target.getTypes(true).includes(PokemonType.STELLAR) && target.getTypes().includes(PokemonType.STEEL))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return target.getTypes(true).includes(PokemonType.STEEL) || (target.getTypes(true).includes(PokemonType.STELLAR) && target.getTypes().includes(PokemonType.STEEL));
|
||||
}),
|
||||
new Ability(AbilityId.SOUNDPROOF, 3)
|
||||
.attr(MoveImmunityAbAttr, (pokemon, attacker, move) => pokemon !== attacker && move.hasFlag(MoveFlags.SOUND_BASED))
|
||||
@ -6654,12 +6631,7 @@ export function initAbilities() {
|
||||
.attr(PostSummonWeatherChangeAbAttr, WeatherType.SUNNY)
|
||||
.attr(PostBiomeChangeWeatherChangeAbAttr, WeatherType.SUNNY),
|
||||
new Ability(AbilityId.ARENA_TRAP, 3)
|
||||
.attr(ArenaTrapAbAttr, (user, target) => {
|
||||
if (target.isGrounded()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.attr(ArenaTrapAbAttr, (user, target) => target.isGrounded())
|
||||
.attr(DoubleBattleChanceAbAttr),
|
||||
new Ability(AbilityId.VITAL_SPIRIT, 3)
|
||||
.attr(StatusEffectImmunityAbAttr, StatusEffect.SLEEP)
|
||||
|
@ -1203,10 +1203,7 @@ export class EncoreTag extends MoveRestrictionBattlerTag {
|
||||
override lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||
if (lapseType === BattlerTagLapseType.CUSTOM) {
|
||||
const encoredMove = pokemon.getMoveset().find(m => m.moveId === this.moveId);
|
||||
if (encoredMove && encoredMove?.getPpRatio() > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !isNullOrUndefined(encoredMove) && encoredMove.getPpRatio() > 0;
|
||||
}
|
||||
return super.lapse(pokemon, lapseType);
|
||||
}
|
||||
@ -1218,10 +1215,7 @@ export class EncoreTag extends MoveRestrictionBattlerTag {
|
||||
* @returns `true` if the move does not match with the moveId stored and as a result, restricted
|
||||
*/
|
||||
override isMoveRestricted(move: MoveId, _user?: Pokemon): boolean {
|
||||
if (move !== this.moveId) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return move !== this.moveId;
|
||||
}
|
||||
|
||||
override selectionDeniedText(_pokemon: Pokemon, move: MoveId): string {
|
||||
@ -2768,10 +2762,7 @@ export class HealBlockTag extends MoveRestrictionBattlerTag {
|
||||
* @returns `true` if the move has a TRIAGE_MOVE flag and is a status move
|
||||
*/
|
||||
override isMoveRestricted(move: MoveId): boolean {
|
||||
if (allMoves[move].hasFlag(MoveFlags.TRIAGE_MOVE) && allMoves[move].category === MoveCategory.STATUS) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return allMoves[move].hasFlag(MoveFlags.TRIAGE_MOVE) && allMoves[move].category === MoveCategory.STATUS;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2785,10 +2776,7 @@ export class HealBlockTag extends MoveRestrictionBattlerTag {
|
||||
override isMoveTargetRestricted(move: MoveId, user: Pokemon, target: Pokemon) {
|
||||
const moveCategory = new NumberHolder(allMoves[move].category);
|
||||
applyMoveAttrs(StatusCategoryOnAllyAttr, user, target, allMoves[move], moveCategory);
|
||||
if (allMoves[move].hasAttr(HealOnAllyAttr) && moveCategory.value === MoveCategory.STATUS) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return allMoves[move].hasAttr(HealOnAllyAttr) && moveCategory.value === MoveCategory.STATUS;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3126,10 +3114,7 @@ export class TormentTag extends MoveRestrictionBattlerTag {
|
||||
const moveObj = allMoves[lastMove.move];
|
||||
const isUnaffected = moveObj.hasAttr(ConsecutiveUseDoublePowerAttr) || user.getTag(BattlerTagType.FRENZY);
|
||||
const validLastMoveResult = lastMove.result === MoveResult.SUCCESS || lastMove.result === MoveResult.MISS;
|
||||
if (lastMove.move === move && validLastMoveResult && lastMove.move !== MoveId.STRUGGLE && !isUnaffected) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return lastMove.move === move && validLastMoveResult && lastMove.move !== MoveId.STRUGGLE && !isUnaffected;
|
||||
}
|
||||
|
||||
override selectionDeniedText(pokemon: Pokemon, _move: MoveId): string {
|
||||
|
@ -5472,13 +5472,6 @@ export class AddBattlerTagAttr extends MoveEffectAttr {
|
||||
this.failOnOverlap = !!failOnOverlap;
|
||||
}
|
||||
|
||||
canApply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
if (!super.canApply(user, target, move, args)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
if (!super.apply(user, target, move, args)) {
|
||||
return false;
|
||||
@ -6832,7 +6825,7 @@ export class RandomMovesetMoveAttr extends CallMoveAttr {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.moveId = moves[user.randBattleSeedInt(moves.length)]!.moveId;
|
||||
this.moveId = moves[user.randBattleSeedInt(moves.length)].moveId;
|
||||
return true;
|
||||
};
|
||||
}
|
||||
@ -7367,11 +7360,7 @@ export class SketchAttr extends MoveEffectAttr {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (user.getMoveset().find(m => m.moveId === targetMove.move)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !user.getMoveset().some(m => m.moveId === targetMove.move);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -275,15 +275,11 @@ export class TimeOfDayRequirement extends EncounterSceneRequirement {
|
||||
|
||||
override meetsRequirement(): boolean {
|
||||
const timeOfDay = globalScene.arena?.getTimeOfDay();
|
||||
if (
|
||||
return !(
|
||||
!isNullOrUndefined(timeOfDay) &&
|
||||
this.requiredTimeOfDay?.length > 0 &&
|
||||
!this.requiredTimeOfDay.includes(timeOfDay)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
);
|
||||
}
|
||||
|
||||
override getDialogueToken(_pokemon?: PlayerPokemon): [string, string] {
|
||||
@ -301,15 +297,11 @@ export class WeatherRequirement extends EncounterSceneRequirement {
|
||||
|
||||
override meetsRequirement(): boolean {
|
||||
const currentWeather = globalScene.arena.weather?.weatherType;
|
||||
if (
|
||||
return !(
|
||||
!isNullOrUndefined(currentWeather) &&
|
||||
this.requiredWeather?.length > 0 &&
|
||||
!this.requiredWeather.includes(currentWeather!)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
);
|
||||
}
|
||||
|
||||
override getDialogueToken(_pokemon?: PlayerPokemon): [string, string] {
|
||||
@ -803,7 +795,7 @@ export class CanFormChangeWithItemRequirement extends EncounterPokemonRequiremen
|
||||
}
|
||||
|
||||
filterByForm(pokemon, formChangeItem) {
|
||||
if (
|
||||
return (
|
||||
pokemonFormChanges.hasOwnProperty(pokemon.species.speciesId) &&
|
||||
// Get all form changes for this species with an item trigger, including any compound triggers
|
||||
pokemonFormChanges[pokemon.species.speciesId]
|
||||
@ -812,10 +804,7 @@ export class CanFormChangeWithItemRequirement extends EncounterPokemonRequiremen
|
||||
.flatMap(fc => fc.findTrigger(SpeciesFormChangeItemTrigger) as SpeciesFormChangeItemTrigger)
|
||||
.flatMap(fc => fc.item)
|
||||
.includes(formChangeItem)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
);
|
||||
}
|
||||
|
||||
override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] {
|
||||
@ -873,17 +862,15 @@ export class CanEvolveWithItemRequirement extends EncounterPokemonRequirement {
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
|
||||
return (
|
||||
pokemon.isFusion() &&
|
||||
pokemonEvolutions.hasOwnProperty(pokemon.fusionSpecies.speciesId) &&
|
||||
pokemonEvolutions[pokemon.fusionSpecies.speciesId].filter(
|
||||
e => e.item === evolutionItem && (!e.condition || e.condition.predicate(pokemon)),
|
||||
).length &&
|
||||
pokemon.getFusionFormKey() !== SpeciesFormKey.GIGANTAMAX
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
);
|
||||
}
|
||||
|
||||
override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] {
|
||||
|
@ -186,11 +186,7 @@ export class SpeciesFormChange {
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.trigger.canChange(pokemon)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return this.trigger.canChange(pokemon);
|
||||
}
|
||||
|
||||
findTrigger(triggerType: Constructor<SpeciesFormChangeTrigger>): SpeciesFormChangeTrigger | nil {
|
||||
|
@ -1281,10 +1281,6 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
||||
};
|
||||
}
|
||||
|
||||
isObtainable() {
|
||||
return super.isObtainable();
|
||||
}
|
||||
|
||||
hasVariants() {
|
||||
let variantDataIndex: string | number = this.speciesId;
|
||||
if (this.forms.length > 0) {
|
||||
|
@ -1292,19 +1292,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
*/
|
||||
isOffsetBySubstitute(): boolean {
|
||||
const substitute = this.getTag(SubstituteTag);
|
||||
if (substitute) {
|
||||
if (substitute.sprite === undefined) {
|
||||
if (!substitute || substitute.sprite === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// During the Pokemon's MoveEffect phase, the offset is removed to put the Pokemon "in focus"
|
||||
const currentPhase = globalScene.getCurrentPhase();
|
||||
if (currentPhase?.is("MoveEffectPhase") && currentPhase.getPokemon() === this) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !(currentPhase?.is("MoveEffectPhase") && currentPhase.getPokemon() === this);
|
||||
}
|
||||
|
||||
/** If this Pokemon has a Substitute on the field, removes its sprite from the field. */
|
||||
@ -2241,10 +2234,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
if (this.getAbility(ignoreOverride).id === ability && (!canApply || this.canApplyAbility())) {
|
||||
return true;
|
||||
}
|
||||
if (this.getPassiveAbility().id === ability && this.hasPassive() && (!canApply || this.canApplyAbility(true))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.getPassiveAbility().id === ability && this.hasPassive() && (!canApply || this.canApplyAbility(true));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2261,10 +2251,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
if ((!canApply || this.canApplyAbility()) && this.getAbility(ignoreOverride).hasAttr(attrType)) {
|
||||
return true;
|
||||
}
|
||||
if (this.hasPassive() && (!canApply || this.canApplyAbility(true)) && this.getPassiveAbility().hasAttr(attrType)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.hasPassive() && (!canApply || this.canApplyAbility(true)) && this.getPassiveAbility().hasAttr(attrType);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -5464,10 +5451,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
if ((ownedAbilityAttrs & 2) > 0 && this.hasSameAbilityInRootForm(1)) {
|
||||
return true;
|
||||
}
|
||||
if ((ownedAbilityAttrs & 4) > 0 && this.hasSameAbilityInRootForm(2)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (ownedAbilityAttrs & 4) > 0 && this.hasSameAbilityInRootForm(2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1090,10 +1090,6 @@ export class PokemonIncrementingStatModifier extends PokemonHeldItemModifier {
|
||||
return new PokemonIncrementingStatModifier(this.type, this.pokemonId, this.stackCount);
|
||||
}
|
||||
|
||||
getArgs(): any[] {
|
||||
return super.getArgs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the {@linkcode PokemonIncrementingStatModifier} should be applied to the {@linkcode Pokemon}.
|
||||
* @param pokemon The {@linkcode Pokemon} that holds the item
|
||||
@ -1216,10 +1212,6 @@ export class StatBoosterModifier extends PokemonHeldItemModifier {
|
||||
* @see {@linkcode apply}
|
||||
*/
|
||||
export class EvolutionStatBoosterModifier extends StatBoosterModifier {
|
||||
clone() {
|
||||
return super.clone() as EvolutionStatBoosterModifier;
|
||||
}
|
||||
|
||||
matchType(modifier: Modifier): boolean {
|
||||
return modifier instanceof EvolutionStatBoosterModifier;
|
||||
}
|
||||
|
@ -21,8 +21,5 @@ export function hasExpSprite(key: string): boolean {
|
||||
if (keyMatch[5]) {
|
||||
k += keyMatch[5];
|
||||
}
|
||||
if (!expSpriteKeys.has(k)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return expSpriteKeys.has(k);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user