From c929bbd23a5c27b80a9c6f180d5fc65e1af04285 Mon Sep 17 00:00:00 2001 From: hayuna Date: Thu, 13 Jun 2024 16:10:31 +0200 Subject: [PATCH] [Refactor] Move enum BattleStyle into separated file (#1906) * Move enum BattleStyle into separated file * Move enum BattleStyle into separated file * Move enum BattleStyle into separated file * Update battle-style.ts * Replace shift into switch --- src/battle-scene.ts | 5 +++-- src/enums/battle-style.ts | 9 +++++++++ src/phases.ts | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 src/enums/battle-style.ts diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 73332e03ec6..a4ed394f862 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -63,6 +63,7 @@ import { Abilities } from "./data/enums/abilities"; import ArenaFlyout from "./ui/arena-flyout"; import { EaseType } from "./ui/enums/ease-type"; import { ExpNotification } from "./enums/exp-notification"; +import { BattleStyle } from "./enums/battle-style"; export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1"; @@ -156,10 +157,10 @@ export default class BattleScene extends SceneBase { public enableVibration: boolean = false; /** * Determines the selected battle style. - * - 0 = 'Shift' + * - 0 = 'Switch' * - 1 = 'Set' - The option to switch the active pokemon at the start of a battle will not display. */ - public battleStyle: integer = 0; + public battleStyle: integer = BattleStyle.SWITCH; /** * Defines whether or not to show type effectiveness hints diff --git a/src/enums/battle-style.ts b/src/enums/battle-style.ts new file mode 100644 index 00000000000..3f3e7f6d8f6 --- /dev/null +++ b/src/enums/battle-style.ts @@ -0,0 +1,9 @@ +/** + * Determines the selected battle style. + * - 'Switch' - The option to switch the active pokemon at the start of a battle will be displayed. + * - 'Set' - The option to switch the active pokemon at the start of a battle will not display. +*/ +export enum BattleStyle { + SWITCH, + SET +} diff --git a/src/phases.ts b/src/phases.ts index 5c9c3ac9360..74746ffd48c 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -64,6 +64,7 @@ import { TextStyle, addTextObject } from "./ui/text"; import { Type } from "./data/type"; import { BerryUsedEvent, EncounterPhaseEvent, MoveUsedEvent, TurnEndEvent, TurnInitEvent } from "./events/battle-scene"; import { ExpNotification } from "./enums/exp-notification"; +import { BattleStyle } from "./enums/battle-style"; export class LoginPhase extends Phase { @@ -1747,7 +1748,7 @@ export class CheckSwitchPhase extends BattlePhase { const pokemon = this.scene.getPlayerField()[this.fieldIndex]; - if (this.scene.battleStyle === 1) { + if (this.scene.battleStyle === BattleStyle.SET) { super.end(); return; }