diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index e97f9eecd..be779d9a5 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -3030,6 +3030,21 @@ export const speciesStarters = { [Species.BLOODMOON_URSALUNA]: 7, }; +export const noStarterFormKeys: string[] = [ + SpeciesFormKey.MEGA, + SpeciesFormKey.MEGA_X, + SpeciesFormKey.MEGA_Y, + SpeciesFormKey.PRIMAL, + SpeciesFormKey.ORIGIN, + SpeciesFormKey.THERIAN, + SpeciesFormKey.GIGANTAMAX, + SpeciesFormKey.GIGANTAMAX_RAPID, + SpeciesFormKey.GIGANTAMAX_SINGLE, + SpeciesFormKey.ETERNAMAX +].map(k => k.toString()); + +console.log(noStarterFormKeys) + // TODO: Remove { //setTimeout(() => { diff --git a/src/phases.ts b/src/phases.ts index 9a100af2e..7e9ed5a85 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -55,7 +55,7 @@ import { OptionSelectConfig, OptionSelectItem } from "./ui/abstact-option-select import { SaveSlotUiMode } from "./ui/save-slot-select-ui-handler"; import { fetchDailyRunSeed, getDailyRunStarters } from "./data/daily-run"; import { GameModes, gameModes } from "./game-mode"; -import { getPokemonSpecies } from "./data/pokemon-species"; +import { getPokemonSpecies, speciesStarters } from "./data/pokemon-species"; export class LoginPhase extends Phase { private showText: boolean; @@ -1512,7 +1512,7 @@ export class CommandPhase extends FieldPhase { } break; case Command.BALL: - if (this.scene.arena.biomeType === Biome.END) { + if (this.scene.arena.biomeType === Biome.END && (!this.scene.gameMode.isClassic || this.scene.gameData.getStarterCount(d => !!d.caughtAttr) < Object.keys(speciesStarters).length - 1)) { this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex); this.scene.ui.setMode(Mode.MESSAGE); this.scene.ui.showText(`An unseen force\nprevents using Poké Balls.`, null, () => { diff --git a/src/system/game-data.ts b/src/system/game-data.ts index ded50d5a5..fbf94776e 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -1,7 +1,7 @@ import BattleScene, { PokeballCounts, bypassLogin } from "../battle-scene"; import Pokemon, { EnemyPokemon, PlayerPokemon } from "../field/pokemon"; import { pokemonPrevolutions } from "../data/pokemon-evolutions"; -import PokemonSpecies, { allSpecies, getPokemonSpecies, speciesStarters } from "../data/pokemon-species"; +import PokemonSpecies, { SpeciesFormKey, allSpecies, getPokemonSpecies, noStarterFormKeys, speciesStarters } from "../data/pokemon-species"; import { Species } from "../data/enums/species"; import * as Utils from "../utils"; import PokemonData from "./pokemon-data"; @@ -936,7 +936,12 @@ export class GameData { return new Promise(resolve => { const dexEntry = this.dexData[species.speciesId]; const caughtAttr = dexEntry.caughtAttr; - dexEntry.caughtAttr |= pokemon.getDexAttr(); + const formIndex = pokemon.formIndex; + if (noStarterFormKeys.includes(pokemon.getFormKey())) + pokemon.formIndex = 0; + const dexAttr = pokemon.getDexAttr(); + pokemon.formIndex = formIndex; + dexEntry.caughtAttr |= dexAttr; dexEntry.natureAttr |= Math.pow(2, pokemon.nature + 1); if (incrementCount) { if (!fromEgg) { @@ -1018,6 +1023,27 @@ export class GameData { } while (pokemonPrevolutions.hasOwnProperty(speciesId) && (speciesId = pokemonPrevolutions[speciesId])); } + getSpeciesCount(dexEntryPredicate: (entry: DexEntry) => boolean): integer { + const dexKeys = Object.keys(this.dexData); + let speciesCount = 0; + for (let s of dexKeys) { + if (dexEntryPredicate(this.dexData[s])) + speciesCount++; + } + return speciesCount; + } + + getStarterCount(dexEntryPredicate: (entry: DexEntry) => boolean): integer { + const starterKeys = Object.keys(speciesStarters); + let starterCount = 0; + for (let s of starterKeys) { + const starterDexEntry = this.dexData[s]; + if (dexEntryPredicate(starterDexEntry)) + starterCount++; + } + return starterCount; + } + getSpeciesDefaultDexAttr(species: PokemonSpecies, forSeen: boolean = false): bigint { let ret = 0n; const dexEntry = this.dexData[species.speciesId]; diff --git a/src/ui/game-stats-ui-handler.ts b/src/ui/game-stats-ui-handler.ts index 75ec3552c..00e358ff8 100644 --- a/src/ui/game-stats-ui-handler.ts +++ b/src/ui/game-stats-ui-handler.ts @@ -25,49 +25,29 @@ const displayStats: DisplayStats = { startersUnlocked: { label: 'Starters', sourceFunc: gameData => { - const starterKeys = Object.keys(speciesStarters); - let starterCount = 0; - for (let s of starterKeys) { - if (gameData.dexData[s].caughtAttr) - starterCount++; - } - return `${starterCount} (${Math.floor((starterCount / starterKeys.length) * 1000) / 10}%)`; + const starterCount = gameData.getStarterCount(d => !!d.caughtAttr); + return `${starterCount} (${Math.floor((starterCount / Object.keys(speciesStarters).length) * 1000) / 10}%)`; } }, shinyStartersUnlocked: { label: 'Shiny Starters', sourceFunc: gameData => { - const starterKeys = Object.keys(speciesStarters); - let starterCount = 0; - for (let s of starterKeys) { - if (gameData.dexData[s].caughtAttr & DexAttr.SHINY) - starterCount++; - } - return `${starterCount} (${Math.floor((starterCount / starterKeys.length) * 1000) / 10}%)`; + const starterCount = gameData.getStarterCount(d => !!(d.caughtAttr & DexAttr.SHINY)); + return `${starterCount} (${Math.floor((starterCount / Object.keys(speciesStarters).length) * 1000) / 10}%)`; } }, dexSeen: { label: 'Species Seen', sourceFunc: gameData => { - const dexKeys = Object.keys(gameData.dexData); - let seenCount = 0; - for (let s of dexKeys) { - if (gameData.dexData[s].seenAttr) - seenCount++; - } - return `${seenCount} (${Math.floor((seenCount / dexKeys.length) * 1000) / 10}%)`; + const seenCount = gameData.getSpeciesCount(d => !!d.seenAttr); + return `${seenCount} (${Math.floor((seenCount / Object.keys(gameData.dexData).length) * 1000) / 10}%)`; } }, dexCaught: { label: 'Species Caught', sourceFunc: gameData => { - const dexKeys = Object.keys(gameData.dexData); - let caughtCount = 0; - for (let s of dexKeys) { - if (gameData.dexData[s].caughtAttr) - caughtCount++; - } - return `${caughtCount} (${Math.floor((caughtCount / dexKeys.length) * 1000) / 10}%)`; + const caughtCount = gameData.getSpeciesCount(d => !!d.caughtAttr); + return `${caughtCount} (${Math.floor((caughtCount / Object.keys(gameData.dexData).length) * 1000) / 10}%)`; } }, classicSessionsPlayed: 'Classic Runs',