Fix modifier type spawning from ultra tier

This commit is contained in:
Sirz Benjie 2025-05-22 19:55:43 -05:00
parent 9eb69e51e7
commit dda809823f
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E

View File

@ -1481,9 +1481,18 @@ class SpeciesStatBoosterModifierTypeGenerator extends ModifierTypeGenerator {
return new SpeciesStatBoosterModifierType(pregenArgs[0] as SpeciesStatBoosterItem); return new SpeciesStatBoosterModifierType(pregenArgs[0] as SpeciesStatBoosterItem);
} }
const values = Object.values(items); // Get a pool of items based on the rarity.
const keys = Object.keys(items); const keys: (keyof SpeciesStatBoosterItem)[] = [];
const weights = keys.map(() => 0); const values: (typeof items)[keyof typeof items][] = [];
const weights: number[] = [];
for (const [key, val] of Object.entries(SpeciesStatBoosterModifierTypeGenerator.items)) {
if (val.rare !== rare) {
continue;
}
values.push(val);
keys.push(key as keyof SpeciesStatBoosterItem);
weights.push(0);
}
for (const p of party) { for (const p of party) {
const speciesId = p.getSpeciesForm(true).speciesId; const speciesId = p.getSpeciesForm(true).speciesId;
@ -1506,8 +1515,6 @@ class SpeciesStatBoosterModifierTypeGenerator extends ModifierTypeGenerator {
if (!hasItem) { if (!hasItem) {
if (checkedSpecies.includes(speciesId) || (!!fusionSpeciesId && checkedSpecies.includes(fusionSpeciesId))) { if (checkedSpecies.includes(speciesId) || (!!fusionSpeciesId && checkedSpecies.includes(fusionSpeciesId))) {
// Sets the item's rarity in order to determine if the item is rare (ultra tier) or not (great tier)
values[i].rare = rare;
// Add weight if party member has a matching species or, if applicable, a matching fusion species // Add weight if party member has a matching species or, if applicable, a matching fusion species
weights[i]++; weights[i]++;
} else if (checkedSpecies.includes(Species.PIKACHU) && hasFling) { } else if (checkedSpecies.includes(Species.PIKACHU) && hasFling) {