forked from chomp/BotGenerator
refactor code to perform metric calculations last
This commit is contained in:
parent
f3975badac
commit
ec25fdd058
50
Generator/BotChancesGenerator.cs
Normal file
50
Generator/BotChancesGenerator.cs
Normal file
@ -0,0 +1,50 @@
|
||||
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
|
||||
{
|
||||
internal class BotChancesGenerator
|
||||
{
|
||||
private readonly List<Bot> _bots;
|
||||
private readonly List<Datum> _rawParsedBots;
|
||||
|
||||
public BotChancesGenerator(List<Bot> botsWithGearAndLoot, List<Datum> parsedBots)
|
||||
{
|
||||
_bots = botsWithGearAndLoot;
|
||||
_rawParsedBots = parsedBots;
|
||||
}
|
||||
|
||||
internal List<Bot> AddChances()
|
||||
{
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
LoggingHelpers.LogToConsole("Started processing bot gear");
|
||||
|
||||
foreach (var botToUpdate in _bots)
|
||||
{
|
||||
var rawParsedBotOfCurrentType = _rawParsedBots
|
||||
.Where(x => x.Info.Settings.Role.Equals(botToUpdate.botType.ToString(), StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
|
||||
if (rawParsedBotOfCurrentType.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
return _bots;
|
||||
}
|
||||
}
|
||||
}
|
@ -37,10 +37,6 @@ namespace Generator
|
||||
continue;
|
||||
}
|
||||
|
||||
GearChanceHelpers.CalculateEquipmentChances(botToUpdate, rawParsedBotOfCurrentType);
|
||||
GearChanceHelpers.AddGenerationChances(botToUpdate);
|
||||
GearChanceHelpers.CalculateModChances(botToUpdate, rawParsedBotOfCurrentType);
|
||||
|
||||
foreach (var rawParsedBot in rawParsedBotOfCurrentType)
|
||||
{
|
||||
GearHelpers.AddEquippedGear(botToUpdate, rawParsedBot);
|
||||
|
@ -109,14 +109,7 @@ namespace Generator.Helpers.Gear
|
||||
|
||||
public static void AddGenerationChances(Bot bot)
|
||||
{
|
||||
switch (bot.botType)
|
||||
{
|
||||
case BotType.assault:
|
||||
case BotType.pmcBot:
|
||||
case BotType.marksman:
|
||||
bot.generation = new GenerationChances(0, 1, 1, 2, 0, 3, 2, 4, 0, 5); //TODO get dynamically
|
||||
break;
|
||||
}
|
||||
bot.generation = new GenerationChances(bot.specialLoot.Count, bot.specialLoot.Count, 1, 2, 0, 3, 2, 4, 0, 5); //TODO get dynamically
|
||||
}
|
||||
|
||||
public static void CalculateEquipmentChances(Bot bot, List<Datum> baseBots)
|
||||
|
@ -59,9 +59,13 @@ namespace Generator
|
||||
var botLootGenerator = new BotLootGenerator(botsWithGear, parsedBots);
|
||||
var botsWithGearAndLoot = botLootGenerator.AddLoot();
|
||||
|
||||
// Add mod/equipment chances
|
||||
var botChancesGenerator = new BotChancesGenerator(botsWithGearAndLoot, parsedBots);
|
||||
var botsWithGearAndLootAndChances = botChancesGenerator.AddChances();
|
||||
|
||||
// Output bot to json file
|
||||
var jsonWriter = new JsonWriter(workingPath, "output");
|
||||
jsonWriter.WriteJson(botsWithGearAndLoot);
|
||||
jsonWriter.WriteJson(botsWithGearAndLootAndChances);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user