Updated types/readme

This commit is contained in:
Dev 2024-07-16 16:58:32 +01:00
parent 66c23d6dff
commit 3be60dbf28
183 changed files with 1873 additions and 183 deletions

View File

@ -1,4 +1,4 @@
# Mod examples for v3.9.1 # Mod examples for v3.9.2
A collection of example mods that perform typical actions in SPT A collection of example mods that perform typical actions in SPT

View File

@ -77,7 +77,7 @@ export declare class BotController {
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>; generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>;
/** /**
* Create a BotGenerationDetails for the bot generator to use * Create a BotGenerationDetails for the bot generator to use
* @param condition Client data defining bot type and difficulty * @param condition Client data defining bot type and difficulty
@ -117,7 +117,7 @@ export declare class BotController {
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>; returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>;
protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void;
/** /**
* Get the difficulty passed in, if its not "asonline", get selected difficulty from config * Get the difficulty passed in, if its not "asonline", get selected difficulty from config

View File

@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData";
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData";
import { FleaOfferType } from "@spt/models/enums/FleaOfferType";
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ILogger } from "@spt/models/spt/utils/ILogger";
import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
@ -148,13 +149,52 @@ export declare class RagfairController {
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse; addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse;
/**
* Create a flea offer for a single item - uncludes an item with > 1 sized stack
* e.g. 1 ammo stack of 30 cartridges
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createSingleOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiples of the same item, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* Each item can be purchsed individually
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createMultiOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiple items, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* The entire package must be purchased in one go
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createPackOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Given a client request, determine what type of offer is being created
* single/multi/pack
* @param offerRequest Client request
* @returns FleaOfferType
*/
protected getOfferType(offerRequest: IAddOfferRequestData): FleaOfferType;
/** /**
* Charge player a listing fee for using flea, pulls charge from data previously sent by client * Charge player a listing fee for using flea, pulls charge from data previously sent by client
* @param sessionID Player id * @param sessionID Player id
* @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @param rootItem Base item being listed (used when client tax cost not found and must be done on server)
* @param pmcData Player profile * @param pmcData Player profile
* @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server) * @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server)
* @param itemStackCount How many items were listed in player (used when client tax cost not found and must be done on server) * @param itemStackCount How many items were listed by player (used when client tax cost not found and must be done on server)
* @param offerRequest Add offer request object from client * @param offerRequest Add offer request object from client
* @param output IItemEventRouterResponse * @param output IItemEventRouterResponse
* @returns True if charging tax to player failed * @returns True if charging tax to player failed
@ -180,7 +220,7 @@ export declare class RagfairController {
* @returns Array of items from player inventory * @returns Array of items from player inventory
*/ */
protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): {
items: Item[] | undefined; items: Item[][] | undefined;
errorMessage: string | undefined; errorMessage: string | undefined;
}; };
createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer;

View File

@ -33,7 +33,7 @@ export declare class RagfairHelper {
getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>; getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>;
protected getCategoryList(handbookId: string): string[]; protected getCategoryList(handbookId: string): string[];
/** /**
* Merges Root Items * Iterate over array of identical items and merge stack count
* Ragfair allows abnormally large stacks. * Ragfair allows abnormally large stacks.
*/ */
mergeStackable(items: Item[]): Item[]; mergeStackable(items: Item[]): Item[];

View File

@ -120,6 +120,12 @@ export declare class RagfairOfferHelper {
* @returns true = complete * @returns true = complete
*/ */
processOffersOnProfile(sessionID: string): boolean; processOffersOnProfile(sessionID: string): boolean;
/**
* Count up all rootitem StackObjectsCount properties of an array of items
* @param itemsInInventoryToList items to sum up
* @returns Total count
*/
getTotalStackCountSize(itemsInInventoryToList: Item[][]): number;
/** /**
* Add amount to players ragfair rating * Add amount to players ragfair rating
* @param sessionId Profile to update * @param sessionId Profile to update

View File

@ -25,7 +25,8 @@ export declare class RagfairSellHelper {
* Get array of item count and sell time (empty array = no sell) * Get array of item count and sell time (empty array = no sell)
* @param sellChancePercent chance item will sell * @param sellChancePercent chance item will sell
* @param itemSellCount count of items to sell * @param itemSellCount count of items to sell
* @param sellInOneGo All items listed get sold at once
* @returns Array of purchases of item(s) listed * @returns Array of purchases of item(s) listed
*/ */
rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[];
} }

View File

@ -0,0 +1,6 @@
export declare enum FleaOfferType {
SINGLE = 0,
MULTI = 1,
PACK = 2,
UNKNOWN = 3
}

View File

@ -1,3 +1,4 @@
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
import { Item } from "@spt/models/eft/common/tables/IItem"; import { Item } from "@spt/models/eft/common/tables/IItem";
@ -9,6 +10,7 @@ import { ConfigServer } from "@spt/servers/ConfigServer";
import { SaveServer } from "@spt/servers/SaveServer"; import { SaveServer } from "@spt/servers/SaveServer";
import { DatabaseService } from "@spt/services/DatabaseService"; import { DatabaseService } from "@spt/services/DatabaseService";
import { LocalisationService } from "@spt/services/LocalisationService"; import { LocalisationService } from "@spt/services/LocalisationService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder";
import { TimeUtil } from "@spt/utils/TimeUtil"; import { TimeUtil } from "@spt/utils/TimeUtil";
@ -18,17 +20,19 @@ export declare class RagfairOfferService {
protected databaseService: DatabaseService; protected databaseService: DatabaseService;
protected saveServer: SaveServer; protected saveServer: SaveServer;
protected ragfairServerHelper: RagfairServerHelper; protected ragfairServerHelper: RagfairServerHelper;
protected itemHelper: ItemHelper;
protected profileHelper: ProfileHelper; protected profileHelper: ProfileHelper;
protected eventOutputHolder: EventOutputHolder; protected eventOutputHolder: EventOutputHolder;
protected httpResponse: HttpResponseUtil; protected httpResponse: HttpResponseUtil;
protected localisationService: LocalisationService; protected localisationService: LocalisationService;
protected configServer: ConfigServer; protected configServer: ConfigServer;
protected cloner: ICloner;
protected playerOffersLoaded: boolean; protected playerOffersLoaded: boolean;
/** Offer id + offer object */ /** Offer id + offer object */
protected expiredOffers: Record<string, IRagfairOffer>; protected expiredOffers: Record<string, IRagfairOffer>;
protected ragfairConfig: IRagfairConfig; protected ragfairConfig: IRagfairConfig;
protected ragfairOfferHandler: RagfairOfferHolder; protected ragfairOfferHandler: RagfairOfferHolder;
constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer); constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, itemHelper: ItemHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
/** /**
* Get all offers * Get all offers
* @returns IRagfairOffer array * @returns IRagfairOffer array
@ -84,4 +88,12 @@ export declare class RagfairOfferService {
*/ */
protected processStaleOffer(staleOffer: IRagfairOffer): void; protected processStaleOffer(staleOffer: IRagfairOffer): void;
protected returnPlayerOffer(playerOffer: IRagfairOffer): void; protected returnPlayerOffer(playerOffer: IRagfairOffer): void;
/**
* Flea offer items are stacked up often beyond the StackMaxSize limit
* Un stack the items into an array of root items and their children
* Will create new items equal to the
* @param items Offer items to unstack
* @returns Unstacked array of items
*/
protected unstackOfferItems(items: Item[]): Item[];
} }

View File

@ -77,7 +77,7 @@ export declare class BotController {
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>; generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>;
/** /**
* Create a BotGenerationDetails for the bot generator to use * Create a BotGenerationDetails for the bot generator to use
* @param condition Client data defining bot type and difficulty * @param condition Client data defining bot type and difficulty
@ -117,7 +117,7 @@ export declare class BotController {
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>; returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>;
protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void;
/** /**
* Get the difficulty passed in, if its not "asonline", get selected difficulty from config * Get the difficulty passed in, if its not "asonline", get selected difficulty from config

View File

@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData";
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData";
import { FleaOfferType } from "@spt/models/enums/FleaOfferType";
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ILogger } from "@spt/models/spt/utils/ILogger";
import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
@ -148,13 +149,52 @@ export declare class RagfairController {
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse; addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse;
/**
* Create a flea offer for a single item - uncludes an item with > 1 sized stack
* e.g. 1 ammo stack of 30 cartridges
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createSingleOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiples of the same item, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* Each item can be purchsed individually
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createMultiOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiple items, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* The entire package must be purchased in one go
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createPackOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Given a client request, determine what type of offer is being created
* single/multi/pack
* @param offerRequest Client request
* @returns FleaOfferType
*/
protected getOfferType(offerRequest: IAddOfferRequestData): FleaOfferType;
/** /**
* Charge player a listing fee for using flea, pulls charge from data previously sent by client * Charge player a listing fee for using flea, pulls charge from data previously sent by client
* @param sessionID Player id * @param sessionID Player id
* @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @param rootItem Base item being listed (used when client tax cost not found and must be done on server)
* @param pmcData Player profile * @param pmcData Player profile
* @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server) * @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server)
* @param itemStackCount How many items were listed in player (used when client tax cost not found and must be done on server) * @param itemStackCount How many items were listed by player (used when client tax cost not found and must be done on server)
* @param offerRequest Add offer request object from client * @param offerRequest Add offer request object from client
* @param output IItemEventRouterResponse * @param output IItemEventRouterResponse
* @returns True if charging tax to player failed * @returns True if charging tax to player failed
@ -180,7 +220,7 @@ export declare class RagfairController {
* @returns Array of items from player inventory * @returns Array of items from player inventory
*/ */
protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): {
items: Item[] | undefined; items: Item[][] | undefined;
errorMessage: string | undefined; errorMessage: string | undefined;
}; };
createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer;

View File

@ -33,7 +33,7 @@ export declare class RagfairHelper {
getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>; getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>;
protected getCategoryList(handbookId: string): string[]; protected getCategoryList(handbookId: string): string[];
/** /**
* Merges Root Items * Iterate over array of identical items and merge stack count
* Ragfair allows abnormally large stacks. * Ragfair allows abnormally large stacks.
*/ */
mergeStackable(items: Item[]): Item[]; mergeStackable(items: Item[]): Item[];

View File

@ -120,6 +120,12 @@ export declare class RagfairOfferHelper {
* @returns true = complete * @returns true = complete
*/ */
processOffersOnProfile(sessionID: string): boolean; processOffersOnProfile(sessionID: string): boolean;
/**
* Count up all rootitem StackObjectsCount properties of an array of items
* @param itemsInInventoryToList items to sum up
* @returns Total count
*/
getTotalStackCountSize(itemsInInventoryToList: Item[][]): number;
/** /**
* Add amount to players ragfair rating * Add amount to players ragfair rating
* @param sessionId Profile to update * @param sessionId Profile to update

View File

@ -25,7 +25,8 @@ export declare class RagfairSellHelper {
* Get array of item count and sell time (empty array = no sell) * Get array of item count and sell time (empty array = no sell)
* @param sellChancePercent chance item will sell * @param sellChancePercent chance item will sell
* @param itemSellCount count of items to sell * @param itemSellCount count of items to sell
* @param sellInOneGo All items listed get sold at once
* @returns Array of purchases of item(s) listed * @returns Array of purchases of item(s) listed
*/ */
rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[];
} }

View File

@ -0,0 +1,6 @@
export declare enum FleaOfferType {
SINGLE = 0,
MULTI = 1,
PACK = 2,
UNKNOWN = 3
}

View File

@ -1,3 +1,4 @@
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
import { Item } from "@spt/models/eft/common/tables/IItem"; import { Item } from "@spt/models/eft/common/tables/IItem";
@ -9,6 +10,7 @@ import { ConfigServer } from "@spt/servers/ConfigServer";
import { SaveServer } from "@spt/servers/SaveServer"; import { SaveServer } from "@spt/servers/SaveServer";
import { DatabaseService } from "@spt/services/DatabaseService"; import { DatabaseService } from "@spt/services/DatabaseService";
import { LocalisationService } from "@spt/services/LocalisationService"; import { LocalisationService } from "@spt/services/LocalisationService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder";
import { TimeUtil } from "@spt/utils/TimeUtil"; import { TimeUtil } from "@spt/utils/TimeUtil";
@ -18,17 +20,19 @@ export declare class RagfairOfferService {
protected databaseService: DatabaseService; protected databaseService: DatabaseService;
protected saveServer: SaveServer; protected saveServer: SaveServer;
protected ragfairServerHelper: RagfairServerHelper; protected ragfairServerHelper: RagfairServerHelper;
protected itemHelper: ItemHelper;
protected profileHelper: ProfileHelper; protected profileHelper: ProfileHelper;
protected eventOutputHolder: EventOutputHolder; protected eventOutputHolder: EventOutputHolder;
protected httpResponse: HttpResponseUtil; protected httpResponse: HttpResponseUtil;
protected localisationService: LocalisationService; protected localisationService: LocalisationService;
protected configServer: ConfigServer; protected configServer: ConfigServer;
protected cloner: ICloner;
protected playerOffersLoaded: boolean; protected playerOffersLoaded: boolean;
/** Offer id + offer object */ /** Offer id + offer object */
protected expiredOffers: Record<string, IRagfairOffer>; protected expiredOffers: Record<string, IRagfairOffer>;
protected ragfairConfig: IRagfairConfig; protected ragfairConfig: IRagfairConfig;
protected ragfairOfferHandler: RagfairOfferHolder; protected ragfairOfferHandler: RagfairOfferHolder;
constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer); constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, itemHelper: ItemHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
/** /**
* Get all offers * Get all offers
* @returns IRagfairOffer array * @returns IRagfairOffer array
@ -84,4 +88,12 @@ export declare class RagfairOfferService {
*/ */
protected processStaleOffer(staleOffer: IRagfairOffer): void; protected processStaleOffer(staleOffer: IRagfairOffer): void;
protected returnPlayerOffer(playerOffer: IRagfairOffer): void; protected returnPlayerOffer(playerOffer: IRagfairOffer): void;
/**
* Flea offer items are stacked up often beyond the StackMaxSize limit
* Un stack the items into an array of root items and their children
* Will create new items equal to the
* @param items Offer items to unstack
* @returns Unstacked array of items
*/
protected unstackOfferItems(items: Item[]): Item[];
} }

View File

@ -77,7 +77,7 @@ export declare class BotController {
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>; generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>;
/** /**
* Create a BotGenerationDetails for the bot generator to use * Create a BotGenerationDetails for the bot generator to use
* @param condition Client data defining bot type and difficulty * @param condition Client data defining bot type and difficulty
@ -117,7 +117,7 @@ export declare class BotController {
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>; returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>;
protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void;
/** /**
* Get the difficulty passed in, if its not "asonline", get selected difficulty from config * Get the difficulty passed in, if its not "asonline", get selected difficulty from config

View File

@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData";
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData";
import { FleaOfferType } from "@spt/models/enums/FleaOfferType";
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ILogger } from "@spt/models/spt/utils/ILogger";
import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
@ -148,13 +149,52 @@ export declare class RagfairController {
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse; addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse;
/**
* Create a flea offer for a single item - uncludes an item with > 1 sized stack
* e.g. 1 ammo stack of 30 cartridges
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createSingleOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiples of the same item, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* Each item can be purchsed individually
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createMultiOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiple items, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* The entire package must be purchased in one go
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createPackOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Given a client request, determine what type of offer is being created
* single/multi/pack
* @param offerRequest Client request
* @returns FleaOfferType
*/
protected getOfferType(offerRequest: IAddOfferRequestData): FleaOfferType;
/** /**
* Charge player a listing fee for using flea, pulls charge from data previously sent by client * Charge player a listing fee for using flea, pulls charge from data previously sent by client
* @param sessionID Player id * @param sessionID Player id
* @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @param rootItem Base item being listed (used when client tax cost not found and must be done on server)
* @param pmcData Player profile * @param pmcData Player profile
* @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server) * @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server)
* @param itemStackCount How many items were listed in player (used when client tax cost not found and must be done on server) * @param itemStackCount How many items were listed by player (used when client tax cost not found and must be done on server)
* @param offerRequest Add offer request object from client * @param offerRequest Add offer request object from client
* @param output IItemEventRouterResponse * @param output IItemEventRouterResponse
* @returns True if charging tax to player failed * @returns True if charging tax to player failed
@ -180,7 +220,7 @@ export declare class RagfairController {
* @returns Array of items from player inventory * @returns Array of items from player inventory
*/ */
protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): {
items: Item[] | undefined; items: Item[][] | undefined;
errorMessage: string | undefined; errorMessage: string | undefined;
}; };
createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer;

View File

@ -33,7 +33,7 @@ export declare class RagfairHelper {
getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>; getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>;
protected getCategoryList(handbookId: string): string[]; protected getCategoryList(handbookId: string): string[];
/** /**
* Merges Root Items * Iterate over array of identical items and merge stack count
* Ragfair allows abnormally large stacks. * Ragfair allows abnormally large stacks.
*/ */
mergeStackable(items: Item[]): Item[]; mergeStackable(items: Item[]): Item[];

View File

@ -120,6 +120,12 @@ export declare class RagfairOfferHelper {
* @returns true = complete * @returns true = complete
*/ */
processOffersOnProfile(sessionID: string): boolean; processOffersOnProfile(sessionID: string): boolean;
/**
* Count up all rootitem StackObjectsCount properties of an array of items
* @param itemsInInventoryToList items to sum up
* @returns Total count
*/
getTotalStackCountSize(itemsInInventoryToList: Item[][]): number;
/** /**
* Add amount to players ragfair rating * Add amount to players ragfair rating
* @param sessionId Profile to update * @param sessionId Profile to update

View File

@ -25,7 +25,8 @@ export declare class RagfairSellHelper {
* Get array of item count and sell time (empty array = no sell) * Get array of item count and sell time (empty array = no sell)
* @param sellChancePercent chance item will sell * @param sellChancePercent chance item will sell
* @param itemSellCount count of items to sell * @param itemSellCount count of items to sell
* @param sellInOneGo All items listed get sold at once
* @returns Array of purchases of item(s) listed * @returns Array of purchases of item(s) listed
*/ */
rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[];
} }

View File

@ -0,0 +1,6 @@
export declare enum FleaOfferType {
SINGLE = 0,
MULTI = 1,
PACK = 2,
UNKNOWN = 3
}

View File

@ -1,3 +1,4 @@
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
import { Item } from "@spt/models/eft/common/tables/IItem"; import { Item } from "@spt/models/eft/common/tables/IItem";
@ -9,6 +10,7 @@ import { ConfigServer } from "@spt/servers/ConfigServer";
import { SaveServer } from "@spt/servers/SaveServer"; import { SaveServer } from "@spt/servers/SaveServer";
import { DatabaseService } from "@spt/services/DatabaseService"; import { DatabaseService } from "@spt/services/DatabaseService";
import { LocalisationService } from "@spt/services/LocalisationService"; import { LocalisationService } from "@spt/services/LocalisationService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder";
import { TimeUtil } from "@spt/utils/TimeUtil"; import { TimeUtil } from "@spt/utils/TimeUtil";
@ -18,17 +20,19 @@ export declare class RagfairOfferService {
protected databaseService: DatabaseService; protected databaseService: DatabaseService;
protected saveServer: SaveServer; protected saveServer: SaveServer;
protected ragfairServerHelper: RagfairServerHelper; protected ragfairServerHelper: RagfairServerHelper;
protected itemHelper: ItemHelper;
protected profileHelper: ProfileHelper; protected profileHelper: ProfileHelper;
protected eventOutputHolder: EventOutputHolder; protected eventOutputHolder: EventOutputHolder;
protected httpResponse: HttpResponseUtil; protected httpResponse: HttpResponseUtil;
protected localisationService: LocalisationService; protected localisationService: LocalisationService;
protected configServer: ConfigServer; protected configServer: ConfigServer;
protected cloner: ICloner;
protected playerOffersLoaded: boolean; protected playerOffersLoaded: boolean;
/** Offer id + offer object */ /** Offer id + offer object */
protected expiredOffers: Record<string, IRagfairOffer>; protected expiredOffers: Record<string, IRagfairOffer>;
protected ragfairConfig: IRagfairConfig; protected ragfairConfig: IRagfairConfig;
protected ragfairOfferHandler: RagfairOfferHolder; protected ragfairOfferHandler: RagfairOfferHolder;
constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer); constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, itemHelper: ItemHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
/** /**
* Get all offers * Get all offers
* @returns IRagfairOffer array * @returns IRagfairOffer array
@ -84,4 +88,12 @@ export declare class RagfairOfferService {
*/ */
protected processStaleOffer(staleOffer: IRagfairOffer): void; protected processStaleOffer(staleOffer: IRagfairOffer): void;
protected returnPlayerOffer(playerOffer: IRagfairOffer): void; protected returnPlayerOffer(playerOffer: IRagfairOffer): void;
/**
* Flea offer items are stacked up often beyond the StackMaxSize limit
* Un stack the items into an array of root items and their children
* Will create new items equal to the
* @param items Offer items to unstack
* @returns Unstacked array of items
*/
protected unstackOfferItems(items: Item[]): Item[];
} }

View File

@ -77,7 +77,7 @@ export declare class BotController {
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>; generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>;
/** /**
* Create a BotGenerationDetails for the bot generator to use * Create a BotGenerationDetails for the bot generator to use
* @param condition Client data defining bot type and difficulty * @param condition Client data defining bot type and difficulty
@ -117,7 +117,7 @@ export declare class BotController {
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>; returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>;
protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void;
/** /**
* Get the difficulty passed in, if its not "asonline", get selected difficulty from config * Get the difficulty passed in, if its not "asonline", get selected difficulty from config

View File

@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData";
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData";
import { FleaOfferType } from "@spt/models/enums/FleaOfferType";
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ILogger } from "@spt/models/spt/utils/ILogger";
import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
@ -148,13 +149,52 @@ export declare class RagfairController {
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse; addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse;
/**
* Create a flea offer for a single item - uncludes an item with > 1 sized stack
* e.g. 1 ammo stack of 30 cartridges
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createSingleOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiples of the same item, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* Each item can be purchsed individually
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createMultiOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiple items, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* The entire package must be purchased in one go
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createPackOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Given a client request, determine what type of offer is being created
* single/multi/pack
* @param offerRequest Client request
* @returns FleaOfferType
*/
protected getOfferType(offerRequest: IAddOfferRequestData): FleaOfferType;
/** /**
* Charge player a listing fee for using flea, pulls charge from data previously sent by client * Charge player a listing fee for using flea, pulls charge from data previously sent by client
* @param sessionID Player id * @param sessionID Player id
* @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @param rootItem Base item being listed (used when client tax cost not found and must be done on server)
* @param pmcData Player profile * @param pmcData Player profile
* @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server) * @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server)
* @param itemStackCount How many items were listed in player (used when client tax cost not found and must be done on server) * @param itemStackCount How many items were listed by player (used when client tax cost not found and must be done on server)
* @param offerRequest Add offer request object from client * @param offerRequest Add offer request object from client
* @param output IItemEventRouterResponse * @param output IItemEventRouterResponse
* @returns True if charging tax to player failed * @returns True if charging tax to player failed
@ -180,7 +220,7 @@ export declare class RagfairController {
* @returns Array of items from player inventory * @returns Array of items from player inventory
*/ */
protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): {
items: Item[] | undefined; items: Item[][] | undefined;
errorMessage: string | undefined; errorMessage: string | undefined;
}; };
createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer;

View File

@ -33,7 +33,7 @@ export declare class RagfairHelper {
getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>; getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>;
protected getCategoryList(handbookId: string): string[]; protected getCategoryList(handbookId: string): string[];
/** /**
* Merges Root Items * Iterate over array of identical items and merge stack count
* Ragfair allows abnormally large stacks. * Ragfair allows abnormally large stacks.
*/ */
mergeStackable(items: Item[]): Item[]; mergeStackable(items: Item[]): Item[];

View File

@ -120,6 +120,12 @@ export declare class RagfairOfferHelper {
* @returns true = complete * @returns true = complete
*/ */
processOffersOnProfile(sessionID: string): boolean; processOffersOnProfile(sessionID: string): boolean;
/**
* Count up all rootitem StackObjectsCount properties of an array of items
* @param itemsInInventoryToList items to sum up
* @returns Total count
*/
getTotalStackCountSize(itemsInInventoryToList: Item[][]): number;
/** /**
* Add amount to players ragfair rating * Add amount to players ragfair rating
* @param sessionId Profile to update * @param sessionId Profile to update

View File

@ -25,7 +25,8 @@ export declare class RagfairSellHelper {
* Get array of item count and sell time (empty array = no sell) * Get array of item count and sell time (empty array = no sell)
* @param sellChancePercent chance item will sell * @param sellChancePercent chance item will sell
* @param itemSellCount count of items to sell * @param itemSellCount count of items to sell
* @param sellInOneGo All items listed get sold at once
* @returns Array of purchases of item(s) listed * @returns Array of purchases of item(s) listed
*/ */
rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[];
} }

View File

@ -0,0 +1,6 @@
export declare enum FleaOfferType {
SINGLE = 0,
MULTI = 1,
PACK = 2,
UNKNOWN = 3
}

View File

@ -1,3 +1,4 @@
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
import { Item } from "@spt/models/eft/common/tables/IItem"; import { Item } from "@spt/models/eft/common/tables/IItem";
@ -9,6 +10,7 @@ import { ConfigServer } from "@spt/servers/ConfigServer";
import { SaveServer } from "@spt/servers/SaveServer"; import { SaveServer } from "@spt/servers/SaveServer";
import { DatabaseService } from "@spt/services/DatabaseService"; import { DatabaseService } from "@spt/services/DatabaseService";
import { LocalisationService } from "@spt/services/LocalisationService"; import { LocalisationService } from "@spt/services/LocalisationService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder";
import { TimeUtil } from "@spt/utils/TimeUtil"; import { TimeUtil } from "@spt/utils/TimeUtil";
@ -18,17 +20,19 @@ export declare class RagfairOfferService {
protected databaseService: DatabaseService; protected databaseService: DatabaseService;
protected saveServer: SaveServer; protected saveServer: SaveServer;
protected ragfairServerHelper: RagfairServerHelper; protected ragfairServerHelper: RagfairServerHelper;
protected itemHelper: ItemHelper;
protected profileHelper: ProfileHelper; protected profileHelper: ProfileHelper;
protected eventOutputHolder: EventOutputHolder; protected eventOutputHolder: EventOutputHolder;
protected httpResponse: HttpResponseUtil; protected httpResponse: HttpResponseUtil;
protected localisationService: LocalisationService; protected localisationService: LocalisationService;
protected configServer: ConfigServer; protected configServer: ConfigServer;
protected cloner: ICloner;
protected playerOffersLoaded: boolean; protected playerOffersLoaded: boolean;
/** Offer id + offer object */ /** Offer id + offer object */
protected expiredOffers: Record<string, IRagfairOffer>; protected expiredOffers: Record<string, IRagfairOffer>;
protected ragfairConfig: IRagfairConfig; protected ragfairConfig: IRagfairConfig;
protected ragfairOfferHandler: RagfairOfferHolder; protected ragfairOfferHandler: RagfairOfferHolder;
constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer); constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, itemHelper: ItemHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
/** /**
* Get all offers * Get all offers
* @returns IRagfairOffer array * @returns IRagfairOffer array
@ -84,4 +88,12 @@ export declare class RagfairOfferService {
*/ */
protected processStaleOffer(staleOffer: IRagfairOffer): void; protected processStaleOffer(staleOffer: IRagfairOffer): void;
protected returnPlayerOffer(playerOffer: IRagfairOffer): void; protected returnPlayerOffer(playerOffer: IRagfairOffer): void;
/**
* Flea offer items are stacked up often beyond the StackMaxSize limit
* Un stack the items into an array of root items and their children
* Will create new items equal to the
* @param items Offer items to unstack
* @returns Unstacked array of items
*/
protected unstackOfferItems(items: Item[]): Item[];
} }

View File

@ -77,7 +77,7 @@ export declare class BotController {
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>; generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>;
/** /**
* Create a BotGenerationDetails for the bot generator to use * Create a BotGenerationDetails for the bot generator to use
* @param condition Client data defining bot type and difficulty * @param condition Client data defining bot type and difficulty
@ -117,7 +117,7 @@ export declare class BotController {
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>; returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>;
protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void;
/** /**
* Get the difficulty passed in, if its not "asonline", get selected difficulty from config * Get the difficulty passed in, if its not "asonline", get selected difficulty from config

View File

@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData";
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData";
import { FleaOfferType } from "@spt/models/enums/FleaOfferType";
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ILogger } from "@spt/models/spt/utils/ILogger";
import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
@ -148,13 +149,52 @@ export declare class RagfairController {
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse; addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse;
/**
* Create a flea offer for a single item - uncludes an item with > 1 sized stack
* e.g. 1 ammo stack of 30 cartridges
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createSingleOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiples of the same item, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* Each item can be purchsed individually
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createMultiOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiple items, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* The entire package must be purchased in one go
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createPackOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Given a client request, determine what type of offer is being created
* single/multi/pack
* @param offerRequest Client request
* @returns FleaOfferType
*/
protected getOfferType(offerRequest: IAddOfferRequestData): FleaOfferType;
/** /**
* Charge player a listing fee for using flea, pulls charge from data previously sent by client * Charge player a listing fee for using flea, pulls charge from data previously sent by client
* @param sessionID Player id * @param sessionID Player id
* @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @param rootItem Base item being listed (used when client tax cost not found and must be done on server)
* @param pmcData Player profile * @param pmcData Player profile
* @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server) * @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server)
* @param itemStackCount How many items were listed in player (used when client tax cost not found and must be done on server) * @param itemStackCount How many items were listed by player (used when client tax cost not found and must be done on server)
* @param offerRequest Add offer request object from client * @param offerRequest Add offer request object from client
* @param output IItemEventRouterResponse * @param output IItemEventRouterResponse
* @returns True if charging tax to player failed * @returns True if charging tax to player failed
@ -180,7 +220,7 @@ export declare class RagfairController {
* @returns Array of items from player inventory * @returns Array of items from player inventory
*/ */
protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): {
items: Item[] | undefined; items: Item[][] | undefined;
errorMessage: string | undefined; errorMessage: string | undefined;
}; };
createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer;

View File

@ -33,7 +33,7 @@ export declare class RagfairHelper {
getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>; getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>;
protected getCategoryList(handbookId: string): string[]; protected getCategoryList(handbookId: string): string[];
/** /**
* Merges Root Items * Iterate over array of identical items and merge stack count
* Ragfair allows abnormally large stacks. * Ragfair allows abnormally large stacks.
*/ */
mergeStackable(items: Item[]): Item[]; mergeStackable(items: Item[]): Item[];

View File

@ -120,6 +120,12 @@ export declare class RagfairOfferHelper {
* @returns true = complete * @returns true = complete
*/ */
processOffersOnProfile(sessionID: string): boolean; processOffersOnProfile(sessionID: string): boolean;
/**
* Count up all rootitem StackObjectsCount properties of an array of items
* @param itemsInInventoryToList items to sum up
* @returns Total count
*/
getTotalStackCountSize(itemsInInventoryToList: Item[][]): number;
/** /**
* Add amount to players ragfair rating * Add amount to players ragfair rating
* @param sessionId Profile to update * @param sessionId Profile to update

View File

@ -25,7 +25,8 @@ export declare class RagfairSellHelper {
* Get array of item count and sell time (empty array = no sell) * Get array of item count and sell time (empty array = no sell)
* @param sellChancePercent chance item will sell * @param sellChancePercent chance item will sell
* @param itemSellCount count of items to sell * @param itemSellCount count of items to sell
* @param sellInOneGo All items listed get sold at once
* @returns Array of purchases of item(s) listed * @returns Array of purchases of item(s) listed
*/ */
rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[];
} }

View File

@ -0,0 +1,6 @@
export declare enum FleaOfferType {
SINGLE = 0,
MULTI = 1,
PACK = 2,
UNKNOWN = 3
}

View File

@ -1,3 +1,4 @@
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
import { Item } from "@spt/models/eft/common/tables/IItem"; import { Item } from "@spt/models/eft/common/tables/IItem";
@ -9,6 +10,7 @@ import { ConfigServer } from "@spt/servers/ConfigServer";
import { SaveServer } from "@spt/servers/SaveServer"; import { SaveServer } from "@spt/servers/SaveServer";
import { DatabaseService } from "@spt/services/DatabaseService"; import { DatabaseService } from "@spt/services/DatabaseService";
import { LocalisationService } from "@spt/services/LocalisationService"; import { LocalisationService } from "@spt/services/LocalisationService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder";
import { TimeUtil } from "@spt/utils/TimeUtil"; import { TimeUtil } from "@spt/utils/TimeUtil";
@ -18,17 +20,19 @@ export declare class RagfairOfferService {
protected databaseService: DatabaseService; protected databaseService: DatabaseService;
protected saveServer: SaveServer; protected saveServer: SaveServer;
protected ragfairServerHelper: RagfairServerHelper; protected ragfairServerHelper: RagfairServerHelper;
protected itemHelper: ItemHelper;
protected profileHelper: ProfileHelper; protected profileHelper: ProfileHelper;
protected eventOutputHolder: EventOutputHolder; protected eventOutputHolder: EventOutputHolder;
protected httpResponse: HttpResponseUtil; protected httpResponse: HttpResponseUtil;
protected localisationService: LocalisationService; protected localisationService: LocalisationService;
protected configServer: ConfigServer; protected configServer: ConfigServer;
protected cloner: ICloner;
protected playerOffersLoaded: boolean; protected playerOffersLoaded: boolean;
/** Offer id + offer object */ /** Offer id + offer object */
protected expiredOffers: Record<string, IRagfairOffer>; protected expiredOffers: Record<string, IRagfairOffer>;
protected ragfairConfig: IRagfairConfig; protected ragfairConfig: IRagfairConfig;
protected ragfairOfferHandler: RagfairOfferHolder; protected ragfairOfferHandler: RagfairOfferHolder;
constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer); constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, itemHelper: ItemHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
/** /**
* Get all offers * Get all offers
* @returns IRagfairOffer array * @returns IRagfairOffer array
@ -84,4 +88,12 @@ export declare class RagfairOfferService {
*/ */
protected processStaleOffer(staleOffer: IRagfairOffer): void; protected processStaleOffer(staleOffer: IRagfairOffer): void;
protected returnPlayerOffer(playerOffer: IRagfairOffer): void; protected returnPlayerOffer(playerOffer: IRagfairOffer): void;
/**
* Flea offer items are stacked up often beyond the StackMaxSize limit
* Un stack the items into an array of root items and their children
* Will create new items equal to the
* @param items Offer items to unstack
* @returns Unstacked array of items
*/
protected unstackOfferItems(items: Item[]): Item[];
} }

View File

@ -77,7 +77,7 @@ export declare class BotController {
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>; generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>;
/** /**
* Create a BotGenerationDetails for the bot generator to use * Create a BotGenerationDetails for the bot generator to use
* @param condition Client data defining bot type and difficulty * @param condition Client data defining bot type and difficulty
@ -117,7 +117,7 @@ export declare class BotController {
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>; returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>;
protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void;
/** /**
* Get the difficulty passed in, if its not "asonline", get selected difficulty from config * Get the difficulty passed in, if its not "asonline", get selected difficulty from config

View File

@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData";
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData";
import { FleaOfferType } from "@spt/models/enums/FleaOfferType";
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ILogger } from "@spt/models/spt/utils/ILogger";
import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
@ -148,13 +149,52 @@ export declare class RagfairController {
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse; addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse;
/**
* Create a flea offer for a single item - uncludes an item with > 1 sized stack
* e.g. 1 ammo stack of 30 cartridges
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createSingleOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiples of the same item, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* Each item can be purchsed individually
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createMultiOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiple items, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* The entire package must be purchased in one go
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createPackOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Given a client request, determine what type of offer is being created
* single/multi/pack
* @param offerRequest Client request
* @returns FleaOfferType
*/
protected getOfferType(offerRequest: IAddOfferRequestData): FleaOfferType;
/** /**
* Charge player a listing fee for using flea, pulls charge from data previously sent by client * Charge player a listing fee for using flea, pulls charge from data previously sent by client
* @param sessionID Player id * @param sessionID Player id
* @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @param rootItem Base item being listed (used when client tax cost not found and must be done on server)
* @param pmcData Player profile * @param pmcData Player profile
* @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server) * @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server)
* @param itemStackCount How many items were listed in player (used when client tax cost not found and must be done on server) * @param itemStackCount How many items were listed by player (used when client tax cost not found and must be done on server)
* @param offerRequest Add offer request object from client * @param offerRequest Add offer request object from client
* @param output IItemEventRouterResponse * @param output IItemEventRouterResponse
* @returns True if charging tax to player failed * @returns True if charging tax to player failed
@ -180,7 +220,7 @@ export declare class RagfairController {
* @returns Array of items from player inventory * @returns Array of items from player inventory
*/ */
protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): {
items: Item[] | undefined; items: Item[][] | undefined;
errorMessage: string | undefined; errorMessage: string | undefined;
}; };
createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer;

View File

@ -33,7 +33,7 @@ export declare class RagfairHelper {
getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>; getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>;
protected getCategoryList(handbookId: string): string[]; protected getCategoryList(handbookId: string): string[];
/** /**
* Merges Root Items * Iterate over array of identical items and merge stack count
* Ragfair allows abnormally large stacks. * Ragfair allows abnormally large stacks.
*/ */
mergeStackable(items: Item[]): Item[]; mergeStackable(items: Item[]): Item[];

View File

@ -120,6 +120,12 @@ export declare class RagfairOfferHelper {
* @returns true = complete * @returns true = complete
*/ */
processOffersOnProfile(sessionID: string): boolean; processOffersOnProfile(sessionID: string): boolean;
/**
* Count up all rootitem StackObjectsCount properties of an array of items
* @param itemsInInventoryToList items to sum up
* @returns Total count
*/
getTotalStackCountSize(itemsInInventoryToList: Item[][]): number;
/** /**
* Add amount to players ragfair rating * Add amount to players ragfair rating
* @param sessionId Profile to update * @param sessionId Profile to update

View File

@ -25,7 +25,8 @@ export declare class RagfairSellHelper {
* Get array of item count and sell time (empty array = no sell) * Get array of item count and sell time (empty array = no sell)
* @param sellChancePercent chance item will sell * @param sellChancePercent chance item will sell
* @param itemSellCount count of items to sell * @param itemSellCount count of items to sell
* @param sellInOneGo All items listed get sold at once
* @returns Array of purchases of item(s) listed * @returns Array of purchases of item(s) listed
*/ */
rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[];
} }

View File

@ -0,0 +1,6 @@
export declare enum FleaOfferType {
SINGLE = 0,
MULTI = 1,
PACK = 2,
UNKNOWN = 3
}

View File

@ -1,3 +1,4 @@
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
import { Item } from "@spt/models/eft/common/tables/IItem"; import { Item } from "@spt/models/eft/common/tables/IItem";
@ -9,6 +10,7 @@ import { ConfigServer } from "@spt/servers/ConfigServer";
import { SaveServer } from "@spt/servers/SaveServer"; import { SaveServer } from "@spt/servers/SaveServer";
import { DatabaseService } from "@spt/services/DatabaseService"; import { DatabaseService } from "@spt/services/DatabaseService";
import { LocalisationService } from "@spt/services/LocalisationService"; import { LocalisationService } from "@spt/services/LocalisationService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder";
import { TimeUtil } from "@spt/utils/TimeUtil"; import { TimeUtil } from "@spt/utils/TimeUtil";
@ -18,17 +20,19 @@ export declare class RagfairOfferService {
protected databaseService: DatabaseService; protected databaseService: DatabaseService;
protected saveServer: SaveServer; protected saveServer: SaveServer;
protected ragfairServerHelper: RagfairServerHelper; protected ragfairServerHelper: RagfairServerHelper;
protected itemHelper: ItemHelper;
protected profileHelper: ProfileHelper; protected profileHelper: ProfileHelper;
protected eventOutputHolder: EventOutputHolder; protected eventOutputHolder: EventOutputHolder;
protected httpResponse: HttpResponseUtil; protected httpResponse: HttpResponseUtil;
protected localisationService: LocalisationService; protected localisationService: LocalisationService;
protected configServer: ConfigServer; protected configServer: ConfigServer;
protected cloner: ICloner;
protected playerOffersLoaded: boolean; protected playerOffersLoaded: boolean;
/** Offer id + offer object */ /** Offer id + offer object */
protected expiredOffers: Record<string, IRagfairOffer>; protected expiredOffers: Record<string, IRagfairOffer>;
protected ragfairConfig: IRagfairConfig; protected ragfairConfig: IRagfairConfig;
protected ragfairOfferHandler: RagfairOfferHolder; protected ragfairOfferHandler: RagfairOfferHolder;
constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer); constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, itemHelper: ItemHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
/** /**
* Get all offers * Get all offers
* @returns IRagfairOffer array * @returns IRagfairOffer array
@ -84,4 +88,12 @@ export declare class RagfairOfferService {
*/ */
protected processStaleOffer(staleOffer: IRagfairOffer): void; protected processStaleOffer(staleOffer: IRagfairOffer): void;
protected returnPlayerOffer(playerOffer: IRagfairOffer): void; protected returnPlayerOffer(playerOffer: IRagfairOffer): void;
/**
* Flea offer items are stacked up often beyond the StackMaxSize limit
* Un stack the items into an array of root items and their children
* Will create new items equal to the
* @param items Offer items to unstack
* @returns Unstacked array of items
*/
protected unstackOfferItems(items: Item[]): Item[];
} }

View File

@ -77,7 +77,7 @@ export declare class BotController {
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>; generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>;
/** /**
* Create a BotGenerationDetails for the bot generator to use * Create a BotGenerationDetails for the bot generator to use
* @param condition Client data defining bot type and difficulty * @param condition Client data defining bot type and difficulty
@ -117,7 +117,7 @@ export declare class BotController {
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>; returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>;
protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void;
/** /**
* Get the difficulty passed in, if its not "asonline", get selected difficulty from config * Get the difficulty passed in, if its not "asonline", get selected difficulty from config

View File

@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData";
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData";
import { FleaOfferType } from "@spt/models/enums/FleaOfferType";
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ILogger } from "@spt/models/spt/utils/ILogger";
import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
@ -148,13 +149,52 @@ export declare class RagfairController {
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse; addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse;
/**
* Create a flea offer for a single item - uncludes an item with > 1 sized stack
* e.g. 1 ammo stack of 30 cartridges
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createSingleOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiples of the same item, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* Each item can be purchsed individually
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createMultiOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiple items, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* The entire package must be purchased in one go
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createPackOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Given a client request, determine what type of offer is being created
* single/multi/pack
* @param offerRequest Client request
* @returns FleaOfferType
*/
protected getOfferType(offerRequest: IAddOfferRequestData): FleaOfferType;
/** /**
* Charge player a listing fee for using flea, pulls charge from data previously sent by client * Charge player a listing fee for using flea, pulls charge from data previously sent by client
* @param sessionID Player id * @param sessionID Player id
* @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @param rootItem Base item being listed (used when client tax cost not found and must be done on server)
* @param pmcData Player profile * @param pmcData Player profile
* @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server) * @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server)
* @param itemStackCount How many items were listed in player (used when client tax cost not found and must be done on server) * @param itemStackCount How many items were listed by player (used when client tax cost not found and must be done on server)
* @param offerRequest Add offer request object from client * @param offerRequest Add offer request object from client
* @param output IItemEventRouterResponse * @param output IItemEventRouterResponse
* @returns True if charging tax to player failed * @returns True if charging tax to player failed
@ -180,7 +220,7 @@ export declare class RagfairController {
* @returns Array of items from player inventory * @returns Array of items from player inventory
*/ */
protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): {
items: Item[] | undefined; items: Item[][] | undefined;
errorMessage: string | undefined; errorMessage: string | undefined;
}; };
createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer;

View File

@ -33,7 +33,7 @@ export declare class RagfairHelper {
getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>; getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>;
protected getCategoryList(handbookId: string): string[]; protected getCategoryList(handbookId: string): string[];
/** /**
* Merges Root Items * Iterate over array of identical items and merge stack count
* Ragfair allows abnormally large stacks. * Ragfair allows abnormally large stacks.
*/ */
mergeStackable(items: Item[]): Item[]; mergeStackable(items: Item[]): Item[];

View File

@ -120,6 +120,12 @@ export declare class RagfairOfferHelper {
* @returns true = complete * @returns true = complete
*/ */
processOffersOnProfile(sessionID: string): boolean; processOffersOnProfile(sessionID: string): boolean;
/**
* Count up all rootitem StackObjectsCount properties of an array of items
* @param itemsInInventoryToList items to sum up
* @returns Total count
*/
getTotalStackCountSize(itemsInInventoryToList: Item[][]): number;
/** /**
* Add amount to players ragfair rating * Add amount to players ragfair rating
* @param sessionId Profile to update * @param sessionId Profile to update

View File

@ -25,7 +25,8 @@ export declare class RagfairSellHelper {
* Get array of item count and sell time (empty array = no sell) * Get array of item count and sell time (empty array = no sell)
* @param sellChancePercent chance item will sell * @param sellChancePercent chance item will sell
* @param itemSellCount count of items to sell * @param itemSellCount count of items to sell
* @param sellInOneGo All items listed get sold at once
* @returns Array of purchases of item(s) listed * @returns Array of purchases of item(s) listed
*/ */
rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[];
} }

View File

@ -0,0 +1,6 @@
export declare enum FleaOfferType {
SINGLE = 0,
MULTI = 1,
PACK = 2,
UNKNOWN = 3
}

View File

@ -1,3 +1,4 @@
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
import { Item } from "@spt/models/eft/common/tables/IItem"; import { Item } from "@spt/models/eft/common/tables/IItem";
@ -9,6 +10,7 @@ import { ConfigServer } from "@spt/servers/ConfigServer";
import { SaveServer } from "@spt/servers/SaveServer"; import { SaveServer } from "@spt/servers/SaveServer";
import { DatabaseService } from "@spt/services/DatabaseService"; import { DatabaseService } from "@spt/services/DatabaseService";
import { LocalisationService } from "@spt/services/LocalisationService"; import { LocalisationService } from "@spt/services/LocalisationService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder";
import { TimeUtil } from "@spt/utils/TimeUtil"; import { TimeUtil } from "@spt/utils/TimeUtil";
@ -18,17 +20,19 @@ export declare class RagfairOfferService {
protected databaseService: DatabaseService; protected databaseService: DatabaseService;
protected saveServer: SaveServer; protected saveServer: SaveServer;
protected ragfairServerHelper: RagfairServerHelper; protected ragfairServerHelper: RagfairServerHelper;
protected itemHelper: ItemHelper;
protected profileHelper: ProfileHelper; protected profileHelper: ProfileHelper;
protected eventOutputHolder: EventOutputHolder; protected eventOutputHolder: EventOutputHolder;
protected httpResponse: HttpResponseUtil; protected httpResponse: HttpResponseUtil;
protected localisationService: LocalisationService; protected localisationService: LocalisationService;
protected configServer: ConfigServer; protected configServer: ConfigServer;
protected cloner: ICloner;
protected playerOffersLoaded: boolean; protected playerOffersLoaded: boolean;
/** Offer id + offer object */ /** Offer id + offer object */
protected expiredOffers: Record<string, IRagfairOffer>; protected expiredOffers: Record<string, IRagfairOffer>;
protected ragfairConfig: IRagfairConfig; protected ragfairConfig: IRagfairConfig;
protected ragfairOfferHandler: RagfairOfferHolder; protected ragfairOfferHandler: RagfairOfferHolder;
constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer); constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, itemHelper: ItemHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
/** /**
* Get all offers * Get all offers
* @returns IRagfairOffer array * @returns IRagfairOffer array
@ -84,4 +88,12 @@ export declare class RagfairOfferService {
*/ */
protected processStaleOffer(staleOffer: IRagfairOffer): void; protected processStaleOffer(staleOffer: IRagfairOffer): void;
protected returnPlayerOffer(playerOffer: IRagfairOffer): void; protected returnPlayerOffer(playerOffer: IRagfairOffer): void;
/**
* Flea offer items are stacked up often beyond the StackMaxSize limit
* Un stack the items into an array of root items and their children
* Will create new items equal to the
* @param items Offer items to unstack
* @returns Unstacked array of items
*/
protected unstackOfferItems(items: Item[]): Item[];
} }

View File

@ -77,7 +77,7 @@ export declare class BotController {
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>; generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>;
/** /**
* Create a BotGenerationDetails for the bot generator to use * Create a BotGenerationDetails for the bot generator to use
* @param condition Client data defining bot type and difficulty * @param condition Client data defining bot type and difficulty
@ -117,7 +117,7 @@ export declare class BotController {
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>; returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>;
protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void;
/** /**
* Get the difficulty passed in, if its not "asonline", get selected difficulty from config * Get the difficulty passed in, if its not "asonline", get selected difficulty from config

View File

@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData";
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData";
import { FleaOfferType } from "@spt/models/enums/FleaOfferType";
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ILogger } from "@spt/models/spt/utils/ILogger";
import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
@ -148,13 +149,52 @@ export declare class RagfairController {
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse; addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse;
/**
* Create a flea offer for a single item - uncludes an item with > 1 sized stack
* e.g. 1 ammo stack of 30 cartridges
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createSingleOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiples of the same item, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* Each item can be purchsed individually
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createMultiOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiple items, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* The entire package must be purchased in one go
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createPackOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Given a client request, determine what type of offer is being created
* single/multi/pack
* @param offerRequest Client request
* @returns FleaOfferType
*/
protected getOfferType(offerRequest: IAddOfferRequestData): FleaOfferType;
/** /**
* Charge player a listing fee for using flea, pulls charge from data previously sent by client * Charge player a listing fee for using flea, pulls charge from data previously sent by client
* @param sessionID Player id * @param sessionID Player id
* @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @param rootItem Base item being listed (used when client tax cost not found and must be done on server)
* @param pmcData Player profile * @param pmcData Player profile
* @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server) * @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server)
* @param itemStackCount How many items were listed in player (used when client tax cost not found and must be done on server) * @param itemStackCount How many items were listed by player (used when client tax cost not found and must be done on server)
* @param offerRequest Add offer request object from client * @param offerRequest Add offer request object from client
* @param output IItemEventRouterResponse * @param output IItemEventRouterResponse
* @returns True if charging tax to player failed * @returns True if charging tax to player failed
@ -180,7 +220,7 @@ export declare class RagfairController {
* @returns Array of items from player inventory * @returns Array of items from player inventory
*/ */
protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): {
items: Item[] | undefined; items: Item[][] | undefined;
errorMessage: string | undefined; errorMessage: string | undefined;
}; };
createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer;

View File

@ -33,7 +33,7 @@ export declare class RagfairHelper {
getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>; getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>;
protected getCategoryList(handbookId: string): string[]; protected getCategoryList(handbookId: string): string[];
/** /**
* Merges Root Items * Iterate over array of identical items and merge stack count
* Ragfair allows abnormally large stacks. * Ragfair allows abnormally large stacks.
*/ */
mergeStackable(items: Item[]): Item[]; mergeStackable(items: Item[]): Item[];

View File

@ -120,6 +120,12 @@ export declare class RagfairOfferHelper {
* @returns true = complete * @returns true = complete
*/ */
processOffersOnProfile(sessionID: string): boolean; processOffersOnProfile(sessionID: string): boolean;
/**
* Count up all rootitem StackObjectsCount properties of an array of items
* @param itemsInInventoryToList items to sum up
* @returns Total count
*/
getTotalStackCountSize(itemsInInventoryToList: Item[][]): number;
/** /**
* Add amount to players ragfair rating * Add amount to players ragfair rating
* @param sessionId Profile to update * @param sessionId Profile to update

View File

@ -25,7 +25,8 @@ export declare class RagfairSellHelper {
* Get array of item count and sell time (empty array = no sell) * Get array of item count and sell time (empty array = no sell)
* @param sellChancePercent chance item will sell * @param sellChancePercent chance item will sell
* @param itemSellCount count of items to sell * @param itemSellCount count of items to sell
* @param sellInOneGo All items listed get sold at once
* @returns Array of purchases of item(s) listed * @returns Array of purchases of item(s) listed
*/ */
rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[];
} }

View File

@ -0,0 +1,6 @@
export declare enum FleaOfferType {
SINGLE = 0,
MULTI = 1,
PACK = 2,
UNKNOWN = 3
}

View File

@ -1,3 +1,4 @@
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
import { Item } from "@spt/models/eft/common/tables/IItem"; import { Item } from "@spt/models/eft/common/tables/IItem";
@ -9,6 +10,7 @@ import { ConfigServer } from "@spt/servers/ConfigServer";
import { SaveServer } from "@spt/servers/SaveServer"; import { SaveServer } from "@spt/servers/SaveServer";
import { DatabaseService } from "@spt/services/DatabaseService"; import { DatabaseService } from "@spt/services/DatabaseService";
import { LocalisationService } from "@spt/services/LocalisationService"; import { LocalisationService } from "@spt/services/LocalisationService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder";
import { TimeUtil } from "@spt/utils/TimeUtil"; import { TimeUtil } from "@spt/utils/TimeUtil";
@ -18,17 +20,19 @@ export declare class RagfairOfferService {
protected databaseService: DatabaseService; protected databaseService: DatabaseService;
protected saveServer: SaveServer; protected saveServer: SaveServer;
protected ragfairServerHelper: RagfairServerHelper; protected ragfairServerHelper: RagfairServerHelper;
protected itemHelper: ItemHelper;
protected profileHelper: ProfileHelper; protected profileHelper: ProfileHelper;
protected eventOutputHolder: EventOutputHolder; protected eventOutputHolder: EventOutputHolder;
protected httpResponse: HttpResponseUtil; protected httpResponse: HttpResponseUtil;
protected localisationService: LocalisationService; protected localisationService: LocalisationService;
protected configServer: ConfigServer; protected configServer: ConfigServer;
protected cloner: ICloner;
protected playerOffersLoaded: boolean; protected playerOffersLoaded: boolean;
/** Offer id + offer object */ /** Offer id + offer object */
protected expiredOffers: Record<string, IRagfairOffer>; protected expiredOffers: Record<string, IRagfairOffer>;
protected ragfairConfig: IRagfairConfig; protected ragfairConfig: IRagfairConfig;
protected ragfairOfferHandler: RagfairOfferHolder; protected ragfairOfferHandler: RagfairOfferHolder;
constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer); constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, itemHelper: ItemHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
/** /**
* Get all offers * Get all offers
* @returns IRagfairOffer array * @returns IRagfairOffer array
@ -84,4 +88,12 @@ export declare class RagfairOfferService {
*/ */
protected processStaleOffer(staleOffer: IRagfairOffer): void; protected processStaleOffer(staleOffer: IRagfairOffer): void;
protected returnPlayerOffer(playerOffer: IRagfairOffer): void; protected returnPlayerOffer(playerOffer: IRagfairOffer): void;
/**
* Flea offer items are stacked up often beyond the StackMaxSize limit
* Un stack the items into an array of root items and their children
* Will create new items equal to the
* @param items Offer items to unstack
* @returns Unstacked array of items
*/
protected unstackOfferItems(items: Item[]): Item[];
} }

View File

@ -77,7 +77,7 @@ export declare class BotController {
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>; generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>;
/** /**
* Create a BotGenerationDetails for the bot generator to use * Create a BotGenerationDetails for the bot generator to use
* @param condition Client data defining bot type and difficulty * @param condition Client data defining bot type and difficulty
@ -117,7 +117,7 @@ export declare class BotController {
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>; returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>;
protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void;
/** /**
* Get the difficulty passed in, if its not "asonline", get selected difficulty from config * Get the difficulty passed in, if its not "asonline", get selected difficulty from config

View File

@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData";
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData";
import { FleaOfferType } from "@spt/models/enums/FleaOfferType";
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ILogger } from "@spt/models/spt/utils/ILogger";
import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
@ -148,13 +149,52 @@ export declare class RagfairController {
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse; addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse;
/**
* Create a flea offer for a single item - uncludes an item with > 1 sized stack
* e.g. 1 ammo stack of 30 cartridges
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createSingleOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiples of the same item, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* Each item can be purchsed individually
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createMultiOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiple items, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* The entire package must be purchased in one go
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createPackOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Given a client request, determine what type of offer is being created
* single/multi/pack
* @param offerRequest Client request
* @returns FleaOfferType
*/
protected getOfferType(offerRequest: IAddOfferRequestData): FleaOfferType;
/** /**
* Charge player a listing fee for using flea, pulls charge from data previously sent by client * Charge player a listing fee for using flea, pulls charge from data previously sent by client
* @param sessionID Player id * @param sessionID Player id
* @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @param rootItem Base item being listed (used when client tax cost not found and must be done on server)
* @param pmcData Player profile * @param pmcData Player profile
* @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server) * @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server)
* @param itemStackCount How many items were listed in player (used when client tax cost not found and must be done on server) * @param itemStackCount How many items were listed by player (used when client tax cost not found and must be done on server)
* @param offerRequest Add offer request object from client * @param offerRequest Add offer request object from client
* @param output IItemEventRouterResponse * @param output IItemEventRouterResponse
* @returns True if charging tax to player failed * @returns True if charging tax to player failed
@ -180,7 +220,7 @@ export declare class RagfairController {
* @returns Array of items from player inventory * @returns Array of items from player inventory
*/ */
protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): {
items: Item[] | undefined; items: Item[][] | undefined;
errorMessage: string | undefined; errorMessage: string | undefined;
}; };
createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer;

View File

@ -33,7 +33,7 @@ export declare class RagfairHelper {
getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>; getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>;
protected getCategoryList(handbookId: string): string[]; protected getCategoryList(handbookId: string): string[];
/** /**
* Merges Root Items * Iterate over array of identical items and merge stack count
* Ragfair allows abnormally large stacks. * Ragfair allows abnormally large stacks.
*/ */
mergeStackable(items: Item[]): Item[]; mergeStackable(items: Item[]): Item[];

View File

@ -120,6 +120,12 @@ export declare class RagfairOfferHelper {
* @returns true = complete * @returns true = complete
*/ */
processOffersOnProfile(sessionID: string): boolean; processOffersOnProfile(sessionID: string): boolean;
/**
* Count up all rootitem StackObjectsCount properties of an array of items
* @param itemsInInventoryToList items to sum up
* @returns Total count
*/
getTotalStackCountSize(itemsInInventoryToList: Item[][]): number;
/** /**
* Add amount to players ragfair rating * Add amount to players ragfair rating
* @param sessionId Profile to update * @param sessionId Profile to update

View File

@ -25,7 +25,8 @@ export declare class RagfairSellHelper {
* Get array of item count and sell time (empty array = no sell) * Get array of item count and sell time (empty array = no sell)
* @param sellChancePercent chance item will sell * @param sellChancePercent chance item will sell
* @param itemSellCount count of items to sell * @param itemSellCount count of items to sell
* @param sellInOneGo All items listed get sold at once
* @returns Array of purchases of item(s) listed * @returns Array of purchases of item(s) listed
*/ */
rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[];
} }

View File

@ -0,0 +1,6 @@
export declare enum FleaOfferType {
SINGLE = 0,
MULTI = 1,
PACK = 2,
UNKNOWN = 3
}

View File

@ -1,3 +1,4 @@
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
import { Item } from "@spt/models/eft/common/tables/IItem"; import { Item } from "@spt/models/eft/common/tables/IItem";
@ -9,6 +10,7 @@ import { ConfigServer } from "@spt/servers/ConfigServer";
import { SaveServer } from "@spt/servers/SaveServer"; import { SaveServer } from "@spt/servers/SaveServer";
import { DatabaseService } from "@spt/services/DatabaseService"; import { DatabaseService } from "@spt/services/DatabaseService";
import { LocalisationService } from "@spt/services/LocalisationService"; import { LocalisationService } from "@spt/services/LocalisationService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder";
import { TimeUtil } from "@spt/utils/TimeUtil"; import { TimeUtil } from "@spt/utils/TimeUtil";
@ -18,17 +20,19 @@ export declare class RagfairOfferService {
protected databaseService: DatabaseService; protected databaseService: DatabaseService;
protected saveServer: SaveServer; protected saveServer: SaveServer;
protected ragfairServerHelper: RagfairServerHelper; protected ragfairServerHelper: RagfairServerHelper;
protected itemHelper: ItemHelper;
protected profileHelper: ProfileHelper; protected profileHelper: ProfileHelper;
protected eventOutputHolder: EventOutputHolder; protected eventOutputHolder: EventOutputHolder;
protected httpResponse: HttpResponseUtil; protected httpResponse: HttpResponseUtil;
protected localisationService: LocalisationService; protected localisationService: LocalisationService;
protected configServer: ConfigServer; protected configServer: ConfigServer;
protected cloner: ICloner;
protected playerOffersLoaded: boolean; protected playerOffersLoaded: boolean;
/** Offer id + offer object */ /** Offer id + offer object */
protected expiredOffers: Record<string, IRagfairOffer>; protected expiredOffers: Record<string, IRagfairOffer>;
protected ragfairConfig: IRagfairConfig; protected ragfairConfig: IRagfairConfig;
protected ragfairOfferHandler: RagfairOfferHolder; protected ragfairOfferHandler: RagfairOfferHolder;
constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer); constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, itemHelper: ItemHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
/** /**
* Get all offers * Get all offers
* @returns IRagfairOffer array * @returns IRagfairOffer array
@ -84,4 +88,12 @@ export declare class RagfairOfferService {
*/ */
protected processStaleOffer(staleOffer: IRagfairOffer): void; protected processStaleOffer(staleOffer: IRagfairOffer): void;
protected returnPlayerOffer(playerOffer: IRagfairOffer): void; protected returnPlayerOffer(playerOffer: IRagfairOffer): void;
/**
* Flea offer items are stacked up often beyond the StackMaxSize limit
* Un stack the items into an array of root items and their children
* Will create new items equal to the
* @param items Offer items to unstack
* @returns Unstacked array of items
*/
protected unstackOfferItems(items: Item[]): Item[];
} }

View File

@ -77,7 +77,7 @@ export declare class BotController {
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>; generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>;
/** /**
* Create a BotGenerationDetails for the bot generator to use * Create a BotGenerationDetails for the bot generator to use
* @param condition Client data defining bot type and difficulty * @param condition Client data defining bot type and difficulty
@ -117,7 +117,7 @@ export declare class BotController {
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>; returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>;
protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void;
/** /**
* Get the difficulty passed in, if its not "asonline", get selected difficulty from config * Get the difficulty passed in, if its not "asonline", get selected difficulty from config

View File

@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData";
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData";
import { FleaOfferType } from "@spt/models/enums/FleaOfferType";
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ILogger } from "@spt/models/spt/utils/ILogger";
import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
@ -148,13 +149,52 @@ export declare class RagfairController {
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse; addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse;
/**
* Create a flea offer for a single item - uncludes an item with > 1 sized stack
* e.g. 1 ammo stack of 30 cartridges
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createSingleOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiples of the same item, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* Each item can be purchsed individually
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createMultiOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiple items, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* The entire package must be purchased in one go
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createPackOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Given a client request, determine what type of offer is being created
* single/multi/pack
* @param offerRequest Client request
* @returns FleaOfferType
*/
protected getOfferType(offerRequest: IAddOfferRequestData): FleaOfferType;
/** /**
* Charge player a listing fee for using flea, pulls charge from data previously sent by client * Charge player a listing fee for using flea, pulls charge from data previously sent by client
* @param sessionID Player id * @param sessionID Player id
* @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @param rootItem Base item being listed (used when client tax cost not found and must be done on server)
* @param pmcData Player profile * @param pmcData Player profile
* @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server) * @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server)
* @param itemStackCount How many items were listed in player (used when client tax cost not found and must be done on server) * @param itemStackCount How many items were listed by player (used when client tax cost not found and must be done on server)
* @param offerRequest Add offer request object from client * @param offerRequest Add offer request object from client
* @param output IItemEventRouterResponse * @param output IItemEventRouterResponse
* @returns True if charging tax to player failed * @returns True if charging tax to player failed
@ -180,7 +220,7 @@ export declare class RagfairController {
* @returns Array of items from player inventory * @returns Array of items from player inventory
*/ */
protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): {
items: Item[] | undefined; items: Item[][] | undefined;
errorMessage: string | undefined; errorMessage: string | undefined;
}; };
createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer;

View File

@ -33,7 +33,7 @@ export declare class RagfairHelper {
getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>; getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>;
protected getCategoryList(handbookId: string): string[]; protected getCategoryList(handbookId: string): string[];
/** /**
* Merges Root Items * Iterate over array of identical items and merge stack count
* Ragfair allows abnormally large stacks. * Ragfair allows abnormally large stacks.
*/ */
mergeStackable(items: Item[]): Item[]; mergeStackable(items: Item[]): Item[];

View File

@ -120,6 +120,12 @@ export declare class RagfairOfferHelper {
* @returns true = complete * @returns true = complete
*/ */
processOffersOnProfile(sessionID: string): boolean; processOffersOnProfile(sessionID: string): boolean;
/**
* Count up all rootitem StackObjectsCount properties of an array of items
* @param itemsInInventoryToList items to sum up
* @returns Total count
*/
getTotalStackCountSize(itemsInInventoryToList: Item[][]): number;
/** /**
* Add amount to players ragfair rating * Add amount to players ragfair rating
* @param sessionId Profile to update * @param sessionId Profile to update

View File

@ -25,7 +25,8 @@ export declare class RagfairSellHelper {
* Get array of item count and sell time (empty array = no sell) * Get array of item count and sell time (empty array = no sell)
* @param sellChancePercent chance item will sell * @param sellChancePercent chance item will sell
* @param itemSellCount count of items to sell * @param itemSellCount count of items to sell
* @param sellInOneGo All items listed get sold at once
* @returns Array of purchases of item(s) listed * @returns Array of purchases of item(s) listed
*/ */
rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[];
} }

View File

@ -0,0 +1,6 @@
export declare enum FleaOfferType {
SINGLE = 0,
MULTI = 1,
PACK = 2,
UNKNOWN = 3
}

View File

@ -1,3 +1,4 @@
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
import { Item } from "@spt/models/eft/common/tables/IItem"; import { Item } from "@spt/models/eft/common/tables/IItem";
@ -9,6 +10,7 @@ import { ConfigServer } from "@spt/servers/ConfigServer";
import { SaveServer } from "@spt/servers/SaveServer"; import { SaveServer } from "@spt/servers/SaveServer";
import { DatabaseService } from "@spt/services/DatabaseService"; import { DatabaseService } from "@spt/services/DatabaseService";
import { LocalisationService } from "@spt/services/LocalisationService"; import { LocalisationService } from "@spt/services/LocalisationService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder";
import { TimeUtil } from "@spt/utils/TimeUtil"; import { TimeUtil } from "@spt/utils/TimeUtil";
@ -18,17 +20,19 @@ export declare class RagfairOfferService {
protected databaseService: DatabaseService; protected databaseService: DatabaseService;
protected saveServer: SaveServer; protected saveServer: SaveServer;
protected ragfairServerHelper: RagfairServerHelper; protected ragfairServerHelper: RagfairServerHelper;
protected itemHelper: ItemHelper;
protected profileHelper: ProfileHelper; protected profileHelper: ProfileHelper;
protected eventOutputHolder: EventOutputHolder; protected eventOutputHolder: EventOutputHolder;
protected httpResponse: HttpResponseUtil; protected httpResponse: HttpResponseUtil;
protected localisationService: LocalisationService; protected localisationService: LocalisationService;
protected configServer: ConfigServer; protected configServer: ConfigServer;
protected cloner: ICloner;
protected playerOffersLoaded: boolean; protected playerOffersLoaded: boolean;
/** Offer id + offer object */ /** Offer id + offer object */
protected expiredOffers: Record<string, IRagfairOffer>; protected expiredOffers: Record<string, IRagfairOffer>;
protected ragfairConfig: IRagfairConfig; protected ragfairConfig: IRagfairConfig;
protected ragfairOfferHandler: RagfairOfferHolder; protected ragfairOfferHandler: RagfairOfferHolder;
constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer); constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, itemHelper: ItemHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
/** /**
* Get all offers * Get all offers
* @returns IRagfairOffer array * @returns IRagfairOffer array
@ -84,4 +88,12 @@ export declare class RagfairOfferService {
*/ */
protected processStaleOffer(staleOffer: IRagfairOffer): void; protected processStaleOffer(staleOffer: IRagfairOffer): void;
protected returnPlayerOffer(playerOffer: IRagfairOffer): void; protected returnPlayerOffer(playerOffer: IRagfairOffer): void;
/**
* Flea offer items are stacked up often beyond the StackMaxSize limit
* Un stack the items into an array of root items and their children
* Will create new items equal to the
* @param items Offer items to unstack
* @returns Unstacked array of items
*/
protected unstackOfferItems(items: Item[]): Item[];
} }

View File

@ -77,7 +77,7 @@ export declare class BotController {
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>; generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>;
/** /**
* Create a BotGenerationDetails for the bot generator to use * Create a BotGenerationDetails for the bot generator to use
* @param condition Client data defining bot type and difficulty * @param condition Client data defining bot type and difficulty
@ -117,7 +117,7 @@ export declare class BotController {
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>; returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>;
protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void;
/** /**
* Get the difficulty passed in, if its not "asonline", get selected difficulty from config * Get the difficulty passed in, if its not "asonline", get selected difficulty from config

View File

@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData";
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData";
import { FleaOfferType } from "@spt/models/enums/FleaOfferType";
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ILogger } from "@spt/models/spt/utils/ILogger";
import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
@ -148,13 +149,52 @@ export declare class RagfairController {
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse; addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse;
/**
* Create a flea offer for a single item - uncludes an item with > 1 sized stack
* e.g. 1 ammo stack of 30 cartridges
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createSingleOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiples of the same item, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* Each item can be purchsed individually
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createMultiOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiple items, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* The entire package must be purchased in one go
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createPackOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Given a client request, determine what type of offer is being created
* single/multi/pack
* @param offerRequest Client request
* @returns FleaOfferType
*/
protected getOfferType(offerRequest: IAddOfferRequestData): FleaOfferType;
/** /**
* Charge player a listing fee for using flea, pulls charge from data previously sent by client * Charge player a listing fee for using flea, pulls charge from data previously sent by client
* @param sessionID Player id * @param sessionID Player id
* @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @param rootItem Base item being listed (used when client tax cost not found and must be done on server)
* @param pmcData Player profile * @param pmcData Player profile
* @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server) * @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server)
* @param itemStackCount How many items were listed in player (used when client tax cost not found and must be done on server) * @param itemStackCount How many items were listed by player (used when client tax cost not found and must be done on server)
* @param offerRequest Add offer request object from client * @param offerRequest Add offer request object from client
* @param output IItemEventRouterResponse * @param output IItemEventRouterResponse
* @returns True if charging tax to player failed * @returns True if charging tax to player failed
@ -180,7 +220,7 @@ export declare class RagfairController {
* @returns Array of items from player inventory * @returns Array of items from player inventory
*/ */
protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): {
items: Item[] | undefined; items: Item[][] | undefined;
errorMessage: string | undefined; errorMessage: string | undefined;
}; };
createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer;

View File

@ -33,7 +33,7 @@ export declare class RagfairHelper {
getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>; getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>;
protected getCategoryList(handbookId: string): string[]; protected getCategoryList(handbookId: string): string[];
/** /**
* Merges Root Items * Iterate over array of identical items and merge stack count
* Ragfair allows abnormally large stacks. * Ragfair allows abnormally large stacks.
*/ */
mergeStackable(items: Item[]): Item[]; mergeStackable(items: Item[]): Item[];

View File

@ -120,6 +120,12 @@ export declare class RagfairOfferHelper {
* @returns true = complete * @returns true = complete
*/ */
processOffersOnProfile(sessionID: string): boolean; processOffersOnProfile(sessionID: string): boolean;
/**
* Count up all rootitem StackObjectsCount properties of an array of items
* @param itemsInInventoryToList items to sum up
* @returns Total count
*/
getTotalStackCountSize(itemsInInventoryToList: Item[][]): number;
/** /**
* Add amount to players ragfair rating * Add amount to players ragfair rating
* @param sessionId Profile to update * @param sessionId Profile to update

View File

@ -25,7 +25,8 @@ export declare class RagfairSellHelper {
* Get array of item count and sell time (empty array = no sell) * Get array of item count and sell time (empty array = no sell)
* @param sellChancePercent chance item will sell * @param sellChancePercent chance item will sell
* @param itemSellCount count of items to sell * @param itemSellCount count of items to sell
* @param sellInOneGo All items listed get sold at once
* @returns Array of purchases of item(s) listed * @returns Array of purchases of item(s) listed
*/ */
rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[];
} }

View File

@ -0,0 +1,6 @@
export declare enum FleaOfferType {
SINGLE = 0,
MULTI = 1,
PACK = 2,
UNKNOWN = 3
}

View File

@ -1,3 +1,4 @@
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
import { Item } from "@spt/models/eft/common/tables/IItem"; import { Item } from "@spt/models/eft/common/tables/IItem";
@ -9,6 +10,7 @@ import { ConfigServer } from "@spt/servers/ConfigServer";
import { SaveServer } from "@spt/servers/SaveServer"; import { SaveServer } from "@spt/servers/SaveServer";
import { DatabaseService } from "@spt/services/DatabaseService"; import { DatabaseService } from "@spt/services/DatabaseService";
import { LocalisationService } from "@spt/services/LocalisationService"; import { LocalisationService } from "@spt/services/LocalisationService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder";
import { TimeUtil } from "@spt/utils/TimeUtil"; import { TimeUtil } from "@spt/utils/TimeUtil";
@ -18,17 +20,19 @@ export declare class RagfairOfferService {
protected databaseService: DatabaseService; protected databaseService: DatabaseService;
protected saveServer: SaveServer; protected saveServer: SaveServer;
protected ragfairServerHelper: RagfairServerHelper; protected ragfairServerHelper: RagfairServerHelper;
protected itemHelper: ItemHelper;
protected profileHelper: ProfileHelper; protected profileHelper: ProfileHelper;
protected eventOutputHolder: EventOutputHolder; protected eventOutputHolder: EventOutputHolder;
protected httpResponse: HttpResponseUtil; protected httpResponse: HttpResponseUtil;
protected localisationService: LocalisationService; protected localisationService: LocalisationService;
protected configServer: ConfigServer; protected configServer: ConfigServer;
protected cloner: ICloner;
protected playerOffersLoaded: boolean; protected playerOffersLoaded: boolean;
/** Offer id + offer object */ /** Offer id + offer object */
protected expiredOffers: Record<string, IRagfairOffer>; protected expiredOffers: Record<string, IRagfairOffer>;
protected ragfairConfig: IRagfairConfig; protected ragfairConfig: IRagfairConfig;
protected ragfairOfferHandler: RagfairOfferHolder; protected ragfairOfferHandler: RagfairOfferHolder;
constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer); constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, itemHelper: ItemHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
/** /**
* Get all offers * Get all offers
* @returns IRagfairOffer array * @returns IRagfairOffer array
@ -84,4 +88,12 @@ export declare class RagfairOfferService {
*/ */
protected processStaleOffer(staleOffer: IRagfairOffer): void; protected processStaleOffer(staleOffer: IRagfairOffer): void;
protected returnPlayerOffer(playerOffer: IRagfairOffer): void; protected returnPlayerOffer(playerOffer: IRagfairOffer): void;
/**
* Flea offer items are stacked up often beyond the StackMaxSize limit
* Un stack the items into an array of root items and their children
* Will create new items equal to the
* @param items Offer items to unstack
* @returns Unstacked array of items
*/
protected unstackOfferItems(items: Item[]): Item[];
} }

View File

@ -77,7 +77,7 @@ export declare class BotController {
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>; generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>;
/** /**
* Create a BotGenerationDetails for the bot generator to use * Create a BotGenerationDetails for the bot generator to use
* @param condition Client data defining bot type and difficulty * @param condition Client data defining bot type and difficulty
@ -117,7 +117,7 @@ export declare class BotController {
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>; returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>;
protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void;
/** /**
* Get the difficulty passed in, if its not "asonline", get selected difficulty from config * Get the difficulty passed in, if its not "asonline", get selected difficulty from config

View File

@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData";
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData";
import { FleaOfferType } from "@spt/models/enums/FleaOfferType";
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ILogger } from "@spt/models/spt/utils/ILogger";
import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
@ -148,13 +149,52 @@ export declare class RagfairController {
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse; addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse;
/**
* Create a flea offer for a single item - uncludes an item with > 1 sized stack
* e.g. 1 ammo stack of 30 cartridges
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createSingleOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiples of the same item, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* Each item can be purchsed individually
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createMultiOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiple items, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* The entire package must be purchased in one go
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createPackOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Given a client request, determine what type of offer is being created
* single/multi/pack
* @param offerRequest Client request
* @returns FleaOfferType
*/
protected getOfferType(offerRequest: IAddOfferRequestData): FleaOfferType;
/** /**
* Charge player a listing fee for using flea, pulls charge from data previously sent by client * Charge player a listing fee for using flea, pulls charge from data previously sent by client
* @param sessionID Player id * @param sessionID Player id
* @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @param rootItem Base item being listed (used when client tax cost not found and must be done on server)
* @param pmcData Player profile * @param pmcData Player profile
* @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server) * @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server)
* @param itemStackCount How many items were listed in player (used when client tax cost not found and must be done on server) * @param itemStackCount How many items were listed by player (used when client tax cost not found and must be done on server)
* @param offerRequest Add offer request object from client * @param offerRequest Add offer request object from client
* @param output IItemEventRouterResponse * @param output IItemEventRouterResponse
* @returns True if charging tax to player failed * @returns True if charging tax to player failed
@ -180,7 +220,7 @@ export declare class RagfairController {
* @returns Array of items from player inventory * @returns Array of items from player inventory
*/ */
protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): {
items: Item[] | undefined; items: Item[][] | undefined;
errorMessage: string | undefined; errorMessage: string | undefined;
}; };
createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer;

View File

@ -33,7 +33,7 @@ export declare class RagfairHelper {
getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>; getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>;
protected getCategoryList(handbookId: string): string[]; protected getCategoryList(handbookId: string): string[];
/** /**
* Merges Root Items * Iterate over array of identical items and merge stack count
* Ragfair allows abnormally large stacks. * Ragfair allows abnormally large stacks.
*/ */
mergeStackable(items: Item[]): Item[]; mergeStackable(items: Item[]): Item[];

View File

@ -120,6 +120,12 @@ export declare class RagfairOfferHelper {
* @returns true = complete * @returns true = complete
*/ */
processOffersOnProfile(sessionID: string): boolean; processOffersOnProfile(sessionID: string): boolean;
/**
* Count up all rootitem StackObjectsCount properties of an array of items
* @param itemsInInventoryToList items to sum up
* @returns Total count
*/
getTotalStackCountSize(itemsInInventoryToList: Item[][]): number;
/** /**
* Add amount to players ragfair rating * Add amount to players ragfair rating
* @param sessionId Profile to update * @param sessionId Profile to update

View File

@ -25,7 +25,8 @@ export declare class RagfairSellHelper {
* Get array of item count and sell time (empty array = no sell) * Get array of item count and sell time (empty array = no sell)
* @param sellChancePercent chance item will sell * @param sellChancePercent chance item will sell
* @param itemSellCount count of items to sell * @param itemSellCount count of items to sell
* @param sellInOneGo All items listed get sold at once
* @returns Array of purchases of item(s) listed * @returns Array of purchases of item(s) listed
*/ */
rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[];
} }

View File

@ -0,0 +1,6 @@
export declare enum FleaOfferType {
SINGLE = 0,
MULTI = 1,
PACK = 2,
UNKNOWN = 3
}

View File

@ -1,3 +1,4 @@
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
import { Item } from "@spt/models/eft/common/tables/IItem"; import { Item } from "@spt/models/eft/common/tables/IItem";
@ -9,6 +10,7 @@ import { ConfigServer } from "@spt/servers/ConfigServer";
import { SaveServer } from "@spt/servers/SaveServer"; import { SaveServer } from "@spt/servers/SaveServer";
import { DatabaseService } from "@spt/services/DatabaseService"; import { DatabaseService } from "@spt/services/DatabaseService";
import { LocalisationService } from "@spt/services/LocalisationService"; import { LocalisationService } from "@spt/services/LocalisationService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder";
import { TimeUtil } from "@spt/utils/TimeUtil"; import { TimeUtil } from "@spt/utils/TimeUtil";
@ -18,17 +20,19 @@ export declare class RagfairOfferService {
protected databaseService: DatabaseService; protected databaseService: DatabaseService;
protected saveServer: SaveServer; protected saveServer: SaveServer;
protected ragfairServerHelper: RagfairServerHelper; protected ragfairServerHelper: RagfairServerHelper;
protected itemHelper: ItemHelper;
protected profileHelper: ProfileHelper; protected profileHelper: ProfileHelper;
protected eventOutputHolder: EventOutputHolder; protected eventOutputHolder: EventOutputHolder;
protected httpResponse: HttpResponseUtil; protected httpResponse: HttpResponseUtil;
protected localisationService: LocalisationService; protected localisationService: LocalisationService;
protected configServer: ConfigServer; protected configServer: ConfigServer;
protected cloner: ICloner;
protected playerOffersLoaded: boolean; protected playerOffersLoaded: boolean;
/** Offer id + offer object */ /** Offer id + offer object */
protected expiredOffers: Record<string, IRagfairOffer>; protected expiredOffers: Record<string, IRagfairOffer>;
protected ragfairConfig: IRagfairConfig; protected ragfairConfig: IRagfairConfig;
protected ragfairOfferHandler: RagfairOfferHolder; protected ragfairOfferHandler: RagfairOfferHolder;
constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer); constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, itemHelper: ItemHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
/** /**
* Get all offers * Get all offers
* @returns IRagfairOffer array * @returns IRagfairOffer array
@ -84,4 +88,12 @@ export declare class RagfairOfferService {
*/ */
protected processStaleOffer(staleOffer: IRagfairOffer): void; protected processStaleOffer(staleOffer: IRagfairOffer): void;
protected returnPlayerOffer(playerOffer: IRagfairOffer): void; protected returnPlayerOffer(playerOffer: IRagfairOffer): void;
/**
* Flea offer items are stacked up often beyond the StackMaxSize limit
* Un stack the items into an array of root items and their children
* Will create new items equal to the
* @param items Offer items to unstack
* @returns Unstacked array of items
*/
protected unstackOfferItems(items: Item[]): Item[];
} }

View File

@ -77,7 +77,7 @@ export declare class BotController {
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>; generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>;
/** /**
* Create a BotGenerationDetails for the bot generator to use * Create a BotGenerationDetails for the bot generator to use
* @param condition Client data defining bot type and difficulty * @param condition Client data defining bot type and difficulty
@ -117,7 +117,7 @@ export declare class BotController {
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>; returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>;
protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void;
/** /**
* Get the difficulty passed in, if its not "asonline", get selected difficulty from config * Get the difficulty passed in, if its not "asonline", get selected difficulty from config

View File

@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData";
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData";
import { FleaOfferType } from "@spt/models/enums/FleaOfferType";
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ILogger } from "@spt/models/spt/utils/ILogger";
import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
@ -148,13 +149,52 @@ export declare class RagfairController {
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse; addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse;
/**
* Create a flea offer for a single item - uncludes an item with > 1 sized stack
* e.g. 1 ammo stack of 30 cartridges
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createSingleOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiples of the same item, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* Each item can be purchsed individually
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createMultiOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiple items, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* The entire package must be purchased in one go
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createPackOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Given a client request, determine what type of offer is being created
* single/multi/pack
* @param offerRequest Client request
* @returns FleaOfferType
*/
protected getOfferType(offerRequest: IAddOfferRequestData): FleaOfferType;
/** /**
* Charge player a listing fee for using flea, pulls charge from data previously sent by client * Charge player a listing fee for using flea, pulls charge from data previously sent by client
* @param sessionID Player id * @param sessionID Player id
* @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @param rootItem Base item being listed (used when client tax cost not found and must be done on server)
* @param pmcData Player profile * @param pmcData Player profile
* @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server) * @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server)
* @param itemStackCount How many items were listed in player (used when client tax cost not found and must be done on server) * @param itemStackCount How many items were listed by player (used when client tax cost not found and must be done on server)
* @param offerRequest Add offer request object from client * @param offerRequest Add offer request object from client
* @param output IItemEventRouterResponse * @param output IItemEventRouterResponse
* @returns True if charging tax to player failed * @returns True if charging tax to player failed
@ -180,7 +220,7 @@ export declare class RagfairController {
* @returns Array of items from player inventory * @returns Array of items from player inventory
*/ */
protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): {
items: Item[] | undefined; items: Item[][] | undefined;
errorMessage: string | undefined; errorMessage: string | undefined;
}; };
createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer;

View File

@ -33,7 +33,7 @@ export declare class RagfairHelper {
getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>; getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>;
protected getCategoryList(handbookId: string): string[]; protected getCategoryList(handbookId: string): string[];
/** /**
* Merges Root Items * Iterate over array of identical items and merge stack count
* Ragfair allows abnormally large stacks. * Ragfair allows abnormally large stacks.
*/ */
mergeStackable(items: Item[]): Item[]; mergeStackable(items: Item[]): Item[];

View File

@ -120,6 +120,12 @@ export declare class RagfairOfferHelper {
* @returns true = complete * @returns true = complete
*/ */
processOffersOnProfile(sessionID: string): boolean; processOffersOnProfile(sessionID: string): boolean;
/**
* Count up all rootitem StackObjectsCount properties of an array of items
* @param itemsInInventoryToList items to sum up
* @returns Total count
*/
getTotalStackCountSize(itemsInInventoryToList: Item[][]): number;
/** /**
* Add amount to players ragfair rating * Add amount to players ragfair rating
* @param sessionId Profile to update * @param sessionId Profile to update

View File

@ -25,7 +25,8 @@ export declare class RagfairSellHelper {
* Get array of item count and sell time (empty array = no sell) * Get array of item count and sell time (empty array = no sell)
* @param sellChancePercent chance item will sell * @param sellChancePercent chance item will sell
* @param itemSellCount count of items to sell * @param itemSellCount count of items to sell
* @param sellInOneGo All items listed get sold at once
* @returns Array of purchases of item(s) listed * @returns Array of purchases of item(s) listed
*/ */
rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[];
} }

View File

@ -0,0 +1,6 @@
export declare enum FleaOfferType {
SINGLE = 0,
MULTI = 1,
PACK = 2,
UNKNOWN = 3
}

View File

@ -1,3 +1,4 @@
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
import { Item } from "@spt/models/eft/common/tables/IItem"; import { Item } from "@spt/models/eft/common/tables/IItem";
@ -9,6 +10,7 @@ import { ConfigServer } from "@spt/servers/ConfigServer";
import { SaveServer } from "@spt/servers/SaveServer"; import { SaveServer } from "@spt/servers/SaveServer";
import { DatabaseService } from "@spt/services/DatabaseService"; import { DatabaseService } from "@spt/services/DatabaseService";
import { LocalisationService } from "@spt/services/LocalisationService"; import { LocalisationService } from "@spt/services/LocalisationService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder";
import { TimeUtil } from "@spt/utils/TimeUtil"; import { TimeUtil } from "@spt/utils/TimeUtil";
@ -18,17 +20,19 @@ export declare class RagfairOfferService {
protected databaseService: DatabaseService; protected databaseService: DatabaseService;
protected saveServer: SaveServer; protected saveServer: SaveServer;
protected ragfairServerHelper: RagfairServerHelper; protected ragfairServerHelper: RagfairServerHelper;
protected itemHelper: ItemHelper;
protected profileHelper: ProfileHelper; protected profileHelper: ProfileHelper;
protected eventOutputHolder: EventOutputHolder; protected eventOutputHolder: EventOutputHolder;
protected httpResponse: HttpResponseUtil; protected httpResponse: HttpResponseUtil;
protected localisationService: LocalisationService; protected localisationService: LocalisationService;
protected configServer: ConfigServer; protected configServer: ConfigServer;
protected cloner: ICloner;
protected playerOffersLoaded: boolean; protected playerOffersLoaded: boolean;
/** Offer id + offer object */ /** Offer id + offer object */
protected expiredOffers: Record<string, IRagfairOffer>; protected expiredOffers: Record<string, IRagfairOffer>;
protected ragfairConfig: IRagfairConfig; protected ragfairConfig: IRagfairConfig;
protected ragfairOfferHandler: RagfairOfferHolder; protected ragfairOfferHandler: RagfairOfferHolder;
constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer); constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, itemHelper: ItemHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
/** /**
* Get all offers * Get all offers
* @returns IRagfairOffer array * @returns IRagfairOffer array
@ -84,4 +88,12 @@ export declare class RagfairOfferService {
*/ */
protected processStaleOffer(staleOffer: IRagfairOffer): void; protected processStaleOffer(staleOffer: IRagfairOffer): void;
protected returnPlayerOffer(playerOffer: IRagfairOffer): void; protected returnPlayerOffer(playerOffer: IRagfairOffer): void;
/**
* Flea offer items are stacked up often beyond the StackMaxSize limit
* Un stack the items into an array of root items and their children
* Will create new items equal to the
* @param items Offer items to unstack
* @returns Unstacked array of items
*/
protected unstackOfferItems(items: Item[]): Item[];
} }

View File

@ -77,7 +77,7 @@ export declare class BotController {
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>; generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>;
/** /**
* Create a BotGenerationDetails for the bot generator to use * Create a BotGenerationDetails for the bot generator to use
* @param condition Client data defining bot type and difficulty * @param condition Client data defining bot type and difficulty
@ -117,7 +117,7 @@ export declare class BotController {
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>; returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>;
protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void;
/** /**
* Get the difficulty passed in, if its not "asonline", get selected difficulty from config * Get the difficulty passed in, if its not "asonline", get selected difficulty from config

View File

@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData";
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData";
import { FleaOfferType } from "@spt/models/enums/FleaOfferType";
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ILogger } from "@spt/models/spt/utils/ILogger";
import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
@ -148,13 +149,52 @@ export declare class RagfairController {
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse; addPlayerOffer(pmcData: IPmcData, offerRequest: IAddOfferRequestData, sessionID: string): IItemEventRouterResponse;
/**
* Create a flea offer for a single item - uncludes an item with > 1 sized stack
* e.g. 1 ammo stack of 30 cartridges
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createSingleOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiples of the same item, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* Each item can be purchsed individually
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createMultiOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Create a flea offer for multiple items, can be single items or items with multiple in the stack
* e.g. 2 ammo stacks of 30 cartridges each
* The entire package must be purchased in one go
* @param sessionID Session id
* @param offerRequest Offer request from client
* @param fullProfile Full profile of player
* @param output Response to send to client
* @returns IItemEventRouterResponse
*/
protected createPackOffer(sessionID: string, offerRequest: IAddOfferRequestData, fullProfile: ISptProfile, output: IItemEventRouterResponse): IItemEventRouterResponse;
/**
* Given a client request, determine what type of offer is being created
* single/multi/pack
* @param offerRequest Client request
* @returns FleaOfferType
*/
protected getOfferType(offerRequest: IAddOfferRequestData): FleaOfferType;
/** /**
* Charge player a listing fee for using flea, pulls charge from data previously sent by client * Charge player a listing fee for using flea, pulls charge from data previously sent by client
* @param sessionID Player id * @param sessionID Player id
* @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @param rootItem Base item being listed (used when client tax cost not found and must be done on server)
* @param pmcData Player profile * @param pmcData Player profile
* @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server) * @param requirementsPriceInRub Rouble cost player chose for listing (used when client tax cost not found and must be done on server)
* @param itemStackCount How many items were listed in player (used when client tax cost not found and must be done on server) * @param itemStackCount How many items were listed by player (used when client tax cost not found and must be done on server)
* @param offerRequest Add offer request object from client * @param offerRequest Add offer request object from client
* @param output IItemEventRouterResponse * @param output IItemEventRouterResponse
* @returns True if charging tax to player failed * @returns True if charging tax to player failed
@ -180,7 +220,7 @@ export declare class RagfairController {
* @returns Array of items from player inventory * @returns Array of items from player inventory
*/ */
protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): {
items: Item[] | undefined; items: Item[][] | undefined;
errorMessage: string | undefined; errorMessage: string | undefined;
}; };
createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer;

View File

@ -33,7 +33,7 @@ export declare class RagfairHelper {
getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>; getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>;
protected getCategoryList(handbookId: string): string[]; protected getCategoryList(handbookId: string): string[];
/** /**
* Merges Root Items * Iterate over array of identical items and merge stack count
* Ragfair allows abnormally large stacks. * Ragfair allows abnormally large stacks.
*/ */
mergeStackable(items: Item[]): Item[]; mergeStackable(items: Item[]): Item[];

View File

@ -120,6 +120,12 @@ export declare class RagfairOfferHelper {
* @returns true = complete * @returns true = complete
*/ */
processOffersOnProfile(sessionID: string): boolean; processOffersOnProfile(sessionID: string): boolean;
/**
* Count up all rootitem StackObjectsCount properties of an array of items
* @param itemsInInventoryToList items to sum up
* @returns Total count
*/
getTotalStackCountSize(itemsInInventoryToList: Item[][]): number;
/** /**
* Add amount to players ragfair rating * Add amount to players ragfair rating
* @param sessionId Profile to update * @param sessionId Profile to update

View File

@ -25,7 +25,8 @@ export declare class RagfairSellHelper {
* Get array of item count and sell time (empty array = no sell) * Get array of item count and sell time (empty array = no sell)
* @param sellChancePercent chance item will sell * @param sellChancePercent chance item will sell
* @param itemSellCount count of items to sell * @param itemSellCount count of items to sell
* @param sellInOneGo All items listed get sold at once
* @returns Array of purchases of item(s) listed * @returns Array of purchases of item(s) listed
*/ */
rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[];
} }

View File

@ -0,0 +1,6 @@
export declare enum FleaOfferType {
SINGLE = 0,
MULTI = 1,
PACK = 2,
UNKNOWN = 3
}

View File

@ -1,3 +1,4 @@
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
import { Item } from "@spt/models/eft/common/tables/IItem"; import { Item } from "@spt/models/eft/common/tables/IItem";
@ -9,6 +10,7 @@ import { ConfigServer } from "@spt/servers/ConfigServer";
import { SaveServer } from "@spt/servers/SaveServer"; import { SaveServer } from "@spt/servers/SaveServer";
import { DatabaseService } from "@spt/services/DatabaseService"; import { DatabaseService } from "@spt/services/DatabaseService";
import { LocalisationService } from "@spt/services/LocalisationService"; import { LocalisationService } from "@spt/services/LocalisationService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder";
import { TimeUtil } from "@spt/utils/TimeUtil"; import { TimeUtil } from "@spt/utils/TimeUtil";
@ -18,17 +20,19 @@ export declare class RagfairOfferService {
protected databaseService: DatabaseService; protected databaseService: DatabaseService;
protected saveServer: SaveServer; protected saveServer: SaveServer;
protected ragfairServerHelper: RagfairServerHelper; protected ragfairServerHelper: RagfairServerHelper;
protected itemHelper: ItemHelper;
protected profileHelper: ProfileHelper; protected profileHelper: ProfileHelper;
protected eventOutputHolder: EventOutputHolder; protected eventOutputHolder: EventOutputHolder;
protected httpResponse: HttpResponseUtil; protected httpResponse: HttpResponseUtil;
protected localisationService: LocalisationService; protected localisationService: LocalisationService;
protected configServer: ConfigServer; protected configServer: ConfigServer;
protected cloner: ICloner;
protected playerOffersLoaded: boolean; protected playerOffersLoaded: boolean;
/** Offer id + offer object */ /** Offer id + offer object */
protected expiredOffers: Record<string, IRagfairOffer>; protected expiredOffers: Record<string, IRagfairOffer>;
protected ragfairConfig: IRagfairConfig; protected ragfairConfig: IRagfairConfig;
protected ragfairOfferHandler: RagfairOfferHolder; protected ragfairOfferHandler: RagfairOfferHolder;
constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer); constructor(logger: ILogger, timeUtil: TimeUtil, databaseService: DatabaseService, saveServer: SaveServer, ragfairServerHelper: RagfairServerHelper, itemHelper: ItemHelper, profileHelper: ProfileHelper, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
/** /**
* Get all offers * Get all offers
* @returns IRagfairOffer array * @returns IRagfairOffer array
@ -84,4 +88,12 @@ export declare class RagfairOfferService {
*/ */
protected processStaleOffer(staleOffer: IRagfairOffer): void; protected processStaleOffer(staleOffer: IRagfairOffer): void;
protected returnPlayerOffer(playerOffer: IRagfairOffer): void; protected returnPlayerOffer(playerOffer: IRagfairOffer): void;
/**
* Flea offer items are stacked up often beyond the StackMaxSize limit
* Un stack the items into an array of root items and their children
* Will create new items equal to the
* @param items Offer items to unstack
* @returns Unstacked array of items
*/
protected unstackOfferItems(items: Item[]): Item[];
} }

View File

@ -77,7 +77,7 @@ export declare class BotController {
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>; generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise<IBotBase[]>;
/** /**
* Create a BotGenerationDetails for the bot generator to use * Create a BotGenerationDetails for the bot generator to use
* @param condition Client data defining bot type and difficulty * @param condition Client data defining bot type and difficulty
@ -117,7 +117,7 @@ export declare class BotController {
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>; returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>;
protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record<string, number>): void;
/** /**
* Get the difficulty passed in, if its not "asonline", get selected difficulty from config * Get the difficulty passed in, if its not "asonline", get selected difficulty from config

Some files were not shown because too many files have changed in this diff Show More