From 6d52d8e8c033e0a8c24574508572c93ebf07d15b Mon Sep 17 00:00:00 2001 From: AJ Fontaine Date: Sun, 19 May 2024 18:01:45 -0400 Subject: [PATCH] Add unlocked egg moves to relearnable moves on starters --- src/field/pokemon.ts | 4 ++++ src/modifier/modifier-type.ts | 3 ++- src/modifier/modifier.ts | 4 +++- src/system/game-data.ts | 19 ++++++++++++++++++- src/ui/party-ui-handler.ts | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 0a5e0a6a991..49d62d5fa63 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -743,6 +743,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return this.getLevelMoves(1, true).map(lm => lm[1]).filter(lm => !this.moveset.filter(m => m.moveId === lm).length).filter((move: Moves, i: integer, array: Moves[]) => array.indexOf(move) === i); } + getLearnableEggMoves(): Moves[] { + return this.metBiome < 0 ? this.scene.gameData.getUnlockedEggMoves(this.species).filter(lm => !this.moveset.filter(m => m.moveId === lm).length).filter((move: Moves, i: integer, array: Moves[]) => array.indexOf(move) === i) : []; + } + getTypes(includeTeraType = false, forDefend: boolean = false, ignoreOverride?: boolean): Type[] { const types = []; diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 278de2f18e8..bafa4081dd0 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -21,6 +21,7 @@ import { ModifierTier } from './modifier-tier'; import { Nature, getNatureName, getNatureStatMultiplier } from '#app/data/nature'; import i18next from '#app/plugins/i18n'; import { getModifierTierTextTint } from '#app/ui/text'; +import { Biome } from '#app/data/enums/biome.js'; const outputModifierData = false; const useMaxWeightForOutput = false; @@ -386,7 +387,7 @@ export class RememberMoveModifierType extends PokemonModifierType { constructor(localeKey: string, iconImage: string, group?: string) { super(localeKey, iconImage, (type, args) => new Modifiers.RememberMoveModifier(type, (args[0] as PlayerPokemon).id, (args[1] as integer)), (pokemon: PlayerPokemon) => { - if (!pokemon.getLearnableLevelMoves().length) + if (!pokemon.getLearnableLevelMoves().length && !pokemon.getLearnableEggMoves().length) return PartyUiHandler.NoEffectMessage; return null; }, group); diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 0736831a01e..485342b1d9e 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -1195,8 +1195,10 @@ export class RememberMoveModifier extends ConsumablePokemonModifier { apply(args: any[]): boolean { const pokemon = args[0] as PlayerPokemon; + const moves = pokemon.getLearnableLevelMoves(); + moves.push(...pokemon.getLearnableEggMoves()); - pokemon.scene.unshiftPhase(new LearnMovePhase(pokemon.scene, pokemon.scene.getParty().indexOf(pokemon), pokemon.getLearnableLevelMoves()[this.levelMoveIndex])); + pokemon.scene.unshiftPhase(new LearnMovePhase(pokemon.scene, pokemon.scene.getParty().indexOf(pokemon), moves[this.levelMoveIndex])); return true; } diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 2691e79be61..7056a4d43d8 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -1253,7 +1253,7 @@ export class GameData { if (!this.starterData[speciesId].eggMoves) this.starterData[speciesId].eggMoves = 0; - const value = Math.pow(2, eggMoveIndex); + const value = Math.pow(2, eggMoveIndex); if (this.starterData[speciesId].eggMoves & value) { resolve(false); @@ -1267,6 +1267,23 @@ export class GameData { }); } + /** + * @returns {Moves}[] An array of every egg move the player has unlocked for a given species + * @param species {PokemonSpecies} species to get the egg moves of + */ + getUnlockedEggMoves(species: PokemonSpecies): Moves[] { + const unlockedEggMoves=[]; + const speciesId = species.getRootSpeciesId(true); + if (speciesEggMoves.hasOwnProperty(speciesId) && this.starterData[speciesId].eggMoves){ + for (let eggMoveIndex = 0; eggMoveIndex < speciesEggMoves[speciesId].length; eggMoveIndex++){ + const value = Math.pow(2, eggMoveIndex); + if (this.starterData[speciesId].eggMoves & value) + unlockedEggMoves.push(speciesEggMoves[speciesId][eggMoveIndex]); + } + } + return unlockedEggMoves; + } + updateSpeciesDexIvs(speciesId: Species, ivs: integer[]): void { let dexEntry: DexEntry; do { diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 8b497655a17..2e96410e3e4 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -17,6 +17,7 @@ import { addWindow } from "./ui-theme"; import { SpeciesFormChangeItemTrigger } from "../data/pokemon-forms"; import { getVariantTint } from "#app/data/variant"; import {Button} from "../enums/buttons"; +import { speciesEggMoves } from "#app/data/egg-moves.js"; const defaultMessage = 'Choose a Pokémon.'; @@ -546,6 +547,8 @@ export default class PartyUiHandler extends MessageUiHandler { const learnableLevelMoves = this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER ? pokemon.getLearnableLevelMoves() : null; + if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER) // Append egg moves to relearn options on starters + learnableLevelMoves.push(...pokemon.getLearnableEggMoves()); const itemModifiers = this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER ? this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier @@ -617,6 +620,7 @@ export default class PartyUiHandler extends MessageUiHandler { this.options.push(PartyOption.MOVE_1 + m); } else if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER) { const learnableMoves = pokemon.getLearnableLevelMoves(); + learnableMoves.push(...pokemon.getLearnableEggMoves()) for (let m = 0; m < learnableMoves.length; m++) this.options.push(m); } else {