mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -05:00
fixed lint/complexity/noForEach
This commit is contained in:
parent
40a9ed4102
commit
3eee163aae
@ -120,7 +120,7 @@ export class InsuranceController
|
|||||||
this.logger.debug(`Processing ${insuranceDetails.length} insurance packages, which includes a total of ${this.countAllInsuranceItems(insuranceDetails)} items, in profile ${sessionID}`);
|
this.logger.debug(`Processing ${insuranceDetails.length} insurance packages, which includes a total of ${this.countAllInsuranceItems(insuranceDetails)} items, in profile ${sessionID}`);
|
||||||
|
|
||||||
// Iterate over each of the insurance packages.
|
// Iterate over each of the insurance packages.
|
||||||
insuranceDetails.forEach(insured =>
|
for (const insured of insuranceDetails)
|
||||||
{
|
{
|
||||||
// Find items that should be deleted from the insured items.
|
// Find items that should be deleted from the insured items.
|
||||||
const itemsToDelete = this.findItemsToDelete(insured);
|
const itemsToDelete = this.findItemsToDelete(insured);
|
||||||
@ -136,7 +136,7 @@ export class InsuranceController
|
|||||||
|
|
||||||
// Remove the fully processed insurance package from the profile.
|
// Remove the fully processed insurance package from the profile.
|
||||||
this.removeInsurancePackageFromProfile(sessionID, insured.messageContent.systemData);
|
this.removeInsurancePackageFromProfile(sessionID, insured.messageContent.systemData);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -216,7 +216,10 @@ export class InsuranceController
|
|||||||
protected populateItemsMap(insured: Insurance): Map<string, Item>
|
protected populateItemsMap(insured: Insurance): Map<string, Item>
|
||||||
{
|
{
|
||||||
const itemsMap = new Map<string, Item>();
|
const itemsMap = new Map<string, Item>();
|
||||||
insured.items.forEach(item => itemsMap.set(item._id, item));
|
for (const item of insured.items)
|
||||||
|
{
|
||||||
|
itemsMap.set(item._id, item);
|
||||||
|
}
|
||||||
return itemsMap;
|
return itemsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +314,10 @@ export class InsuranceController
|
|||||||
const allChildrenAreAttachments = directChildren.every(child => this.itemHelper.isAttachmentAttached(child));
|
const allChildrenAreAttachments = directChildren.every(child => this.itemHelper.isAttachmentAttached(child));
|
||||||
if (allChildrenAreAttachments)
|
if (allChildrenAreAttachments)
|
||||||
{
|
{
|
||||||
itemAndChildren.forEach(item => toDelete.add(item._id));
|
for (const item of itemAndChildren)
|
||||||
|
{
|
||||||
|
toDelete.add(item._id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,7 +333,7 @@ export class InsuranceController
|
|||||||
*/
|
*/
|
||||||
protected processAttachments(mainParentToAttachmentsMap: Map<string, Item[]>, itemsMap: Map<string, Item>, traderId: string, toDelete: Set<string>): void
|
protected processAttachments(mainParentToAttachmentsMap: Map<string, Item[]>, itemsMap: Map<string, Item>, traderId: string, toDelete: Set<string>): void
|
||||||
{
|
{
|
||||||
mainParentToAttachmentsMap.forEach((attachmentItems, parentId) =>
|
for (const [ parentId, attachmentItems ] of mainParentToAttachmentsMap)
|
||||||
{
|
{
|
||||||
// Log the parent item's name.
|
// Log the parent item's name.
|
||||||
const parentItem = itemsMap.get(parentId);
|
const parentItem = itemsMap.get(parentId);
|
||||||
@ -336,7 +342,7 @@ export class InsuranceController
|
|||||||
|
|
||||||
// Process the attachments for this individual parent item.
|
// Process the attachments for this individual parent item.
|
||||||
this.processAttachmentByParent(attachmentItems, traderId, toDelete);
|
this.processAttachmentByParent(attachmentItems, traderId, toDelete);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -383,10 +389,10 @@ export class InsuranceController
|
|||||||
*/
|
*/
|
||||||
protected logAttachmentsDetails(attachments: EnrichedItem[]): void
|
protected logAttachmentsDetails(attachments: EnrichedItem[]): void
|
||||||
{
|
{
|
||||||
attachments.forEach(({ name, maxPrice }) =>
|
for ( const attachment of attachments)
|
||||||
{
|
{
|
||||||
this.logger.debug(`Child Item - Name: ${name}, Max Price: ${maxPrice}`);
|
this.logger.debug(`Child Item - Name: ${attachment.name}, Max Price: ${attachment.maxPrice}`);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -413,7 +419,7 @@ export class InsuranceController
|
|||||||
{
|
{
|
||||||
const valuableToDelete = attachments.slice(0, successfulRolls).map(({ _id }) => _id);
|
const valuableToDelete = attachments.slice(0, successfulRolls).map(({ _id }) => _id);
|
||||||
|
|
||||||
valuableToDelete.forEach(attachmentsId =>
|
for (const attachmentsId of valuableToDelete)
|
||||||
{
|
{
|
||||||
const valuableChild = attachments.find(({ _id }) => _id === attachmentsId);
|
const valuableChild = attachments.find(({ _id }) => _id === attachmentsId);
|
||||||
if (valuableChild)
|
if (valuableChild)
|
||||||
@ -422,7 +428,7 @@ export class InsuranceController
|
|||||||
this.logger.debug(`Marked for removal - Child Item: ${name}, Max Price: ${maxPrice}`);
|
this.logger.debug(`Marked for removal - Child Item: ${name}, Max Price: ${maxPrice}`);
|
||||||
toDelete.add(attachmentsId);
|
toDelete.add(attachmentsId);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -448,7 +454,7 @@ export class InsuranceController
|
|||||||
{
|
{
|
||||||
const hideoutParentId = this.fetchHideoutItemParent(insured.items);
|
const hideoutParentId = this.fetchHideoutItemParent(insured.items);
|
||||||
|
|
||||||
insured.items.forEach(item =>
|
for (const item of insured.items)
|
||||||
{
|
{
|
||||||
// Check if the item's parent exists in the insured items list.
|
// Check if the item's parent exists in the insured items list.
|
||||||
const parentExists = insured.items.some(parentItem => parentItem._id === item.parentId);
|
const parentExists = insured.items.some(parentItem => parentItem._id === item.parentId);
|
||||||
@ -460,7 +466,7 @@ export class InsuranceController
|
|||||||
item.slotId = "hideout";
|
item.slotId = "hideout";
|
||||||
delete item.location;
|
delete item.location;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -237,7 +237,10 @@ export class LocationGenerator
|
|||||||
|
|
||||||
// Create probability array with all possible container ids in this group and their relataive probability of spawning
|
// Create probability array with all possible container ids in this group and their relataive probability of spawning
|
||||||
const containerDistribution = new ProbabilityObjectArray<string>(this.mathUtil, this.jsonUtil);
|
const containerDistribution = new ProbabilityObjectArray<string>(this.mathUtil, this.jsonUtil);
|
||||||
containerIds.forEach(x => containerDistribution.push(new ProbabilityObject(x, containerData.containerIdsWithProbability[x])));
|
for (const containerId of containerIds)
|
||||||
|
{
|
||||||
|
containerDistribution.push(new ProbabilityObject(containerId, containerData.containerIdsWithProbability[containerId]));
|
||||||
|
}
|
||||||
|
|
||||||
chosenContainerIds.push(...containerDistribution.draw(containerData.chosenCount));
|
chosenContainerIds.push(...containerDistribution.draw(containerData.chosenCount));
|
||||||
|
|
||||||
|
@ -54,13 +54,13 @@ export class LootGenerator
|
|||||||
const itemTypeCounts = this.initItemLimitCounter(options.itemLimits);
|
const itemTypeCounts = this.initItemLimitCounter(options.itemLimits);
|
||||||
|
|
||||||
const tables = this.databaseServer.getTables();
|
const tables = this.databaseServer.getTables();
|
||||||
const itemBlacklist = new Set(this.itemFilterService.getBlacklistedItems());
|
const itemBlacklist = new Set<string>([...this.itemFilterService.getBlacklistedItems(), ...options.itemBlacklist]);
|
||||||
|
|
||||||
options.itemBlacklist.forEach(itemBlacklist.add, itemBlacklist);
|
|
||||||
|
|
||||||
if (!options.allowBossItems)
|
if (!options.allowBossItems)
|
||||||
{
|
{
|
||||||
this.itemFilterService.getBossItems().forEach(itemBlacklist.add, itemBlacklist);
|
for (const bossItem of this.itemFilterService.getBossItems())
|
||||||
|
{
|
||||||
|
itemBlacklist.add(bossItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle sealed weapon containers
|
// Handle sealed weapon containers
|
||||||
|
@ -127,7 +127,13 @@ export class AssortHelper
|
|||||||
|
|
||||||
if (assort.barter_scheme[itemID] && flea)
|
if (assort.barter_scheme[itemID] && flea)
|
||||||
{
|
{
|
||||||
assort.barter_scheme[itemID].forEach(b => b.forEach(br => br.sptQuestLocked = true));
|
for (const barterSchemes of assort.barter_scheme[itemID])
|
||||||
|
{
|
||||||
|
for (const barterScheme of barterSchemes)
|
||||||
|
{
|
||||||
|
barterScheme.sptQuestLocked = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return assort;
|
return assort;
|
||||||
}
|
}
|
||||||
delete assort.barter_scheme[itemID];
|
delete assort.barter_scheme[itemID];
|
||||||
|
@ -364,10 +364,10 @@ export class InRaidHelper
|
|||||||
&& !(this.inRaidConfig.keepFiRSecureContainerOnDeath && this.itemHelper.itemIsInsideContainer(x, "SecuredContainer", postRaidProfile.Inventory.items));
|
&& !(this.inRaidConfig.keepFiRSecureContainerOnDeath && this.itemHelper.itemIsInsideContainer(x, "SecuredContainer", postRaidProfile.Inventory.items));
|
||||||
});
|
});
|
||||||
|
|
||||||
itemsToRemovePropertyFrom.forEach(item =>
|
for (const item of itemsToRemovePropertyFrom)
|
||||||
{
|
{
|
||||||
delete item.upd.SpawnedInSession;
|
delete item.upd.SpawnedInSession;
|
||||||
});
|
}
|
||||||
|
|
||||||
return postRaidProfile;
|
return postRaidProfile;
|
||||||
}
|
}
|
||||||
@ -410,10 +410,10 @@ export class InRaidHelper
|
|||||||
{
|
{
|
||||||
// Get inventory item ids to remove from players profile
|
// Get inventory item ids to remove from players profile
|
||||||
const itemIdsToDeleteFromProfile = this.getInventoryItemsLostOnDeath(pmcData).map(x => x._id);
|
const itemIdsToDeleteFromProfile = this.getInventoryItemsLostOnDeath(pmcData).map(x => x._id);
|
||||||
itemIdsToDeleteFromProfile.forEach(x =>
|
for (const itemId of itemIdsToDeleteFromProfile)
|
||||||
{
|
{
|
||||||
this.inventoryHelper.removeItem(pmcData, x, sessionID);
|
this.inventoryHelper.removeItem(pmcData, itemId, sessionID);
|
||||||
});
|
}
|
||||||
|
|
||||||
// Remove contents of fast panel
|
// Remove contents of fast panel
|
||||||
pmcData.Inventory.fastPanel = {};
|
pmcData.Inventory.fastPanel = {};
|
||||||
|
@ -146,10 +146,10 @@ export class PreAkiModLoader implements IModLoader
|
|||||||
const modOrder = this.vfs.readFile(this.modOrderPath, { encoding: "utf8" });
|
const modOrder = this.vfs.readFile(this.modOrderPath, { encoding: "utf8" });
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.jsonUtil.deserialize<any>(modOrder).order.forEach((mod: string, index: number) =>
|
for (const [index, mod] of (this.jsonUtil.deserialize<any>(modOrder).order as string[]).entries())
|
||||||
{
|
{
|
||||||
this.order[mod] = index;
|
this.order[mod] = index;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
catch (error)
|
catch (error)
|
||||||
{
|
{
|
||||||
@ -210,7 +210,10 @@ export class PreAkiModLoader implements IModLoader
|
|||||||
validMods.sort((prev, next) => this.sortMods(prev, next, missingFromOrderJSON));
|
validMods.sort((prev, next) => this.sortMods(prev, next, missingFromOrderJSON));
|
||||||
|
|
||||||
// log the missing mods from order.json
|
// log the missing mods from order.json
|
||||||
Object.keys(missingFromOrderJSON).forEach((missingMod) => (this.logger.debug(this.localisationService.getText("modloader-mod_order_missing_from_json", missingMod))));
|
for (const missingMod of Object.keys(missingFromOrderJSON))
|
||||||
|
{
|
||||||
|
this.logger.debug(this.localisationService.getText("modloader-mod_order_missing_from_json", missingMod));
|
||||||
|
}
|
||||||
|
|
||||||
// add mods
|
// add mods
|
||||||
for (const mod of validMods)
|
for (const mod of validMods)
|
||||||
|
4
project/src/models/external/HttpFramework.ts
vendored
4
project/src/models/external/HttpFramework.ts
vendored
@ -32,7 +32,7 @@ export const Listen = (basePath: string) =>
|
|||||||
if (!handlersArray) return;
|
if (!handlersArray) return;
|
||||||
|
|
||||||
// Add each flagged handler to the Record
|
// Add each flagged handler to the Record
|
||||||
handlersArray.forEach(({ handlerName, path, httpMethod }) =>
|
for (const { handlerName, path, httpMethod } of handlersArray)
|
||||||
{
|
{
|
||||||
if (!this.handlers[httpMethod]) this.handlers[httpMethod] = {};
|
if (!this.handlers[httpMethod]) this.handlers[httpMethod] = {};
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ export const Listen = (basePath: string) =>
|
|||||||
if (!path || path === "") this.handlers[httpMethod][`/${basePath}`] = this[handlerName];
|
if (!path || path === "") this.handlers[httpMethod][`/${basePath}`] = this[handlerName];
|
||||||
this.handlers[httpMethod][`/${basePath}/${path}`] = this[handlerName];
|
this.handlers[httpMethod][`/${basePath}/${path}`] = this[handlerName];
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
// Cleanup the handlers list
|
// Cleanup the handlers list
|
||||||
Base.prototype["handlers"] = [];
|
Base.prototype["handlers"] = [];
|
||||||
|
@ -15,7 +15,7 @@ export class HttpRouter
|
|||||||
protected groupBy<T>(list: T[], keyGetter: (t:T) => string): Map<string, T[]>
|
protected groupBy<T>(list: T[], keyGetter: (t:T) => string): Map<string, T[]>
|
||||||
{
|
{
|
||||||
const map: Map<string, T[]> = new Map();
|
const map: Map<string, T[]> = new Map();
|
||||||
list.forEach((item) =>
|
for (const item of list)
|
||||||
{
|
{
|
||||||
const key = keyGetter(item);
|
const key = keyGetter(item);
|
||||||
const collection = map.get(key);
|
const collection = map.get(key);
|
||||||
@ -27,7 +27,7 @@ export class HttpRouter
|
|||||||
{
|
{
|
||||||
collection.push(item);
|
collection.push(item);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,17 +27,17 @@ export class BotGenerationCacheService
|
|||||||
*/
|
*/
|
||||||
public storeBots(key: string, botsToStore: IBotBase[]): void
|
public storeBots(key: string, botsToStore: IBotBase[]): void
|
||||||
{
|
{
|
||||||
botsToStore.forEach(e =>
|
for (const bot of botsToStore)
|
||||||
{
|
{
|
||||||
if (this.storedBots.has(key))
|
if (this.storedBots.has(key))
|
||||||
{
|
{
|
||||||
this.storedBots.get(key).unshift(e);
|
this.storedBots.get(key).unshift(bot);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.storedBots.set(key, [e]);
|
this.storedBots.set(key, [bot]);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -383,14 +383,14 @@ export class ProfileFixerService
|
|||||||
protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]
|
protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]
|
||||||
{
|
{
|
||||||
let activeQuests = [];
|
let activeQuests = [];
|
||||||
repeatableQuests?.forEach(x =>
|
for (const repeatableQuest of repeatableQuests)
|
||||||
{
|
{
|
||||||
if (x.activeQuests.length > 0)
|
if (repeatableQuest.activeQuests.length > 0)
|
||||||
{
|
{
|
||||||
// daily/weekly collection has active quests in them, add to array and return
|
// daily/weekly collection has active quests in them, add to array and return
|
||||||
activeQuests = activeQuests.concat(x.activeQuests);
|
activeQuests = activeQuests.concat(repeatableQuest.activeQuests);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
return activeQuests;
|
return activeQuests;
|
||||||
}
|
}
|
||||||
|
@ -187,9 +187,10 @@ export class RagfairOfferService
|
|||||||
public expireStaleOffers(): void
|
public expireStaleOffers(): void
|
||||||
{
|
{
|
||||||
const time = this.timeUtil.getTimestamp();
|
const time = this.timeUtil.getTimestamp();
|
||||||
this.ragfairOfferHandler
|
for (const staleOffer of this.ragfairOfferHandler.getStaleOffers(time))
|
||||||
.getStaleOffers(time)
|
{
|
||||||
.forEach(o => this.processStaleOffer(o));
|
this.processStaleOffer(staleOffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,7 +51,10 @@ export class RagfairOfferHolder
|
|||||||
|
|
||||||
public addOffers(offers: Array<IRagfairOffer>): void
|
public addOffers(offers: Array<IRagfairOffer>): void
|
||||||
{
|
{
|
||||||
offers.forEach(o => this.addOffer(o));
|
for (const offer of offers)
|
||||||
|
{
|
||||||
|
this.addOffer(offer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public addOffer(offer: IRagfairOffer): void
|
public addOffer(offer: IRagfairOffer): void
|
||||||
@ -76,7 +79,10 @@ export class RagfairOfferHolder
|
|||||||
|
|
||||||
public removeOffers(offers: Array<IRagfairOffer>): void
|
public removeOffers(offers: Array<IRagfairOffer>): void
|
||||||
{
|
{
|
||||||
offers.forEach(o => this.removeOffer(o));
|
for (const offer of offers)
|
||||||
|
{
|
||||||
|
this.removeOffer(offer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public removeOfferByTrader(traderId: string): void
|
public removeOfferByTrader(traderId: string): void
|
||||||
|
@ -19,7 +19,10 @@ export class Queue<T>
|
|||||||
|
|
||||||
public enqueueAll(elements: T[]): void
|
public enqueueAll(elements: T[]): void
|
||||||
{
|
{
|
||||||
elements.forEach(e => this.enqueue(e));
|
for (const element of elements)
|
||||||
|
{
|
||||||
|
this.enqueue(element);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public dequeue(): T
|
public dequeue(): T
|
||||||
|
Loading…
x
Reference in New Issue
Block a user