diff --git a/README.md b/README.md index 664d400..fd5ba1e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/TypeScript/10ScopesAndTypes/types/controllers/BotController.d.ts b/TypeScript/10ScopesAndTypes/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/10ScopesAndTypes/types/controllers/BotController.d.ts +++ b/TypeScript/10ScopesAndTypes/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/10ScopesAndTypes/types/controllers/RagfairController.d.ts b/TypeScript/10ScopesAndTypes/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/10ScopesAndTypes/types/controllers/RagfairController.d.ts +++ b/TypeScript/10ScopesAndTypes/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/10ScopesAndTypes/types/helpers/RagfairHelper.d.ts b/TypeScript/10ScopesAndTypes/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/10ScopesAndTypes/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/10ScopesAndTypes/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/10ScopesAndTypes/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/10ScopesAndTypes/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/10ScopesAndTypes/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/10ScopesAndTypes/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/10ScopesAndTypes/types/helpers/RagfairSellHelper.d.ts b/TypeScript/10ScopesAndTypes/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/10ScopesAndTypes/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/10ScopesAndTypes/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/10ScopesAndTypes/types/models/enums/FleaOfferType.d.ts b/TypeScript/10ScopesAndTypes/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/10ScopesAndTypes/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/10ScopesAndTypes/types/services/RagfairOfferService.d.ts b/TypeScript/10ScopesAndTypes/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/10ScopesAndTypes/types/services/RagfairOfferService.d.ts +++ b/TypeScript/10ScopesAndTypes/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/11BundleLoadingSample/types/controllers/BotController.d.ts b/TypeScript/11BundleLoadingSample/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/11BundleLoadingSample/types/controllers/BotController.d.ts +++ b/TypeScript/11BundleLoadingSample/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/11BundleLoadingSample/types/controllers/RagfairController.d.ts b/TypeScript/11BundleLoadingSample/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/11BundleLoadingSample/types/controllers/RagfairController.d.ts +++ b/TypeScript/11BundleLoadingSample/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/11BundleLoadingSample/types/helpers/RagfairHelper.d.ts b/TypeScript/11BundleLoadingSample/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/11BundleLoadingSample/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/11BundleLoadingSample/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/11BundleLoadingSample/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/11BundleLoadingSample/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/11BundleLoadingSample/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/11BundleLoadingSample/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/11BundleLoadingSample/types/helpers/RagfairSellHelper.d.ts b/TypeScript/11BundleLoadingSample/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/11BundleLoadingSample/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/11BundleLoadingSample/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/11BundleLoadingSample/types/models/enums/FleaOfferType.d.ts b/TypeScript/11BundleLoadingSample/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/11BundleLoadingSample/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/11BundleLoadingSample/types/services/RagfairOfferService.d.ts b/TypeScript/11BundleLoadingSample/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/11BundleLoadingSample/types/services/RagfairOfferService.d.ts +++ b/TypeScript/11BundleLoadingSample/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/12ClassExtensionOverride/types/controllers/BotController.d.ts b/TypeScript/12ClassExtensionOverride/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/12ClassExtensionOverride/types/controllers/BotController.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/12ClassExtensionOverride/types/controllers/RagfairController.d.ts b/TypeScript/12ClassExtensionOverride/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/12ClassExtensionOverride/types/controllers/RagfairController.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/12ClassExtensionOverride/types/helpers/RagfairHelper.d.ts b/TypeScript/12ClassExtensionOverride/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/12ClassExtensionOverride/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/12ClassExtensionOverride/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/12ClassExtensionOverride/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/12ClassExtensionOverride/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/12ClassExtensionOverride/types/helpers/RagfairSellHelper.d.ts b/TypeScript/12ClassExtensionOverride/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/12ClassExtensionOverride/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/12ClassExtensionOverride/types/models/enums/FleaOfferType.d.ts b/TypeScript/12ClassExtensionOverride/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/12ClassExtensionOverride/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/12ClassExtensionOverride/types/services/RagfairOfferService.d.ts b/TypeScript/12ClassExtensionOverride/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/12ClassExtensionOverride/types/services/RagfairOfferService.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/13.1AddTraderWithAssortJSON/types/controllers/BotController.d.ts b/TypeScript/13.1AddTraderWithAssortJSON/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/13.1AddTraderWithAssortJSON/types/controllers/BotController.d.ts +++ b/TypeScript/13.1AddTraderWithAssortJSON/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/13.1AddTraderWithAssortJSON/types/controllers/RagfairController.d.ts b/TypeScript/13.1AddTraderWithAssortJSON/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/13.1AddTraderWithAssortJSON/types/controllers/RagfairController.d.ts +++ b/TypeScript/13.1AddTraderWithAssortJSON/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/13.1AddTraderWithAssortJSON/types/helpers/RagfairHelper.d.ts b/TypeScript/13.1AddTraderWithAssortJSON/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/13.1AddTraderWithAssortJSON/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/13.1AddTraderWithAssortJSON/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/13.1AddTraderWithAssortJSON/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/13.1AddTraderWithAssortJSON/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/13.1AddTraderWithAssortJSON/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/13.1AddTraderWithAssortJSON/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/13.1AddTraderWithAssortJSON/types/helpers/RagfairSellHelper.d.ts b/TypeScript/13.1AddTraderWithAssortJSON/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/13.1AddTraderWithAssortJSON/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/13.1AddTraderWithAssortJSON/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/13.1AddTraderWithAssortJSON/types/models/enums/FleaOfferType.d.ts b/TypeScript/13.1AddTraderWithAssortJSON/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/13.1AddTraderWithAssortJSON/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/13.1AddTraderWithAssortJSON/types/services/RagfairOfferService.d.ts b/TypeScript/13.1AddTraderWithAssortJSON/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/13.1AddTraderWithAssortJSON/types/services/RagfairOfferService.d.ts +++ b/TypeScript/13.1AddTraderWithAssortJSON/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/13AddTrader/types/controllers/BotController.d.ts b/TypeScript/13AddTrader/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/13AddTrader/types/controllers/BotController.d.ts +++ b/TypeScript/13AddTrader/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/13AddTrader/types/controllers/RagfairController.d.ts b/TypeScript/13AddTrader/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/13AddTrader/types/controllers/RagfairController.d.ts +++ b/TypeScript/13AddTrader/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/13AddTrader/types/helpers/RagfairHelper.d.ts b/TypeScript/13AddTrader/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/13AddTrader/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/13AddTrader/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/13AddTrader/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/13AddTrader/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/13AddTrader/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/13AddTrader/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/13AddTrader/types/helpers/RagfairSellHelper.d.ts b/TypeScript/13AddTrader/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/13AddTrader/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/13AddTrader/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/13AddTrader/types/models/enums/FleaOfferType.d.ts b/TypeScript/13AddTrader/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/13AddTrader/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/13AddTrader/types/services/RagfairOfferService.d.ts b/TypeScript/13AddTrader/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/13AddTrader/types/services/RagfairOfferService.d.ts +++ b/TypeScript/13AddTrader/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/14AfterDBLoadHook/types/controllers/BotController.d.ts b/TypeScript/14AfterDBLoadHook/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/14AfterDBLoadHook/types/controllers/BotController.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/14AfterDBLoadHook/types/controllers/RagfairController.d.ts b/TypeScript/14AfterDBLoadHook/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/14AfterDBLoadHook/types/controllers/RagfairController.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/14AfterDBLoadHook/types/helpers/RagfairHelper.d.ts b/TypeScript/14AfterDBLoadHook/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/14AfterDBLoadHook/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/14AfterDBLoadHook/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/14AfterDBLoadHook/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/14AfterDBLoadHook/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/14AfterDBLoadHook/types/helpers/RagfairSellHelper.d.ts b/TypeScript/14AfterDBLoadHook/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/14AfterDBLoadHook/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/14AfterDBLoadHook/types/models/enums/FleaOfferType.d.ts b/TypeScript/14AfterDBLoadHook/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/14AfterDBLoadHook/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/14AfterDBLoadHook/types/services/RagfairOfferService.d.ts b/TypeScript/14AfterDBLoadHook/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/14AfterDBLoadHook/types/services/RagfairOfferService.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/15HttpListenerExample/types/controllers/BotController.d.ts b/TypeScript/15HttpListenerExample/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/15HttpListenerExample/types/controllers/BotController.d.ts +++ b/TypeScript/15HttpListenerExample/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/15HttpListenerExample/types/controllers/RagfairController.d.ts b/TypeScript/15HttpListenerExample/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/15HttpListenerExample/types/controllers/RagfairController.d.ts +++ b/TypeScript/15HttpListenerExample/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/15HttpListenerExample/types/helpers/RagfairHelper.d.ts b/TypeScript/15HttpListenerExample/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/15HttpListenerExample/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/15HttpListenerExample/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/15HttpListenerExample/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/15HttpListenerExample/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/15HttpListenerExample/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/15HttpListenerExample/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/15HttpListenerExample/types/helpers/RagfairSellHelper.d.ts b/TypeScript/15HttpListenerExample/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/15HttpListenerExample/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/15HttpListenerExample/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/15HttpListenerExample/types/models/enums/FleaOfferType.d.ts b/TypeScript/15HttpListenerExample/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/15HttpListenerExample/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/15HttpListenerExample/types/services/RagfairOfferService.d.ts b/TypeScript/15HttpListenerExample/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/15HttpListenerExample/types/services/RagfairOfferService.d.ts +++ b/TypeScript/15HttpListenerExample/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/16ImporterUtil/types/controllers/BotController.d.ts b/TypeScript/16ImporterUtil/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/16ImporterUtil/types/controllers/BotController.d.ts +++ b/TypeScript/16ImporterUtil/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/16ImporterUtil/types/controllers/RagfairController.d.ts b/TypeScript/16ImporterUtil/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/16ImporterUtil/types/controllers/RagfairController.d.ts +++ b/TypeScript/16ImporterUtil/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/16ImporterUtil/types/helpers/RagfairHelper.d.ts b/TypeScript/16ImporterUtil/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/16ImporterUtil/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/16ImporterUtil/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/16ImporterUtil/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/16ImporterUtil/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/16ImporterUtil/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/16ImporterUtil/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/16ImporterUtil/types/helpers/RagfairSellHelper.d.ts b/TypeScript/16ImporterUtil/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/16ImporterUtil/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/16ImporterUtil/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/16ImporterUtil/types/models/enums/FleaOfferType.d.ts b/TypeScript/16ImporterUtil/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/16ImporterUtil/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/16ImporterUtil/types/services/RagfairOfferService.d.ts b/TypeScript/16ImporterUtil/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/16ImporterUtil/types/services/RagfairOfferService.d.ts +++ b/TypeScript/16ImporterUtil/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/17AsyncImporterWithDependency1/types/controllers/BotController.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/controllers/BotController.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/17AsyncImporterWithDependency1/types/controllers/RagfairController.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/controllers/RagfairController.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/17AsyncImporterWithDependency1/types/helpers/RagfairHelper.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/17AsyncImporterWithDependency1/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/17AsyncImporterWithDependency1/types/helpers/RagfairSellHelper.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/17AsyncImporterWithDependency1/types/models/enums/FleaOfferType.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/17AsyncImporterWithDependency1/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/17AsyncImporterWithDependency1/types/services/RagfairOfferService.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/services/RagfairOfferService.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/17AsyncImporterWithDependency2/types/controllers/BotController.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/controllers/BotController.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/17AsyncImporterWithDependency2/types/controllers/RagfairController.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/controllers/RagfairController.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/17AsyncImporterWithDependency2/types/helpers/RagfairHelper.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/17AsyncImporterWithDependency2/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/17AsyncImporterWithDependency2/types/helpers/RagfairSellHelper.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/17AsyncImporterWithDependency2/types/models/enums/FleaOfferType.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/17AsyncImporterWithDependency2/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/17AsyncImporterWithDependency2/types/services/RagfairOfferService.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/services/RagfairOfferService.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/18.1CustomItemServiceLootBox/types/controllers/BotController.d.ts b/TypeScript/18.1CustomItemServiceLootBox/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/18.1CustomItemServiceLootBox/types/controllers/BotController.d.ts +++ b/TypeScript/18.1CustomItemServiceLootBox/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/18.1CustomItemServiceLootBox/types/controllers/RagfairController.d.ts b/TypeScript/18.1CustomItemServiceLootBox/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/18.1CustomItemServiceLootBox/types/controllers/RagfairController.d.ts +++ b/TypeScript/18.1CustomItemServiceLootBox/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/18.1CustomItemServiceLootBox/types/helpers/RagfairHelper.d.ts b/TypeScript/18.1CustomItemServiceLootBox/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/18.1CustomItemServiceLootBox/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/18.1CustomItemServiceLootBox/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/18.1CustomItemServiceLootBox/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/18.1CustomItemServiceLootBox/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/18.1CustomItemServiceLootBox/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/18.1CustomItemServiceLootBox/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/18.1CustomItemServiceLootBox/types/helpers/RagfairSellHelper.d.ts b/TypeScript/18.1CustomItemServiceLootBox/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/18.1CustomItemServiceLootBox/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/18.1CustomItemServiceLootBox/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/18.1CustomItemServiceLootBox/types/models/enums/FleaOfferType.d.ts b/TypeScript/18.1CustomItemServiceLootBox/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/18.1CustomItemServiceLootBox/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/18.1CustomItemServiceLootBox/types/services/RagfairOfferService.d.ts b/TypeScript/18.1CustomItemServiceLootBox/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/18.1CustomItemServiceLootBox/types/services/RagfairOfferService.d.ts +++ b/TypeScript/18.1CustomItemServiceLootBox/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/18CustomItemService/types/controllers/BotController.d.ts b/TypeScript/18CustomItemService/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/18CustomItemService/types/controllers/BotController.d.ts +++ b/TypeScript/18CustomItemService/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/18CustomItemService/types/controllers/RagfairController.d.ts b/TypeScript/18CustomItemService/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/18CustomItemService/types/controllers/RagfairController.d.ts +++ b/TypeScript/18CustomItemService/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/18CustomItemService/types/helpers/RagfairHelper.d.ts b/TypeScript/18CustomItemService/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/18CustomItemService/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/18CustomItemService/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/18CustomItemService/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/18CustomItemService/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/18CustomItemService/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/18CustomItemService/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/18CustomItemService/types/helpers/RagfairSellHelper.d.ts b/TypeScript/18CustomItemService/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/18CustomItemService/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/18CustomItemService/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/18CustomItemService/types/models/enums/FleaOfferType.d.ts b/TypeScript/18CustomItemService/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/18CustomItemService/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/18CustomItemService/types/services/RagfairOfferService.d.ts b/TypeScript/18CustomItemService/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/18CustomItemService/types/services/RagfairOfferService.d.ts +++ b/TypeScript/18CustomItemService/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/19UseExternalLibraries/types/controllers/BotController.d.ts b/TypeScript/19UseExternalLibraries/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/19UseExternalLibraries/types/controllers/BotController.d.ts +++ b/TypeScript/19UseExternalLibraries/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/19UseExternalLibraries/types/controllers/RagfairController.d.ts b/TypeScript/19UseExternalLibraries/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/19UseExternalLibraries/types/controllers/RagfairController.d.ts +++ b/TypeScript/19UseExternalLibraries/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/19UseExternalLibraries/types/helpers/RagfairHelper.d.ts b/TypeScript/19UseExternalLibraries/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/19UseExternalLibraries/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/19UseExternalLibraries/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/19UseExternalLibraries/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/19UseExternalLibraries/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/19UseExternalLibraries/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/19UseExternalLibraries/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/19UseExternalLibraries/types/helpers/RagfairSellHelper.d.ts b/TypeScript/19UseExternalLibraries/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/19UseExternalLibraries/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/19UseExternalLibraries/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/19UseExternalLibraries/types/models/enums/FleaOfferType.d.ts b/TypeScript/19UseExternalLibraries/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/19UseExternalLibraries/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/19UseExternalLibraries/types/services/RagfairOfferService.d.ts b/TypeScript/19UseExternalLibraries/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/19UseExternalLibraries/types/services/RagfairOfferService.d.ts +++ b/TypeScript/19UseExternalLibraries/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/1LogToConsole/types/controllers/BotController.d.ts b/TypeScript/1LogToConsole/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/1LogToConsole/types/controllers/BotController.d.ts +++ b/TypeScript/1LogToConsole/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/1LogToConsole/types/controllers/RagfairController.d.ts b/TypeScript/1LogToConsole/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/1LogToConsole/types/controllers/RagfairController.d.ts +++ b/TypeScript/1LogToConsole/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/1LogToConsole/types/helpers/RagfairHelper.d.ts b/TypeScript/1LogToConsole/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/1LogToConsole/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/1LogToConsole/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/1LogToConsole/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/1LogToConsole/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/1LogToConsole/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/1LogToConsole/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/1LogToConsole/types/helpers/RagfairSellHelper.d.ts b/TypeScript/1LogToConsole/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/1LogToConsole/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/1LogToConsole/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/1LogToConsole/types/models/enums/FleaOfferType.d.ts b/TypeScript/1LogToConsole/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/1LogToConsole/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/1LogToConsole/types/services/RagfairOfferService.d.ts b/TypeScript/1LogToConsole/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/1LogToConsole/types/services/RagfairOfferService.d.ts +++ b/TypeScript/1LogToConsole/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/20CustomChatBot/types/controllers/BotController.d.ts b/TypeScript/20CustomChatBot/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/20CustomChatBot/types/controllers/BotController.d.ts +++ b/TypeScript/20CustomChatBot/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/20CustomChatBot/types/controllers/RagfairController.d.ts b/TypeScript/20CustomChatBot/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/20CustomChatBot/types/controllers/RagfairController.d.ts +++ b/TypeScript/20CustomChatBot/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/20CustomChatBot/types/helpers/RagfairHelper.d.ts b/TypeScript/20CustomChatBot/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/20CustomChatBot/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/20CustomChatBot/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/20CustomChatBot/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/20CustomChatBot/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/20CustomChatBot/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/20CustomChatBot/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/20CustomChatBot/types/helpers/RagfairSellHelper.d.ts b/TypeScript/20CustomChatBot/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/20CustomChatBot/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/20CustomChatBot/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/20CustomChatBot/types/models/enums/FleaOfferType.d.ts b/TypeScript/20CustomChatBot/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/20CustomChatBot/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/20CustomChatBot/types/services/RagfairOfferService.d.ts b/TypeScript/20CustomChatBot/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/20CustomChatBot/types/services/RagfairOfferService.d.ts +++ b/TypeScript/20CustomChatBot/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/21CustomCommandoCommand/types/controllers/BotController.d.ts b/TypeScript/21CustomCommandoCommand/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/21CustomCommandoCommand/types/controllers/BotController.d.ts +++ b/TypeScript/21CustomCommandoCommand/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/21CustomCommandoCommand/types/controllers/RagfairController.d.ts b/TypeScript/21CustomCommandoCommand/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/21CustomCommandoCommand/types/controllers/RagfairController.d.ts +++ b/TypeScript/21CustomCommandoCommand/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/21CustomCommandoCommand/types/helpers/RagfairHelper.d.ts b/TypeScript/21CustomCommandoCommand/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/21CustomCommandoCommand/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/21CustomCommandoCommand/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/21CustomCommandoCommand/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/21CustomCommandoCommand/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/21CustomCommandoCommand/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/21CustomCommandoCommand/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/21CustomCommandoCommand/types/helpers/RagfairSellHelper.d.ts b/TypeScript/21CustomCommandoCommand/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/21CustomCommandoCommand/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/21CustomCommandoCommand/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/21CustomCommandoCommand/types/models/enums/FleaOfferType.d.ts b/TypeScript/21CustomCommandoCommand/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/21CustomCommandoCommand/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/21CustomCommandoCommand/types/services/RagfairOfferService.d.ts b/TypeScript/21CustomCommandoCommand/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/21CustomCommandoCommand/types/services/RagfairOfferService.d.ts +++ b/TypeScript/21CustomCommandoCommand/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/22CustomAkiCommand/types/controllers/BotController.d.ts b/TypeScript/22CustomAkiCommand/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/22CustomAkiCommand/types/controllers/BotController.d.ts +++ b/TypeScript/22CustomAkiCommand/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/22CustomAkiCommand/types/controllers/RagfairController.d.ts b/TypeScript/22CustomAkiCommand/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/22CustomAkiCommand/types/controllers/RagfairController.d.ts +++ b/TypeScript/22CustomAkiCommand/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/22CustomAkiCommand/types/helpers/RagfairHelper.d.ts b/TypeScript/22CustomAkiCommand/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/22CustomAkiCommand/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/22CustomAkiCommand/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/22CustomAkiCommand/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/22CustomAkiCommand/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/22CustomAkiCommand/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/22CustomAkiCommand/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/22CustomAkiCommand/types/helpers/RagfairSellHelper.d.ts b/TypeScript/22CustomAkiCommand/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/22CustomAkiCommand/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/22CustomAkiCommand/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/22CustomAkiCommand/types/models/enums/FleaOfferType.d.ts b/TypeScript/22CustomAkiCommand/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/22CustomAkiCommand/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/22CustomAkiCommand/types/services/RagfairOfferService.d.ts b/TypeScript/22CustomAkiCommand/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/22CustomAkiCommand/types/services/RagfairOfferService.d.ts +++ b/TypeScript/22CustomAkiCommand/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/2EditDatabase/types/controllers/BotController.d.ts b/TypeScript/2EditDatabase/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/2EditDatabase/types/controllers/BotController.d.ts +++ b/TypeScript/2EditDatabase/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/2EditDatabase/types/controllers/RagfairController.d.ts b/TypeScript/2EditDatabase/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/2EditDatabase/types/controllers/RagfairController.d.ts +++ b/TypeScript/2EditDatabase/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/2EditDatabase/types/helpers/RagfairHelper.d.ts b/TypeScript/2EditDatabase/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/2EditDatabase/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/2EditDatabase/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/2EditDatabase/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/2EditDatabase/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/2EditDatabase/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/2EditDatabase/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/2EditDatabase/types/helpers/RagfairSellHelper.d.ts b/TypeScript/2EditDatabase/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/2EditDatabase/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/2EditDatabase/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/2EditDatabase/types/models/enums/FleaOfferType.d.ts b/TypeScript/2EditDatabase/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/2EditDatabase/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/2EditDatabase/types/services/RagfairOfferService.d.ts b/TypeScript/2EditDatabase/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/2EditDatabase/types/services/RagfairOfferService.d.ts +++ b/TypeScript/2EditDatabase/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/3GetSptConfigFile/types/controllers/BotController.d.ts b/TypeScript/3GetSptConfigFile/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/3GetSptConfigFile/types/controllers/BotController.d.ts +++ b/TypeScript/3GetSptConfigFile/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/3GetSptConfigFile/types/controllers/RagfairController.d.ts b/TypeScript/3GetSptConfigFile/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/3GetSptConfigFile/types/controllers/RagfairController.d.ts +++ b/TypeScript/3GetSptConfigFile/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/3GetSptConfigFile/types/helpers/RagfairHelper.d.ts b/TypeScript/3GetSptConfigFile/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/3GetSptConfigFile/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/3GetSptConfigFile/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/3GetSptConfigFile/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/3GetSptConfigFile/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/3GetSptConfigFile/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/3GetSptConfigFile/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/3GetSptConfigFile/types/helpers/RagfairSellHelper.d.ts b/TypeScript/3GetSptConfigFile/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/3GetSptConfigFile/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/3GetSptConfigFile/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/3GetSptConfigFile/types/models/enums/FleaOfferType.d.ts b/TypeScript/3GetSptConfigFile/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/3GetSptConfigFile/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/3GetSptConfigFile/types/services/RagfairOfferService.d.ts b/TypeScript/3GetSptConfigFile/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/3GetSptConfigFile/types/services/RagfairOfferService.d.ts +++ b/TypeScript/3GetSptConfigFile/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/controllers/BotController.d.ts b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/controllers/BotController.d.ts +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/controllers/RagfairController.d.ts b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/controllers/RagfairController.d.ts +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/RagfairHelper.d.ts b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/RagfairSellHelper.d.ts b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/models/enums/FleaOfferType.d.ts b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/services/RagfairOfferService.d.ts b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/services/RagfairOfferService.d.ts +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/4UseACustomConfigFile/types/controllers/BotController.d.ts b/TypeScript/4UseACustomConfigFile/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/4UseACustomConfigFile/types/controllers/BotController.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/4UseACustomConfigFile/types/controllers/RagfairController.d.ts b/TypeScript/4UseACustomConfigFile/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/4UseACustomConfigFile/types/controllers/RagfairController.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/4UseACustomConfigFile/types/helpers/RagfairHelper.d.ts b/TypeScript/4UseACustomConfigFile/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/4UseACustomConfigFile/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/4UseACustomConfigFile/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/4UseACustomConfigFile/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/4UseACustomConfigFile/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/4UseACustomConfigFile/types/helpers/RagfairSellHelper.d.ts b/TypeScript/4UseACustomConfigFile/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/4UseACustomConfigFile/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/4UseACustomConfigFile/types/models/enums/FleaOfferType.d.ts b/TypeScript/4UseACustomConfigFile/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/4UseACustomConfigFile/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/4UseACustomConfigFile/types/services/RagfairOfferService.d.ts b/TypeScript/4UseACustomConfigFile/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/4UseACustomConfigFile/types/services/RagfairOfferService.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/5ReplaceMethod/types/controllers/BotController.d.ts b/TypeScript/5ReplaceMethod/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/5ReplaceMethod/types/controllers/BotController.d.ts +++ b/TypeScript/5ReplaceMethod/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/5ReplaceMethod/types/controllers/RagfairController.d.ts b/TypeScript/5ReplaceMethod/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/5ReplaceMethod/types/controllers/RagfairController.d.ts +++ b/TypeScript/5ReplaceMethod/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/5ReplaceMethod/types/helpers/RagfairHelper.d.ts b/TypeScript/5ReplaceMethod/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/5ReplaceMethod/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/5ReplaceMethod/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/5ReplaceMethod/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/5ReplaceMethod/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/5ReplaceMethod/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/5ReplaceMethod/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/5ReplaceMethod/types/helpers/RagfairSellHelper.d.ts b/TypeScript/5ReplaceMethod/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/5ReplaceMethod/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/5ReplaceMethod/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/5ReplaceMethod/types/models/enums/FleaOfferType.d.ts b/TypeScript/5ReplaceMethod/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/5ReplaceMethod/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/5ReplaceMethod/types/services/RagfairOfferService.d.ts b/TypeScript/5ReplaceMethod/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/5ReplaceMethod/types/services/RagfairOfferService.d.ts +++ b/TypeScript/5ReplaceMethod/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/6ReferenceAnotherClass/types/controllers/BotController.d.ts b/TypeScript/6ReferenceAnotherClass/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/6ReferenceAnotherClass/types/controllers/BotController.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/6ReferenceAnotherClass/types/controllers/RagfairController.d.ts b/TypeScript/6ReferenceAnotherClass/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/6ReferenceAnotherClass/types/controllers/RagfairController.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/6ReferenceAnotherClass/types/helpers/RagfairHelper.d.ts b/TypeScript/6ReferenceAnotherClass/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/6ReferenceAnotherClass/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/6ReferenceAnotherClass/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/6ReferenceAnotherClass/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/6ReferenceAnotherClass/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/6ReferenceAnotherClass/types/helpers/RagfairSellHelper.d.ts b/TypeScript/6ReferenceAnotherClass/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/6ReferenceAnotherClass/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/6ReferenceAnotherClass/types/models/enums/FleaOfferType.d.ts b/TypeScript/6ReferenceAnotherClass/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/6ReferenceAnotherClass/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/6ReferenceAnotherClass/types/services/RagfairOfferService.d.ts b/TypeScript/6ReferenceAnotherClass/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/6ReferenceAnotherClass/types/services/RagfairOfferService.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/7OnLoadHook/types/controllers/BotController.d.ts b/TypeScript/7OnLoadHook/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/7OnLoadHook/types/controllers/BotController.d.ts +++ b/TypeScript/7OnLoadHook/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/7OnLoadHook/types/controllers/RagfairController.d.ts b/TypeScript/7OnLoadHook/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/7OnLoadHook/types/controllers/RagfairController.d.ts +++ b/TypeScript/7OnLoadHook/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/7OnLoadHook/types/helpers/RagfairHelper.d.ts b/TypeScript/7OnLoadHook/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/7OnLoadHook/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/7OnLoadHook/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/7OnLoadHook/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/7OnLoadHook/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/7OnLoadHook/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/7OnLoadHook/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/7OnLoadHook/types/helpers/RagfairSellHelper.d.ts b/TypeScript/7OnLoadHook/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/7OnLoadHook/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/7OnLoadHook/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/7OnLoadHook/types/models/enums/FleaOfferType.d.ts b/TypeScript/7OnLoadHook/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/7OnLoadHook/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/7OnLoadHook/types/services/RagfairOfferService.d.ts b/TypeScript/7OnLoadHook/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/7OnLoadHook/types/services/RagfairOfferService.d.ts +++ b/TypeScript/7OnLoadHook/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/8OnUpdateHook/types/controllers/BotController.d.ts b/TypeScript/8OnUpdateHook/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/8OnUpdateHook/types/controllers/BotController.d.ts +++ b/TypeScript/8OnUpdateHook/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/8OnUpdateHook/types/controllers/RagfairController.d.ts b/TypeScript/8OnUpdateHook/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/8OnUpdateHook/types/controllers/RagfairController.d.ts +++ b/TypeScript/8OnUpdateHook/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/8OnUpdateHook/types/helpers/RagfairHelper.d.ts b/TypeScript/8OnUpdateHook/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/8OnUpdateHook/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/8OnUpdateHook/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/8OnUpdateHook/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/8OnUpdateHook/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/8OnUpdateHook/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/8OnUpdateHook/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/8OnUpdateHook/types/helpers/RagfairSellHelper.d.ts b/TypeScript/8OnUpdateHook/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/8OnUpdateHook/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/8OnUpdateHook/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/8OnUpdateHook/types/models/enums/FleaOfferType.d.ts b/TypeScript/8OnUpdateHook/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/8OnUpdateHook/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/8OnUpdateHook/types/services/RagfairOfferService.d.ts b/TypeScript/8OnUpdateHook/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/8OnUpdateHook/types/services/RagfairOfferService.d.ts +++ b/TypeScript/8OnUpdateHook/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; } diff --git a/TypeScript/9RouterHooks/types/controllers/BotController.d.ts b/TypeScript/9RouterHooks/types/controllers/BotController.d.ts index e592cc2..6431fca 100644 --- a/TypeScript/9RouterHooks/types/controllers/BotController.d.ts +++ b/TypeScript/9RouterHooks/types/controllers/BotController.d.ts @@ -77,7 +77,7 @@ export declare class BotController { * @param sessionId Session id * @returns */ - protected generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; + generateBotsFirstTime(request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string): Promise; /** * Create a BotGenerationDetails for the bot generator to use * @param condition Client data defining bot type and difficulty @@ -117,7 +117,7 @@ export declare class BotController { * @param request Bot generation request object * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; + returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise; protected updateBotGenerationDetailsToRandomBoss(botGenerationDetails: BotGenerationDetails, possibleBossTypeWeights: Record): void; /** * Get the difficulty passed in, if its not "asonline", get selected difficulty from config diff --git a/TypeScript/9RouterHooks/types/controllers/RagfairController.d.ts b/TypeScript/9RouterHooks/types/controllers/RagfairController.d.ts index d4d4574..fbd25e0 100644 --- a/TypeScript/9RouterHooks/types/controllers/RagfairController.d.ts +++ b/TypeScript/9RouterHooks/types/controllers/RagfairController.d.ts @@ -24,6 +24,7 @@ import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData"; +import { FleaOfferType } from "@spt/models/enums/FleaOfferType"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { EventOutputHolder } from "@spt/routers/EventOutputHolder"; @@ -148,13 +149,52 @@ export declare class RagfairController { * @returns 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 * @param sessionID Player id * @param rootItem Base item being listed (used when client tax cost not found and must be done on server) * @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 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 output IItemEventRouterResponse * @returns True if charging tax to player failed @@ -180,7 +220,7 @@ export declare class RagfairController { * @returns Array of items from player inventory */ protected getItemsToListOnFleaFromInventory(pmcData: IPmcData, itemIdsFromFleaOfferRequest: string[]): { - items: Item[] | undefined; + items: Item[][] | undefined; errorMessage: string | undefined; }; createPlayerOffer(sessionId: string, requirements: Requirement[], items: Item[], sellInOnePiece: boolean): IRagfairOffer; diff --git a/TypeScript/9RouterHooks/types/helpers/RagfairHelper.d.ts b/TypeScript/9RouterHooks/types/helpers/RagfairHelper.d.ts index 4f45bba..52ca467 100644 --- a/TypeScript/9RouterHooks/types/helpers/RagfairHelper.d.ts +++ b/TypeScript/9RouterHooks/types/helpers/RagfairHelper.d.ts @@ -33,7 +33,7 @@ export declare class RagfairHelper { getDisplayableAssorts(sessionID: string): Record; protected getCategoryList(handbookId: string): string[]; /** - * Merges Root Items + * Iterate over array of identical items and merge stack count * Ragfair allows abnormally large stacks. */ mergeStackable(items: Item[]): Item[]; diff --git a/TypeScript/9RouterHooks/types/helpers/RagfairOfferHelper.d.ts b/TypeScript/9RouterHooks/types/helpers/RagfairOfferHelper.d.ts index f33c130..b526554 100644 --- a/TypeScript/9RouterHooks/types/helpers/RagfairOfferHelper.d.ts +++ b/TypeScript/9RouterHooks/types/helpers/RagfairOfferHelper.d.ts @@ -120,6 +120,12 @@ export declare class RagfairOfferHelper { * @returns true = complete */ 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 * @param sessionId Profile to update diff --git a/TypeScript/9RouterHooks/types/helpers/RagfairSellHelper.d.ts b/TypeScript/9RouterHooks/types/helpers/RagfairSellHelper.d.ts index dfea2a8..fc9e4b5 100644 --- a/TypeScript/9RouterHooks/types/helpers/RagfairSellHelper.d.ts +++ b/TypeScript/9RouterHooks/types/helpers/RagfairSellHelper.d.ts @@ -25,7 +25,8 @@ export declare class RagfairSellHelper { * Get array of item count and sell time (empty array = no sell) * @param sellChancePercent chance item will 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 */ - rollForSale(sellChancePercent: number, itemSellCount: number): SellResult[]; + rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[]; } diff --git a/TypeScript/9RouterHooks/types/models/enums/FleaOfferType.d.ts b/TypeScript/9RouterHooks/types/models/enums/FleaOfferType.d.ts new file mode 100644 index 0000000..9915abf --- /dev/null +++ b/TypeScript/9RouterHooks/types/models/enums/FleaOfferType.d.ts @@ -0,0 +1,6 @@ +export declare enum FleaOfferType { + SINGLE = 0, + MULTI = 1, + PACK = 2, + UNKNOWN = 3 +} diff --git a/TypeScript/9RouterHooks/types/services/RagfairOfferService.d.ts b/TypeScript/9RouterHooks/types/services/RagfairOfferService.d.ts index 4bc07c3..6c13b1d 100644 --- a/TypeScript/9RouterHooks/types/services/RagfairOfferService.d.ts +++ b/TypeScript/9RouterHooks/types/services/RagfairOfferService.d.ts @@ -1,3 +1,4 @@ +import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper"; 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 { DatabaseService } from "@spt/services/DatabaseService"; import { LocalisationService } from "@spt/services/LocalisationService"; +import { ICloner } from "@spt/utils/cloners/ICloner"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { RagfairOfferHolder } from "@spt/utils/RagfairOfferHolder"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -18,17 +20,19 @@ export declare class RagfairOfferService { protected databaseService: DatabaseService; protected saveServer: SaveServer; protected ragfairServerHelper: RagfairServerHelper; + protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected eventOutputHolder: EventOutputHolder; protected httpResponse: HttpResponseUtil; protected localisationService: LocalisationService; protected configServer: ConfigServer; + protected cloner: ICloner; protected playerOffersLoaded: boolean; /** Offer id + offer object */ protected expiredOffers: Record; protected ragfairConfig: IRagfairConfig; 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 * @returns IRagfairOffer array @@ -84,4 +88,12 @@ export declare class RagfairOfferService { */ protected processStaleOffer(staleOffer: 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[]; }