Update project to handle new bot types and json changes made to server

This commit is contained in:
Chomp 2022-06-30 11:20:34 +01:00
parent 60833e40d2
commit 5ed62b1e05
11 changed files with 325305 additions and 272229 deletions

View File

@ -25,6 +25,9 @@
sectantwarrior = 21, sectantwarrior = 21,
usec = 22, usec = 22,
exUsec = 23, exUsec = 23,
gifter = 24 gifter = 24,
bossknight = 25,
followerbirdeye = 26,
followerbigpipe = 27
} }
} }

View File

@ -1,10 +1,22 @@
using Newtonsoft.Json; using System.Collections.Generic;
using System.Collections.Generic; using System.Text.Json.Serialization;
namespace Common.Models.Output namespace Common.Models.Output;
[JsonSerializable(typeof(Bot))]
[JsonSourceGenerationOptions(GenerationMode = JsonSourceGenerationMode.Serialization, WriteIndented = true)]
public partial class BotJsonContext : JsonSerializerContext
{ {
}
public class Bot public class Bot
{ {
public Bot()
{
}
public Bot(BotType botType) public Bot(BotType botType)
{ {
this.botType = botType; this.botType = botType;
@ -173,6 +185,8 @@ public class GenerationChances
{ {
public GenerationChances(int specialMin, int SpecialMax, public GenerationChances(int specialMin, int SpecialMax,
int healingMin, int healingMax, int healingMin, int healingMax,
int drugMin, int drugMax,
int stimMin, int stimMax,
int looseLootMin, int looseLootMax, int looseLootMin, int looseLootMax,
int magazinesMin, int MagazineMax, int magazinesMin, int MagazineMax,
int grenandesMin, int grenadesMax) int grenandesMin, int grenadesMax)
@ -181,6 +195,8 @@ public class GenerationChances
{ {
specialItems = new MinMax(specialMin, SpecialMax), specialItems = new MinMax(specialMin, SpecialMax),
healing = new MinMax(healingMin, healingMax), healing = new MinMax(healingMin, healingMax),
drugs = new MinMax(drugMin, drugMax),
stims = new MinMax(stimMin, stimMax),
looseLoot = new MinMax(looseLootMin, looseLootMax), looseLoot = new MinMax(looseLootMin, looseLootMax),
magazines = new MinMax(magazinesMin, MagazineMax), magazines = new MinMax(magazinesMin, MagazineMax),
grenades = new MinMax(grenandesMin, grenadesMax) grenades = new MinMax(grenandesMin, grenadesMax)
@ -201,6 +217,8 @@ public class ItemChances
{ {
specialItems = new MinMax(0, 1); specialItems = new MinMax(0, 1);
healing = new MinMax(1, 2); healing = new MinMax(1, 2);
drugs = new MinMax(0, 1);
stims = new MinMax(0, 1);
looseLoot = new MinMax(0, 3); looseLoot = new MinMax(0, 3);
magazines = new MinMax(2, 4); magazines = new MinMax(2, 4);
grenades = new MinMax(0, 5); grenades = new MinMax(0, 5);
@ -208,6 +226,8 @@ public class ItemChances
public MinMax specialItems { get; set; } public MinMax specialItems { get; set; }
public MinMax healing { get; set; } public MinMax healing { get; set; }
public MinMax drugs { get; set; }
public MinMax stims { get; set; }
public MinMax looseLoot { get; set; } public MinMax looseLoot { get; set; }
public MinMax magazines { get; set; } public MinMax magazines { get; set; }
public MinMax grenades { get; set; } public MinMax grenades { get; set; }
@ -224,4 +244,3 @@ public class MinMax
public int min { get; set; } public int min { get; set; }
public int max { get; set; } public int max { get; set; }
} }
}

File diff suppressed because it is too large Load Diff

View File

@ -36,13 +36,24 @@ public static class BotParser
int dupeCount = 0; int dupeCount = 0;
var rawInputString = await ReadFileContentsAsync(file); var rawInputString = await ReadFileContentsAsync(file);
var json = rawInputString; //var json = rawInputString;
if (rawInputString.Contains("location\":1,")) //if (rawInputString.Contains("location\":1,"))
//{
// json = PruneMalformedBsgJson(rawInputString, splitFilePath.Last());
//}
List<Datum> bots = null;
try
{ {
json = PruneMalformedBsgJson(rawInputString, splitFilePath.Last()); bots = ParseJson(rawInputString);
}
catch (Exception ex)
{
Console.WriteLine($"file parse fucked up: {file}");
throw;
} }
var bots = ParseJson(json);
if (bots == null || bots.Count == 0) if (bots == null || bots.Count == 0)
{ {
Console.WriteLine($"skipping file: {splitFilePath.Last()}. no bots found, "); Console.WriteLine($"skipping file: {splitFilePath.Last()}. no bots found, ");

View File

@ -31,16 +31,19 @@ namespace Generator
// Iterate over each bot type wejust made and put some data into them // Iterate over each bot type wejust made and put some data into them
foreach (var botToUpdate in baseBots) foreach (var botToUpdate in baseBots)
{ {
var rawBotsOfSameType = rawBots.Where(x => string.Equals(x.Info.Settings.Role, botToUpdate.botType.ToString(), StringComparison.OrdinalIgnoreCase)) var rawBotType = botToUpdate.botType.ToString();
var rawBotsOfSameType = rawBots.Where(x => string.Equals(x.Info.Settings.Role, rawBotType, StringComparison.OrdinalIgnoreCase))
.ToList(); .ToList();
var rawBotsOfSameTypeCount = rawBotsOfSameType.Count.ToString();
if (rawBotsOfSameType.Count == 0) if (rawBotsOfSameType.Count == 0)
{ {
LoggingHelpers.LogToConsole($"no bots of type {botToUpdate.botType}", ConsoleColor.DarkRed); LoggingHelpers.LogToConsole($"no bots of type {rawBotType}, skipping", ConsoleColor.DarkRed);
continue; continue;
} }
LoggingHelpers.LogToConsole($"Found {rawBotsOfSameType.Count} bots of type: {botToUpdate.botType}"); LoggingHelpers.LogToConsole($"Found {rawBotsOfSameTypeCount} bots of type: {rawBotType}");
UpdateBodyPartHealth(botToUpdate, rawBotsOfSameType); UpdateBodyPartHealth(botToUpdate, rawBotsOfSameType);
AddDifficulties(botToUpdate, workingPath); AddDifficulties(botToUpdate, workingPath);
@ -95,12 +98,13 @@ namespace Generator
private static void AddDifficulties(Bot bot, string workingPath) private static void AddDifficulties(Bot bot, string workingPath)
{ {
var botFiles = Directory string botType = bot.botType.ToString();
var botDifficultyFiles = Directory
.GetFiles($"{workingPath}//Assets", "*.txt", SearchOption.TopDirectoryOnly) .GetFiles($"{workingPath}//Assets", "*.txt", SearchOption.TopDirectoryOnly)
.Where(x => x.Contains(bot.botType.ToString(), StringComparison.InvariantCultureIgnoreCase)) .Where(x => x.Contains(botType, StringComparison.InvariantCultureIgnoreCase))
.ToList(); .ToList();
DifficultyHelper.AddDifficultySettings(bot, botFiles); DifficultyHelper.AddDifficultySettings(bot, botDifficultyFiles);
} }
private static void UpdateBodyPartHealth(Bot botToUpdate, List<Datum> rawBots) private static void UpdateBodyPartHealth(Bot botToUpdate, List<Datum> rawBots)
@ -158,9 +162,9 @@ namespace Generator
{ {
// Add lastnames to all bots except raiders // Add lastnames to all bots except raiders
if (botToUpdate.botType != BotType.pmcBot) if (botToUpdate.botType != BotType.pmcBot)
{ {
botToUpdate.lastName.AddUnique(name[1]); botToUpdate.lastName.AddUnique(name[1]);
} }
} }
} }

View File

@ -18,8 +18,9 @@ namespace Generator
foreach (var botToUpdate in botsToUpdate) foreach (var botToUpdate in botsToUpdate)
{ {
var botType = botToUpdate.botType.ToString();
var rawParsedBotOfCurrentType = rawBots var rawParsedBotOfCurrentType = rawBots
.Where(x => x.Info.Settings.Role.Equals(botToUpdate.botType.ToString(), StringComparison.OrdinalIgnoreCase)) .Where(x => x.Info.Settings.Role.Equals(botType, StringComparison.OrdinalIgnoreCase))
.ToList(); .ToList();
if (rawParsedBotOfCurrentType.Count == 0) if (rawParsedBotOfCurrentType.Count == 0)

View File

@ -18,7 +18,8 @@ namespace Generator
foreach (var botToUpdate in baseBots) foreach (var botToUpdate in baseBots)
{ {
var rawParsedBotOfCurrentType = rawBots.Where(x => x.Info.Settings.Role.Equals(botToUpdate.botType.ToString(), StringComparison.OrdinalIgnoreCase)) var botType = botToUpdate.botType.ToString();
var rawParsedBotOfCurrentType = rawBots.Where(x => x.Info.Settings.Role.Equals(botType, StringComparison.OrdinalIgnoreCase))
.ToList(); .ToList();
if (rawParsedBotOfCurrentType.Count == 0) if (rawParsedBotOfCurrentType.Count == 0)

View File

@ -21,8 +21,9 @@ namespace Generator
// Iterate over assault/raider etc // Iterate over assault/raider etc
Parallel.ForEach(botsWithGear, botToUpdate => Parallel.ForEach(botsWithGear, botToUpdate =>
{ {
var botType = botToUpdate.botType.ToString();
var rawBotsOfSameType = rawBots var rawBotsOfSameType = rawBots
.Where(x => x.Info.Settings.Role.Equals(botToUpdate.botType.ToString(), StringComparison.OrdinalIgnoreCase)) .Where(x => x.Info.Settings.Role.Equals(botType, StringComparison.OrdinalIgnoreCase))
.ToList(); .ToList();
if (rawBotsOfSameType.Count == 0) if (rawBotsOfSameType.Count == 0)

View File

@ -152,6 +152,8 @@ namespace Generator.Helpers.Gear
bot.generation = new GenerationChances( bot.generation = new GenerationChances(
bot.inventory.items.SpecialLoot.Count, bot.inventory.items.SpecialLoot.Count, bot.inventory.items.SpecialLoot.Count, bot.inventory.items.SpecialLoot.Count,
healingMin: GetMedicalItemCountByBotType(bot.botType).min, healingMax: GetMedicalItemCountByBotType(bot.botType).max, healingMin: GetMedicalItemCountByBotType(bot.botType).min, healingMax: GetMedicalItemCountByBotType(bot.botType).max,
drugMin: 0, drugMax: 1,
stimMin: 0, stimMax: 1,
looseLootMin: GetLooseLootCountByBotType(bot.botType).min, looseLootMax: GetLooseLootCountByBotType(bot.botType).max, looseLootMin: GetLooseLootCountByBotType(bot.botType).min, looseLootMax: GetLooseLootCountByBotType(bot.botType).max,
magazinesMin: GetMagazineCountByBotType(bot.botType).min, MagazineMax: GetMagazineCountByBotType(bot.botType).max, magazinesMin: GetMagazineCountByBotType(bot.botType).min, MagazineMax: GetMagazineCountByBotType(bot.botType).max,
grenandesMin: 0, grenadesMax: 5); //TODO get dynamically grenandesMin: 0, grenadesMax: 5); //TODO get dynamically
@ -233,10 +235,34 @@ namespace Generator.Helpers.Gear
switch (botType) switch (botType)
{ {
case BotType.assault:
min= 0;
max= 6;
break;
case BotType.marksman:
min = 0;
max = 0;
break;
case BotType.exUsec: case BotType.exUsec:
min = 3; min = 2;
max = 4; max = 4;
break; break;
case BotType.bossbully:
min = 3;
max= 7;
break;
case BotType.bossgluhar:
min = 2;
max = 9;
break;
case BotType.bosskilla:
min = 4;
max = 10;
break;
case BotType.bosskojaniy:
min = 0;
max = 7;
break;
case BotType.bosssanitar: case BotType.bosssanitar:
case BotType.followersanitar: case BotType.followersanitar:
min = 2; min = 2;

View File

@ -82,6 +82,7 @@ namespace Generator.Helpers.Gear
break; break;
case BotType.bosskojaniy: case BotType.bosskojaniy:
results.Add("5d08d21286f774736e7c94c3"); // Shturman's stash key results.Add("5d08d21286f774736e7c94c3"); // Shturman's stash key
results.Add("5c94bbff86f7747ee735c08f"); // labs keycard
break; break;
case BotType.bosssanitar: case BotType.bosssanitar:
results.Add("5efde6b4f5448336730dbd61"); // Keycard with a blue marking results.Add("5efde6b4f5448336730dbd61"); // Keycard with a blue marking

View File

@ -26,20 +26,6 @@ public class Program
return; return;
} }
//var dupeCount = 0;
//var botTemplates = new List<Datum>();
//foreach (var bot in parsedBots)
//{
// if (botTemplates.ContainsBot(bot))
// {
// dupeCount++;
// continue;
// }
// botTemplates.Add(bot);
//}
var dictDupeCount = 0; var dictDupeCount = 0;
var uniqueBotTemplates = new Dictionary<string, Datum>(); var uniqueBotTemplates = new Dictionary<string, Datum>();
foreach (var bot in parsedBots) foreach (var bot in parsedBots)