mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-28 12:32:44 +02:00
Converted Berries Abound encounter
This commit is contained in:
parent
9a79882e05
commit
51a2a15799
@ -1,7 +1,6 @@
|
|||||||
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
|
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
|
||||||
import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||||
import {
|
import {
|
||||||
generateModifierType,
|
|
||||||
generateModifierTypeOption,
|
generateModifierTypeOption,
|
||||||
getRandomEncounterSpecies,
|
getRandomEncounterSpecies,
|
||||||
initBattleWithEnemyConfig,
|
initBattleWithEnemyConfig,
|
||||||
@ -11,7 +10,7 @@ import {
|
|||||||
} from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
} from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||||
import type { PlayerPokemon } from "#app/field/pokemon";
|
import type { PlayerPokemon } from "#app/field/pokemon";
|
||||||
import type Pokemon from "#app/field/pokemon";
|
import type Pokemon from "#app/field/pokemon";
|
||||||
import type { BerryModifierType, ModifierTypeOption } from "#app/modifier/modifier-type";
|
import type { ModifierTypeOption } from "#app/modifier/modifier-type";
|
||||||
import { ModifierPoolType, modifierTypes, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type";
|
import { ModifierPoolType, modifierTypes, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type";
|
||||||
import { randSeedInt } from "#app/utils/common";
|
import { randSeedInt } from "#app/utils/common";
|
||||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||||
@ -24,18 +23,17 @@ import { getPokemonNameWithAffix } from "#app/messages";
|
|||||||
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
||||||
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
||||||
import {
|
import {
|
||||||
applyModifierTypeToPlayerPokemon,
|
|
||||||
getEncounterPokemonLevelForWave,
|
getEncounterPokemonLevelForWave,
|
||||||
getHighestStatPlayerPokemon,
|
getHighestStatPlayerPokemon,
|
||||||
getSpriteKeysFromPokemon,
|
getSpriteKeysFromPokemon,
|
||||||
STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER,
|
STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER,
|
||||||
} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
|
} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
|
||||||
import PokemonData from "#app/system/pokemon-data";
|
import PokemonData from "#app/system/pokemon-data";
|
||||||
import { BerryModifier } from "#app/modifier/modifier";
|
|
||||||
import i18next from "#app/plugins/i18n";
|
import i18next from "#app/plugins/i18n";
|
||||||
import { BerryType } from "#enums/berry-type";
|
import { BerryType } from "#enums/berry-type";
|
||||||
import { PERMANENT_STATS, Stat } from "#enums/stat";
|
import { PERMANENT_STATS, Stat } from "#enums/stat";
|
||||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants";
|
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants";
|
||||||
|
import { berryTypeToHeldItem } from "#app/items/held-items/berry";
|
||||||
|
|
||||||
/** the i18n namespace for the encounter */
|
/** the i18n namespace for the encounter */
|
||||||
const namespace = "mysteryEncounters/berriesAbound";
|
const namespace = "mysteryEncounters/berriesAbound";
|
||||||
@ -310,35 +308,17 @@ export const BerriesAboundEncounter: MysteryEncounter = MysteryEncounterBuilder.
|
|||||||
|
|
||||||
function tryGiveBerry(prioritizedPokemon?: PlayerPokemon) {
|
function tryGiveBerry(prioritizedPokemon?: PlayerPokemon) {
|
||||||
const berryType = randSeedInt(Object.keys(BerryType).filter(s => !Number.isNaN(Number(s))).length) as BerryType;
|
const berryType = randSeedInt(Object.keys(BerryType).filter(s => !Number.isNaN(Number(s))).length) as BerryType;
|
||||||
const berry = generateModifierType(modifierTypes.BERRY, [berryType]) as BerryModifierType;
|
const berry = berryTypeToHeldItem[berryType];
|
||||||
|
|
||||||
const party = globalScene.getPlayerParty();
|
const party = globalScene.getPlayerParty();
|
||||||
|
|
||||||
// Will try to apply to prioritized pokemon first, then do normal application method if it fails
|
// Will give the berry to a Pokemon, starting from the prioritized one
|
||||||
if (prioritizedPokemon) {
|
if (prioritizedPokemon?.heldItemManager.add(berry)) {
|
||||||
const heldBerriesOfType = globalScene.findModifier(
|
|
||||||
m =>
|
|
||||||
m instanceof BerryModifier &&
|
|
||||||
m.pokemonId === prioritizedPokemon.id &&
|
|
||||||
(m as BerryModifier).berryType === berryType,
|
|
||||||
true,
|
|
||||||
) as BerryModifier;
|
|
||||||
|
|
||||||
if (!heldBerriesOfType || heldBerriesOfType.getStackCount() < heldBerriesOfType.getMaxStackCount()) {
|
|
||||||
applyModifierTypeToPlayerPokemon(prioritizedPokemon, berry);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Iterate over the party until berry was successfully given
|
|
||||||
for (const pokemon of party) {
|
for (const pokemon of party) {
|
||||||
const heldBerriesOfType = globalScene.findModifier(
|
if (pokemon.heldItemManager.add(berry)) {
|
||||||
m => m instanceof BerryModifier && m.pokemonId === pokemon.id && (m as BerryModifier).berryType === berryType,
|
|
||||||
true,
|
|
||||||
) as BerryModifier;
|
|
||||||
|
|
||||||
if (!heldBerriesOfType || heldBerriesOfType.getStackCount() < heldBerriesOfType.getMaxStackCount()) {
|
|
||||||
applyModifierTypeToPlayerPokemon(pokemon, berry);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user