Fixed module comment + underzealous double battle test override

This commit is contained in:
Bertie690 2025-09-15 21:45:20 -04:00
parent ad018db015
commit 3117dfe94e
2 changed files with 25 additions and 17 deletions

View File

@ -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 // biome-ignore lint/correctness/noUnusedImports: TSDoc
import type { BattleScene } from "#app/battle-scene"; import type { BattleScene } from "#app/battle-scene";
import type { BattleType } from "#enums/battle-type"; 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 { Trainer } from "#field/trainer";
import type { TrainerData } from "#system/trainer-data"; 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 representing the base type of a new battle config, used for DRY. */
interface NewBattleBaseProps { interface NewBattleBaseProps {
/** The type of battle to create. */ /** The type of battle to create. */

View File

@ -1534,6 +1534,12 @@ export class BattleScene extends SceneBase {
* @returns Whether the battle should be a duouble battle. * @returns Whether the battle should be a duouble battle.
*/ */
private checkIsDouble({ double, battleType, waveIndex, trainer }: NewBattleConstructedProps): boolean { 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 // Edge cases
if ( if (
// Wave 1 doubles cause crashes // Wave 1 doubles cause crashes
@ -1544,13 +1550,21 @@ export class BattleScene extends SceneBase {
) { ) {
return false; return false;
} }
// Previously defined double battle status (from save data)
if (double != null) { if (double != null) {
return double; 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) { switch (Overrides.BATTLE_STYLE_OVERRIDE) {
case "double": case "double":
return true; return true;
@ -1561,12 +1575,6 @@ export class BattleScene extends SceneBase {
case "odd-doubles": case "odd-doubles":
return waveIndex % 2 === 1; 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 { newArena(biome: BiomeId, playerFaints = 0): Arena {