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 e5a5bf2ee2
commit 727ba83273
3 changed files with 15 additions and 13 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

@ -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,14 +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: isPackOffer, sellInOnePiece: isPackOffer,
locked: false, locked: false,
unlimitedCount: false,
}; };
this.offerCounter++; this.offerCounter++;

View File

@ -11,19 +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
} }
export interface OfferRequirement export interface OfferRequirement