private static void PrintStatistics() { ScriptHelper.PrintMessage("--BotExtended statistics--", ScriptHelper.ERROR_COLOR); var botFactions = BotHelper.GetAvailableBotFactions(); ScriptHelper.PrintMessage("[WinCount] [TotalMatch] [SurvivalRate]", ScriptHelper.WARNING_COLOR); foreach (var botFaction in botFactions) { var factionSet = GetFactionSet(botFaction); for (var i = 0; i < factionSet.Factions.Count; i++) { var factionKey = BotHelper.StorageKey(botFaction, i) + "_WIN_STATS"; int[] winStats; if (BotHelper.Storage.TryGetItemIntArr(factionKey, out winStats)) { var winCount = winStats[0]; var totalMatch = winStats[1]; var survivalRate = (float)winCount / totalMatch; var survivalRateStr = survivalRate.ToString("0.##", System.Globalization.CultureInfo.InvariantCulture); ScriptHelper.PrintMessage(SharpHelper.EnumToString(botFaction) + " " + i + ": " + " " + winCount + " " + totalMatch + " " + survivalRateStr); } } } }
private static IEnumerable <string> GetFactionNames() { var factions = BotHelper.GetAvailableBotFactions(); foreach (var faction in factions) { yield return(((int)faction).ToString() + ": " + SharpHelper.EnumToString(faction)); } }
private static void ClearStatistics() { var botFactions = BotHelper.GetAvailableBotFactions(); foreach (var botFaction in botFactions) { var factionSet = GetFactionSet(botFaction); for (var i = 0; i < factionSet.Factions.Count; i++) { var factionKey = BotHelper.StorageKey(botFaction, i) + "_WIN_STATS"; BotHelper.Storage.RemoveItem(factionKey); } } ScriptHelper.PrintMessage("[Botextended] Clear successfully"); }
public static Settings Get() { int botCount; var botCountKey = BotHelper.StorageKey("BOT_COUNT"); if (!BotHelper.Storage.TryGetItemInt(botCountKey, out botCount)) { botCount = Constants.DEFAULT_MAX_BOT_COUNT; BotHelper.Storage.SetItem(botCountKey, Constants.DEFAULT_MAX_BOT_COUNT); } botCount = (int)MathHelper.Clamp(botCount, Constants.BOT_COUNT_MIN, Constants.BOT_COUNT_MAX); int factionRotationInterval; var factionRotationIntervalKey = BotHelper.StorageKey("FACTION_ROTATION_INTERVAL"); if (!BotHelper.Storage.TryGetItemInt(factionRotationIntervalKey, out factionRotationInterval)) { factionRotationInterval = Constants.DEFAULT_FACTION_ROTATION_INTERVAL; BotHelper.Storage.SetItem(factionRotationIntervalKey, Constants.DEFAULT_FACTION_ROTATION_INTERVAL); } int roundsUntilRotation; var roundsUntilRotationKey = BotHelper.StorageKey("ROUNDS_UNTIL_FACTION_ROTATION"); if (!BotHelper.Storage.TryGetItemInt(roundsUntilRotationKey, out roundsUntilRotation)) { roundsUntilRotation = factionRotationInterval; BotHelper.Storage.SetItem(roundsUntilRotationKey, factionRotationInterval); } var teams = SharpHelper.EnumToList <PlayerTeam>(); var botFactions = new Dictionary <PlayerTeam, List <BotFaction> >(); var currentFaction = new Dictionary <PlayerTeam, BotFaction>(); string[] currentFactionStr; var currentFactionKey = BotHelper.StorageKey("CURRENT_FACTION"); if (!BotHelper.Storage.TryGetItemStringArr(currentFactionKey, out currentFactionStr)) { currentFactionStr = new string[] { "None", "None", "None", "None" }; } for (var i = 0; i < 4; i++) { currentFaction.Add((PlayerTeam)i + 1, SharpHelper.StringToEnum <BotFaction>(currentFactionStr[i])); } foreach (var team in teams) { if (team == PlayerTeam.Independent) { continue; } string[] factions = null; var factionsKey = BotHelper.StorageKey("BOT_FACTIONS_" + team); if (!BotHelper.Storage.TryGetItemStringArr(factionsKey, out factions)) { if (team == BotManager.BotTeam) { factions = Constants.DEFAULT_FACTIONS; } else { factions = new string[] { "None" } }; BotHelper.Storage.SetItem(factionsKey, factions); } List <BotFaction> botFactionList; if (factions.Count() == 1 && factions.Single() == "All") { botFactionList = BotHelper.GetAvailableBotFactions().ToList(); } else { botFactionList = new List <BotFaction>(); foreach (var faction in factions) { botFactionList.Add(SharpHelper.StringToEnum <BotFaction>(faction)); } } botFactions.Add(team, botFactionList); } string[] playerSettings; var playerSettingsKey = BotHelper.StorageKey("PLAYER_SETTINGS"); if (!BotHelper.Storage.TryGetItemStringArr(playerSettingsKey, out playerSettings)) { playerSettings = new string[] { }; } return(new Settings( botCount, factionRotationInterval, roundsUntilRotation, botFactions, currentFaction, playerSettings )); } }