This commit is contained in:
Dev 2023-08-12 11:41:50 +01:00
parent 0001d202d0
commit 8a8546052a
5 changed files with 25 additions and 6 deletions

View File

@ -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<object> InsuredItems { get; set; }
public Hideout Hideout { get; set; }
public List<object> Bonuses { get; set; }
public IEnumerable<object> Bonuses { get; set; }
}
public class Root
{
public int err { get; set; }
public object errmsg { get; set; }
public List<Datum> data { get; set; }
public IEnumerable<Datum> data { get; set; }
}

View File

@ -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<Datum> 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<Datum> ParseJson(string json)
private static IEnumerable<Datum> ParseJson(string json)
{
var deSerialisedObject = JsonSerializer.Deserialize<Root>(json, serialiserOptions);
return deSerialisedObject.data;

View File

@ -296,6 +296,7 @@
"5fc64ea372b0dd78d51159dc": 7,
"601948682627df266209af05": 1
}
}
},
"Ammo": {}
}
}

View File

@ -181,4 +181,16 @@
</Page>
</ItemGroup>
<ItemGroup>
<None Update="Assets\normal_bossBoarSniper_BotGlobalSettings.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Assets\normal_bossBoar_BotGlobalSettings.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Assets\normal_followerBoar_BotGlobalSettings.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -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))
{