mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-20 06:19:29 +02:00
implement pokemon.setCustomNature + nature unlock utility method(s)
This commit is contained in:
parent
a87e15dbac
commit
63e4618888
@ -138,7 +138,7 @@ export const ShadyVitaminDealerEncounter: MysteryEncounter =
|
||||
newNature = randSeedInt(25) as Nature;
|
||||
}
|
||||
|
||||
chosenPokemon.customPokemonData.nature = newNature;
|
||||
chosenPokemon.setCustomNature(newNature);
|
||||
encounter.setDialogueToken("newNature", getNatureName(newNature));
|
||||
queueEncounterMessage(scene, `${namespace}:cheap_side_effects`);
|
||||
setEncounterExp(scene, [ chosenPokemon.id ], 100);
|
||||
|
@ -225,9 +225,8 @@ export const TrainingSessionEncounter: MysteryEncounter =
|
||||
const onBeforeRewardsPhase = () => {
|
||||
queueEncounterMessage(scene, `${namespace}:option.2.finished`);
|
||||
// Add the pokemon back to party with Nature change
|
||||
playerPokemon.setNature(encounter.misc.chosenNature);
|
||||
playerPokemon.customPokemonData.nature = encounter.misc.chosenNature;
|
||||
scene.gameData.setPokemonCaught(playerPokemon, false);
|
||||
playerPokemon.setCustomNature(encounter.misc.chosenNature);
|
||||
scene.gameData.unlockSpeciesNature(playerPokemon.species, encounter.misc.chosenNature);
|
||||
|
||||
// Add pokemon and modifiers back
|
||||
scene.getPlayerParty().push(playerPokemon);
|
||||
|
@ -1067,6 +1067,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
this.calculateStats();
|
||||
}
|
||||
|
||||
setCustomNature(nature: Nature): void {
|
||||
this.customPokemonData.nature = nature;
|
||||
this.calculateStats();
|
||||
}
|
||||
|
||||
generateNature(naturePool?: Nature[]): void {
|
||||
if (naturePool === undefined) {
|
||||
naturePool = Utils.getEnumValues(Nature);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type BattleScene from "#app/battle-scene";
|
||||
import { FusionSpeciesFormEvolution, pokemonEvolutions, pokemonPrevolutions } from "#app/data/balance/pokemon-evolutions";
|
||||
import { FusionSpeciesFormEvolution, pokemonEvolutions } from "#app/data/balance/pokemon-evolutions";
|
||||
import { getBerryEffectFunc, getBerryPredicate } from "#app/data/berry";
|
||||
import { getLevelTotalExp } from "#app/data/exp";
|
||||
import { allMoves } from "#app/data/move";
|
||||
@ -2189,14 +2189,8 @@ export class PokemonNatureChangeModifier extends ConsumablePokemonModifier {
|
||||
* @returns
|
||||
*/
|
||||
override apply(playerPokemon: PlayerPokemon): boolean {
|
||||
playerPokemon.customPokemonData.nature = this.nature;
|
||||
let speciesId = playerPokemon.species.speciesId;
|
||||
playerPokemon.scene.gameData.dexData[speciesId].natureAttr |= 1 << (this.nature + 1);
|
||||
|
||||
while (pokemonPrevolutions.hasOwnProperty(speciesId)) {
|
||||
speciesId = pokemonPrevolutions[speciesId];
|
||||
playerPokemon.scene.gameData.dexData[speciesId].natureAttr |= 1 << (this.nature + 1);
|
||||
}
|
||||
playerPokemon.setCustomNature(this.nature);
|
||||
playerPokemon.scene.gameData.unlockSpeciesNature(playerPokemon.species, this.nature);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1791,6 +1791,35 @@ export class GameData {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {PokemonSpecies} species
|
||||
* @returns {boolean} whether root species has been unlocked for given {@linkcode PokemonSpecies}
|
||||
*/
|
||||
isRootSpeciesUnlocked(species: PokemonSpecies): boolean {
|
||||
return !!this.dexData[species.getRootSpeciesId()]?.caughtAttr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlocks nature for a given {@linkcode PokemonSpecies} and its prevolutions.
|
||||
* Will fail silently if root species has not been unlocked
|
||||
* @param {PokemonSpecies} species
|
||||
* @param {Nature} nature
|
||||
*/
|
||||
unlockSpeciesNature(species: PokemonSpecies, nature: Nature): void {
|
||||
if (!this.isRootSpeciesUnlocked(species)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//recursively unlock nature for species and prevolutions
|
||||
const _unlockSpeciesNature = (speciesId: Species) => {
|
||||
this.dexData[speciesId].natureAttr |= 1 << (nature + 1);
|
||||
if (pokemonPrevolutions.hasOwnProperty(speciesId)) {
|
||||
_unlockSpeciesNature(pokemonPrevolutions[speciesId]);
|
||||
}
|
||||
};
|
||||
_unlockSpeciesNature(species.speciesId);
|
||||
}
|
||||
|
||||
updateSpeciesDexIvs(speciesId: Species, ivs: integer[]): void {
|
||||
let dexEntry: DexEntry;
|
||||
do {
|
||||
|
Loading…
Reference in New Issue
Block a user