Added RagfairOfferExtensions

This commit is contained in:
Chomp
2025-06-28 16:45:58 +01:00
parent 7782806f91
commit f9d1c81437
2 changed files with 20 additions and 12 deletions
@@ -0,0 +1,18 @@
using SPTarkov.Server.Core.Models.Eft.Ragfair;
namespace SPTarkov.Server.Core.Extensions
{
public static class RagfairOfferExtensions
{
/// <summary>
/// Is the passed in offer stale - end time > passed in time
/// </summary>
/// <param name="offer">Offer to check</param>
/// <param name="time">Time to check offer against</param>
/// <returns>True - offer is stale</returns>
public static bool IsStale(this RagfairOffer offer, long time)
{
return offer.EndTime < time || (offer.Quantity ?? 0) < 1;
}
}
}
@@ -1,5 +1,6 @@
using System.Collections.Concurrent;
using SPTarkov.DI.Annotations;
using SPTarkov.Server.Core.Extensions;
using SPTarkov.Server.Core.Helpers;
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
using SPTarkov.Server.Core.Models.Eft.Ragfair;
@@ -292,17 +293,6 @@ public class RagfairOfferHolder(
return false;
}
/// <summary>
/// Is the passed in offer stale - end time > passed in time
/// </summary>
/// <param name="offer">Offer to check</param>
/// <param name="time">Time to check offer against</param>
/// <returns>True - offer is stale</returns>
protected bool IsStale(RagfairOffer offer, long time)
{
return offer.EndTime < time || (offer.Quantity ?? 0) < 1;
}
/// <summary>
/// Add a stale offers id to _expiredOfferIds collection for later processing
/// </summary>
@@ -394,7 +384,7 @@ public class RagfairOfferHolder(
continue;
}
if (IsStale(offer, timestamp))
if (offer.IsStale(timestamp))
{
if (!_expiredOfferIds.Add(offer.Id))
{