mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -05:00
Replaced various array.find()
with array.some()
Rewrote `tagItem()` to use `.find()`
This commit is contained in:
parent
3327bc916a
commit
f8bd65ed90
@ -133,7 +133,7 @@ export class DialogueController
|
|||||||
// User to user messages are special in that they need the player to exist in them, add if they don't
|
// User to user messages are special in that they need the player to exist in them, add if they don't
|
||||||
if (
|
if (
|
||||||
messageType === MessageType.USER_MESSAGE
|
messageType === MessageType.USER_MESSAGE
|
||||||
&& !dialog.Users?.find((userDialog) => userDialog._id === profile.characters.pmc.sessionId)
|
&& !dialog.Users?.some((userDialog) => userDialog._id === profile.characters.pmc.sessionId)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!dialog.Users)
|
if (!dialog.Users)
|
||||||
@ -237,7 +237,7 @@ export class DialogueController
|
|||||||
{
|
{
|
||||||
result.push(...dialogUsers);
|
result.push(...dialogUsers);
|
||||||
|
|
||||||
if (!result.find((userDialog) => userDialog._id === fullProfile.info.id))
|
if (!result.some((userDialog) => userDialog._id === fullProfile.info.id))
|
||||||
{
|
{
|
||||||
// Player doesnt exist, add them in before returning
|
// Player doesnt exist, add them in before returning
|
||||||
const pmcProfile = fullProfile.characters.pmc;
|
const pmcProfile = fullProfile.characters.pmc;
|
||||||
|
@ -117,7 +117,7 @@ export class HealthController
|
|||||||
const output = this.eventOutputHolder.getOutput(sessionID);
|
const output = this.eventOutputHolder.getOutput(sessionID);
|
||||||
let resourceLeft = 0;
|
let resourceLeft = 0;
|
||||||
|
|
||||||
const itemToConsume = pmcData.Inventory.items.find((x) => x._id === request.item);
|
const itemToConsume = pmcData.Inventory.items.find((item) => item._id === request.item);
|
||||||
if (!itemToConsume)
|
if (!itemToConsume)
|
||||||
{
|
{
|
||||||
// Item not found, very bad
|
// Item not found, very bad
|
||||||
|
@ -321,7 +321,8 @@ export class HideoutController
|
|||||||
|
|
||||||
// Set child area level to same as parent area
|
// Set child area level to same as parent area
|
||||||
pmcData.Hideout.Areas
|
pmcData.Hideout.Areas
|
||||||
.find((x) => x.type === childDbArea.type).level = pmcData.Hideout.Areas
|
.find((hideoutArea) => hideoutArea.type === childDbArea.type).level
|
||||||
|
= pmcData.Hideout.Areas
|
||||||
.find((x) => x.type === profileParentHideoutArea.type,
|
.find((x) => x.type === profileParentHideoutArea.type,
|
||||||
).level;
|
).level;
|
||||||
|
|
||||||
@ -346,7 +347,7 @@ export class HideoutController
|
|||||||
hideoutStage: Stage,
|
hideoutStage: Stage,
|
||||||
): void
|
): void
|
||||||
{
|
{
|
||||||
const existingInventoryItem = pmcData.Inventory.items.find((x) => x._id === dbHideoutData._id);
|
const existingInventoryItem = pmcData.Inventory.items.find((item) => item._id === dbHideoutData._id);
|
||||||
if (existingInventoryItem)
|
if (existingInventoryItem)
|
||||||
{
|
{
|
||||||
// Update existing items container tpl to point to new id (tpl)
|
// Update existing items container tpl to point to new id (tpl)
|
||||||
@ -599,7 +600,7 @@ export class HideoutController
|
|||||||
|
|
||||||
// Find the recipe of the production
|
// Find the recipe of the production
|
||||||
const recipe = this.databaseService.getHideout().production
|
const recipe = this.databaseService.getHideout().production
|
||||||
.find((p) => p._id === body.recipeId);
|
.find((production) => production._id === body.recipeId);
|
||||||
|
|
||||||
// Find the actual amount of items we need to remove because body can send weird data
|
// Find the actual amount of items we need to remove because body can send weird data
|
||||||
const recipeRequirementsClone = this.cloner.clone(
|
const recipeRequirementsClone = this.cloner.clone(
|
||||||
@ -1203,7 +1204,7 @@ export class HideoutController
|
|||||||
public recordShootingRangePoints(sessionId: string, pmcData: IPmcData, request: IRecordShootingRangePoints): void
|
public recordShootingRangePoints(sessionId: string, pmcData: IPmcData, request: IRecordShootingRangePoints): void
|
||||||
{
|
{
|
||||||
// Check if counter exists, add placeholder if it doesnt
|
// Check if counter exists, add placeholder if it doesnt
|
||||||
if (!pmcData.Stats.Eft.OverallCounters.Items.find((x) => x.Key.includes("ShootingRangePoints")))
|
if (!pmcData.Stats.Eft.OverallCounters.Items.some((counter) => counter.Key.includes("ShootingRangePoints")))
|
||||||
{
|
{
|
||||||
pmcData.Stats.Eft.OverallCounters.Items.push({ Key: ["ShootingRangePoints"], Value: 0 });
|
pmcData.Stats.Eft.OverallCounters.Items.push({ Key: ["ShootingRangePoints"], Value: 0 });
|
||||||
}
|
}
|
||||||
|
@ -540,26 +540,21 @@ export class InventoryController
|
|||||||
*/
|
*/
|
||||||
public tagItem(pmcData: IPmcData, body: IInventoryTagRequestData, sessionID: string): IItemEventRouterResponse
|
public tagItem(pmcData: IPmcData, body: IInventoryTagRequestData, sessionID: string): IItemEventRouterResponse
|
||||||
{
|
{
|
||||||
// TODO - replace with single .find() call
|
const itemToTag = pmcData.Inventory.items.find((item) => item._id === body.item);
|
||||||
for (const item of pmcData.Inventory.items)
|
if (!itemToTag)
|
||||||
{
|
{
|
||||||
if (item._id === body.item)
|
return { warnings: [], profileChanges: {} };
|
||||||
{
|
|
||||||
if ("upd" in item)
|
|
||||||
{
|
|
||||||
item.upd.Tag = { Color: body.TagColor, Name: body.TagName };
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (!itemToTag.upd)
|
||||||
{
|
{
|
||||||
item.upd = { Tag: { Color: body.TagColor, Name: body.TagName } };
|
itemToTag.upd = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
itemToTag.upd.Tag = { Color: body.TagColor, Name: body.TagName };
|
||||||
|
|
||||||
return this.eventOutputHolder.getOutput(sessionID);
|
return this.eventOutputHolder.getOutput(sessionID);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return { warnings: [], profileChanges: {} };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind an inventory item to the quick access menu at bottom of player screen
|
* Bind an inventory item to the quick access menu at bottom of player screen
|
||||||
@ -651,12 +646,8 @@ export class InventoryController
|
|||||||
|
|
||||||
if (!itemId)
|
if (!itemId)
|
||||||
{
|
{
|
||||||
// player inventory
|
// Player inventory
|
||||||
const target = pmcData.Inventory.items.find((item) =>
|
const target = pmcData.Inventory.items.find((item) => item._id === body.item);
|
||||||
{
|
|
||||||
return body.item === item._id;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
itemId = target._tpl;
|
itemId = target._tpl;
|
||||||
@ -719,7 +710,7 @@ export class InventoryController
|
|||||||
if (request.fromOwner.id === Traders.FENCE)
|
if (request.fromOwner.id === Traders.FENCE)
|
||||||
{
|
{
|
||||||
// Get tpl from fence assorts
|
// Get tpl from fence assorts
|
||||||
return this.fenceService.getRawFenceAssorts().items.find((x) => x._id === request.item)._tpl;
|
return this.fenceService.getRawFenceAssorts().items.find((x) => x._id === request.item)?._tpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.fromOwner.type === "Trader")
|
if (request.fromOwner.type === "Trader")
|
||||||
@ -727,7 +718,7 @@ export class InventoryController
|
|||||||
// Not fence
|
// Not fence
|
||||||
// get tpl from trader assort
|
// get tpl from trader assort
|
||||||
return this.databaseService.getTrader(request.fromOwner.id).assort.items
|
return this.databaseService.getTrader(request.fromOwner.id).assort.items
|
||||||
.find((item) => item._id === request.item)._tpl;
|
.find((item) => item._id === request.item)?._tpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.fromOwner.type === "RagFair")
|
if (request.fromOwner.type === "RagFair")
|
||||||
@ -932,8 +923,8 @@ export class InventoryController
|
|||||||
// Hard coded to `SYSTEM` for now
|
// Hard coded to `SYSTEM` for now
|
||||||
// TODO: make this dynamic
|
// TODO: make this dynamic
|
||||||
const dialog = fullProfile.dialogues["59e7125688a45068a6249071"];
|
const dialog = fullProfile.dialogues["59e7125688a45068a6249071"];
|
||||||
const mail = dialog.messages.find((x) => x._id === event.MessageId);
|
const mail = dialog.messages.find((message) => message._id === event.MessageId);
|
||||||
const mailEvent = mail.profileChangeEvents.find((x) => x._id === event.EventId);
|
const mailEvent = mail.profileChangeEvents.find((changeEvent) => changeEvent._id === event.EventId);
|
||||||
|
|
||||||
switch (mailEvent.Type)
|
switch (mailEvent.Type)
|
||||||
{
|
{
|
||||||
|
@ -158,7 +158,7 @@ export class RagfairController
|
|||||||
public getOfferById(sessionId: string, request: IGetRagfairOfferByIdRequest): IRagfairOffer
|
public getOfferById(sessionId: string, request: IGetRagfairOfferByIdRequest): IRagfairOffer
|
||||||
{
|
{
|
||||||
const offers = this.ragfairOfferService.getOffers();
|
const offers = this.ragfairOfferService.getOffers();
|
||||||
const offerToReturn = offers.find((x) => x.intId === request.id);
|
const offerToReturn = offers.find((offer) => offer.intId === request.id);
|
||||||
|
|
||||||
return offerToReturn;
|
return offerToReturn;
|
||||||
}
|
}
|
||||||
@ -659,7 +659,7 @@ export class RagfairController
|
|||||||
const loyalLevel = 1;
|
const loyalLevel = 1;
|
||||||
const formattedItems: Item[] = items.map((item) =>
|
const formattedItems: Item[] = items.map((item) =>
|
||||||
{
|
{
|
||||||
const isChild = items.find((it) => it._id === item.parentId);
|
const isChild = items.some((it) => it._id === item.parentId);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
_id: item._id,
|
_id: item._id,
|
||||||
|
@ -461,8 +461,8 @@ export class BotEquipmentModGenerator
|
|||||||
// Force spawn chance to be 100% to ensure it gets added
|
// Force spawn chance to be 100% to ensure it gets added
|
||||||
if (
|
if (
|
||||||
modSlot === "mod_handguard"
|
modSlot === "mod_handguard"
|
||||||
&& modToAddTemplate._props.Slots.find((slot) => slot._name === "mod_handguard")
|
&& modToAddTemplate._props.Slots.some((slot) => slot._name === "mod_handguard")
|
||||||
&& !request.weapon.find((item) => item.slotId === "mod_launcher")
|
&& !request.weapon.some((item) => item.slotId === "mod_launcher")
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Needed for handguards with lower
|
// Needed for handguards with lower
|
||||||
@ -473,7 +473,7 @@ export class BotEquipmentModGenerator
|
|||||||
// Or if mod_stock is configured to be forced on
|
// Or if mod_stock is configured to be forced on
|
||||||
if (
|
if (
|
||||||
modSlot === "mod_stock"
|
modSlot === "mod_stock"
|
||||||
&& modToAddTemplate._props.Slots.find(
|
&& modToAddTemplate._props.Slots.some(
|
||||||
(slot) => slot._name.includes("mod_stock") || botEquipConfig.forceStock,
|
(slot) => slot._name.includes("mod_stock") || botEquipConfig.forceStock,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -344,12 +344,12 @@ export class BotLootGenerator
|
|||||||
{
|
{
|
||||||
const result = [EquipmentSlots.POCKETS];
|
const result = [EquipmentSlots.POCKETS];
|
||||||
|
|
||||||
if (botInventory.items.find((item) => item.slotId === EquipmentSlots.TACTICAL_VEST))
|
if (botInventory.items.some((item) => item.slotId === EquipmentSlots.TACTICAL_VEST))
|
||||||
{
|
{
|
||||||
result.push(EquipmentSlots.TACTICAL_VEST);
|
result.push(EquipmentSlots.TACTICAL_VEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (botInventory.items.find((item) => item.slotId === EquipmentSlots.BACKPACK))
|
if (botInventory.items.some((item) => item.slotId === EquipmentSlots.BACKPACK))
|
||||||
{
|
{
|
||||||
result.push(EquipmentSlots.BACKPACK);
|
result.push(EquipmentSlots.BACKPACK);
|
||||||
}
|
}
|
||||||
|
@ -375,10 +375,10 @@ export class BotWeaponGenerator
|
|||||||
for (const modSlotTemplate of modTemplate._props.Slots.filter((slot) => slot._required))
|
for (const modSlotTemplate of modTemplate._props.Slots.filter((slot) => slot._required))
|
||||||
{
|
{
|
||||||
const slotName = modSlotTemplate._name;
|
const slotName = modSlotTemplate._name;
|
||||||
const weaponSlotItem = weaponItemArray.find(
|
const hasWeaponSlotItem = weaponItemArray.some(
|
||||||
(weaponItem) => weaponItem.parentId === mod._id && weaponItem.slotId === slotName,
|
(weaponItem) => weaponItem.parentId === mod._id && weaponItem.slotId === slotName,
|
||||||
);
|
);
|
||||||
if (!weaponSlotItem)
|
if (!hasWeaponSlotItem)
|
||||||
{
|
{
|
||||||
this.logger.warning(
|
this.logger.warning(
|
||||||
this.localisationService.getText("bot-weapons_required_slot_missing_item", {
|
this.localisationService.getText("bot-weapons_required_slot_missing_item", {
|
||||||
|
@ -841,7 +841,7 @@ export class LocationGenerator
|
|||||||
locationTemplateToAdd.Items[0]._id = locationTemplateToAdd.Root;
|
locationTemplateToAdd.Items[0]._id = locationTemplateToAdd.Root;
|
||||||
|
|
||||||
// Push forced location into array as long as it doesnt exist already
|
// Push forced location into array as long as it doesnt exist already
|
||||||
const existingLocation = lootLocationTemplates.find(
|
const existingLocation = lootLocationTemplates.some(
|
||||||
(spawnPoint) => spawnPoint.Id === locationTemplateToAdd.Id,
|
(spawnPoint) => spawnPoint.Id === locationTemplateToAdd.Id,
|
||||||
);
|
);
|
||||||
if (!existingLocation)
|
if (!existingLocation)
|
||||||
|
@ -802,9 +802,7 @@ export class HideoutHelper
|
|||||||
*/
|
*/
|
||||||
protected getTotalProductionTimeSeconds(prodId: string): number
|
protected getTotalProductionTimeSeconds(prodId: string): number
|
||||||
{
|
{
|
||||||
const recipe = this.databaseService.getHideout().production.find((prod) => prod._id === prodId);
|
return this.databaseService.getHideout().production.find((prod) => prod._id === prodId)?.productionTime ?? 0;
|
||||||
|
|
||||||
return recipe.productionTime || 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1305,7 +1305,7 @@ export class InventoryHelper
|
|||||||
*/
|
*/
|
||||||
public isItemInStash(pmcData: IPmcData, itemToCheck: Item): boolean
|
public isItemInStash(pmcData: IPmcData, itemToCheck: Item): boolean
|
||||||
{
|
{
|
||||||
let container = itemToCheck;
|
const container = itemToCheck;
|
||||||
|
|
||||||
while ("parentId" in container)
|
while ("parentId" in container)
|
||||||
{
|
{
|
||||||
@ -1314,12 +1314,12 @@ export class InventoryHelper
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
container = pmcData.Inventory.items.find((item) => item._id === container.parentId);
|
if (!pmcData.Inventory.items.some((item) => item._id === container.parentId))
|
||||||
if (!container)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ export class ItemHelper
|
|||||||
|
|
||||||
// Check if item has slots that match soft insert name ids
|
// Check if item has slots that match soft insert name ids
|
||||||
const softInsertIds = this.getSoftInsertSlotIds();
|
const softInsertIds = this.getSoftInsertSlotIds();
|
||||||
if (itemDbDetails[1]._props.Slots.find((slot) => softInsertIds.includes(slot._name.toLowerCase())))
|
if (itemDbDetails[1]._props.Slots.some((slot) => softInsertIds.includes(slot._name.toLowerCase())))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -668,7 +668,7 @@ export class ItemHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Items parentid matches root item AND returned items doesnt contain current child
|
// Items parentid matches root item AND returned items doesnt contain current child
|
||||||
if (childItem.parentId === baseItemId && !list.find((item) => childItem._id === item._id))
|
if (childItem.parentId === baseItemId && !list.some((item) => childItem._id === item._id))
|
||||||
{
|
{
|
||||||
list.push(...this.findAndReturnChildrenAsItems(items, childItem._id));
|
list.push(...this.findAndReturnChildrenAsItems(items, childItem._id));
|
||||||
}
|
}
|
||||||
@ -689,7 +689,7 @@ export class ItemHelper
|
|||||||
|
|
||||||
for (const itemFromAssort of assort)
|
for (const itemFromAssort of assort)
|
||||||
{
|
{
|
||||||
if (itemFromAssort.parentId === itemIdToFind && !list.find((item) => itemFromAssort._id === item._id))
|
if (itemFromAssort.parentId === itemIdToFind && !list.some((item) => itemFromAssort._id === item._id))
|
||||||
{
|
{
|
||||||
list.push(itemFromAssort);
|
list.push(itemFromAssort);
|
||||||
list = list.concat(this.findAndReturnChildrenByAssort(itemFromAssort._id, assort));
|
list = list.concat(this.findAndReturnChildrenByAssort(itemFromAssort._id, assort));
|
||||||
@ -1260,7 +1260,7 @@ export class ItemHelper
|
|||||||
const cartridgeMaxStackSize = cartridgeDetails[1]._props.StackMaxSize;
|
const cartridgeMaxStackSize = cartridgeDetails[1]._props.StackMaxSize;
|
||||||
|
|
||||||
// Exit if ammo already exists in box
|
// Exit if ammo already exists in box
|
||||||
if (ammoBox.find((item) => item._tpl === cartridgeTpl))
|
if (ammoBox.some((item) => item._tpl === cartridgeTpl))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1107,7 +1107,7 @@ export class QuestHelper
|
|||||||
{
|
{
|
||||||
// Quest from db matches quests in profile, skip
|
// Quest from db matches quests in profile, skip
|
||||||
const questData = quests[questIdKey];
|
const questData = quests[questIdKey];
|
||||||
if (pmcProfile.Quests.find((x) => x.qid === questData._id))
|
if (pmcProfile.Quests.some((x) => x.qid === questData._id))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ export class RagfairHelper
|
|||||||
for (let item of items)
|
for (let item of items)
|
||||||
{
|
{
|
||||||
item = this.itemHelper.fixItemStackCount(item);
|
item = this.itemHelper.fixItemStackCount(item);
|
||||||
const isChild = items.find((it) => it._id === item.parentId);
|
const isChild = items.some((it) => it._id === item.parentId);
|
||||||
|
|
||||||
if (!isChild)
|
if (!isChild)
|
||||||
{
|
{
|
||||||
|
@ -790,7 +790,7 @@ export class RagfairOfferHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!traderAssorts[offer.user.id].items.find((item) =>
|
!traderAssorts[offer.user.id].items.some((item) =>
|
||||||
{
|
{
|
||||||
return item._id === offer.root;
|
return item._id === offer.root;
|
||||||
})
|
})
|
||||||
|
@ -80,7 +80,7 @@ export class CustomLocationWaveService
|
|||||||
|
|
||||||
for (const bossWave of bossWavesToApply[mapKey])
|
for (const bossWave of bossWavesToApply[mapKey])
|
||||||
{
|
{
|
||||||
if (locationBase.BossLocationSpawn.find((x) => x.sptId === bossWave.sptId))
|
if (locationBase.BossLocationSpawn.some((x) => x.sptId === bossWave.sptId))
|
||||||
{
|
{
|
||||||
// Already exists, skip
|
// Already exists, skip
|
||||||
continue;
|
continue;
|
||||||
@ -104,7 +104,7 @@ export class CustomLocationWaveService
|
|||||||
|
|
||||||
for (const normalWave of normalWavesToApply[mapKey])
|
for (const normalWave of normalWavesToApply[mapKey])
|
||||||
{
|
{
|
||||||
if (locationBase.waves.find((x) => x.sptId === normalWave.sptId))
|
if (locationBase.waves.some((x) => x.sptId === normalWave.sptId))
|
||||||
{
|
{
|
||||||
// Already exists, skip
|
// Already exists, skip
|
||||||
continue;
|
continue;
|
||||||
|
@ -169,7 +169,7 @@ export class InsuranceService
|
|||||||
for (const insuredItem of this.getInsurance(sessionId)[traderId])
|
for (const insuredItem of this.getInsurance(sessionId)[traderId])
|
||||||
{
|
{
|
||||||
// Find insured items parent
|
// Find insured items parent
|
||||||
const insuredItemsParent = insuredItems.find((x) => x._id === insuredItem.parentId);
|
const insuredItemsParent = insuredItems.some((x) => x._id === insuredItem.parentId);
|
||||||
if (!insuredItemsParent)
|
if (!insuredItemsParent)
|
||||||
{
|
{
|
||||||
// Remove location + set slotId of insured items parent
|
// Remove location + set slotId of insured items parent
|
||||||
|
@ -196,7 +196,7 @@ export class ProfileFixerService
|
|||||||
= hideoutStandSecondaryAreaDb._id;
|
= hideoutStandSecondaryAreaDb._id;
|
||||||
|
|
||||||
// Add stash item to profile
|
// Add stash item to profile
|
||||||
const gunStandStashItem = pmcProfile.Inventory.items.find((x) => x._id === hideoutStandAreaDb._id);
|
const gunStandStashItem = pmcProfile.Inventory.items.find((item) => item._id === hideoutStandAreaDb._id);
|
||||||
if (gunStandStashItem)
|
if (gunStandStashItem)
|
||||||
{
|
{
|
||||||
gunStandStashItem._tpl = stageCurrentAt.container!;
|
gunStandStashItem._tpl = stageCurrentAt.container!;
|
||||||
@ -214,7 +214,7 @@ export class ProfileFixerService
|
|||||||
|
|
||||||
// Add secondary stash item to profile
|
// Add secondary stash item to profile
|
||||||
const gunStandStashSecondaryItem = pmcProfile.Inventory.items.find(
|
const gunStandStashSecondaryItem = pmcProfile.Inventory.items.find(
|
||||||
(x) => x._id === hideoutStandSecondaryAreaDb._id,
|
(item) => item._id === hideoutStandSecondaryAreaDb._id,
|
||||||
)!;
|
)!;
|
||||||
if (gunStandStashItem)
|
if (gunStandStashItem)
|
||||||
{
|
{
|
||||||
@ -299,7 +299,7 @@ export class ProfileFixerService
|
|||||||
pmcProfile.Inventory.hideoutAreaStashes[HideoutAreas.PLACE_OF_FAME] = placeOfFameAreaDb._id;
|
pmcProfile.Inventory.hideoutAreaStashes[HideoutAreas.PLACE_OF_FAME] = placeOfFameAreaDb._id;
|
||||||
|
|
||||||
// Add stash item to profile
|
// Add stash item to profile
|
||||||
const placeOfFameStashItem = pmcProfile.Inventory.items.find((x) => x._id === placeOfFameAreaDb._id);
|
const placeOfFameStashItem = pmcProfile.Inventory.items.find((item) => item._id === placeOfFameAreaDb._id);
|
||||||
if (placeOfFameStashItem)
|
if (placeOfFameStashItem)
|
||||||
{
|
{
|
||||||
placeOfFameStashItem._tpl = stageCurrentlyAt.container!;
|
placeOfFameStashItem._tpl = stageCurrentlyAt.container!;
|
||||||
@ -363,7 +363,7 @@ export class ProfileFixerService
|
|||||||
|
|
||||||
protected addMissingHideoutWallAreas(pmcProfile: IPmcData): void
|
protected addMissingHideoutWallAreas(pmcProfile: IPmcData): void
|
||||||
{
|
{
|
||||||
if (!pmcProfile.Hideout.Areas.find((x) => x.type === HideoutAreas.WEAPON_STAND))
|
if (!pmcProfile.Hideout.Areas.some((x) => x.type === HideoutAreas.WEAPON_STAND))
|
||||||
{
|
{
|
||||||
pmcProfile.Hideout.Areas.push({
|
pmcProfile.Hideout.Areas.push({
|
||||||
type: 24,
|
type: 24,
|
||||||
@ -377,7 +377,7 @@ export class ProfileFixerService
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pmcProfile.Hideout.Areas.find((x) => x.type === HideoutAreas.WEAPON_STAND_SECONDARY))
|
if (!pmcProfile.Hideout.Areas.some((x) => x.type === HideoutAreas.WEAPON_STAND_SECONDARY))
|
||||||
{
|
{
|
||||||
pmcProfile.Hideout.Areas.push({
|
pmcProfile.Hideout.Areas.push({
|
||||||
type: 25,
|
type: 25,
|
||||||
@ -767,7 +767,7 @@ export class ProfileFixerService
|
|||||||
{
|
{
|
||||||
for (let i = 0; i < count; i++)
|
for (let i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (!slots.find((x) => x.locationIndex === i))
|
if (!slots.some((x) => x.locationIndex === i))
|
||||||
{
|
{
|
||||||
slots.push({ locationIndex: i });
|
slots.push({ locationIndex: i });
|
||||||
}
|
}
|
||||||
@ -1168,9 +1168,9 @@ export class ProfileFixerService
|
|||||||
const itemsHaveChildren = pmcProfile.Inventory.items.some((x) => x.parentId === key);
|
const itemsHaveChildren = pmcProfile.Inventory.items.some((x) => x.parentId === key);
|
||||||
if (!itemsHaveChildren)
|
if (!itemsHaveChildren)
|
||||||
{
|
{
|
||||||
const itemToAdjustId = pmcProfile.Inventory.items.find((x) => x._id === key)!;
|
const itemToAdjust = pmcProfile.Inventory.items.find((x) => x._id === key)!;
|
||||||
itemToAdjustId._id = this.hashUtil.generate();
|
itemToAdjust._id = this.hashUtil.generate();
|
||||||
this.logger.warning(`Replace duplicate item Id: ${key} with ${itemToAdjustId._id}`);
|
this.logger.warning(`Replace duplicate item Id: ${key} with ${itemToAdjust._id}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1285,7 +1285,7 @@ export class ProfileFixerService
|
|||||||
// Get all areas from templates/profiles.json
|
// Get all areas from templates/profiles.json
|
||||||
for (const area of profileTemplate.character.Hideout.Areas)
|
for (const area of profileTemplate.character.Hideout.Areas)
|
||||||
{
|
{
|
||||||
if (!pmcProfile.Hideout.Areas.find((x) => x.type === area.type))
|
if (!pmcProfile.Hideout.Areas.some((x) => x.type === area.type))
|
||||||
{
|
{
|
||||||
pmcProfile.Hideout.Areas.push(area);
|
pmcProfile.Hideout.Areas.push(area);
|
||||||
this.logger.debug(`Added missing hideout area ${area.type} to profile`);
|
this.logger.debug(`Added missing hideout area ${area.type} to profile`);
|
||||||
@ -1444,7 +1444,7 @@ export class ProfileFixerService
|
|||||||
|
|
||||||
for (let i = profileQuests.length - 1; i >= 0; i--)
|
for (let i = profileQuests.length - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (!(quests[profileQuests[i].qid] || repeatableQuests.find((x) => x._id === profileQuests[i].qid)))
|
if (!(quests[profileQuests[i].qid] || repeatableQuests.some((x) => x._id === profileQuests[i].qid)))
|
||||||
{
|
{
|
||||||
profileQuests.splice(i, 1);
|
profileQuests.splice(i, 1);
|
||||||
this.logger.success("Successfully removed orphaned quest that doesnt exist in our quest data");
|
this.logger.success("Successfully removed orphaned quest that doesnt exist in our quest data");
|
||||||
|
@ -441,7 +441,7 @@ export class SeasonalEventService
|
|||||||
const locations = this.databaseService.getLocations();
|
const locations = this.databaseService.getLocations();
|
||||||
|
|
||||||
const mapBosses: BossLocationSpawn[] = locations[mapKey].base.BossLocationSpawn;
|
const mapBosses: BossLocationSpawn[] = locations[mapKey].base.BossLocationSpawn;
|
||||||
if (!mapBosses.find((bossSpawn) => bossSpawn.BossName === boss.BossName))
|
if (!mapBosses.some((bossSpawn) => bossSpawn.BossName === boss.BossName))
|
||||||
{
|
{
|
||||||
locations[mapKey].base.BossLocationSpawn.push(...bossesToAdd);
|
locations[mapKey].base.BossLocationSpawn.push(...bossesToAdd);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user