BotGenerator/Generator/BotGearGenerator.cs

58 lines
1.9 KiB
C#
Raw Normal View History

2021-08-12 16:52:06 +01:00
using Generator.Helpers;
using Generator.Helpers.Gear;
2021-08-12 16:52:06 +01:00
using Generator.Models.Input;
using Generator.Models.Output;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace Generator
{
public class BotGearGenerator
{
private readonly List<Bot> _baseBots;
private readonly List<Datum> _rawParsedBots;
public BotGearGenerator(List<Bot> baseBots, List<Datum> parsedBots)
{
_baseBots = baseBots;
_rawParsedBots = parsedBots;
}
internal List<Bot> AddGear()
{
var stopwatch = Stopwatch.StartNew();
LoggingHelpers.LogToConsole("Started processing bot gear");
2021-08-17 18:33:55 +01:00
foreach (var botToUpdate in _baseBots)
2021-08-12 16:52:06 +01:00
{
var rawParsedBotOfCurrentType = _rawParsedBots
2021-08-17 18:33:55 +01:00
.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
}
GearChanceHelpers.CalculateEquipmentChances(botToUpdate, rawParsedBotOfCurrentType);
GearChanceHelpers.AddGenerationChances(botToUpdate);
GearChanceHelpers.CalculateModChances(botToUpdate, rawParsedBotOfCurrentType);
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
return _baseBots;
}
}
}