2021-08-27 21:34:12 +01:00
|
|
|
|
using Common;
|
|
|
|
|
using Generator.Helpers.Gear;
|
2021-09-18 22:36:59 +01:00
|
|
|
|
using Common.Models.Input;
|
|
|
|
|
using Common.Models.Output;
|
2021-08-27 21:34:12 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
2023-08-21 16:32:20 +01:00
|
|
|
|
using Generator.Weighting;
|
2021-08-27 21:34:12 +01:00
|
|
|
|
|
|
|
|
|
namespace Generator
|
|
|
|
|
{
|
2021-09-01 19:19:44 +03:00
|
|
|
|
public static class BotChancesGenerator
|
2021-08-27 21:34:12 +01:00
|
|
|
|
{
|
2021-09-05 12:27:17 +01:00
|
|
|
|
public static IEnumerable<Bot> AddChances(this IEnumerable<Bot> botsToUpdate, IEnumerable<Datum> rawBots)
|
2021-08-27 21:34:12 +01:00
|
|
|
|
{
|
|
|
|
|
var stopwatch = Stopwatch.StartNew();
|
|
|
|
|
LoggingHelpers.LogToConsole("Started processing bot gear");
|
|
|
|
|
|
2023-08-21 16:32:20 +01:00
|
|
|
|
var weightHelper = new WeightingService();
|
2021-09-05 12:27:17 +01:00
|
|
|
|
foreach (var botToUpdate in botsToUpdate)
|
2021-08-27 21:34:12 +01:00
|
|
|
|
{
|
2023-08-15 09:29:16 +00:00
|
|
|
|
var botType = botToUpdate.botType.ToString();
|
2021-09-05 12:27:17 +01:00
|
|
|
|
var rawParsedBotOfCurrentType = rawBots
|
2023-08-15 09:29:16 +00:00
|
|
|
|
.Where(x => x.Info.Settings.Role.Equals(botType, StringComparison.OrdinalIgnoreCase))
|
2021-08-27 21:34:12 +01:00
|
|
|
|
.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);
|
2023-08-21 16:32:20 +01:00
|
|
|
|
GearChanceHelpers.AddGenerationChances(botToUpdate, rawBots, weightHelper);
|
2021-08-27 21:34:12 +01:00
|
|
|
|
GearChanceHelpers.CalculateModChances(botToUpdate, rawParsedBotOfCurrentType);
|
2021-09-08 08:00:39 +01:00
|
|
|
|
GearChanceHelpers.ApplyModChanceOverrides(botToUpdate);
|
2021-10-08 09:44:38 +01:00
|
|
|
|
GearChanceHelpers.ApplyEquipmentChanceOverrides(botToUpdate);
|
2021-08-27 21:34:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2021-08-27 21:34:12 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|