mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 08:16:04 +00:00
[Refactor] Move Daily Pokerus Start Generation to its own function in data/pokemon-species (#3501)
* Moving daily Pokerus generation to game-data * Moved pokerus starter generation to pokemon-species * Added JsDocs * Update src/data/pokemon-species.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * boo typedocs boo --------- Co-authored-by: Frutescens <info@laptop> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
parent
828897316e
commit
0cd52b86d2
@ -3317,6 +3317,28 @@ export function getStarterValueFriendshipCap(value: integer): integer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the daily list of starters with Pokerus.
|
||||
* @param scene {@linkcode BattleScene} used as part of RNG
|
||||
* @returns A list of starters with Pokerus
|
||||
*/
|
||||
export function getPokerusStarters(scene: BattleScene): PokemonSpecies[] {
|
||||
const pokerusStarters: PokemonSpecies[] = [];
|
||||
const date = new Date();
|
||||
const starterCount = 3; //for easy future adjustment!
|
||||
date.setUTCHours(0, 0, 0, 0);
|
||||
scene.executeWithSeedOffset(() => {
|
||||
while (pokerusStarters.length < starterCount) {
|
||||
const randomSpeciesId = parseInt(Utils.randSeedItem(Object.keys(speciesStarters)), 10);
|
||||
const species = getPokemonSpecies(randomSpeciesId);
|
||||
if (!pokerusStarters.includes(species)) {
|
||||
pokerusStarters.push(species);
|
||||
}
|
||||
}
|
||||
}, 0, date.getTime().toString());
|
||||
return pokerusStarters;
|
||||
}
|
||||
|
||||
export const starterPassiveAbilities = {
|
||||
[Species.BULBASAUR]: Abilities.GRASSY_SURGE,
|
||||
[Species.CHARMANDER]: Abilities.BEAST_BOOST,
|
||||
|
@ -13,7 +13,7 @@ import { allMoves } from "../data/move";
|
||||
import { Nature, getNatureName } from "../data/nature";
|
||||
import { pokemonFormChanges } from "../data/pokemon-forms";
|
||||
import { LevelMoves, pokemonFormLevelMoves, pokemonSpeciesLevelMoves } from "../data/pokemon-level-moves";
|
||||
import PokemonSpecies, { allSpecies, getPokemonSpecies, getPokemonSpeciesForm, getStarterValueFriendshipCap, speciesStarters, starterPassiveAbilities } from "../data/pokemon-species";
|
||||
import PokemonSpecies, { allSpecies, getPokemonSpeciesForm, getStarterValueFriendshipCap, speciesStarters, starterPassiveAbilities, getPokerusStarters } from "../data/pokemon-species";
|
||||
import { Type } from "../data/type";
|
||||
import { GameModes } from "../game-mode";
|
||||
import { AbilityAttr, DexAttr, DexAttrProps, DexEntry, StarterMoveset, StarterAttributes, StarterPreferences, StarterPrefs } from "../system/game-data";
|
||||
@ -872,38 +872,6 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||
this.message.setOrigin(0, 0);
|
||||
this.starterSelectMessageBoxContainer.add(this.message);
|
||||
|
||||
const date = new Date();
|
||||
date.setUTCHours(0, 0, 0, 0);
|
||||
|
||||
this.scene.executeWithSeedOffset(() => {
|
||||
for (let c = 0; c < 3; c++) {
|
||||
let randomSpeciesId: Species;
|
||||
let species: PokemonSpecies | undefined;
|
||||
|
||||
const generateSpecies = () => {
|
||||
randomSpeciesId = Utils.randSeedItem(starterSpecies);
|
||||
species = getPokemonSpecies(randomSpeciesId);
|
||||
};
|
||||
|
||||
let dupe = false;
|
||||
|
||||
do {
|
||||
dupe = false;
|
||||
|
||||
generateSpecies();
|
||||
|
||||
for (let ps = 0; ps < c; ps++) {
|
||||
if (this.pokerusSpecies[ps] === species) {
|
||||
dupe = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (dupe);
|
||||
|
||||
this.pokerusSpecies.push(species!); // TODO: is the bang correct?
|
||||
}
|
||||
}, 0, date.getTime().toString());
|
||||
|
||||
this.statsContainer = new StatsContainer(this.scene, 6, 16);
|
||||
|
||||
this.scene.add.existing(this.statsContainer);
|
||||
@ -934,6 +902,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||
this.starterPreferences = StarterPrefs.load();
|
||||
}
|
||||
this.moveInfoOverlay.clear(); // clear this when removing a menu; the cancel button doesn't seem to trigger this automatically on controllers
|
||||
this.pokerusSpecies = getPokerusStarters(this.scene);
|
||||
|
||||
if (args.length >= 1 && args[0] instanceof Function) {
|
||||
super.show(args);
|
||||
this.starterSelectCallback = args[0] as StarterSelectCallback;
|
||||
|
Loading…
Reference in New Issue
Block a user