Refactor removeSecureContainer()
This commit is contained in:
parent
08be8654e4
commit
cbf06fcece
@ -278,25 +278,15 @@ export class ProfileHelper
|
|||||||
public removeSecureContainer(profile: IPmcData): IPmcData
|
public removeSecureContainer(profile: IPmcData): IPmcData
|
||||||
{
|
{
|
||||||
const items = profile.Inventory.items;
|
const items = profile.Inventory.items;
|
||||||
for (const item of items)
|
const secureContainer = items.find(x => x.slotId === "SecuredContainer");
|
||||||
|
if (secureContainer)
|
||||||
{
|
{
|
||||||
if (item.slotId === "SecuredContainer")
|
// Find and remove container + children
|
||||||
{
|
const childItemsInSecureContainer = this.itemHelper.findAndReturnChildrenByItems(items, secureContainer._id);
|
||||||
const toRemove = this.itemHelper.findAndReturnChildrenByItems(items, item._id);
|
|
||||||
let n = items.length;
|
|
||||||
|
|
||||||
while (n-- > 0)
|
// Remove child items + secure container
|
||||||
{
|
profile.Inventory.items = items.filter(x => !childItemsInSecureContainer.includes(x._id));
|
||||||
if (toRemove.includes(items[n]._id))
|
|
||||||
{
|
|
||||||
items.splice(n, 1);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.Inventory.items = items;
|
|
||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user