public static AIProfiles Load() { AIProfiles aIProfiles = new AIProfiles(); if (!Directory.Exists(AIProfiles.PATH)) { throw new AISettingsException("Directory does not exist", -1); } if (File.Exists(AIProfiles.FILE_PATH)) { string value = File.ReadAllText(AIProfiles.FILE_PATH); Dictionary <string, object> dictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(value); try { aIProfiles.ST_Delay = Convert.ToInt32(dictionary["ST_Delay"]); } catch (Exception) { } try { aIProfiles.ST_ReconnectInterruptEnable = (bool)dictionary["ST_ReconnectInterruptEnable"]; } catch (Exception) { } try { aIProfiles.ST_ReconnectInterruptInterval = Convert.ToInt32(dictionary["ST_ReconnectInterruptInterval"]); } catch (Exception) { } try { aIProfiles.ST_EnableHotTimeProfile = (bool)dictionary["ST_EnableHotTimeProfile"]; } catch (Exception) { } try { aIProfiles.ST_EnableAutoProfile = (bool)dictionary["ST_EnableAutoProfile"]; } catch (Exception) { } try { aIProfiles.ST_EnableAutoShutdown = (bool)dictionary["ST_EnableAutoShutdown"]; } catch (Exception) { } try { aIProfiles.AD_Pause100 = (bool)dictionary["AD_Pause100"]; } catch (Exception) { } try { aIProfiles.AD_NoHeroUp = (bool)dictionary["AD_NoHeroUp"]; } catch (Exception) { } try { aIProfiles.ST_EnableTelegram = (bool)dictionary["ST_EnableTelegram"]; } catch (Exception) { } try { aIProfiles.ST_EnableTelegramMsg1 = (bool)dictionary["ST_EnableTelegramMsg1"]; } catch (Exception) { } try { aIProfiles.ST_TelegramWarnBoost = (bool)dictionary["ST_TelegramWarnBoost"]; } catch (Exception) { } try { aIProfiles.ST_TelegramWarnHT = (bool)dictionary["ST_TelegramWarnHT"]; } catch (Exception) { } try { aIProfiles.ST_HotTimeProfile = (string)dictionary["ST_HotTimeProfile"]; } catch (Exception) { } try { aIProfiles.ST_BlueStacksForceActive = (bool)dictionary["ST_BlueStacksForceActive"]; } catch (Exception) { } try { aIProfiles.ST_TelegramToken = ((dictionary["ST_TelegramToken"] == null) ? null : dictionary["ST_TelegramToken"].ToString()); } catch (Exception) { } try { aIProfiles.ST_LDTitle = ((dictionary["ST_LDTitle"] == null) ? "LDPlayer" : dictionary["ST_LDTitle"].ToString()); } catch (Exception) { } try { aIProfiles.ST_TelegramChatID = ((dictionary["ST_TelegramChatID"] == null) ? null : dictionary["ST_TelegramChatID"].ToString()); } catch (Exception) { } try { aIProfiles.ST_ForegroundMode = (bool)dictionary["ST_ForegroundMode"]; } catch (Exception) { } } string text = null; string[] files = Directory.GetFiles(AIProfiles.PATH); for (int i = 0; i < files.Length; i++) { string text2 = files[i]; if (text2.EndsWith(AIProfiles.FILE_EXTENSION) && !(text2 == AIProfiles.FILE_PATH)) { text2.Substring(text2.IndexOf('\\') + 1); AISettings value2 = AISettings.Load(text2); aIProfiles.Settings.Add(text2, value2); if (string.IsNullOrEmpty(text)) { text = text2; } } } if (aIProfiles.Settings.Count <= 0) { throw new AISettingsException("No profile available", -1); } aIProfiles.CurrentKey = text; return(aIProfiles); }
private void Init() { MainForm.Instance = this; this.SynchronizationContext = SynchronizationContext.Current; HotTimeHelper.ImportHotTimeSchedule(); try { this.AIProfiles = AIProfiles.Load(); } catch (AISettingsException ex) { if (ex.ErrorCode != -1) { MessageBox.Show("Error loading settings: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } this.AIProfiles = new AIProfiles(new AISettings()); } this.AI = new SevenKnightsCore(this.AIProfiles); }
public SevenKnightsCore(AIProfiles profile) { this.AIProfiles = profile; this.Pushbullet = new SlimPushbullet("SpD0cXpZzSFuLlNBVO6Zo2wKK0jVEkZK"); this.OneSecTimer = new System.Timers.Timer(1000.0); this.OneSecTimer.Elapsed += new ElapsedEventHandler(this.OnOneSecEvent); try { this.Tesseractor = new Tesseractor("eng"); } catch (TesseractException) { MessageBox.Show("Tesseract engine could not be initialized", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); this.Tesseractor = null; } }
public static AIProfiles Load() { AIProfiles aIProfiles = new AIProfiles(); if (!Directory.Exists(AIProfiles.PATH)) { throw new AISettingsException("Directory does not exist", -1); } if (File.Exists(AIProfiles.FILE_PATH)) { string value = File.ReadAllText(AIProfiles.FILE_PATH); Dictionary<string, object> dictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>(value); try { aIProfiles.ST_Delay = Convert.ToInt32(dictionary["ST_Delay"]); } catch (Exception) { } try { aIProfiles.ST_ReconnectInterruptEnable = (bool)dictionary["ST_ReconnectInterruptEnable"]; } catch (Exception) { } try { aIProfiles.ST_ReconnectInterruptInterval = Convert.ToInt32(dictionary["ST_ReconnectInterruptInterval"]); } catch (Exception) { } try { aIProfiles.ST_EnableHotTimeProfile = (bool)dictionary["ST_EnableHotTimeProfile"]; } catch (Exception) { } try { aIProfiles.ST_HotTimeProfile = (string)dictionary["ST_HotTimeProfile"]; } catch (Exception) { } try { aIProfiles.ST_BlueStacksForceActive = (bool)dictionary["ST_BlueStacksForceActive"]; } catch (Exception) { } try { aIProfiles.ST_PushbulletEnable = (bool)dictionary["ST_PushbulletEnable"]; } catch (Exception) { } try { aIProfiles.ST_PushbulletEmail = ((dictionary["ST_PushbulletEmail"] == null) ? null : dictionary["ST_PushbulletEmail"].ToString()); } catch (Exception) { } try { aIProfiles.ST_ForegroundMode = (bool)dictionary["ST_ForegroundMode"]; } catch (Exception) { } } string text = null; string[] files = Directory.GetFiles(AIProfiles.PATH); for (int i = 0; i < files.Length; i++) { string text2 = files[i]; if (text2.EndsWith(AIProfiles.FILE_EXTENSION) && !(text2 == AIProfiles.FILE_PATH)) { text2.Substring(text2.IndexOf('\\') + 1); AISettings value2 = AISettings.Load(text2); aIProfiles.Settings.Add(text2, value2); if (string.IsNullOrEmpty(text)) { text = text2; } } } if (aIProfiles.Settings.Count <= 0) { throw new AISettingsException("No profile available", -1); } aIProfiles.CurrentKey = text; return aIProfiles; }