From 5083c7c5c3d4a5269f98cb1587bc3b86e51cfc43 Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 14 Nov 2024 11:52:11 +0000 Subject: [PATCH] Updated to store experience/aggressor bonus/exp reward in dictionaries keyed by bot difficulty --- Common.Models/Output/Output.cs | 8 ++++---- Generator/BaseBotGenerator.cs | 26 +++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Common.Models/Output/Output.cs b/Common.Models/Output/Output.cs index 30b8709..ea554d1 100644 --- a/Common.Models/Output/Output.cs +++ b/Common.Models/Output/Output.cs @@ -70,16 +70,16 @@ public class Experience public Experience() { level = new MinMax(0, 1); - reward = new MinMax(-1, -1); + reward = new Dictionary(); standingForKill = new Dictionary(); - aggressorBonus = null; + aggressorBonus = new Dictionary(); ; useSimpleAnimator = false; } public MinMax level { get; set; } - public MinMax reward { get; set; } + public Dictionary reward { get; set; } public Dictionary standingForKill { get; set; } - public object aggressorBonus { get; set; } + public new Dictionary aggressorBonus { get; set; } public bool useSimpleAnimator { get; set; } } diff --git a/Generator/BaseBotGenerator.cs b/Generator/BaseBotGenerator.cs index 50d8af7..997e6a5 100644 --- a/Generator/BaseBotGenerator.cs +++ b/Generator/BaseBotGenerator.cs @@ -14,6 +14,7 @@ namespace Generator UpdateBodyPartHealth(botData, rawBotData); AddExperience(botData, rawBotData); AddStandingForKill(botData, rawBotData); + AddAggressorBonus(botData, rawBotData); AddSkills(botData, rawBotData); botData.experience.useSimpleAnimator = rawBotData.Info.Settings.UseSimpleAnimator; @@ -47,14 +48,33 @@ namespace Generator { botToUpdate.experience.standingForKill.Add(rawBotData.Info.Settings.BotDifficulty, rawBotData.Info.Settings.StandingForKill); } + } - botToUpdate.experience.aggressorBonus ??= rawBotData.Info.Settings.AggressorBonus; + private static void AddAggressorBonus(Bot botToUpdate, Datum rawBotData) + { + botToUpdate.experience.aggressorBonus ??= new Dictionary(); + + if (!botToUpdate.experience.aggressorBonus.ContainsKey(rawBotData.Info.Settings.BotDifficulty)) + { + botToUpdate.experience.aggressorBonus.Add(rawBotData.Info.Settings.BotDifficulty, rawBotData.Info.Settings.AggressorBonus); + } } private static void AddExperience(Bot botToUpdate, Datum rawBotData) { - botToUpdate.experience.reward.min = rawBotData.Info.Settings.Experience; - botToUpdate.experience.reward.max = rawBotData.Info.Settings.Experience; + botToUpdate.experience.reward ??= new(); + + botToUpdate.experience.reward.TryGetValue(rawBotData.Info.Settings.BotDifficulty, out var minMaxValues); + if (minMaxValues is null) + { + botToUpdate.experience.reward.Add(rawBotData.Info.Settings.BotDifficulty, new(rawBotData.Info.Settings.Experience, rawBotData.Info.Settings.Experience)); + + return; + } + + minMaxValues.min = Math.Min(minMaxValues.min, rawBotData.Info.Settings.Experience); + minMaxValues.max = Math.Max(minMaxValues.max, rawBotData.Info.Settings.Experience); + } private static void AddVoice(Bot bot, Datum rawBot)