BotGenerator/Generator/BotChancesGenerator.cs

42 lines
1.5 KiB
C#
Raw Normal View History

using Common;
using Generator.Helpers.Gear;
using Generator.Models.Input;
using Generator.Models.Output;
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 BotChancesGenerator
{
2021-09-05 12:27:17 +01:00
public static IEnumerable<Bot> AddChances(this IEnumerable<Bot> botsToUpdate, IEnumerable<Datum> rawBots)
{
var stopwatch = Stopwatch.StartNew();
LoggingHelpers.LogToConsole("Started processing bot gear");
2021-09-05 12:27:17 +01:00
foreach (var botToUpdate in botsToUpdate)
{
2021-09-05 12:27:17 +01:00
var rawParsedBotOfCurrentType = rawBots
.Where(x => x.Info.Settings.Role.Equals(botToUpdate.botType.ToString(), StringComparison.OrdinalIgnoreCase))
.ToList();
if (rawParsedBotOfCurrentType.Count == 0)
{
continue;
}
2021-09-01 19:19:44 +03:00
// TODO: Add check to make sure incoming bot list has gear
GearChanceHelpers.CalculateEquipmentChances(botToUpdate, rawParsedBotOfCurrentType);
GearChanceHelpers.AddGenerationChances(botToUpdate);
GearChanceHelpers.CalculateModChances(botToUpdate, rawParsedBotOfCurrentType);
}
stopwatch.Stop();
LoggingHelpers.LogToConsole($"Finished processing bot chances. Took {LoggingHelpers.LogTimeTaken(stopwatch.Elapsed.TotalSeconds)} seconds");
2021-09-05 12:27:17 +01:00
return botsToUpdate;
}
}
}