Files
SPT-Server-Build/Libraries/Core/Services/RagfairOfferService.cs
T
2025-01-23 14:57:41 +00:00

170 lines
4.9 KiB
C#

using Core.Helpers;
using SptCommon.Annotations;
using Core.Models.Eft.Common.Tables;
using Core.Models.Eft.Ragfair;
using Core.Models.Utils;
using Core.Utils;
namespace Core.Services;
[Injectable(InjectionType.Singleton)]
public class RagfairOfferService(
ISptLogger<RagfairOfferService> _logger,
TimeUtil _timeUtil,
DatabaseService _databaseService,
RagfairOfferHelper _ragfairOfferHelper ,
RagfairOfferHolder _ragfairOfferHolder,
LocalisationService _localisationService)
{
/// <summary>
/// Get all offers
/// </summary>
/// <returns>List of RagfairOffer</returns>
public List<RagfairOffer> GetOffers()
{
throw new NotImplementedException();
}
public RagfairOffer? GetOfferByOfferId(string offerId)
{
throw new NotImplementedException();
}
public List<RagfairOffer> GetOffersOfType(string templateId)
{
throw new NotImplementedException();
}
public void AddOffer(RagfairOffer offer)
{
throw new NotImplementedException();
}
public void AddOfferToExpired(RagfairOffer staleOffer)
{
throw new NotImplementedException();
}
/// <summary>
/// Get total count of current expired offers
/// </summary>
/// <returns>Number of expired offers</returns>
public int GetExpiredOfferCount()
{
Console.WriteLine($"actually implement me plz: owo: GetExpiredOfferCount");
return 0;
}
/// <summary>
/// Get a list of lists of expired offer items + children
/// </summary>
/// <returns>Expired offer assorts</returns>
public List<List<Item>> GetExpiredOfferAssorts()
{
Console.WriteLine($"actually implement me plz: owo: GetExpiredOfferAssorts");
return new List<List<Item>>();
}
/// <summary>
/// Clear out internal expiredOffers dictionary of all items
/// </summary>
public void ResetExpiredOffers()
{
Console.WriteLine($"actually implement me plz: owo: ResetExpiredOffers");
}
/// <summary>
/// Does the offer exist on the ragfair
/// </summary>
/// <param name="offerId">offer id to check for</param>
/// <returns>offer exists - true</returns>
public bool DoesOfferExist(string offerId)
{
throw new NotImplementedException();
}
/// <summary>
/// Remove an offer from ragfair by offer id
/// </summary>
/// <param name="offerId">Offer id to remove</param>
public void RemoveOfferById(string offerId)
{
throw new NotImplementedException();
}
/// <summary>
/// Reduce size of an offer stack by specified amount
/// </summary>
/// <param name="offerId">Offer to adjust stack size of</param>
/// <param name="amount">How much to deduct from offers stack size</param>
public void RemoveOfferStack(string offerId, int amount)
{
throw new NotImplementedException();
}
public void RemoveAllOffersByTrader(string traderId)
{
throw new NotImplementedException();
}
/// <summary>
/// Do the trader offers on flea need to be refreshed
/// </summary>
/// <param name="traderId">Trader to check</param>
/// <returns>true if they do</returns>
public bool TraderOffersNeedRefreshing(string traderId)
{
var trader = _databaseService.GetTrader(traderId);
if (trader?.Base == null) {
_logger.Error(_localisationService.GetText("ragfair-trader_missing_base_file", traderId));
return false;
}
// No value, occurs when first run, trader offers need to be added to flea
trader.Base.RefreshTraderRagfairOffers ??= true;
return trader.Base.RefreshTraderRagfairOffers.GetValueOrDefault(false);
}
public void AddPlayerOffers()
{
Console.WriteLine($"actually implement me plz: owo: AddPlayerOffers");
// throw new NotImplementedException();
}
public void ExpireStaleOffers()
{
var time = _timeUtil.GetTimeStamp();
foreach (var staleOffer in _ragfairOfferHolder.GetStaleOffers(time)) {
ProcessStaleOffer(staleOffer);
}
}
/// <summary>
/// Remove stale offer from flea
/// </summary>
/// <param name="staleOffer">Stale offer to process</param>
protected void ProcessStaleOffer(RagfairOffer staleOffer)
{
throw new NotImplementedException();
}
protected void ReturnPlayerOffer(RagfairOffer playerOffer)
{
throw new NotImplementedException();
}
/// <summary>
/// Flea offer items are stacked up often beyond the StackMaxSize limit
/// Unstack the items into a list of root items and their children
/// Will create new items equal to the
/// </summary>
/// <param name="items">Offer items to unstack</param>
/// <returns>Unstacked list of items</returns>
protected List<Item> UnstackOfferItems(List<Item> items)
{
throw new NotImplementedException();
}
}