[Refactor] Remove randSeedWeightedItem utils function. (#6492)

Remove randSeedWeightedItem utils function.
This commit is contained in:
Xavion3 2025-09-06 16:12:32 +10:00 committed by GitHub
parent 4b86dffcf9
commit 3765f843db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 8 deletions

View File

@ -17,7 +17,7 @@ import { getIsInitialized, initI18n } from "#plugins/i18n";
import type { TrainerConfig } from "#trainers/trainer-config";
import { trainerConfigs } from "#trainers/trainer-config";
import { TrainerPartyCompoundTemplate, type TrainerPartyTemplate } from "#trainers/trainer-party-template";
import { randSeedInt, randSeedItem, randSeedWeightedItem } from "#utils/common";
import { randSeedInt, randSeedItem } from "#utils/common";
import { getRandomLocaleEntry } from "#utils/i18n";
import { getPokemonSpecies } from "#utils/pokemon-utils";
import { toCamelCase } from "#utils/strings";
@ -61,9 +61,7 @@ export class Trainer extends Phaser.GameObjects.Container {
this.variant = variant;
this.partyTemplateIndex = Math.min(
partyTemplateIndex !== undefined
? partyTemplateIndex
: randSeedWeightedItem(this.config.partyTemplates.map((_, i) => i)),
partyTemplateIndex !== undefined ? partyTemplateIndex : randSeedItem(this.config.partyTemplates.map((_, i) => i)),
this.config.partyTemplates.length - 1,
);
// TODO: Rework this and add actual error handling for missing names

View File

@ -133,10 +133,6 @@ export function randSeedItem<T>(items: T[]): T {
return items.length === 1 ? items[0] : Phaser.Math.RND.pick(items);
}
export function randSeedWeightedItem<T>(items: T[]): T {
return items.length === 1 ? items[0] : Phaser.Math.RND.weightedPick(items);
}
/**
* Shuffle a list using the seeded rng. Utilises the Fisher-Yates algorithm.
* @param {Array} items An array of items.