two-slot-extended-mags/types/helpers/HandbookHelper.d.ts

72 lines
2.7 KiB
TypeScript
Raw Normal View History

2024-04-03 20:15:11 +11:00
import { Category } from "@spt-aki/models/eft/common/tables/IHandbookBase";
import { Item } from "@spt-aki/models/eft/common/tables/IItem";
import { IItemConfig } from "@spt-aki/models/spt/config/IItemConfig";
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
2023-06-11 15:10:34 +10:00
declare class LookupItem<T, I> {
readonly byId: Map<string, T>;
readonly byParent: Map<string, I[]>;
constructor();
}
export declare class LookupCollection {
readonly items: LookupItem<number, string>;
readonly categories: LookupItem<string, string>;
constructor();
}
export declare class HandbookHelper {
protected databaseServer: DatabaseServer;
2024-04-03 20:15:11 +11:00
protected jsonUtil: JsonUtil;
protected configServer: ConfigServer;
protected itemConfig: IItemConfig;
2023-06-11 15:10:34 +10:00
protected lookupCacheGenerated: boolean;
protected handbookPriceCache: LookupCollection;
2024-04-03 20:15:11 +11:00
constructor(databaseServer: DatabaseServer, jsonUtil: JsonUtil, configServer: ConfigServer);
2023-10-09 20:21:00 +11:00
/**
* Create an in-memory cache of all items with associated handbook price in handbookPriceCache class
*/
2023-06-11 15:10:34 +10:00
hydrateLookup(): void;
/**
* Get price from internal cache, if cache empty look up price directly in handbook (expensive)
* If no values found, return 1
* @param tpl item tpl to look up price for
* @returns price in roubles
*/
getTemplatePrice(tpl: string): number;
2024-04-03 20:15:11 +11:00
getTemplatePriceForItems(items: Item[]): number;
2023-06-11 15:10:34 +10:00
/**
2023-10-09 20:21:00 +11:00
* Get all items in template with the given parent category
* @param parentId
2023-06-11 15:10:34 +10:00
* @returns string array
*/
2023-10-09 20:21:00 +11:00
templatesWithParent(parentId: string): string[];
2023-06-11 15:10:34 +10:00
/**
* Does category exist in handbook cache
* @param category
* @returns true if exists in cache
*/
isCategory(category: string): boolean;
2023-10-09 20:21:00 +11:00
/**
* Get all items associated with a categories parent
* @param categoryParent
* @returns string array
*/
childrenCategories(categoryParent: string): string[];
2023-06-11 15:10:34 +10:00
/**
* Convert non-roubles into roubles
* @param nonRoubleCurrencyCount Currency count to convert
* @param currencyTypeFrom What current currency is
* @returns Count in roubles
*/
inRUB(nonRoubleCurrencyCount: number, currencyTypeFrom: string): number;
/**
* Convert roubles into another currency
* @param roubleCurrencyCount roubles to convert
* @param currencyTypeTo Currency to convert roubles into
* @returns currency count in desired type
*/
fromRUB(roubleCurrencyCount: number, currencyTypeTo: string): number;
2024-04-03 20:15:11 +11:00
getCategoryById(handbookId: string): Category;
2023-06-11 15:10:34 +10:00
}
export {};