mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -05:00
Rebranded src code and scripts to SPT Co-authored-by: clodan <clodan@clodan.com> Reviewed-on: SPT-AKI/Server#345 Co-authored-by: Alex <clodan@noreply.dev.sp-tarkov.com> Co-committed-by: Alex <clodan@noreply.dev.sp-tarkov.com>
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { inject, injectable } from "tsyringe";
|
|
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
|
import { Item } from "@spt/models/eft/common/tables/IItem";
|
|
|
|
export interface OwnerInventoryItems
|
|
{
|
|
from: Item[]
|
|
to: Item[]
|
|
sameInventory: boolean
|
|
isMail: boolean
|
|
}
|
|
|
|
@injectable()
|
|
export class SecureContainerHelper
|
|
{
|
|
constructor(@inject("ItemHelper") protected itemHelper: ItemHelper)
|
|
{}
|
|
|
|
/**
|
|
* Get an array of the item IDs (NOT tpls) inside a secure container
|
|
* @param items Inventory items to look for secure container in
|
|
* @returns Array of ids
|
|
*/
|
|
public getSecureContainerItems(items: Item[]): string[]
|
|
{
|
|
const secureContainer = items.find((x) => x.slotId === "SecuredContainer");
|
|
|
|
// No container found, drop out
|
|
if (!secureContainer)
|
|
{
|
|
return [];
|
|
}
|
|
|
|
const itemsInSecureContainer = this.itemHelper.findAndReturnChildrenByItems(items, secureContainer._id);
|
|
|
|
// Return all items returned and exclude the secure container item itself
|
|
return itemsInSecureContainer.filter((x) => x !== secureContainer._id);
|
|
}
|
|
}
|