mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-23 15:03:24 +02:00
[Refactor] Remove randSeedWeightedItem utils function. (#6492)
Remove randSeedWeightedItem utils function.
This commit is contained in:
parent
4b86dffcf9
commit
3765f843db
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user