Example #1
0
        public static bool checkForLeagueEnd()
        {
            // Does anything happen when you get put in a better league? Gonna have to test that.
            // If not, this should work already.

            Bitmap league_end_label = BotHelper.getResourceByName("label_league_over");

            Point labelPoint = ImageRecognition.getPictureLocation(comparePic, league_end_label);

            if (labelPoint != pNull)
            {
                // League ended. We gotta press "Claim" now and open that chest. :)
                BotHelper.randomDelay(1000, 100);

                Bitmap claimButton = BotHelper.getResourceByName("button_claim_onend");
                Point  claimPoint  = ImageRecognition.getPictureLocation(comparePic, claimButton);
                if (claimPoint != pNull)
                {
                    ADBHelper.simulateClick(claimPoint);
                    BotHelper.randomDelay(1000, 100);
                    ChestLogic.openChest();
                }
                else
                {
                    BotHelper.Log("Couldn't find claim button for leagueEnd. Returning to regular duty.");
                }

                return(true);
            }

            return(false);
        }
Example #2
0
        public static void openChest()
        {
            for (int i = 0; i < 16; i++)
            {
                // just to make sure it'll still be randomized...
                ADBHelper.simulateClick(new Point(rnd.Next(270 - 50, 270 + 50), rnd.Next(200 - 50, 200 + 50))); //Click anywhere to unbox
                BotHelper.randomDelay(200, 20);
            }

            ADBHelper.simulateClick(ImageRecognition.getRandomLoc(BotHelper.getResourceByName("button_collect_prizes"), 0.901f));

            // Check for Bonus item
            BotHelper.randomDelay(4000, 100); // it might take a second or two for the bonus chest to appear, better be safe than sorry
            comparePic = ADBHelper.getScreencap();
            Point bonusLabel = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("label_bonus")).FirstOrDefault();

            if (bonusLabel.X != 0 && bonusLabel.Y != 0)
            {
                // Bonus item, yay!
                Point watchButton = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("button_watch"), 0.901f).FirstOrDefault();
                if (watchButton.X != 0 && watchButton.Y != 0)
                {
                    // Ugh, they want us to watch an ad. Close the window.
                    Point closeButton = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("button_cancel"), 0.901f).FirstOrDefault();
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(closeButton, BotHelper.getResourceByName("button_cancel")));
                }
                else
                {
                    ADBHelper.simulateClick(new Point(rnd.Next(270 - 50, 270 + 50), rnd.Next(200 - 50, 200 + 50))); //Click anywhere to unbox
                    BotHelper.randomDelay(300, 20);
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(BotHelper.getResourceByName("button_collect_prizes"), 0.901f));
                }
            }
        }
Example #3
0
 public List <Info_Devices> GetDevices2_Running()
 {
     try
     {
         int                 j              = 0;
         List <string>       list_adb_id    = ADBHelper.GetDevices();
         List <Info_Devices> listLDPlayer   = new List <Info_Devices>();
         List <string>       device_running = GetDevices_Running();
         string[]            arr            = ExecuteLD_Result("list2").Trim().Split('\n');
         for (int i = 0; i < arr.Length; i++)
         {
             Info_Devices devices = new Info_Devices();
             string[]     aDetail = arr[i].Trim().Split(',');
             devices.index = int.Parse(aDetail[0]);
             devices.name  = aDetail[1];
             if (device_running.Contains(devices.name))
             {
                 devices.adb_id = list_adb_id[j];
                 listLDPlayer.Add(devices);
                 j++;
             }
         }
         return(listLDPlayer);
     }
     catch
     {
         return(new List <Info_Devices>());
     }
     //System.Windows.Forms.MessageBox.Show(string.Join("\n", arr));
 }
Example #4
0
        public static void doLogic()
        {
            if (checkReconnect())
            {
                int reconnectTime = Settings.getInstance().reconnectTime;
                BotHelper.Log("Reconnect Button found. Pressing it in " + reconnectTime + " minutes.");

                int sleepTime = 0;
                if (reconnectTime != 0)
                {
                    sleepTime = reconnectTime * 1000 * 60;
                }
                else
                {
                    sleepTime = 5000; //wait 5 seconds anyways, just to be sure
                }
                System.Threading.Thread.Sleep(sleepTime);

                Bitmap button_reconnect = BotHelper.getResourceByName("button_reconnect");

                Point reconnectButton = ImageRecognition.getPictureLocation(button_reconnect, 0.90f);
                ADBHelper.simulateClick(ImageRecognition.getRandomLoc(reconnectButton, button_reconnect));

                BotHelper.Log("Reconnect Button pressed.");
            }
            else
            {
                BotHelper.Log("Reconnect Button check completed; Button not found.", true, true);
            }
        }
Example #5
0
        private static void openClosestChest()
        {
            Point closestChest = getClosestChest();

            // The sponsor chest is the smallest one, so we use this for our random location algorithm to make sure won't miss a chest
            ADBHelper.simulateClick(ImageRecognition.getRandomLoc(closestChest, BotHelper.getResourceByName("chest_sponsor")));
            BotHelper.randomDelay(5000, 50); // it takes some time to open a chest sometimes
            openChest();
        }
Example #6
0
        //IMG OpenCV
        public void Tap_Img(string deviceID, Bitmap ImgFind)
        {
            Bitmap bm     = (Bitmap)ImgFind.Clone();
            var    screen = ADBHelper.ScreenShoot(deviceID);
            var    Point  = ImageScanOpenCV.FindOutPoint(screen, bm);

            if (Point != null)
            {
                ADBHelper.Tap(deviceID, Point.Value.X, Point.Value.Y);
                return;
            }
            //MessageBox.Show("Tìm không ra");
        }
Example #7
0
        public static void doLogic()
        {
            BotHelper.randomDelay(1000, 100); //make sure to screen is cleared from previous tasks, just in case. Will probably be removed after some testing.
            currentlyUnlocking = true;
            comparePic         = ImageRecognition.CaptureApplication();

            currentlyUnlocking = isChestUnlocking();

            if (chestsReady())
            {
                BotHelper.Log("Completed box found!");
                openClosestChest();
            }

            if (!currentlyUnlocking)
            {
                BotHelper.Log("There's no box being unlocked right now, unlocking");
                List <Point> regularBoxes = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("chest_regular"));
                List <Point> superBoxes   = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("chest_super"));

                Point firstReg = regularBoxes.FirstOrDefault();
                Point firstSup = superBoxes.FirstOrDefault();

                if (firstReg.X != 0 && firstReg.Y != 0)
                {
                    // Open a regular box
                    BotHelper.Log(" regular box", false);
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(firstReg, BotHelper.getResourceByName("chest_regular")));
                    BotHelper.randomDelay(1000, 100);
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(BotHelper.getResourceByName("button_unlock")));
                    BotHelper.randomDelay(1000, 100);
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(BotHelper.getResourceByName("button_cancel"), 0.901f));
                }
                else if (firstSup.X != 0 && firstSup.Y != 0)
                {
                    // Open a super box
                    BotHelper.Log(" super box", false);
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(firstSup, BotHelper.getResourceByName("chest_super")));
                    BotHelper.randomDelay(1000, 100);
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(BotHelper.getResourceByName("button_unlock")));
                    BotHelper.randomDelay(1000, 100);
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(BotHelper.getResourceByName("button_cancel"), 0.901f));
                }
                else
                {
                    BotHelper.Log(" ...nevermind. No boxes found.", false);
                }
            }

            BotHelper.Log("Finished ChestLogic!");
        }
Example #8
0
        private static System.Drawing.Point?GetPoint(string id, Bitmap img)
        {
            var    screen  = ADBHelper.ScreenShoot(id, false);
            Bitmap tmp_img = (Bitmap)img.Clone();
            Bitmap tmp_scr = (Bitmap)screen.Clone();
            var    point   = ImageScanOpenCV.FindOutPoint(tmp_scr, tmp_img);

            return(point);
            //var aa = ImageScanOpenCV.Find(screen, D_FLAG);
            //if (aa != null)
            //{
            //    aa.Save("aaa.png");
            //}
        }
Example #9
0
        // Check if we defended, if yes, click that filthy "Claim" button that's preventing us from clicking "QUICK FIGHT" ;)
        public static bool checkDefense()
        {
            Helper.BotHelper.Log("Successful defense check", true, true);
            Bitmap button_claim = BotHelper.getResourceByName("button_claim");
            Point  claimPoint   = ImageRecognition.getPictureLocation(button_claim);

            if (claimPoint != pNull)
            {
                ADBHelper.simulateClick(ImageRecognition.getRandomLoc(claimPoint, button_claim));
                BotHelper.Log("We defended. Free coins! :)");
                BotHelper.randomDelay(1200, 100);
                return(true);
            }
            return(false);
        }
Example #10
0
        // Check if somebody got an instant promotion, because that window will be blocking the bot even after a restart
        public static bool checkInstantPromo()
        {
            Bitmap button_ok = BotHelper.getResourceByName("button_ok");

            Helper.BotHelper.Log("Instant Promo Check", true, true);
            Point okPoint = ImageRecognition.getPictureLocation(comparePic, button_ok);

            if (okPoint != pNull)
            {
                ADBHelper.simulateClick(ImageRecognition.getRandomLoc(okPoint, button_ok));
                BotHelper.Log("Someone got instant promoted.");
                BotHelper.randomDelay(1200, 100);
                return(true);
            }
            return(false);
        }
Example #11
0
        //Attack Logic
        public static void doLogic()
        {
            if (logicErrors >= 5)
            {
                BotHelper.Log("Too many errors. Restarting CATS.");
                ADBHelper.stopCATS();
                BotHelper.randomDelay(1000, 5);
                ADBHelper.startCATS();
                BotHelper.Log("Waiting for CATS to restart. Waiting 30s.");
                BotHelper.randomDelay(30000, 5);
            }

            if (searchDuell())
            {
                if (waitDuell())
                {
                    if (startDuell())
                    {
                        BotHelper.Log("AttackLogic successfully completed.");
                        logicErrors = 0;
                    }
                    else
                    {
                        BotHelper.Log("AttackLogic failed during startDuell");
                        logicErrors++;
                    }
                }
                else
                {
                    BotHelper.Log("AttackLogic failed during waitDUell");
                    logicErrors++;
                }
            }
            else
            {
                BotHelper.Log("AttackLogic failed during searchDuell");
                BotHelper.Log("Please make sure that your games language is set to English and that MEmu is set to 1280x720 in windowed mode.");
                logicErrors++;
                Thread.Sleep(5000); //give the user time to see this message :P
            }

            if (logicErrors > 0)
            {
                BotHelper.Log("We had " + logicErrors + " errors in a row during AttackLogic, restarting at 5 errors");
            }
        }
Example #12
0
 public static void doLogic()
 {
     comparePic = ADBHelper.getScreencap();
     if (checkDefense())
     {
         comparePic = ADBHelper.getScreencap();                 // update the screen if needed
     }
     if (checkForLeagueEnd())
     {
         comparePic = ADBHelper.getScreencap();                      // update the screen if needed
     }
     if (checkForChampionshipEnd())
     {
         comparePic = ADBHelper.getScreencap();                            // update the screen if needed
     }
     if (checkForChestInForeground())
     {
         comparePic = ADBHelper.getScreencap();                              // update the screen if needed
     }
     checkInstantPromo();
 }
Example #13
0
        // Try to find the "Quick Fight" button and click on it.
        public static bool searchDuell()
        {
            Bitmap button_fight = BotHelper.getResourceByName("button_fight");

            BotHelper.Log("Attempting to press the Duell button", true, true);
            //BotHelper.setDebugPic(ImageRecognition.CaptureApplication(BotHelper.memu));
            //BotHelper.setDebugPic2(ImageRecognition.ConvertToFormat(Properties.Resources.button_fight, System.Drawing.Imaging.PixelFormat.Format24bppRgb, true));
            //return false;
            Point fightPoint = ImageRecognition.getPictureLocation(button_fight);

            if (fightPoint != pNull)
            {
                BotHelper.Log("Button found at: X = " + fightPoint.X + "; Y = " + fightPoint.Y, true, true);
                ADBHelper.simulateClick(ImageRecognition.getRandomLoc(fightPoint, button_fight));
                return(true);
            }
            else
            {
                BotHelper.Log("Could not find the quick fight button. :/", true, false);
                return(false);
            }
        }
Example #14
0
        public static bool checkForChampionshipEnd()
        {
            // This should work as long as you don't get promoted. If you happen to be promoted, the bot will probably be stuck at the sticker selection.

            Bitmap league_end_label = BotHelper.getResourceByName("label_championship_over");
            Point  labelPoint       = ImageRecognition.getPictureLocation(comparePic, league_end_label);

            if (labelPoint != pNull)
            {
                // Championship ended. We gotta press "Claim" now and open that chest. :)
                BotHelper.randomDelay(1000, 100);

                Bitmap claimButton = BotHelper.getResourceByName("button_claim_onend");
                Point  claimPoint  = ImageRecognition.getPictureLocation(comparePic, claimButton);
                if (claimPoint != pNull)
                {
                    ADBHelper.simulateClick(claimPoint);
                    BotHelper.randomDelay(1000, 100);
                    ChestLogic.openChest();
                    BotHelper.randomDelay(2000, 100);

                    Bitmap backButton = BotHelper.getResourceByName("button_champ_back");
                    Point  backPoint  = ImageRecognition.getPictureLocation(backButton);

                    ADBHelper.simulateClick(backPoint);
                    BotHelper.randomDelay(1000, 100);
                    ADBHelper.simulateClick(backPoint);
                    BotHelper.randomDelay(1000, 100);
                }
                else
                {
                    BotHelper.Log("Couldn't find claim button for champEnd. Returning to regular duty.");
                }
                return(true);
            }

            return(false);
        }
Example #15
0
        private static string CheckImage(string id, Bitmap img)
        {
            //Task l = new Task(() =>
            //{
            //while (true)
            //{
            var screen = ADBHelper.ScreenShoot(id);
            var point  = ImageScanOpenCV.FindOutPoint(screen, img);
            var aa     = ImageScanOpenCV.Find(screen, img);

            aa.Save("aaa.png");
            if (point != null)
            {
                //Dispatcher.BeginInvoke(new ThreadStart(() => rtb1.AppendText("Home!!!")));
                //break;

                return("find!");
            }

            return("");
            //}
            //});
            //l.Start();
        }
Example #16
0
 //Change Proxy
 public void Change_Proxy(string deviceID, string ip_proxy, string port_proxy)
 {
     ADBHelper.ExecuteCMD(string.Format("adb -s {0} shell settings put global http_proxy {1}:{2}", deviceID, ip_proxy, port_proxy));
 }
Example #17
0
        static void RunDungeon(string ID)
        {
            if (ID == "")
            {
                return;
            }

            while (true)
            {
                if (step == -1)
                {
                    var img = (Bitmap)GOTO_MAP.Clone();
                    var _p  = GetPoint(ID, img);
                    if (_p != null)
                    {
                        ADBHelper.Tap(ID, _p.Value.X, _p.Value.Y);
                        _p = null;
                        Thread.Sleep(500);
                    }
                    else
                    {
                        img = (Bitmap)GOTO_HOME.Clone();
                        _p  = GetPoint(ID, img);
                        if (_p != null)
                        {
                            img = (Bitmap)GOTO_DUNGEON.Clone();
                            _p  = GetPoint(ID, img);
                            if (_p != null)
                            {
                                step = 0;
                                ADBHelper.Tap(ID, _p.Value.X, _p.Value.Y);
                                _p = null;
                                Thread.Sleep(500);
                            }
                        }
                    }
                }

                System.Drawing.Point?p;

                switch (step)
                {
                case 0:
                    break;

                case 1:     // Start Dungeon
                    #region Start Dungeon
                    p = GetPoint(ID, (Bitmap)D_GOTO_THE_MAP.Clone());
                    Console.WriteLine("[" + ID + "] STEP " + step);
                    if (p != null)
                    {
                        step = 2;
                        ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                        p = null;
                    }
                    break;

                    #endregion
                case 2:     // Choose FLAG
                    #region Chọn ải
                    // Check xem co phan thuong tu ai truoc hay khong?
                    p = GetPoint(ID, (Bitmap)D_REWARD_CLOSE.Clone());
                    if (p != null)
                    {
                        ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                        p = null;
                    }

                    //Flag Normal
                    p = GetPoint(ID, (Bitmap)D_HOME_MAP.Clone());
                    Console.WriteLine("[" + ID + "] STEP " + step);
                    if (p != null)
                    {
                        p = GetPoint(ID, (Bitmap)D_FLAG.Clone());
                        if (p != null)
                        {
                            step = 3;
                            ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                            p = null;

                            // click tab Your squad
                            ADBHelper.Tap(ID, 671, 39);
                            break;
                        }
                        else
                        {
                            p = GetPoint(ID, (Bitmap)D_FLAG_BIG.Clone());
                            if (p != null)
                            {
                                step = 3;
                                ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                                p = null;

                                // click tab Your squad
                                ADBHelper.Tap(ID, 671, 39);
                                break;
                            }
                            else
                            {
                                p = GetPoint(ID, (Bitmap)D_FLAG_BIG2.Clone());
                                if (p != null)
                                {
                                    step = 3;
                                    ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                                    p = null;

                                    // click tab Your squad
                                    ADBHelper.Tap(ID, 671, 39);
                                    break;
                                }
                                else
                                {
                                    p = GetPoint(ID, (Bitmap)D_FLAG_BIG3.Clone());
                                    if (p != null)
                                    {
                                        step = 3;
                                        ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                                        p = null;

                                        // click tab Your squad
                                        ADBHelper.Tap(ID, 671, 39);
                                        break;
                                    }
                                }
                            }
                        }

                        // Flag Boss
                        p = GetPoint(ID, (Bitmap)D_FLAG_BOSS.Clone());
                        if (p != null)
                        {
                            step = 3;
                            ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                            p = null;

                            // click tab Your squad
                            ADBHelper.Tap(ID, 671, 39);
                            break;
                        }
                        else
                        {
                            p = GetPoint(ID, (Bitmap)D_FLAG_BOSS1.Clone());
                            if (p != null)
                            {
                                step = 3;
                                ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                                p = null;

                                // click tab Your squad
                                ADBHelper.Tap(ID, 671, 39);
                                break;
                            }
                        }
                        //tmp_img = (Bitmap)D_FLAG_COMBAT.Clone();
                        //p = GetPoint(ID, tmp_img);
                        //if (p != null)
                        //{

                        //    ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                        //    p = null;
                        //    Thread.Sleep(500);
                        //}
                    }
                    #endregion
                    break;

                case 3:     // Click "GO HERE" -> Set Leader
                    #region Click "GO HERE" -> Set Leader
                    if (IDKey != "")
                    {
                        step = 4;
                        break;
                    }

                    p = GetPoint(ID, (Bitmap)D_GO_HERE.Clone());
                    Console.WriteLine("[" + ID + "] STEP " + step);
                    if (p != null)
                    {
                        Console.WriteLine("[" + ID + "] STEP " + step + "---->KEY");
                        IDKey = ID;
                        ADBHelper.Tap(ID, 766, 456);
                        p = null;
                        Thread.Sleep(500);
                    }
                    else
                    {
                        IDKey = "";
                    }
                    step = 4;
                    #endregion
                    break;

                case 4:     // Deploy fighter
                    #region Deploy fighter
                    Console.WriteLine("[" + ID + "] STEP " + step);
                    p = GetPoint(ID, (Bitmap)D_ADD_FIGHTER.Clone());
                    var p2 = GetPoint(ID, (Bitmap)D_CANCEL.Clone());

                    if (p != null && p2 == null)
                    {
                        while (true)
                        {
                            ADBHelper.Swipe(ID, 236, 354, 813, 164, 2000);
                            ADBHelper.Swipe(ID, 252, 354, 813, 164, 2000);
                            ADBHelper.Swipe(ID, 298, 354, 813, 164, 2000);
                            ADBHelper.Swipe(ID, 340, 354, 813, 164, 5000);
                            ADBHelper.Swipe(ID, 393, 354, 813, 164, 5000);
                            ADBHelper.Swipe(ID, 435, 354, 813, 164, 5000);

                            p = GetPoint(ID, (Bitmap)D_ADD_FIGHTER.Clone());
                            Thread.Sleep(200);
                            if (p == null)
                            {
                                p = null;
                                break;
                            }
                        }
                    }

                    p = GetPoint(ID, (Bitmap)D_ADD_FIGHTER.Clone());
                    var p1 = GetPoint(ID, (Bitmap)D_READY.Clone());
                    if (p == null && p1 != null)
                    {
                        ADBHelper.Tap(ID, p1.Value.X, p1.Value.Y);
                        p1 = null;
                        Thread.Sleep(1000);
                    }

                    // Sau khi deploy xong
                    // Key -> start battal
                    // NoKey -> quay ra map
                    p = GetPoint(ID, (Bitmap)D_TO_BATTLE.Clone());
                    if (p != null && p2 != null)
                    {
                        step = 5;
                        ADBHelper.Tap(ID, 766, 456);
                        p = null;
                    }
                    else
                    {
                        p = GetPoint(ID, (Bitmap)D_X.Clone());
                        if (p != null)
                        {
                            step = 2;
                            ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                            p = null;
                        }
                    }
                    #endregion
                    break;

                case 5:     // Sau khi xong combat thi quay lai map dungeon
                    #region Sau khi xong combat thi quay lai map dungeon
                    p = GetPoint(ID, (Bitmap)D_HOME.Clone());
                    Console.WriteLine("[" + ID + "] STEP " + step);
                    if (p != null)
                    {
                        step = 2;
                        ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                        p = null;
                    }
                    #endregion
                    break;

                case 6:     // Khi het Flag thi end dungeon
                    #region Khi het Flag thi end dungeon
                    p = GetPoint(ID, (Bitmap)D_END_JOURNEY.Clone());
                    Console.WriteLine("[" + ID + "] STEP " + step);
                    if (p != null)
                    {
                        step = 7;
                        ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                        p = null;
                        Thread.Sleep(1000);
                        ADBHelper.Tap(ID, 391, 345);     // Click popup question
                    }
                    #endregion
                    break;

                case 7:     // Tổng kết
                    #region Tổng kết phần thưởng dungeon
                    p = GetPoint(ID, (Bitmap)D_SUMMARY.Clone());
                    Console.WriteLine("[" + ID + "] STEP " + step);
                    if (p != null)
                    {
                        step = 8;
                        ADBHelper.Tap(ID, p.Value.X, p.Value.Y, 10);
                        p = null;
                        Thread.Sleep(1000);
                    }
                    #endregion
                    break;

                case 8:     // Re-invite friend
                    #region Re-invite friend
                    p = GetPoint(ID, (Bitmap)D_INVITE.Clone());
                    Console.WriteLine("[" + ID + "] STEP " + step);
                    if (p != null)
                    {
                        step = 9;
                        ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                        p = null;
                        Thread.Sleep(1000);
                    }
                    #endregion
                    break;

                case 9:     // Hai ben cung chon thi bat dau dungeon moi
                    #region Hai ben cung chon thi bat dau dungeon moi
                    p = GetPoint(ID, (Bitmap)D_START_JOURNEY.Clone());
                    Console.WriteLine("[" + ID + "] STEP " + step);
                    if (p != null)
                    {
                        step = 10;
                        ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                        p = null;
                    }
                    #endregion
                    break;

                case 10:     // Chon ve' vao dungeon
                    #region Chon ve' vao dungeon
                    p = GetPoint(ID, (Bitmap)D_ACCEPT_TORCHES.Clone());
                    Console.WriteLine("[" + ID + "] STEP " + step);
                    if (p != null)
                    {
                        step = 11;
                        ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                        p = null;
                        Thread.Sleep(500);
                    }
                    #endregion
                    break;

                case 11:     // xac nhan doi hinh vao dungeon
                    #region xac nhan doi hinh vao dungeon
                    p = GetPoint(ID, (Bitmap)D_CONFIRM_FIGHTER.Clone());
                    Console.WriteLine("[" + ID + "] STEP " + step);
                    if (p != null)
                    {
                        step = 2;
                        ADBHelper.Tap(ID, p.Value.X, p.Value.Y);
                        p = null;
                        Thread.Sleep(17000);
                    }
                    #endregion
                    break;

                default:
                    break;
                }
            }
        }
Example #18
0
        // Start the fight by clicking anywhere and wait for it to end (by searching for the "OK" button)
        public static bool startDuell(int attempt = 1)
        {
            Bitmap button_ok = BotHelper.getResourceByName("button_ok");

            ADBHelper.simulateClick(new Point(rnd.Next(670 - 100, 670 + 100), rnd.Next(400 - 100, 400 + 100))); //Click anywhere to start the battle

            // wait for the duell to end and click on ok
            BotHelper.Log("Waiting for the duell to end.");
            int   checks = 0;
            Point locOK  = new Point();

            do
            {
                BotHelper.Log(" " + checks, false);
                checks++;

                locOK = ImageRecognition.getPictureLocation(button_ok);
            } while ((locOK == pNull) && checks <= 55);

            if (checks >= 55)
            {
                BotHelper.Log("We timed out. :(");
            }

            BotHelper.randomDelay(500, 50);
            if (locOK.X == 0 && locOK.Y == 0) //something went wrong (note: the code should never enter this)
            {
                BotHelper.Log("Something weird happened.");
                if (attempt < 3)
                {
                    return(startDuell(attempt + 1));
                }
                else
                {
                    return(false); // TODO: Restart CATS?
                }
            }
            else //we won!
            {
                BotHelper.Log("Battle finished.", true, false);

                int winloss = checkWin();
                if (winloss == 1)
                {
                    BotHelper.Log(" We won!", false, false);
                    wins++;
                    winsInARow++;
                    if ((winsInARow % 5) == 0)
                    {
                        crowns++;
                    }
                }
                else if (winloss == 2)
                {
                    BotHelper.Log(" We lost. :(", false, false);
                    losses++;
                    winsInARow = 0;
                }
                else
                {
                    BotHelper.Log("Error checking win/loss, not counting stats", true, false);
                }

                BotHelper.updateStats(wins, losses, crowns);

                Point rndP = ImageRecognition.getRandomLoc(locOK, button_ok);
                BotHelper.Log("Clicked on: X = " + rndP.X + "; Y = " + rndP.Y, true, true);
                ADBHelper.simulateClick(rndP);
            }

            //BotHelper.UpdateStats(wins, losses, crowns);
            BotHelper.Log("Returning to main screen");

            return(true);
        }
Example #19
0
 // Điều Hướng
 public void Back(string deviceID)
 {
     ADBHelper.Key(deviceID, ADBKeyEvent.KEYCODE_BACK);
 }
Example #20
0
 public void Home(string deviceID)
 {
     ADBHelper.Key(deviceID, ADBKeyEvent.KEYCODE_HOME);
 }
Example #21
0
 public void Menu(string deviceID)
 {
     ADBHelper.Key(deviceID, ADBKeyEvent.KEYCODE_APP_SWITCH);
 }
Example #22
0
 private void CaiDatGonews()
 {
     ADBHelper.ExecuteCMD("adb install gonews.apk");
 }
Example #23
0
 public void Remove_Proxy(string deviceID)
 {
     ADBHelper.ExecuteCMD(string.Format("adb -s {0} shell settings put global http_proxy :0", deviceID));
 }