Improved accuracy when creating flea offer - store single item price in `` property

Made `unlimited` property optional as its only used by traders
Slightly reduced pack offer chance + made them have more items
This commit is contained in:
Dev 2024-07-19 13:45:34 +01:00
parent 5447203bf4
commit ccc4974fa2
3 changed files with 22 additions and 25 deletions

View File

@ -48,9 +48,9 @@
] ]
}, },
"pack": { "pack": {
"chancePercent": 20, "chancePercent": 18,
"itemCountMin": 4, "itemCountMin": 4,
"itemCountMax": 12, "itemCountMax": 18,
"itemTypeWhitelist": [ "itemTypeWhitelist": [
"5448eb774bdc2d0a728b4567", "5448eb774bdc2d0a728b4567",
"5448e8d64bdc2dce718b4568", "5448e8d64bdc2dce718b4568",

View File

@ -101,7 +101,7 @@ export class RagfairOfferGenerator
* @param items Items in the offer * @param items Items in the offer
* @param barterScheme Cost of item (currency or barter) * @param barterScheme Cost of item (currency or barter)
* @param loyalLevel Loyalty level needed to buy item * @param loyalLevel Loyalty level needed to buy item
* @param sellInOnePiece Set StackObjectsCount to 1 * @param isPackOffer Is offer being created flaged as a pack
* @returns IRagfairOffer * @returns IRagfairOffer
*/ */
protected createOffer( protected createOffer(
@ -110,7 +110,7 @@ export class RagfairOfferGenerator
items: Item[], items: Item[],
barterScheme: IBarterScheme[], barterScheme: IBarterScheme[],
loyalLevel: number, loyalLevel: number,
sellInOnePiece = false, isPackOffer = false,
): IRagfairOffer ): IRagfairOffer
{ {
const isTrader = this.ragfairServerHelper.isTrader(userID); const isTrader = this.ragfairServerHelper.isTrader(userID);
@ -123,6 +123,7 @@ export class RagfairOfferGenerator
// Clone to avoid modifying original array // Clone to avoid modifying original array
const itemsClone = this.cloner.clone(items); const itemsClone = this.cloner.clone(items);
const itemStackCount = itemsClone[0].upd?.StackObjectsCount ?? 1;
// Hydrate ammo boxes with cartridges + ensure only 1 item is present (ammo box) // Hydrate ammo boxes with cartridges + ensure only 1 item is present (ammo box)
// On offer refresh dont re-add cartridges to ammo box that already has cartridges // On offer refresh dont re-add cartridges to ammo box that already has cartridges
@ -132,8 +133,8 @@ export class RagfairOfferGenerator
this.itemHelper.addCartridgesToAmmoBox(itemsClone, this.itemHelper.getItem(items[0]._tpl)[1]); this.itemHelper.addCartridgesToAmmoBox(itemsClone, this.itemHelper.getItem(items[0]._tpl)[1]);
} }
const itemRootCount = items.filter((item) => item.slotId === "hideout").length; const roubleListingPrice = Math.round(this.convertOfferRequirementsIntoRoubles(offerRequirements));
const roublePrice = Math.round(this.convertOfferRequirementsIntoRoubles(offerRequirements)); const singleItemListingPrice = isPackOffer ? roubleListingPrice / itemStackCount : roubleListingPrice;
const offer: IRagfairOffer = { const offer: IRagfairOffer = {
_id: this.hashUtil.generate(), _id: this.hashUtil.generate(),
@ -143,17 +144,13 @@ export class RagfairOfferGenerator
items: itemsClone, items: itemsClone,
itemsCost: Math.round(this.handbookHelper.getTemplatePrice(items[0]._tpl)), // Handbook price itemsCost: Math.round(this.handbookHelper.getTemplatePrice(items[0]._tpl)), // Handbook price
requirements: offerRequirements, requirements: offerRequirements,
requirementsCost: roublePrice, requirementsCost: singleItemListingPrice,
summaryCost: roublePrice, summaryCost: roubleListingPrice,
startTime: time, startTime: time,
endTime: this.getOfferEndTime(userID, time), endTime: this.getOfferEndTime(userID, time),
loyaltyLevel: loyalLevel, loyaltyLevel: loyalLevel,
sellInOnePiece: sellInOnePiece, sellInOnePiece: isPackOffer,
priority: false,
locked: false, locked: false,
unlimitedCount: false,
notAvailable: false,
CurrentItemCount: itemRootCount,
}; };
this.offerCounter++; this.offerCounter++;
@ -184,9 +181,10 @@ export class RagfairOfferGenerator
const playerProfile = this.profileHelper.getPmcProfile(userID)!; const playerProfile = this.profileHelper.getPmcProfile(userID)!;
return { return {
id: playerProfile._id, id: playerProfile._id,
memberType: MemberCategory.DEFAULT, memberType: playerProfile.Info.MemberCategory,
selectedMemberCategory: playerProfile.Info.SelectedMemberCategory,
nickname: playerProfile.Info.Nickname, nickname: playerProfile.Info.Nickname,
rating: playerProfile.RagfairInfo.rating, rating: playerProfile.RagfairInfo.rating ?? 0,
isRatingGrowing: playerProfile.RagfairInfo.isRatingGrowing, isRatingGrowing: playerProfile.RagfairInfo.isRatingGrowing,
avatar: undefined, avatar: undefined,
aid: playerProfile.aid, aid: playerProfile.aid,

View File

@ -11,23 +11,21 @@ export interface IRagfairOffer
intId: number intId: number
/** Handbook price */ /** Handbook price */
itemsCost: number itemsCost: number
/** Rouble price */ /** Rouble price per item */
requirementsCost: number requirementsCost: number
startTime: number startTime: number
endTime: number endTime: number
sellInOnePiece: boolean sellInOnePiece: boolean
/** Rouble price - same as requirementsCost */
summaryCost: number
user: IRagfairOfferUser
/** Trader only */
unlimitedCount?: boolean
loyaltyLevel: number loyaltyLevel: number
buyRestrictionMax?: number buyRestrictionMax?: number
buyRestrictionCurrent?: number buyRestrictionCurrent?: number
locked: boolean locked?: boolean
unlimitedCount: boolean
/** Rouble price */
summaryCost: number
user: IRagfairOfferUser
notAvailable: boolean
/** TODO - implement this value - not currently used */
CurrentItemCount: number
priority: boolean
} }
export interface OfferRequirement export interface OfferRequirement
@ -43,6 +41,7 @@ export interface IRagfairOfferUser
nickname?: string nickname?: string
rating?: number rating?: number
memberType: MemberCategory memberType: MemberCategory
selectedMemberCategory?: MemberCategory
avatar?: string avatar?: string
isRatingGrowing?: boolean isRatingGrowing?: boolean
aid?: number aid?: number