From 8a8546052aa4119ad9dfbc8933b6133a1ac0f72f Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 12 Aug 2023 11:41:50 +0100 Subject: [PATCH] Update --- Common.Models/Input/Settings.cs | 5 +++-- Common/Bot/BotParser.cs | 7 ++++--- Generator/Assets/weights.json | 3 ++- Generator/Generator.csproj | 12 ++++++++++++ Generator/Weighting/WeightingService.cs | 4 ++++ 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Common.Models/Input/Settings.cs b/Common.Models/Input/Settings.cs index 6201173..3e00003 100644 --- a/Common.Models/Input/Settings.cs +++ b/Common.Models/Input/Settings.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Runtime.Serialization; @@ -287,14 +288,14 @@ namespace Common.Models.Input public BackendCounters BackendCounters { get; set; } public List InsuredItems { get; set; } public Hideout Hideout { get; set; } - public List Bonuses { get; set; } + public IEnumerable Bonuses { get; set; } } public class Root { public int err { get; set; } public object errmsg { get; set; } - public List data { get; set; } + public IEnumerable data { get; set; } } diff --git a/Common/Bot/BotParser.cs b/Common/Bot/BotParser.cs index ee3b1aa..2b0c4a3 100644 --- a/Common/Bot/BotParser.cs +++ b/Common/Bot/BotParser.cs @@ -1,5 +1,6 @@ using Common.Models.Input; using Newtonsoft.Json.Linq; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -27,7 +28,7 @@ public static class BotParser ParallelOptions parallelOptions = new() { - MaxDegreeOfParallelism = Environment.ProcessorCount + MaxDegreeOfParallelism = 1 }; await Parallel.ForEachAsync(botFiles, parallelOptions, async (file, token) => { @@ -45,7 +46,7 @@ public static class BotParser List bots = null; try { - bots = ParseJson(rawInputString); + bots = ParseJson(rawInputString).ToList(); } catch (Exception ex) { @@ -124,7 +125,7 @@ public static class BotParser return returnString; } - private static List ParseJson(string json) + private static IEnumerable ParseJson(string json) { var deSerialisedObject = JsonSerializer.Deserialize(json, serialiserOptions); return deSerialisedObject.data; diff --git a/Generator/Assets/weights.json b/Generator/Assets/weights.json index 758d6d5..66f63f5 100644 --- a/Generator/Assets/weights.json +++ b/Generator/Assets/weights.json @@ -296,6 +296,7 @@ "5fc64ea372b0dd78d51159dc": 7, "601948682627df266209af05": 1 } - } + }, + "Ammo": {} } } diff --git a/Generator/Generator.csproj b/Generator/Generator.csproj index 26596bd..ef66d31 100644 --- a/Generator/Generator.csproj +++ b/Generator/Generator.csproj @@ -181,4 +181,16 @@ + + + Always + + + Always + + + Always + + + diff --git a/Generator/Weighting/WeightingService.cs b/Generator/Weighting/WeightingService.cs index ec5e32f..8b312ce 100644 --- a/Generator/Weighting/WeightingService.cs +++ b/Generator/Weighting/WeightingService.cs @@ -38,6 +38,10 @@ namespace Generator.Weighting if (_weights.ContainsKey(botType)) { var botWeights = _weights[botType]; + if (botWeights.Ammo == null) + { + return 1; + } if (botWeights.Ammo.ContainsKey(caliber)) {