Transition to BooleanHolder

This commit is contained in:
xsn34kzx 2025-08-01 15:05:20 -04:00
parent 809a981893
commit b2e5983153
12 changed files with 195 additions and 96 deletions

View File

@ -344,70 +344,78 @@ export abstract class Challenge {
/** /**
* An apply function for PARTY_HEAL. Derived classes should alter this. * 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 { applyPartyHeal(_status: BooleanHolder): boolean {
return true; return false;
} }
/** /**
* An apply function for SHOP. Derived classes should alter this. * 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() { applyShop(_status: BooleanHolder) {
return true; return false;
} }
/** /**
* An apply function for POKEMON_ADD_TO_PARTY. Derived classes should alter this. * An apply function for POKEMON_ADD_TO_PARTY. Derived classes should alter this.
* @param _pokemon - The pokemon being caught * @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 { applyPokemonAddToParty(_pokemon: EnemyPokemon, _status: BooleanHolder): boolean {
return true; return false;
} }
/** /**
* An apply function for POKEMON_FUSION. Derived classes should alter this. * An apply function for POKEMON_FUSION. Derived classes should alter this.
* @param _pokemon - The pokemon being checked * @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; return false;
} }
/** /**
* An apply function for POKEMON_MOVE. Derived classes should alter this. * An apply function for POKEMON_MOVE. Derived classes should alter this.
* @param _moveId - The move being checked * @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 { applyPokemonMove(_moveId: MoveId, _status: BooleanHolder): boolean {
return true; return false;
} }
/** /**
* An apply function for SHOP_ITEM. Derived classes should alter this. * An apply function for SHOP_ITEM. Derived classes should alter this.
* @param _shopItem - The item being checked * @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 { applyShopItem(_shopItem: ModifierTypeOption | null, _status: BooleanHolder): boolean {
return true; return false;
} }
/** /**
* An apply function for WAVE_REWARD. Derived classes should alter this. * An apply function for WAVE_REWARD. Derived classes should alter this.
* @param _reward - The reward being checked * @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 { applyWaveReward(_reward: ModifierTypeOption | null, _status: BooleanHolder): boolean {
return true; return false;
} }
/** /**
* An apply function for PREVENT_REVIVE. Derived classes should alter this. * 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; return false;
} }
} }
@ -933,19 +941,24 @@ export class LowerStarterPointsChallenge extends Challenge {
* Implements a No Support challenge * Implements a No Support challenge
*/ */
export class NoSupportChallenge extends Challenge { export class NoSupportChallenge extends Challenge {
// 1 is no_heal
// 2 is no_shop
// 3 is both
constructor() { constructor() {
super(Challenges.NO_SUPPORT, 3); super(Challenges.NO_SUPPORT, 3);
} }
override applyPartyHeal(): boolean { override applyPartyHeal(status: BooleanHolder): boolean {
return this.value === 2; if (status.value) {
status.value = this.value === 2;
return true;
}
return false;
} }
override applyShop(): boolean { override applyShop(status: BooleanHolder): boolean {
return this.value === 1; if (status.value) {
status.value = this.value === 1;
return true;
}
return false;
} }
static override loadChallenge(source: NoSupportChallenge | any): NoSupportChallenge { static override loadChallenge(source: NoSupportChallenge | any): NoSupportChallenge {
@ -964,8 +977,12 @@ export class LimitedCatchChallenge extends Challenge {
super(Challenges.LIMITED_CATCH, 1); super(Challenges.LIMITED_CATCH, 1);
} }
override applyPokemonAddToParty(pokemon: EnemyPokemon): boolean { override applyPokemonAddToParty(pokemon: EnemyPokemon, status: BooleanHolder): boolean {
return pokemon.metWave % 10 === 1; if (status.value) {
status.value = pokemon.metWave % 10 === 1;
return true;
}
return false;
} }
static override loadChallenge(source: LimitedCatchChallenge | any): LimitedCatchChallenge { static override loadChallenge(source: LimitedCatchChallenge | any): LimitedCatchChallenge {
@ -984,24 +1001,40 @@ export class PermanentFaintChallenge extends Challenge {
super(Challenges.PERMANENT_FAINT, 1); super(Challenges.PERMANENT_FAINT, 1);
} }
override applyPokemonFusion(pokemon: PlayerPokemon): boolean { override applyPokemonFusion(pokemon: PlayerPokemon, status: BooleanHolder): boolean {
return !pokemon.isFainted(); if (!status.value) {
status.value = pokemon.isFainted();
return true;
}
return false;
} }
override applyShopItem(shopItem: ModifierTypeOption | null): boolean { override applyShopItem(shopItem: ModifierTypeOption | null, status: BooleanHolder): boolean {
return shopItem?.type.group !== "revive"; if (status.value) {
status.value = shopItem?.type.group !== "revive";
return true;
}
return false;
} }
override applyWaveReward(reward: ModifierTypeOption | null): boolean { override applyWaveReward(reward: ModifierTypeOption | null, status: BooleanHolder): boolean {
return this.applyShopItem(reward); return this.applyShopItem(reward, status);
} }
override applyPokemonMove(moveId: MoveId) { override applyPokemonMove(moveId: MoveId, status: BooleanHolder) {
return moveId !== MoveId.REVIVAL_BLESSING; if (status.value) {
status.value = moveId !== MoveId.REVIVAL_BLESSING;
return true;
}
return false;
} }
override applyPreventRevive(): boolean { override applyPreventRevive(status: BooleanHolder): boolean {
return true; if (!status.value) {
status.value = true;
return true;
}
return false;
} }
static override loadChallenge(source: PermanentFaintChallenge | any): PermanentFaintChallenge { static override loadChallenge(source: PermanentFaintChallenge | any): PermanentFaintChallenge {

View File

@ -1,8 +1,10 @@
import { allMoves } from "#data/data-lists"; import { allMoves } from "#data/data-lists";
import { ChallengeType } from "#enums/challenge-type";
import type { MoveId } from "#enums/move-id"; import type { MoveId } from "#enums/move-id";
import type { Pokemon } from "#field/pokemon"; import type { Pokemon } from "#field/pokemon";
import type { Move } from "#moves/move"; 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. * 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 { isUsable(pokemon: Pokemon, ignorePp = false, ignoreRestrictionTags = false): boolean {
const move = this.getMove(); const move = this.getMove();
// TODO: Add Sky Drop's 1 turn stall // TODO: Add Sky Drop's 1 turn stall
return ( const usability = new BooleanHolder(
!(this.moveId && !ignoreRestrictionTags && pokemon.isMoveRestricted(this.moveId, pokemon)) && !move.name.endsWith(" (N)") &&
(ignorePp || this.ppUsed < this.getMovePp() || move.pp === -1) && (ignorePp || this.ppUsed < this.getMovePp() || move.pp === -1) &&
// TODO: Fix apply calls !(this.moveId && !ignoreRestrictionTags && pokemon.isMoveRestricted(this.moveId, pokemon)),
//(!pokemon.isPlayer() || applyChallenges(ChallengeType.POKEMON_MOVE, this.moveId)) &&
!move.name.endsWith(" (N)")
); );
if (usability.value && pokemon.isPlayer()) {
applyChallenges(ChallengeType.POKEMON_MOVE, move.id, usability);
}
return usability.value;
} }
getMove(): Move { getMove(): Move {

View File

@ -35,7 +35,7 @@ import type { PartyOption } from "#ui/party-ui-handler";
import { PartyUiMode } from "#ui/party-ui-handler"; import { PartyUiMode } from "#ui/party-ui-handler";
import { SummaryUiMode } from "#ui/summary-ui-handler"; import { SummaryUiMode } from "#ui/summary-ui-handler";
import { applyChallenges } from "#utils/challenge-utils"; 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 { getPokemonSpecies } from "#utils/pokemon-utils";
import i18next from "i18next"; import i18next from "i18next";
@ -709,7 +709,9 @@ export async function catchPokemon(
}; };
Promise.all([pokemon.hideInfo(), globalScene.gameData.setPokemonCaught(pokemon)]).then(() => { Promise.all([pokemon.hideInfo(), globalScene.gameData.setPokemonCaught(pokemon)]).then(() => {
// TODO: Address ME edge cases (Safari Zone, etc.) // 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(); removePokemon();
end(); end();
return; return;

View File

@ -14,7 +14,7 @@ import { SpeciesId } from "#enums/species-id";
import type { Arena } from "#field/arena"; import type { Arena } from "#field/arena";
import { classicFixedBattles, type FixedBattleConfigs } from "#trainers/fixed-battle-configs"; import { classicFixedBattles, type FixedBattleConfigs } from "#trainers/fixed-battle-configs";
import { applyChallenges } from "#utils/challenge-utils"; 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"; import i18next from "i18next";
interface GameModeConfig { interface GameModeConfig {
@ -315,8 +315,10 @@ export class GameMode implements GameModeConfig {
* Checks if the game mode has the shop enabled or not * Checks if the game mode has the shop enabled or not
* @returns Whether the shop is available or not * @returns Whether the shop is available or not
*/ */
getShopAvailability(): boolean { getShopStatus(): boolean {
return !this.hasNoShop && this.modeId === GameModes.CHALLENGE && applyChallenges(ChallengeType.SHOP); const status = new BooleanHolder(!this.hasNoShop);
applyChallenges(ChallengeType.SHOP, status);
return status.value;
} }
getClearScoreBonus(): number { getClearScoreBonus(): number {

View File

@ -118,7 +118,15 @@ import type { PokemonMoveSelectFilter, PokemonSelectFilter } from "#ui/party-ui-
import { PartyUiHandler } from "#ui/party-ui-handler"; import { PartyUiHandler } from "#ui/party-ui-handler";
import { getModifierTierTextTint } from "#ui/text"; import { getModifierTierTextTint } from "#ui/text";
import { applyChallenges } from "#utils/challenge-utils"; 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 { getEnumKeys, getEnumValues } from "#utils/enums";
import { getModifierPoolForType, getModifierType } from "#utils/modifier-utils"; import { getModifierPoolForType, getModifierType } from "#utils/modifier-utils";
import i18next from "i18next"; import i18next from "i18next";
@ -535,7 +543,9 @@ export class PokemonReviveModifierType extends PokemonHpRestoreModifierType {
); );
this.selectFilter = (pokemon: PlayerPokemon) => { 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 PartyUiHandler.NoEffectMessage;
} }
return null; return null;
@ -1265,7 +1275,9 @@ export class FusePokemonModifierType extends PokemonModifierType {
iconImage, iconImage,
(_type, args) => new FusePokemonModifier(this, (args[0] as PlayerPokemon).id, (args[1] as PlayerPokemon).id), (_type, args) => new FusePokemonModifier(this, (args[0] as PlayerPokemon).id, (args[1] as PlayerPokemon).id),
(pokemon: PlayerPokemon) => { (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 PartyUiHandler.NoEffectMessage;
} }
return null; return null;
@ -2577,14 +2589,15 @@ function getModifierTypeOptionWithRetry(
): ModifierTypeOption { ): ModifierTypeOption {
allowLuckUpgrades = allowLuckUpgrades ?? true; allowLuckUpgrades = allowLuckUpgrades ?? true;
let candidate = getNewModifierTypeOption(party, ModifierPoolType.PLAYER, tier, undefined, 0, allowLuckUpgrades); 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; let r = 0;
while ( while (
(existingOptions.length && (existingOptions.length &&
++r < retryCount && ++r < retryCount &&
existingOptions.filter(o => o.type.name === candidate?.type.name || o.type.group === candidate?.type.group) existingOptions.filter(o => o.type.name === candidate?.type.name || o.type.group === candidate?.type.group)
.length) || .length) ||
!candidateValidity !candidateValidity.value
) { ) {
candidate = getNewModifierTypeOption( candidate = getNewModifierTypeOption(
party, party,
@ -2594,7 +2607,7 @@ function getModifierTypeOptionWithRetry(
0, 0,
allowLuckUpgrades, allowLuckUpgrades,
); );
candidateValidity = applyChallenges(ChallengeType.WAVE_REWARD, candidate); applyChallenges(ChallengeType.WAVE_REWARD, candidate, candidateValidity);
} }
return candidate!; return candidate!;
} }
@ -2659,7 +2672,11 @@ export function getPlayerShopModifierTypeOptionsForWave(waveIndex: number, baseC
return options return options
.slice(0, Math.ceil(Math.max(waveIndex + 10, 0) / 30)) .slice(0, Math.ceil(Math.max(waveIndex + 10, 0) / 30))
.flat() .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( export function getEnemyBuffModifierForWave(

View File

@ -25,6 +25,7 @@ import type { PartyOption } from "#ui/party-ui-handler";
import { PartyUiMode } from "#ui/party-ui-handler"; import { PartyUiMode } from "#ui/party-ui-handler";
import { SummaryUiMode } from "#ui/summary-ui-handler"; import { SummaryUiMode } from "#ui/summary-ui-handler";
import { applyChallenges } from "#utils/challenge-utils"; import { applyChallenges } from "#utils/challenge-utils";
import { BooleanHolder } from "#utils/common";
import i18next from "i18next"; import i18next from "i18next";
// TODO: Refactor and split up to allow for overriding capture chance // 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(() => { 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(); removePokemon();
end(); end();
return; return;

View File

@ -23,6 +23,7 @@ import { getMoveTargets } from "#moves/move-utils";
import { FieldPhase } from "#phases/field-phase"; import { FieldPhase } from "#phases/field-phase";
import type { TurnMove } from "#types/turn-move"; import type { TurnMove } from "#types/turn-move";
import { applyChallenges } from "#utils/challenge-utils"; import { applyChallenges } from "#utils/challenge-utils";
import { BooleanHolder } from "#utils/common";
import i18next from "i18next"; import i18next from "i18next";
export class CommandPhase extends FieldPhase { 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 // Set the translation key for why the move cannot be selected
let cannotSelectKey: string; let cannotSelectKey: string;
if (user.isMoveRestricted(move.moveId, user)) { const moveStatus = new BooleanHolder(true);
cannotSelectKey = user.getRestrictingTag(move.moveId, user)!.selectionDeniedText(user, move.moveId); applyChallenges(ChallengeType.POKEMON_MOVE, move.moveId, moveStatus);
if (!moveStatus.value) {
cannotSelectKey = "battle:moveCannotUseChallenge";
} else if (move.getPpRatio() === 0) { } else if (move.getPpRatio() === 0) {
cannotSelectKey = "battle:moveNoPP"; cannotSelectKey = "battle:moveNoPP";
} else if (!applyChallenges(ChallengeType.POKEMON_MOVE, move.moveId)) {
cannotSelectKey = "battle:moveCannotUseChallenge";
} else if (move.getName().endsWith(" (N)")) { } else if (move.getName().endsWith(" (N)")) {
cannotSelectKey = "battle:moveNotImplemented"; cannotSelectKey = "battle:moveNotImplemented";
} else if (user.isMoveRestricted(move.moveId, user)) {
cannotSelectKey = user.getRestrictingTag(move.moveId, user)!.selectionDeniedText(user, move.moveId);
} else { } else {
// TODO: Consider a message that signals a being unusable for an unknown reason // TODO: Consider a message that signals a being unusable for an unknown reason
cannotSelectKey = ""; cannotSelectKey = "";

View File

@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene";
import { ChallengeType } from "#enums/challenge-type"; import { ChallengeType } from "#enums/challenge-type";
import { BattlePhase } from "#phases/battle-phase"; import { BattlePhase } from "#phases/battle-phase";
import { applyChallenges } from "#utils/challenge-utils"; import { applyChallenges } from "#utils/challenge-utils";
import { fixedInt } from "#utils/common"; import { BooleanHolder, fixedInt } from "#utils/common";
export class PartyHealPhase extends BattlePhase { export class PartyHealPhase extends BattlePhase {
public readonly phaseName = "PartyHealPhase"; public readonly phaseName = "PartyHealPhase";
@ -22,9 +22,10 @@ export class PartyHealPhase extends BattlePhase {
globalScene.fadeOutBgm(1000, false); globalScene.fadeOutBgm(1000, false);
} }
globalScene.ui.fadeOut(1000).then(() => { 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()) { for (const pokemon of globalScene.getPlayerParty()) {
if (!(pokemon.isFainted() && preventRevive)) { if (!(pokemon.isFainted() && preventRevive.value)) {
pokemon.hp = pokemon.getMaxHp(); pokemon.hp = pokemon.getMaxHp();
pokemon.resetStatus(true, false, false, true); pokemon.resetStatus(true, false, false, true);
for (const move of pokemon.moveset) { for (const move of pokemon.moveset) {

View File

@ -7,7 +7,7 @@ import { MapModifier, MoneyInterestModifier } from "#modifiers/modifier";
import { BattlePhase } from "#phases/battle-phase"; import { BattlePhase } from "#phases/battle-phase";
import type { OptionSelectItem } from "#ui/abstact-option-select-ui-handler"; import type { OptionSelectItem } from "#ui/abstact-option-select-ui-handler";
import { applyChallenges } from "#utils/challenge-utils"; import { applyChallenges } from "#utils/challenge-utils";
import { randSeedInt } from "#utils/common"; import { BooleanHolder, randSeedInt } from "#utils/common";
export class SelectBiomePhase extends BattlePhase { export class SelectBiomePhase extends BattlePhase {
public readonly phaseName = "SelectBiomePhase"; public readonly phaseName = "SelectBiomePhase";
@ -22,7 +22,9 @@ export class SelectBiomePhase extends BattlePhase {
const setNextBiome = (nextBiome: BiomeId) => { const setNextBiome = (nextBiome: BiomeId) => {
if (nextWaveIndex % 10 === 1) { if (nextWaveIndex % 10 === 1) {
globalScene.applyModifiers(MoneyInterestModifier, true); 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); globalScene.phaseManager.unshiftNew("PartyHealPhase", false);
} }
} }

View File

@ -9,6 +9,7 @@ import type { CustomModifierSettings } from "#modifiers/modifier-type";
import { handleMysteryEncounterVictory } from "#mystery-encounters/encounter-phase-utils"; import { handleMysteryEncounterVictory } from "#mystery-encounters/encounter-phase-utils";
import { PokemonPhase } from "#phases/pokemon-phase"; import { PokemonPhase } from "#phases/pokemon-phase";
import { applyChallenges } from "#utils/challenge-utils"; import { applyChallenges } from "#utils/challenge-utils";
import { BooleanHolder } from "#utils/common";
export class VictoryPhase extends PokemonPhase { export class VictoryPhase extends PokemonPhase {
public readonly phaseName = "VictoryPhase"; public readonly phaseName = "VictoryPhase";
@ -65,7 +66,9 @@ export class VictoryPhase extends PokemonPhase {
break; 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( globalScene.phaseManager.pushNew(
"SelectModifierPhase", "SelectModifierPhase",
undefined, undefined,

View File

@ -209,7 +209,7 @@ export class ModifierSelectUiHandler extends AwaitableUiHandler {
this.updateRerollCostText(); this.updateRerollCostText();
const typeOptions = args[1] as ModifierTypeOption[]; const typeOptions = args[1] as ModifierTypeOption[];
const hasShop = globalScene.gameMode.getShopAvailability(); const hasShop = globalScene.gameMode.getShopStatus();
const baseShopCost = new NumberHolder(globalScene.getWaveMoneyAmount(1)); const baseShopCost = new NumberHolder(globalScene.getWaveMoneyAmount(1));
globalScene.applyModifier(HealShopCostModifier, true, baseShopCost); globalScene.applyModifier(HealShopCostModifier, true, baseShopCost);
const shopTypeOptions = hasShop const shopTypeOptions = hasShop

View File

@ -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 * Apply all challenges that conditionally enable or disable automatic party healing during biome transitions
* @param challengeType - {@linkcode ChallengeType.PARTY_HEAL} * @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 * 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 * 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 challengeType - {@linkcode ChallengeType.POKEMON_ADD_TO_PARTY}
* @param pokemon - The pokemon being caught * @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 * Apply all challenges that validate whether a pokemon is allowed to fuse or not
* @param challengeType - {@linkcode ChallengeType.POKEMON_FUSION} * @param challengeType - {@linkcode ChallengeType.POKEMON_FUSION}
* @param pokemon - The pokemon being checked * @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 * Apply all challenges that validate whether particular moves can or cannot be used
* @param challengeType - {@linkcode ChallengeType.POKEMON_MOVE} * @param challengeType - {@linkcode ChallengeType.POKEMON_MOVE}
* @param moveId - The move being checked * @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 * Apply all challenges that validate whether particular items are or are not sold in the shop
* @param challengeType - {@linkcode ChallengeType.SHOP_ITEM} * @param challengeType - {@linkcode ChallengeType.SHOP_ITEM}
* @param shopItem - The item being checked * @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 * Apply all challenges that validate whether particular items will be given as a reward after a wave
* @param challengeType - {@linkcode ChallengeType.WAVE_REWARD} * @param challengeType - {@linkcode ChallengeType.WAVE_REWARD}
* @param reward - The reward being checked * @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 * Apply all challenges that prevent recovery from fainting
* @param challengeType - {@linkcode ChallengeType.PREVENT_REVIVE} * @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 { export function applyChallenges(challengeType: ChallengeType, ...args: any[]): boolean {
let ret = false; let ret = false;
@ -273,28 +302,28 @@ export function applyChallenges(challengeType: ChallengeType, ...args: any[]): b
ret ||= c.applyFlipStat(args[0], args[1]); ret ||= c.applyFlipStat(args[0], args[1]);
break; break;
case ChallengeType.PARTY_HEAL: case ChallengeType.PARTY_HEAL:
ret ||= c.applyPartyHeal(); ret ||= c.applyPartyHeal(args[0]);
break; break;
case ChallengeType.SHOP: case ChallengeType.SHOP:
ret ||= c.applyShop(); ret ||= c.applyShop(args[0]);
break; break;
case ChallengeType.POKEMON_ADD_TO_PARTY: case ChallengeType.POKEMON_ADD_TO_PARTY:
ret ||= c.applyPokemonAddToParty(args[0]); ret ||= c.applyPokemonAddToParty(args[0], args[1]);
break; break;
case ChallengeType.POKEMON_FUSION: case ChallengeType.POKEMON_FUSION:
ret ||= c.applyPokemonFusion(args[0]); ret ||= c.applyPokemonFusion(args[0], args[1]);
break; break;
case ChallengeType.POKEMON_MOVE: case ChallengeType.POKEMON_MOVE:
ret ||= c.applyPokemonMove(args[0]); ret ||= c.applyPokemonMove(args[0], args[1]);
break; break;
case ChallengeType.SHOP_ITEM: case ChallengeType.SHOP_ITEM:
ret ||= c.applyShopItem(args[0]); ret ||= c.applyShopItem(args[0], args[1]);
break; break;
case ChallengeType.WAVE_REWARD: case ChallengeType.WAVE_REWARD:
ret ||= c.applyWaveReward(args[0]); ret ||= c.applyWaveReward(args[0], args[1]);
break; break;
case ChallengeType.PREVENT_REVIVE: case ChallengeType.PREVENT_REVIVE:
ret ||= c.applyPreventRevive(); ret ||= c.applyPreventRevive(args[0]);
break; break;
} }
} }