Improved stale offer processing
Pass offer creation info into methods for quicker checking Removed unused methods
This commit is contained in:
@@ -277,32 +277,6 @@ public class RagfairOfferGenerator(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Is the offers user rating growing
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="userID"> User to check rating of</param>
|
|
||||||
/// <returns> True if growing </returns>
|
|
||||||
protected bool GetRatingGrowing(MongoId userID)
|
|
||||||
{
|
|
||||||
if (profileHelper.IsPlayer(userID))
|
|
||||||
// player offer
|
|
||||||
{
|
|
||||||
return saveServer
|
|
||||||
.GetProfile(userID)
|
|
||||||
.CharacterData?.PmcData?.RagfairInfo?.IsRatingGrowing ?? false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ragfairServerHelper.IsTrader(userID))
|
|
||||||
// trader offer
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// generated offer
|
|
||||||
// 50/50 growing/falling
|
|
||||||
return randomUtil.GetBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get number of section until offer should expire
|
/// Get number of section until offer should expire
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -438,7 +412,8 @@ public class RagfairOfferGenerator(
|
|||||||
clonedAssort,
|
clonedAssort,
|
||||||
isPreset,
|
isPreset,
|
||||||
itemToSellDetails.Value,
|
itemToSellDetails.Value,
|
||||||
isExpiredOffer
|
isExpiredOffer,
|
||||||
|
OfferCreator.FakePlayer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -499,12 +474,14 @@ public class RagfairOfferGenerator(
|
|||||||
/// <param name="isPreset"> Is item a weapon preset</param>
|
/// <param name="isPreset"> Is item a weapon preset</param>
|
||||||
/// <param name="itemToSellDetails"> Raw DB item details </param>
|
/// <param name="itemToSellDetails"> Raw DB item details </param>
|
||||||
/// <param name="isExpiredOffer">Offer being created is to replace an expired, existing offer</param>
|
/// <param name="isExpiredOffer">Offer being created is to replace an expired, existing offer</param>
|
||||||
|
/// <param name="offerCreator">What type of entity created this offer</param>
|
||||||
protected void CreateSingleOfferForItem(
|
protected void CreateSingleOfferForItem(
|
||||||
MongoId sellerId,
|
MongoId sellerId,
|
||||||
List<Item> itemWithChildren,
|
List<Item> itemWithChildren,
|
||||||
bool isPreset,
|
bool isPreset,
|
||||||
TemplateItem itemToSellDetails,
|
TemplateItem itemToSellDetails,
|
||||||
bool isExpiredOffer
|
bool isExpiredOffer,
|
||||||
|
OfferCreator offerCreator
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var rootItem = itemWithChildren.FirstOrDefault();
|
var rootItem = itemWithChildren.FirstOrDefault();
|
||||||
@@ -553,7 +530,12 @@ public class RagfairOfferGenerator(
|
|||||||
else if (isBarterOffer)
|
else if (isBarterOffer)
|
||||||
{
|
{
|
||||||
// Apply randomised properties
|
// Apply randomised properties
|
||||||
RandomiseOfferItemUpdProperties(sellerId, itemWithChildren, itemToSellDetails);
|
RandomiseOfferItemUpdProperties(
|
||||||
|
sellerId,
|
||||||
|
itemWithChildren,
|
||||||
|
itemToSellDetails,
|
||||||
|
offerCreator
|
||||||
|
);
|
||||||
barterScheme = CreateBarterBarterScheme(itemWithChildren, ragfairConfig.Dynamic.Barter);
|
barterScheme = CreateBarterBarterScheme(itemWithChildren, ragfairConfig.Dynamic.Barter);
|
||||||
if (ragfairConfig.Dynamic.Barter.MakeSingleStackOnly)
|
if (ragfairConfig.Dynamic.Barter.MakeSingleStackOnly)
|
||||||
{
|
{
|
||||||
@@ -568,7 +550,12 @@ public class RagfairOfferGenerator(
|
|||||||
{
|
{
|
||||||
// Not barter or pack offer
|
// Not barter or pack offer
|
||||||
// Apply randomised properties
|
// Apply randomised properties
|
||||||
RandomiseOfferItemUpdProperties(sellerId, itemWithChildren, itemToSellDetails);
|
RandomiseOfferItemUpdProperties(
|
||||||
|
sellerId,
|
||||||
|
itemWithChildren,
|
||||||
|
itemToSellDetails,
|
||||||
|
offerCreator
|
||||||
|
);
|
||||||
barterScheme = CreateCurrencyBarterScheme(itemWithChildren, isPackOffer);
|
barterScheme = CreateCurrencyBarterScheme(itemWithChildren, isPackOffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,7 +567,7 @@ public class RagfairOfferGenerator(
|
|||||||
BarterScheme = barterScheme,
|
BarterScheme = barterScheme,
|
||||||
LoyalLevel = 1,
|
LoyalLevel = 1,
|
||||||
Quantity = desiredStackSize,
|
Quantity = desiredStackSize,
|
||||||
Creator = OfferCreator.FakePlayer,
|
Creator = offerCreator,
|
||||||
SellInOnePiece = isPackOffer, // sellAsOnePiece - pack offer
|
SellInOnePiece = isPackOffer, // sellAsOnePiece - pack offer
|
||||||
};
|
};
|
||||||
CreateAndAddFleaOffer(createOfferDetails);
|
CreateAndAddFleaOffer(createOfferDetails);
|
||||||
@@ -723,16 +710,18 @@ public class RagfairOfferGenerator(
|
|||||||
/// <param name="userID"> ID of owner of item </param>
|
/// <param name="userID"> ID of owner of item </param>
|
||||||
/// <param name="itemWithMods"> Item and mods, get condition of first item (only first array item is modified) </param>
|
/// <param name="itemWithMods"> Item and mods, get condition of first item (only first array item is modified) </param>
|
||||||
/// <param name="itemDetails"> DB details of first item</param>
|
/// <param name="itemDetails"> DB details of first item</param>
|
||||||
|
/// <param name="offerCreator"></param>
|
||||||
protected void RandomiseOfferItemUpdProperties(
|
protected void RandomiseOfferItemUpdProperties(
|
||||||
MongoId userID,
|
MongoId userID,
|
||||||
IEnumerable<Item> itemWithMods,
|
IEnumerable<Item> itemWithMods,
|
||||||
TemplateItem itemDetails
|
TemplateItem itemDetails,
|
||||||
|
OfferCreator offerCreator
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Add any missing properties to first item in array
|
// Add any missing properties to first item in array
|
||||||
AddMissingConditions(itemWithMods.First());
|
AddMissingConditions(itemWithMods.First());
|
||||||
|
|
||||||
if (!(profileHelper.IsPlayer(userID) || ragfairServerHelper.IsTrader(userID)))
|
if (offerCreator is OfferCreator.FakePlayer)
|
||||||
{
|
{
|
||||||
var parentId = GetDynamicConditionIdForTpl(itemDetails.Id);
|
var parentId = GetDynamicConditionIdForTpl(itemDetails.Id);
|
||||||
if (parentId == null)
|
if (parentId == null)
|
||||||
|
|||||||
@@ -201,9 +201,7 @@ public class RagfairOfferService(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle dynamic offer from PMCs
|
// Handle dynamic offer from PMCs
|
||||||
var isPlayer = profileHelper.IsPlayer(
|
var isPlayer = staleOffer.CreatedBy == OfferCreator.Player;
|
||||||
staleOffer.User.Id.ToString().RegexReplace("^pmc", "")
|
|
||||||
);
|
|
||||||
if (flagOfferAsExpired && !isPlayer)
|
if (flagOfferAsExpired && !isPlayer)
|
||||||
{
|
{
|
||||||
// Not trader or a player offer
|
// Not trader or a player offer
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ public class RagfairOfferHolder(
|
|||||||
/// Add a stale offers id to _expiredOfferIds collection for later processing
|
/// Add a stale offers id to _expiredOfferIds collection for later processing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="staleOfferId">Id of offer to add to stale collection</param>
|
/// <param name="staleOfferId">Id of offer to add to stale collection</param>
|
||||||
public void FlagOfferAsExpired(string staleOfferId)
|
public void FlagOfferAsExpired(MongoId staleOfferId)
|
||||||
{
|
{
|
||||||
lock (_expiredOfferIdsLock)
|
lock (_expiredOfferIdsLock)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user