Improved how ragfair offer creator status is checked - store creator type in offer
Converted `IsTraderOffer` into extension method string to mongoid conversions
This commit is contained in:
@@ -127,7 +127,7 @@ public class RagfairController(
|
||||
}
|
||||
|
||||
// Update trader offers' values, Lock quest-linked offers + adjust offer buy limits
|
||||
foreach (var traderOffer in result.Offers.Where(ragfairOfferHelper.OfferIsFromTrader))
|
||||
foreach (var traderOffer in result.Offers.Where(x => x.IsTraderOffer()))
|
||||
{
|
||||
// For the items, check the barter schemes. The method getDisplayableAssorts sets a flag sptQuestLocked
|
||||
// to true if the quest is not completed yet
|
||||
@@ -427,7 +427,7 @@ public class RagfairController(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ignoreTraderOffers && ragfairOfferHelper.OfferIsFromTrader(offer))
|
||||
if (ignoreTraderOffers && offer.IsTraderOffer())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -1020,8 +1020,8 @@ public class RagfairController(
|
||||
formattedRequirements.ToList(),
|
||||
loyalLevel,
|
||||
(int?)items.FirstOrDefault()?.Upd?.StackObjectsCount ?? 1,
|
||||
sellInOnePiece,
|
||||
true
|
||||
OfferCreator.Player,
|
||||
sellInOnePiece
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ public class TradeController(
|
||||
);
|
||||
}
|
||||
|
||||
if (ragfairOfferHelper.OfferIsFromTrader(fleaOffer))
|
||||
if (fleaOffer.IsTraderOffer())
|
||||
{
|
||||
BuyTraderItemFromRagfair(sessionID, pmcData, fleaOffer, offer, output);
|
||||
}
|
||||
@@ -244,7 +244,7 @@ public class TradeController(
|
||||
var offerOwnerId = fleaOffer.User.Id;
|
||||
var offerBuyCount = requestOffer.Count;
|
||||
|
||||
if (IsPlayerOffer(fleaOffer.Id, fleaOffer.User?.Id))
|
||||
if (fleaOffer.IsPlayerOffer())
|
||||
{
|
||||
// Complete selling the offer now it has been purchased
|
||||
ragfairOfferHelper.CompleteOffer(offerOwnerId, fleaOffer, offerBuyCount ?? 0);
|
||||
@@ -256,31 +256,6 @@ public class TradeController(
|
||||
ragfairServer.ReduceOfferQuantity(fleaOffer.Id, requestOffer.Count ?? 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is the provided offerId and ownerId from a player made offer
|
||||
/// </summary>
|
||||
/// <param name="offerId">id of the offer</param>
|
||||
/// <param name="offerOwnerId">Owner id</param>
|
||||
/// <returns>true if offer was made by a player</returns>
|
||||
protected bool IsPlayerOffer(string offerId, MongoId? offerOwnerId)
|
||||
{
|
||||
// No ownerId, not player offer
|
||||
if (offerOwnerId is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var offerCreatorProfile = profileHelper.GetPmcProfile(offerOwnerId.Value);
|
||||
if (offerCreatorProfile is null || offerCreatorProfile.RagfairInfo.Offers?.Count == 0)
|
||||
// No profile or no offers
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Does offer id exist in profile
|
||||
return offerCreatorProfile.RagfairInfo.Offers.Any(offer => offer.Id == offerId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does Player have necessary trader loyalty to purchase flea offer
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user