Add endless mode biome weighting

This commit is contained in:
Flashfyre committed 2023-12-07 13:41:47 -05:00
1 parent b7687a9a30
commit fae2c50916
2 files changed
+54 -9

No files matched your search

+23
View File
@@ -60,6 +60,10 @@ interface BiomeLinks {
[key: integer]: Biome | Biome[]
}
interface BiomeDepths {
[key: integer]: integer
}
export const biomeLinks: BiomeLinks = {
[Biome.TOWN]: Biome.PLAINS,
[Biome.PLAINS]: [ Biome.GRASS, Biome.CITY, Biome.LAKE ],
@@ -91,6 +95,8 @@ export const biomeLinks: BiomeLinks = {
[Biome.JUNGLE]: Biome.SWAMP
};
export const biomeDepths: BiomeDepths = {}
export enum BiomePoolTier {
COMMON,
UNCOMMON,
@@ -4561,6 +4567,23 @@ export const biomeTrainerPools: BiomeTrainerPools = {
[ TrainerType.RIVAL, [] ]
];
biomeDepths[Biome.TOWN] = 0;
const traverseBiome = (biome: Biome, depth: integer) => {
const linkedBiomes: Biome[] = Array.isArray(biomeLinks[biome])
? biomeLinks[biome] as Biome[]
: [ biomeLinks[biome] as Biome ];
for (let linkedBiome of linkedBiomes) {
if (!biomeDepths.hasOwnProperty(linkedBiome) || depth < biomeDepths[linkedBiome]) {
biomeDepths[linkedBiome] = depth + 1;
traverseBiome(linkedBiome, depth + 1);
}
}
};
traverseBiome(Biome.TOWN, 0);
biomeDepths[Biome.END] = Object.values(biomeDepths).reduce((max: integer, value: integer) => Math.max(max, value), 0) + 1;
for (let biome of Utils.getEnumValues(Biome)) {
biomePokemonPools[biome] = {};
biomeTrainerPools[biome] = {};