From b2b7dead5f7dc9044feb559ff060b661257a5f34 Mon Sep 17 00:00:00 2001 From: Jimmybald1 <147992650+IBBCalc@users.noreply.github.com> Date: Mon, 13 Jan 2025 18:19:06 +0100 Subject: [PATCH] [Balance] Daily Mode now has its own Generate Random Starting Biome --- src/data/daily-run.ts | 74 +++++++++++++++++++++++++++++++++++++++++++ src/game-mode.ts | 3 +- 2 files changed, 76 insertions(+), 1 deletion(-) 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; }