From b6cb000078ef034d11f6e69fb4fdfe540091345f Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 18 Jan 2025 14:16:22 +0100 Subject: [PATCH] work smart, not hard --- src/controllers/api/rerollRandomModController.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/controllers/api/rerollRandomModController.ts b/src/controllers/api/rerollRandomModController.ts index d7eee8e8..3ad07de0 100644 --- a/src/controllers/api/rerollRandomModController.ts +++ b/src/controllers/api/rerollRandomModController.ts @@ -55,21 +55,15 @@ const randomiseStats = (randomModType: string, fingerprint: IUnveiledRivenFinger fingerprint.buffs = []; const numBuffs = 2 + Math.trunc(Math.random() * 2); // 2 or 3 + const buffEntries = meta.upgradeEntries!.filter(x => x.canBeBuff); for (let i = 0; i != numBuffs; ++i) { - let entry = getRandomElement(meta.upgradeEntries!); - while (!entry.canBeBuff) { - entry = getRandomElement(meta.upgradeEntries!); - } + const entry = getRandomElement(buffEntries); fingerprint.buffs.push({ Tag: entry.tag, Value: Math.trunc(Math.random() * 0x40000000) }); } fingerprint.curses = []; - const numCurses = Math.trunc(Math.random() * 2); // 0 or 1 - for (let i = 0; i != numCurses; ++i) { - let entry = getRandomElement(meta.upgradeEntries!); - while (!entry.canBeCurse) { - entry = getRandomElement(meta.upgradeEntries!); - } + if (Math.random() < 0.5) { + const entry = getRandomElement(meta.upgradeEntries!.filter(x => x.canBeCurse)); fingerprint.curses.push({ Tag: entry.tag, Value: Math.trunc(Math.random() * 0x40000000) }); } };