2021-08-27 21:34:12 +01:00
|
|
|
|
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-08-27 21:34:12 +01:00
|
|
|
|
{
|
2021-09-01 19:19:44 +03:00
|
|
|
|
public static IEnumerable<Bot> AddChances(this IEnumerable<Bot> botsWithGear, IEnumerable<Datum> parsedBots)
|
2021-08-27 21:34:12 +01:00
|
|
|
|
{
|
|
|
|
|
var stopwatch = Stopwatch.StartNew();
|
|
|
|
|
LoggingHelpers.LogToConsole("Started processing bot gear");
|
|
|
|
|
|
2021-09-01 19:19:44 +03:00
|
|
|
|
foreach (var botToUpdate in botsWithGear)
|
2021-08-27 21:34:12 +01:00
|
|
|
|
{
|
2021-09-01 19:19:44 +03:00
|
|
|
|
var rawParsedBotOfCurrentType = parsedBots
|
2021-08-27 21:34:12 +01:00
|
|
|
|
.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
|
2021-08-27 21:34:12 +01:00
|
|
|
|
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-01 19:19:44 +03:00
|
|
|
|
return botsWithGear;
|
2021-08-27 21:34:12 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|