Fixed flea-banned players being able to buy pmc items from flea

This commit is contained in:
Dev 2024-06-03 22:35:09 +01:00
parent 307822f647
commit ba8829681d
2 changed files with 20 additions and 4 deletions

View File

@ -1,7 +1,7 @@
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import { ItemHelper } from "@spt/helpers/ItemHelper"; import { ItemHelper } from "@spt/helpers/ItemHelper";
import { IPmcData } from "@spt/models/eft/common/IPmcData"; import { IPmcData } from "@spt/models/eft/common/IPmcData";
import { Common, CounterKeyValue, Stats } from "@spt/models/eft/common/tables/IBotBase"; import { BanType, Common, CounterKeyValue, Stats } from "@spt/models/eft/common/tables/IBotBase";
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile"; import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData"; import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
import { AccountTypes } from "@spt/models/enums/AccountTypes"; import { AccountTypes } from "@spt/models/enums/AccountTypes";
@ -550,4 +550,11 @@ export class ProfileHelper
existingBonus.value += rowsToAdd; existingBonus.value += rowsToAdd;
} }
} }
public playerIsFleaBanned(pmcProfile: IPmcData): boolean
{
const currentTimestamp = this.timeUtil.getTimestamp();
return pmcProfile.Info.Bans
.some((ban) => ban.banType === BanType.RAGFAIR && currentTimestamp < ban.dateTime);
}
} }

View File

@ -87,6 +87,7 @@ export class RagfairOfferHelper
pmcData: IPmcData, pmcData: IPmcData,
): IRagfairOffer[] ): IRagfairOffer[]
{ {
const playerIsFleaBanned = this.profileHelper.playerIsFleaBanned(pmcData);
return this.ragfairOfferService.getOffers().filter((offer) => return this.ragfairOfferService.getOffers().filter((offer) =>
{ {
if (!this.passesSearchFilterCriteria(searchRequest, offer, pmcData)) if (!this.passesSearchFilterCriteria(searchRequest, offer, pmcData))
@ -94,7 +95,7 @@ export class RagfairOfferHelper
return false; return false;
} }
return this.isDisplayableOffer(searchRequest, itemsToAdd, traderAssorts, offer, pmcData); return this.isDisplayableOffer(searchRequest, itemsToAdd, traderAssorts, offer, pmcData, playerIsFleaBanned);
}); });
} }
@ -136,6 +137,7 @@ export class RagfairOfferHelper
{ {
const offersMap = new Map<string, IRagfairOffer[]>(); const offersMap = new Map<string, IRagfairOffer[]>();
const offers: IRagfairOffer[] = []; const offers: IRagfairOffer[] = [];
const playerIsFleaBanned = this.profileHelper.playerIsFleaBanned(pmcData);
for (const offer of this.ragfairOfferService.getOffers()) for (const offer of this.ragfairOfferService.getOffers())
{ {
if (!this.passesSearchFilterCriteria(searchRequest, offer, pmcData)) if (!this.passesSearchFilterCriteria(searchRequest, offer, pmcData))
@ -143,7 +145,7 @@ export class RagfairOfferHelper
continue; continue;
} }
if (this.isDisplayableOffer(searchRequest, itemsToAdd, traderAssorts, offer, pmcData)) if (this.isDisplayableOffer(searchRequest, itemsToAdd, traderAssorts, offer, pmcData, playerIsFleaBanned))
{ {
const isTraderOffer = offer.user.memberType === MemberCategory.TRADER; const isTraderOffer = offer.user.memberType === MemberCategory.TRADER;
@ -715,11 +717,18 @@ export class RagfairOfferHelper
traderAssorts: Record<string, ITraderAssort>, traderAssorts: Record<string, ITraderAssort>,
offer: IRagfairOffer, offer: IRagfairOffer,
pmcProfile: IPmcData, pmcProfile: IPmcData,
playerIsFleaBanned?: boolean,
): boolean ): boolean
{ {
const offerRootItem = offer.items[0]; const offerRootItem = offer.items[0];
/** Currency offer is sold for */ /** Currency offer is sold for */
const moneyTypeTpl = offer.requirements[0]._tpl; const moneyTypeTpl = offer.requirements[0]._tpl;
const isTraderOffer = offer.user.id in this.databaseService.getTraders();
if (!isTraderOffer && playerIsFleaBanned)
{
return false;
}
// Offer root items tpl not in searched for array // Offer root items tpl not in searched for array
if (!itemsToAdd?.includes(offerRootItem._tpl)) if (!itemsToAdd?.includes(offerRootItem._tpl))
@ -764,7 +773,7 @@ export class RagfairOfferHelper
// Handle trader items to remove items that are not available to the user right now // Handle trader items to remove items that are not available to the user right now
// required search for "lamp" shows 4 items, 3 of which are not available to a new player // required search for "lamp" shows 4 items, 3 of which are not available to a new player
// filter those out // filter those out
if (offer.user.id in this.databaseService.getTraders()) if (isTraderOffer)
{ {
if (!(offer.user.id in traderAssorts)) if (!(offer.user.id in traderAssorts))
{ {