From 759e4d0288700445d532d519d3d9f291d867fecb Mon Sep 17 00:00:00 2001 From: Mumble Date: Fri, 5 Jul 2024 10:46:36 -0700 Subject: [PATCH] [QoL] Summary option when new Pokemon caught and party is full (#2242) * Option to view Summary before adding new Pokemon to party * Fixed issues described by HopsWas * Adjusted makeRoomForConfirmUi to improve window spacing * Fixed ESLint issue + addressed OrangeRed review * Fixed Github pages issue * Removed duplicate unshiftPhase * Fixed phase order --------- Co-authored-by: Frutescens --- src/phases.ts | 17 +++++++++---- src/ui/confirm-ui-handler.ts | 41 ++++++++++++++++++++++++++++++-- src/ui/pokemon-info-container.ts | 5 ++-- src/ui/summary-ui-handler.ts | 11 +++++++-- 4 files changed, 64 insertions(+), 10 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index df7314e6285..40a2683b09d 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -4890,7 +4890,10 @@ export class AttemptCapturePhase extends PokemonPhase { }); } }, - onComplete: () => this.catch() + onComplete: () => { + this.scene.gameData.setPokemonCaught(pokemon); + this.catch(); + } }); }; @@ -4931,7 +4934,6 @@ export class AttemptCapturePhase extends PokemonPhase { catch() { const pokemon = this.getPokemon() as EnemyPokemon; - this.scene.unshiftPhase(new VictoryPhase(this.scene, this.battlerIndex)); const speciesForm = !pokemon.fusionSpecies ? pokemon.getSpeciesForm() : pokemon.getFusionSpeciesForm(); @@ -4957,6 +4959,7 @@ export class AttemptCapturePhase extends PokemonPhase { this.scene.ui.showText(i18next.t("battle:pokemonCaught", { pokemonName: pokemon.name }), null, () => { const end = () => { + this.scene.unshiftPhase(new VictoryPhase(this.scene, this.battlerIndex)); this.scene.pokemonInfoContainer.hide(); this.removePb(); this.end(); @@ -4985,12 +4988,18 @@ export class AttemptCapturePhase extends PokemonPhase { } }); }; - Promise.all([pokemon.hideInfo(), this.scene.gameData.setPokemonCaught(pokemon)]).then(() => { + Promise.all([pokemon.hideInfo()]).then(() => { if (this.scene.getParty().length === 6) { const promptRelease = () => { this.scene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.name }), null, () => { - this.scene.pokemonInfoContainer.makeRoomForConfirmUi(); + this.scene.pokemonInfoContainer.makeRoomForConfirmUi(1, true); this.scene.ui.setMode(Mode.CONFIRM, () => { + const newPokemon = this.scene.addPlayerPokemon(pokemon.species, pokemon.level, pokemon.abilityIndex, pokemon.formIndex, pokemon.gender, pokemon.shiny, pokemon.variant, pokemon.ivs, pokemon.nature, pokemon); + this.scene.ui.setMode(Mode.SUMMARY, newPokemon).then(() => { + this.catch(); + return; + }); + }, () => { this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, this.fieldIndex, (slotIndex: integer, _option: PartyOption) => { this.scene.ui.setMode(Mode.MESSAGE).then(() => { if (slotIndex < 6) { diff --git a/src/ui/confirm-ui-handler.ts b/src/ui/confirm-ui-handler.ts index 953ed4972ac..49c4782a8a7 100644 --- a/src/ui/confirm-ui-handler.ts +++ b/src/ui/confirm-ui-handler.ts @@ -20,7 +20,45 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler { } show(args: any[]): boolean { - if (args.length >= 2 && args[0] instanceof Function && args[1] instanceof Function) { + if (args.length === 3 && args[0].toString().includes("newPokemon")) { + const config: OptionSelectConfig = { + options: [ + { + label: i18next.t("partyUiHandler:SUMMARY"), + handler: () => { + args[0](); + return false; + }, + }, { + label: i18next.t("menu:yes"), + handler: () => { + args[1](); + return true; + } + }, { + label: i18next.t("menu:no"), + handler: () => { + args[2](); + return true; + } + } + ], + delay: args.length >= 7 && args[6] !== null ? args[6] as integer : 0 + }; + + super.show([ config ]); + + this.switchCheck = args.length >= 4 && args[3] !== null && args[3] as boolean; + + const xOffset = (args.length >= 5 && args[4] !== null ? args[4] as number : 0); + const yOffset = (args.length >= 6 && args[5] !== null ? args[5] as number : 0); + + this.optionSelectContainer.setPosition((this.scene.game.canvas.width / 6) - 1 + xOffset, -48 + yOffset); + + this.setCursor(this.switchCheck ? this.switchCheckCursor : 0); + + return true; + } else if (args.length >= 2 && args[0] instanceof Function && args[1] instanceof Function) { const config: OptionSelectConfig = { options: [ { @@ -54,7 +92,6 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler { return true; } - return false; } diff --git a/src/ui/pokemon-info-container.ts b/src/ui/pokemon-info-container.ts index 9f4df2b20b4..1e958ae53b7 100644 --- a/src/ui/pokemon-info-container.ts +++ b/src/ui/pokemon-info-container.ts @@ -364,13 +364,14 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { }); } - makeRoomForConfirmUi(speedMultiplier: number = 1): Promise { + makeRoomForConfirmUi(speedMultiplier: number = 1, fromCatch: boolean = false): Promise { + const xPosition = fromCatch ? this.initialX - this.infoWindowWidth - 65 : this.initialX - this.infoWindowWidth - ConfirmUiHandler.windowWidth; return new Promise(resolve => { this.scene.tweens.add({ targets: this, duration: Utils.fixedInt(Math.floor(150 / speedMultiplier)), ease: "Cubic.easeInOut", - x: this.initialX - this.infoWindowWidth - ConfirmUiHandler.windowWidth, + x: xPosition, onComplete: () => { resolve(); } diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index ae94951bc4c..33a74c54938 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -397,7 +397,7 @@ export default class SummaryUiHandler extends UiHandler { } const ui = this.getUi(); - + const fromPartyMode = ui.handlers[Mode.PARTY].active; let success = false; let error = false; @@ -485,7 +485,12 @@ export default class SummaryUiHandler extends UiHandler { if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) { this.hideMoveSelect(); } else { - ui.setMode(Mode.PARTY); + + if (!fromPartyMode) { + ui.setMode(Mode.MESSAGE); + } else { + ui.setMode(Mode.PARTY); + } } success = true; } else { @@ -495,6 +500,8 @@ export default class SummaryUiHandler extends UiHandler { case Button.DOWN: if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) { break; + } else if (!fromPartyMode) { + break; } const isDown = button === Button.DOWN; const party = this.scene.getParty();