Prevent fainted pokemon from being spliced in hardcore

This commit is contained in:
NightKev 2024-10-24 01:45:35 -07:00
parent df73978bb4
commit 4de5572b0e
2 changed files with 32 additions and 20 deletions

View File

@ -1,22 +1,22 @@
import { BattleType, FixedBattleConfig } from "#app/battle";
import { pokemonEvolutions } from "#app/data/balance/pokemon-evolutions";
import { speciesStarterCosts } from "#app/data/balance/starters";
import { Nature } from "#app/data/nature";
import { pokemonFormChanges } from "#app/data/pokemon-forms";
import { BooleanHolder, NumberHolder, randSeedItem } from "#app/utils";
import i18next from "i18next";
import { defaultStarterSpecies, DexAttrProps, GameData } from "#app/system/game-data";
import PokemonSpecies, { getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species";
import { Type } from "#app/data/type";
import Pokemon, { EnemyPokemon, PlayerPokemon, PokemonMove } from "#app/field/pokemon";
import { speciesStarterCosts } from "#app/data/balance/starters";
import Pokemon, { type EnemyPokemon, PokemonMove, type PlayerPokemon } from "#app/field/pokemon";
import { BattleType, FixedBattleConfig } from "#app/battle";
import Trainer, { TrainerVariant } from "#app/field/trainer";
import { GameMode } from "#app/game-mode";
import { ModifierTypeOption } from "#app/modifier/modifier-type";
import { defaultStarterSpecies, DexAttrProps, GameData } from "#app/system/game-data";
import { BooleanHolder, NumberHolder, randSeedItem } from "#app/utils";
import { Type } from "#app/data/type";
import { Challenges } from "#enums/challenges";
import { TypeColor, TypeShadow } from "#enums/color";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { TrainerType } from "#enums/trainer-type";
import i18next from "i18next";
import { Nature } from "#app/data/nature";
import { Moves } from "#enums/moves";
import { TypeColor, TypeShadow } from "#enums/color";
import { pokemonEvolutions } from "#app/data/balance/pokemon-evolutions";
import { pokemonFormChanges } from "#app/data/pokemon-forms";
import type { ModifierTypeOption } from "#app/modifier/modifier-type";
/** A constant for the default max cost of the starting party before a run */
const DEFAULT_PARTY_MAX_COST = 10;
@ -862,12 +862,18 @@ export class NoAutomaticHealChallenge extends Challenge {
/** Challenge that removes the ability to revive fallen pokemon */
export class HardcoreChallenge extends Challenge {
private itemBlackList = [ "modifierType:ModifierType.REVIVE", "modifierType:ModifierType.MAX_REVIVE", "modifierType:ModifierType.SACRED_ASH", "modifierType:ModifierType.REVIVER_SEED" ];
private readonly itemBlackList = [ "modifierType:ModifierType.REVIVE", "modifierType:ModifierType.MAX_REVIVE", "modifierType:ModifierType.SACRED_ASH", "modifierType:ModifierType.REVIVER_SEED" ];
private readonly moveBlacklist = [ Moves.REVIVAL_BLESSING ];
constructor() {
super(Challenges.HARDCORE, 1);
}
override applyPokemonInBattle(pokemon: Pokemon, valid: BooleanHolder): boolean {
valid.value = !pokemon.isFainted();
return true;
}
override applyRandomItemBlacklist(randomItem: ModifierTypeOption | null, isValid: BooleanHolder): boolean {
if (randomItem !== null) {
isValid.value = !this.itemBlackList.includes(randomItem.type.localeKey);
@ -881,8 +887,7 @@ export class HardcoreChallenge extends Challenge {
}
override applyMoveBlacklist(move: PokemonMove, moveCanBeUsed: BooleanHolder): boolean {
const moveBlacklist = [ Moves.REVIVAL_BLESSING ];
moveCanBeUsed.value = !moveBlacklist.includes(move.moveId);
moveCanBeUsed.value = !this.moveBlacklist.includes(move.moveId);
return true;
}

View File

@ -391,12 +391,14 @@ export default class PartyUiHandler extends MessageUiHandler {
this.clearOptions();
} else {
this.clearOptions();
this.showText(filterResult as string, undefined, () => this.showText("", 0), undefined, true);
this.showText(filterResult, undefined, () => this.showText("", 0), undefined, true);
}
ui.playSelect();
return true;
} else if ((option !== PartyOption.SUMMARY && option !== PartyOption.UNPAUSE_EVOLUTION && option !== PartyOption.UNSPLICE && option !== PartyOption.RELEASE && option !== PartyOption.CANCEL && option !== PartyOption.RENAME)
|| (option === PartyOption.RELEASE && this.partyUiMode === PartyUiMode.RELEASE)) {
} else if (
![ PartyOption.SUMMARY, PartyOption.UNPAUSE_EVOLUTION, PartyOption.UNSPLICE, PartyOption.RELEASE, PartyOption.CANCEL, PartyOption.RENAME ].includes(option)
|| (option === PartyOption.RELEASE && this.partyUiMode === PartyUiMode.RELEASE)
) {
let filterResult: string | null;
const getTransferrableItemsFromPokemon = (pokemon: PlayerPokemon) =>
this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier && m.isTransferable && m.pokemonId === pokemon.id) as PokemonHeldItemModifier[];
@ -865,6 +867,11 @@ export default class PartyUiHandler extends MessageUiHandler {
this.options.push(PartyOption.TRANSFER);
break;
case PartyUiMode.SPLICE:
const isAllowedInChallenge = new Utils.BooleanHolder(true);
applyChallenges(this.scene.gameMode, ChallengeType.POKEMON_IN_BATTLE, pokemon, isAllowedInChallenge);
if (!isAllowedInChallenge.value) {
break;
}
if (this.transferMode) {
if (this.cursor !== this.transferCursor) {
this.options.push(PartyOption.SPLICE);