internal bool ShowBastion()
        {
            string battlePath = $"{_imgDirPath}{_imgNameBattle}";

            if (!File.Exists(battlePath))
            {
                ConsoleWriter.WriteLineError($"Cannot find file {battlePath}");
                return(false);
            }
            MouseHandler.SetCursorPosition(0, 0);
            Bitmap bitmapTemoin = new Bitmap(battlePath);
            int    c            = 0;

debut:
            WindowHandler.RepositionRaidWindow(raidProcessId);
            if (c > 20)
            {
                throw new Exception("Cannot find the bastion. Number of attempts failed.");
            }
            Bitmap bitmapTest = ImgHandler.GetBitmap(_recBattle);

            if (ImgHandler.AreBitmapsDifferent(bitmapTemoin, bitmapTest, RaidOptions.SavePicturesAllowed))
            {
                KeyBoardHandler.SendKey(KEY_ESCAPE);
                Thread.Sleep(2000);
                c++;
                goto debut;
            }

            return(true);
        }
 private bool GoToCampaignMap()
 {
     if (!ShowBastion())
     {
         return(false);
     }
     KeyBoardHandler.SendKey(KEY_ENTER);
     if (!(ImgHandler.ReadBitmap(_recDungeonTitle).ToUpper() == "DUNGEONS"))
     {
         ConsoleWriter.WriteLineError("Cannot find the campaign. Abort.");
         return(false);
     }
     else
     {
         Console.WriteLine("--> Entering the campaign map...");
         Thread.Sleep(1000);
         MouseHandler.MouseClick(812, 321);
         return(true);
     }
 }
        private int AutoBattleForKeeps(int nbLoop, int compteur, string keepName)
        {
            MouseHandler.MouseWheelDown(25);
            Thread.Sleep(500);
            MouseHandler.MouseClick(1803, 380);
            ConsoleWriter.CountDown("Starting battle in {0}  ", _battleCountDown);
            MouseHandler.MouseClick(1790, 550);

            DateTime dateStart = DateTime.Now;
            TimeSpan t;
            Bitmap   bmpReplay = new Bitmap($"{_imgDirPath}{_imgNameReplay}");
            Bitmap   bmpLvlUp  = new Bitmap($"{_imgDirPath}{_imgNameLevelUp}");

            compteur++;
            do
            {
                WindowHandler.RepositionRaidWindow(raidProcessId);
                Thread.Sleep(500);
                var bmpTestReplay = ImgHandler.GetBitmap(_recReplay);
                var bmpTestLvlUp  = ImgHandler.GetBitmap(_recLevelUp);
                if (!ImgHandler.AreBitmapsDifferent(bmpReplay, bmpTestReplay, RaidOptions.SavePicturesAllowed))
                {
                    t = DateTime.Now - dateStart;
                    ConsoleWriter.KeepAwake();
                    if ((t.TotalMinutes > 20) && (RaidOptions.CheckMineAllowed || RaidOptions.CheckPitAllowed || RaidOptions.CheckRewardsAllowed))
                    {
                        Console.Write("\nPausing the battle to check the bastion...");
                        Thread.Sleep(800);
                        break;
                    }
                    if ((nbLoop != 0) && (compteur >= nbLoop))
                    {
                        Console.Write("\nMax number of allowed battle reached...");
                        //switch (keepName)
                        //{
                        //    case "magic keep":
                        //        RaidOptions.MagicKeepAllowed = false;
                        //        break;
                        //    case "void keep":
                        //        RaidOptions.VoidKeepAllowed = false;
                        //        break;
                        //    case "spirit keep":
                        //        RaidOptions.SpiritKeepAllowed = false;
                        //        break;
                        //    case "force keep":
                        //        RaidOptions.ForceKeepAllowed = false;
                        //        break;
                        //    case "arcane keep":
                        //        RaidOptions.ArcaneKeepAllowed = false;
                        //        break;
                        //    default:
                        //        throw new ArgumentNullException($"Cannot find the keep '{keepName}' !");
                        //}
                        break;
                    }
                    KeyBoardHandler.SendKey(KEY_R);
                    compteur++;
                    Thread.Sleep(1000);
                }
                else if (!ImgHandler.AreBitmapsDifferent(bmpLvlUp, bmpTestLvlUp, RaidOptions.SavePicturesAllowed))
                {
                    KeyBoardHandler.SendKey(KEY_ESCAPE);
                }
                if (nbLoop != 0)
                {
                    Console.Write($"\r=> Starting run {compteur}/{nbLoop}   ");
                }
                else
                {
                    Console.Write($"\r=> Starting run {compteur}          ");
                }
                Thread.Sleep(_battleIdle);
            } while (true);
            Console.WriteLine();
            return(compteur);
        }
        internal int RunDurhamForest(int nbLoop)
        {
            int      compteur  = 0;
            DateTime dateStart = DateTime.Now;
            TimeSpan t;
            Bitmap   bmpReplay = new Bitmap($"{_imgDirPath}{_imgNameReplay}");
            Bitmap   bmpLvlUp  = new Bitmap($"{_imgDirPath}{_imgNameLevelUp}");

            Console.Write("-> Starting the Durham Forest run ");
            if (nbLoop != 0)
            {
                Console.Write($"({nbLoop} run left)");
            }
            Console.WriteLine();
            Thread.Sleep(1000);
            if (GoToCampaignMap())
            {
                Console.WriteLine("---> Entering durham forest...");
                Thread.Sleep(1000);
                MouseHandler.MouseDrag(1767, 327, 905, 467);
                Thread.Sleep(2000);
                MouseHandler.MouseClick(1239, 271);
                Thread.Sleep(2000);
                MouseHandler.MouseClick(1815, 130);
                ConsoleWriter.CountDown("Starting battle in {0}  ", _battleCountDown);
                MouseHandler.MouseClick(1790, 550);
                compteur++;
                do
                {
                    Thread.Sleep(1000);
                    WindowHandler.RepositionRaidWindow(raidProcessId);
                    Thread.Sleep(500);
                    var bmpTestReplay = ImgHandler.GetBitmap(_recReplay);
                    var bmpTestLvlUp  = ImgHandler.GetBitmap(_recLevelUp);
                    if (!ImgHandler.AreBitmapsDifferent(bmpReplay, bmpTestReplay, RaidOptions.SavePicturesAllowed))
                    {
                        t = DateTime.Now - dateStart;
                        ConsoleWriter.KeepAwake();
                        if ((t.TotalMinutes > 20) && (RaidOptions.CheckMineAllowed || RaidOptions.CheckPitAllowed || RaidOptions.CheckRewardsAllowed))
                        {
                            Console.Write("\nPausing the battle to check the bastion...");
                            Thread.Sleep(800);
                            break;
                        }
                        if ((nbLoop != 0) && (compteur >= nbLoop))
                        {
                            Console.Write("\nMax number of allowed battle reached...");
                            RaidOptions.DurhamForestAllowed = false;
                            break;
                        }
                        KeyBoardHandler.SendKey(KEY_R);
                        compteur++;
                        Thread.Sleep(1000);
                    }
                    else if (!ImgHandler.AreBitmapsDifferent(bmpLvlUp, bmpTestLvlUp, RaidOptions.SavePicturesAllowed))
                    {
                        KeyBoardHandler.SendKey(KEY_ESCAPE);
                    }
                    if (nbLoop != 0)
                    {
                        Console.Write($"\r=> Starting run {compteur}/{nbLoop}   ");
                    }
                    else
                    {
                        Console.Write($"\r=> Starting run {compteur}          ");
                    }
                    Thread.Sleep(_battleIdle);
                } while (true);
                Console.WriteLine();
            }

            if (nbLoop != 0)
            {
                return(nbLoop - compteur);
            }
            else
            {
                return(nbLoop);
            }
        }
        internal void CheckPlaytimeRewards()
        {
            //daily playtime reward
            string imgPath = $"{_imgDirPath}{_imgNameReward}";

            Console.WriteLine("-> Starting to check the playtime rewards...");
            if (!File.Exists(imgPath))
            {
                ConsoleWriter.WriteLineWarning($"Cannot find file {imgPath}. Phase skipped.");
                return;
            }
            WindowHandler.RepositionRaidWindow(raidProcessId);
            MouseHandler.SetCursorPosition(0, 0);
            Bitmap bitmapTemoin = new Bitmap(imgPath);
            Bitmap bitmapTest   = ImgHandler.GetBitmap(_recReward);

            //bitmapTest.Save("RewardRedDot.bmp");
            Thread.Sleep(100);
            if (!ImgHandler.AreBitmapsDifferent(bitmapTemoin, bitmapTest, RaidOptions.SavePicturesAllowed))
            {
                ConsoleWriter.WriteLineInformation("Playtime rewards found. Let's get them.");
                MouseHandler.MouseClick(1853, 486);
                Thread.Sleep(100);
                MouseHandler.MouseClick(1038, 404);
                Thread.Sleep(100);
                MouseHandler.MouseClick(1148, 399);
                Thread.Sleep(100);
                MouseHandler.MouseClick(1259, 403);
                Thread.Sleep(100);
                MouseHandler.MouseClick(1370, 406);
                Thread.Sleep(100);
                MouseHandler.MouseClick(1474, 399);
                Thread.Sleep(100);
                MouseHandler.MouseClick(1591, 402);
                Thread.Sleep(100);
            }
            else
            {
                Console.WriteLine("No rewards found.");
                Thread.Sleep(100);
            }

            ShowBastion();

            //daily login rewards
            imgPath = $"{_imgDirPath}{_imgDailyReward}";
            Console.WriteLine("-> Starting to check the daily login rewards...");
            if (!File.Exists(imgPath))
            {
                ConsoleWriter.WriteLineWarning($"Cannot find file {imgPath}. Phase skipped.");
                Thread.Sleep(500);
                return;
            }
            WindowHandler.RepositionRaidWindow(raidProcessId);
            MouseHandler.SetCursorPosition(0, 0);
            bitmapTemoin = new Bitmap(imgPath);
            bitmapTest   = ImgHandler.GetBitmap(_recDailyReward);
            if (!ImgHandler.AreBitmapsDifferent(bitmapTemoin, bitmapTest, RaidOptions.SavePicturesAllowed))
            {
                Console.WriteLine("Daily rewards found. Let's go get them.");
                MouseHandler.MouseClick(717, 314);
                MouseHandler.MouseClick(744, 110);
                KeyBoardHandler.SendKey(KEY_ESCAPE);
            }
            else
            {
                Console.WriteLine("No rewards found.");
                Thread.Sleep(500);
            }
        }