From a6d4beb02a87c3ac03f8a0301861e8fd1007992b Mon Sep 17 00:00:00 2001 From: Greenlamp Date: Mon, 6 May 2024 21:18:49 +0200 Subject: [PATCH] last line of code for this feature. will revert everything after. --- src/phases.ts | 8 ++++++-- src/ui/party-ui-handler.ts | 21 +++++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index 5e46133ed48..d4b6657f0f4 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1788,7 +1788,7 @@ export class CommandPhase extends FieldPhase { if (!batonPass) enemyField.forEach(enemyPokemon => applyCheckTrappedAbAttrs(CheckTrappedAbAttr, enemyPokemon, trapped)); if (batonPass || (!trapTag && !trapped.value)) { - this.scene.currentBattle.turnCommands[this.fieldIndex] = isSwitch + this.scene.currentBattle.turnCommands[args[1]] = isSwitch ? { command: Command.POKEMON, cursor: cursor, args: args } : { command: Command.RUN }; success = true; @@ -1955,11 +1955,15 @@ export class TurnStartPhase extends FieldPhase { start() { super.start(); + const field = this.scene.getField(); const order = this.getOrder(); - const moveOrder = order.slice(0); + console.log('field', field); + console.log('moveOrder', moveOrder); + // if (this.scene.currentBattle.turn === 1 && field.) + moveOrder.sort((a, b) => { const aCommand = this.scene.currentBattle.turnCommands[a]; const bCommand = this.scene.currentBattle.turnCommands[b]; diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index dc57dd9e7a1..e0c16fc0b67 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -95,6 +95,7 @@ export default class PartyUiHandler extends MessageUiHandler { private moveSelectFilter: PokemonMoveSelectFilter; private tmMoveId: Moves; private showMovePp: boolean; + private slots: Map = new Map(); private iconAnimHandler: PokemonIconAnimHandler; @@ -291,8 +292,11 @@ export default class PartyUiHandler extends MessageUiHandler { this.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeItemTrigger, false, true); break; } - } else if (this.cursor) - (this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, this.cursor, option === PartyOption.PASS_BATON); + } else if (this.cursor) { + this.doSwitch(this.cursor, option); + // (this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, this.cursor, option === PartyOption.PASS_BATON, option); + } + } if (this.partyUiMode !== PartyUiMode.MODIFIER && this.partyUiMode !== PartyUiMode.TM_MODIFIER && this.partyUiMode !== PartyUiMode.MOVE_MODIFIER) ui.playSelect(); @@ -370,7 +374,11 @@ export default class PartyUiHandler extends MessageUiHandler { } else if (this.partyUiMode === PartyUiMode.FAINT_SWITCH) ui.playError(); else if (this.cursor === 6) { - console.log('DONE'); + console.log('done'); + if (this.slots[PartyOption.SEND_OUT_1]) + (this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, this.slots[PartyOption.SEND_OUT_1], false, PartyOption.SEND_OUT_1); + if (this.slots[PartyOption.SEND_OUT_2]) + (this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, this.slots[PartyOption.SEND_OUT_2], false, PartyOption.SEND_OUT_2); } else return this.processInput(Button.CANCEL); return true; @@ -533,7 +541,7 @@ export default class PartyUiHandler extends MessageUiHandler { } showOptions() { - if (this.cursor === 6) + if (this.cursor === 6 || this.cursor === 7) return; this.optionsMode = true; @@ -752,6 +760,11 @@ export default class PartyUiHandler extends MessageUiHandler { this.partySlots[this.transferCursor].setTransfer(false); } + doSwitch(slotIndex: integer, target: integer): void { + if (target !== PartyOption.SEND_OUT_1 && target !== PartyOption.SEND_OUT_2) return; + this.slots[target] = slotIndex; + } + doRelease(slotIndex: integer): void { this.showText(this.getReleaseMessage(this.scene.getParty()[slotIndex].name), null, () => { this.clearPartySlots();