better dex tracking for summary after regular egg hatching

This commit is contained in:
James Diefenbach 2024-08-24 18:44:39 +10:00
parent 486a43207e
commit 06dd3822c6
5 changed files with 68 additions and 300 deletions

View File

@ -456,6 +456,7 @@ export class EggHatchPhase extends Phase {
// return ret;
this.eggHatchData = this.hatchScene.generatePokemon(this.egg);
this.eggHatchData.setDex();
return this.eggHatchData.pokemon;
}
@ -532,21 +533,17 @@ export class EggHatchData {
// function that can be called when doing egg summary to set dex one at a time
updatePokemon(showMessage : boolean = false) {
console.log("setting dex (actual, local):");
const currDexEntry = this.scene.gameData.dexData[this.pokemon.species.speciesId];
console.log(currDexEntry);
console.log(this.prevDexEntry);
this.setDex();
// console.log("setting dex (actual, local):");
// const currDexEntry = this.scene.gameData.dexData[this.pokemon.species.speciesId];
// console.log(currDexEntry);
// console.log(this.prevDexEntry);
// this.setDex();
// TODO seperate dex updates for skip or serial hatch
// this.setDex();
return new Promise<void>(resolve => {
// this.scene.ui.showText(`${this.pokemonHatched[0].name}`, 0);
this.scene.gameData.setPokemonCaught(this.pokemon, true, true, showMessage).then(() => {
//TODO pass through egg move updates
// console.log("set IVs");
this.scene.gameData.updateSpeciesDexIvs(this.pokemon.species.speciesId, this.pokemon.ivs);
// console.log("set egg moves");
this.scene.gameData.setEggMoveUnlocked(this.pokemon.species, this.eggMoveIndex, showMessage).then((value) => {
console.log(value);
this.eggMoveUnlocked = value;
console.log("updates complete, logging actual dex and local dexEntry");
const currDexEntry = this.scene.gameData.dexData[this.pokemon.species.speciesId];
@ -563,288 +560,3 @@ export class EggHatchData {
// TODO easy function to get egg move for display (or no egg move)
}
}
export class EggSummaryPhase extends Phase {
private egg: Egg;
private eggHatchData: EggHatchData[];
private showMessages: boolean;
private eggHatchHandler: EggHatchSceneHandler;
private eggHatchContainer: Phaser.GameObjects.Container;
private eggHatchBg: Phaser.GameObjects.Image;
private pokemonBg: Phaser.GameObjects.Image;
private eggHatchOverlay: Phaser.GameObjects.Rectangle;
private infoContainer: PokemonInfoContainer;
private spriteContainers: Phaser.GameObjects.Container[];
private shinyIcons: Phaser.GameObjects.Image[];
private hiddenAbilityIcons: Phaser.GameObjects.Image[];
private pokeballIcons: Phaser.GameObjects.Image[];
private eggMoveIcons: Phaser.GameObjects.Image[];
private infoContainers: PokemonInfoContainer[];
constructor(scene: BattleScene, eggHatchData: EggHatchData[]) {
super(scene);
this.eggHatchData = eggHatchData;
}
start() {
super.start();
// 55 pokemon total now
// for (let i = 0; i < 44; i++) {
// this.pokemonHatched.push(this.scene.addPlayerPokemon(getPokemonSpecies(Species.PIKACHU), 1, undefined, undefined, undefined, false));
// }
// for (const eggInfo of this.eggHatchData) {
// eggInfo.updatePokemon(false);
// }
const updateNextPokemon = (i: integer) => {
console.log(i);
if (i >= this.eggHatchData.length) {
console.log("displayed all pokemon");
this.scene.ui.setModeForceTransition(Mode.EGG_HATCH_SUMMARY, this.eggHatchData).then(() => {
this.scene.fadeOutBgm(null, false);
this.eggHatchHandler = this.scene.ui.getHandler() as EggHatchSceneHandler;
this.eggHatchContainer = this.eggHatchHandler.eggHatchContainer;
});
// this.scene.ui.showText(" ", null, () => {
// // this.scene.ui.showText(null, 0);
// // this.scene.tweens.add({
// // duration: Utils.fixedInt(3000),
// // targets: this.eggHatchOverlay,
// // alpha: 0,
// // ease: "Cubic.easeOut"
// console.log("displayed all pokemon");
// // TODO change end to be called by UI
// // this.end();
// }, null, true);
} else {
this.eggHatchData[i].updatePokemon().then(() => {
console.log("updating next pokemon");
if (i < this.eggHatchData.length) {
updateNextPokemon(i + 1);
}
});
}
};
updateNextPokemon(0);
// this.scene.ui.setModeForceTransition(Mode.EGG_HATCH_SUMMARY, this.eggHatchData).then(() => {
// this.scene.fadeOutBgm(null, false);
// this.eggHatchHandler = this.scene.ui.getHandler() as EggHatchSceneHandler;
// this.eggHatchContainer = this.eggHatchHandler.eggHatchContainer;
// });
//////////////// old method
// this.eggHatchBg = this.scene.add.image(0, 0, "egg_list_bg");
// this.pokemonBg = this.scene.add.image(0, 0, "starter_container_bg");
// this.eggHatchContainer.add(this.eggHatchBg);
// this.eggHatchContainer.add(this.pokemonBg);
// this.eggHatchBg.setOrigin(0, 0);
// this.pokemonBg.setOrigin(0.3,0);
// this.pokemonBg.setDepth(1);
// this.pokemonBg.setScale(1,1);
// this.eggHatchOverlay = this.scene.add.rectangle(0, -this.scene.game.canvas.height / 6, this.scene.game.canvas.width / 6, this.scene.game.canvas.height / 6, 0xFFFFFF);
// this.eggHatchOverlay.setOrigin(0, 0);
// this.eggHatchOverlay.setAlpha(0);
// this.scene.fieldUI.add(this.eggHatchOverlay);
// this.infoContainer = new PokemonInfoContainer(this.scene);
// this.infoContainer.setup();
// this.eggHatchContainer.add(this.infoContainer);
// this.spriteContainers = new Array(this.pokemonHatched.length).fill(null).map((_, i) => {
// const container = this.scene.add.container(0, 0);
// if (i) {
// container.setVisible(false);
// }
// this.eggHatchContainer.add(container);
// return container;
// });
// //TODO format grid properly with pokemon sprites
// let i = 0;
// let cols = 11;
// let size = 22;
// if (this.pokemonHatched.length >= 50) {
// cols = 13;
// size = 14;
// }
// const scale_size = size * 2;
// this.shinyIcons = new Array(this.pokemonHatched.length).fill(null).map((_, i) => {
// const x = (i % cols) * size;
// const y = Math.floor(i / cols) * size;
// const ret = this.scene.add.image(x + 0.1 * size, y + 0.2 * size, "shiny_star_small");
// ret.setOrigin(0, 0);
// ret.setScale(size / scale_size);
// ret.setVisible(true);
// this.eggHatchContainer.add(ret);
// return ret;
// });
// this.hiddenAbilityIcons = new Array(this.pokemonHatched.length).fill(null).map((_, i) => {
// const x = (i % cols) * size;
// const y = Math.floor(i / cols) * size;
// const ret = this.scene.add.image(x + 0.5 * size, y + 0.9 * size, "ha_capsule");
// ret.setOrigin(0, 0);
// ret.setScale(size / scale_size);
// ret.setVisible(true);
// this.eggHatchContainer.add(ret);
// return ret;
// });
// this.pokeballIcons = new Array(this.pokemonHatched.length).fill(null).map((_, i) => {
// const x = (i % cols) * size;
// const y = Math.floor(i / cols) * size;
// const ret = this.scene.add.image(x+ 0.1 * size, y + 0.9 * size, "icon_owned");
// ret.setOrigin(0, 0);
// ret.setScale(size / scale_size);
// ret.setVisible(true);
// this.eggHatchContainer.add(ret);
// return ret;
// });
// this.eggMoveIcons = new Array(this.pokemonHatched.length).fill(null).map((_, i) => {
// const x = (i % cols) * size;
// const y = Math.floor(i / cols) * size;
// const ret = this.scene.add.image(x + 0.8 * size, y + 0.9 * size, "icon_owned");
// ret.setOrigin(0, 0);
// ret.setScale(size / scale_size);
// ret.setVisible(true);
// ret.setTint(0.5);
// this.eggHatchContainer.add(ret);
// return ret;
// });
// this.infoContainers = new Array(this.pokemonHatched.length).fill(null).map((_, i) => {
// const ret = new PokemonInfoContainer(this.scene);
// ret.setup();
// ret.show(this.pokemonHatched[i]);
// this.eggHatchContainer.add(ret);
// return ret;
// });
// for (const displayPokemon of this.pokemonHatched) {
// console.log(displayPokemon);
// // const x = (index % 9) * 18;
// // const y = Math.floor(index / 9) * 18;
// const x = (i % cols) * size;
// const y = Math.floor(i / cols) * size;
// const icon = this.scene.add.sprite(x-2, y+2, displayPokemon.species.getIconAtlasKey(displayPokemon.formIndex, displayPokemon.shiny, displayPokemon.variant));
// icon.setScale(size / (scale_size));
// icon.setOrigin(0, 0);
// icon.setFrame(displayPokemon.species.getIconId(displayPokemon.gender === Gender.FEMALE, displayPokemon.formIndex, displayPokemon.shiny, displayPokemon.variant));
// // this.checkIconId(icon, displayPokemon.species, displayPokemon.female, displayPokemon.formIndex, displayPokemon.shiny, displayPokemon.variant);
// this.spriteContainers[i].add(icon);
// this.spriteContainers[i].setVisible(true);
// // const cursorObj = this.scene.add.image(x, y, "select_cursor_pokerus");
// // cursorObj.setVisible(true);
// // cursorObj.setOrigin(0, 0);
// // cursorObj.setScale(size / scale_size * 2);
// // this.spriteContainers[i].add(cursorObj);
// // DONE shiny icon funcitonality for variants
// // TODO test shiny icons
// this.shinyIcons[i].setVisible(displayPokemon.shiny);
// this.shinyIcons[i].setTint(getVariantTint(displayPokemon.variant));
// // this.shinyIcons[i].setTint(getVariantTint(speciesVariants[v] === DexAttr.DEFAULT_VARIANT ? 0 : speciesVariants[v] === DexAttr.VARIANT_2 ? 1 : 2));
// // DONE new pokemon / catch icon functionality
// // TODO test for new pokemon
// const dexEntry = this.scene.gameData.dexData[this.pokemonHatched[i].species.speciesId];
// const caughtAttr = dexEntry.caughtAttr;
// this.pokeballIcons[i].setVisible(!caughtAttr);
// // this.pokeballIcons[i].setVisible(this.scene.gameData.dexData[displayPokemon.species.speciesId].caughtAttr)
// // DONE? hidden ability icon functionality
// // TODO test hidden abilities / ask
// this.hiddenAbilityIcons[i].setVisible((displayPokemon.abilityIndex >= 2));
// // TODO new egg move icon functionality
// this.eggMoveIcons[i].setVisible(true);
// i++;
// }
// // for(const ret of this.pokemonHatched) {
// console.log(this.pokemonHatched);
// console.log(this.newEggMoves);
// this.scene.ui.showText(`${this.pokemonHatched.length} eggs hatched. Skip messages?`, 0);
// this.scene.ui.setModeWithoutClear(Mode.CONFIRM, () => {
// console.log("messages skipped");
// this.showMessages = false;
// updateNextPokemon(0);
// }, () => {
// console.log("messages shown");
// this.showMessages = true;
// updateNextPokemon(0);
// }
// );
// this.scene.ui.showText(`${this.pokemonHatched.length} eggs hatched. Skip messages?`, null, () => {
// this.scene.ui.setModeWithoutClear(Mode.CONFIRM, () => {
// this.scene.ui.setMode(Mode.MESSAGE);
// this.showMessages = false;
// updateNextPokemon(0);
// }, () => {
// this.scene.ui.setMode(Mode.MESSAGE);
// this.showMessages = true;
// updateNextPokemon(0);
// }
// });
}
// updatePokemon(pokemon: PlayerPokemon, eggMoveIndex: integer, showMessage : boolean = false) {
// console.log(pokemon);
// return new Promise<void>(resolve => {
// // this.scene.ui.showText(`${this.pokemonHatched[0].name}`, 0);
// this.scene.gameData.setPokemonCaught(pokemon, true, true, showMessage).then(() => {
// //TODO pass through egg move updates
// // console.log("set IVs");
// this.scene.gameData.updateSpeciesDexIvs(pokemon.species.speciesId, pokemon.ivs);
// // console.log("set egg moves");
// this.scene.gameData.setEggMoveUnlocked(pokemon.species, eggMoveIndex, showMessage).then((value) => {
// if (value) {
// this.eggMoveUnlocks.push(true);
// console.log("new egg move?");
// } else {
// this.eggMoveUnlocks.push(false);
// }
// resolve();
// });
// });
// });
// }
end() {
console.log("ended egg hatch summary phase");
this.scene.tweens.add({
duration: Utils.fixedInt(250),
targets: this.eggHatchOverlay,
alpha: 0,
ease: "Cubic.easeOut"
});
this.eggHatchHandler.clear();
this.scene.time.delayedCall(250, () => this.scene.setModifiersVisible(true));
super.end();
}
}

View File

@ -3,10 +3,11 @@ import { Egg, EGG_SEED } from "#app/data/egg.js";
import { Phase } from "#app/phase.js";
import i18next from "i18next";
import Overrides from "#app/overrides";
import { EggHatchData, EggHatchPhase, EggSummaryPhase } from "./egg-hatch-phase";
import { EggHatchData, EggHatchPhase } from "./egg-hatch-phase";
import { Mode } from "#app/ui/ui.js";
import { achvs } from "#app/system/achv.js";
import { PlayerPokemon } from "#app/field/pokemon.js";
import { EggSummaryPhase } from "./egg-summary-phase";
export class EggLapsePhase extends Phase {
@ -26,14 +27,15 @@ export class EggLapsePhase extends Phase {
this.eggHatchData= [];
if (eggsToHatchCount > 0) {
if (eggsToHatchCount >= 1) {
if (eggsToHatchCount >= 5) {
this.scene.ui.showText(i18next.t("battle:eggHatching"), 0, () => {
// show prompt for skip
this.scene.ui.showText("Lots of eggs ?", 0);
this.scene.ui.showText("Skip to egg summary?", 0);
this.scene.ui.setModeWithoutClear(Mode.CONFIRM, () => {
for (const egg of eggsToHatch) {
this.hatchEggSilently(egg);
}
this.scene.unshiftPhase(new EggSummaryPhase(this.scene, this.eggHatchData));
this.end();
}, () => {
@ -41,6 +43,7 @@ export class EggLapsePhase extends Phase {
this.scene.unshiftPhase(new EggHatchPhase(this.scene, this, egg, eggsToHatchCount));
eggsToHatchCount--;
}
this.scene.unshiftPhase(new EggSummaryPhase(this.scene, this.eggHatchData));
this.end();
}
@ -52,6 +55,7 @@ export class EggLapsePhase extends Phase {
this.scene.unshiftPhase(new EggHatchPhase(this.scene, this, egg, eggsToHatchCount));
eggsToHatchCount--;
}
this.scene.unshiftPhase(new EggSummaryPhase(this.scene, this.eggHatchData));
this.end();
}
@ -107,6 +111,7 @@ export class EggLapsePhase extends Phase {
this.scene.executeWithSeedOffset(() => {
ret = egg.generatePlayerPokemon(this.scene);
newHatchData = new EggHatchData(this.scene, ret, egg.eggMoveIndex);
newHatchData.setDex();
this.eggHatchData.push(newHatchData);
}, egg.id, EGG_SEED.toString());

View File

@ -0,0 +1,50 @@
import BattleScene from "#app/battle-scene.js";
import { Phase } from "#app/phase.js";
import { EggHatchData } from "./egg-hatch-phase";
import { Mode } from "#app/ui/ui.js";
import EggHatchSceneHandler from "#app/ui/egg-hatch-scene-handler.js";
export class EggSummaryPhase extends Phase {
private eggHatchData: EggHatchData[];
private eggHatchHandler: EggHatchSceneHandler;
private eggHatchOverlay: Phaser.GameObjects.Rectangle;
constructor(scene: BattleScene, eggHatchData: EggHatchData[]) {
super(scene);
this.eggHatchData = eggHatchData;
}
start() {
super.start();
const updateNextPokemon = (i: integer) => {
console.log(i);
if (i >= this.eggHatchData.length) {
console.log("displayed all pokemon");
this.scene.ui.setModeForceTransition(Mode.EGG_HATCH_SUMMARY, this.eggHatchData).then(() => {
this.scene.fadeOutBgm(null, false);
this.eggHatchHandler = this.scene.ui.getHandler() as EggHatchSceneHandler;
});
} else {
this.eggHatchData[i].updatePokemon().then(() => {
console.log("updating next pokemon");
if (i < this.eggHatchData.length) {
updateNextPokemon(i + 1);
}
});
}
};
updateNextPokemon(0);
}
end() {
console.log("ended egg hatch summary phase");
this.eggHatchHandler.clear();
// this.scene.time.delayedCall(250, () => this.scene.setModifiersVisible(true));
super.end();
}
}

View File

@ -8,7 +8,8 @@ import { Gender } from "#app/data/gender.js";
import { getVariantTint } from "#app/data/variant.js";
import { EggTier } from "#app/enums/egg-type.js";
import PokemonHatchInfoContainer from "./pokemon-hatch-info-container";
import { EggHatchData, EggSummaryPhase } from "#app/phases/egg-hatch-phase.js";
import { EggHatchData } from "#app/phases/egg-hatch-phase.js";
import { EggSummaryPhase } from "#app/phases/egg-summary-phase.js";
export default class EggSummaryUiHandler extends MessageUiHandler {
private pokemonListContainer: Phaser.GameObjects.Container;

View File

@ -164,10 +164,10 @@ export default class UI extends Phaser.GameObjects.Container {
new SaveSlotSelectUiHandler(scene),
new PartyUiHandler(scene),
new SummaryUiHandler(scene),
new EggSummaryUiHandler(scene),
new StarterSelectUiHandler(scene),
new EvolutionSceneHandler(scene),
new EggHatchSceneHandler(scene),
new EggSummaryUiHandler(scene),
new ConfirmUiHandler(scene),
new OptionSelectUiHandler(scene),
new MenuUiHandler(scene),