mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -05:00
Rewrites a number of filter().reduce() calls to use more straight-forward for...of loop.
This commit is contained in:
parent
f6ba864ea8
commit
50f8a84f5c
@ -273,7 +273,7 @@ export class BotEquipmentFilterService
|
|||||||
{
|
{
|
||||||
const botEquipment = baseBotNode.inventory.equipment[equipmentSlotKey];
|
const botEquipment = baseBotNode.inventory.equipment[equipmentSlotKey];
|
||||||
|
|
||||||
// Skip equipment slot if whitelist doesnt exist / is empty
|
// Skip equipment slot if whitelist doesn't exist / is empty
|
||||||
const whitelistEquipmentForSlot = whitelist.equipment[equipmentSlotKey];
|
const whitelistEquipmentForSlot = whitelist.equipment[equipmentSlotKey];
|
||||||
if (!whitelistEquipmentForSlot || Object.keys(whitelistEquipmentForSlot).length === 0)
|
if (!whitelistEquipmentForSlot || Object.keys(whitelistEquipmentForSlot).length === 0)
|
||||||
{
|
{
|
||||||
@ -281,9 +281,14 @@ export class BotEquipmentFilterService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Filter equipment slot items to just items in whitelist
|
// Filter equipment slot items to just items in whitelist
|
||||||
baseBotNode.inventory.equipment[equipmentSlotKey] = Object.keys(botEquipment).filter((tpl) =>
|
baseBotNode.inventory.equipment[equipmentSlotKey] = {};
|
||||||
whitelistEquipmentForSlot.includes(tpl)
|
for (const key of Object.keys(botEquipment))
|
||||||
).reduce((res, key) => (res[key] = botEquipment[key], res), {});
|
{
|
||||||
|
if (whitelistEquipmentForSlot.includes(key))
|
||||||
|
{
|
||||||
|
baseBotNode.inventory.equipment[equipmentSlotKey][key] = botEquipment[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -295,7 +300,7 @@ export class BotEquipmentFilterService
|
|||||||
{
|
{
|
||||||
const botEquipment = baseBotNode.inventory.equipment[equipmentSlotKey];
|
const botEquipment = baseBotNode.inventory.equipment[equipmentSlotKey];
|
||||||
|
|
||||||
// Skip equipment slot if blacklist doesnt exist / is empty
|
// Skip equipment slot if blacklist doesn't exist / is empty
|
||||||
const equipmentSlotBlacklist = blacklist.equipment[equipmentSlotKey];
|
const equipmentSlotBlacklist = blacklist.equipment[equipmentSlotKey];
|
||||||
if (!equipmentSlotBlacklist || Object.keys(equipmentSlotBlacklist).length === 0)
|
if (!equipmentSlotBlacklist || Object.keys(equipmentSlotBlacklist).length === 0)
|
||||||
{
|
{
|
||||||
@ -303,9 +308,14 @@ export class BotEquipmentFilterService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Filter equipment slot items to just items not in blacklist
|
// Filter equipment slot items to just items not in blacklist
|
||||||
baseBotNode.inventory.equipment[equipmentSlotKey] = Object.keys(botEquipment).filter((tpl) =>
|
baseBotNode.inventory.equipment[equipmentSlotKey] = {};
|
||||||
!equipmentSlotBlacklist.includes(tpl)
|
for (const key of Object.keys(botEquipment))
|
||||||
).reduce((res, key) => (res[key] = botEquipment[key], res), {});
|
{
|
||||||
|
if (!equipmentSlotBlacklist.includes(key))
|
||||||
|
{
|
||||||
|
baseBotNode.inventory.equipment[equipmentSlotKey][key] = botEquipment[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -330,17 +340,22 @@ export class BotEquipmentFilterService
|
|||||||
{
|
{
|
||||||
const botAmmo = baseBotNode.inventory.Ammo[ammoCaliberKey];
|
const botAmmo = baseBotNode.inventory.Ammo[ammoCaliberKey];
|
||||||
|
|
||||||
// Skip cartridge slot if whitelist doesnt exist / is empty
|
// Skip cartridge slot if whitelist doesn't exist / is empty
|
||||||
const whiteListedCartridgesForCaliber = whitelist.cartridge[ammoCaliberKey];
|
const whiteListedCartridgesForCaliber = whitelist.cartridge[ammoCaliberKey];
|
||||||
if (!whiteListedCartridgesForCaliber || Object.keys(whiteListedCartridgesForCaliber).length === 0)
|
if (!whiteListedCartridgesForCaliber || Object.keys(whiteListedCartridgesForCaliber).length === 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter caliber slot items to just items in whitelist
|
// Filter calibre slot items to just items in whitelist
|
||||||
baseBotNode.inventory.Ammo[ammoCaliberKey] = Object.keys(botAmmo).filter((tpl) =>
|
baseBotNode.inventory.Ammo[ammoCaliberKey] = {};
|
||||||
whitelist.cartridge[ammoCaliberKey].includes(tpl)
|
for (const key of Object.keys(botAmmo))
|
||||||
).reduce((res, key) => (res[key] = botAmmo[key], res), {});
|
{
|
||||||
|
if (whitelist.cartridge[ammoCaliberKey].includes(key))
|
||||||
|
{
|
||||||
|
baseBotNode.inventory.Ammo[ammoCaliberKey][key] = botAmmo[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -352,7 +367,7 @@ export class BotEquipmentFilterService
|
|||||||
{
|
{
|
||||||
const botAmmo = baseBotNode.inventory.Ammo[ammoCaliberKey];
|
const botAmmo = baseBotNode.inventory.Ammo[ammoCaliberKey];
|
||||||
|
|
||||||
// Skip cartridge slot if blacklist doesnt exist / is empty
|
// Skip cartridge slot if blacklist doesn't exist / is empty
|
||||||
const cartridgeCaliberBlacklist = blacklist.cartridge[ammoCaliberKey];
|
const cartridgeCaliberBlacklist = blacklist.cartridge[ammoCaliberKey];
|
||||||
if (!cartridgeCaliberBlacklist || Object.keys(cartridgeCaliberBlacklist).length === 0)
|
if (!cartridgeCaliberBlacklist || Object.keys(cartridgeCaliberBlacklist).length === 0)
|
||||||
{
|
{
|
||||||
@ -360,9 +375,14 @@ export class BotEquipmentFilterService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Filter cartridge slot items to just items not in blacklist
|
// Filter cartridge slot items to just items not in blacklist
|
||||||
baseBotNode.inventory.Ammo[ammoCaliberKey] = Object.keys(botAmmo).filter((tpl) =>
|
baseBotNode.inventory.Ammo[ammoCaliberKey] = {};
|
||||||
!cartridgeCaliberBlacklist.includes(tpl)
|
for (const key of Object.keys(botAmmo))
|
||||||
).reduce((res, key) => (res[key] = botAmmo[key], res), {});
|
{
|
||||||
|
if (!cartridgeCaliberBlacklist.includes(key))
|
||||||
|
{
|
||||||
|
baseBotNode.inventory.Ammo[ammoCaliberKey][key] = botAmmo[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user