FenseService

This commit is contained in:
Alex
2025-01-24 12:16:17 +00:00
parent 7aba4b1575
commit 3eaf6887a1
5 changed files with 1252 additions and 337 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ public class TradeHelper(
)
{
List<Item> offerItems = [];
Action<double>? buyCallback;
Action<int>? buyCallback;
if (buyRequestData.TransactionId.ToLower() == "ragfair")
{
@@ -16,7 +16,7 @@ public record AddItemsDirectRequest
/// Runs after EACH item with children is added
[JsonPropertyName("callback")]
public Action<double>? Callback { get; set; }
public Action<int>? Callback { get; set; }
/// Should sorting table be used when no space found in stash
[JsonPropertyName("useSortingTable")]
@@ -83,7 +83,7 @@ public record FenceConfig
/** Key: item tpl */
[JsonPropertyName("itemStackSizeOverrideMinMax")]
public Dictionary<string, MinMax> ItemStackSizeOverrideMinMax { get; set; }
public Dictionary<string, MinMax?> ItemStackSizeOverrideMinMax { get; set; }
[JsonPropertyName("itemTypeLimits")]
public Dictionary<string, int> ItemTypeLimits { get; set; }
@@ -97,11 +97,11 @@ public record FenceConfig
/** Max rouble price before item is not listed on flea */
[JsonPropertyName("itemCategoryRoublePriceLimit")]
public Dictionary<string, double> ItemCategoryRoublePriceLimit { get; set; }
public Dictionary<string, double?> ItemCategoryRoublePriceLimit { get; set; }
/** Each slotid with % to be removed prior to listing on fence */
[JsonPropertyName("presetSlotsToRemoveChancePercent")]
public Dictionary<string, double> PresetSlotsToRemoveChancePercent { get; set; }
public Dictionary<string, double?> PresetSlotsToRemoveChancePercent { get; set; }
/** Block seasonal items from appearing when season is inactive */
[JsonPropertyName("blacklistSeasonalItems")]
File diff suppressed because it is too large Load Diff
+9 -2
View File
@@ -468,9 +468,16 @@ public class RandomUtil(ISptLogger<RandomUtil> _logger, ICloner _cloner)
: 0;
}
public T GetArrayValue<T>(IEnumerable<T> list)
public T? GetArrayValue<T>(IEnumerable<T> list)
{
var rand = new Random();
return list.ElementAt(rand.Next(0, list.Count()));
try
{
return list.ElementAt(rand.Next(0, list.Count()));
}
catch (Exception)
{
return default;
}
}
}