mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-04 15:32:18 +02:00
Compare commits
4 Commits
6192ba369d
...
2535f0ab67
Author | SHA1 | Date | |
---|---|---|---|
|
2535f0ab67 | ||
|
c9d05daad1 | ||
|
aaec973af3 | ||
|
ab5f252f16 |
@ -13,6 +13,7 @@ import { EggHatchData } from "#app/data/egg-hatch-data.js";
|
|||||||
export class EggLapsePhase extends Phase {
|
export class EggLapsePhase extends Phase {
|
||||||
|
|
||||||
private eggHatchData: EggHatchData[] = [];
|
private eggHatchData: EggHatchData[] = [];
|
||||||
|
private loadsWaiting: number;
|
||||||
constructor(scene: BattleScene) {
|
constructor(scene: BattleScene) {
|
||||||
super(scene);
|
super(scene);
|
||||||
}
|
}
|
||||||
@ -28,6 +29,7 @@ export class EggLapsePhase extends Phase {
|
|||||||
this.eggHatchData= [];
|
this.eggHatchData= [];
|
||||||
|
|
||||||
const minEggsToPromptSkip = 5;
|
const minEggsToPromptSkip = 5;
|
||||||
|
this.loadsWaiting = eggsToHatch.length;
|
||||||
|
|
||||||
if (eggsToHatchCount > 0) {
|
if (eggsToHatchCount > 0) {
|
||||||
|
|
||||||
@ -36,20 +38,17 @@ export class EggLapsePhase extends Phase {
|
|||||||
// show prompt for skip
|
// show prompt for skip
|
||||||
this.scene.ui.showText(i18next.t("battle:eggSkipPrompt"), 0);
|
this.scene.ui.showText(i18next.t("battle:eggSkipPrompt"), 0);
|
||||||
this.scene.ui.setModeWithoutClear(Mode.CONFIRM, () => {
|
this.scene.ui.setModeWithoutClear(Mode.CONFIRM, () => {
|
||||||
|
console.time("hatch eggs");
|
||||||
for (const egg of eggsToHatch) {
|
for (const egg of eggsToHatch) {
|
||||||
this.hatchEggSilently(egg);
|
this.hatchEggSilently(egg);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.scene.unshiftPhase(new EggSummaryPhase(this.scene, this.eggHatchData));
|
|
||||||
this.end();
|
|
||||||
}, () => {
|
}, () => {
|
||||||
for (const egg of eggsToHatch) {
|
for (const egg of eggsToHatch) {
|
||||||
this.scene.unshiftPhase(new EggHatchPhase(this.scene, this, egg, eggsToHatchCount));
|
this.scene.unshiftPhase(new EggHatchPhase(this.scene, this, egg, eggsToHatchCount));
|
||||||
eggsToHatchCount--;
|
eggsToHatchCount--;
|
||||||
}
|
}
|
||||||
|
this.showSummary();
|
||||||
|
|
||||||
this.scene.unshiftPhase(new EggSummaryPhase(this.scene, this.eggHatchData));
|
|
||||||
this.end();
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}, 100, true);
|
}, 100, true);
|
||||||
@ -62,14 +61,16 @@ export class EggLapsePhase extends Phase {
|
|||||||
}
|
}
|
||||||
this.end();
|
this.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
console.log(this.eggHatchData);
|
|
||||||
} else {
|
} else {
|
||||||
this.end();
|
this.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showSummary() {
|
||||||
|
this.scene.unshiftPhase(new EggSummaryPhase(this.scene, this.eggHatchData));
|
||||||
|
this.end();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hatches an egg and stores it in the local EggHatchData array without animations
|
* Hatches an egg and stores it in the local EggHatchData array without animations
|
||||||
* Also validates the achievements for the hatched pokemon and removes the egg
|
* Also validates the achievements for the hatched pokemon and removes the egg
|
||||||
@ -78,6 +79,7 @@ export class EggLapsePhase extends Phase {
|
|||||||
*/
|
*/
|
||||||
hatchEggSilently(egg: Egg) {
|
hatchEggSilently(egg: Egg) {
|
||||||
const eggIndex = this.scene.gameData.eggs.findIndex(e => e.id === egg.id);
|
const eggIndex = this.scene.gameData.eggs.findIndex(e => e.id === egg.id);
|
||||||
|
const eggsRemaining = this.scene.gameData.eggs.length;
|
||||||
if (eggIndex === -1) {
|
if (eggIndex === -1) {
|
||||||
return this.end();
|
return this.end();
|
||||||
}
|
}
|
||||||
@ -88,9 +90,17 @@ export class EggLapsePhase extends Phase {
|
|||||||
if (pokemon.fusionSpecies) {
|
if (pokemon.fusionSpecies) {
|
||||||
pokemon.clearFusionSpecies();
|
pokemon.clearFusionSpecies();
|
||||||
}
|
}
|
||||||
console.log(pokemon);
|
|
||||||
|
|
||||||
|
console.time("loading assets " + pokemon.name + " " + eggsRemaining);
|
||||||
pokemon.loadAssets().then(() => {
|
pokemon.loadAssets().then(() => {
|
||||||
|
this.loadsWaiting--;
|
||||||
|
console.log(this.loadsWaiting);
|
||||||
|
console.timeEnd("loading assets " + pokemon.name + " " + eggsRemaining);
|
||||||
|
|
||||||
|
if (this.loadsWaiting === 0) {
|
||||||
|
console.timeEnd("hatch eggs");
|
||||||
|
this.showSummary();
|
||||||
|
}
|
||||||
|
|
||||||
if (pokemon.species.subLegendary) {
|
if (pokemon.species.subLegendary) {
|
||||||
this.scene.validateAchv(achvs.HATCH_SUB_LEGENDARY);
|
this.scene.validateAchv(achvs.HATCH_SUB_LEGENDARY);
|
||||||
@ -104,7 +114,6 @@ export class EggLapsePhase extends Phase {
|
|||||||
if (pokemon.isShiny()) {
|
if (pokemon.isShiny()) {
|
||||||
this.scene.validateAchv(achvs.HATCH_SHINY);
|
this.scene.validateAchv(achvs.HATCH_SHINY);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,12 @@ export class EggSummaryPhase extends Phase {
|
|||||||
|
|
||||||
start() {
|
start() {
|
||||||
super.start();
|
super.start();
|
||||||
|
console.time("update egg dex");
|
||||||
|
|
||||||
const updateNextPokemon = (i: integer) => {
|
const updateNextPokemon = (i: integer) => {
|
||||||
console.log(i);
|
|
||||||
if (i >= this.eggHatchData.length) {
|
if (i >= this.eggHatchData.length) {
|
||||||
console.log("displayed all pokemon");
|
console.timeEnd("update egg dex");
|
||||||
|
|
||||||
this.scene.ui.setModeForceTransition(Mode.EGG_HATCH_SUMMARY, this.eggHatchData).then(() => {
|
this.scene.ui.setModeForceTransition(Mode.EGG_HATCH_SUMMARY, this.eggHatchData).then(() => {
|
||||||
this.scene.fadeOutBgm(undefined, false);
|
this.scene.fadeOutBgm(undefined, false);
|
||||||
this.eggHatchHandler = this.scene.ui.getHandler() as EggHatchSceneHandler;
|
this.eggHatchHandler = this.scene.ui.getHandler() as EggHatchSceneHandler;
|
||||||
@ -35,7 +36,6 @@ export class EggSummaryPhase extends Phase {
|
|||||||
} else {
|
} else {
|
||||||
this.eggHatchData[i].setDex();
|
this.eggHatchData[i].setDex();
|
||||||
this.eggHatchData[i].updatePokemon().then(() => {
|
this.eggHatchData[i].updatePokemon().then(() => {
|
||||||
console.log("updating next pokemon");
|
|
||||||
if (i < this.eggHatchData.length) {
|
if (i < this.eggHatchData.length) {
|
||||||
updateNextPokemon(i + 1);
|
updateNextPokemon(i + 1);
|
||||||
}
|
}
|
||||||
|
@ -1618,12 +1618,10 @@ export class GameData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const checkPrevolution = () => {
|
const checkPrevolution = () => {
|
||||||
console.log("checking prevolution");
|
|
||||||
if (hasPrevolution) {
|
if (hasPrevolution) {
|
||||||
const prevolutionSpecies = pokemonPrevolutions[species.speciesId];
|
const prevolutionSpecies = pokemonPrevolutions[species.speciesId];
|
||||||
this.setPokemonSpeciesCaught(pokemon, getPokemonSpecies(prevolutionSpecies), incrementCount, fromEgg, showMessage).then(() => resolve());
|
this.setPokemonSpeciesCaught(pokemon, getPokemonSpecies(prevolutionSpecies), incrementCount, fromEgg, showMessage).then(() => resolve());
|
||||||
} else {
|
} else {
|
||||||
console.log("resolving");
|
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -156,6 +156,7 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
|
|||||||
this.eggHatchBg.setVisible(true);
|
this.eggHatchBg.setVisible(true);
|
||||||
|
|
||||||
this.infoContainer.hideDisplayPokemon();
|
this.infoContainer.hideDisplayPokemon();
|
||||||
|
console.time("display icons");
|
||||||
|
|
||||||
this.eggHatchData.forEach( (value: EggHatchData, i: number) => {
|
this.eggHatchData.forEach( (value: EggHatchData, i: number) => {
|
||||||
const x = (i % 11) * 18;
|
const x = (i % 11) * 18;
|
||||||
@ -229,6 +230,8 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
|
|||||||
em.setVisible(value.eggMoveUnlocked);
|
em.setVisible(value.eggMoveUnlocked);
|
||||||
this.pokemonIconsContainer.add(em);
|
this.pokemonIconsContainer.add(em);
|
||||||
});
|
});
|
||||||
|
console.timeEnd("display icons");
|
||||||
|
|
||||||
this.setCursor(0);
|
this.setCursor(0);
|
||||||
|
|
||||||
// TODO nice animation reveal for all eggs hatching at once
|
// TODO nice animation reveal for all eggs hatching at once
|
||||||
@ -242,7 +245,6 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
const error = false;
|
const error = false;
|
||||||
console.log("egg handler button " + button);
|
|
||||||
if (button === Button.CANCEL) {
|
if (button === Button.CANCEL) {
|
||||||
const phase = this.scene.getCurrentPhase();
|
const phase = this.scene.getCurrentPhase();
|
||||||
if (phase instanceof EggSummaryPhase) {
|
if (phase instanceof EggSummaryPhase) {
|
||||||
@ -294,7 +296,6 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
|
|||||||
const lastCursor = this.cursor;
|
const lastCursor = this.cursor;
|
||||||
|
|
||||||
changed = super.setCursor(cursor);
|
changed = super.setCursor(cursor);
|
||||||
this.infoContainer.interruptDisplay();
|
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
this.cursorObj.setPosition(114 + 18 * (cursor % 11), 10 + 18 * Math.floor(cursor / 11));
|
this.cursorObj.setPosition(114 + 18 * (cursor % 11), 10 + 18 * Math.floor(cursor / 11));
|
||||||
|
@ -3,7 +3,6 @@ import PokemonInfoContainer from "./pokemon-info-container";
|
|||||||
import BattleScene from "../battle-scene";
|
import BattleScene from "../battle-scene";
|
||||||
import { Gender } from "../data/gender";
|
import { Gender } from "../data/gender";
|
||||||
import { Type } from "../data/type";
|
import { Type } from "../data/type";
|
||||||
import i18next from "i18next";
|
|
||||||
import * as Utils from "../utils";
|
import * as Utils from "../utils";
|
||||||
import { TextStyle, addTextObject } from "./text";
|
import { TextStyle, addTextObject } from "./text";
|
||||||
import { speciesEggMoves } from "#app/data/egg-moves.js";
|
import { speciesEggMoves } from "#app/data/egg-moves.js";
|
||||||
@ -33,7 +32,6 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer {
|
|||||||
private pokemonCandyIcon: Phaser.GameObjects.Sprite;
|
private pokemonCandyIcon: Phaser.GameObjects.Sprite;
|
||||||
private pokemonCandyOverlayIcon: Phaser.GameObjects.Sprite;
|
private pokemonCandyOverlayIcon: Phaser.GameObjects.Sprite;
|
||||||
private pokemonCandyCountText: Phaser.GameObjects.Text;
|
private pokemonCandyCountText: Phaser.GameObjects.Text;
|
||||||
private assetLoadCancelled: Utils.BooleanHolder | null;
|
|
||||||
|
|
||||||
constructor(scene: BattleScene, listContainer : Phaser.GameObjects.Container, x: number = 115, y: number = 9,) {
|
constructor(scene: BattleScene, listContainer : Phaser.GameObjects.Container, x: number = 115, y: number = 9,) {
|
||||||
super(scene, x, y);
|
super(scene, x, y);
|
||||||
@ -74,7 +72,7 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer {
|
|||||||
this.pokemonCandyOverlayIcon.setOrigin(0, 0);
|
this.pokemonCandyOverlayIcon.setOrigin(0, 0);
|
||||||
this.pokemonListContainer.add(this.pokemonCandyOverlayIcon);
|
this.pokemonListContainer.add(this.pokemonCandyOverlayIcon);
|
||||||
|
|
||||||
this.pokemonCandyCountText = addTextObject(this.scene, 14, 40, "x0", TextStyle.WINDOW_ALT, { fontSize: "56px" });
|
this.pokemonCandyCountText = addTextObject(this.scene, 14, 40, "x0", TextStyle.SUMMARY, { fontSize: "56px" });
|
||||||
this.pokemonCandyCountText.setOrigin(0, 0);
|
this.pokemonCandyCountText.setOrigin(0, 0);
|
||||||
this.pokemonListContainer.add(this.pokemonCandyCountText);
|
this.pokemonListContainer.add(this.pokemonCandyCountText);
|
||||||
|
|
||||||
@ -86,11 +84,6 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer {
|
|||||||
this.pokemonEggMovesContainer.setVisible(false);
|
this.pokemonEggMovesContainer.setVisible(false);
|
||||||
this.pokemonEggMovesContainer.setScale(0.5);
|
this.pokemonEggMovesContainer.setScale(0.5);
|
||||||
|
|
||||||
const eggMovesLabel = addTextObject(this.scene, 70, 0, i18next.t("starterSelectUiHandler:eggMoves"), TextStyle.WINDOW_ALT);
|
|
||||||
eggMovesLabel.setOrigin(0.5, 0);
|
|
||||||
|
|
||||||
this.pokemonEggMovesContainer.add(eggMovesLabel);
|
|
||||||
|
|
||||||
for (let m = 0; m < 4; m++) {
|
for (let m = 0; m < 4; m++) {
|
||||||
const eggMoveContainer = this.scene.add.container(0, 0 + 6 * m);
|
const eggMoveContainer = this.scene.add.container(0, 0 + 6 * m);
|
||||||
|
|
||||||
@ -123,42 +116,26 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer {
|
|||||||
this.currentPokemonSprite.setVisible(false);
|
this.currentPokemonSprite.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
interruptDisplay() {
|
|
||||||
if (this.assetLoadCancelled) {
|
|
||||||
this.assetLoadCancelled.value = true;
|
|
||||||
this.assetLoadCancelled = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a given pokemon sprite with animations
|
* Display a given pokemon sprite with animations
|
||||||
|
* @precondition the specific pokemon sprite has already been loaded
|
||||||
*/
|
*/
|
||||||
displayPokemon(pokemon: PlayerPokemon) {
|
displayPokemon(pokemon: PlayerPokemon) {
|
||||||
|
console.time("display pokemon" + pokemon.name);
|
||||||
console.log("displaying pokemon", pokemon.name);
|
console.log("displaying pokemon", pokemon.name);
|
||||||
const species = pokemon.species;
|
const species = pokemon.species;
|
||||||
const female = pokemon.gender === Gender.FEMALE;
|
const female = pokemon.gender === Gender.FEMALE;
|
||||||
const formIndex = pokemon.formIndex;
|
const formIndex = pokemon.formIndex;
|
||||||
const shiny = pokemon.shiny;
|
const shiny = pokemon.shiny;
|
||||||
const variant = pokemon.variant;
|
const variant = pokemon.variant;
|
||||||
const assetLoadCancelled = new Utils.BooleanHolder(false);
|
|
||||||
this.assetLoadCancelled = assetLoadCancelled;
|
|
||||||
|
|
||||||
species.loadAssets(this.scene, female, formIndex, shiny, variant, true).then(() => {
|
getPokemonSpeciesForm(species.speciesId, pokemon.formIndex).cry(this.scene);
|
||||||
if (assetLoadCancelled.value) {
|
this.currentPokemonSprite.play(species.getSpriteKey(female, formIndex, shiny, variant));
|
||||||
console.log("interrupted");
|
this.currentPokemonSprite.setPipelineData("shiny", shiny);
|
||||||
return;
|
this.currentPokemonSprite.setPipelineData("variant", variant);
|
||||||
}
|
this.currentPokemonSprite.setPipelineData("spriteKey", species.getSpriteKey(female, formIndex, shiny, variant));
|
||||||
this.assetLoadCancelled = null;
|
this.currentPokemonSprite.setVisible(true);
|
||||||
// this.speciesLoaded.set(species.speciesId, true);
|
console.timeEnd("display pokemon" + pokemon.name);
|
||||||
// redundant setVisible(true) but makes sure sprite is only visible after being rendered (no substitute visible)
|
|
||||||
this.currentPokemonSprite.setVisible(true);
|
|
||||||
getPokemonSpeciesForm(species.speciesId, pokemon.formIndex).cry(this.scene);
|
|
||||||
this.currentPokemonSprite.play(species.getSpriteKey(female, formIndex, shiny, variant));
|
|
||||||
this.currentPokemonSprite.setPipelineData("shiny", shiny);
|
|
||||||
this.currentPokemonSprite.setPipelineData("variant", variant);
|
|
||||||
this.currentPokemonSprite.setPipelineData("spriteKey", species.getSpriteKey(female, formIndex, shiny, variant));
|
|
||||||
// this.pokemonSprite.setVisible(!this.statsMode);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -167,7 +144,7 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer {
|
|||||||
* @param hatchInfo The EggHatchData of the pokemon / new hatch to show
|
* @param hatchInfo The EggHatchData of the pokemon / new hatch to show
|
||||||
*/
|
*/
|
||||||
showHatchInfo(hatchInfo: EggHatchData) {
|
showHatchInfo(hatchInfo: EggHatchData) {
|
||||||
console.log("showing hatch info", hatchInfo.pokemon.name);
|
console.time("show hatch info" + hatchInfo.pokemon.name);
|
||||||
this.pokemonEggMovesContainer.setVisible(true);
|
this.pokemonEggMovesContainer.setVisible(true);
|
||||||
|
|
||||||
const pokemon = hatchInfo.pokemon;
|
const pokemon = hatchInfo.pokemon;
|
||||||
@ -208,6 +185,7 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer {
|
|||||||
} else {
|
} else {
|
||||||
this.pokemonHatchedIcon.setFrame(getEggTierForSpecies(species));
|
this.pokemonHatchedIcon.setFrame(getEggTierForSpecies(species));
|
||||||
}
|
}
|
||||||
|
console.timeEnd("show hatch info" + hatchInfo.pokemon.name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user