From 1323093eb5797fd5e75c2647f420c7ecedbc7e59 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 3 Apr 2024 19:01:09 -0400 Subject: [PATCH] Fix enemy item generation softlock with no attack moves --- src/modifier/modifier-type.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index ac4efb184..c33fd3e4d 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -564,6 +564,9 @@ class AttackTypeBoosterModifierTypeGenerator extends ModifierTypeGenerator { return new AttackTypeBoosterModifierType(pregenArgs[0] as Type, 20); const attackMoveTypes = party.map(p => p.getMoveset().map(m => m.getMove()).filter(m => m instanceof AttackMove).map(m => m.type)).flat(); + if (!attackMoveTypes.length) + return null; + const attackMoveTypeWeights = new Map(); let totalWeight = 0; for (let t of attackMoveTypes) { @@ -1349,7 +1352,7 @@ export function getDailyRunStarterModifiers(party: PlayerPokemon[]): Modifiers.P return ret; } -function getNewModifierTypeOption(party: Pokemon[], poolType: ModifierPoolType, tier?: ModifierTier, upgradeCount?: integer): ModifierTypeOption { +function getNewModifierTypeOption(party: Pokemon[], poolType: ModifierPoolType, tier?: ModifierTier, upgradeCount?: integer, retryCount: integer = 0): ModifierTypeOption { const player = !poolType; let pool: ModifierPool; let thresholds: object; @@ -1398,6 +1401,9 @@ function getNewModifierTypeOption(party: Pokemon[], poolType: ModifierPoolType, if (upgradeCount) upgradeCount--; } + } else if (retryCount === 10 && tier) { + retryCount = 0; + tier--; } const tierThresholds = Object.keys(thresholds[tier]); @@ -1420,7 +1426,7 @@ function getNewModifierTypeOption(party: Pokemon[], poolType: ModifierPoolType, if (modifierType === null) { if (player) console.log(ModifierTier[tier], upgradeCount); - return getNewModifierTypeOption(party, poolType, tier, upgradeCount); + return getNewModifierTypeOption(party, poolType, tier, upgradeCount, ++retryCount); } }