Add egg moves logic

This commit is contained in:
Flashfyre committed 2024-02-25 12:45:41 -05:00
1 parent 7f77507d2b
commit 649717a3cd
7 files changed
+151 -16

No files matched your search

+16 -2
View File
@@ -7,7 +7,8 @@ import { Type } from './type';
import { LevelMoves, pokemonFormLevelMoves, pokemonFormLevelMoves as pokemonSpeciesFormLevelMoves, pokemonSpeciesLevelMoves } from './pokemon-level-moves';
import { uncatchableSpecies } from './biomes';
import * as Utils from '../utils';
import { StarterMoveset } from '../system/game-data';
import { StarterEggMoveData, StarterMoveset } from '../system/game-data';
import { speciesEggMoves } from './egg-moves';
export enum Region {
NORMAL,
@@ -98,6 +99,13 @@ export abstract class PokemonSpeciesForm {
this.genderDiffs = genderDiffs;
}
getRootSpeciesId(): Species {
let ret = this.speciesId;
while (pokemonPrevolutions.hasOwnProperty(ret))
ret = pokemonPrevolutions[ret];
return ret;
}
isOfType(type: integer): boolean {
return this.type1 === type || (this.type2 !== null && this.type2 === type);
}
@@ -261,8 +269,14 @@ export abstract class PokemonSpeciesForm {
return ret;
}
validateStarterMoveset(moveset: StarterMoveset): boolean {
validateStarterMoveset(moveset: StarterMoveset, eggMoves: integer): boolean {
const rootSpeciesId = this.getRootSpeciesId();
for (let moveId of moveset) {
if (speciesEggMoves.hasOwnProperty(rootSpeciesId)) {
const eggMoveIndex = speciesEggMoves[rootSpeciesId].findIndex(m => m === moveId);
if (eggMoveIndex > -1 && eggMoves & Math.pow(2, eggMoveIndex))
continue;
}
if (pokemonFormLevelMoves.hasOwnProperty(this.speciesId) && pokemonFormLevelMoves[this.speciesId].hasOwnProperty(this.formIndex)) {
if (!pokemonFormLevelMoves[this.speciesId][this.formIndex].find(lm => lm[0] <= 5 && lm[1] === moveId))
return false;