ScavXpCounts/types/helpers/HandbookHelper.d.ts

72 lines
2.7 KiB
TypeScript
Raw Normal View History

2024-02-23 15:06:00 -07:00
import { Category } from "@spt-aki/models/eft/common/tables/IHandbookBase";
2024-04-19 21:23:52 -06:00
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";
2024-02-23 15:06:00 -07:00
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
2023-08-17 19:49:16 -06: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-02-23 15:06:00 -07:00
protected jsonUtil: JsonUtil;
2024-04-19 21:23:52 -06:00
protected configServer: ConfigServer;
protected itemConfig: IItemConfig;
2023-08-17 19:49:16 -06:00
protected lookupCacheGenerated: boolean;
protected handbookPriceCache: LookupCollection;
2024-04-19 21:23:52 -06:00
constructor(databaseServer: DatabaseServer, jsonUtil: JsonUtil, configServer: ConfigServer);
2023-08-17 19:49:16 -06:00
/**
* Create an in-memory cache of all items with associated handbook price in handbookPriceCache class
*/
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-19 21:23:52 -06:00
getTemplatePriceForItems(items: Item[]): number;
2023-08-17 19:49:16 -06:00
/**
* Get all items in template with the given parent category
* @param parentId
* @returns string array
*/
templatesWithParent(parentId: string): string[];
/**
* Does category exist in handbook cache
* @param category
* @returns true if exists in cache
*/
isCategory(category: string): boolean;
/**
* Get all items associated with a categories parent
* @param categoryParent
* @returns string array
*/
childrenCategories(categoryParent: string): string[];
/**
* 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-02-23 15:06:00 -07:00
getCategoryById(handbookId: string): Category;
2023-08-17 19:49:16 -06:00
}
export {};