diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 6cc33dc476d..6db9311bac8 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -1865,7 +1865,7 @@ export default class BattleScene extends SceneBase { generateRandomBiome(waveIndex: integer): Biome { const relWave = waveIndex % 250; - const biomes = Utils.getEnumValues(Biome).slice(1, Utils.getEnumValues(Biome).filter(b => b >= 40).length * -1); + const biomes = Utils.getEnumValues(Biome).filter(b => b !== Biome.TOWN && b !== Biome.END); const maxDepth = biomeDepths[Biome.END][0] - 2; const depthWeights = new Array(maxDepth + 1).fill(null) .map((_, i: integer) => ((1 - Math.min(Math.abs((i / (maxDepth - 1)) - (relWave / 250)) + 0.25, 1)) / 0.75) * 250); @@ -1878,9 +1878,9 @@ export default class BattleScene extends SceneBase { const randInt = Utils.randSeedInt(totalWeight); - for (const biome of biomes) { - if (randInt < biomeThresholds[biome]) { - return biome; + for (let i = 0; i < biomes.length; i++) { + if (randInt < biomeThresholds[i]) { + return biomes[i]; } } diff --git a/src/data/daily-run.ts b/src/data/daily-run.ts index b0ce38cebd2..2a4a78a9caf 100644 --- a/src/data/daily-run.ts +++ b/src/data/daily-run.ts @@ -8,6 +8,7 @@ import type { PokemonSpeciesForm } from "#app/data/pokemon-species"; import PokemonSpecies, { getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species"; import { speciesStarterCosts } from "#app/data/balance/starters"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; +import { Biome } from "#app/enums/biome"; export interface DailyRunConfig { seed: integer; @@ -71,3 +72,76 @@ function getDailyRunStarter(starterSpeciesForm: PokemonSpeciesForm, startingLeve pokemon.destroy(); return starter; } + +interface BiomeWeights { + [key: integer]: integer +} + +// Initially weighted by amount of exits each biome has +// Town and End are set to 0 however +// And some other biomes were balanced +1/-1 based on average size of the total daily. +const dailyBiomeWeights: BiomeWeights = { + [Biome.CAVE]: 3, + [Biome.LAKE]: 3, + [Biome.PLAINS]: 3, + [Biome.SNOWY_FOREST]: 3, + [Biome.SWAMP]: 3, // 2 -> 3 + [Biome.TALL_GRASS]: 3, // 2 -> 3 + + [Biome.ABYSS]: 2, // 3 -> 2 + [Biome.RUINS]: 2, + [Biome.BADLANDS]: 2, + [Biome.BEACH]: 2, + [Biome.CONSTRUCTION_SITE]: 2, + [Biome.DESERT]: 2, + [Biome.DOJO]: 2, // 3 -> 2 + [Biome.FACTORY]: 2, + [Biome.FAIRY_CAVE]: 2, + [Biome.FOREST]: 2, + [Biome.GRASS]: 2, // 1 -> 2 + [Biome.MEADOW]: 2, + [Biome.MOUNTAIN]: 2, // 3 -> 2 + [Biome.SEA]: 2, + [Biome.SEABED]: 2, + [Biome.SLUM]: 2, + [Biome.TEMPLE]: 2, // 3 -> 2 + [Biome.VOLCANO]: 2, + + [Biome.GRAVEYARD]: 1, + [Biome.ICE_CAVE]: 1, + [Biome.ISLAND]: 1, + [Biome.JUNGLE]: 1, + [Biome.LABORATORY]: 1, + [Biome.METROPOLIS]: 1, + [Biome.POWER_PLANT]: 1, + [Biome.SPACE]: 1, + [Biome.WASTELAND]: 1, + + [Biome.TOWN]: 0, + [Biome.END]: 0, +}; + +export function getDailyStartingBiome(): Biome { + const biomes = Utils.getEnumValues(Biome).filter(b => b !== Biome.TOWN && b !== Biome.END); + + let totalWeight = 0; + const biomeThresholds: integer[] = []; + for (const biome of biomes) { + // Keep track of the total weight + totalWeight += dailyBiomeWeights[biome]; + + // Keep track of each biomes cumulative weight + biomeThresholds.push(totalWeight); + } + + const randInt = Utils.randSeedInt(totalWeight); + + for (let i = 0; i < biomes.length; i++) { + if (randInt < biomeThresholds[i]) { + return biomes[i]; + } + } + + // Fallback in case something went wrong + return biomes[Utils.randSeedInt(biomes.length)]; +} diff --git a/src/game-mode.ts b/src/game-mode.ts index 4e0f5715851..78a65a54890 100644 --- a/src/game-mode.ts +++ b/src/game-mode.ts @@ -12,6 +12,7 @@ import { Biome } from "#enums/biome"; import { Species } from "#enums/species"; import { Challenges } from "./enums/challenges"; import { globalScene } from "#app/global-scene"; +import { getDailyStartingBiome } from "./data/daily-run"; export enum GameModes { CLASSIC, @@ -120,7 +121,7 @@ export class GameMode implements GameModeConfig { getStartingBiome(): Biome { switch (this.modeId) { case GameModes.DAILY: - return globalScene.generateRandomBiome(this.getWaveForDifficulty(1)); + return getDailyStartingBiome(); default: return Overrides.STARTING_BIOME_OVERRIDE || Biome.TOWN; }