Merge branch 'develop' into just-oblivion-memes

This commit is contained in:
CWX
2025-05-28 20:41:54 +01:00
committed by GitHub
5 changed files with 19 additions and 21 deletions
@@ -167,8 +167,9 @@ public class RagfairOfferHelper(
/// <returns>Matching RagfairOffer objects</returns>
public List<RagfairOffer> GetOffersThatRequireItem(SearchRequestData searchRequest, PmcData pmcData)
{
// Get all offers that require the desired item and filter out offers from non traders if player below ragifar unlock
// Get all offers that require the desired item and filter out offers from non traders if player below ragfair unlock
var requiredOffers = _ragfairRequiredItemsService.GetRequiredItemsById(searchRequest.NeededSearchId);
var tieredFlea = _ragfairConfig.TieredFlea;
var tieredFleaLimitTypes = tieredFlea.UnlocksType;
return requiredOffers.Where(offer =>
@@ -36,8 +36,12 @@ public class RagfairCategoriesService(
return false;
}
// Skip items not for currency when `removeBartering` is enabled
// Skip when:
// Not a 'required' search
// Remove barters checkbox checked
// Offer requirement has children or requirement is not money
if (
string.IsNullOrEmpty(searchRequestData.NeededSearchId) &&
searchRequestData.RemoveBartering.GetValueOrDefault(false) &&
(offer.Requirements.Count > 1 || !_paymentHelper.IsMoneyTpl(offer.Requirements.FirstOrDefault().Template))
)
@@ -110,17 +110,6 @@ public class RagfairLinkedItemService(
}
}
protected void ApplyLinkedItems(HashSet<string> items, TemplateItem item, ref HashSet<string> itemLinkedSet)
{
itemLinkedSet.UnionWith(items);
foreach (var linkedItemId in items)
{
GetLinkedItems(linkedItemId).Add(item.Id);
}
}
/// <summary>
/// Add ammo to revolvers linked item dictionary
/// </summary>
@@ -12,11 +12,14 @@ public class RagfairRequiredItemsService(
{
protected ConcurrentDictionary<string, List<RagfairOffer>> _requiredItemsCache = new();
public List<RagfairOffer>? GetRequiredItemsById(string searchId)
public List<RagfairOffer> GetRequiredItemsById(string searchId)
{
_requiredItemsCache.TryGetValue(searchId, out var list);
if (_requiredItemsCache.TryGetValue(searchId, out var list))
{
return list;
}
return list;
return [];
}
public void BuildRequiredItemTable()
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization;
@@ -19,15 +20,15 @@ public class StringToNumberFactoryConverter : JsonConverterFactory
private class StringToNumberConverter<T> : JsonConverter<T>
{
private static readonly MethodInfo? stringParseMethod;
private static readonly MethodInfo? _stringParseMethod;
static StringToNumberConverter()
{
// Do reflection only once to get parse
if (stringParseMethod == null)
if (_stringParseMethod == null)
{
var underlyingType = Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T);
stringParseMethod = underlyingType.GetMethod("Parse", [typeof(string)]);
_stringParseMethod = underlyingType.GetMethod("Parse", [typeof(string), typeof(IFormatProvider)]);
}
}
@@ -46,9 +47,9 @@ public class StringToNumberFactoryConverter : JsonConverterFactory
{
var underlyingType = Nullable.GetUnderlyingType(typeToConvert) ?? typeToConvert;
if (stringParseMethod != null)
if (_stringParseMethod != null)
{
return (T) stringParseMethod.Invoke(null, [value]);
return (T) _stringParseMethod.Invoke(null, [value, CultureInfo.CreateSpecificCulture("en-US")]);
}
}
catch (Exception ex)