Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QoL] Summary option when new Pokemon caught and party is full #2242

Merged
merged 13 commits into from
Jul 5, 2024
Merged
16 changes: 12 additions & 4 deletions src/phases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4890,7 +4890,9 @@
});
}
},
onComplete: () => this.catch()
onComplete: () => {
this.scene.unshiftPhase(new VictoryPhase(this.scene, this.battlerIndex)); this.scene.gameData.setPokemonCaught(pokemon); this.catch();
}
frutescens marked this conversation as resolved.
Show resolved Hide resolved
});
};

Expand Down Expand Up @@ -4931,7 +4933,6 @@

catch() {
const pokemon = this.getPokemon() as EnemyPokemon;
this.scene.unshiftPhase(new VictoryPhase(this.scene, this.battlerIndex));

const speciesForm = !pokemon.fusionSpecies ? pokemon.getSpeciesForm() : pokemon.getFusionSpeciesForm();

Expand Down Expand Up @@ -4985,12 +4986,19 @@
}
});
};
Promise.all([pokemon.hideInfo(), this.scene.gameData.setPokemonCaught(pokemon)]).then(() => {

Check failure on line 4989 in src/phases.ts

View workflow job for this annotation

GitHub Actions / Run linters

Trailing spaces not allowed
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();
frutescens marked this conversation as resolved.
Show resolved Hide resolved
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) {
Expand Down
41 changes: 39 additions & 2 deletions src/ui/confirm-ui-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down Expand Up @@ -54,7 +92,6 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler {

return true;
}

return false;
}

Expand Down
5 changes: 3 additions & 2 deletions src/ui/pokemon-info-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,14 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container {
});
}

makeRoomForConfirmUi(speedMultiplier: number = 1): Promise<void> {
makeRoomForConfirmUi(speedMultiplier: number = 1, fromCatch: boolean = false): Promise<void> {
const xPosition = fromCatch ? this.initialX - this.infoWindowWidth - 65 : this.initialX - this.infoWindowWidth - ConfirmUiHandler.windowWidth;
return new Promise<void>(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();
}
Expand Down
8 changes: 7 additions & 1 deletion src/ui/summary-ui-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,11 @@ export default class SummaryUiHandler extends UiHandler {
if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) {
this.hideMoveSelect();
} else {
ui.setMode(Mode.PARTY);
if (ui.getMessageHandler().onActionInput) {
ui.setMode(Mode.MESSAGE);
} else {
ui.setMode(Mode.PARTY);
}
}
success = true;
} else {
Expand All @@ -495,6 +499,8 @@ export default class SummaryUiHandler extends UiHandler {
case Button.DOWN:
if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) {
break;
} else if (ui.getMessageHandler().onActionInput) {
break;
}
const isDown = button === Button.DOWN;
const party = this.scene.getParty();
Expand Down
Loading