private void UpdateTowerKeys() { PixelMapping[] array = new PixelMapping[] { TowerStartPM.Key_0, TowerStartPM.Key_1, TowerStartPM.Key_2, TowerStartPM.Key_3, TowerStartPM.Key_4 }; int num = 5; for (int i = 0; i < array.Length; i++) { if (this.MatchMapping(array[i], 4)) { num = i; break; } } if (num < 5) { using (Bitmap bitmap = this.CropFrame(this.BlueStacks.MainWindowAS.CurrentFrame, TowerStartPM.R_Time)) { using (Page page = this.Tesseractor.Engine.Process(bitmap, null)) { string text = page.GetText(); Utility.FilterAscii(text); if (text.Length >= 2) { string s = text.Substring(0, 2); string s2 = text.Substring(3, 2); int minutes; int.TryParse(s, out minutes); int seconds; int.TryParse(s2, out seconds); TimeSpan towerKeyTime = new TimeSpan(0, minutes, seconds); this.TowerKeyTime = towerKeyTime; } else { this.TowerKeyTime = TimeSpan.MaxValue; } } goto IL_170; } this.TowerKeyTime = TimeSpan.MaxValue; IL_170:; } this.TowerKeys = num; this.ReportKeys(Objective.GOLD_CHAMBER); }
private void SellItems() { PixelMapping[] array = new PixelMapping[] { SellItemPopupPM.SellButtonRow1, SellItemPopupPM.SellButtonRow2, SellItemPopupPM.SellButtonRow3, SellItemPopupPM.SellButtonRow4, SellItemPopupPM.SellButtonRow5 }; PixelMapping[] array2 = new PixelMapping[] { SellItemConfirmPopupPM.Star1, SellItemConfirmPopupPM.Star2, SellItemConfirmPopupPM.Star3, SellItemConfirmPopupPM.Star4, SellItemConfirmPopupPM.Star5, SellItemConfirmPopupPM.Star6 }; this.Log("Start selling items", this.COLOR_SELL_ITEMS); this.PushNote("Selling items", "AI will only sell the item if the given condition is met."); if (this.MatchMapping(SellItemPopupPM.SortButtonDescending, 2)) { this.WeightedClick(SellItemPopupPM.SortButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(300); } this.ScrollItemPopup(false); SevenKnightsCore.Sleep(500); bool flag = false; int num = 0; int num2 = 0; ulong num3 = 0uL; ulong hash = 0uL; double num4 = 99.9; int num5 = 0; while (num5 < 80 && !this.Worker.CancellationPending) { this.CaptureFrame(); Scene scene = this.SceneSearch(); if (scene != null && scene.SceneType != SceneType.SELL_ITEM_POPUP) { this.DoneSellItems(-1); return; } if (!this.AISettings.RS_SellItemAll && num2 >= this.AISettings.RS_SellItemAmount) { this.DoneSellItems(num2); return; } if (!this.MatchMapping(array[num], 3)) { this.DoneSellItems(num2); return; } this.WeightedClick(array[num], 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); this.CaptureFrame(); scene = this.SceneSearch(); if (scene != null && scene.SceneType != SceneType.SELL_ITEM_CONFIRM_POPUP) { this.DoneSellItems(-1); return; } int num6 = -1; for (int i = 5; i >= 0; i--) { if (this.MatchMapping(array2[i], 8)) { num6 = i + 1; break; } } int num7 = this.AISettings.RS_SellItemStars; if (num6 != -1 && num6 <= this.AISettings.RS_SellItemStars) { num2++; this.Log(string.Format("-- Item sold ({0})", num2), this.COLOR_SELL_ITEMS); this.WeightedClick(SellItemConfirmPopupPM.SellButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(1000); } else { num++; if (!flag) { num %= 2; } this.WeightedClick(SellItemConfirmPopupPM.NoButton, 1.0, 1.0, 1, 0, "left"); if (num == 0) { SevenKnightsCore.Sleep(500); this.ScrollItemPopup(true); SevenKnightsCore.Sleep(200); Bitmap frame = this.CaptureFrame(); scene = this.SceneSearch(); if (scene != null && scene.SceneType != SceneType.SELL_ITEM_POPUP) { this.DoneSellItems(-1); return; } using (Bitmap bitmap = this.CropFrame(frame, SellItemPopupPM.R_ScrollBarArea)) { ulong num8 = ImageHashing.AverageHash(bitmap); double num9 = ImageHashing.Similarity(num3, num8); double num10 = ImageHashing.Similarity(hash, num8); if (!flag && num3 != 0uL && num9 >= num4 && num10 >= num4) { Console.WriteLine("At last row"); flag = true; num = 2; } hash = num3; num3 = num8; } } } if (flag && num >= array.Length) { this.DoneSellItems(num2); return; } SevenKnightsCore.Sleep(1200); num5++; } }
private void SendHonors() { PixelMapping[] array = new PixelMapping[] { FriendsPM.FacebookTab, FriendsPM.InGameTab }; PixelMapping arg_34_0 = FriendsPM.Facebook_TabSelected; PixelMapping arg_3A_0 = FriendsPM.InGame_TabSelected; string[] array2 = new string[] { "Facebook friends", "In-Game friends" }; bool[] array3 = new bool[] { this.AISettings.RS_SendHonorsFacebook, this.AISettings.RS_SendHonorsInGame }; this.Log("Start sending honors", this.COLOR_HONOR); this.PushNote("Sending honors", "AI is sending honors to friends."); List<int> list = new List<int>(); for (int i = 0; i < array.Length; i++) { if (array3[i]) { list.Add(i); } } if (list.Count <= 0) { this.Log("Nothing to do", this.COLOR_HONOR); this.DoneSendHonors(); return; } foreach (int current in list) { if (this.Worker.CancellationPending) { return; } SevenKnightsCore.Sleep(500); this.Log(string.Format("Sending to {0}", array2[current]), this.COLOR_HONOR); PixelMapping mapping = array[current]; this.WeightedClick(mapping, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(1000); this.CaptureFrame(); Scene scene = this.SceneSearch(); if (scene != null && scene.SceneType != SceneType.FRIENDS) { this.DoneSendHonors(); return; } this.UpdateHonor(SceneType.FRIENDS); if (current == 0 && this.MatchMapping(FriendsPM.Facebook_NotConnected, 4)) { this.Log("Not connected to facebook", this.COLOR_HONOR); } else { this.WeightedClick(FriendsPM.SendAllButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(1000); this.CaptureFrame(); scene = this.SceneSearch(); if (scene == null || scene.SceneType != SceneType.SEND_HONOR_CONFIRM_POPUP) { SevenKnightsCore.Sleep(300); this.Escape(); } else { this.WeightedClick(SendHonorConfirmPopupPM.HonorsGiftButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); this.CaptureFrame(); while (!this.Worker.CancellationPending && this.MatchMapping(SendHonorSendingPopupPM.RedCross, 3)) { this.CaptureFrame(); SevenKnightsCore.Sleep(500); } SevenKnightsCore.Sleep(500); this.CaptureFrame(); scene = this.SceneSearch(); if (scene == null || scene.SceneType != SceneType.SEND_HONOR_FAILED_POPUP || scene.SceneType != SceneType.SEND_HONOR_FULL_POPUP || scene.SceneType != SceneType.SEND_HONOR_CONFIRM_POPUP) { SevenKnightsCore.Sleep(300); this.Escape(); } else { if (scene.SceneType == SceneType.SEND_HONOR_FULL_POPUP || scene.SceneType == SceneType.SEND_HONOR_CONFIRM_POPUP) { this.DoneSendHonors(); return; } if (scene.SceneType == SceneType.SEND_HONOR_FAILED_POPUP) { SevenKnightsCore.Sleep(300); this.Escape(); } } } } } this.DoneSendHonors(); }
private void SellHeroes() { PixelMapping[] array = new PixelMapping[] { SellHeroConfirmPopupPM.Star1, SellHeroConfirmPopupPM.Star2, SellHeroConfirmPopupPM.Star3, SellHeroConfirmPopupPM.Star4, SellHeroConfirmPopupPM.Star5, SellHeroConfirmPopupPM.Star6 }; PixelMapping[] array2 = new PixelMapping[] { HeroesPM.HeroCard1, HeroesPM.HeroCard2, HeroesPM.HeroCard3, HeroesPM.HeroCard4, HeroesPM.HeroCard5, HeroesPM.HeroCard6, HeroesPM.HeroCard7, HeroesPM.HeroCard8 }; PixelMapping[][] array3 = new PixelMapping[][] { new PixelMapping[] { SellHeroConfirmPopupPM.ElementWater_1, SellHeroConfirmPopupPM.ElementWater_2, SellHeroConfirmPopupPM.ElementWater_3 }, new PixelMapping[] { SellHeroConfirmPopupPM.ElementFire_1, SellHeroConfirmPopupPM.ElementFire_2, SellHeroConfirmPopupPM.ElementFire_3 }, new PixelMapping[] { SellHeroConfirmPopupPM.ElementLight_1, SellHeroConfirmPopupPM.ElementLight_2, SellHeroConfirmPopupPM.ElementLight_3 }, new PixelMapping[] { SellHeroConfirmPopupPM.ElementDark_1, SellHeroConfirmPopupPM.ElementDark_2, SellHeroConfirmPopupPM.ElementDark_3 }, new PixelMapping[] { SellHeroConfirmPopupPM.ElementRock_1, SellHeroConfirmPopupPM.ElementRock_2, SellHeroConfirmPopupPM.ElementRock_3 } }; this.Log("Start selling heroes", this.COLOR_SELL_HEROES); this.PushNote("Selling heroes", "AI will only sell the hero if the given condition is met."); if (!this.MatchMapping(HeroesPM.SortByBoxExpanded, 2)) { this.WeightedClick(HeroesPM.SortByBox, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(300); } this.WeightedClick(HeroesPM.SortByRank, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(300); if (!this.MatchMapping(HeroesPM.SortButtonAscending, 2)) { this.WeightedClick(HeroesPM.SortButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); } this.ScrollHeroCards(false); SevenKnightsCore.Sleep(500); bool flag = false; int num = 0; int num2 = 0; int num3 = 0; while (num3 < 100 && !this.Worker.CancellationPending) { this.CaptureFrame(); Scene scene = this.SceneSearch(); if (scene != null && scene.SceneType != SceneType.HEROES) { this.DoneSellHeroes(-1); return; } if (this.MatchMapping(HeroesPM.LastRow_1, 3) && this.MatchMapping(HeroesPM.LastRow_2, 3)) { flag = true; } if (!this.AISettings.RS_SellHeroAll && num2 >= this.AISettings.RS_SellHeroAmount) { this.DoneSellHeroes(-1); return; } this.WeightedClick(array2[num], 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(this.AIProfiles.ST_Delay); this.CaptureFrame(); scene = this.SceneSearch(); if (scene != null && scene.SceneType != SceneType.HERO_JOIN && scene.SceneType != SceneType.HERO_REMOVE) { this.DoneSellHeroes(-1); return; } if (this.IsHeroLevel30() && this.MatchMapping(HeroJoinPM.SellButton, 2)) { this.WeightedClick(HeroJoinPM.SellButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); this.CaptureFrame(); scene = this.SceneSearch(); if (scene != null && scene.SceneType != SceneType.SELL_HERO_CONFIRM_POPUP) { this.DoneSellHeroes(-1); return; } int num4 = -1; for (int i = 5; i >= 0; i--) { if (this.MatchMapping(array[i], 8)) { num4 = i + 1; break; } } int num5 = this.AISettings.RS_SellHeroStars; if (num4 == -1 || num4 > num5) { this.WeightedClick(SellHeroConfirmPopupPM.NoButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); this.DoneSellHeroes(num2); return; } PixelMapping[][] array4 = array3; for (int j = 0; j < array4.Length; j++) { PixelMapping[] array5 = array4[j]; if (this.MatchMapping(array5[0], 5) && this.MatchMapping(array5[1], 5) && this.MatchMapping(array5[2], 5)) { this.Log("-- Found element hero, skipping..", this.COLOR_SELL_HEROES); this.WeightedClick(SellHeroConfirmPopupPM.NoButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(300); this.Escape(); SevenKnightsCore.Sleep(500); } } num2++; this.Log(string.Format("-- Hero sold ({0})", num2), this.COLOR_SELL_HEROES); this.WeightedClick(SellHeroConfirmPopupPM.SellButton, 1.0, 1.0, 1, 0, "left"); this.LongSleep(2000, 1000); } else { this.Escape(); SevenKnightsCore.Sleep(500); num++; if (!flag) { num %= 4; } if (num == 0) { this.ScrollHeroCards(true); SevenKnightsCore.Sleep(800); } if (flag && num >= array2.Length) { this.DoneSellHeroes(num2); return; } } num3++; } return; }
private void CollectInbox() { PixelMapping[] array = new PixelMapping[] { InboxPM.HonorsTab, InboxPM.KeysTab, InboxPM.GoldTab, InboxPM.RubiesTab, InboxPM.TicketTab }; PixelMapping[] array2 = new PixelMapping[] { InboxPM.HonorsTabRedIcon, InboxPM.KeysTabRedIcon, InboxPM.GoldTabRedIcon, InboxPM.RubiesTabRedIcon, InboxPM.TicketTabRedIcon }; string[] array3 = new string[] { "Honors", "Keys", "Gold", "Rubies", "Tickets" }; bool[] array4 = new bool[] { this.AISettings.RS_InboxHonors, this.AISettings.RS_InboxKeys, this.AISettings.RS_InboxGold, this.AISettings.RS_InboxRubies, this.AISettings.RS_InboxTickets }; this.Log("Start collecting inbox", this.COLOR_INBOX); this.PushNote("Collecting inbox", "AI is collecting your inbox."); List<int> list = new List<int>(); for (int i = 0; i < array2.Length; i++) { if (this.MatchMapping(array2[i], 4) && array4[i]) { list.Add(i); } } foreach (int current in list) { this.Log(string.Format("- Got Tab: {0}", array3[current]), this.COLOR_INBOX); } if (list.Count <= 0) { this.Log("Nothing to collect", this.COLOR_INBOX); this.DoneCollectInbox(); return; } foreach (int current2 in list) { if (this.Worker.CancellationPending) { return; } SevenKnightsCore.Sleep(500); this.Log(string.Format("Collecting {0}", array3[current2]), this.COLOR_INBOX); PixelMapping mapping = array[current2]; this.WeightedClick(mapping, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(1000); this.CaptureFrame(); Scene scene = this.SceneSearch(); if (scene != null && scene.SceneType != SceneType.INBOX) { this.DoneCollectInbox(); return; } if (current2 == 4) { while (!this.Worker.CancellationPending) { this.CaptureFrame(); scene = this.SceneSearch(); if (scene != null && scene.SceneType != SceneType.INBOX) { this.DoneCollectInbox(); return; } if (!this.MatchMapping(InboxPM.AttachCollectButtonBackground, 4)) { this.DoneCollectInbox(); return; } this.WeightedClick(InboxPM.AttachCollectButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(1000); if (!this.HandleInboxCollected(current2)) { this.DoneCollectInbox(); return; } SevenKnightsCore.Sleep(500); } } else if (this.MatchMapping(InboxPM.CollectAllButtonBackground, 4)) { this.WeightedClick(InboxPM.CollectAllButton, 1.0, 1.0, 1, 0, "left"); this.LongSleep(1000, 1000); if (!this.HandleInboxCollected(current2)) { SevenKnightsCore.Sleep(300); this.Escape(); } } else { SevenKnightsCore.Sleep(300); this.Escape(); } } this.DoneCollectInbox(); }
private void CollectSpecialQuests() { PixelMapping[] array = new PixelMapping[] { SpecialQuestPM.DailyTab, SpecialQuestPM.WeeklyTab, SpecialQuestPM.MonthlyTab }; PixelMapping[] array2 = new PixelMapping[] { SpecialQuestPM.DailyAvailable, SpecialQuestPM.WeeklyAvailable, SpecialQuestPM.MonthlyAvailable }; string[] array3 = new string[] { "Daily", "Weekly", "Monthly" }; bool[] array4 = new bool[] { this.AISettings.RS_SpecialQuestsDaily, this.AISettings.RS_SpecialQuestsWeekly, this.AISettings.RS_SpecialQuestsMonthly }; this.Log("Start collecting special quests", this.COLOR_QUEST); this.PushNote("Collecting special quests", "AI is collecting special quests."); List<int> list = new List<int>(); for (int i = 0; i < array2.Length; i++) { if (this.MatchMapping(array2[i], 4) && array4[i]) { list.Add(i); } } foreach (int current in list) { this.Log(string.Format("- Got Tab: {0}", array3[current]), this.COLOR_QUEST); } if (list.Count <= 0) { this.Log("Nothing to collect", this.COLOR_QUEST); this.DoneCollectSpecialQuests(); return; } foreach (int current2 in list) { if (this.Worker.CancellationPending) { return; } SevenKnightsCore.Sleep(500); this.Log(string.Format("Collecting {0} quest", array3[current2]), this.COLOR_QUEST); PixelMapping mapping = array[current2]; this.WeightedClick(mapping, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(1000); this.CaptureFrame(); Scene scene = this.SceneSearch(); if (scene != null && scene.SceneType != SceneType.SPECIAL_QUEST) { this.DoneCollectSpecialQuests(); return; } while (!this.Worker.CancellationPending) { this.CaptureFrame(); scene = this.SceneSearch(); if (scene != null && scene.SceneType != SceneType.SPECIAL_QUEST) { this.DoneCollectSpecialQuests(); return; } if (!this.MatchMapping(SpecialQuestPM.CollectButtonBackground, 4)) { break; } this.WeightedClick(SpecialQuestPM.CollectButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); if (!this.HandleSpecialQuestsCollected(current2)) { break; } SevenKnightsCore.Sleep(500); } this.CaptureFrame(); scene = this.SceneSearch(); if (scene != null && scene.SceneType != SceneType.SPECIAL_QUEST) { this.DoneCollectSpecialQuests(); return; } if (this.MatchMapping(SpecialQuestPM.CollectMainButtonBackground, 4)) { this.WeightedClick(SpecialQuestPM.CollectMainButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(1000); if (!this.HandleSpecialQuestsCollected(current2)) { SevenKnightsCore.Sleep(300); this.Escape(); } } } this.DoneCollectSpecialQuests(); }
private void MainLoop(object sender, DoWorkEventArgs e) { bool flag = false; bool flag2 = false; bool flag3 = false; this.Log("Initializing AI..."); this.BlueStacks = new BlueStacks(); string errorMessage; if (!this.BlueStacks.Hook()) { errorMessage = "BlueStacks is not active or not yet initialized"; this.LogError(errorMessage); this.SynchronizationContext.Send(delegate (object callback) { MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); }, null); return; } if (this.BlueStacks.NeedResize() || this.BlueStacks.NeedRenderConfig()) { string text = "BlueStacks needs to be resized. Proceed?"; DialogResult dialogResult = MessageBox.Show(text, "Restart Required", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); if (dialogResult == DialogResult.OK) { string exePath = this.BlueStacks.GetExePath(); this.BlueStacks.RenderConfig(); this.BlueStacks.Resize(); this.BlueStacks.Kill(); SevenKnightsCore.Sleep(500); Process.Start(exePath); } return; } if (this.BlueStacks.IsGameInstalled()) { if (!this.BlueStacks.IsGameActive()) { this.Log("Launching Seven Knights..."); this.BlueStacks.LaunchGame(); this.LongSleep(3000, 1000); } this.InitLoop(); string value = null; while (!this.Worker.CancellationPending) { try { if (!this.AIProfiles.TMP_Paused && !this.AIProfiles.TMP_WaitingForKeys) { //if (!this.IsGameActive()) //{ // errorMessage = "Seven Knights is not active"; // this.LogError(errorMessage); // this.SynchronizationContext.Send(delegate (object callback) // { // MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); // }, null); // break; //} if (this.AIProfiles.ST_BlueStacksForceActive) { this.BlueStacks.MainWindowAS.BringToFront(); } int sT_Delay = this.AIProfiles.ST_Delay; SevenKnightsCore.Sleep(sT_Delay); this.IdleCounter += sT_Delay; this.HangCounter += sT_Delay; this.MapSelectCounter += sT_Delay; this.CooldownInbox -= sT_Delay; this.CooldownQuests -= sT_Delay; this.CooldownSendHonors -= sT_Delay; this.CooldownSellHeroes -= sT_Delay; this.CooldownSellItems -= sT_Delay; this.CaptureFrame(); if (this.BlueStacks.MainWindowAS.CurrentFrame != null) { this.UpdateHangFingerprint(); if (this.HangCounter >= 30000) { this.Log("Restarting Seven Knights", Color.DarkRed); this.PushNote("Restarting Seven Knights", "The game is not responding... AI will restart the game and continue."); this.HangCounter = 0; if (!this.BlueStacks.RestartGame(5)) { errorMessage = "Restart failed"; this.LogError(errorMessage); this.SynchronizationContext.Send(delegate (object callback) { MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); }, null); break; } if (this.PreviousObjective == Objective.HERO_MANAGEMENT) { this.ChangeObjective(Objective.HERO_MANAGEMENT); } this.IdleCounter = 0; this.LongSleep(10000, 1000); } Scene scene = this.SceneSearch(); bool flag4 = false; string text2; if (scene == null) { text2 = "..."; flag4 = true; } else { text2 = scene.SceneType.ToString(); } if (!text2.Equals(value)) { this.LogScene(text2); value = text2; } if (flag4) { if (this.MatchMapping(SharedPM.BackButton, 2) && this.MatchMapping(SharedPM.BackButtonAnchor, 2)) { this.LogScene("BACKABLE"); this.Escape(); } else if (this.IdleCounter >= 8000) { this.Escape(); this.IdleCounter = 0; } } else { if (scene.SceneType != SceneType.ADVENTURE_FIGHT && scene.SceneType != SceneType.TOWER_FIGHT && scene.SceneType != SceneType.ARENA_FIGHT && scene.SceneType != SceneType.RAID_FIGHT) { this.CurrentWave = 0; this.CurrentRaidTeam = 0; this.CurrentSkillSet = null; this.CurrentSkill = -1; this.PressedSkill = -1; } if (scene.SceneType != SceneType.MAP_SELECT) { this.MapSelectCounter = 0; } if (scene.SceneType != SceneType.ADVENTURE_START && scene.SceneType != SceneType.MAP_SELECT && scene.SceneType != SceneType.ADVENTURE_READY && scene.SceneType != SceneType.MAP_SELECT_POPUP) { this.MapCheckCount = 0; } this.IdleCounter = 0; switch (scene.SceneType) { case SceneType._ANDROID_POPUP: if (this.AIProfiles.ST_ReconnectInterruptEnable) { this.LongSleep(this.AIProfiles.ST_ReconnectInterruptInterval * 60000, 1000); if (!this.BlueStacks.RestartGame(5)) { this.SynchronizationContext.Send(delegate (object callback) { MessageBox.Show("BlueStacks restart failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); }, null); return; } } break; case SceneType._DIALOG: this.Escape(); SevenKnightsCore.Sleep(300); break; case SceneType.TAP_TO_PLAY: this.WeightedClick(TapToPlayPM.TapArea, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(1000); break; case SceneType.NOTICE: this.Escape(); break; case SceneType.ADS: this.Escape(); break; case SceneType.ADS_CLOSE: this.WeightedClick(AdsClosePM.CloseButton, 1.0, 1.0, 1, 0, "left"); break; case SceneType.CHECK_IN: this.Escape(); break; case SceneType.POPUP_1: this.Escape(); break; case SceneType.POPUP_2: this.Escape(); break; case SceneType.DISCONNECTED_POPUP: this.WeightedClick(DisconnectedPopupPM.OkButton, 1.0, 1.0, 1, 0, "left"); this.LongSleep(3000, 1000); break; case SceneType.WIFI_WARNING_POPUP: this.WeightedClick(WifiWarningPopupPM.OkButton, 1.0, 1.0, 1, 0, "left"); break; case SceneType.LOBBY: this.UpdateAdventureKeys(scene.SceneType); this.UpdateGold(scene.SceneType); this.UpdateRuby(scene.SceneType); this.UpdateHonor(scene.SceneType); this.UpdateTopaz(scene.SceneType); if (this.AISettings.RS_CollectLuckyChest && this.MatchMapping(LobbyPM.MaysLuckyChestAvailable_1, 4) && this.MatchMapping(LobbyPM.MaysLuckyChestAvailable_2, 4)) { this.WeightedClick(LobbyPM.MaysLuckyChestButton, 1.0, 1.0, 1, 0, "left"); } else if (this.AISettings.RS_CollectLuckyBox && this.EnableLuckyBox && this.MatchMapping(LobbyPM.LuckyBoxAvailable_1, 4) && this.MatchMapping(LobbyPM.LuckyBoxAvailable_2, 4)) { if (this.MatchMapping(LobbyPM.LuckyBoxLastOne_1, 2) && this.MatchMapping(LobbyPM.LuckyBoxLastOne_2, 2)) { this.StopLuckyBox(false); } else { this.WeightedClick(LobbyPM.LuckyBoxButton, 1.0, 1.0, 1, 0, "left"); } } else { if (this.IsSendHonorsEnabled() && this.CooldownSendHonors <= 0) { this.CooldownSendHonors = 1800000; if (this.IsSendHonorsEnabled() && this.CurrentObjective != Objective.COLLECT_QUESTS && this.CurrentObjective != Objective.COLLECT_INBOX && this.CurrentObjective != Objective.SEND_HONORS && this.CurrentObjective != Objective.BUY_KEYS && this.CurrentObjective != Objective.HERO_MANAGEMENT) { this.ChangeObjective(Objective.SEND_HONORS); } } else if (this.MatchMapping(LobbyPM.QuestAvailable, 3) && this.IsAnyQuestsEnabled() && this.CooldownQuests <= 0) { this.CooldownQuests = 1800000; if (this.IsAnyQuestsEnabled() && this.CurrentObjective != Objective.COLLECT_QUESTS && this.CurrentObjective != Objective.COLLECT_INBOX && this.CurrentObjective != Objective.SEND_HONORS && this.CurrentObjective != Objective.BUY_KEYS && this.CurrentObjective != Objective.HERO_MANAGEMENT) { this.ChangeObjective(Objective.COLLECT_QUESTS); } } else if (this.MatchMapping(LobbyPM.InboxAvailable, 3) && this.IsInboxEnabled() && this.CooldownInbox <= 0) { this.CooldownInbox = 1800000; if (this.IsInboxEnabled() && this.CurrentObjective != Objective.COLLECT_INBOX && this.CurrentObjective != Objective.COLLECT_QUESTS && this.CurrentObjective != Objective.SEND_HONORS && this.CurrentObjective != Objective.BUY_KEYS && this.CurrentObjective != Objective.HERO_MANAGEMENT) { this.ChangeObjective(Objective.COLLECT_INBOX); } } if (this.CurrentObjective == Objective.ADVENTURE || this.CurrentObjective == Objective.GOLD_CHAMBER || this.CurrentObjective == Objective.RAID) { this.WeightedClick(LobbyPM.AdventureButton, 1.0, 1.0, 1, 0, "left"); } else if (this.CurrentObjective == Objective.ARENA) { this.WeightedClick(LobbyPM.BattleButton, 1.0, 1.0, 1, 0, "left"); } else if (this.CurrentObjective == Objective.HERO_MANAGEMENT || this.CurrentObjective == Objective.SELL_HEROES) { this.WeightedClick(LobbyPM.HeroButton, 1.0, 1.0, 1, 0, "left"); } else if (this.CurrentObjective == Objective.BUY_KEYS) { this.WeightedClick(LobbyPM.ShopButton, 1.0, 1.0, 1, 0, "left"); } else if (this.CurrentObjective == Objective.COLLECT_INBOX) { this.WeightedClick(LobbyPM.InboxButton, 1.0, 1.0, 1, 0, "left"); } else if (this.CurrentObjective == Objective.COLLECT_QUESTS) { this.WeightedClick(LobbyPM.QuestButton, 1.0, 1.0, 1, 0, "left"); } else if (this.CurrentObjective == Objective.SEND_HONORS) { this.WeightedClick(LobbyPM.SocialButton, 1.0, 1.0, 1, 0, "left"); } else if (this.CurrentObjective == Objective.IDLE) { this.NextPossibleObjective(); } SevenKnightsCore.Sleep(300); } break; case SceneType.GIFT_REWARDS_POPUP: this.PushNote("Reward Received!", "AI has collected May's Lucky Chest or Lucky Box."); this.WeightedClick(SharedPM.Rewards_OkButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(300); break; case SceneType.GIFT_FULL_ITEM_POPUP: this.StopLuckyBox(true); break; case SceneType.GIFT_FULL_HERO_POPUP: this.StopLuckyBox(true); break; case SceneType.GIFT_FULL_HONOR_POPUP: this.StopLuckyBox(true); break; case SceneType.OUT_OF_LUCKY_BOX_POPUP: this.Escape(); break; case SceneType.MASTERY_POPUP: { if (this.MasteryChecked) { this.WeightedClick(MasteryPopupPM.CloseButton, 1.0, 1.0, 1, 0, "left"); return; } int num = -1; if (this.CurrentObjective == Objective.ADVENTURE) { num = (int)this.AISettings.AD_Mastery; } else if (this.CurrentObjective == Objective.GOLD_CHAMBER) { num = (int)this.AISettings.GC_Mastery; } else if (this.CurrentObjective == Objective.ARENA) { num = (int)this.AISettings.AR_Mastery; } if (num == 0 || num == -1) { this.WeightedClick(MasteryPopupPM.CloseButton, 1.0, 1.0, 1, 0, "left"); return; } PixelMapping[] array = new PixelMapping[] { MasteryPopupPM.Tab1, MasteryPopupPM.Tab2, MasteryPopupPM.Tab3 }; this.WeightedClick(array[num - 1], 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); this.MasteryChecked = true; this.WeightedClick(MasteryPopupPM.CloseButton, 1.0, 1.0, 1, 0, "left"); break; } case SceneType.ADVENTURE_MODES: this.UpdateAdventureKeys(scene.SceneType); this.UpdateGold(scene.SceneType); this.UpdateRuby(scene.SceneType); if (this.CurrentObjective == Objective.ADVENTURE) { this.WeightedClick(AdventureModesPM.AdventureButton, 1.0, 1.0, 1, 0, "left"); } else if (this.CurrentObjective == Objective.GOLD_CHAMBER) { this.WeightedClick(AdventureModesPM.CelestialTowerButton, 1.0, 1.0, 1, 0, "left"); } else if (this.CurrentObjective == Objective.RAID) { this.WeightedClick(AdventureModesPM.RaidButton, 1.0, 1.0, 1, 0, "left"); } else { this.Escape(); } break; case SceneType.MAP_SELECT: this.UpdateAdventureKeys(scene.SceneType); this.UpdateGold(scene.SceneType); this.UpdateRuby(scene.SceneType); if (this.MapSelectCounter >= 10000) { this.WeightedClick(SharedPM.BackButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); } else if (this.CurrentObjective == Objective.ADVENTURE) { World world = this.AISettings.AD_World; int stage = this.AISettings.AD_Stage; if (this.AISettings.AD_World == World.Sequencer) { Tuple<World, int> worldStageFromSequencer = this.GetWorldStageFromSequencer(); if (worldStageFromSequencer == null) { this.LogError("Stage sequence is empty"); this.NextPossibleObjective(); break; } world = worldStageFromSequencer.Item1; stage = worldStageFromSequencer.Item2; } if (world == World.MoonlitIsle || world == World.WesternEmpire || world == World.EasternEmpire) { if (this.MatchMapping(MapSelectPM.DifficultyBoxBorderLeft, 2) && this.MatchMapping(MapSelectPM.DifficultyBoxBorderRight, 2)) { this.WeightedClick(MapSelectPM.ContinentButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(1000); } this.SelectStageAisha(world, stage); } else { if (!this.MatchMapping(MapSelectPM.DifficultyBoxBorderLeft, 2) && !this.MatchMapping(MapSelectPM.DifficultyBoxBorderRight, 2)) { this.WeightedClick(MapSelectPM.ContinentButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(1000); } this.SelectStageAsgar(world, stage); } } else { this.Escape(); } break; case SceneType.MAP_SELECT_POPUP: this.Escape(); break; case SceneType.FULL_ITEM_POPUP: if (!flag) { this.PushNote("Item Full!", "Your inventory is full. AI will start selling them if enabled."); flag = true; } if (this.AISettings.RS_SellItems && this.CooldownSellItems <= 0) { if (this.CurrentObjective != Objective.SELL_ITEMS) { this.ChangeObjective(Objective.SELL_ITEMS); } this.WeightedClick(SharedPM.Full_SellButton, 1.0, 1.0, 1, 0, "left"); } else { this.WeightedClick(SharedPM.Full_ProceedButton, 1.0, 1.0, 1, 0, "left"); } SevenKnightsCore.Sleep(500); break; case SceneType.FULL_HERO_POPUP: if (this.AISettings.AD_StopOnFullHeroes) { this.Alert("Heroes Full"); this.Escape(); } if (!flag2) { this.PushNote("Hero Full!", "Your hero cards are full. AI will start selling them if enabled."); flag2 = true; } if (this.AISettings.RS_SellHeroes && this.CooldownSellHeroes <= 0) { if (this.CurrentObjective != Objective.SELL_HEROES) { this.ChangeObjective(Objective.SELL_HEROES); } this.WeightedClick(SharedPM.Full_SellButton, 1.0, 1.0, 1, 0, "left"); } else { this.WeightedClick(SharedPM.Full_ProceedButton, 1.0, 1.0, 1, 0, "left"); } SevenKnightsCore.Sleep(500); break; case SceneType.ADVENTURE_READY: if (this.CurrentObjective == Objective.ADVENTURE) { this.WeightedClick(AdventureReadyPM.ReadyButton, 1.0, 1.0, 1, 0, "left"); } else { this.WeightedClick(AdventureReadyPM.CloseButton, 1.0, 1.0, 1, 0, "left"); } break; case SceneType.ADVENTURE_START: this.UpdateAdventureKeys(scene.SceneType); this.UpdateGold(scene.SceneType); if (this.CurrentObjective == Objective.ADVENTURE) { World world2 = this.AISettings.AD_World; int stage2 = this.AISettings.AD_Stage; if (this.AISettings.AD_World == World.Sequencer) { Tuple<World, int> worldStageFromSequencer2 = this.GetWorldStageFromSequencer(); if (worldStageFromSequencer2 == null) { this.LogError("Stage sequence is empty"); this.NextPossibleObjective(); break; } world2 = worldStageFromSequencer2.Item1; stage2 = worldStageFromSequencer2.Item2; } if (this.AISettings.AD_Continuous || this.CheckMapNumber(world2, stage2) || this.MapCheckCount >= 3) { if (!this.CheckMastery(scene.SceneType)) { this.MasteryChecked = false; this.SelectTeam(SceneType.ADVENTURE_START); this.WeightedClick(SharedPM.PrepareFight_StartButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(300); } } else { this.MapCheckCount++; this.Escape(); SevenKnightsCore.Sleep(300); } } else if (this.CurrentObjective == Objective.HERO_MANAGEMENT) { this.WeightedClick(SharedPM.PrepareFight_ManageButton, 1.0, 1.0, 1, 0, "left"); } else { this.Escape(); } break; case SceneType.ADVENTURE_FIGHT: this.PerformFightTatics(scene.SceneType); break; case SceneType.ADVENTURE_LOST: this.AdventureAfterFight(); this.Log("Your team lost the battle [Adventure]", this.COLOR_DEATH); this.PushNote("You Lose! [Adventure]", "Your team has lost a battle. Continuing AI."); this.WeightedClick(AdventureLostPM.AdventureButton, 1.0, 1.0, 1, 0, "left"); break; case SceneType.VICTORY: for (int i = 0; i < 3; i++) { SevenKnightsCore.Sleep(500); this.WeightedClick(VictoryPM.TapToSkipArea, 1.0, 1.0, 1, 0, "left"); } break; case SceneType.ADVENTURE_LOOT_ITEM: case SceneType.ADVENTURE_LOOT_HERO: case SceneType.ADVENTURE_LOOT_GOLD: this.AdventureAfterFight(); SevenKnightsCore.Sleep(500); if (this.CurrentObjective == Objective.ADVENTURE) { if (this.AISettings.AD_Continuous && this.AISettings.AD_World != World.Sequencer) { this.WeightedClick(AdventureLootItemPM.NextZoneButton, 1.0, 1.0, 1, 0, "left"); } else if (this.AISettings.AD_World == World.None) { this.WeightedClick(AdventureLootItemPM.QuickStartButton, 1.0, 1.0, 1, 0, "left"); } else { this.WeightedClick(AdventureLootItemPM.AgainButton, 1.0, 1.0, 1, 0, "left"); } } else { this.WeightedClick(SharedPM.Loot_LobbyButton, 1.0, 1.0, 1, 0, "left"); } break; case SceneType.ADVENTURE_LOOT_HERO_SPECIAL: this.AdventureAfterFight(); SevenKnightsCore.Sleep(300); this.WeightedClick(SharedPM.Loot_LobbyButton, 1.0, 1.0, 1, 0, "left"); break; case SceneType.OUT_OF_KEYS_OFFER: if (!flag3) { this.PushNote("Out of Keys [Adventure]", "AI will buy more keys or play other modes while waiting."); flag3 = true; } if (this.CurrentObjective != Objective.BUY_KEYS) { this.ChangeObjective(Objective.BUY_KEYS); } this.Escape(); break; case SceneType.OUT_OF_KEYS_POPUP: if (!flag3) { this.PushNote("Out of Keys [Adventure]", "AI will buy more keys or play other modes while waiting."); flag3 = true; } this.HandleOutOfKey(scene.SceneType); break; case SceneType.TOWER_SELECT: this.UpdateTowerKeys(); if (this.CurrentObjective == Objective.GOLD_CHAMBER) { if (this.TowerKeys > 0) { this.WeightedClick(TowerSelectPM.GoldChamberButton, 1.0, 1.0, 1, 0, "left"); } else { this.NextPossibleObjective(); } } else { this.Escape(); } break; case SceneType.TOWER_START: this.UpdateTowerKeys(); if (this.CurrentObjective == Objective.GOLD_CHAMBER) { if (this.TowerKeys > 0) { if (!this.CheckMastery(scene.SceneType)) { this.MasteryChecked = false; this.SelectTeam(SceneType.TOWER_START); this.WeightedClick(TowerStartPM.StartButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(300); } } else { this.NextPossibleObjective(); } } else { this.Escape(); } break; case SceneType.TOWER_FIGHT: this.PerformFightTatics(scene.SceneType); break; case SceneType.TOWER_LOST: this.GoldChamberAfterFight(); this.Log("Your team lost the battle [Tower]", this.COLOR_DEATH); this.PushNote("You Lose! [Tower]", "Your team has lost a battle. Continuing AI."); this.WeightedClick(TowerLostPM.ReadyButton, 1.0, 1.0, 1, 0, "left"); break; case SceneType.GOLD_CHAMBER_LOOT: this.GoldChamberAfterFight(); if (this.CurrentObjective == Objective.GOLD_CHAMBER) { this.WeightedClick(GoldChamberLootPM.AgainButton, 1.0, 1.0, 1, 0, "left"); } else { this.WeightedClick(SharedPM.Loot_LobbyButton, 1.0, 1.0, 1, 0, "left"); } break; case SceneType.OUT_OF_SILVER_KEYS_POPUP: this.Escape(); this.NextPossibleObjective(); break; case SceneType.BATTLE_MODES: this.UpdateGold(scene.SceneType); this.UpdateRuby(scene.SceneType); this.UpdateHonor(scene.SceneType); if (this.CurrentObjective == Objective.ARENA) { this.WeightedClick(BattleModesPM.ArenaButton, 1.0, 1.0, 1, 0, "left"); } else { this.Escape(); } break; case SceneType.ARENA_READY: this.UpdateArenaKeys(); this.UpdateRuby(scene.SceneType); this.UpdateHonor(scene.SceneType); if (this.CurrentObjective == Objective.ARENA) { if (this.ArenaKeys > 0 || this.ArenaUseRuby()) { this.WeightedClick(ArenaReadyPM.ReadyButton, 1.0, 1.0, 1, 0, "left"); } else { this.NextPossibleObjective(); } } else { this.Escape(); } break; case SceneType.ARENA_START: this.UpdateArenaKeys(); this.UpdateRuby(scene.SceneType); this.UpdateHonor(scene.SceneType); if (this.CurrentObjective == Objective.ARENA) { bool flag5 = this.ArenaUseRuby(); if (this.ArenaKeys > 0 || flag5) { if (!this.CheckMastery(scene.SceneType)) { this.MasteryChecked = false; this.WeightedClick(ArenaStartPM.StartButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(300); } } else { this.NextPossibleObjective(); } } else { this.Escape(); } break; case SceneType.ARENA_FIGHT: this.PerformFightTatics(scene.SceneType); break; case SceneType.ARENA_END: if (this.MatchMapping(ArenaEndPM.GetStrongerButton, 2)) { this.Log("Arena Lose", this.COLOR_ARENA); this.ArenaAfterFight(false); } else { this.Log("Arena Victory", this.COLOR_ARENA); this.ArenaAfterFight(true); } if (this.CurrentObjective == Objective.ARENA) { this.WeightedClick(ArenaEndPM.QuickStartButton, 1.0, 1.0, 1, 0, "left"); } else { this.WeightedClick(ArenaEndPM.LobbyButton, 1.0, 1.0, 1, 0, "left"); } this.LongSleep(2000, 1000); break; case SceneType.ARENA_FULL_HONOR_POPUP: this.WeightedClick(ArenaFullHonorPopupPM.YesButton, 1.0, 1.0, 1, 0, "left"); break; case SceneType.OUT_OF_SWORDS_POPUP: if (this.ArenaUseRuby()) { this.Log(string.Format("Entering arena using Ruby ({0})", this.ArenaRubiesCount + 1), this.COLOR_ARENA); this.WeightedClick(OutOfSwordsPopupPM.EnterButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(1000); this.ArenaRubiesCount++; } else { this.Escape(); this.NextPossibleObjective(); } SevenKnightsCore.Sleep(1000); break; case SceneType.LEVEL_UP_DIALOG: this.Log("Player Level Up", this.COLOR_LEVEL_UP); if (this.AISettings.AD_Formation != Formation.None && this.AISettings.AD_HeroManagePositions != null && this.AISettings.AD_HeroManagePositions.Length > 0) { this.ChangeObjective(Objective.HERO_MANAGEMENT); } this.WeightedClick(LevelUpDialogPM.OkButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(300); break; case SceneType.LEVEL_30_DIALOG: case SceneType.LEVEL_30_MAX_DIALOG: this.Log("Hero Level 30", this.COLOR_LEVEL_30); if (this.AISettings.AD_Formation != Formation.None && this.AISettings.AD_HeroManagePositions != null && this.AISettings.AD_HeroManagePositions.Length > 0) { this.ChangeObjective(Objective.HERO_MANAGEMENT); } this.WeightedClick(Level30DialogPM.OkButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(300); break; case SceneType.HEROES: this.UpdateAdventureKeys(scene.SceneType); this.UpdateGold(scene.SceneType); this.UpdateRuby(scene.SceneType); if (this.CurrentObjective != Objective.HERO_MANAGEMENT && this.PreviousObjective != Objective.HERO_MANAGEMENT && this.CurrentObjective != Objective.SELL_HEROES && this.PreviousObjective != Objective.SELL_HEROES && this.AISettings.AD_Formation != Formation.None && this.AISettings.AD_HeroManagePositions != null && this.AISettings.AD_HeroManagePositions.Length > 0) { this.ChangeObjective(Objective.HERO_MANAGEMENT); } if (this.MatchMapping(HeroesPM.BlockingChatCloseButton, 2)) { this.WeightedClick(HeroesPM.BlockingChatCloseButton, 1.0, 1.0, 1, 0, "left"); } else if (this.CurrentObjective == Objective.HERO_MANAGEMENT) { if (this.AISettings.AD_ElementHeroesOnly) { if (this.MatchMapping(HeroesPM.ElementButton, 2)) { this.WeightedClick(HeroesPM.ElementButton, 1.0, 1.0, 1, 0, "left"); break; } } else if (!this.MatchMapping(HeroesPM.ElementButton, 2)) { this.WeightedClick(HeroesPM.ElementButton, 1.0, 1.0, 1, 0, "left"); break; } this.ManageHeroes(); } else if (this.CurrentObjective == Objective.SELL_HEROES) { if (!this.MatchMapping(HeroesPM.ElementButton, 2)) { this.WeightedClick(HeroesPM.ElementButton, 1.0, 1.0, 1, 0, "left"); } else { this.SellHeroes(); } } else { this.Escape(); } break; case SceneType.HEROES_SAME_TEAM_POPUP: this.Escape(); break; case SceneType.HERO_JOIN: this.Escape(); break; case SceneType.HERO_REMOVE: this.Escape(); break; case SceneType.RAID_DRAGON: this.PushNote("The dragon appears!", "AI will fight the dragon or ignore it depending on your settings."); if (this.AISettings.RD_Enable) { this.ChangeObjective(Objective.RAID); } this.WeightedClick(RaidDragonPM.TapArea, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); break; case SceneType.RAID_LOBBY: if (this.CurrentObjective == Objective.RAID) { if (this.EnableRaidRewards) { this.WeightedClick(RaidLobbyPM.DefeatedTab, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); this.CaptureFrame(); if (this.MatchMapping(RaidLobbyPM.EnterButton, 2)) { this.WeightedClick(RaidLobbyPM.EnterButton, 1.0, 1.0, 1, 0, "left"); } else { this.DoneRaid(); } } else { this.WeightedClick(RaidLobbyPM.NewTab, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); this.CaptureFrame(); if (this.MatchMapping(RaidLobbyPM.EnterButton, 2)) { this.WeightedClick(RaidLobbyPM.EnterButton, 1.0, 1.0, 1, 0, "left"); this.EnableRaidRewards = true; } else { this.DoneRaid(); } } } else { this.Escape(); } break; case SceneType.RAID_READY: if (this.CurrentObjective == Objective.RAID && (!this.AISettings.RD_EnableDragonLimit || this.ParseEntred() < this.AISettings.RD_DragonLimit) ) { this.WeightedClick(RaidReadyPM.ReadyButton, 1.0, 1.0, 1, 0, "left"); } else { this.Escape(); } break; case SceneType.RAID_START: if (this.CurrentObjective == Objective.RAID) { this.WeightedClick(RaidStartPM.StartButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(300); } else { this.Escape(); } break; case SceneType.RAID_FIGHT: this.PerformFightTatics(scene.SceneType); break; case SceneType.RAID_END: this.RaidAfterFight(); this.PushNote("Raid has ended!", "AI will collect the reward and if there is any."); this.WeightedClick(RaidEndPM.AgainButton, 1.0, 1.0, 1, 0, "left"); this.LongSleep(1000, 1000); break; case SceneType.RAID_REWARD: if (this.CurrentObjective == Objective.RAID) { if (this.MatchMapping(RaidRewardPM.RewardButtonRedIcon, 2)) { this.WeightedClick(RaidRewardPM.RewardButton, 1.0, 1.0, 1, 0, "left"); } else { this.DoneRaid(); } } else { this.Escape(); } break; case SceneType.RAID_REWARD_POPUP: this.DoneRaid(); break; case SceneType.RAID_REWARD_FAILED_POPUP: this.DoneRaid(); break; case SceneType.RAID_OUT_OF_KEYS_POPUP: if (!flag3) { this.PushNote("Out of Keys [Raid]", "AI will buy more keys or play other modes while waiting."); flag3 = true; } this.HandleOutOfKey(scene.SceneType); break; case SceneType.RAID_ALREADY_ENDED_POPUP: this.DoneRaid(); break; case SceneType.ENTER_RAID_AGAIN_POPUP: this.DoneRaid(); break; case SceneType.SELL_HERO_CONFIRM_POPUP: this.Escape(); break; case SceneType.SELL_ITEM_POPUP: if (this.AISettings.RS_SellItems) { if (this.CurrentObjective != Objective.SELL_ITEMS) { this.ChangeObjective(Objective.SELL_ITEMS); } this.SellItems(); } else { this.Escape(); } break; case SceneType.SELL_ITEM_CONFIRM_POPUP: this.Escape(); break; case SceneType.LOOT_HERO: this.Escape(); break; case SceneType.LOOT_ITEM: this.Escape(); break; case SceneType.SHOP: this.UpdateAdventureKeys(scene.SceneType); this.UpdateGold(scene.SceneType); this.UpdateRuby(scene.SceneType); this.UpdateHonor(scene.SceneType); if (this.CurrentObjective == Objective.BUY_KEYS) { this.BuyKeys(); } else { this.Escape(); } break; case SceneType.SHOP_BUY_POPUP: this.Escape(); break; case SceneType.SHOP_BUY_FAILED_POPUP: this.Escape(); break; case SceneType.SHOP_PURCHASE_COMPLETE_POPUP: this.Escape(); break; case SceneType.INBOX: this.UpdateAdventureKeys(scene.SceneType); this.UpdateGold(scene.SceneType); this.UpdateRuby(scene.SceneType); this.UpdateHonor(scene.SceneType); if (this.IsInboxEnabled()) { if (this.CurrentObjective != Objective.COLLECT_INBOX && this.PreviousObjective != Objective.COLLECT_INBOX) { this.ChangeObjective(Objective.COLLECT_INBOX); } if (this.CurrentObjective == Objective.COLLECT_INBOX) { this.CollectInbox(); } else { this.Escape(); } } else { this.Escape(); } break; case SceneType.INBOX_REWARDS_POPUP: this.WeightedClick(SharedPM.Rewards_OkButton, 1.0, 1.0, 1, 0, "left"); break; case SceneType.INBOX_COLLECT_FAILED_POPUP: this.Escape(); break; case SceneType.INBOX_SELECT_HERO: this.Escape(); break; case SceneType.QUEST_SELECT: if (this.CurrentObjective == Objective.COLLECT_QUESTS && this.IsAnyQuestsEnabled()) { bool flag6 = this.IsSpecialQuestsEnabled() && this.MatchMapping(QuestSelectPM.SpecialQuestAvailable, 4); bool flag7 = this.IsQuestsEnabled() && this.MatchMapping(QuestSelectPM.QuestAvailable, 4); if (this.CollectQuestsTotal == -1 || this.CollectQuestsCount == -1) { this.CollectQuestsCount = 0; this.CollectQuestsTotal = 0; if (flag6) { this.CollectQuestsTotal++; } if (flag7) { this.CollectQuestsTotal++; } } if (this.CollectQuestsCount == 0 && this.CollectQuestsTotal == 1) { if (flag6) { this.WeightedClick(QuestSelectPM.SpecialQuestButton, 1.0, 1.0, 1, 0, "left"); } else if (flag7) { this.WeightedClick(QuestSelectPM.QuestButton, 1.0, 1.0, 1, 0, "left"); } } else if (this.CollectQuestsCount == 0 && this.CollectQuestsTotal == 2) { this.WeightedClick(QuestSelectPM.SpecialQuestButton, 1.0, 1.0, 1, 0, "left"); } else { if (this.CollectQuestsCount != 1 || this.CollectQuestsTotal != 2) { this.DoneCollectAllQuests(); break; } this.WeightedClick(QuestSelectPM.QuestButton, 1.0, 1.0, 1, 0, "left"); } this.LongSleep(1000, 1000); } else { this.Escape(); } break; case SceneType.SPECIAL_QUEST: this.UpdateAdventureKeys(scene.SceneType); this.UpdateGold(scene.SceneType); this.UpdateRuby(scene.SceneType); this.UpdateHonor(scene.SceneType); if (this.CurrentObjective == Objective.COLLECT_QUESTS && this.IsSpecialQuestsEnabled()) { this.CollectSpecialQuests(); } else { this.Escape(); } break; case SceneType.QUEST: this.UpdateAdventureKeys(scene.SceneType); this.UpdateGold(scene.SceneType); this.UpdateRuby(scene.SceneType); this.UpdateHonor(scene.SceneType); if (this.CurrentObjective == Objective.COLLECT_QUESTS && this.IsQuestsEnabled()) { this.CollectQuests(); } else { this.Escape(); } break; case SceneType.QUEST_REWARDS_POPUP: this.WeightedClick(SharedPM.Rewards_OkButton, 1.0, 1.0, 1, 0, "left"); break; case SceneType.QUEST_COLLECT_FAILED_POPUP: this.Escape(); break; case SceneType.SOCIAL_SELECT: if (this.CurrentObjective == Objective.SEND_HONORS && this.IsSendHonorsEnabled()) { this.WeightedClick(SocialSelectPM.FriendsButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); } else { this.Escape(); } break; case SceneType.FRIENDS: this.UpdateAdventureKeys(scene.SceneType); this.UpdateGold(scene.SceneType); this.UpdateHonor(scene.SceneType); if (this.CurrentObjective == Objective.SEND_HONORS && this.IsSendHonorsEnabled()) { this.SendHonors(); } else { this.Escape(); } break; case SceneType.SEND_HONOR_SENDING_POPUP: this.Escape(); break; case SceneType.SEND_HONOR_FAILED_POPUP: this.WeightedClick(SendHonorFailedPopupPM.YellowTick, 1.0, 1.0, 1, 0, "left"); break; case SceneType.SEND_HONOR_CONFIRM_POPUP: this.Escape(); break; case SceneType.SEND_HONOR_FULL_POPUP: this.Escape(); break; } } } } else if (this.AIProfiles.TMP_WaitingForKeys) { Random rnd = new Random(); #if DEBUG if ((this.AISettings.AD_Enable && this.AdventureKeys >= 1 && rnd.Next(1, (int)this.AdventureKeyTime.TotalMinutes) == 1) || (this.AISettings.AR_Enable && this.ArenaKeys >= 1 && rnd.Next(1, (int)this.ArenaKeyTime.TotalMinutes) == 1) || (this.AISettings.GC_Enable && this.TowerKeys >= 1 && rnd.Next(1, (int)this.TowerKeyTime.TotalMinutes) == 1) || (this.AISettings.RD_Enable && this.AdventureKeys >= 1 && rnd.Next(1, (int)this.AdventureKeyTime.TotalMinutes) == 1)) #else if ((this.AISettings.AD_Enable && this.AdventureKeys >= 10 && rnd.Next(1, (int)this.AdventureKeyTime.TotalSeconds) == 1) || (this.AISettings.AR_Enable && this.ArenaKeys >= 4 && rnd.Next(1, (int)this.ArenaKeyTime.TotalSeconds) == 1) || (this.AISettings.GC_Enable && this.TowerKeys >= 4 && rnd.Next(1, (int)this.TowerKeyTime.TotalSeconds) == 1) || (this.AISettings.RD_Enable && this.AdventureKeys >= 10 && rnd.Next(1, (int)this.AdventureKeyTime.TotalSeconds) == 1)) #endif { int resumeIn = rnd.Next(1, 60); this.Log("Resuming in " + resumeIn + " seconds"); Sleep(resumeIn * 1000); this.BlueStacks.LaunchGame(); this.AIProfiles.TMP_WaitingForKeys = false; this.Log("Keys sufficiently Replenished. Resuming"); } } if (!this.AIProfiles.TMP_WaitingForKeys && this.AISettings.GB_WaitForKeys && ((!this.AISettings.AD_Enable && !this.AISettings.RD_Enable) || this.AdventureKeys == 0) && (!this.AISettings.AR_Enable || this.ArenaKeys == 0) && (!this.AISettings.GC_Enable || this.TowerKeys == 0)) { this.AIProfiles.TMP_WaitingForKeys = true; this.Log("Waiting for keys to replenish"); this.BlueStacks.TerminateGame(); } MousePos(); } catch (Exception ex) { this.LogError(ex.Message); this.LogError(ex.ToString()); } } this.OneSecTimer.Enabled = false; return; } errorMessage = "Seven Knights not installed in BlueStacks"; this.LogError(errorMessage); this.SynchronizationContext.Send(delegate (object callback) { MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); }, null); }
private void SelectStage(PixelMapping[][] anchorMappings, PixelMapping stageMapping, int pageDestIndex) { int num = this.SearchStage(anchorMappings); if (num > anchorMappings.Length - 1) { return; } if (num != pageDestIndex) { int num2 = this.FindShortestWorldPath(num, pageDestIndex, anchorMappings.Length); PixelMapping mapping = (num2 > 0) ? MapSelectPM.NextButton : MapSelectPM.PreviousButton; for (int i = 0; i < Math.Abs(num2); i++) { this.WeightedClick(mapping, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); } } SevenKnightsCore.Sleep(500); int num3 = this.SearchStage(anchorMappings); if (num3 == pageDestIndex) { this.SelectDifficulty(); SevenKnightsCore.Sleep(500); this.WeightedClick(stageMapping, 1.0, 1.0, 1, 0, "left"); } }
private void SelectStageAisha(World world, int stage) { PixelMapping[][] array = new PixelMapping[][] { new PixelMapping[] { MapSelectPM.World8_1Anchor_1, MapSelectPM.World8_1Anchor_2 }, new PixelMapping[] { MapSelectPM.World8_2Anchor_1, MapSelectPM.World8_2Anchor_2 }, new PixelMapping[] { MapSelectPM.World8_3Anchor_1, MapSelectPM.World8_3Anchor_2 }, new PixelMapping[] { MapSelectPM.World8_4Anchor_1, MapSelectPM.World8_4Anchor_2 }, new PixelMapping[] { MapSelectPM.World9_1Anchor_1, MapSelectPM.World9_1Anchor_2 }, new PixelMapping[] { MapSelectPM.World9_2Anchor_1, MapSelectPM.World9_2Anchor_2 }, new PixelMapping[] { MapSelectPM.World9_3Anchor_1, MapSelectPM.World9_3Anchor_2 }, new PixelMapping[] { MapSelectPM.World10_1Anchor_1, MapSelectPM.World10_1Anchor_2 }, new PixelMapping[] { MapSelectPM.World10_2Anchor_1, MapSelectPM.World10_2Anchor_2 } }; PixelMapping[][] stages = new PixelMapping[][] { new PixelMapping[] { MapSelectPM.World8_1Stage1, MapSelectPM.World8_1Stage2, MapSelectPM.World8_1Stage3, MapSelectPM.World8_1Stage4, MapSelectPM.World8_1Stage5, MapSelectPM.World8_2Stage6, MapSelectPM.World8_2Stage7, MapSelectPM.World8_2Stage8, MapSelectPM.World8_2Stage9, MapSelectPM.World8_2Stage10, MapSelectPM.World8_3Stage11, MapSelectPM.World8_3Stage12, MapSelectPM.World8_3Stage13, MapSelectPM.World8_3Stage14, MapSelectPM.World8_3Stage15, MapSelectPM.World8_4Stage16, MapSelectPM.World8_4Stage17, MapSelectPM.World8_4Stage18, MapSelectPM.World8_4Stage19, MapSelectPM.World8_4Stage20, }, new PixelMapping[] { MapSelectPM.World9_1Stage1, MapSelectPM.World9_1Stage2, MapSelectPM.World9_1Stage3, MapSelectPM.World9_1Stage4, MapSelectPM.World9_1Stage5, MapSelectPM.World9_2Stage6, MapSelectPM.World9_2Stage7, MapSelectPM.World9_2Stage8, MapSelectPM.World9_2Stage9, MapSelectPM.World9_2Stage10, MapSelectPM.World9_3Stage11, MapSelectPM.World9_3Stage12, MapSelectPM.World9_3Stage13, MapSelectPM.World9_3Stage14, MapSelectPM.World9_3Stage15 }, new PixelMapping[] { MapSelectPM.World10_1Stage1, MapSelectPM.World10_1Stage2, MapSelectPM.World10_1Stage3, MapSelectPM.World10_1Stage4, MapSelectPM.World10_1Stage5, MapSelectPM.World10_2Stage6, MapSelectPM.World10_2Stage7, MapSelectPM.World10_2Stage8, MapSelectPM.World10_2Stage9, MapSelectPM.World10_2Stage10 } }; int pageDestIndex = array.Length + 1; if (world == World.None) { this.WeightedClick(MapSelectPM.QuickStartButton, 1.0, 1.0, 1, 0, "left"); return; } PixelMapping stageMapping; if (world == World.MoonlitIsle) { stageMapping = stages[0][stage]; if (stage < 5) { pageDestIndex = 0; } else if (stage < 10) { pageDestIndex = 1; } else if (stage < 15) { pageDestIndex = 2; } else if (stage < 20) { pageDestIndex = 3; } } else if (world == World.WesternEmpire) { stageMapping = stages[1][stage]; if (stage < 5) { pageDestIndex = 4; } else if (stage < 10) { pageDestIndex = 5; } else if (stage < 15) { pageDestIndex = 6; } } else if (world == World.EasternEmpire) { stageMapping = stages[2][stage]; if (stage < 5) { pageDestIndex = 7; } else if (stage < 10) { pageDestIndex = 8; } } else { return; } this.SelectStage(array, stageMapping, pageDestIndex); }
private int SearchStage(PixelMapping[][] anchorMappings) { this.CaptureFrame(); int num = 0; for (int i = 0; i < anchorMappings.Length; i++) { PixelMapping[] array = anchorMappings[i]; if (this.MatchMapping(array[0], 3) && this.MatchMapping(array[1], 3)) { break; } num++; } return num; }
private void SelectDifficulty() { PixelMapping[] array = new PixelMapping[] { MapSelectPM.DifficultyBox, MapSelectPM.DifficultyBoxSelectEasy, MapSelectPM.DifficultyBoxSelectNormal, MapSelectPM.DifficultyBoxSelectHard }; Difficulty aD_Difficulty = this.AISettings.AD_Difficulty; PixelMapping mapping = array[(int)aD_Difficulty]; if (this.MatchMapping(MapSelectPM.DifficultyBoxExpanded, 2)) { this.WeightedClick(mapping, 1.0, 1.0, 1, 0, "left"); return; } if (aD_Difficulty != Difficulty.None) { this.WeightedClick(array[0], 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); this.WeightedClick(mapping, 1.0, 1.0, 1, 0, "left"); } }
//This Function accepts a PixelMapping and send through to MatchPixel. private bool MatchMapping(PixelMapping mapping, int tolerance = 2, bool log = false) { // If if either log paramater or the log property of the mapping it will send true. return this.MatchPixel(mapping.X, mapping.Y, mapping.Color, tolerance, log || mapping.Log); }
private void ManageHeroes() { this.HeroManageAttemps++; if (this.HeroManageAttemps > 3) { this.DoneManageHeroes(); return; } PixelMapping[] array = new PixelMapping[] { HeroesPM.TeamAButton, HeroesPM.TeamBButton, HeroesPM.TeamCButton }; PixelMapping[] array2 = new PixelMapping[] { HeroesPM.HeroCard1, HeroesPM.HeroCard2, HeroesPM.HeroCard3, HeroesPM.HeroCard4, HeroesPM.HeroCard5, HeroesPM.HeroCard6, HeroesPM.HeroCard7, HeroesPM.HeroCard8 }; PixelMapping[][] array3 = new PixelMapping[][] { new PixelMapping[] { HeroesPM.F2B3_1, HeroesPM.F2B3_2, HeroesPM.F2B3_3, HeroesPM.F2B3_4, HeroesPM.F2B3_5 }, new PixelMapping[] { HeroesPM.F3B2_1, HeroesPM.F3B2_2, HeroesPM.F3B2_3, HeroesPM.F3B2_4, HeroesPM.F3B2_5 }, new PixelMapping[] { HeroesPM.F1B4_1, HeroesPM.F1B4_2, HeroesPM.F1B4_3, HeroesPM.F1B4_4, HeroesPM.F1B4_5 }, new PixelMapping[] { HeroesPM.F4B1_1, HeroesPM.F4B1_2, HeroesPM.F4B1_3, HeroesPM.F4B1_4, HeroesPM.F4B1_5 } }; PixelMapping[][] array4 = new PixelMapping[][] { new PixelMapping[] { HeroesPM.F2B3_Finger_1, HeroesPM.F2B3_Finger_2, HeroesPM.F2B3_Finger_3, HeroesPM.F2B3_Finger_4, HeroesPM.F2B3_Finger_5 }, new PixelMapping[] { HeroesPM.F3B2_Finger_1, HeroesPM.F3B2_Finger_2, HeroesPM.F3B2_Finger_3, HeroesPM.F3B2_Finger_4, HeroesPM.F3B2_Finger_5 }, new PixelMapping[] { HeroesPM.F1B4_Finger_1, HeroesPM.F1B4_Finger_2, HeroesPM.F1B4_Finger_3, HeroesPM.F1B4_Finger_4, HeroesPM.F1B4_Finger_5 }, new PixelMapping[] { HeroesPM.F4B1_Finger_1, HeroesPM.F4B1_Finger_2, HeroesPM.F4B1_Finger_3, HeroesPM.F4B1_Finger_4, HeroesPM.F4B1_Finger_5 } }; Team aD_Team = this.AISettings.AD_Team; Formation aD_Formation = this.AISettings.AD_Formation; List<int> list = new List<int>(this.AISettings.AD_HeroManagePositions); if (aD_Formation == Formation.None || list == null) { this.DoneManageHeroes(); return; } if (this.HeroManageAttemps == 1) { this.Log("Start managing heroes", this.COLOR_HEROES_MANAGEMENT); this.PushNote("Start managing heroes", "AI will replace the team on the selected positions with lower level heroes"); } int num = aD_Formation - Formation.Front2Back3; PixelMapping[] array5 = array3[num]; PixelMapping[] array6 = array4[num]; if (aD_Team != Team.None) { this.WeightedClick(array[aD_Team - Team.A], 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(1000); this.CaptureFrame(); } this.Log("Checking each position for level 30...", this.COLOR_HEROES_MANAGEMENT); List<int> list2 = new List<int>(); List<int> list3 = new List<int>(); foreach (int current in list) { if (this.Worker.CancellationPending) { return; } this.WeightedClick(array5[current], 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(this.AIProfiles.ST_Delay); if (!this.ExpectingScene(SceneType.HERO_REMOVE, 30, 500)) { return; } if (this.IsHeroLevel30()) { this.Log(string.Format("- Got position: {0}", current + 1), this.COLOR_HEROES_MANAGEMENT); list2.Add(current); } if (this.Worker.CancellationPending) { return; } this.Escape(); SevenKnightsCore.Sleep(500); if (!this.ExpectingScene(SceneType.HEROES, 5, 500)) { return; } } SevenKnightsCore.Sleep(300); if (list2.Count <= 0) { this.Log("Nothing to manage", this.COLOR_HEROES_MANAGEMENT); this.DoneManageHeroes(); } else { if (!this.ExpectingScene(SceneType.HEROES, 5, 500)) { return; } this.HeroSortReset(true, true); this.Log("Finding heroes...", this.COLOR_HEROES_MANAGEMENT); bool flag = false; ulong num2 = 0uL; double num3 = 91.0; int num4 = 0; while (num4 < 100 && !this.Worker.CancellationPending) { bool flag2 = false; this.CaptureFrame(); Scene scene = this.SceneSearch(); if (!this.ExpectingScene(SceneType.HEROES, 5, 500)) { return; } if (this.MatchMapping(HeroesPM.LastRow_1, 3) && this.MatchMapping(HeroesPM.LastRow_2, 3)) { flag = true; } int num5 = 0; while (num5 < (flag ? 8 : 4) && !this.Worker.CancellationPending) { if (list2.Count == 0) { this.DoneManageHeroes(); return; } Rectangle r_HeroCard_Base = HeroesPM.R_HeroCard_Base; r_HeroCard_Base.X += HeroesPM.CARD_X_DELTA * num5; if (flag) { r_HeroCard_Base.Y += HeroesPM.CARD_Y_DELTA + HeroesPM.CARD_LAST_Y_DELTA; } SevenKnightsCore.Sleep(500); ulong num6 = 0uL; using (this.CaptureFrame()) { using (Bitmap bitmap2 = this.CropFrame(this.CaptureFrame(), r_HeroCard_Base)) { num6 = ImageHashing.AverageHash(bitmap2); double num7 = ImageHashing.Similarity(num2, num6); if (num2 != 0uL && num7 >= num3) { goto IL_B14; } } } goto IL_7A8; IL_B14: num5++; continue; IL_7A8: this.WeightedClick(array2[num5], 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); if (this.Worker.CancellationPending) { return; } if (!this.ExpectingScenes(new List<SceneType> { SceneType.HERO_JOIN, SceneType.HERO_REMOVE }, 5, 500)) { return; } this.CaptureFrame(); scene = this.SceneSearch(); if (scene.SceneType == SceneType.HERO_JOIN) { if (this.IsHeroLevel30()) { this.Log("No more heroes less than level 30", this.COLOR_HEROES_MANAGEMENT); this.Escape(); SevenKnightsCore.Sleep(300); this.CaptureFrame(); scene = this.SceneSearch(); if (this.AISettings.AD_ElementHeroesOnly) { this.DoneManageHeroes(); return; } if (this.MatchMapping(HeroesPM.ElementButton, 2)) { this.WeightedClick(HeroesPM.ElementButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(1000); num2 = 0uL; this.HeroSortReset(true, true); flag2 = true; break; } this.DoneManageHeroes(); return; } else { this.WeightedClick(HeroJoinPM.JoinButton, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); this.CaptureFrame(); scene = this.SceneSearch(); if (this.Worker.CancellationPending || scene == null || scene.SceneType != SceneType.HEROES) { return; } int num8 = -1; int num9 = 0; while (num9 < 5 && !this.Worker.CancellationPending) { this.CaptureFrame(); for (int i = 0; i < array6.Length; i++) { bool flag3 = true; for (int j = 0; j < array6.Length; j++) { if (i != j) { flag3 &= this.MatchMapping(array6[j], 3); } } if (this.MatchMapping(array6[i], 3) && !flag3) { num8 = i; break; } } if (num8 != -1) { break; } SevenKnightsCore.Sleep(100); num9++; } int num10; if (num8 != -1) { if (!list3.Contains(num8) && list2.Contains(num8)) { num10 = list2.IndexOf(num8); } else { if (num6 != 0uL) { num2 = num6; goto IL_B14; } goto IL_B14; } } else { num10 = 0; } int num11 = list2[num10]; this.WeightedClick(array5[num11], 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); if (!this.ExpectingScenes(new List<SceneType> { SceneType.HEROES_SAME_TEAM_POPUP, SceneType.HEROES }, 5, 500)) { return; } this.CaptureFrame(); scene = this.SceneSearch(); if (scene.SceneType == SceneType.HEROES_SAME_TEAM_POPUP) { if (num6 != 0uL) { num2 = num6; } this.Escape(); goto IL_B14; } if (scene.SceneType == SceneType.HEROES) { if (num6 != 0uL) { num2 = num6; } this.Log(string.Format("Replaced hero position: {0}", num11 + 1), this.COLOR_HEROES_MANAGEMENT); list2.RemoveAt(num10); list3.Add(num10); goto IL_B14; } goto IL_B14; } } else { if (scene.SceneType == SceneType.HERO_REMOVE) { this.Escape(); SevenKnightsCore.Sleep(500); goto IL_B14; } return; } } if (flag) { break; } if (!flag2) { this.ScrollHeroCards(true); SevenKnightsCore.Sleep(800); } num4++; } this.DoneManageHeroes(); return; } }
private void BuyKeys() { PixelMapping[] array = new PixelMapping[] { ShopPM.Key1Honor10, ShopPM.Key10Honor100 }; PixelMapping[] array2 = new PixelMapping[] { ShopPM.Key5Ruby10, ShopPM.Key10Ruby20, ShopPM.Key20Ruby35, ShopPM.Key40Ruby45, ShopPM.Key100Ruby100 }; this.Log("Start buying keys", this.COLOR_BUY_KEYS); this.PushNote("Buying keys", "AI will buy the keys with honors first, then with rubies."); this.WeightedClick(ShopPM.KeyTab, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); Scene scene; while (!this.Worker.CancellationPending && !this.MatchMapping(ShopPM.KeyTabSelected, 2)) { this.CaptureFrame(); scene = this.SceneSearch(); if (scene != null && scene.SceneType != SceneType.SHOP) { this.DoneBuyKeys(); return; } this.WeightedClick(ShopPM.KeyTab, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); } bool flag; if (this.IsBuyKeysHonors()) { this.Log(string.Format("Buy with honors ({0})", this.KeysBoughtHonors + 1), this.COLOR_BUY_KEYS); flag = true; } else { if (!this.IsBuyKeysRubies()) { this.Log("Nothing to buy", this.COLOR_BUY_KEYS); this.DoneBuyKeys(); return; } this.Log(string.Format("Buy with rubies ({0})", this.KeysBoughtRubies + 1), this.COLOR_BUY_KEYS); flag = false; } if (flag || (!flag && this.AISettings.RS_BuyKeyRubiesType == BuyKeyRubiesType.Key5Ruby10)) { for (int i = 0; i < 5; i++) { this.ScrollShopKeys(false); this.LongSleep(2000, 1000); this.CaptureFrame(); if (this.MatchMapping(ShopPM.KeyTabLeftMost, 3)) { break; } } } else { for (int j = 0; j < 5; j++) { this.ScrollShopKeys(true); this.LongSleep(2000, 1000); this.CaptureFrame(); if (this.MatchMapping(ShopPM.KeyTabRightMost, 3)) { break; } } } SevenKnightsCore.Sleep(300); PixelMapping mapping; if (flag) { int rS_BuyKeyHonorsType = (int)this.AISettings.RS_BuyKeyHonorsType; mapping = array[rS_BuyKeyHonorsType]; } else { int rS_BuyKeyRubiesType = (int)this.AISettings.RS_BuyKeyRubiesType; mapping = array2[rS_BuyKeyRubiesType]; } this.WeightedClick(mapping, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(300); this.CaptureFrame(); scene = this.SceneSearch(); if (scene != null && scene.SceneType == SceneType.SHOP_BUY_FAILED_POPUP) { string text = string.Format("Unable to buy keys using {0}", flag ? "honors" : "rubies"); this.Log(text, this.COLOR_BUY_KEYS); this.PushNote("Failed to buy keys", text + "."); } if (scene != null && scene.SceneType != SceneType.SHOP_BUY_POPUP) { this.DoneBuyKeys(); return; } this.WeightedClick(ShopBuyPopupPM.BuyButton, 1.0, 1.0, 1, 0, "left"); this.LongSleep(2000, 1000); this.CaptureFrame(); scene = this.SceneSearch(); if (scene != null && scene.SceneType != SceneType.SHOP_PURCHASE_COMPLETE_POPUP) { this.DoneBuyKeys(); return; } this.Log("Keys bought", this.COLOR_BUY_KEYS); this.WeightedClick(ShopPurchaseCompletePopupPM.OkButton, 1.0, 1.0, 1, 0, "left"); if (flag) { this.KeysBoughtHonors++; } else { this.KeysBoughtRubies++; } SevenKnightsCore.Sleep(500); this.DoneBuyKeys(); }
private void WeightedClick(PixelMapping mapping, double scale = 1.0, double density = 1.0, int numClicks = 1, int delay = 0, string button = "left") { this.BlueStacks.MainWindowAS.Click(mapping.X, mapping.Y, numClicks, delay, button); }
private void SelectStageAsgar(World world, int stage) { PixelMapping[][] anchorMappings = new PixelMapping[][] { new PixelMapping[] { MapSelectPM.World1Anchor_1, MapSelectPM.World1Anchor_2 }, new PixelMapping[] { MapSelectPM.World2Anchor_1, MapSelectPM.World2Anchor_2 }, new PixelMapping[] { MapSelectPM.World3Anchor_1, MapSelectPM.World3Anchor_2 }, new PixelMapping[] { MapSelectPM.World4Anchor_1, MapSelectPM.World4Anchor_2 }, new PixelMapping[] { MapSelectPM.World5Anchor_1, MapSelectPM.World5Anchor_2 }, new PixelMapping[] { MapSelectPM.World6Anchor_1, MapSelectPM.World6Anchor_2 }, new PixelMapping[] { MapSelectPM.World7Anchor_1, MapSelectPM.World7Anchor_2 } }; PixelMapping[][] array = new PixelMapping[][] { new PixelMapping[] { MapSelectPM.World1Stage1, MapSelectPM.World1Stage2, MapSelectPM.World1Stage3, MapSelectPM.World1Stage4, MapSelectPM.World1Stage5, MapSelectPM.World1Stage6, MapSelectPM.World1Stage7, MapSelectPM.World1Stage8, MapSelectPM.World1Stage9, MapSelectPM.World1Stage10 }, new PixelMapping[] { MapSelectPM.World2Stage1, MapSelectPM.World2Stage2, MapSelectPM.World2Stage3, MapSelectPM.World2Stage4, MapSelectPM.World2Stage5, MapSelectPM.World2Stage6, MapSelectPM.World2Stage7, MapSelectPM.World2Stage8, MapSelectPM.World2Stage9, MapSelectPM.World2Stage10 }, new PixelMapping[] { MapSelectPM.World3Stage1, MapSelectPM.World3Stage2, MapSelectPM.World3Stage3, MapSelectPM.World3Stage4, MapSelectPM.World3Stage5, MapSelectPM.World3Stage6, MapSelectPM.World3Stage7, MapSelectPM.World3Stage8, MapSelectPM.World3Stage9, MapSelectPM.World3Stage10 }, new PixelMapping[] { MapSelectPM.World4Stage1, MapSelectPM.World4Stage2, MapSelectPM.World4Stage3, MapSelectPM.World4Stage4, MapSelectPM.World4Stage5, MapSelectPM.World4Stage6, MapSelectPM.World4Stage7, MapSelectPM.World4Stage8, MapSelectPM.World4Stage9, MapSelectPM.World4Stage10 }, new PixelMapping[] { MapSelectPM.World5Stage1, MapSelectPM.World5Stage2, MapSelectPM.World5Stage3, MapSelectPM.World5Stage4, MapSelectPM.World5Stage5, MapSelectPM.World5Stage6, MapSelectPM.World5Stage7, MapSelectPM.World5Stage8, MapSelectPM.World5Stage9, MapSelectPM.World5Stage10 }, new PixelMapping[] { MapSelectPM.World6Stage1, MapSelectPM.World6Stage2, MapSelectPM.World6Stage3, MapSelectPM.World6Stage4, MapSelectPM.World6Stage5, MapSelectPM.World6Stage6, MapSelectPM.World6Stage7, MapSelectPM.World6Stage8, MapSelectPM.World6Stage9, MapSelectPM.World6Stage10 }, new PixelMapping[] { MapSelectPM.World7Stage1, MapSelectPM.World7Stage2, MapSelectPM.World7Stage3, MapSelectPM.World7Stage4, MapSelectPM.World7Stage5, MapSelectPM.World7Stage6, MapSelectPM.World7Stage7, MapSelectPM.World7Stage8, MapSelectPM.World7Stage9, MapSelectPM.World7Stage10 } }; if (world == World.None) { this.WeightedClick(MapSelectPM.QuickStartButton, 1.0, 1.0, 1, 0, "left"); return; } int num = world - World.MysticWoods; PixelMapping stageMapping = array[num][stage]; this.SelectStage(anchorMappings, stageMapping, num); }
private void CollectQuests() { PixelMapping[] array = new PixelMapping[] { QuestPM.BattleTab, QuestPM.HeroTab, QuestPM.ItemTab, QuestPM.SocialTab }; PixelMapping[] array2 = new PixelMapping[] { QuestPM.BattleAvailable, QuestPM.HeroAvailable, QuestPM.ItemAvailable, QuestPM.SocialAvailable }; string[] array3 = new string[] { "Battle", "Hero", "Item", "Social" }; bool[] array4 = new bool[] { this.AISettings.RS_QuestsBattle, this.AISettings.RS_QuestsHero, this.AISettings.RS_QuestsItem, this.AISettings.RS_QuestsSocial }; this.Log("Start collecting quests", this.COLOR_QUEST); this.PushNote("Collecting quests", "AI is collecting quests."); List<int> list = new List<int>(); for (int i = 0; i < array2.Length; i++) { if (this.MatchMapping(array2[i], 4) && array4[i]) { list.Add(i); } } foreach (int current in list) { this.Log(string.Format("- Got Tab: {0}", array3[current]), this.COLOR_QUEST); } if (list.Count <= 0) { this.Log("Nothing to collect", this.COLOR_QUEST); this.DoneCollectQuests(); return; } foreach (int current2 in list) { if (this.Worker.CancellationPending) { return; } SevenKnightsCore.Sleep(500); this.Log(string.Format("Collecting {0} quest", array3[current2]), this.COLOR_QUEST); PixelMapping mapping = array[current2]; this.WeightedClick(mapping, 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(1000); this.CaptureFrame(); Scene scene = this.SceneSearch(); if (scene != null && scene.SceneType != SceneType.QUEST) { this.DoneCollectQuests(); return; } if (this.MatchMapping(QuestPM.CollectAllButtonBackground, 4)) { this.WeightedClick(QuestPM.CollectAllButton, 1.0, 1.0, 1, 0, "left"); this.LongSleep(1000, 1000); while (!this.Worker.CancellationPending && this.MatchMapping(QuestPM.CollectAllButtonBackground, 4)) { this.CaptureFrame(); SevenKnightsCore.Sleep(500); } SevenKnightsCore.Sleep(1000); this.CaptureFrame(); scene = this.SceneSearch(); if (scene == null || scene.SceneType != SceneType.QUEST_REWARDS_POPUP || scene.SceneType != SceneType.LOOT_HERO || scene.SceneType != SceneType.LOOT_ITEM) { SevenKnightsCore.Sleep(300); this.Escape(); } } } this.DoneCollectQuests(); }
private void SelectTeam(SceneType sceneType) { Team team = Team.None; PixelMapping[] array = new PixelMapping[] { SharedPM.PrepareFight_TeamAButton, SharedPM.PrepareFight_TeamBButton, SharedPM.PrepareFight_TeamCButton }; if (sceneType != SceneType.ADVENTURE_START) { if (sceneType == SceneType.TOWER_START) { team = this.AISettings.GC_Team; } } else { team = this.AISettings.AD_Team; } if (team == Team.None) { return; } this.WeightedClick(array[team - Team.A], 1.0, 1.0, 1, 0, "left"); SevenKnightsCore.Sleep(500); }
private PixelMapping[][] CreateQueueMappingSet(bool towerFight = false) { PixelMapping[][] result; if (towerFight) { result = new PixelMapping[][] { new PixelMapping[] { TowerFightPM.Skill1_Q1_1, TowerFightPM.Skill1_Q1_2 }, new PixelMapping[] { TowerFightPM.Skill2_Q1_1, TowerFightPM.Skill2_Q1_2 }, new PixelMapping[] { TowerFightPM.Skill3_Q1_1, TowerFightPM.Skill3_Q1_2 }, new PixelMapping[] { TowerFightPM.Skill4_Q1_1, TowerFightPM.Skill4_Q1_2 }, new PixelMapping[] { TowerFightPM.Skill5_Q1_1, TowerFightPM.Skill5_Q1_2 }, new PixelMapping[] { TowerFightPM.Skill6_Q1_1, TowerFightPM.Skill6_Q1_2 }, new PixelMapping[] { TowerFightPM.Skill7_Q1_1, TowerFightPM.Skill7_Q1_2 }, new PixelMapping[] { TowerFightPM.Skill8_Q1_1, TowerFightPM.Skill8_Q1_2 }, new PixelMapping[] { TowerFightPM.Skill9_Q1_1, TowerFightPM.Skill9_Q1_2 }, new PixelMapping[] { TowerFightPM.Skill10_Q1_1, TowerFightPM.Skill10_Q1_2 } }; } else { result = new PixelMapping[][] { new PixelMapping[] { SharedPM.Fight_Skill1_Q1_1, SharedPM.Fight_Skill1_Q1_2 }, new PixelMapping[] { SharedPM.Fight_Skill2_Q1_1, SharedPM.Fight_Skill2_Q1_2 }, new PixelMapping[] { SharedPM.Fight_Skill3_Q1_1, SharedPM.Fight_Skill3_Q1_2 }, new PixelMapping[] { SharedPM.Fight_Skill4_Q1_1, SharedPM.Fight_Skill4_Q1_2 }, new PixelMapping[] { SharedPM.Fight_Skill5_Q1_1, SharedPM.Fight_Skill5_Q1_2 }, new PixelMapping[] { SharedPM.Fight_Skill6_Q1_1, SharedPM.Fight_Skill6_Q1_2 }, new PixelMapping[] { SharedPM.Fight_Skill7_Q1_1, SharedPM.Fight_Skill7_Q1_2 }, new PixelMapping[] { SharedPM.Fight_Skill8_Q1_1, SharedPM.Fight_Skill8_Q1_2 }, new PixelMapping[] { SharedPM.Fight_Skill9_Q1_1, SharedPM.Fight_Skill9_Q1_2 }, new PixelMapping[] { SharedPM.Fight_Skill10_Q1_1, SharedPM.Fight_Skill10_Q1_2 } }; } return result; }
private bool IsSelectedMastery(SceneType sceneType) { PixelMapping[] array = new PixelMapping[] { SharedPM.PrepareFight_Mastery_1, SharedPM.PrepareFight_Mastery_2, SharedPM.PrepareFight_Mastery_3 }; PixelMapping[] array2 = new PixelMapping[] { ArenaStartPM.Mastery_1, ArenaStartPM.Mastery_2, ArenaStartPM.Mastery_3 }; int tolerance = 3; int num = -1; PixelMapping[] array3 = null; if (sceneType != SceneType.ADVENTURE_START) { if (sceneType != SceneType.TOWER_START) { if (sceneType == SceneType.ARENA_START) { num = (int)this.AISettings.AR_Mastery; array3 = array2; } } else { num = (int)this.AISettings.GC_Mastery; array3 = array; } } else { num = (int)this.AISettings.AD_Mastery; array3 = array; } if (num < 1 || num > 3) { return true; } int num2 = num - 1; bool flag = this.MatchMapping(array3[num2], tolerance); if (flag) { return true; } int num3 = 0; PixelMapping[] array4 = array3; for (int i = 0; i < array4.Length; i++) { PixelMapping arg_117_0 = array4[i]; if (num3 != num2) { bool flag2 = this.MatchMapping(array3[num3], tolerance); if (flag2) { return false; } num3++; } } return false; }