ragfair-safety-net (!318)
Co-authored-by: clodan <clodan@clodan.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/318 Co-authored-by: Alex <clodan@noreply.dev.sp-tarkov.com> Co-committed-by: Alex <clodan@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
2ba5358f39
commit
bccda0302f
@ -25,7 +25,7 @@ export class RagfairOfferService
|
|||||||
protected expiredOffers: Record<string, IRagfairOffer> = {};
|
protected expiredOffers: Record<string, IRagfairOffer> = {};
|
||||||
|
|
||||||
protected ragfairConfig: IRagfairConfig;
|
protected ragfairConfig: IRagfairConfig;
|
||||||
protected ragfairOfferHandler: RagfairOfferHolder = new RagfairOfferHolder();
|
protected ragfairOfferHandler: RagfairOfferHolder;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@inject("WinstonLogger") protected logger: ILogger,
|
@inject("WinstonLogger") protected logger: ILogger,
|
||||||
@ -41,6 +41,10 @@ export class RagfairOfferService
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.ragfairConfig = this.configServer.getConfig(ConfigTypes.RAGFAIR);
|
this.ragfairConfig = this.configServer.getConfig(ConfigTypes.RAGFAIR);
|
||||||
|
this.ragfairOfferHandler = new RagfairOfferHolder(
|
||||||
|
this.ragfairConfig.dynamic.offerItemCount.max,
|
||||||
|
ragfairServerHelper,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { RagfairServerHelper } from "@spt-aki/helpers/RagfairServerHelper";
|
||||||
import { IRagfairOffer } from "@spt-aki/models/eft/ragfair/IRagfairOffer";
|
import { IRagfairOffer } from "@spt-aki/models/eft/ragfair/IRagfairOffer";
|
||||||
|
|
||||||
export class RagfairOfferHolder
|
export class RagfairOfferHolder
|
||||||
@ -6,7 +7,7 @@ export class RagfairOfferHolder
|
|||||||
protected offersByTemplate: Map<string, Map<string, IRagfairOffer>>;
|
protected offersByTemplate: Map<string, Map<string, IRagfairOffer>>;
|
||||||
protected offersByTrader: Map<string, Map<string, IRagfairOffer>>;
|
protected offersByTrader: Map<string, Map<string, IRagfairOffer>>;
|
||||||
|
|
||||||
constructor()
|
constructor(protected maxOffersPerTemplate: number, protected ragfairServerHelper: RagfairServerHelper)
|
||||||
{
|
{
|
||||||
this.offersById = new Map();
|
this.offersById = new Map();
|
||||||
this.offersByTemplate = new Map();
|
this.offersByTemplate = new Map();
|
||||||
@ -62,6 +63,15 @@ export class RagfairOfferHolder
|
|||||||
const trader = offer.user.id;
|
const trader = offer.user.id;
|
||||||
const offerId = offer._id;
|
const offerId = offer._id;
|
||||||
const itemTpl = offer.items[0]._tpl;
|
const itemTpl = offer.items[0]._tpl;
|
||||||
|
// If its an NPC PMC offer AND we have already reached the maximum amount of possible offers
|
||||||
|
// for this template, just dont add in more
|
||||||
|
if (
|
||||||
|
!(this.ragfairServerHelper.isTrader(trader) || this.ragfairServerHelper.isPlayer(trader))
|
||||||
|
&& this.getOffersByTemplate(itemTpl)?.length >= this.maxOffersPerTemplate
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.offersById.set(offerId, offer);
|
this.offersById.set(offerId, offer);
|
||||||
this.addOfferByTrader(trader, offer);
|
this.addOfferByTrader(trader, offer);
|
||||||
this.addOfferByTemplates(itemTpl, offer);
|
this.addOfferByTemplates(itemTpl, offer);
|
||||||
|
Loading…
Reference in New Issue
Block a user