Fix some bugs with double battle switching
parent
95f35fd2f7
commit
47fd9985c8
|
@ -453,6 +453,15 @@ export class SummonPhase extends PartyMemberPokemonPhase {
|
||||||
}
|
}
|
||||||
|
|
||||||
preSummon(): void {
|
preSummon(): void {
|
||||||
|
const partyMember = this.getPokemon();
|
||||||
|
if (partyMember.isFainted()) {
|
||||||
|
const party = this.scene.getParty();
|
||||||
|
const nonFaintedIndex = party.slice(this.partyMemberIndex).findIndex(p => !p.isFainted()) + this.partyMemberIndex;
|
||||||
|
const nonFaintedPartyMember = party[nonFaintedIndex];
|
||||||
|
party[nonFaintedIndex] = partyMember;
|
||||||
|
party[this.partyMemberIndex] = nonFaintedPartyMember;
|
||||||
|
}
|
||||||
|
|
||||||
this.scene.ui.showText(`Go! ${this.getPokemon().name}!`);
|
this.scene.ui.showText(`Go! ${this.getPokemon().name}!`);
|
||||||
this.scene.trainer.play('trainer_m_pb');
|
this.scene.trainer.play('trainer_m_pb');
|
||||||
this.scene.tweens.add({
|
this.scene.tweens.add({
|
||||||
|
@ -478,8 +487,6 @@ export class SummonPhase extends PartyMemberPokemonPhase {
|
||||||
|
|
||||||
const fpOffset = playerPokemon.getFieldPositionOffset();
|
const fpOffset = playerPokemon.getFieldPositionOffset();
|
||||||
|
|
||||||
console.log(fpOffset);
|
|
||||||
|
|
||||||
pokeball.setVisible(true);
|
pokeball.setVisible(true);
|
||||||
|
|
||||||
this.scene.tweens.add({
|
this.scene.tweens.add({
|
||||||
|
@ -563,7 +570,7 @@ export class SwitchSummonPhase extends SummonPhase {
|
||||||
}
|
}
|
||||||
|
|
||||||
preSummon(): void {
|
preSummon(): void {
|
||||||
if (!this.doReturn) {
|
if (!this.doReturn || !this.scene.getParty()[this.slotIndex]) {
|
||||||
this.switchAndSummon();
|
this.switchAndSummon();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -594,7 +601,7 @@ export class SwitchSummonPhase extends SummonPhase {
|
||||||
const party = this.scene.getParty();
|
const party = this.scene.getParty();
|
||||||
const switchedPokemon = party[this.slotIndex];
|
const switchedPokemon = party[this.slotIndex];
|
||||||
this.lastPokemon = this.getPokemon();
|
this.lastPokemon = this.getPokemon();
|
||||||
if (this.batonPass) {
|
if (this.batonPass && switchedPokemon) {
|
||||||
this.scene.getEnemyField().forEach(enemyPokemon => enemyPokemon.transferTagsBySourceId(this.lastPokemon.id, switchedPokemon.id));
|
this.scene.getEnemyField().forEach(enemyPokemon => enemyPokemon.transferTagsBySourceId(this.lastPokemon.id, switchedPokemon.id));
|
||||||
if (!this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier && (m as SwitchEffectTransferModifier).pokemonId === switchedPokemon.id)) {
|
if (!this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier && (m as SwitchEffectTransferModifier).pokemonId === switchedPokemon.id)) {
|
||||||
const batonPassModifier = this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier
|
const batonPassModifier = this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier
|
||||||
|
@ -602,15 +609,20 @@ export class SwitchSummonPhase extends SummonPhase {
|
||||||
this.scene.tryTransferHeldItemModifier(batonPassModifier, switchedPokemon, false, false);
|
this.scene.tryTransferHeldItemModifier(batonPassModifier, switchedPokemon, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (switchedPokemon) {
|
||||||
party[this.slotIndex] = this.lastPokemon;
|
party[this.slotIndex] = this.lastPokemon;
|
||||||
party[this.fieldIndex] = switchedPokemon;
|
party[this.fieldIndex] = switchedPokemon;
|
||||||
this.scene.ui.showText(`Go! ${switchedPokemon.name}!`);
|
this.scene.ui.showText(`Go! ${switchedPokemon.name}!`);
|
||||||
this.summon();
|
this.summon();
|
||||||
|
} else
|
||||||
|
this.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
end() {
|
end() {
|
||||||
if (this.batonPass)
|
const pokemon = this.getPokemon();
|
||||||
this.getPokemon().transferSummon(this.lastPokemon);
|
|
||||||
|
if (this.batonPass && pokemon)
|
||||||
|
pokemon.transferSummon(this.lastPokemon);
|
||||||
|
|
||||||
this.lastPokemon?.resetSummonData();
|
this.lastPokemon?.resetSummonData();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { CommandPhase } from "../battle-phases";
|
||||||
import BattleScene, { Button } from "../battle-scene";
|
import BattleScene, { Button } from "../battle-scene";
|
||||||
import { addTextObject, TextStyle } from "./text";
|
import { addTextObject, TextStyle } from "./text";
|
||||||
import { toPokemonUpperCase } from "../utils";
|
import { toPokemonUpperCase } from "../utils";
|
||||||
import { PartyUiMode } from "./party-ui-handler";
|
import PartyUiHandler, { PartyUiMode } from "./party-ui-handler";
|
||||||
import UI, { Mode } from "./ui";
|
import UI, { Mode } from "./ui";
|
||||||
import UiHandler from "./uiHandler";
|
import UiHandler from "./uiHandler";
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ export default class CommandUiHandler extends UiHandler {
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
ui.setMode(Mode.PARTY, PartyUiMode.SWITCH, (this.scene.getCurrentPhase() as CommandPhase).getPokemon().getFieldIndex());
|
ui.setMode(Mode.PARTY, PartyUiMode.SWITCH, (this.scene.getCurrentPhase() as CommandPhase).getPokemon().getFieldIndex(), null, PartyUiHandler.FilterNonFainted);
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
|
Loading…
Reference in New Issue