mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-26 02:02:20 +02:00
Refactored switchSummonPhase so that preSwitchOutAbAttr and leaveField are called at the right time
This commit is contained in:
parent
de47693a9d
commit
f2a7d0b68c
@ -52,6 +52,7 @@ export class SwitchSummonPhase extends SummonPhase {
|
|||||||
globalScene.pbTrayEnemy.showPbTray(globalScene.getEnemyParty());
|
globalScene.pbTrayEnemy.showPbTray(globalScene.getEnemyParty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log("a");
|
||||||
|
|
||||||
if (!this.doReturn || (this.slotIndex !== -1 && !(this.player ? globalScene.getPlayerParty() : globalScene.getEnemyParty())[this.slotIndex])) {
|
if (!this.doReturn || (this.slotIndex !== -1 && !(this.player ? globalScene.getPlayerParty() : globalScene.getEnemyParty())[this.slotIndex])) {
|
||||||
if (this.player) {
|
if (this.player) {
|
||||||
@ -61,6 +62,7 @@ export class SwitchSummonPhase extends SummonPhase {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log("b");
|
||||||
|
|
||||||
const pokemon = this.getPokemon();
|
const pokemon = this.getPokemon();
|
||||||
(this.player ? globalScene.getEnemyField() : globalScene.getPlayerField()).forEach(enemyPokemon => enemyPokemon.removeTagsBySourceId(pokemon.id));
|
(this.player ? globalScene.getEnemyField() : globalScene.getPlayerField()).forEach(enemyPokemon => enemyPokemon.removeTagsBySourceId(pokemon.id));
|
||||||
@ -77,6 +79,9 @@ export class SwitchSummonPhase extends SummonPhase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log("c");
|
||||||
|
|
||||||
|
console.log(pokemon.name, pokemon.isOnField(), pokemon.canApplyAbility());
|
||||||
|
|
||||||
globalScene.ui.showText(this.player ?
|
globalScene.ui.showText(this.player ?
|
||||||
i18next.t("battle:playerComeBack", { pokemonName: getPokemonNameWithAffix(pokemon) }) :
|
i18next.t("battle:playerComeBack", { pokemonName: getPokemonNameWithAffix(pokemon) }) :
|
||||||
@ -95,16 +100,16 @@ export class SwitchSummonPhase extends SummonPhase {
|
|||||||
scale: 0.5,
|
scale: 0.5,
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
globalScene.time.delayedCall(750, () => this.switchAndSummon());
|
globalScene.time.delayedCall(750, () => this.switchAndSummon());
|
||||||
pokemon.leaveField(this.switchType === SwitchType.SWITCH, false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log("d");
|
||||||
}
|
}
|
||||||
|
|
||||||
switchAndSummon() {
|
switchAndSummon() {
|
||||||
const party = this.player ? this.getParty() : globalScene.getEnemyParty();
|
const party = this.player ? this.getParty() : globalScene.getEnemyParty();
|
||||||
const switchedInPokemon = party[this.slotIndex];
|
const switchedInPokemon = party[this.slotIndex];
|
||||||
this.lastPokemon = this.getPokemon();
|
this.lastPokemon = this.getPokemon();
|
||||||
applyPreSwitchOutAbAttrs(PreSwitchOutAbAttr, this.lastPokemon);
|
console.log(this.lastPokemon.name, this.lastPokemon.isOnField(), this.lastPokemon.canApplyAbility());
|
||||||
if (this.switchType === SwitchType.BATON_PASS && switchedInPokemon) {
|
if (this.switchType === SwitchType.BATON_PASS && switchedInPokemon) {
|
||||||
(this.player ? globalScene.getEnemyField() : globalScene.getPlayerField()).forEach(enemyPokemon => enemyPokemon.transferTagsBySourceId(this.lastPokemon.id, switchedInPokemon.id));
|
(this.player ? globalScene.getEnemyField() : globalScene.getPlayerField()).forEach(enemyPokemon => enemyPokemon.transferTagsBySourceId(this.lastPokemon.id, switchedInPokemon.id));
|
||||||
if (!globalScene.findModifier(m => m instanceof SwitchEffectTransferModifier && (m as SwitchEffectTransferModifier).pokemonId === switchedInPokemon.id)) {
|
if (!globalScene.findModifier(m => m instanceof SwitchEffectTransferModifier && (m as SwitchEffectTransferModifier).pokemonId === switchedInPokemon.id)) {
|
||||||
@ -116,6 +121,7 @@ export class SwitchSummonPhase extends SummonPhase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (switchedInPokemon) {
|
if (switchedInPokemon) {
|
||||||
|
applyPreSwitchOutAbAttrs(PreSwitchOutAbAttr, this.lastPokemon);
|
||||||
party[this.slotIndex] = this.lastPokemon;
|
party[this.slotIndex] = this.lastPokemon;
|
||||||
party[this.fieldIndex] = switchedInPokemon;
|
party[this.fieldIndex] = switchedInPokemon;
|
||||||
const showTextAndSummon = () => {
|
const showTextAndSummon = () => {
|
||||||
@ -140,6 +146,7 @@ export class SwitchSummonPhase extends SummonPhase {
|
|||||||
} else {
|
} else {
|
||||||
switchedInPokemon.resetSummonData();
|
switchedInPokemon.resetSummonData();
|
||||||
}
|
}
|
||||||
|
this.lastPokemon.leaveField(true, false);
|
||||||
this.summon();
|
this.summon();
|
||||||
};
|
};
|
||||||
if (this.player) {
|
if (this.player) {
|
||||||
|
Loading…
Reference in New Issue
Block a user