Handle a bot type with no dumps

This commit is contained in:
Chomp 2021-08-17 18:33:55 +01:00
parent c8cf5f847e
commit 76a17e6d6a
5 changed files with 38 additions and 19 deletions

View File

@ -39,15 +39,15 @@ namespace Generator
var rawBots = new List<Bot>
{
assaultBot,
raiderBot,
marksmanBot,
assaultBot,
raiderBot,
marksmanBot,
bossbully,
bossgluharBot,
bosskillaBot,
bosskojaniyBot,
bosssanitarBot
bossbully,
bossgluharBot,
bosskillaBot,
bosskojaniyBot,
bosssanitarBot
};
foreach (var botToUpdate in rawBots)
@ -57,10 +57,12 @@ namespace Generator
if (rawBotsOfSameType.Count == 0)
{
Console.WriteLine($"no bots of type {botToUpdate.botType.ToString()}");
LoggingHelpers.LogToConsole($"no bots of type {botToUpdate.botType}", ConsoleColor.DarkRed);
break;
}
LoggingHelpers.LogToConsole($"Found {rawBotsOfSameType.Count} bots of type: {botToUpdate.botType}");
UpdateBodyPartHealth(botToUpdate, rawBotsOfSameType);
AddDifficulties(botToUpdate, _workingPath);
AddExperience(botToUpdate, rawBotsOfSameType);

View File

@ -25,20 +25,26 @@ namespace Generator
var stopwatch = Stopwatch.StartNew();
LoggingHelpers.LogToConsole("Started processing bot gear");
foreach (var bot in _baseBots)
foreach (var botToUpdate in _baseBots)
{
var rawParsedBotOfCurrentType = _rawParsedBots
.Where(x => x.Info.Settings.Role.Equals(bot.botType.ToString(), StringComparison.OrdinalIgnoreCase))
.Where(x => x.Info.Settings.Role.Equals(botToUpdate.botType.ToString(), StringComparison.OrdinalIgnoreCase))
.ToList();
GearChanceHelpers.CalculateEquipmentChances(bot, rawParsedBotOfCurrentType);
GearChanceHelpers.AddGenerationChances(bot);
GearChanceHelpers.CalculateModChances(bot, rawParsedBotOfCurrentType);
if (rawParsedBotOfCurrentType.Count == 0)
{
break;
}
GearChanceHelpers.CalculateEquipmentChances(botToUpdate, rawParsedBotOfCurrentType);
GearChanceHelpers.AddGenerationChances(botToUpdate);
GearChanceHelpers.CalculateModChances(botToUpdate, rawParsedBotOfCurrentType);
foreach (var rawParsedBot in rawParsedBotOfCurrentType)
{
GearHelpers.AddEquippedGear(bot, rawParsedBot);
GearHelpers.AddEquippedMods(bot, rawParsedBot);
GearHelpers.AddCartridges(bot, rawParsedBot);
GearHelpers.AddEquippedGear(botToUpdate, rawParsedBot);
GearHelpers.AddEquippedMods(botToUpdate, rawParsedBot);
GearHelpers.AddCartridges(botToUpdate, rawParsedBot);
}
}

View File

@ -30,6 +30,12 @@ namespace Generator
var rawBotsOfSameType = _rawParsedBots
.Where(x => x.Info.Settings.Role.Equals(botToUpdate.botType.ToString(), StringComparison.OrdinalIgnoreCase))
.ToList();
if (rawBotsOfSameType.Count == 0)
{
break;
}
foreach (var rawParsedBot in rawBotsOfSameType)
{
AddPocketLoot(botToUpdate, rawParsedBot);

View File

@ -9,9 +9,9 @@ namespace Generator.Helpers
return Math.Round(totalSeconds, 2, MidpointRounding.ToEven).ToString();
}
public static void LogToConsole(string message)
public static void LogToConsole(string message, ConsoleColor backgroundColour = ConsoleColor.Green)
{
Console.BackgroundColor = ConsoleColor.Green;
Console.BackgroundColor = backgroundColour;
Console.ForegroundColor = ConsoleColor.Black;
Console.WriteLine(message);

View File

@ -24,6 +24,11 @@ namespace Generator
foreach (var bot in bots)
{
if (bot.appearance.body.Count == 0) // only process files that have data in them, no body = no dumps
{
Helpers.LoggingHelpers.LogToConsole($"Unable to process bot type: {bot.botType}, skipping", ConsoleColor.DarkRed);
continue;
}
var output = JsonConvert.SerializeObject(bot, Formatting.Indented);
Console.WriteLine($"Writing json file {bot.botType} to {outputPath}");
File.WriteAllText($"{outputPath}\\{bot.botType}.json", output);