Example #1
0
 public HustleCastleBot()
 {
     navigation = new Navigation();
     ocr        = new UtilsOcr();
     config     = new ConfigurationFile();
     adb        = new UtilsAdb();
     writer     = new WriteHelper();
 }
Example #2
0
        /// <summary>
        /// Comprueba si hay un error
        /// </summary>
        public void CheckForError()
        {
            WriteHelper Writer = new WriteHelper();
            var         image  = ScreenCapture();

            if (image == null)
            {
                Writer.WriteError("No se puede contactar con el emulador!");
                Console.ReadKey();
            }
        }
Example #3
0
        public bool DustWorker(int r, Dictionary <Places, PositionState> dic, bool force)
        {
            Thread.Sleep(2000);

            if (dic.FirstOrDefault(_g => _g.Key == Enum.Parse <Places>($"DustPosition{r}")).Value != PositionState.Played)
            {
                nav.TapDustPosition(Enum.Parse <Places>($"DustPosition{r}"));
                WriteHelper.WriteLine($"Intentado luchar contra el enemigo en la posición: {r} ");
                nav.WaitForLocation(Places.BattlePopUp);

                var battlePower = ocr.GetDustPlayersPower();
                var margin      = config.GetEnemyMargin();
                int difference  = -1;

                if (force)
                {
                    difference = (battlePower.Item1 + margin) - battlePower.Item2;
                }
                else
                {
                    difference = battlePower.Item1 - battlePower.Item2;
                }

                if (difference > 0)
                {
                    nav.TapInGoDustFight();
                    nav.WaitForLocation(Places.Battle);
                    nav.DoubleSpeed();
                    nav.WaitForLocation(Places.BattleFinish);
                    nav.TapFinishBattle();
                    nav.WaitForLocation(Places.DustMap);

                    return(true);
                }

                WriteHelper.WriteError($"El enemigo en la posición {r} es demasiado poderoso!");
                nav.KeyScap();
            }
            return(false);
        }
Example #4
0
        public void Run(int i)
        {
            Image image = nav.ScreenCapture();

            nav.ShowDustIncomingStep(i);
            var positionStates = nav.GetDustPositionStates(image);

            Places myPosition = nav.GetMyDustPositionStates(positionStates);

            if (nav.IsPositionBattleFinished(image, myPosition) == false)
            {
                if (DustBucle(myPosition, positionStates) == false)
                {
                    WriteHelper.WriteError($"No se ha podido luchar contra nadie. Intentamos luchar contra alguien más fuerte.");
                    DustBucle(myPosition, positionStates, true);
                }
            }
            else
            {
                WriteHelper.WriteWarning($"Ya se han luchado las peleas de esta etapa.");
            }
        }
Example #5
0
        /// <summary>
        /// Captura la pantalla
        /// </summary>
        /// <returns></returns>
        public Image ScreenCapture()
        {
            WriteHelper Writer = new WriteHelper();

            try
            {
                //return Image.FromFile(ImagePath);

                Image  result = null;
                byte[] data   = Convert.FromBase64String(ReturnExec(@"exec-out ""screencap -p | base64""", Commands.CommandEnum.Adb));
                using (var stream = new MemoryStream(data, 0, data.Length))
                {
                    result = Image.FromStream(stream);
                }
                result.Save(ImagePath);
                return(result);
            }
            catch (Exception)
            {
                Writer.WriteError($"No se puede contactar con el emulador!");
                Thread.Sleep(1000);
                return(null);
            }
        }
Example #6
0
 public UtilsOcr()
 {
     UtilsAdb = new UtilsAdb();
     Config   = new ConfigurationFile();
     Writer   = new WriteHelper();
 }
Example #7
0
 public Navigation()
 {
     WriteHelper = new WriteHelper();
     adb         = new UtilsAdb();
     ocr         = new UtilsOcr();
 }