Updated createSingleOfferForItem()
to pass in sellerid + pass in itemdb object instead of array
This commit is contained in:
parent
1aac4a0635
commit
d744a38306
@ -368,11 +368,11 @@ export class RagfairOfferGenerator {
|
|||||||
isExpiredOffer: boolean,
|
isExpiredOffer: boolean,
|
||||||
config: IDynamic,
|
config: IDynamic,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const itemDetails = this.itemHelper.getItem(assortItemWithChildren[0]._tpl);
|
const itemToSellDetails = this.itemHelper.getItem(assortItemWithChildren[0]._tpl);
|
||||||
const isPreset = this.presetHelper.isPreset(assortItemWithChildren[0].upd.sptPresetId);
|
const isPreset = this.presetHelper.isPreset(assortItemWithChildren[0].upd.sptPresetId);
|
||||||
|
|
||||||
// Only perform checks on newly generated items, skip expired items being refreshed
|
// Only perform checks on newly generated items, skip expired items being refreshed
|
||||||
if (!(isExpiredOffer || this.ragfairServerHelper.isItemValidRagfairItem(itemDetails))) {
|
if (!(isExpiredOffer || this.ragfairServerHelper.isItemValidRagfairItem(itemToSellDetails))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,7 +398,9 @@ export class RagfairOfferGenerator {
|
|||||||
delete clonedAssort[0].parentId;
|
delete clonedAssort[0].parentId;
|
||||||
delete clonedAssort[0].slotId;
|
delete clonedAssort[0].slotId;
|
||||||
|
|
||||||
assortSingleOfferProcesses.push(this.createSingleOfferForItem(clonedAssort, isPreset, itemDetails));
|
assortSingleOfferProcesses.push(
|
||||||
|
this.createSingleOfferForItem(this.hashUtil.generate(), clonedAssort, isPreset, itemToSellDetails[1]),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(assortSingleOfferProcesses);
|
await Promise.all(assortSingleOfferProcesses);
|
||||||
@ -446,15 +448,17 @@ export class RagfairOfferGenerator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create one flea offer for a specific item
|
* Create one flea offer for a specific item
|
||||||
|
* @param sellerId Id of seller
|
||||||
* @param itemWithChildren Item to create offer for
|
* @param itemWithChildren Item to create offer for
|
||||||
* @param isPreset Is item a weapon preset
|
* @param isPreset Is item a weapon preset
|
||||||
* @param itemDetails raw db item details
|
* @param itemToSellDetails Raw db item details
|
||||||
* @returns Item array
|
* @returns Item array
|
||||||
*/
|
*/
|
||||||
protected async createSingleOfferForItem(
|
protected async createSingleOfferForItem(
|
||||||
|
sellerId: string,
|
||||||
itemWithChildren: IItem[],
|
itemWithChildren: IItem[],
|
||||||
isPreset: boolean,
|
isPreset: boolean,
|
||||||
itemDetails: [boolean, ITemplateItem],
|
itemToSellDetails: ITemplateItem,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
// Set stack size to random value
|
// Set stack size to random value
|
||||||
itemWithChildren[0].upd.StackObjectsCount = this.ragfairServerHelper.calculateDynamicStackCount(
|
itemWithChildren[0].upd.StackObjectsCount = this.ragfairServerHelper.calculateDynamicStackCount(
|
||||||
@ -472,8 +476,6 @@ export class RagfairOfferGenerator {
|
|||||||
this.ragfairConfig.dynamic.pack.itemTypeWhitelist,
|
this.ragfairConfig.dynamic.pack.itemTypeWhitelist,
|
||||||
);
|
);
|
||||||
|
|
||||||
const randomUserId = this.hashUtil.generate();
|
|
||||||
|
|
||||||
// Remove removable plates if % check passes
|
// Remove removable plates if % check passes
|
||||||
if (this.itemHelper.armorItemCanHoldMods(itemWithChildren[0]._tpl)) {
|
if (this.itemHelper.armorItemCanHoldMods(itemWithChildren[0]._tpl)) {
|
||||||
const armorConfig = this.ragfairConfig.dynamic.armor;
|
const armorConfig = this.ragfairConfig.dynamic.armor;
|
||||||
@ -503,19 +505,19 @@ export class RagfairOfferGenerator {
|
|||||||
barterScheme = this.createCurrencyBarterScheme(itemWithChildren, isPackOffer, stackSize);
|
barterScheme = this.createCurrencyBarterScheme(itemWithChildren, isPackOffer, stackSize);
|
||||||
} else if (isBarterOffer) {
|
} else if (isBarterOffer) {
|
||||||
// Apply randomised properties
|
// Apply randomised properties
|
||||||
this.randomiseOfferItemUpdProperties(randomUserId, itemWithChildren, itemDetails[1]);
|
this.randomiseOfferItemUpdProperties(sellerId, itemWithChildren, itemToSellDetails);
|
||||||
barterScheme = this.createBarterBarterScheme(itemWithChildren, this.ragfairConfig.dynamic.barter);
|
barterScheme = this.createBarterBarterScheme(itemWithChildren, this.ragfairConfig.dynamic.barter);
|
||||||
if (this.ragfairConfig.dynamic.barter.makeSingleStackOnly) {
|
if (this.ragfairConfig.dynamic.barter.makeSingleStackOnly) {
|
||||||
itemWithChildren[0].upd.StackObjectsCount = 1;
|
itemWithChildren[0].upd.StackObjectsCount = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Apply randomised properties
|
// Apply randomised properties
|
||||||
this.randomiseOfferItemUpdProperties(randomUserId, itemWithChildren, itemDetails[1]);
|
this.randomiseOfferItemUpdProperties(sellerId, itemWithChildren, itemToSellDetails);
|
||||||
barterScheme = this.createCurrencyBarterScheme(itemWithChildren, isPackOffer);
|
barterScheme = this.createCurrencyBarterScheme(itemWithChildren, isPackOffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
const offer = this.createAndAddFleaOffer(
|
const offer = this.createAndAddFleaOffer(
|
||||||
randomUserId,
|
sellerId,
|
||||||
this.timeUtil.getTimestamp(),
|
this.timeUtil.getTimestamp(),
|
||||||
itemWithChildren,
|
itemWithChildren,
|
||||||
barterScheme,
|
barterScheme,
|
||||||
|
Loading…
Reference in New Issue
Block a user