From 5127d73d4f3f334330fae881b5ee3c16bc7fb04d Mon Sep 17 00:00:00 2001 From: Greenlamp Date: Sun, 5 May 2024 16:08:59 +0200 Subject: [PATCH 1/7] added settings to set battle style, either shift or set --- src/battle-scene.ts | 1 + src/phases.ts | 5 +++++ src/system/settings.ts | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 46f7b4ae0..c772f8364 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -119,6 +119,7 @@ export default class BattleScene extends SceneBase { public experimentalSprites: boolean = false; public moveAnimations: boolean = true; public expGainsSpeed: integer = 0; + public battleStyle: integer = 0; public hpBarSpeed: integer = 0; public fusionPaletteSwaps: boolean = true; public gamepadSupport: boolean = true; diff --git a/src/phases.ts b/src/phases.ts index 6f1ebc261..6fb5b1572 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1559,6 +1559,11 @@ export class CheckSwitchPhase extends BattlePhase { return; } + if (this.scene.battleStyle === 1) { + super.end(); + return; + } + this.scene.ui.showText(i18next.t('battle:switchQuestion', { pokemonName: this.useName ? pokemon.name : i18next.t('battle:pokemon') }), null, () => { this.scene.ui.setMode(Mode.CONFIRM, () => { this.scene.ui.setMode(Mode.MESSAGE); diff --git a/src/system/settings.ts b/src/system/settings.ts index e5769dfcc..2e76d21b5 100644 --- a/src/system/settings.ts +++ b/src/system/settings.ts @@ -21,6 +21,7 @@ export enum Setting { Move_Animations = "MOVE_ANIMATIONS", Show_Stats_on_Level_Up = "SHOW_LEVEL_UP_STATS", EXP_Gains_Speed = "EXP_GAINS_SPEED", + Battle_Style = "BATTLE_STYLE", HP_Bar_Speed = "HP_BAR_SPEED", Fusion_Palette_Swaps = "FUSION_PALETTE_SWAPS", Player_Gender = "PLAYER_GENDER", @@ -53,6 +54,7 @@ export const settingOptions: SettingOptions = { [Setting.Move_Animations]: [ 'Off', 'On' ], [Setting.Show_Stats_on_Level_Up]: [ 'Off', 'On' ], [Setting.EXP_Gains_Speed]: [ 'Normal', 'Fast', 'Faster', 'Skip' ], + [Setting.Battle_Style]: [ 'Shift', 'Set' ], [Setting.HP_Bar_Speed]: [ 'Normal', 'Fast', 'Faster', 'Instant' ], [Setting.Fusion_Palette_Swaps]: [ 'Off', 'On' ], [Setting.Player_Gender]: [ 'Boy', 'Girl' ], @@ -77,6 +79,7 @@ export const settingDefaults: SettingDefaults = { [Setting.Move_Animations]: 1, [Setting.Show_Stats_on_Level_Up]: 1, [Setting.EXP_Gains_Speed]: 0, + [Setting.Battle_Style]: 0, [Setting.HP_Bar_Speed]: 0, [Setting.Fusion_Palette_Swaps]: 1, [Setting.Player_Gender]: 0, @@ -134,6 +137,9 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer) case Setting.EXP_Gains_Speed: scene.expGainsSpeed = value; break; + case Setting.Battle_Style: + scene.battleStyle = value; + break; case Setting.HP_Bar_Speed: scene.hpBarSpeed = value; break; From a65c696e6924a76d8fc40ace536e7170487fef4d Mon Sep 17 00:00:00 2001 From: Greenlamp Date: Mon, 6 May 2024 12:44:50 +0200 Subject: [PATCH 2/7] added "Free switch" text when variable "hasFreeSwitch" is true and display it only when we can see the command box --- src/battle-scene.ts | 2 ++ src/battle.ts | 1 + src/ui/command-ui-handler.ts | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 1a1d9626c..9cdb29e0d 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -163,6 +163,8 @@ export default class BattleScene extends SceneBase { public waveCycleOffset: integer; public offsetGym: boolean; + public hasFreeSwitch: boolean; + public damageNumberHandler: DamageNumberHandler private spriteSparkleHandler: PokemonSpriteSparkleHandler; diff --git a/src/battle.ts b/src/battle.ts index 580bad9a5..9e3a87dc9 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -133,6 +133,7 @@ export default class Battle { incrementTurn(scene: BattleScene): void { this.turn++; + scene.hasFreeSwitch = this.turn === 1; this.turnCommands = Object.fromEntries(Utils.getEnumValues(BattlerIndex).map(bt => [ bt, null ])); this.battleSeedState = null; } diff --git a/src/ui/command-ui-handler.ts b/src/ui/command-ui-handler.ts index a27053015..f4b5e09e4 100644 --- a/src/ui/command-ui-handler.ts +++ b/src/ui/command-ui-handler.ts @@ -17,6 +17,7 @@ export enum Command { export default class CommandUiHandler extends UiHandler { private commandsContainer: Phaser.GameObjects.Container; private cursorObj: Phaser.GameObjects.Image; + private freeSwitchText: Phaser.GameObjects.Text; protected fieldIndex: integer = 0; protected cursor2: integer = 0; @@ -42,6 +43,21 @@ export default class CommandUiHandler extends UiHandler { const commandText = addTextObject(this.scene, c % 2 === 0 ? 0 : 55.8, c < 2 ? 0 : 16, commands[c], TextStyle.WINDOW); this.commandsContainer.add(commandText); } + + this.freeSwitchText = addTextObject(this.scene, -45, 25, '', TextStyle.WINDOW, {fontSize: '48px', color: '#A8E4A0'}); + this.freeSwitchText.setVisible(false); + this.commandsContainer.add(this.freeSwitchText); + } + + updateFreeSwitchText(): void { + if (!this.scene.currentBattle?.turn) return; + if (this.scene.hasFreeSwitch) { + this.freeSwitchText.setText('Free Switch'); + this.freeSwitchText.setVisible(true); + } else { + this.freeSwitchText.setText(''); + this.freeSwitchText.setVisible(false); + } } show(args: any[]): boolean { @@ -64,6 +80,7 @@ export default class CommandUiHandler extends UiHandler { messageHandler.message.setWordWrapWidth(1110); messageHandler.showText(i18next.t('commandUiHandler:actionMessage', {pokemonName: commandPhase.getPokemon().name}), 0); this.setCursor(this.getCursor()); + this.updateFreeSwitchText(); return true; } From ff562af446f131c256692d8ce829e9880fbeba51 Mon Sep 17 00:00:00 2001 From: Greenlamp Date: Mon, 6 May 2024 14:56:45 +0200 Subject: [PATCH 3/7] added Done button in pokemon selection menu and choosing which pokemon to replace --- src/phases.ts | 6 ++- src/ui/party-ui-handler.ts | 97 +++++++++++++++++++++++++++++++++----- 2 files changed, 89 insertions(+), 14 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index b966712f2..5e46133ed 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1936,8 +1936,10 @@ export class SelectTargetPhase extends PokemonPhase { if (cursor === -1) { this.scene.currentBattle.turnCommands[this.fieldIndex] = null; this.scene.unshiftPhase(new CommandPhase(this.scene, this.fieldIndex)); - } else - turnCommand.targets = [ cursor ]; + } else { + turnCommand.targets = [cursor]; + this.scene.hasFreeSwitch = false; + } if (turnCommand.command === Command.BALL && this.fieldIndex) this.scene.currentBattle.turnCommands[this.fieldIndex - 1].skip = true; this.end(); diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 8b497655a..dc57dd9e7 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -36,6 +36,8 @@ export enum PartyUiMode { export enum PartyOption { CANCEL = -1, SEND_OUT, + SEND_OUT_1, + SEND_OUT_2, PASS_BATON, APPLY, TEACH, @@ -51,7 +53,7 @@ export enum PartyOption { MOVE_1 = 3000, MOVE_2, MOVE_3, - MOVE_4 + MOVE_4, } export type PartySelectCallback = (cursor: integer, option: PartyOption) => void; @@ -70,6 +72,7 @@ export default class PartyUiHandler extends MessageUiHandler { private partySlotsContainer: Phaser.GameObjects.Container; private partySlots: PartySlot[]; private partyCancelButton: PartyCancelButton; + private partyDoneButton: PartyDoneButton; private partyMessageBox: Phaser.GameObjects.NineSlice; private optionsMode: boolean; @@ -153,10 +156,13 @@ export default class PartyUiHandler extends MessageUiHandler { this.message = partyMessageText; - const partyCancelButton = new PartyCancelButton(this.scene, 291, -16); + const partyCancelButton = new PartyCancelButton(this.scene, 291, -9); + const partyDoneButton = new PartyDoneButton(this.scene, 291, -26); partyContainer.add(partyCancelButton); + partyContainer.add(partyDoneButton); this.partyCancelButton = partyCancelButton; + this.partyDoneButton = partyDoneButton; this.optionsContainer = this.scene.add.container((this.scene.game.canvas.width / 6) - 1, -1); partyContainer.add(this.optionsContainer); @@ -363,7 +369,9 @@ export default class PartyUiHandler extends MessageUiHandler { ui.playSelect(); } else if (this.partyUiMode === PartyUiMode.FAINT_SWITCH) ui.playError(); - else + else if (this.cursor === 6) { + console.log('DONE'); + } else return this.processInput(Button.CANCEL); return true; } else if (button === Button.CANCEL) { @@ -390,26 +398,27 @@ export default class PartyUiHandler extends MessageUiHandler { switch (button) { case Button.UP: - success = this.setCursor(this.cursor ? this.cursor < 6 ? this.cursor - 1 : slotCount - 1 : 6); + if (this.cursor === 7) success = this.setCursor(6); + else success = this.setCursor(this.cursor ? this.cursor < 6 ? this.cursor - 1 : slotCount - 1 : 7); break; case Button.DOWN: - success = this.setCursor(this.cursor < 6 ? this.cursor < slotCount - 1 ? this.cursor + 1 : 6 : 0); + if (this.cursor === 6) success = this.setCursor(7); + else success = this.setCursor(this.cursor < 6 ? this.cursor < slotCount - 1 ? this.cursor + 1 : 6 : 0); break; case Button.LEFT: - if (this.cursor >= battlerCount && this.cursor <= 6) + if (this.cursor >= battlerCount && this.cursor <= 7) success = this.setCursor(0); break; case Button.RIGHT: if (slotCount === battlerCount){ success = this.setCursor(6); - break; + break; } else if (battlerCount >= 2 && slotCount > battlerCount && this.getCursor() === 0 && this.lastCursor === 1){ success = this.setCursor(2); break; - } else if (slotCount > battlerCount && this.cursor < battlerCount){ + } else if (slotCount > battlerCount && this.cursor < battlerCount) success = this.setCursor(this.lastCursor < 6 ? this.lastCursor || battlerCount : battlerCount); break; - } } } @@ -425,6 +434,8 @@ export default class PartyUiHandler extends MessageUiHandler { if (this.cursor < 6 && this.cursor >= party.length) this.cursor = party.length - 1; else if (this.cursor === 6) + this.partyDoneButton.select(); + else if (this.cursor === 7) this.partyCancelButton.select(); for (let p in party) { @@ -482,12 +493,24 @@ export default class PartyUiHandler extends MessageUiHandler { this.cursor = cursor; if (this.lastCursor < 6) this.partySlots[this.lastCursor].deselect(); - else if (this.lastCursor === 6) + else if (this.lastCursor === 6){ this.partyCancelButton.deselect(); - if (cursor < 6) + } else if (this.lastCursor === 7){ + this.partyDoneButton.deselect(); + } + if (cursor < 6) { this.partySlots[cursor].select(); - else if (cursor === 6) + this.partyCancelButton.deselect(); + this.partyDoneButton.deselect(); + } + else if (cursor === 6){ + this.partyCancelButton.deselect(); + this.partyDoneButton.select(); + } + else if (cursor === 7) { + this.partyDoneButton.deselect(); this.partyCancelButton.select(); + } } } @@ -567,6 +590,8 @@ export default class PartyUiHandler extends MessageUiHandler { case PartyUiMode.POST_BATTLE_SWITCH: if (this.cursor >= this.scene.currentBattle.getBattlerCount()) { this.options.push(PartyOption.SEND_OUT); + this.options.push(PartyOption.SEND_OUT_1); + this.options.push(PartyOption.SEND_OUT_2); if (this.partyUiMode !== PartyUiMode.FAINT_SWITCH && this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier && (m as SwitchEffectTransferModifier).pokemonId === this.scene.getPlayerField()[this.fieldIndex].id)) @@ -1058,4 +1083,52 @@ class PartyCancelButton extends Phaser.GameObjects.Container { this.partyCancelBg.setFrame('party_cancel'); this.partyCancelPb.setFrame('party_pb'); } +} + +class PartyDoneButton extends Phaser.GameObjects.Container { + private selected: boolean; + + private partyDoneBg: Phaser.GameObjects.Sprite; + private partyDonePb: Phaser.GameObjects.Sprite; + + constructor(scene: BattleScene, x: number, y: number) { + super(scene, x, y); + + this.setup(); + } + + setup() { + const partyDoneBg = this.scene.add.sprite(0, 0, 'party_cancel'); + this.add(partyDoneBg); + + this.partyDoneBg = partyDoneBg; + + const partyDonePb = this.scene.add.sprite(-17, 0, 'party_pb'); + this.add(partyDonePb); + + this.partyDonePb = partyDonePb; + + const partyCancelText = addTextObject(this.scene, -7, -6, 'Done', TextStyle.PARTY); + this.add(partyCancelText); + } + + select() { + if (this.selected) + return; + + this.selected = true; + + this.partyDoneBg.setFrame(`party_cancel_sel`); + this.partyDonePb.setFrame('party_pb_sel'); + } + + deselect() { + if (!this.selected) + return; + + this.selected = false; + + this.partyDoneBg.setFrame('party_cancel'); + this.partyDonePb.setFrame('party_pb'); + } } \ No newline at end of file From a6d4beb02a87c3ac03f8a0301861e8fd1007992b Mon Sep 17 00:00:00 2001 From: Greenlamp Date: Mon, 6 May 2024 21:18:49 +0200 Subject: [PATCH 4/7] 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 5e46133ed..d4b6657f0 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 dc57dd9e7..e0c16fc0b 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(); From f2139bb99a443b5aba0e3d8c8dedd95ef5dc6518 Mon Sep 17 00:00:00 2001 From: Greenlamp Date: Mon, 6 May 2024 21:19:16 +0200 Subject: [PATCH 5/7] Revert "last line of code for this feature. will revert everything after." This reverts commit a6d4beb02a87c3ac03f8a0301861e8fd1007992b. --- src/phases.ts | 8 ++------ src/ui/party-ui-handler.ts | 21 ++++----------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index d4b6657f0..5e46133ed 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[args[1]] = isSwitch + this.scene.currentBattle.turnCommands[this.fieldIndex] = isSwitch ? { command: Command.POKEMON, cursor: cursor, args: args } : { command: Command.RUN }; success = true; @@ -1955,14 +1955,10 @@ 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.) + const moveOrder = order.slice(0); moveOrder.sort((a, b) => { const aCommand = this.scene.currentBattle.turnCommands[a]; diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index e0c16fc0b..dc57dd9e7 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -95,7 +95,6 @@ export default class PartyUiHandler extends MessageUiHandler { private moveSelectFilter: PokemonMoveSelectFilter; private tmMoveId: Moves; private showMovePp: boolean; - private slots: Map = new Map(); private iconAnimHandler: PokemonIconAnimHandler; @@ -292,11 +291,8 @@ export default class PartyUiHandler extends MessageUiHandler { this.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeItemTrigger, false, true); break; } - } else if (this.cursor) { - this.doSwitch(this.cursor, option); - // (this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, this.cursor, option === PartyOption.PASS_BATON, option); - } - + } else if (this.cursor) + (this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, this.cursor, option === PartyOption.PASS_BATON); } if (this.partyUiMode !== PartyUiMode.MODIFIER && this.partyUiMode !== PartyUiMode.TM_MODIFIER && this.partyUiMode !== PartyUiMode.MOVE_MODIFIER) ui.playSelect(); @@ -374,11 +370,7 @@ export default class PartyUiHandler extends MessageUiHandler { } else if (this.partyUiMode === PartyUiMode.FAINT_SWITCH) ui.playError(); else if (this.cursor === 6) { - 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); + console.log('DONE'); } else return this.processInput(Button.CANCEL); return true; @@ -541,7 +533,7 @@ export default class PartyUiHandler extends MessageUiHandler { } showOptions() { - if (this.cursor === 6 || this.cursor === 7) + if (this.cursor === 6) return; this.optionsMode = true; @@ -760,11 +752,6 @@ 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(); From 90f0d7e72e304a7a91611b581b40876940dfb1ab Mon Sep 17 00:00:00 2001 From: Greenlamp Date: Mon, 6 May 2024 21:19:22 +0200 Subject: [PATCH 6/7] Revert "added Done button in pokemon selection menu and choosing which pokemon to replace" This reverts commit ff562af446f131c256692d8ce829e9880fbeba51. --- src/phases.ts | 6 +-- src/ui/party-ui-handler.ts | 97 +++++--------------------------------- 2 files changed, 14 insertions(+), 89 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index 5e46133ed..b966712f2 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1936,10 +1936,8 @@ export class SelectTargetPhase extends PokemonPhase { if (cursor === -1) { this.scene.currentBattle.turnCommands[this.fieldIndex] = null; this.scene.unshiftPhase(new CommandPhase(this.scene, this.fieldIndex)); - } else { - turnCommand.targets = [cursor]; - this.scene.hasFreeSwitch = false; - } + } else + turnCommand.targets = [ cursor ]; if (turnCommand.command === Command.BALL && this.fieldIndex) this.scene.currentBattle.turnCommands[this.fieldIndex - 1].skip = true; this.end(); diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index dc57dd9e7..8b497655a 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -36,8 +36,6 @@ export enum PartyUiMode { export enum PartyOption { CANCEL = -1, SEND_OUT, - SEND_OUT_1, - SEND_OUT_2, PASS_BATON, APPLY, TEACH, @@ -53,7 +51,7 @@ export enum PartyOption { MOVE_1 = 3000, MOVE_2, MOVE_3, - MOVE_4, + MOVE_4 } export type PartySelectCallback = (cursor: integer, option: PartyOption) => void; @@ -72,7 +70,6 @@ export default class PartyUiHandler extends MessageUiHandler { private partySlotsContainer: Phaser.GameObjects.Container; private partySlots: PartySlot[]; private partyCancelButton: PartyCancelButton; - private partyDoneButton: PartyDoneButton; private partyMessageBox: Phaser.GameObjects.NineSlice; private optionsMode: boolean; @@ -156,13 +153,10 @@ export default class PartyUiHandler extends MessageUiHandler { this.message = partyMessageText; - const partyCancelButton = new PartyCancelButton(this.scene, 291, -9); - const partyDoneButton = new PartyDoneButton(this.scene, 291, -26); + const partyCancelButton = new PartyCancelButton(this.scene, 291, -16); partyContainer.add(partyCancelButton); - partyContainer.add(partyDoneButton); this.partyCancelButton = partyCancelButton; - this.partyDoneButton = partyDoneButton; this.optionsContainer = this.scene.add.container((this.scene.game.canvas.width / 6) - 1, -1); partyContainer.add(this.optionsContainer); @@ -369,9 +363,7 @@ export default class PartyUiHandler extends MessageUiHandler { ui.playSelect(); } else if (this.partyUiMode === PartyUiMode.FAINT_SWITCH) ui.playError(); - else if (this.cursor === 6) { - console.log('DONE'); - } else + else return this.processInput(Button.CANCEL); return true; } else if (button === Button.CANCEL) { @@ -398,27 +390,26 @@ export default class PartyUiHandler extends MessageUiHandler { switch (button) { case Button.UP: - if (this.cursor === 7) success = this.setCursor(6); - else success = this.setCursor(this.cursor ? this.cursor < 6 ? this.cursor - 1 : slotCount - 1 : 7); + success = this.setCursor(this.cursor ? this.cursor < 6 ? this.cursor - 1 : slotCount - 1 : 6); break; case Button.DOWN: - if (this.cursor === 6) success = this.setCursor(7); - else success = this.setCursor(this.cursor < 6 ? this.cursor < slotCount - 1 ? this.cursor + 1 : 6 : 0); + success = this.setCursor(this.cursor < 6 ? this.cursor < slotCount - 1 ? this.cursor + 1 : 6 : 0); break; case Button.LEFT: - if (this.cursor >= battlerCount && this.cursor <= 7) + if (this.cursor >= battlerCount && this.cursor <= 6) success = this.setCursor(0); break; case Button.RIGHT: if (slotCount === battlerCount){ success = this.setCursor(6); - break; + break; } else if (battlerCount >= 2 && slotCount > battlerCount && this.getCursor() === 0 && this.lastCursor === 1){ success = this.setCursor(2); break; - } else if (slotCount > battlerCount && this.cursor < battlerCount) + } else if (slotCount > battlerCount && this.cursor < battlerCount){ success = this.setCursor(this.lastCursor < 6 ? this.lastCursor || battlerCount : battlerCount); break; + } } } @@ -434,8 +425,6 @@ export default class PartyUiHandler extends MessageUiHandler { if (this.cursor < 6 && this.cursor >= party.length) this.cursor = party.length - 1; else if (this.cursor === 6) - this.partyDoneButton.select(); - else if (this.cursor === 7) this.partyCancelButton.select(); for (let p in party) { @@ -493,24 +482,12 @@ export default class PartyUiHandler extends MessageUiHandler { this.cursor = cursor; if (this.lastCursor < 6) this.partySlots[this.lastCursor].deselect(); - else if (this.lastCursor === 6){ + else if (this.lastCursor === 6) this.partyCancelButton.deselect(); - } else if (this.lastCursor === 7){ - this.partyDoneButton.deselect(); - } - if (cursor < 6) { + if (cursor < 6) this.partySlots[cursor].select(); - this.partyCancelButton.deselect(); - this.partyDoneButton.deselect(); - } - else if (cursor === 6){ - this.partyCancelButton.deselect(); - this.partyDoneButton.select(); - } - else if (cursor === 7) { - this.partyDoneButton.deselect(); + else if (cursor === 6) this.partyCancelButton.select(); - } } } @@ -590,8 +567,6 @@ export default class PartyUiHandler extends MessageUiHandler { case PartyUiMode.POST_BATTLE_SWITCH: if (this.cursor >= this.scene.currentBattle.getBattlerCount()) { this.options.push(PartyOption.SEND_OUT); - this.options.push(PartyOption.SEND_OUT_1); - this.options.push(PartyOption.SEND_OUT_2); if (this.partyUiMode !== PartyUiMode.FAINT_SWITCH && this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier && (m as SwitchEffectTransferModifier).pokemonId === this.scene.getPlayerField()[this.fieldIndex].id)) @@ -1083,52 +1058,4 @@ class PartyCancelButton extends Phaser.GameObjects.Container { this.partyCancelBg.setFrame('party_cancel'); this.partyCancelPb.setFrame('party_pb'); } -} - -class PartyDoneButton extends Phaser.GameObjects.Container { - private selected: boolean; - - private partyDoneBg: Phaser.GameObjects.Sprite; - private partyDonePb: Phaser.GameObjects.Sprite; - - constructor(scene: BattleScene, x: number, y: number) { - super(scene, x, y); - - this.setup(); - } - - setup() { - const partyDoneBg = this.scene.add.sprite(0, 0, 'party_cancel'); - this.add(partyDoneBg); - - this.partyDoneBg = partyDoneBg; - - const partyDonePb = this.scene.add.sprite(-17, 0, 'party_pb'); - this.add(partyDonePb); - - this.partyDonePb = partyDonePb; - - const partyCancelText = addTextObject(this.scene, -7, -6, 'Done', TextStyle.PARTY); - this.add(partyCancelText); - } - - select() { - if (this.selected) - return; - - this.selected = true; - - this.partyDoneBg.setFrame(`party_cancel_sel`); - this.partyDonePb.setFrame('party_pb_sel'); - } - - deselect() { - if (!this.selected) - return; - - this.selected = false; - - this.partyDoneBg.setFrame('party_cancel'); - this.partyDonePb.setFrame('party_pb'); - } } \ No newline at end of file From 78b7eae307880f3a000a859005601aab3983f50f Mon Sep 17 00:00:00 2001 From: Greenlamp Date: Mon, 6 May 2024 21:19:26 +0200 Subject: [PATCH 7/7] Revert "added "Free switch" text when variable "hasFreeSwitch" is true and display it only when we can see the command box" This reverts commit a65c696e6924a76d8fc40ace536e7170487fef4d. --- src/battle-scene.ts | 2 -- src/battle.ts | 1 - src/ui/command-ui-handler.ts | 17 ----------------- 3 files changed, 20 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 9cdb29e0d..1a1d9626c 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -163,8 +163,6 @@ export default class BattleScene extends SceneBase { public waveCycleOffset: integer; public offsetGym: boolean; - public hasFreeSwitch: boolean; - public damageNumberHandler: DamageNumberHandler private spriteSparkleHandler: PokemonSpriteSparkleHandler; diff --git a/src/battle.ts b/src/battle.ts index 9e3a87dc9..580bad9a5 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -133,7 +133,6 @@ export default class Battle { incrementTurn(scene: BattleScene): void { this.turn++; - scene.hasFreeSwitch = this.turn === 1; this.turnCommands = Object.fromEntries(Utils.getEnumValues(BattlerIndex).map(bt => [ bt, null ])); this.battleSeedState = null; } diff --git a/src/ui/command-ui-handler.ts b/src/ui/command-ui-handler.ts index f4b5e09e4..a27053015 100644 --- a/src/ui/command-ui-handler.ts +++ b/src/ui/command-ui-handler.ts @@ -17,7 +17,6 @@ export enum Command { export default class CommandUiHandler extends UiHandler { private commandsContainer: Phaser.GameObjects.Container; private cursorObj: Phaser.GameObjects.Image; - private freeSwitchText: Phaser.GameObjects.Text; protected fieldIndex: integer = 0; protected cursor2: integer = 0; @@ -43,21 +42,6 @@ export default class CommandUiHandler extends UiHandler { const commandText = addTextObject(this.scene, c % 2 === 0 ? 0 : 55.8, c < 2 ? 0 : 16, commands[c], TextStyle.WINDOW); this.commandsContainer.add(commandText); } - - this.freeSwitchText = addTextObject(this.scene, -45, 25, '', TextStyle.WINDOW, {fontSize: '48px', color: '#A8E4A0'}); - this.freeSwitchText.setVisible(false); - this.commandsContainer.add(this.freeSwitchText); - } - - updateFreeSwitchText(): void { - if (!this.scene.currentBattle?.turn) return; - if (this.scene.hasFreeSwitch) { - this.freeSwitchText.setText('Free Switch'); - this.freeSwitchText.setVisible(true); - } else { - this.freeSwitchText.setText(''); - this.freeSwitchText.setVisible(false); - } } show(args: any[]): boolean { @@ -80,7 +64,6 @@ export default class CommandUiHandler extends UiHandler { messageHandler.message.setWordWrapWidth(1110); messageHandler.showText(i18next.t('commandUiHandler:actionMessage', {pokemonName: commandPhase.getPokemon().name}), 0); this.setCursor(this.getCursor()); - this.updateFreeSwitchText(); return true; }