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": {
"chancePercent": 20,
"chancePercent": 18,
"itemCountMin": 4,
"itemCountMax": 12,
"itemCountMax": 18,
"itemTypeWhitelist": [
"5448eb774bdc2d0a728b4567",
"5448e8d64bdc2dce718b4568",

View File

@ -101,7 +101,7 @@ export class RagfairOfferGenerator
* @param items Items in the offer
* @param barterScheme Cost of item (currency or barter)
* @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
*/
protected createOffer(
@ -110,7 +110,7 @@ export class RagfairOfferGenerator
items: Item[],
barterScheme: IBarterScheme[],
loyalLevel: number,
sellInOnePiece = false,
isPackOffer = false,
): IRagfairOffer
{
const isTrader = this.ragfairServerHelper.isTrader(userID);
@ -123,6 +123,7 @@ export class RagfairOfferGenerator
// Clone to avoid modifying original array
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)
// 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]);
}
const itemRootCount = items.filter((item) => item.slotId === "hideout").length;
const roublePrice = Math.round(this.convertOfferRequirementsIntoRoubles(offerRequirements));
const roubleListingPrice = Math.round(this.convertOfferRequirementsIntoRoubles(offerRequirements));
const singleItemListingPrice = isPackOffer ? roubleListingPrice / itemStackCount : roubleListingPrice;
const offer: IRagfairOffer = {
_id: this.hashUtil.generate(),
@ -143,17 +144,13 @@ export class RagfairOfferGenerator
items: itemsClone,
itemsCost: Math.round(this.handbookHelper.getTemplatePrice(items[0]._tpl)), // Handbook price
requirements: offerRequirements,
requirementsCost: roublePrice,
summaryCost: roublePrice,
requirementsCost: singleItemListingPrice,
summaryCost: roubleListingPrice,
startTime: time,
endTime: this.getOfferEndTime(userID, time),
loyaltyLevel: loyalLevel,
sellInOnePiece: sellInOnePiece,
priority: false,
sellInOnePiece: isPackOffer,
locked: false,
unlimitedCount: false,
notAvailable: false,
CurrentItemCount: itemRootCount,
};
this.offerCounter++;
@ -184,9 +181,10 @@ export class RagfairOfferGenerator
const playerProfile = this.profileHelper.getPmcProfile(userID)!;
return {
id: playerProfile._id,
memberType: MemberCategory.DEFAULT,
memberType: playerProfile.Info.MemberCategory,
selectedMemberCategory: playerProfile.Info.SelectedMemberCategory,
nickname: playerProfile.Info.Nickname,
rating: playerProfile.RagfairInfo.rating,
rating: playerProfile.RagfairInfo.rating ?? 0,
isRatingGrowing: playerProfile.RagfairInfo.isRatingGrowing,
avatar: undefined,
aid: playerProfile.aid,

View File

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