Fix various bugs related to switch out attack moves
parent
8063472bac
commit
20569b0317
|
@ -101,6 +101,7 @@ export class CheckLoadPhase extends BattlePhase {
|
||||||
if (!this.scene.gameData.hasSession())
|
if (!this.scene.gameData.hasSession())
|
||||||
return this.end();
|
return this.end();
|
||||||
|
|
||||||
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
this.scene.ui.showText('You currently have a session in progress.\nWould you like to continue where you left off?', null, () => {
|
this.scene.ui.showText('You currently have a session in progress.\nWould you like to continue where you left off?', null, () => {
|
||||||
this.scene.ui.setMode(Mode.CONFIRM, () => {
|
this.scene.ui.setMode(Mode.CONFIRM, () => {
|
||||||
this.scene.ui.setMode(Mode.MESSAGE);
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
|
|
|
@ -2581,6 +2581,8 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
|
if (move.category !== MoveCategory.STATUS && !this.getSwitchOutCondition()(user, target, move))
|
||||||
|
return resolve(false);
|
||||||
const switchOutTarget = this.user ? user : target;
|
const switchOutTarget = this.user ? user : target;
|
||||||
if (switchOutTarget instanceof PlayerPokemon) {
|
if (switchOutTarget instanceof PlayerPokemon) {
|
||||||
(switchOutTarget as PlayerPokemon).switchOut(this.batonPass).then(() => resolve(true));
|
(switchOutTarget as PlayerPokemon).switchOut(this.batonPass).then(() => resolve(true));
|
||||||
|
@ -2590,21 +2592,17 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||||
switchOutTarget.resetSummonData();
|
switchOutTarget.resetSummonData();
|
||||||
switchOutTarget.hideInfo();
|
switchOutTarget.hideInfo();
|
||||||
switchOutTarget.setVisible(false);
|
switchOutTarget.setVisible(false);
|
||||||
|
switchOutTarget.scene.field.remove(switchOutTarget);
|
||||||
|
|
||||||
if (switchOutTarget.hp)
|
if (switchOutTarget.hp)
|
||||||
user.scene.unshiftPhase(new SwitchSummonPhase(user.scene, switchOutTarget.getFieldIndex(), user.scene.currentBattle.trainer.getNextSummonIndex(), false, this.batonPass, false));
|
user.scene.unshiftPhase(new SwitchSummonPhase(user.scene, switchOutTarget.getFieldIndex(), user.scene.currentBattle.trainer.getNextSummonIndex(), false, this.batonPass, false));
|
||||||
} else {
|
} else {
|
||||||
switchOutTarget.hideInfo().then(() => switchOutTarget.destroy());
|
switchOutTarget.setVisible(false);
|
||||||
switchOutTarget.hp = 0;
|
|
||||||
switchOutTarget.trySetStatus(StatusEffect.FAINT);
|
|
||||||
|
|
||||||
user.scene.queueMessage(getPokemonMessage(switchOutTarget, ' fled!'), null, true, 500);
|
if (switchOutTarget.hp) {
|
||||||
|
switchOutTarget.hideInfo().then(() => switchOutTarget.destroy());
|
||||||
if (!switchOutTarget.getAlly()?.isActive(true)) {
|
switchOutTarget.scene.field.remove(switchOutTarget);
|
||||||
user.scene.clearEnemyHeldItemModifiers();
|
user.scene.queueMessage(getPokemonMessage(switchOutTarget, ' fled!'), null, true, 500);
|
||||||
|
|
||||||
user.scene.pushPhase(new BattleEndPhase(user.scene));
|
|
||||||
user.scene.pushPhase(new NewBattlePhase(user.scene));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2613,6 +2611,10 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||||
}
|
}
|
||||||
|
|
||||||
getCondition(): MoveCondition {
|
getCondition(): MoveCondition {
|
||||||
|
return (user, target, move) => move.category !== MoveCategory.STATUS || this.getSwitchOutCondition()(user, target, move);
|
||||||
|
}
|
||||||
|
|
||||||
|
getSwitchOutCondition(): MoveCondition {
|
||||||
return (user, target, move) => {
|
return (user, target, move) => {
|
||||||
const switchOutTarget = (this.user ? user : target);
|
const switchOutTarget = (this.user ? user : target);
|
||||||
const player = switchOutTarget instanceof PlayerPokemon;
|
const player = switchOutTarget instanceof PlayerPokemon;
|
||||||
|
|
Loading…
Reference in New Issue