BotGenerator/Generator/BotGearGenerator.cs

44 lines
1.5 KiB
C#
Raw Normal View History

2021-08-24 12:08:30 +01:00
using Common;
using Common.Models.Input;
using Common.Models.Output;
using Generator.Helpers.Gear;
2021-08-12 16:52:06 +01:00
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace Generator
{
2021-09-01 19:19:44 +03:00
public static class BotGearGenerator
2021-08-12 16:52:06 +01:00
{
2021-09-05 12:27:17 +01:00
public static IEnumerable<Bot> AddGear(this IEnumerable<Bot> baseBots, IEnumerable<Datum> rawBots)
2021-08-12 16:52:06 +01:00
{
var stopwatch = Stopwatch.StartNew();
LoggingHelpers.LogToConsole("Started processing bot gear");
2021-09-01 19:19:44 +03:00
foreach (var botToUpdate in baseBots)
2021-08-12 16:52:06 +01:00
{
2021-09-05 12:27:17 +01:00
var rawParsedBotOfCurrentType = rawBots.Where(x => x.Info.Settings.Role.Equals(botToUpdate.botType.ToString(), StringComparison.OrdinalIgnoreCase))
.ToList();
2021-08-17 18:33:55 +01:00
if (rawParsedBotOfCurrentType.Count == 0)
{
continue;
2021-08-17 18:33:55 +01:00
}
foreach (var rawParsedBot in rawParsedBotOfCurrentType)
2021-08-12 16:52:06 +01:00
{
2021-08-17 18:33:55 +01:00
GearHelpers.AddEquippedGear(botToUpdate, rawParsedBot);
GearHelpers.AddEquippedMods(botToUpdate, rawParsedBot);
GearHelpers.AddCartridges(botToUpdate, rawParsedBot);
2021-08-12 16:52:06 +01:00
}
}
stopwatch.Stop();
2021-08-12 21:31:15 +01:00
LoggingHelpers.LogToConsole($"Finished processing bot gear. Took {LoggingHelpers.LogTimeTaken(stopwatch.Elapsed.TotalSeconds)} seconds");
2021-08-12 16:52:06 +01:00
2021-09-01 19:19:44 +03:00
return baseBots;
2021-08-12 16:52:06 +01:00
}
}
}