added check to make sure same item isnt used, still has an edge case, if maxRequestedAmount is too high, and we cant offer enough items, dupes will appear, but this will fix normal use

This commit is contained in:
CWXDEV 2024-01-12 23:44:58 +00:00
parent 04564d7e76
commit 091e4fa41b

View File

@ -559,9 +559,19 @@ export class RepeatableQuestGenerator
// Draw items to ask player to retrieve
let isAmmo = 0
const randomNumbersUsed = [];
for (let i = 0; i < distinctItemsToRetrieveCount; i++)
{
const itemSelected = itemSelection[this.randomUtil.randInt(itemSelection.length)];
let randomNumber = this.randomUtil.randInt(itemSelection.length);
while (randomNumbersUsed.includes(randomNumber) && randomNumbersUsed.length !== itemSelection.length)
{
randomNumber = this.randomUtil.randInt(itemSelection.length);
}
randomNumbersUsed.push(randomNumber);
const itemSelected = itemSelection[randomNumber];
const itemUnitPrice = this.itemHelper.getItemPrice(itemSelected[0]);
let minValue = completionConfig.minRequestedAmount;
let maxValue = completionConfig.maxRequestedAmount;