From 3117dfe94e7d8646bb09f55e030b4b7a3e6e2bed Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Mon, 15 Sep 2025 21:45:20 -0400 Subject: [PATCH] Fixed module comment + underzealous double battle test override --- src/@types/new-battle-props.ts | 16 ++++++++-------- src/battle-scene.ts | 26 +++++++++++++++++--------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/@types/new-battle-props.ts b/src/@types/new-battle-props.ts index 2ce27175336..269a164cc5f 100644 --- a/src/@types/new-battle-props.ts +++ b/src/@types/new-battle-props.ts @@ -1,3 +1,11 @@ +/** + * A collection of types/interfaces used for {@linkcode BattleScene.newBattle} and associated + * sub-methods. + * + * Types are listed in order of appearance in the function. + * @module + */ + // biome-ignore lint/correctness/noUnusedImports: TSDoc import type { BattleScene } from "#app/battle-scene"; import type { BattleType } from "#enums/battle-type"; @@ -5,14 +13,6 @@ import type { MysteryEncounterType } from "#enums/mystery-encounter-type"; import type { Trainer } from "#field/trainer"; import type { TrainerData } from "#system/trainer-data"; -/** - * @module - * A collection of types/interfaces used for {@linkcode BattleScene.newBattle} and associated - * sub-methods. - * - * Types are listed in order of appearance in the function. - */ - /** Interface representing the base type of a new battle config, used for DRY. */ interface NewBattleBaseProps { /** The type of battle to create. */ diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 9ae24fa367f..6a4e6eb13bd 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -1534,6 +1534,12 @@ export class BattleScene extends SceneBase { * @returns Whether the battle should be a duouble battle. */ private checkIsDouble({ double, battleType, waveIndex, trainer }: NewBattleConstructedProps): boolean { + const overriddenDouble = this.doCheckDoubleOverride(waveIndex); + // If running unit tests, overrides take precedence over normal code + if (import.meta.env.NODE_ENV === "test" && overriddenDouble != null) { + return overriddenDouble; + } + // Edge cases if ( // Wave 1 doubles cause crashes @@ -1544,13 +1550,21 @@ export class BattleScene extends SceneBase { ) { return false; } - - // Previously defined double battle status (from save data) if (double != null) { return double; } + if (overriddenDouble != null) { + return overriddenDouble; + } - // Overrides + // Standard wild battle chance + if (battleType === BattleType.WILD) { + return !randSeedInt(this.getDoubleBattleChance(waveIndex)); + } + return trainer?.variant === TrainerVariant.DOUBLE; + } + + private doCheckDoubleOverride(waveIndex: number): boolean | undefined { switch (Overrides.BATTLE_STYLE_OVERRIDE) { case "double": return true; @@ -1561,12 +1575,6 @@ export class BattleScene extends SceneBase { case "odd-doubles": return waveIndex % 2 === 1; } - - // Standard wild battle chance - if (battleType === BattleType.WILD) { - return !randSeedInt(this.getDoubleBattleChance(waveIndex)); - } - return trainer?.variant === TrainerVariant.DOUBLE; } newArena(biome: BiomeId, playerFaints = 0): Arena {