Update project to handle new bot types and json changes made to server
This commit is contained in:
parent
60833e40d2
commit
5ed62b1e05
@ -25,6 +25,9 @@
|
||||
sectantwarrior = 21,
|
||||
usec = 22,
|
||||
exUsec = 23,
|
||||
gifter = 24
|
||||
gifter = 24,
|
||||
bossknight = 25,
|
||||
followerbirdeye = 26,
|
||||
followerbigpipe = 27
|
||||
}
|
||||
}
|
||||
|
@ -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 Bot()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Bot(BotType botType)
|
||||
{
|
||||
this.botType = botType;
|
||||
@ -173,6 +185,8 @@ public class GenerationChances
|
||||
{
|
||||
public GenerationChances(int specialMin, int SpecialMax,
|
||||
int healingMin, int healingMax,
|
||||
int drugMin, int drugMax,
|
||||
int stimMin, int stimMax,
|
||||
int looseLootMin, int looseLootMax,
|
||||
int magazinesMin, int MagazineMax,
|
||||
int grenandesMin, int grenadesMax)
|
||||
@ -181,6 +195,8 @@ public class GenerationChances
|
||||
{
|
||||
specialItems = new MinMax(specialMin, SpecialMax),
|
||||
healing = new MinMax(healingMin, healingMax),
|
||||
drugs = new MinMax(drugMin, drugMax),
|
||||
stims = new MinMax(stimMin, stimMax),
|
||||
looseLoot = new MinMax(looseLootMin, looseLootMax),
|
||||
magazines = new MinMax(magazinesMin, MagazineMax),
|
||||
grenades = new MinMax(grenandesMin, grenadesMax)
|
||||
@ -201,6 +217,8 @@ public class ItemChances
|
||||
{
|
||||
specialItems = new MinMax(0, 1);
|
||||
healing = new MinMax(1, 2);
|
||||
drugs = new MinMax(0, 1);
|
||||
stims = new MinMax(0, 1);
|
||||
looseLoot = new MinMax(0, 3);
|
||||
magazines = new MinMax(2, 4);
|
||||
grenades = new MinMax(0, 5);
|
||||
@ -208,6 +226,8 @@ public class ItemChances
|
||||
|
||||
public MinMax specialItems { get; set; }
|
||||
public MinMax healing { get; set; }
|
||||
public MinMax drugs { get; set; }
|
||||
public MinMax stims { get; set; }
|
||||
public MinMax looseLoot { get; set; }
|
||||
public MinMax magazines { get; set; }
|
||||
public MinMax grenades { get; set; }
|
||||
@ -224,4 +244,3 @@ public class MinMax
|
||||
public int min { get; set; }
|
||||
public int max { get; set; }
|
||||
}
|
||||
}
|
||||
|
597409
Common/Assets/items.json
597409
Common/Assets/items.json
File diff suppressed because it is too large
Load Diff
@ -36,13 +36,24 @@ public static class BotParser
|
||||
int dupeCount = 0;
|
||||
var rawInputString = await ReadFileContentsAsync(file);
|
||||
|
||||
var json = rawInputString;
|
||||
if (rawInputString.Contains("location\":1,"))
|
||||
//var json = rawInputString;
|
||||
//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)
|
||||
{
|
||||
Console.WriteLine($"skipping file: {splitFilePath.Last()}. no bots found, ");
|
||||
|
@ -31,16 +31,19 @@ namespace Generator
|
||||
// Iterate over each bot type wejust made and put some data into them
|
||||
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();
|
||||
var rawBotsOfSameTypeCount = rawBotsOfSameType.Count.ToString();
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
LoggingHelpers.LogToConsole($"Found {rawBotsOfSameType.Count} bots of type: {botToUpdate.botType}");
|
||||
LoggingHelpers.LogToConsole($"Found {rawBotsOfSameTypeCount} bots of type: {rawBotType}");
|
||||
|
||||
UpdateBodyPartHealth(botToUpdate, rawBotsOfSameType);
|
||||
AddDifficulties(botToUpdate, workingPath);
|
||||
@ -95,12 +98,13 @@ namespace Generator
|
||||
|
||||
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)
|
||||
.Where(x => x.Contains(bot.botType.ToString(), StringComparison.InvariantCultureIgnoreCase))
|
||||
.Where(x => x.Contains(botType, StringComparison.InvariantCultureIgnoreCase))
|
||||
.ToList();
|
||||
|
||||
DifficultyHelper.AddDifficultySettings(bot, botFiles);
|
||||
DifficultyHelper.AddDifficultySettings(bot, botDifficultyFiles);
|
||||
}
|
||||
|
||||
private static void UpdateBodyPartHealth(Bot botToUpdate, List<Datum> rawBots)
|
||||
@ -158,9 +162,9 @@ namespace Generator
|
||||
{
|
||||
// Add lastnames to all bots except raiders
|
||||
if (botToUpdate.botType != BotType.pmcBot)
|
||||
{
|
||||
botToUpdate.lastName.AddUnique(name[1]);
|
||||
}
|
||||
{
|
||||
botToUpdate.lastName.AddUnique(name[1]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,9 @@ namespace Generator
|
||||
|
||||
foreach (var botToUpdate in botsToUpdate)
|
||||
{
|
||||
var botType = botToUpdate.botType.ToString();
|
||||
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();
|
||||
|
||||
if (rawParsedBotOfCurrentType.Count == 0)
|
||||
|
@ -18,7 +18,8 @@ namespace Generator
|
||||
|
||||
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();
|
||||
|
||||
if (rawParsedBotOfCurrentType.Count == 0)
|
||||
|
@ -21,8 +21,9 @@ namespace Generator
|
||||
// Iterate over assault/raider etc
|
||||
Parallel.ForEach(botsWithGear, botToUpdate =>
|
||||
{
|
||||
var botType = botToUpdate.botType.ToString();
|
||||
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();
|
||||
|
||||
if (rawBotsOfSameType.Count == 0)
|
||||
|
@ -152,6 +152,8 @@ namespace Generator.Helpers.Gear
|
||||
bot.generation = new GenerationChances(
|
||||
bot.inventory.items.SpecialLoot.Count, bot.inventory.items.SpecialLoot.Count,
|
||||
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,
|
||||
magazinesMin: GetMagazineCountByBotType(bot.botType).min, MagazineMax: GetMagazineCountByBotType(bot.botType).max,
|
||||
grenandesMin: 0, grenadesMax: 5); //TODO get dynamically
|
||||
@ -233,10 +235,34 @@ namespace Generator.Helpers.Gear
|
||||
|
||||
switch (botType)
|
||||
{
|
||||
case BotType.assault:
|
||||
min= 0;
|
||||
max= 6;
|
||||
break;
|
||||
case BotType.marksman:
|
||||
min = 0;
|
||||
max = 0;
|
||||
break;
|
||||
case BotType.exUsec:
|
||||
min = 3;
|
||||
min = 2;
|
||||
max = 4;
|
||||
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.followersanitar:
|
||||
min = 2;
|
||||
|
@ -82,6 +82,7 @@ namespace Generator.Helpers.Gear
|
||||
break;
|
||||
case BotType.bosskojaniy:
|
||||
results.Add("5d08d21286f774736e7c94c3"); // Shturman's stash key
|
||||
results.Add("5c94bbff86f7747ee735c08f"); // labs keycard
|
||||
break;
|
||||
case BotType.bosssanitar:
|
||||
results.Add("5efde6b4f5448336730dbd61"); // Keycard with a blue marking
|
||||
|
@ -26,20 +26,6 @@ public class Program
|
||||
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 uniqueBotTemplates = new Dictionary<string, Datum>();
|
||||
foreach (var bot in parsedBots)
|
||||
|
Loading…
x
Reference in New Issue
Block a user