Dont add bot types we're not interested in

This commit is contained in:
Chomp 2023-02-01 10:35:27 +00:00
parent c580c0dec7
commit 9110fabfcf
2 changed files with 8 additions and 2 deletions

View File

@ -13,7 +13,7 @@ public static class BotParser
{ {
static JsonSerializerOptions serialiserOptions = new JsonSerializerOptions { }; static JsonSerializerOptions serialiserOptions = new JsonSerializerOptions { };
public static async Task<List<Datum>> ParseAsync(string dumpPath) public static async Task<List<Datum>> ParseAsync(string dumpPath, string[] botTypes)
{ {
var stopwatch = Stopwatch.StartNew(); var stopwatch = Stopwatch.StartNew();
@ -63,12 +63,18 @@ public static class BotParser
Console.WriteLine($"parsing: {bots.Count} bots in file {splitFilePath.Last()}"); Console.WriteLine($"parsing: {bots.Count} bots in file {splitFilePath.Last()}");
foreach (var bot in bots) foreach (var bot in bots)
{ {
if (!botTypes.Contains(bot.Info.Settings.Role.ToLower()))
{
continue;
}
if (!parsedBotsDict.ContainsKey(bot._id)) if (!parsedBotsDict.ContainsKey(bot._id))
{ {
parsedBotsDict.Add(bot._id, bot); parsedBotsDict.Add(bot._id, bot);
} }
else else
{ {
var existingBot = parsedBotsDict[bot._id];
dupeCount++; dupeCount++;
} }
} }

View File

@ -40,7 +40,7 @@ internal static class Program
// Read raw bot dumps and turn into c# objects // Read raw bot dumps and turn into c# objects
var workingPath = Directory.GetCurrentDirectory(); var workingPath = Directory.GetCurrentDirectory();
var dumpPath = $"{workingPath}//dumps"; var dumpPath = $"{workingPath}//dumps";
var parsedBots = await BotParser.ParseAsync(dumpPath); var parsedBots = await BotParser.ParseAsync(dumpPath, botTypes);
if (parsedBots.Count == 0) if (parsedBots.Count == 0)
{ {