0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 09:50:43 -05:00

Refactored mergeCamoraPool()

This commit is contained in:
Dev 2024-06-19 10:40:59 +01:00
parent 8a46d2c33d
commit 416ef74902

View File

@ -1352,7 +1352,7 @@ export class BotEquipmentModGenerator
{ {
modSlot = camoraFirstSlot; modSlot = camoraFirstSlot;
exhaustableModPool = new ExhaustableArray( exhaustableModPool = new ExhaustableArray(
this.mergeCamoraPoolsTogether(itemModPool), this.mergeCamoraPools(itemModPool),
this.randomUtil, this.randomUtil,
this.cloner, this.cloner,
); );
@ -1383,36 +1383,29 @@ export class BotEquipmentModGenerator
return; return;
} }
for (const slot of parentTemplate._props.Slots) for (const slot of cylinderMagTemplate._props.Slots)
{ {
const modSlotId = slot._name; const modSlotId = slot._name;
const modId = this.hashUtil.generate(); const modId = this.hashUtil.generate();
items.push({ _id: modId, _tpl: modTpl, parentId: parentId, slotId: modSlotId }); items.push({ _id: modId, _tpl: modTpl, parentId: cylinderMagParentId, slotId: modSlotId });
} }
} }
/** /**
* Take a record of camoras and merge the compatible shells into one array * Take a record of camoras and merge the compatible shells into one array
* @param camorasWithShells camoras we want to merge into one array * @param camorasWithShells Dictionary of camoras we want to merge into one array
* @returns string array of shells for multiple camora sources * @returns String array of shells for multiple camora sources
*/ */
protected mergeCamoraPoolsTogether(camorasWithShells: Record<string, string[]>): string[] protected mergeCamoraPools(camorasWithShells: Record<string, string[]>): string[]
{ {
const poolResult: string[] = []; const uniqueShells = new Set<string>();
for (const camoraKey in camorasWithShells) for (const shells of Object.values(camorasWithShells))
{ {
const shells = camorasWithShells[camoraKey]; // Add all shells to the set.
for (const shell of shells) shells.forEach((shell) => uniqueShells.add(shell));
{
// Only add distinct shells
if (!poolResult.includes(shell))
{
poolResult.push(shell);
}
}
} }
return poolResult; return Array.from(uniqueShells);
} }
/** /**