mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 08:16:04 +00:00
refactor executed code while importing and initializing all of these in loading-scene (#1125)
This commit is contained in:
parent
a9af2bd6ff
commit
c1a7df913a
@ -2,7 +2,7 @@ import Phaser from "phaser";
|
|||||||
import UI from "./ui/ui";
|
import UI from "./ui/ui";
|
||||||
import { NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, MessagePhase, TurnInitPhase, ReturnPhase, LevelCapPhase, ShowTrainerPhase, LoginPhase, MovePhase, TitlePhase, SwitchPhase } from "./phases";
|
import { NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, MessagePhase, TurnInitPhase, ReturnPhase, LevelCapPhase, ShowTrainerPhase, LoginPhase, MovePhase, TitlePhase, SwitchPhase } from "./phases";
|
||||||
import Pokemon, { PlayerPokemon, EnemyPokemon } from "./field/pokemon";
|
import Pokemon, { PlayerPokemon, EnemyPokemon } from "./field/pokemon";
|
||||||
import PokemonSpecies, { PokemonSpeciesFilter, allSpecies, getPokemonSpecies, initSpecies } from "./data/pokemon-species";
|
import PokemonSpecies, { PokemonSpeciesFilter, allSpecies, getPokemonSpecies } from "./data/pokemon-species";
|
||||||
import * as Utils from "./utils";
|
import * as Utils from "./utils";
|
||||||
import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier, ModifierPredicate, DoubleBattleChanceBoosterModifier, FusePokemonModifier, PokemonFormChangeItemModifier, TerastallizeModifier, overrideModifiers, overrideHeldItems } from "./modifier/modifier";
|
import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier, ModifierPredicate, DoubleBattleChanceBoosterModifier, FusePokemonModifier, PokemonFormChangeItemModifier, TerastallizeModifier, overrideModifiers, overrideHeldItems } from "./modifier/modifier";
|
||||||
import { PokeballType } from "./data/pokeball";
|
import { PokeballType } from "./data/pokeball";
|
||||||
@ -15,10 +15,9 @@ import { GameData, PlayerGender } from "./system/game-data";
|
|||||||
import { TextStyle, addTextObject } from "./ui/text";
|
import { TextStyle, addTextObject } from "./ui/text";
|
||||||
import { Moves } from "./data/enums/moves";
|
import { Moves } from "./data/enums/moves";
|
||||||
import { allMoves } from "./data/move";
|
import { allMoves } from "./data/move";
|
||||||
import { initMoves } from "./data/move";
|
|
||||||
import { ModifierPoolType, getDefaultModifierTypeForTier, getEnemyModifierTypesForWave, getLuckString, getLuckTextTint, getModifierPoolForType, getPartyLuckValue } from "./modifier/modifier-type";
|
import { ModifierPoolType, getDefaultModifierTypeForTier, getEnemyModifierTypesForWave, getLuckString, getLuckTextTint, getModifierPoolForType, getPartyLuckValue } from "./modifier/modifier-type";
|
||||||
import AbilityBar from "./ui/ability-bar";
|
import AbilityBar from "./ui/ability-bar";
|
||||||
import { BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, IncrementMovePriorityAbAttr, applyAbAttrs, initAbilities } from "./data/ability";
|
import { BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, IncrementMovePriorityAbAttr, applyAbAttrs } from "./data/ability";
|
||||||
import { allAbilities } from "./data/ability";
|
import { allAbilities } from "./data/ability";
|
||||||
import Battle, { BattleType, FixedBattleConfig, fixedBattles } from "./battle";
|
import Battle, { BattleType, FixedBattleConfig, fixedBattles } from "./battle";
|
||||||
import { GameMode, GameModes, gameModes } from "./game-mode";
|
import { GameMode, GameModes, gameModes } from "./game-mode";
|
||||||
@ -187,11 +186,6 @@ export default class BattleScene extends SceneBase {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("battle");
|
super("battle");
|
||||||
|
|
||||||
initSpecies();
|
|
||||||
initMoves();
|
|
||||||
initAbilities();
|
|
||||||
|
|
||||||
this.phaseQueue = [];
|
this.phaseQueue = [];
|
||||||
this.phaseQueuePrepend = [];
|
this.phaseQueuePrepend = [];
|
||||||
this.phaseQueuePrependSpliceIndex = -1;
|
this.phaseQueuePrependSpliceIndex = -1;
|
||||||
|
@ -5,7 +5,7 @@ import beautify from "json-beautify";
|
|||||||
import { TrainerType } from "./enums/trainer-type";
|
import { TrainerType } from "./enums/trainer-type";
|
||||||
import { TimeOfDay } from "./enums/time-of-day";
|
import { TimeOfDay } from "./enums/time-of-day";
|
||||||
import { Biome } from "./enums/biome";
|
import { Biome } from "./enums/biome";
|
||||||
import { SpeciesFormEvolution } from "./pokemon-evolutions";
|
import {pokemonEvolutions, SpeciesFormEvolution} from "./pokemon-evolutions";
|
||||||
|
|
||||||
export function getBiomeName(biome: Biome | -1) {
|
export function getBiomeName(biome: Biome | -1) {
|
||||||
if (biome === -1) {
|
if (biome === -1) {
|
||||||
@ -2012,7 +2012,7 @@ export const biomeTrainerPools: BiomeTrainerPools = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
export function initBiomes() {
|
||||||
const pokemonBiomes = [
|
const pokemonBiomes = [
|
||||||
[ Species.BULBASAUR, Type.GRASS, Type.POISON, [
|
[ Species.BULBASAUR, Type.GRASS, Type.POISON, [
|
||||||
[ Biome.GRASS, BiomePoolTier.RARE ]
|
[ Biome.GRASS, BiomePoolTier.RARE ]
|
||||||
@ -7677,130 +7677,126 @@ export const biomeTrainerPools: BiomeTrainerPools = {
|
|||||||
traverseBiome(Biome.TOWN, 0);
|
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 ];
|
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 => {
|
for (const biome of Utils.getEnumValues(Biome)) {
|
||||||
const pokemonEvolutions = pe.pokemonEvolutions;
|
biomePokemonPools[biome] = {};
|
||||||
for (const biome of Utils.getEnumValues(Biome)) {
|
biomeTrainerPools[biome] = {};
|
||||||
biomePokemonPools[biome] = {};
|
|
||||||
biomeTrainerPools[biome] = {};
|
|
||||||
|
|
||||||
for (const tier of Utils.getEnumValues(BiomePoolTier)) {
|
for (const tier of Utils.getEnumValues(BiomePoolTier)) {
|
||||||
biomePokemonPools[biome][tier] = {};
|
biomePokemonPools[biome][tier] = {};
|
||||||
biomeTrainerPools[biome][tier] = [];
|
biomeTrainerPools[biome][tier] = [];
|
||||||
|
|
||||||
for (const tod of Utils.getEnumValues(TimeOfDay)) {
|
for (const tod of Utils.getEnumValues(TimeOfDay)) {
|
||||||
biomePokemonPools[biome][tier][tod] = [];
|
biomePokemonPools[biome][tier][tod] = [];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const pb of pokemonBiomes) {
|
for (const pb of pokemonBiomes) {
|
||||||
const speciesId = pb[0] as Species;
|
const speciesId = pb[0] as Species;
|
||||||
const biomeEntries = pb[3] as (Biome | BiomePoolTier)[][];
|
const biomeEntries = pb[3] as (Biome | BiomePoolTier)[][];
|
||||||
|
|
||||||
const speciesEvolutions: SpeciesFormEvolution[] = pokemonEvolutions.hasOwnProperty(speciesId)
|
const speciesEvolutions: SpeciesFormEvolution[] = pokemonEvolutions.hasOwnProperty(speciesId)
|
||||||
? pokemonEvolutions[speciesId]
|
? pokemonEvolutions[speciesId]
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
if (!biomeEntries.filter(b => b[0] !== Biome.END).length && !speciesEvolutions.filter(es => !!((pokemonBiomes.find(p => p[0] === es.speciesId))[3] as any[]).filter(b => b[0] !== Biome.END).length).length) {
|
if (!biomeEntries.filter(b => b[0] !== Biome.END).length && !speciesEvolutions.filter(es => !!((pokemonBiomes.find(p => p[0] === es.speciesId))[3] as any[]).filter(b => b[0] !== Biome.END).length).length) {
|
||||||
uncatchableSpecies.push(speciesId);
|
uncatchableSpecies.push(speciesId);
|
||||||
}
|
|
||||||
|
|
||||||
for (const b of biomeEntries) {
|
|
||||||
const biome = b[0];
|
|
||||||
const tier = b[1];
|
|
||||||
const timesOfDay = b.length > 2
|
|
||||||
? Array.isArray(b[2])
|
|
||||||
? b[2]
|
|
||||||
: [ b[2] ]
|
|
||||||
: [ TimeOfDay.ALL ];
|
|
||||||
|
|
||||||
for (const tod of timesOfDay) {
|
|
||||||
if (!biomePokemonPools.hasOwnProperty(biome) || !biomePokemonPools[biome].hasOwnProperty(tier) || !biomePokemonPools[biome][tier].hasOwnProperty(tod)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const biomeTierPool = biomePokemonPools[biome][tier][tod];
|
|
||||||
|
|
||||||
let treeIndex = -1;
|
|
||||||
let arrayIndex = 0;
|
|
||||||
|
|
||||||
for (let t = 0; t < biomeTierPool.length; t++) {
|
|
||||||
const existingSpeciesIds = biomeTierPool[t] as unknown as Species[];
|
|
||||||
for (let es = 0; es < existingSpeciesIds.length; es++) {
|
|
||||||
const existingSpeciesId = existingSpeciesIds[es];
|
|
||||||
if (pokemonEvolutions.hasOwnProperty(existingSpeciesId) && (pokemonEvolutions[existingSpeciesId] as SpeciesFormEvolution[]).find(ese => ese.speciesId === speciesId)) {
|
|
||||||
treeIndex = t;
|
|
||||||
arrayIndex = es + 1;
|
|
||||||
break;
|
|
||||||
} else if (speciesEvolutions && speciesEvolutions.find(se => se.speciesId === existingSpeciesId)) {
|
|
||||||
treeIndex = t;
|
|
||||||
arrayIndex = es;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (treeIndex > -1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (treeIndex > -1) {
|
|
||||||
(biomeTierPool[treeIndex] as unknown as Species[]).splice(arrayIndex, 0, speciesId);
|
|
||||||
} else {
|
|
||||||
(biomeTierPool as unknown as Species[][]).push([ speciesId ]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const b of Object.keys(biomePokemonPools)) {
|
for (const b of biomeEntries) {
|
||||||
for (const t of Object.keys(biomePokemonPools[b])) {
|
const biome = b[0];
|
||||||
const tier = parseInt(t) as BiomePoolTier;
|
const tier = b[1];
|
||||||
for (const tod of Object.keys(biomePokemonPools[b][t])) {
|
const timesOfDay = b.length > 2
|
||||||
const biomeTierTimePool = biomePokemonPools[b][t][tod];
|
? Array.isArray(b[2])
|
||||||
for (let e = 0; e < biomeTierTimePool.length; e++) {
|
? b[2]
|
||||||
const entry = biomeTierTimePool[e];
|
: [ b[2] ]
|
||||||
if (entry.length === 1) {
|
: [ TimeOfDay.ALL ];
|
||||||
biomeTierTimePool[e] = entry[0];
|
|
||||||
} else {
|
|
||||||
const newEntry = {
|
|
||||||
1: [ entry[0] ]
|
|
||||||
};
|
|
||||||
for (let s = 1; s < entry.length; s++) {
|
|
||||||
const speciesId = entry[s];
|
|
||||||
const prevolution = entry.map(s => pokemonEvolutions[s]).flat().find(e => e && e.speciesId === speciesId);
|
|
||||||
const level = prevolution.level - (prevolution.level === 1 ? 1 : 0) + (prevolution.wildDelay * 10) - (tier >= BiomePoolTier.BOSS ? 10 : 0);
|
|
||||||
if (!newEntry.hasOwnProperty(level)) {
|
|
||||||
newEntry[level] = [ speciesId ];
|
|
||||||
} else {
|
|
||||||
newEntry[level].push(speciesId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
biomeTierTimePool[e] = newEntry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const tb of trainerBiomes) {
|
for (const tod of timesOfDay) {
|
||||||
const trainerType = tb[0] as TrainerType;
|
if (!biomePokemonPools.hasOwnProperty(biome) || !biomePokemonPools[biome].hasOwnProperty(tier) || !biomePokemonPools[biome][tier].hasOwnProperty(tod)) {
|
||||||
const biomeEntries = tb[1] as BiomePoolTier[][];
|
|
||||||
|
|
||||||
for (const b of biomeEntries) {
|
|
||||||
const biome = b[0];
|
|
||||||
const tier = b[1];
|
|
||||||
|
|
||||||
if (!biomeTrainerPools.hasOwnProperty(biome) || !biomeTrainerPools[biome].hasOwnProperty(tier)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const biomeTierPool = biomeTrainerPools[biome][tier];
|
const biomeTierPool = biomePokemonPools[biome][tier][tod];
|
||||||
biomeTierPool.push(trainerType);
|
|
||||||
|
let treeIndex = -1;
|
||||||
|
let arrayIndex = 0;
|
||||||
|
|
||||||
|
for (let t = 0; t < biomeTierPool.length; t++) {
|
||||||
|
const existingSpeciesIds = biomeTierPool[t] as unknown as Species[];
|
||||||
|
for (let es = 0; es < existingSpeciesIds.length; es++) {
|
||||||
|
const existingSpeciesId = existingSpeciesIds[es];
|
||||||
|
if (pokemonEvolutions.hasOwnProperty(existingSpeciesId) && (pokemonEvolutions[existingSpeciesId] as SpeciesFormEvolution[]).find(ese => ese.speciesId === speciesId)) {
|
||||||
|
treeIndex = t;
|
||||||
|
arrayIndex = es + 1;
|
||||||
|
break;
|
||||||
|
} else if (speciesEvolutions && speciesEvolutions.find(se => se.speciesId === existingSpeciesId)) {
|
||||||
|
treeIndex = t;
|
||||||
|
arrayIndex = es;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (treeIndex > -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (treeIndex > -1) {
|
||||||
|
(biomeTierPool[treeIndex] as unknown as Species[]).splice(arrayIndex, 0, speciesId);
|
||||||
|
} else {
|
||||||
|
(biomeTierPool as unknown as Species[][]).push([ speciesId ]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const b of Object.keys(biomePokemonPools)) {
|
||||||
|
for (const t of Object.keys(biomePokemonPools[b])) {
|
||||||
|
const tier = parseInt(t) as BiomePoolTier;
|
||||||
|
for (const tod of Object.keys(biomePokemonPools[b][t])) {
|
||||||
|
const biomeTierTimePool = biomePokemonPools[b][t][tod];
|
||||||
|
for (let e = 0; e < biomeTierTimePool.length; e++) {
|
||||||
|
const entry = biomeTierTimePool[e];
|
||||||
|
if (entry.length === 1) {
|
||||||
|
biomeTierTimePool[e] = entry[0];
|
||||||
|
} else {
|
||||||
|
const newEntry = {
|
||||||
|
1: [ entry[0] ]
|
||||||
|
};
|
||||||
|
for (let s = 1; s < entry.length; s++) {
|
||||||
|
const speciesId = entry[s];
|
||||||
|
const prevolution = entry.map(s => pokemonEvolutions[s]).flat().find(e => e && e.speciesId === speciesId);
|
||||||
|
const level = prevolution.level - (prevolution.level === 1 ? 1 : 0) + (prevolution.wildDelay * 10) - (tier >= BiomePoolTier.BOSS ? 10 : 0);
|
||||||
|
if (!newEntry.hasOwnProperty(level)) {
|
||||||
|
newEntry[level] = [ speciesId ];
|
||||||
|
} else {
|
||||||
|
newEntry[level].push(speciesId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
biomeTierTimePool[e] = newEntry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const tb of trainerBiomes) {
|
||||||
|
const trainerType = tb[0] as TrainerType;
|
||||||
|
const biomeEntries = tb[1] as BiomePoolTier[][];
|
||||||
|
|
||||||
|
for (const b of biomeEntries) {
|
||||||
|
const biome = b[0];
|
||||||
|
const tier = b[1];
|
||||||
|
|
||||||
|
if (!biomeTrainerPools.hasOwnProperty(biome) || !biomeTrainerPools[biome].hasOwnProperty(tier)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const biomeTierPool = biomeTrainerPools[biome][tier];
|
||||||
|
biomeTierPool.push(trainerType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//outputPools();
|
|
||||||
});
|
|
||||||
|
|
||||||
// used in a commented code
|
// used in a commented code
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
@ -608,9 +608,11 @@ function parseEggMoves(content: string): void {
|
|||||||
console.log(output);
|
console.log(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
const eggMovesStr = "";
|
export function initEggMoves() {
|
||||||
if (eggMovesStr) {
|
const eggMovesStr = "";
|
||||||
setTimeout(() => {
|
if (eggMovesStr) {
|
||||||
parseEggMoves(eggMovesStr);
|
setTimeout(() => {
|
||||||
}, 1000);
|
parseEggMoves(eggMovesStr);
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1619,7 +1619,7 @@ interface PokemonPrevolutions {
|
|||||||
|
|
||||||
export const pokemonPrevolutions: 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 megaFormKeys = [ SpeciesFormKey.MEGA, "", SpeciesFormKey.MEGA_X, "", SpeciesFormKey.MEGA_Y ].map(sfk => sfk as string);
|
||||||
const prevolutionKeys = Object.keys(pokemonEvolutions);
|
const prevolutionKeys = Object.keys(pokemonEvolutions);
|
||||||
prevolutionKeys.forEach(pk => {
|
prevolutionKeys.forEach(pk => {
|
||||||
|
@ -729,7 +729,7 @@ export const pokemonFormChanges: PokemonFormChanges = {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
export function initPokemonForms() {
|
||||||
const formChangeKeys = Object.keys(pokemonFormChanges);
|
const formChangeKeys = Object.keys(pokemonFormChanges);
|
||||||
formChangeKeys.forEach(pk => {
|
formChangeKeys.forEach(pk => {
|
||||||
const formChanges = pokemonFormChanges[pk];
|
const formChanges = pokemonFormChanges[pk];
|
||||||
|
@ -1051,6 +1051,6 @@ export const trainerConfigs: TrainerConfigs = {
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
(function () {
|
export function initTrainerTypeDialogue() {
|
||||||
initTrainerTypeDialogue();
|
initTrainerTypeDialogue();
|
||||||
})();
|
}
|
||||||
|
@ -9,6 +9,14 @@ import { WindowVariant, getWindowVariantSuffix } from "./ui/ui-theme";
|
|||||||
import { isMobile } from "./touch-controls";
|
import { isMobile } from "./touch-controls";
|
||||||
import * as Utils from "./utils";
|
import * as Utils from "./utils";
|
||||||
import { initI18n } from "./plugins/i18n";
|
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 {
|
export class LoadingScene extends SceneBase {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -284,6 +292,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.load.plugin("rextexteditplugin", "https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/dist/rextexteditplugin.min.js", true);
|
||||||
|
|
||||||
this.loadLoadingScreen();
|
this.loadLoadingScreen();
|
||||||
|
|
||||||
|
initStatsKeys();
|
||||||
|
initPokemonPrevolutions();
|
||||||
|
initBiomes();
|
||||||
|
initEggMoves();
|
||||||
|
initPokemonForms();
|
||||||
|
initSpecies();
|
||||||
|
initMoves();
|
||||||
|
initAbilities();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadLoadingScreen() {
|
loadLoadingScreen() {
|
||||||
|
9
src/test/achievement.test.ts
Normal file
9
src/test/achievement.test.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import {describe, expect, it} from "vitest";
|
||||||
|
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} 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 "vitest-canvas-mock";
|
||||||
import "#app/test/phaser.setup";
|
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();
|
||||||
|
@ -230,7 +230,7 @@ export default class GameStatsUiHandler extends UiHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(function () {
|
export function initStatsKeys() {
|
||||||
const statKeys = Object.keys(displayStats);
|
const statKeys = Object.keys(displayStats);
|
||||||
|
|
||||||
for (const key of statKeys) {
|
for (const key of statKeys) {
|
||||||
@ -256,4 +256,4 @@ export default class GameStatsUiHandler extends UiHandler {
|
|||||||
(displayStats[key] as DisplayStat).label = Utils.toReadableString(`${splittableKey[0].toUpperCase()}${splittableKey.slice(1)}`);
|
(displayStats[key] as DisplayStat).label = Utils.toReadableString(`${splittableKey[0].toUpperCase()}${splittableKey.slice(1)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})();
|
}
|
||||||
|
@ -14,6 +14,7 @@ export default defineConfig(({ mode }) => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
threads: false,
|
threads: false,
|
||||||
|
trace: true,
|
||||||
environmentOptions: {
|
environmentOptions: {
|
||||||
jsdom: {
|
jsdom: {
|
||||||
resources: 'usable',
|
resources: 'usable',
|
||||||
|
Loading…
Reference in New Issue
Block a user