Valens-Progression/types/helpers/TraderHelper.d.ts

159 lines
7.2 KiB
TypeScript
Raw Normal View History

import { FenceLevel } from "../models/eft/common/IGlobals";
import { IPmcData } from "../models/eft/common/IPmcData";
import { Item } from "../models/eft/common/tables/IItem";
import { IBarterScheme, ITraderAssort, ITraderBase, LoyaltyLevel } from "../models/eft/common/tables/ITrader";
import { ITraderConfig } from "../models/spt/config/ITraderConfig";
import { ILogger } from "../models/spt/utils/ILogger";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { SaveServer } from "../servers/SaveServer";
import { FenceService } from "../services/FenceService";
2022-12-25 18:45:30 -05:00
import { LocalisationService } from "../services/LocalisationService";
import { PlayerService } from "../services/PlayerService";
import { TimeUtil } from "../utils/TimeUtil";
import { HandbookHelper } from "./HandbookHelper";
import { ItemHelper } from "./ItemHelper";
import { PaymentHelper } from "./PaymentHelper";
import { ProfileHelper } from "./ProfileHelper";
export declare class TraderHelper {
protected logger: ILogger;
protected databaseServer: DatabaseServer;
protected saveServer: SaveServer;
protected profileHelper: ProfileHelper;
protected paymentHelper: PaymentHelper;
protected itemHelper: ItemHelper;
protected handbookHelper: HandbookHelper;
protected playerService: PlayerService;
2022-12-25 18:45:30 -05:00
protected localisationService: LocalisationService;
protected fenceService: FenceService;
protected timeUtil: TimeUtil;
protected configServer: ConfigServer;
protected traderConfig: ITraderConfig;
2023-02-12 23:21:22 -05:00
/** Dictionary of item tpl and the highest trader rouble price */
protected highestTraderPriceItems: Record<string, number>;
2022-12-25 18:45:30 -05:00
constructor(logger: ILogger, databaseServer: DatabaseServer, saveServer: SaveServer, profileHelper: ProfileHelper, paymentHelper: PaymentHelper, itemHelper: ItemHelper, handbookHelper: HandbookHelper, playerService: PlayerService, localisationService: LocalisationService, fenceService: FenceService, timeUtil: TimeUtil, configServer: ConfigServer);
getTrader(traderID: string, sessionID: string): ITraderBase;
getTraderAssortsById(traderId: string): ITraderAssort;
/**
* Reset a profiles trader data back to its initial state as seen by a level 1 player
* Does NOT take into account different profile levels
* @param sessionID session id
* @param traderID trader id to reset
*/
resetTrader(sessionID: string, traderID: string): void;
/**
* Alter a traders unlocked status
2023-02-12 23:21:22 -05:00
* @param traderId Trader to alter
* @param status New status to use
2023-02-12 23:21:22 -05:00
* @param sessionId Session id
*/
2023-02-12 23:21:22 -05:00
setTraderUnlockedState(traderId: string, status: boolean, sessionId: string): void;
/**
* Get a list of items and their prices from player inventory that can be sold to a trader
* @param traderID trader id being traded with
* @param sessionID session id
* @returns IBarterScheme[][]
*/
getPurchasesData(traderID: string, sessionID: string): Record<string, IBarterScheme[][]>;
/**
* Should item be skipped when selling to trader according to its sell categories and other checks
2022-12-25 18:45:30 -05:00
* @param pmcData Profile
* @param item Item to be checked is sellable to trader
* @param sellCategory categories trader will buy
* @param traderId Trader item is being checked can be sold to
* @returns true if should NOT be sold to trader
*/
2022-12-25 18:45:30 -05:00
protected isItemUnSellableToTrader(pmcData: IPmcData, item: Item, sellCategory: string[], traderId: string): boolean;
/**
2022-12-25 18:45:30 -05:00
* Check if item has durability so low it precludes it from being sold to the trader (inclusive)
* @param item Item to check durability of
* @param traderId Trader item is sold to
* @returns
*/
2022-12-25 18:45:30 -05:00
protected itemIsBelowSellableDurabilityThreshhold(item: Item, traderId: string): boolean;
/**
* Get the percentage threshold value a trader will buy armor/weapons above
* @param traderId Trader to look up
* @returns percentage
*/
protected getTraderDurabiltyPurchaseThreshold(traderId: string): number;
/**
2023-01-15 00:21:11 -05:00
* Get the price of passed in item and all of its attached children (mods)
2023-02-12 23:21:22 -05:00
* Take into account bonuses/adjustments e.g. discounts
* @param pmcData profile data
* @param item item to calculate price of
* @param buyPriceCoefficient
* @param fenceInfo fence data
* @param traderBase trader details
* @param currencyTpl Currency to get price as
* @returns price of item + children
*/
protected getAdjustedItemPrice(pmcData: IPmcData, item: Item, buyPriceCoefficient: number, fenceInfo: FenceLevel, traderBase: ITraderBase, currencyTpl: string): number;
/**
* Get the raw price of item+child items from handbook without any modification
* @param pmcData profile data
* @param item item to calculate price of
* @returns price as number
*/
protected getRawItemPrice(pmcData: IPmcData, item: Item): number;
2023-01-15 00:21:11 -05:00
/**
* Get discount modifier for desired trader
* @param trader Trader to get discount for
* @param buyPriceCoefficient
* @param fenceInfo fence info, needed if getting fence modifier value
* @returns discount modifier value
*/
protected getTraderDiscount(trader: ITraderBase, buyPriceCoefficient: number, fenceInfo: FenceLevel): number;
/**
* Add standing to a trader and level them up if exp goes over level threshold
2023-02-12 23:21:22 -05:00
* @param sessionId Session id
* @param traderId Traders id
* @param standingToAdd Standing value to add to trader
*/
2023-02-12 23:21:22 -05:00
addStandingToTrader(sessionId: string, traderId: string, standingToAdd: number): void;
/**
* Calculate traders level based on exp amount and increments level if over threshold
* @param traderID trader to process
* @param sessionID session id
*/
lvlUp(traderID: string, sessionID: string): void;
/**
* Get the next update timestamp for a trader
* @param traderID Trader to look up update value for
* @returns future timestamp
*/
getNextUpdateTimestamp(traderID: string): number;
/**
* Get the reset time between trader assort refreshes in seconds
* @param traderId Trader to look up
* @returns Time in seconds
*/
getTraderUpdateSeconds(traderId: string): number;
/**
* check if an item is allowed to be sold to a trader
2022-12-25 18:45:30 -05:00
* @param categoriesTraderBuys array of allowed categories
* @param tplToCheck itemTpl of inventory
2022-12-25 18:45:30 -05:00
* @returns boolean if item can be sold to trader
*/
2022-12-25 18:45:30 -05:00
doesTraderBuyItem(categoriesTraderBuys: string[], tplToCheck: string): boolean;
getLoyaltyLevel(traderID: string, pmcData: IPmcData): LoyaltyLevel;
2022-12-25 18:45:30 -05:00
/**
* Store the purchase of an assort from a trader in the player profile
* @param sessionID Session id
* @param newPurchaseDetails New item assort id + count
*/
addTraderPurchasesToPlayerProfile(sessionID: string, newPurchaseDetails: {
items: {
item_id: string;
count: number;
}[];
tid: string;
}): void;
2023-02-12 23:21:22 -05:00
/**
* Get the highest rouble price for an item from traders
* @param tpl Item to look up highest pride for
* @returns highest rouble cost for item
*/
getHighestTraderPriceRouble(tpl: string): number;
}