account for undefined egg moves
This commit is contained in:
parent
219215f54c
commit
d52f691d43
|
@ -25,7 +25,6 @@ import { getEncounterText, showEncounterText } from "#app/data/mystery-encounter
|
|||
import { trainerNamePools } from "#app/data/trainer-names";
|
||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
|
||||
import { addPokemonDataToDexAndValidateAchievements } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
|
||||
import { Moves } from "#enums/moves";
|
||||
|
||||
/** the i18n namespace for the encounter */
|
||||
const namespace = "mysteryEncounter:globalTradeSystem";
|
||||
|
@ -258,11 +257,8 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
|||
|
||||
// If Pokemon is still not shiny or with HA, give the Pokemon a random Common egg move in its moveset
|
||||
if (!tradePokemon.shiny && (!tradePokemon.species.abilityHidden || tradePokemon.abilityIndex < hiddenIndex)) {
|
||||
const eggMoves: Moves[] = tradePokemon.getEggMoves();
|
||||
|
||||
const eggMoves = tradePokemon.getEggMoves();
|
||||
if (eggMoves) {
|
||||
|
||||
}
|
||||
// Cannot gen the rare egg move, only 1 of the first 3 common moves
|
||||
const eggMove = eggMoves[randSeedInt(3)];
|
||||
if (!tradePokemon.moveset.some(m => m?.moveId === eggMove)) {
|
||||
|
@ -274,6 +270,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
encounter.setDialogueToken("tradedPokemon", pokemon.getNameToRender());
|
||||
encounter.setDialogueToken("received", tradePokemon.getNameToRender());
|
||||
|
|
|
@ -54,7 +54,8 @@ export const UncommonBreedEncounter: MysteryEncounter =
|
|||
const pokemon = new EnemyPokemon(scene, species, level, TrainerSlot.NONE, true);
|
||||
|
||||
// Pokemon will always have one of its egg moves in its moveset
|
||||
const eggMoves: Moves[] = pokemon.getEggMoves();
|
||||
const eggMoves = pokemon.getEggMoves();
|
||||
if (eggMoves) {
|
||||
const eggMoveIndex = randSeedInt(4);
|
||||
const randomEggMove: Moves = eggMoves[eggMoveIndex];
|
||||
encounter.misc = {
|
||||
|
@ -65,6 +66,7 @@ export const UncommonBreedEncounter: MysteryEncounter =
|
|||
} else {
|
||||
pokemon.moveset[0] = new PokemonMove(randomEggMove);
|
||||
}
|
||||
}
|
||||
|
||||
encounter.misc.pokemon = pokemon;
|
||||
|
||||
|
@ -243,7 +245,8 @@ export const UncommonBreedEncounter: MysteryEncounter =
|
|||
.build();
|
||||
|
||||
function givePokemonExtraEggMove(pokemon: EnemyPokemon, previousEggMove: Moves) {
|
||||
const eggMoves: Moves[] = pokemon.getEggMoves();
|
||||
const eggMoves = pokemon.getEggMoves();
|
||||
if (eggMoves) {
|
||||
let randomEggMove: Moves = eggMoves[randSeedInt(4)];
|
||||
while (randomEggMove === previousEggMove) {
|
||||
randomEggMove = eggMoves[randSeedInt(4)];
|
||||
|
@ -254,3 +257,4 @@ function givePokemonExtraEggMove(pokemon: EnemyPokemon, previousEggMove: Moves)
|
|||
pokemon.moveset[1] = new PokemonMove(randomEggMove);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import { IntegerHolder, isNullOrUndefined, randSeedInt, randSeedShuffle } from "
|
|||
import PokemonSpecies, { allSpecies, getPokemonSpecies } from "#app/data/pokemon-species";
|
||||
import { HiddenAbilityRateBoosterModifier, PokemonFormChangeItemModifier, PokemonHeldItemModifier } from "#app/modifier/modifier";
|
||||
import { achvs } from "#app/system/achv";
|
||||
import { speciesEggMoves } from "#app/data/egg-moves";
|
||||
import { MysteryEncounterPokemonData } from "#app/data/mystery-encounters/mystery-encounter-pokemon-data";
|
||||
import { showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
|
||||
import { modifierTypes } from "#app/modifier/modifier-type";
|
||||
|
@ -22,7 +21,6 @@ import { getLevelTotalExp } from "#app/data/exp";
|
|||
import { Stat } from "#enums/stat";
|
||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
|
||||
import { Challenges } from "#enums/challenges";
|
||||
import { Moves } from "#enums/moves";
|
||||
|
||||
/** i18n namespace for encounter */
|
||||
const namespace = "mysteryEncounter:weirdDream";
|
||||
|
@ -553,8 +551,8 @@ function doSideBySideTransformations(scene: BattleScene, transformations: Pokemo
|
|||
*/
|
||||
async function addEggMoveToNewPokemonMoveset(scene: BattleScene, newPokemon: PlayerPokemon, speciesRootForm: Species): Promise<number | null> {
|
||||
let eggMoveIndex: null | number = null;
|
||||
if (speciesEggMoves.hasOwnProperty(speciesRootForm)) {
|
||||
const eggMoves: Moves[] = newPokemon.getEggMoves().slice(0);
|
||||
const eggMoves = newPokemon.getEggMoves()?.slice(0);
|
||||
if (eggMoves) {
|
||||
const eggMoveIndices = [0, 1, 2, 3];
|
||||
randSeedShuffle(eggMoveIndices);
|
||||
let randomEggMoveIndex = eggMoveIndices.pop();
|
||||
|
|
|
@ -1799,7 +1799,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
*
|
||||
* @returns list of egg moves
|
||||
*/
|
||||
getEggMoves() : Moves[] {
|
||||
getEggMoves() : Moves[] | undefined {
|
||||
return speciesEggMoves[this.getSpeciesForm().getRootSpeciesId(true)];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue