From f144b55570c2e3209513ea15a5395be07a5a1729 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 18 Jan 2025 14:18:12 +0100 Subject: [PATCH] avoid rolling the same buff multiple times --- src/controllers/api/rerollRandomModController.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/controllers/api/rerollRandomModController.ts b/src/controllers/api/rerollRandomModController.ts index 3ad07de0..1957c476 100644 --- a/src/controllers/api/rerollRandomModController.ts +++ b/src/controllers/api/rerollRandomModController.ts @@ -57,8 +57,10 @@ const randomiseStats = (randomModType: string, fingerprint: IUnveiledRivenFinger 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) { - const entry = getRandomElement(buffEntries); + const buffIndex = Math.trunc(Math.random() * buffEntries.length); + const entry = buffEntries[buffIndex]; fingerprint.buffs.push({ Tag: entry.tag, Value: Math.trunc(Math.random() * 0x40000000) }); + buffEntries.splice(buffIndex, 1); } fingerprint.curses = [];