Skip to content

Commit

Permalink
Fix Post-Summon abilities not applying after switch prompt (#4908)
Browse files Browse the repository at this point in the history
  • Loading branch information
innerthunder authored Dec 1, 2024
1 parent d5146a5 commit 80555be
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/phases/check-switch-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { getPokemonNameWithAffix } from "#app/messages";
import { Mode } from "#app/ui/ui";
import i18next from "i18next";
import { BattlePhase } from "./battle-phase";
import { PostSummonPhase } from "./post-summon-phase";
import { SummonMissingPhase } from "./summon-missing-phase";
import { SwitchPhase } from "./switch-phase";
import { SwitchType } from "#enums/switch-type";
Expand Down Expand Up @@ -54,7 +53,6 @@ export class CheckSwitchPhase extends BattlePhase {
this.scene.ui.showText(i18next.t("battle:switchQuestion", { pokemonName: this.useName ? getPokemonNameWithAffix(pokemon) : i18next.t("battle:pokemon") }), null, () => {
this.scene.ui.setMode(Mode.CONFIRM, () => {
this.scene.ui.setMode(Mode.MESSAGE);
this.scene.tryRemovePhase(p => p instanceof PostSummonPhase && p.player && p.fieldIndex === this.fieldIndex);
this.scene.unshiftPhase(new SwitchPhase(this.scene, SwitchType.INITIAL_SWITCH, this.fieldIndex, false, true));
this.end();
}, () => {
Expand Down
9 changes: 6 additions & 3 deletions src/phases/post-summon-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ export class PostSummonPhase extends PokemonPhase {
pokemon.lapseTag(BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON);
}

applyPostSummonAbAttrs(PostSummonAbAttr, pokemon).then(() => this.end());
applyPostSummonAbAttrs(PostSummonAbAttr, pokemon)
.then(() => {
const field = pokemon.isPlayer() ? this.scene.getPlayerField() : this.scene.getEnemyField();
field.forEach((p) => applyAbAttrs(CommanderAbAttr, p, null, false));

const field = pokemon.isPlayer() ? this.scene.getPlayerField() : this.scene.getEnemyField();
field.forEach((p) => applyAbAttrs(CommanderAbAttr, p, null, false));
this.end();
});
}
}
4 changes: 4 additions & 0 deletions src/phases/switch-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PartyUiHandler, { PartyOption, PartyUiMode } from "#app/ui/party-ui-handl
import { Mode } from "#app/ui/ui";
import { SwitchType } from "#enums/switch-type";
import { BattlePhase } from "./battle-phase";
import { PostSummonPhase } from "./post-summon-phase";
import { SwitchSummonPhase } from "./switch-summon-phase";

/**
Expand Down Expand Up @@ -63,6 +64,9 @@ export class SwitchPhase extends BattlePhase {

this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, fieldIndex, (slotIndex: integer, option: PartyOption) => {
if (slotIndex >= this.scene.currentBattle.getBattlerCount() && slotIndex < 6) {
// Remove any pre-existing PostSummonPhase under the same field index.
// Pre-existing PostSummonPhases may occur when this phase is invoked during a prompt to switch at the start of a wave.
this.scene.tryRemovePhase(p => p instanceof PostSummonPhase && p.player && p.fieldIndex === this.fieldIndex);
const switchType = (option === PartyOption.PASS_BATON) ? SwitchType.BATON_PASS : this.switchType;
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, switchType, fieldIndex, slotIndex, this.doReturn));
}
Expand Down

0 comments on commit 80555be

Please sign in to comment.