mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-16 21:32:18 +02:00
refactor executed code while importing and initializing all of these in loading-scene
This commit is contained in:
parent
0914fd14e2
commit
cb780d7d69
@ -192,11 +192,6 @@ export default class BattleScene extends SceneBase {
|
||||
|
||||
constructor() {
|
||||
super('battle');
|
||||
|
||||
initSpecies();
|
||||
initMoves();
|
||||
initAbilities();
|
||||
|
||||
this.phaseQueue = [];
|
||||
this.phaseQueuePrepend = [];
|
||||
this.phaseQueuePrependSpliceIndex = -1;
|
||||
|
@ -5,7 +5,7 @@ import beautify from 'json-beautify';
|
||||
import { TrainerType } from "./enums/trainer-type";
|
||||
import { TimeOfDay } from "./enums/time-of-day";
|
||||
import { Biome } from "./enums/biome";
|
||||
import { SpeciesFormEvolution } from "./pokemon-evolutions";
|
||||
import {initPokemonPrevolutions, pokemonEvolutions, SpeciesFormEvolution} from "./pokemon-evolutions";
|
||||
|
||||
export function getBiomeName(biome: Biome | -1) {
|
||||
if (biome === -1)
|
||||
@ -2011,7 +2011,7 @@ export const biomeTrainerPools: BiomeTrainerPools = {
|
||||
}
|
||||
};
|
||||
|
||||
{
|
||||
export function initBiomes() {
|
||||
const pokemonBiomes = [
|
||||
[ Species.BULBASAUR, Type.GRASS, Type.POISON, [
|
||||
[ Biome.GRASS, BiomePoolTier.RARE ]
|
||||
@ -7676,8 +7676,6 @@ export const biomeTrainerPools: BiomeTrainerPools = {
|
||||
traverseBiome(Biome.TOWN, 0);
|
||||
biomeDepths[Biome.END] = [ Object.values(biomeDepths).map(d => d[0]).reduce((max: integer, value: integer) => Math.max(max, value), 0) + 1, 1 ];
|
||||
|
||||
import('./pokemon-evolutions').then(pe => {
|
||||
const pokemonEvolutions = pe.pokemonEvolutions;
|
||||
for (let biome of Utils.getEnumValues(Biome)) {
|
||||
biomePokemonPools[biome] = {};
|
||||
biomeTrainerPools[biome] = {};
|
||||
@ -7695,6 +7693,8 @@ export const biomeTrainerPools: BiomeTrainerPools = {
|
||||
const speciesId = pb[0] as Species;
|
||||
const biomeEntries = pb[3] as (Biome | BiomePoolTier)[][];
|
||||
|
||||
if (!pokemonEvolutions) initPokemonPrevolutions();
|
||||
|
||||
const speciesEvolutions: SpeciesFormEvolution[] = pokemonEvolutions.hasOwnProperty(speciesId)
|
||||
? pokemonEvolutions[speciesId]
|
||||
: [];
|
||||
@ -7791,8 +7791,6 @@ export const biomeTrainerPools: BiomeTrainerPools = {
|
||||
}
|
||||
}
|
||||
|
||||
//outputPools();
|
||||
});
|
||||
|
||||
function outputPools() {
|
||||
const pokemonOutput = {};
|
||||
|
@ -606,9 +606,12 @@ function parseEggMoves(content: string): void {
|
||||
console.log(output);
|
||||
}
|
||||
|
||||
|
||||
export function initEggMoves() {
|
||||
const eggMovesStr = ``;
|
||||
if (eggMovesStr) {
|
||||
setTimeout(() => {
|
||||
parseEggMoves(eggMovesStr);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
@ -1618,7 +1618,7 @@ interface PokemonPrevolutions {
|
||||
|
||||
export const pokemonPrevolutions: PokemonPrevolutions = {};
|
||||
|
||||
{
|
||||
export function initPokemonPrevolutions(): void {
|
||||
const megaFormKeys = [ SpeciesFormKey.MEGA, '', SpeciesFormKey.MEGA_X, '', SpeciesFormKey.MEGA_Y ].map(sfk => sfk as string);
|
||||
const prevolutionKeys = Object.keys(pokemonEvolutions);
|
||||
prevolutionKeys.forEach(pk => {
|
||||
|
@ -715,7 +715,7 @@ export const pokemonFormChanges: PokemonFormChanges = {
|
||||
]
|
||||
};
|
||||
|
||||
{
|
||||
export function initPokemonForms() {
|
||||
const formChangeKeys = Object.keys(pokemonFormChanges);
|
||||
formChangeKeys.forEach(pk => {
|
||||
const formChanges = pokemonFormChanges[pk];
|
||||
|
@ -3751,23 +3751,3 @@ export const starterPassiveAbilities = {
|
||||
[Species.PALDEA_WOOPER]: Abilities.THICK_FAT,
|
||||
[Species.BLOODMOON_URSALUNA]: Abilities.BERSERK
|
||||
};
|
||||
|
||||
// TODO: Remove
|
||||
{
|
||||
//setTimeout(() => {
|
||||
/*for (let tc of Object.keys(trainerConfigs)) {
|
||||
console.log(TrainerType[tc], !trainerConfigs[tc].speciesFilter ? 'all' : [...new Set(allSpecies.filter(s => s.generation <= 9).filter(trainerConfigs[tc].speciesFilter).map(s => {
|
||||
while (pokemonPrevolutions.hasOwnProperty(s.speciesId))
|
||||
s = getPokemonSpecies(pokemonPrevolutions[s.speciesId]);
|
||||
return s;
|
||||
}))].map(s => s.name));
|
||||
}
|
||||
|
||||
const speciesFilter = (species: PokemonSpecies) => !species.legendary && !species.pseudoLegendary && !species.mythical && species.baseTotal >= 540;
|
||||
console.log(!speciesFilter ? 'all' : [...new Set(allSpecies.filter(s => s.generation <= 9).filter(speciesFilter).map(s => {
|
||||
while (pokemonPrevolutions.hasOwnProperty(s.speciesId))
|
||||
s = getPokemonSpecies(pokemonPrevolutions[s.speciesId]);
|
||||
return s;
|
||||
}))].map(s => s.name));*/
|
||||
//}, 1000);
|
||||
}
|
||||
|
@ -1038,6 +1038,7 @@ export const trainerConfigs: TrainerConfigs = {
|
||||
}),
|
||||
};
|
||||
|
||||
(function () {
|
||||
|
||||
export function initTrainerTypeDialogue() {
|
||||
initTrainerTypeDialogue();
|
||||
})();
|
||||
}
|
||||
|
@ -9,6 +9,14 @@ import { WindowVariant, getWindowVariantSuffix } from "./ui/ui-theme";
|
||||
import { isMobile } from "./touch-controls";
|
||||
import * as Utils from "./utils";
|
||||
import { initI18n } from "./plugins/i18n";
|
||||
import {initStatsKeys} from "#app/ui/game-stats-ui-handler";
|
||||
import {initPokemonPrevolutions} from "#app/data/pokemon-evolutions";
|
||||
import {initBiomes} from "#app/data/biomes";
|
||||
import {initEggMoves} from "#app/data/egg-moves";
|
||||
import {initPokemonForms} from "#app/data/pokemon-forms";
|
||||
import {initSpecies} from "#app/data/pokemon-species";
|
||||
import {initMoves} from "#app/data/move";
|
||||
import {initAbilities} from "#app/data/ability";
|
||||
|
||||
export class LoadingScene extends SceneBase {
|
||||
constructor() {
|
||||
@ -276,6 +284,15 @@ export class LoadingScene extends SceneBase {
|
||||
this.load.plugin('rextexteditplugin', 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/dist/rextexteditplugin.min.js', true);
|
||||
|
||||
this.loadLoadingScreen();
|
||||
|
||||
initStatsKeys();
|
||||
initPokemonPrevolutions();
|
||||
initBiomes();
|
||||
initEggMoves();
|
||||
initPokemonForms();
|
||||
initSpecies();
|
||||
initMoves();
|
||||
initAbilities();
|
||||
}
|
||||
|
||||
loadLoadingScreen() {
|
||||
|
10
src/test/achievement.test.ts
Normal file
10
src/test/achievement.test.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import {beforeAll, describe, expect, it} from "vitest";
|
||||
import {initStatsKeys} from "#app/ui/game-stats-ui-handler";
|
||||
import {MoneyAchv} from "#app/system/achv";
|
||||
|
||||
describe("check some Achievement related stuff", () => {
|
||||
it ('should check Achievement creation', () => {
|
||||
const ach = new MoneyAchv("Achievement", 1000, null, 100);
|
||||
expect(ach.name).toBe("Achievement");
|
||||
});
|
||||
});
|
35
src/test/debugImports.test.ts
Normal file
35
src/test/debugImports.test.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { describe, expect, it} from "vitest";
|
||||
import {initStatsKeys} from "#app/ui/game-stats-ui-handler";
|
||||
|
||||
async function importModule() {
|
||||
try {
|
||||
initStatsKeys();
|
||||
const { PokemonMove } = await import('#app/field/pokemon');
|
||||
const { Species } = await import('#app/data/enums/species');
|
||||
return {
|
||||
PokemonMove,
|
||||
Species,
|
||||
}
|
||||
// Dynamically import the module
|
||||
} catch (error) {
|
||||
// Log the error stack trace
|
||||
console.error('Error during import:', error.stack);
|
||||
// Rethrow the error to ensure the test fails
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
describe("tests to debug the import, with trace", () => {
|
||||
it('import PokemonMove module', async () => {
|
||||
const module = await importModule();
|
||||
// Example assertion
|
||||
expect(module.PokemonMove).toBeDefined();
|
||||
});
|
||||
|
||||
it('import Species module', async () => {
|
||||
const module = await importModule();
|
||||
// Example assertion
|
||||
expect(module.Species).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
57
src/test/pokemon.test.ts
Normal file
57
src/test/pokemon.test.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import {describe, expect, it} from "vitest";
|
||||
import {getPokemonSpecies, initSpecies} from "#app/data/pokemon-species";
|
||||
import {PokemonMove} from "#app/field/pokemon";
|
||||
import {Species} from "#app/data/enums/species";
|
||||
import {Moves} from "#app/data/enums/moves";
|
||||
import PokemonData from "#app/system/pokemon-data";
|
||||
|
||||
describe("some tests related to PokemonData and Species", () => {
|
||||
it('should create a species', () => {
|
||||
const species = getPokemonSpecies(Species.MEW);
|
||||
expect(species).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should create a pokemon', () => {
|
||||
const pokemon = new PokemonData({
|
||||
species: Species.MEW,
|
||||
level: 1,
|
||||
});
|
||||
expect(pokemon).not.toBeNull();
|
||||
expect(pokemon.level).toEqual(1);
|
||||
expect(pokemon.species).toEqual(Species.MEW);
|
||||
});
|
||||
|
||||
it('should generate a moveset', () => {
|
||||
const pokemon = new PokemonData({
|
||||
species: Species.MEW,
|
||||
level: 1,
|
||||
});
|
||||
expect(pokemon.moveset[0].moveId).toBe(Moves.TACKLE);
|
||||
expect(pokemon.moveset[1].moveId).toBe(Moves.GROWL);
|
||||
});
|
||||
|
||||
it('should create an ennemypokemon', () => {
|
||||
const ennemyPokemon = new PokemonData({
|
||||
species: Species.MEWTWO,
|
||||
level: 100,
|
||||
});
|
||||
expect(ennemyPokemon).not.toBeNull();
|
||||
expect(ennemyPokemon.level).toEqual(100);
|
||||
expect(ennemyPokemon.species).toEqual(Species.MEWTWO);
|
||||
});
|
||||
|
||||
it('should create an ennemypokemon with specified moveset', () => {
|
||||
const ennemyPokemon = new PokemonData({
|
||||
species: Species.MEWTWO,
|
||||
level: 100,
|
||||
moveset: [
|
||||
new PokemonMove(Moves.ACID),
|
||||
new PokemonMove(Moves.ACROBATICS),
|
||||
new PokemonMove(Moves.FOCUS_ENERGY),
|
||||
]
|
||||
});
|
||||
expect(ennemyPokemon.moveset[0].moveId).toBe(Moves.ACID);
|
||||
expect(ennemyPokemon.moveset[1].moveId).toBe(Moves.ACROBATICS);
|
||||
expect(ennemyPokemon.moveset[2].moveId).toBe(Moves.FOCUS_ENERGY);
|
||||
});
|
||||
});
|
@ -1,2 +1,19 @@
|
||||
import "vitest-canvas-mock";
|
||||
import "#app/test/phaser.setup";
|
||||
import {initStatsKeys} from "#app/ui/game-stats-ui-handler";
|
||||
import {initPokemonPrevolutions} from "#app/data/pokemon-evolutions";
|
||||
import {initBiomes} from "#app/data/biomes";
|
||||
import {initEggMoves} from "#app/data/egg-moves";
|
||||
import {initPokemonForms} from "#app/data/pokemon-forms";
|
||||
import {initSpecies} from "#app/data/pokemon-species";
|
||||
import {initMoves} from "#app/data/move";
|
||||
import {initAbilities} from "#app/data/ability";
|
||||
|
||||
initStatsKeys();
|
||||
initPokemonPrevolutions();
|
||||
initBiomes();
|
||||
initEggMoves();
|
||||
initPokemonForms();
|
||||
initSpecies();
|
||||
initMoves();
|
||||
initAbilities();
|
@ -225,7 +225,7 @@ export default class GameStatsUiHandler extends UiHandler {
|
||||
}
|
||||
}
|
||||
|
||||
(function () {
|
||||
export function initStatsKeys() {
|
||||
const statKeys = Object.keys(displayStats);
|
||||
|
||||
for (let key of statKeys) {
|
||||
@ -251,4 +251,4 @@ export default class GameStatsUiHandler extends UiHandler {
|
||||
(displayStats[key] as DisplayStat).label = Utils.toReadableString(`${splittableKey[0].toUpperCase()}${splittableKey.slice(1)}`);
|
||||
}
|
||||
}
|
||||
})();
|
||||
}
|
@ -14,6 +14,7 @@ export default defineConfig(({ mode }) => {
|
||||
}
|
||||
},
|
||||
threads: false,
|
||||
trace: true,
|
||||
environmentOptions: {
|
||||
jsdom: {
|
||||
resources: 'usable',
|
||||
|
Loading…
Reference in New Issue
Block a user