Rework logic for defeat ability trigger

pull/26/head
Flashfyre 2024-04-02 10:13:00 -04:00
parent 53c0d501cc
commit d9ebf99cdd
1 changed files with 7 additions and 2 deletions

View File

@ -2979,12 +2979,17 @@ export class VictoryPhase extends PokemonPhase {
if (exp) {
const partyMemberIndex = party.indexOf(expPartyMembers[pm]);
this.scene.unshiftPhase(expPartyMembers[pm].isOnField() ? new ExpPhase(this.scene, partyMemberIndex, exp) : new ShowPartyExpBarPhase(this.scene, partyMemberIndex, exp));
if (expPartyMembers[pm].isOnField())
applyPostVictoryAbAttrs(PostVictoryAbAttr, expPartyMembers[pm]);
}
}
}
const defeatedPokemon = this.getPokemon();
if (defeatedPokemon.turnData?.attacksReceived?.length) {
const defeatSource = this.scene.getPokemonById(defeatedPokemon.turnData.attacksReceived[0].sourceId);
if (defeatSource?.isOnField())
applyPostVictoryAbAttrs(PostVictoryAbAttr, defeatSource);
}
if (!this.scene.getEnemyParty().find(p => this.scene.currentBattle.battleType ? !p?.isFainted(true) : p.isOnField())) {
this.scene.pushPhase(new BattleEndPhase(this.scene));
if (this.scene.currentBattle.battleType === BattleType.TRAINER)