Fix various bugs related to switch out attack moves

pull/14/head
Flashfyre 2023-12-30 22:01:46 -05:00
parent 8063472bac
commit 20569b0317
2 changed files with 15 additions and 12 deletions

View File

@ -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);

View File

@ -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.setVisible(false);
if (switchOutTarget.hp) {
switchOutTarget.hideInfo().then(() => switchOutTarget.destroy()); switchOutTarget.hideInfo().then(() => switchOutTarget.destroy());
switchOutTarget.hp = 0; switchOutTarget.scene.field.remove(switchOutTarget);
switchOutTarget.trySetStatus(StatusEffect.FAINT);
user.scene.queueMessage(getPokemonMessage(switchOutTarget, ' fled!'), null, true, 500); user.scene.queueMessage(getPokemonMessage(switchOutTarget, ' fled!'), null, true, 500);
if (!switchOutTarget.getAlly()?.isActive(true)) {
user.scene.clearEnemyHeldItemModifiers();
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;