From b2e59831539e386304153437da282275befbd61e Mon Sep 17 00:00:00 2001 From: xsn34kzx Date: Fri, 1 Aug 2025 15:05:20 -0400 Subject: [PATCH] Transition to `BooleanHolder` --- src/data/challenge.ts | 115 +++++++++++------- src/data/moves/pokemon-move.ts | 18 +-- .../utils/encounter-pokemon-utils.ts | 6 +- src/game-mode.ts | 8 +- src/modifier/modifier-type.ts | 31 +++-- src/phases/attempt-capture-phase.ts | 5 +- src/phases/command-phase.ts | 11 +- src/phases/party-heal-phase.ts | 7 +- src/phases/select-biome-phase.ts | 6 +- src/phases/victory-phase.ts | 5 +- src/ui/modifier-select-ui-handler.ts | 2 +- src/utils/challenge-utils.ts | 77 ++++++++---- 12 files changed, 195 insertions(+), 96 deletions(-) diff --git a/src/data/challenge.ts b/src/data/challenge.ts index 76a78a0c2ce..4a86cb1a6ef 100644 --- a/src/data/challenge.ts +++ b/src/data/challenge.ts @@ -344,70 +344,78 @@ export abstract class Challenge { /** * An apply function for PARTY_HEAL. Derived classes should alter this. - * @returns Whether party healing is enabled or not + * @param _status - Whether party healing is enabled or not + * @returns Whether this function did anything */ - applyPartyHeal(): boolean { - return true; + applyPartyHeal(_status: BooleanHolder): boolean { + return false; } /** * An apply function for SHOP. Derived classes should alter this. - * @returns Whether the shop is or is not available after a wave + * @param _status - Whether the shop is or is not available after a wave + * @returns Whether this function did anything */ - applyShop() { - return true; + applyShop(_status: BooleanHolder) { + return false; } /** * An apply function for POKEMON_ADD_TO_PARTY. Derived classes should alter this. * @param _pokemon - The pokemon being caught - * @return Whether the pokemon can be added to the party or not + * @param _status - Whether the pokemon can be added to the party or not + * @return Whether this function did anything */ - applyPokemonAddToParty(_pokemon: EnemyPokemon): boolean { - return true; + applyPokemonAddToParty(_pokemon: EnemyPokemon, _status: BooleanHolder): boolean { + return false; } /** * An apply function for POKEMON_FUSION. Derived classes should alter this. * @param _pokemon - The pokemon being checked - * @returns Whether the selected pokemon is allowed to fuse or not + * @param _status - Whether the selected pokemon is allowed to fuse or not + * @returns Whether this function did anything */ - applyPokemonFusion(_pokemon: PlayerPokemon): boolean { + applyPokemonFusion(_pokemon: PlayerPokemon, _status: BooleanHolder): boolean { return false; } /** * An apply function for POKEMON_MOVE. Derived classes should alter this. * @param _moveId - The move being checked - * @returns Whether the move can be used or not + * @param _status - Whether the move can be used or not + * @returns Whether this function did anything */ - applyPokemonMove(_moveId: MoveId): boolean { - return true; + applyPokemonMove(_moveId: MoveId, _status: BooleanHolder): boolean { + return false; } /** * An apply function for SHOP_ITEM. Derived classes should alter this. * @param _shopItem - The item being checked - * @returns Whether the item should be added to the shop or not + * @param _status - Whether the item should be added to the shop or not + * @returns Whether this function did anything */ - applyShopItem(_shopItem: ModifierTypeOption | null): boolean { - return true; + applyShopItem(_shopItem: ModifierTypeOption | null, _status: BooleanHolder): boolean { + return false; } /** * An apply function for WAVE_REWARD. Derived classes should alter this. * @param _reward - The reward being checked - * @returns Whether the reward should be added to the reward options or not + * @param _status - Whether the reward should be added to the reward options or not + * @returns Whether this function did anything */ - applyWaveReward(_reward: ModifierTypeOption | null): boolean { - return true; + applyWaveReward(_reward: ModifierTypeOption | null, _status: BooleanHolder): boolean { + return false; } /** * An apply function for PREVENT_REVIVE. Derived classes should alter this. - * @returns Whether fainting is a permanent status or not + * @param _status - Whether fainting is a permanent status or not + * @returns Whether this function did anything */ - applyPreventRevive(): boolean { + applyPreventRevive(_status: BooleanHolder): boolean { return false; } } @@ -933,19 +941,24 @@ export class LowerStarterPointsChallenge extends Challenge { * Implements a No Support challenge */ export class NoSupportChallenge extends Challenge { - // 1 is no_heal - // 2 is no_shop - // 3 is both constructor() { super(Challenges.NO_SUPPORT, 3); } - override applyPartyHeal(): boolean { - return this.value === 2; + override applyPartyHeal(status: BooleanHolder): boolean { + if (status.value) { + status.value = this.value === 2; + return true; + } + return false; } - override applyShop(): boolean { - return this.value === 1; + override applyShop(status: BooleanHolder): boolean { + if (status.value) { + status.value = this.value === 1; + return true; + } + return false; } static override loadChallenge(source: NoSupportChallenge | any): NoSupportChallenge { @@ -964,8 +977,12 @@ export class LimitedCatchChallenge extends Challenge { super(Challenges.LIMITED_CATCH, 1); } - override applyPokemonAddToParty(pokemon: EnemyPokemon): boolean { - return pokemon.metWave % 10 === 1; + override applyPokemonAddToParty(pokemon: EnemyPokemon, status: BooleanHolder): boolean { + if (status.value) { + status.value = pokemon.metWave % 10 === 1; + return true; + } + return false; } static override loadChallenge(source: LimitedCatchChallenge | any): LimitedCatchChallenge { @@ -984,24 +1001,40 @@ export class PermanentFaintChallenge extends Challenge { super(Challenges.PERMANENT_FAINT, 1); } - override applyPokemonFusion(pokemon: PlayerPokemon): boolean { - return !pokemon.isFainted(); + override applyPokemonFusion(pokemon: PlayerPokemon, status: BooleanHolder): boolean { + if (!status.value) { + status.value = pokemon.isFainted(); + return true; + } + return false; } - override applyShopItem(shopItem: ModifierTypeOption | null): boolean { - return shopItem?.type.group !== "revive"; + override applyShopItem(shopItem: ModifierTypeOption | null, status: BooleanHolder): boolean { + if (status.value) { + status.value = shopItem?.type.group !== "revive"; + return true; + } + return false; } - override applyWaveReward(reward: ModifierTypeOption | null): boolean { - return this.applyShopItem(reward); + override applyWaveReward(reward: ModifierTypeOption | null, status: BooleanHolder): boolean { + return this.applyShopItem(reward, status); } - override applyPokemonMove(moveId: MoveId) { - return moveId !== MoveId.REVIVAL_BLESSING; + override applyPokemonMove(moveId: MoveId, status: BooleanHolder) { + if (status.value) { + status.value = moveId !== MoveId.REVIVAL_BLESSING; + return true; + } + return false; } - override applyPreventRevive(): boolean { - return true; + override applyPreventRevive(status: BooleanHolder): boolean { + if (!status.value) { + status.value = true; + return true; + } + return false; } static override loadChallenge(source: PermanentFaintChallenge | any): PermanentFaintChallenge { diff --git a/src/data/moves/pokemon-move.ts b/src/data/moves/pokemon-move.ts index 3d75a565edf..9678889ea51 100644 --- a/src/data/moves/pokemon-move.ts +++ b/src/data/moves/pokemon-move.ts @@ -1,8 +1,10 @@ import { allMoves } from "#data/data-lists"; +import { ChallengeType } from "#enums/challenge-type"; import type { MoveId } from "#enums/move-id"; import type { Pokemon } from "#field/pokemon"; import type { Move } from "#moves/move"; -import { toDmgValue } from "#utils/common"; +import { applyChallenges } from "#utils/challenge-utils"; +import { BooleanHolder, toDmgValue } from "#utils/common"; /** * Wrapper class for the {@linkcode Move} class for Pokemon to interact with. @@ -47,13 +49,15 @@ export class PokemonMove { isUsable(pokemon: Pokemon, ignorePp = false, ignoreRestrictionTags = false): boolean { const move = this.getMove(); // TODO: Add Sky Drop's 1 turn stall - return ( - !(this.moveId && !ignoreRestrictionTags && pokemon.isMoveRestricted(this.moveId, pokemon)) && - (ignorePp || this.ppUsed < this.getMovePp() || move.pp === -1) && - // TODO: Fix apply calls - //(!pokemon.isPlayer() || applyChallenges(ChallengeType.POKEMON_MOVE, this.moveId)) && - !move.name.endsWith(" (N)") + const usability = new BooleanHolder( + !move.name.endsWith(" (N)") && + (ignorePp || this.ppUsed < this.getMovePp() || move.pp === -1) && + !(this.moveId && !ignoreRestrictionTags && pokemon.isMoveRestricted(this.moveId, pokemon)), ); + if (usability.value && pokemon.isPlayer()) { + applyChallenges(ChallengeType.POKEMON_MOVE, move.id, usability); + } + return usability.value; } getMove(): Move { diff --git a/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts b/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts index 07513da2b37..ff79b9fc312 100644 --- a/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts @@ -35,7 +35,7 @@ import type { PartyOption } from "#ui/party-ui-handler"; import { PartyUiMode } from "#ui/party-ui-handler"; import { SummaryUiMode } from "#ui/summary-ui-handler"; import { applyChallenges } from "#utils/challenge-utils"; -import { isNullOrUndefined, randSeedInt } from "#utils/common"; +import { BooleanHolder, isNullOrUndefined, randSeedInt } from "#utils/common"; import { getPokemonSpecies } from "#utils/pokemon-utils"; import i18next from "i18next"; @@ -709,7 +709,9 @@ export async function catchPokemon( }; Promise.all([pokemon.hideInfo(), globalScene.gameData.setPokemonCaught(pokemon)]).then(() => { // TODO: Address ME edge cases (Safari Zone, etc.) - if (!applyChallenges(ChallengeType.POKEMON_ADD_TO_PARTY, pokemon)) { + const addStatus = new BooleanHolder(true); + applyChallenges(ChallengeType.POKEMON_ADD_TO_PARTY, pokemon, addStatus); + if (!addStatus.value) { removePokemon(); end(); return; diff --git a/src/game-mode.ts b/src/game-mode.ts index 415b16f83ed..645a6b8c449 100644 --- a/src/game-mode.ts +++ b/src/game-mode.ts @@ -14,7 +14,7 @@ import { SpeciesId } from "#enums/species-id"; import type { Arena } from "#field/arena"; import { classicFixedBattles, type FixedBattleConfigs } from "#trainers/fixed-battle-configs"; import { applyChallenges } from "#utils/challenge-utils"; -import { isNullOrUndefined, randSeedInt, randSeedItem } from "#utils/common"; +import { BooleanHolder, isNullOrUndefined, randSeedInt, randSeedItem } from "#utils/common"; import i18next from "i18next"; interface GameModeConfig { @@ -315,8 +315,10 @@ export class GameMode implements GameModeConfig { * Checks if the game mode has the shop enabled or not * @returns Whether the shop is available or not */ - getShopAvailability(): boolean { - return !this.hasNoShop && this.modeId === GameModes.CHALLENGE && applyChallenges(ChallengeType.SHOP); + getShopStatus(): boolean { + const status = new BooleanHolder(!this.hasNoShop); + applyChallenges(ChallengeType.SHOP, status); + return status.value; } getClearScoreBonus(): number { diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index f0692b98991..9ec9ee0ad48 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -118,7 +118,15 @@ import type { PokemonMoveSelectFilter, PokemonSelectFilter } from "#ui/party-ui- import { PartyUiHandler } from "#ui/party-ui-handler"; import { getModifierTierTextTint } from "#ui/text"; import { applyChallenges } from "#utils/challenge-utils"; -import { formatMoney, isNullOrUndefined, NumberHolder, padInt, randSeedInt, randSeedItem } from "#utils/common"; +import { + BooleanHolder, + formatMoney, + isNullOrUndefined, + NumberHolder, + padInt, + randSeedInt, + randSeedItem, +} from "#utils/common"; import { getEnumKeys, getEnumValues } from "#utils/enums"; import { getModifierPoolForType, getModifierType } from "#utils/modifier-utils"; import i18next from "i18next"; @@ -535,7 +543,9 @@ export class PokemonReviveModifierType extends PokemonHpRestoreModifierType { ); this.selectFilter = (pokemon: PlayerPokemon) => { - if (pokemon.hp || applyChallenges(ChallengeType.PREVENT_REVIVE)) { + const selectStatus = new BooleanHolder(pokemon.hp !== 0); + applyChallenges(ChallengeType.PREVENT_REVIVE, selectStatus); + if (selectStatus.value) { return PartyUiHandler.NoEffectMessage; } return null; @@ -1265,7 +1275,9 @@ export class FusePokemonModifierType extends PokemonModifierType { iconImage, (_type, args) => new FusePokemonModifier(this, (args[0] as PlayerPokemon).id, (args[1] as PlayerPokemon).id), (pokemon: PlayerPokemon) => { - if (pokemon.isFusion() || !applyChallenges(ChallengeType.POKEMON_FUSION, pokemon)) { + const selectStatus = new BooleanHolder(pokemon.isFusion()); + applyChallenges(ChallengeType.POKEMON_FUSION, pokemon, selectStatus); + if (selectStatus.value) { return PartyUiHandler.NoEffectMessage; } return null; @@ -2577,14 +2589,15 @@ function getModifierTypeOptionWithRetry( ): ModifierTypeOption { allowLuckUpgrades = allowLuckUpgrades ?? true; let candidate = getNewModifierTypeOption(party, ModifierPoolType.PLAYER, tier, undefined, 0, allowLuckUpgrades); - let candidateValidity = applyChallenges(ChallengeType.WAVE_REWARD, candidate); + const candidateValidity = new BooleanHolder(true); + applyChallenges(ChallengeType.WAVE_REWARD, candidate, candidateValidity); let r = 0; while ( (existingOptions.length && ++r < retryCount && existingOptions.filter(o => o.type.name === candidate?.type.name || o.type.group === candidate?.type.group) .length) || - !candidateValidity + !candidateValidity.value ) { candidate = getNewModifierTypeOption( party, @@ -2594,7 +2607,7 @@ function getModifierTypeOptionWithRetry( 0, allowLuckUpgrades, ); - candidateValidity = applyChallenges(ChallengeType.WAVE_REWARD, candidate); + applyChallenges(ChallengeType.WAVE_REWARD, candidate, candidateValidity); } return candidate!; } @@ -2659,7 +2672,11 @@ export function getPlayerShopModifierTypeOptionsForWave(waveIndex: number, baseC return options .slice(0, Math.ceil(Math.max(waveIndex + 10, 0) / 30)) .flat() - .filter(shopItem => applyChallenges(ChallengeType.SHOP_ITEM, shopItem)); + .filter(shopItem => { + const status = new BooleanHolder(true); + applyChallenges(ChallengeType.SHOP_ITEM, shopItem, status); + return status.value; + }); } export function getEnemyBuffModifierForWave( diff --git a/src/phases/attempt-capture-phase.ts b/src/phases/attempt-capture-phase.ts index 6283a18fc28..aea39cff294 100644 --- a/src/phases/attempt-capture-phase.ts +++ b/src/phases/attempt-capture-phase.ts @@ -25,6 +25,7 @@ import type { PartyOption } from "#ui/party-ui-handler"; import { PartyUiMode } from "#ui/party-ui-handler"; import { SummaryUiMode } from "#ui/summary-ui-handler"; import { applyChallenges } from "#utils/challenge-utils"; +import { BooleanHolder } from "#utils/common"; import i18next from "i18next"; // TODO: Refactor and split up to allow for overriding capture chance @@ -289,7 +290,9 @@ export class AttemptCapturePhase extends PokemonPhase { }); }; Promise.all([pokemon.hideInfo(), globalScene.gameData.setPokemonCaught(pokemon)]).then(() => { - if (!applyChallenges(ChallengeType.POKEMON_ADD_TO_PARTY, pokemon)) { + const addStatus = new BooleanHolder(true); + applyChallenges(ChallengeType.POKEMON_ADD_TO_PARTY, pokemon, addStatus); + if (!addStatus.value) { removePokemon(); end(); return; diff --git a/src/phases/command-phase.ts b/src/phases/command-phase.ts index a6865fa1522..c7eb466157d 100644 --- a/src/phases/command-phase.ts +++ b/src/phases/command-phase.ts @@ -23,6 +23,7 @@ import { getMoveTargets } from "#moves/move-utils"; import { FieldPhase } from "#phases/field-phase"; import type { TurnMove } from "#types/turn-move"; import { applyChallenges } from "#utils/challenge-utils"; +import { BooleanHolder } from "#utils/common"; import i18next from "i18next"; export class CommandPhase extends FieldPhase { @@ -214,14 +215,16 @@ export class CommandPhase extends FieldPhase { // Set the translation key for why the move cannot be selected let cannotSelectKey: string; - if (user.isMoveRestricted(move.moveId, user)) { - cannotSelectKey = user.getRestrictingTag(move.moveId, user)!.selectionDeniedText(user, move.moveId); + const moveStatus = new BooleanHolder(true); + applyChallenges(ChallengeType.POKEMON_MOVE, move.moveId, moveStatus); + if (!moveStatus.value) { + cannotSelectKey = "battle:moveCannotUseChallenge"; } else if (move.getPpRatio() === 0) { cannotSelectKey = "battle:moveNoPP"; - } else if (!applyChallenges(ChallengeType.POKEMON_MOVE, move.moveId)) { - cannotSelectKey = "battle:moveCannotUseChallenge"; } else if (move.getName().endsWith(" (N)")) { cannotSelectKey = "battle:moveNotImplemented"; + } else if (user.isMoveRestricted(move.moveId, user)) { + cannotSelectKey = user.getRestrictingTag(move.moveId, user)!.selectionDeniedText(user, move.moveId); } else { // TODO: Consider a message that signals a being unusable for an unknown reason cannotSelectKey = ""; diff --git a/src/phases/party-heal-phase.ts b/src/phases/party-heal-phase.ts index d16e732a87f..9596be86c09 100644 --- a/src/phases/party-heal-phase.ts +++ b/src/phases/party-heal-phase.ts @@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene"; import { ChallengeType } from "#enums/challenge-type"; import { BattlePhase } from "#phases/battle-phase"; import { applyChallenges } from "#utils/challenge-utils"; -import { fixedInt } from "#utils/common"; +import { BooleanHolder, fixedInt } from "#utils/common"; export class PartyHealPhase extends BattlePhase { public readonly phaseName = "PartyHealPhase"; @@ -22,9 +22,10 @@ export class PartyHealPhase extends BattlePhase { globalScene.fadeOutBgm(1000, false); } globalScene.ui.fadeOut(1000).then(() => { - const preventRevive = applyChallenges(ChallengeType.PREVENT_REVIVE); + const preventRevive = new BooleanHolder(false); + applyChallenges(ChallengeType.PREVENT_REVIVE, preventRevive); for (const pokemon of globalScene.getPlayerParty()) { - if (!(pokemon.isFainted() && preventRevive)) { + if (!(pokemon.isFainted() && preventRevive.value)) { pokemon.hp = pokemon.getMaxHp(); pokemon.resetStatus(true, false, false, true); for (const move of pokemon.moveset) { diff --git a/src/phases/select-biome-phase.ts b/src/phases/select-biome-phase.ts index be76ef721f5..fd6e69e04a7 100644 --- a/src/phases/select-biome-phase.ts +++ b/src/phases/select-biome-phase.ts @@ -7,7 +7,7 @@ import { MapModifier, MoneyInterestModifier } from "#modifiers/modifier"; import { BattlePhase } from "#phases/battle-phase"; import type { OptionSelectItem } from "#ui/abstact-option-select-ui-handler"; import { applyChallenges } from "#utils/challenge-utils"; -import { randSeedInt } from "#utils/common"; +import { BooleanHolder, randSeedInt } from "#utils/common"; export class SelectBiomePhase extends BattlePhase { public readonly phaseName = "SelectBiomePhase"; @@ -22,7 +22,9 @@ export class SelectBiomePhase extends BattlePhase { const setNextBiome = (nextBiome: BiomeId) => { if (nextWaveIndex % 10 === 1) { globalScene.applyModifiers(MoneyInterestModifier, true); - if (applyChallenges(ChallengeType.PARTY_HEAL)) { + const healStatus = new BooleanHolder(false); + applyChallenges(ChallengeType.PARTY_HEAL, healStatus); + if (healStatus.value) { globalScene.phaseManager.unshiftNew("PartyHealPhase", false); } } diff --git a/src/phases/victory-phase.ts b/src/phases/victory-phase.ts index 8ec195a99db..c0f4a32d7e1 100644 --- a/src/phases/victory-phase.ts +++ b/src/phases/victory-phase.ts @@ -9,6 +9,7 @@ import type { CustomModifierSettings } from "#modifiers/modifier-type"; import { handleMysteryEncounterVictory } from "#mystery-encounters/encounter-phase-utils"; import { PokemonPhase } from "#phases/pokemon-phase"; import { applyChallenges } from "#utils/challenge-utils"; +import { BooleanHolder } from "#utils/common"; export class VictoryPhase extends PokemonPhase { public readonly phaseName = "VictoryPhase"; @@ -65,7 +66,9 @@ export class VictoryPhase extends PokemonPhase { break; } } - if (globalScene.currentBattle.waveIndex % 10 || !applyChallenges(ChallengeType.PARTY_HEAL)) { + const healStatus = new BooleanHolder(globalScene.currentBattle.waveIndex % 10 === 0); + applyChallenges(ChallengeType.PARTY_HEAL, healStatus); + if (!healStatus.value) { globalScene.phaseManager.pushNew( "SelectModifierPhase", undefined, diff --git a/src/ui/modifier-select-ui-handler.ts b/src/ui/modifier-select-ui-handler.ts index e8d20323c74..d90b3310fb0 100644 --- a/src/ui/modifier-select-ui-handler.ts +++ b/src/ui/modifier-select-ui-handler.ts @@ -209,7 +209,7 @@ export class ModifierSelectUiHandler extends AwaitableUiHandler { this.updateRerollCostText(); const typeOptions = args[1] as ModifierTypeOption[]; - const hasShop = globalScene.gameMode.getShopAvailability(); + const hasShop = globalScene.gameMode.getShopStatus(); const baseShopCost = new NumberHolder(globalScene.getWaveMoneyAmount(1)); globalScene.applyModifier(HealShopCostModifier, true, baseShopCost); const shopTypeOptions = hasShop diff --git a/src/utils/challenge-utils.ts b/src/utils/challenge-utils.ts index 67f1d2d2be3..c38bb887a00 100644 --- a/src/utils/challenge-utils.ts +++ b/src/utils/challenge-utils.ts @@ -168,62 +168,91 @@ export function applyChallenges(challengeType: ChallengeType.FLIP_STAT, pokemon: /** * Apply all challenges that conditionally enable or disable automatic party healing during biome transitions * @param challengeType - {@linkcode ChallengeType.PARTY_HEAL} - * @returns Whether party healing is enabled or not + * @param status - Whether party healing is enabled or not + * @returns `true` if any challenge was successfully applied, `false` otherwise */ -export function applyChallenges(challengeType: ChallengeType.PARTY_HEAL): boolean; +export function applyChallenges(challengeType: ChallengeType.PARTY_HEAL, status: BooleanHolder): boolean; /** * Apply all challenges that conditionally enable or disable the shop - * @returns Whether the shop is or is not available after a wave + * @param challengeType - {@linkcode ChallengeType.SHOP} + * @param status - Whether party healing is enabled or not + * @returns `true` if any challenge was successfully applied, `false` otherwise */ -export function applyChallenges(challengeType: ChallengeType.SHOP): boolean; +export function applyChallenges(challengeType: ChallengeType.SHOP, status: BooleanHolder): boolean; /** * Apply all challenges that validate whether a pokemon can be added to the player's party or not * @param challengeType - {@linkcode ChallengeType.POKEMON_ADD_TO_PARTY} * @param pokemon - The pokemon being caught - * @return Whether the pokemon can be added to the party or not + * @param status - Whether the pokemon can be added to the party or not + * @return `true` if any challenge was sucessfully applied, `false` otherwise */ -export function applyChallenges(challengeType: ChallengeType.POKEMON_ADD_TO_PARTY, pokemon: EnemyPokemon): boolean; +export function applyChallenges( + challengeType: ChallengeType.POKEMON_ADD_TO_PARTY, + pokemon: EnemyPokemon, + status: BooleanHolder, +): boolean; /** * Apply all challenges that validate whether a pokemon is allowed to fuse or not * @param challengeType - {@linkcode ChallengeType.POKEMON_FUSION} * @param pokemon - The pokemon being checked - * @returns Whether the selected pokemon is allowed to fuse or not + * @param status - Whether the selected pokemon is allowed to fuse or not + * @return `true` if any challenge was sucessfully applied, `false` otherwise */ -export function applyChallenges(challengeType: ChallengeType.POKEMON_FUSION, pokemon: PlayerPokemon): boolean; +export function applyChallenges( + challengeType: ChallengeType.POKEMON_FUSION, + pokemon: PlayerPokemon, + status: BooleanHolder, +): boolean; /** * Apply all challenges that validate whether particular moves can or cannot be used * @param challengeType - {@linkcode ChallengeType.POKEMON_MOVE} * @param moveId - The move being checked - * @returns Whether the move can be used or not + * @param status - Whether the move can be used or not + * @return `true` if any challenge was sucessfully applied, `false` otherwise */ -export function applyChallenges(challengeType: ChallengeType.POKEMON_MOVE, moveId: MoveId): boolean; +export function applyChallenges( + challengeType: ChallengeType.POKEMON_MOVE, + moveId: MoveId, + status: BooleanHolder, +): boolean; /** * Apply all challenges that validate whether particular items are or are not sold in the shop * @param challengeType - {@linkcode ChallengeType.SHOP_ITEM} * @param shopItem - The item being checked - * @returns Whether the item should be added to the shop or not + * @param status - Whether the item should be added to the shop or not + * @return `true` if any challenge was sucessfully applied, `false` otherwise */ -export function applyChallenges(challengeType: ChallengeType.SHOP_ITEM, shopItem: ModifierTypeOption | null): boolean; +export function applyChallenges( + challengeType: ChallengeType.SHOP_ITEM, + shopItem: ModifierTypeOption | null, + status: BooleanHolder, +): boolean; /** * Apply all challenges that validate whether particular items will be given as a reward after a wave * @param challengeType - {@linkcode ChallengeType.WAVE_REWARD} * @param reward - The reward being checked - * @returns Whether the reward should be added to the reward options or not + * @param status - Whether the reward should be added to the reward options or not + * @return `true` if any challenge was sucessfully applied, `false` otherwise */ -export function applyChallenges(challengeType: ChallengeType.WAVE_REWARD, reward: ModifierTypeOption | null): boolean; +export function applyChallenges( + challengeType: ChallengeType.WAVE_REWARD, + reward: ModifierTypeOption | null, + status: BooleanHolder, +): boolean; /** * Apply all challenges that prevent recovery from fainting * @param challengeType - {@linkcode ChallengeType.PREVENT_REVIVE} - * @returns Whether fainting is a permanent status or not + * @param status - Whether fainting is a permanent status or not + * @return `true` if any challenge was sucessfully applied, `false` otherwise */ -export function applyChallenges(challengeType: ChallengeType.PREVENT_REVIVE): boolean; +export function applyChallenges(challengeType: ChallengeType.PREVENT_REVIVE, status: BooleanHolder): boolean; export function applyChallenges(challengeType: ChallengeType, ...args: any[]): boolean { let ret = false; @@ -273,28 +302,28 @@ export function applyChallenges(challengeType: ChallengeType, ...args: any[]): b ret ||= c.applyFlipStat(args[0], args[1]); break; case ChallengeType.PARTY_HEAL: - ret ||= c.applyPartyHeal(); + ret ||= c.applyPartyHeal(args[0]); break; case ChallengeType.SHOP: - ret ||= c.applyShop(); + ret ||= c.applyShop(args[0]); break; case ChallengeType.POKEMON_ADD_TO_PARTY: - ret ||= c.applyPokemonAddToParty(args[0]); + ret ||= c.applyPokemonAddToParty(args[0], args[1]); break; case ChallengeType.POKEMON_FUSION: - ret ||= c.applyPokemonFusion(args[0]); + ret ||= c.applyPokemonFusion(args[0], args[1]); break; case ChallengeType.POKEMON_MOVE: - ret ||= c.applyPokemonMove(args[0]); + ret ||= c.applyPokemonMove(args[0], args[1]); break; case ChallengeType.SHOP_ITEM: - ret ||= c.applyShopItem(args[0]); + ret ||= c.applyShopItem(args[0], args[1]); break; case ChallengeType.WAVE_REWARD: - ret ||= c.applyWaveReward(args[0]); + ret ||= c.applyWaveReward(args[0], args[1]); break; case ChallengeType.PREVENT_REVIVE: - ret ||= c.applyPreventRevive(); + ret ||= c.applyPreventRevive(args[0]); break; } }