Exemplo n.º 1
0
 private void handleLiveGeoLocations(GeoCoordinate coords)
 {
     Invoke(new MethodInvoker(() => {
         try {
             var newPosition     = new PointLatLng(coords.Latitude, coords.Longitude);
             _botMarker.Position = newPosition;
             _botRoute.Points.Add(newPosition);
             map.Position = newPosition;
             if (!asViewOnly)
             {
                 textBox1.Text  = coords.Latitude.ToString(CultureInfo.InvariantCulture);
                 textBox2.Text  = coords.Longitude.ToString(CultureInfo.InvariantCulture);
                 tbAddress.Text = LocationUtils.FindAddress(newPosition);
             }
         } catch (Exception e) {
             Logger.ExceptionInfo(string.Format("Error in handleLiveGeoLocations: {0}", e));
         }
     }));
 }
Exemplo n.º 2
0
 void infoObservable_HandleNewPokemonLocation(MapPokemon mapPokemon)
 {
     Invoke(new MethodInvoker(() => {
         if (!_pokemonMarks.ContainsKey(mapPokemon.SpawnPointId))
         {
             GMarkerGoogle pokemonMarker;
             Bitmap pokebitMap = PokeImgManager.GetPokemonMediumImage(mapPokemon.PokemonId);
             if (pokebitMap != null)
             {
                 var ImageSize = new System.Drawing.Size(pokebitMap.Width, pokebitMap.Height);
                 pokemonMarker = new GMarkerGoogle(new PointLatLng(mapPokemon.Latitude, mapPokemon.Longitude), pokebitMap)
                 {
                     Offset = new System.Drawing.Point(-ImageSize.Width / 2, -ImageSize.Height / 2)
                 };
             }
             else
             {
                 pokemonMarker = new GMarkerGoogle(new PointLatLng(mapPokemon.Latitude, mapPokemon.Longitude), GMarkerGoogleType.green_small);
             }
             var expriationTime = StringUtils.TimeMStoString(mapPokemon.ExpirationTimestampMs, @"mm\:ss");
             Logger.Debug("Expires in: " + expriationTime);
             var address = LocationUtils.FindAddress(mapPokemon.Latitude, mapPokemon.Longitude);
             pokemonMarker.ToolTipText = th.TS("{0}\nExpires in: {1}\n{2}\n{3},{4}", new object[] {
                 mapPokemon.PokemonId,
                 expriationTime,
                 address,
                 mapPokemon.Latitude,
                 mapPokemon.Longitude
             });
             pokemonMarker.ToolTip.Font = new Font("Arial", 12, GraphicsUnit.Pixel);
             pokemonMarker.ToolTipMode  = MarkerTooltipMode.OnMouseOver;
             _pokemonMarks.Add(mapPokemon.SpawnPointId, pokemonMarker);
             _pokemonOverlay.Markers.Add(pokemonMarker);
         }
     }));
 }
Exemplo n.º 3
0
        public void Execute(PokemonId pokeid, GeoCoordinate remoteCoords)
        {
            GeoCoordinate returnCoords = new GeoCoordinate();

            returnCoords.Latitude  = _client.CurrentLatitude;
            returnCoords.Longitude = _client.CurrentLongitude;
            returnCoords.Altitude  = _client.CurrentAltitude;
            LocationUtils.updatePlayerLocation(_client, returnCoords.Latitude, returnCoords.Longitude, returnCoords.Altitude);

            //var result = _client.Player.UpdatePlayerLocation(returnCoords.Latitude, returnCoords.Longitude, returnCoords.Altitude).Result;

            if (_botSettings == null && _client == null)
            {
                SendToLog($" client or settings are not set");
                return;
            }

            try
            {
                remoteCoords.Altitude = LocationUtils.getAltitude(remoteCoords.Latitude, remoteCoords.Longitude);

                SendToLog($"Trying to capture {pokeid}  at { remoteCoords.Latitude } / {remoteCoords.Longitude}");
                SendToLog(LocationUtils.FindAddress(remoteCoords.Latitude, remoteCoords.Longitude));
                LocationUtils.updatePlayerLocation(_client, remoteCoords.Latitude, remoteCoords.Longitude, remoteCoords.Altitude);
                //result = _client.Player.UpdatePlayerLocation(remoteCoords.Latitude, remoteCoords.Longitude, remoteCoords.Altitude).Result;

                SendToLog($"We are at sniping location...");
                SendToLog($"Waiting {GlobalVars.SnipeOpts.WaitSecond} seconds for Pokemon to appear...");
                RandomHelper.RandomSleep(GlobalVars.SnipeOpts.WaitSecond * 1000, GlobalVars.SnipeOpts.WaitSecond * 1100);

                var catchedID = TrySnipePokemons(pokeid, remoteCoords, returnCoords);
                if ((catchedID > 0) && GlobalVars.SnipeOpts.TransferIt)
                {
                    var trResult = Logic.objClient.Inventory.TransferPokemon(catchedID);
                    if (trResult.Result == ReleasePokemonResponse.Types.Result.Success)
                    {
                        SendToLog("Pokemon was transfered.");
                        SendToLog("Candies awarded: " + trResult.CandyAwarded);
                    }
                }

                // Restore Position
                LocationUtils.updatePlayerLocation(_client, returnCoords.Latitude, returnCoords.Longitude, returnCoords.Altitude);
                //result = _client.Player.UpdatePlayerLocation(returnCoords.Latitude, returnCoords.Longitude, returnCoords.Altitude).Result;

                SendToLog($"Location after Snipe : {returnCoords.Latitude} / {returnCoords.Longitude} / {returnCoords.Altitude}");
                SendToLog(LocationUtils.FindAddress(returnCoords.Latitude, returnCoords.Longitude));

                RandomHelper.RandomSleep(20000, 22000);  // Avoid cache after snipe
            }
            catch (Exception ex)
            {
                Logger.ExceptionInfo(ex.ToString());
                SendToLog($"Go to {returnCoords.Latitude} / {returnCoords.Longitude} / {returnCoords.Altitude}.");
                LocationUtils.updatePlayerLocation(_client, returnCoords.Latitude, returnCoords.Longitude, returnCoords.Altitude);
                //result = _client.Player.UpdatePlayerLocation(returnCoords.Latitude, returnCoords.Longitude, returnCoords.Altitude).Result;
            }

            GlobalVars.SnipeOpts.Enabled    = false;
            GlobalVars.SnipeOpts.ID         = PokemonId.Missingno;
            GlobalVars.SnipeOpts.Location   = null;
            GlobalVars.SnipeOpts.WaitSecond = 6;
            GlobalVars.SnipeOpts.NumTries   = 3;
        }
Exemplo n.º 4
0
        private void initViewOnly(int team, int level, long exp)
        {
            //first hide all controls
            foreach (Control c in Controls)
            {
                c.Visible = false;
            }
            cbShowPokeStops.Visible = false;
            btnPauseWalking.Visible = true;
            cbShowPokemon.Visible   = true;

            Bitmap bmp = Properties.MapData.player;

            switch (team)
            {
            case 1:
                bmp = Properties.MapData.player_blue;
                break;

            case 2:
                bmp = Properties.MapData.player_red;
                break;

            case 3:
                bmp = Properties.MapData.player_yellow;
                break;
            }

            //show map
            map.Visible    = true;
            map.Dock       = DockStyle.Fill;
            map.ShowCenter = false;
            routeOverlay   = new GMapOverlay();
            routeOverlay.Routes.Add(_botRoute);
            PokemonOverlay = new GMapOverlay();
            CreateBotMarker(team, level, exp);
            //routeOverlay.Markers.Add(_botMarker);
            _botStartMarker              = new GMarkerGoogle(new PointLatLng(), Properties.MapData.start_point);
            _botStartMarker.Position     = new PointLatLng(GlobalVars.latitude, GlobalVars.longitude);
            _botStartMarker.ToolTipText  = string.Format("Start Point.\n{0}\n{1},{2}", LocationUtils.FindAddress(GlobalVars.latitude, GlobalVars.longitude), GlobalVars.latitude, GlobalVars.longitude);
            _botStartMarker.ToolTip.Font = new System.Drawing.Font("Arial", 12, System.Drawing.GraphicsUnit.Pixel);
            _botStartMarker.ToolTipMode  = MarkerTooltipMode.OnMouseOver;
            routeOverlay.Markers.Add(_botStartMarker);
            _circle = CreateCircle(new PointLatLng(GlobalVars.latitude, GlobalVars.longitude), GlobalVars.radius, 100);
            routeOverlay.Polygons.Add(_circle);

            map.Overlays.Add(routeOverlay);
            map.Overlays.Add(_pokeStopsOverlay);
            map.Overlays.Add(_pokemonOverlay);
            map.Overlays.Add(_pokeGymsOverlay);
            //show geodata controls
            label1.Visible               = true;
            label2.Visible               = true;
            textBox1.Visible             = true;
            textBox2.Visible             = true;
            buttonRefreshForts.Visible   = true;
            cbShowPokeStops.Visible      = true;
            cbShowPokemon.Visible        = true;
            _pokemonOverlay.IsVisibile   = true;
            _pokeStopsOverlay.IsVisibile = true;
            _pokeGymsOverlay.IsVisibile  = true;

            //don't ask at closing
            close = false;
            //add & remove live data handler after form loaded
            GlobalVars.infoObservable.HandleNewGeoLocations       += handleLiveGeoLocations;
            GlobalVars.infoObservable.HandleAvailablePokeStop     += InfoObservable_HandlePokeStop;
            GlobalVars.infoObservable.HandleAvailablePokeGym      += InfoObservable_HandlePokeGym;
            GlobalVars.infoObservable.HandlePokeStopInfoUpdate    += InfoObservable_HandlePokeStopInfoUpdate;
            GlobalVars.infoObservable.HandleClearPokemon          += infoObservable_HandleClearPokemon;
            GlobalVars.infoObservable.HandleNewPokemonLocation    += infoObservable_HandleNewPokemonLocation;
            GlobalVars.infoObservable.HandleNewPokemonLocations   += infoObservable_HandleNewPokemonLocations;
            GlobalVars.infoObservable.HandleDeletePokemonLocation += infoObservable_HandleDeletePokemonLocation;
        }
Exemplo n.º 5
0
        private void InfoObservable_HandlePokeGym(POGOProtos.Map.Fort.FortData[] forts)
        {
            Invoke(new MethodInvoker(() =>
            {
                try
                {
                    if (forts.Length > 0)
                    {
                        _pokeGymsOverlay.IsVisibile = false;
                        _pokeGymsOverlay.Markers.Clear();
                        _pokeGymsMarks.Clear();
                        int prevCount = forts.Length;
                        //< var filteredForts = forts;
                        var filteredForts = forts.Where(i => LocationUtils.CalculateDistanceInMeters(Logic.Logic.Instance.BotSettings.DefaultLatitude, Logic.Logic.Instance.BotSettings.DefaultLongitude, i.Latitude, i.Longitude) <= Logic.Logic.Instance.BotSettings.MaxWalkingRadiusInMeters).ToArray();
                        Logger.ColoredConsoleWrite(ConsoleColor.White, string.Format("Got new Gym Count: {0}, unfiltered: {1}", filteredForts.Length, forts.Length));

                        for (int i = filteredForts.Length - 1; i >= 0; i--)
                        {
                            var pokeGym = filteredForts[i];
                            if (pokeGym.Id != null)
                            {
                                var bitmap = Properties.MapData.pokegym;
                                var color  = Color.Black;
                                switch (pokeGym.OwnedByTeam)
                                {
                                case POGOProtos.Enums.TeamColor.Blue:
                                    bitmap = Properties.MapData.pokegym_blue;
                                    color  = Color.Blue;
                                    break;

                                case POGOProtos.Enums.TeamColor.Red:
                                    bitmap = Properties.MapData.pokegym_red;
                                    color  = Color.Red;
                                    break;

                                case POGOProtos.Enums.TeamColor.Yellow:
                                    bitmap = Properties.MapData.pokegym_yellow;
                                    color  = Color.Yellow;
                                    break;
                                }
                                ;

                                var str                   = string.Format("Level:{0} ({1})", GetLevel(pokeGym.GymPoints), pokeGym.GymPoints);
                                var pokeGymMaker          = new GMarkerGoogle(new PointLatLng(pokeGym.Latitude, pokeGym.Longitude), bitmap);
                                pokeGymMaker.ToolTipText  = string.Format("{0}\n{1}, {2}\n{3}", LocationUtils.FindAddress(pokeGym.Latitude, pokeGym.Longitude), pokeGym.Latitude, pokeGym.Longitude, str);
                                pokeGymMaker.ToolTip.Font = new System.Drawing.Font("Arial", 12, System.Drawing.GraphicsUnit.Pixel);
                                pokeGymMaker.ToolTipMode  = MarkerTooltipMode.OnMouseOver;
                                _pokeGymsMarks.Add(pokeGym.Id, pokeGymMaker);
                                _pokeGymsOverlay.Markers.Add(pokeGymMaker);
                                // Show Guard
                                GMarkerGoogle guardPokemonMarker;
                                Bitmap pokebitMap = PokeImgManager.GetPokemonMediumImage(pokeGym.GuardPokemonId);

                                var offsetY = 0;
                                if (pokebitMap != null)
                                {
                                    for (int idx = 0; idx < pokebitMap.Width; idx++)
                                    {
                                        pokebitMap.SetPixel(idx, 0, color);
                                        pokebitMap.SetPixel(idx, pokebitMap.Height - 1, color);
                                    }
                                    for (int idx = 0; idx < pokebitMap.Height; idx++)
                                    {
                                        pokebitMap.SetPixel(0, idx, color);
                                        pokebitMap.SetPixel(pokebitMap.Width - 1, idx, color);
                                    }
                                    var ImageSize      = new System.Drawing.Size(pokebitMap.Width, pokebitMap.Height);
                                    guardPokemonMarker = new GMarkerGoogle(new PointLatLng(pokeGym.Latitude, pokeGym.Longitude), pokebitMap);
                                    offsetY            = 5 - pokebitMap.Height / 2;
                                }
                                else
                                {
                                    guardPokemonMarker = new GMarkerGoogle(new PointLatLng(pokeGym.Latitude, pokeGym.Longitude), GMarkerGoogleType.green_small);
                                }
                                guardPokemonMarker.Offset = new Point(-bitmap.Width / 2 - 8, offsetY - bitmap.Height);
                                _pokeGymsMarks.Add(pokeGym.Id + "-" + pokeGym.GuardPokemonId, guardPokemonMarker);
                                _pokeGymsOverlay.Markers.Add(guardPokemonMarker);
                            }
                            else
                            {
                                Logger.ColoredConsoleWrite(ConsoleColor.DarkRed, string.Format("Ignore this: pokeGym.Id is null."));
                            }
                        }
                        if (!map.Overlays.Contains(_pokeGymsOverlay))
                        {
                            map.Overlays.Add(_pokeGymsOverlay);
                        }
                        _pokeGymsOverlay.IsVisibile = true;
                    }
                    else
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.DarkRed, string.Format("Ignore this: pokeGym length is 0."));
                    }
                }
                catch (Exception e)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.DarkRed, "Ignore this: sending exception information to log file.");
                    Logger.AddLog(string.Format("Error in HandlePokeStop: {0}", e.ToString()));
                }
            }));
        }
Exemplo n.º 6
0
        private void InfoObservable_HandlePokeStop(POGOProtos.Map.Fort.FortData[] pokeStops)
        {
            Invoke(new MethodInvoker(() =>
            {
                try
                {
                    if (pokeStops.Length > 0)
                    {
                        _pokeStopsOverlay.IsVisibile = false;
                        _pokeStopsOverlay.Markers.Clear();
                        _pokeStopsMarks.Clear();
                        routeOverlay.Polygons.Clear();
                        routeOverlay.Polygons.Add(_circle = CreateCircle(new PointLatLng(GlobalVars.latitude, GlobalVars.longitude), GlobalVars.radius, 100));
                        routeOverlay.Markers.Clear();
                        _botStartMarker              = new GMarkerGoogle(new PointLatLng(), Properties.MapData.start_point);
                        _botStartMarker.Position     = new PointLatLng(GlobalVars.latitude, GlobalVars.longitude);
                        _botStartMarker.ToolTipText  = string.Format("Start Point.\n{0}\n{1},{2}", LocationUtils.FindAddress(GlobalVars.latitude, GlobalVars.longitude), GlobalVars.latitude, GlobalVars.longitude);
                        _botStartMarker.ToolTip.Font = new System.Drawing.Font("Arial", 12, System.Drawing.GraphicsUnit.Pixel);
                        _botStartMarker.ToolTipMode  = MarkerTooltipMode.OnMouseOver;
                        routeOverlay.Markers.Add(_botStartMarker);
                        routeOverlay.Markers.Add(_botMarker);
                        int prevCount = pokeStops.Length;
                        //<var filteredPokeStops = pokeStops;
                        var filteredPokeStops = pokeStops.Where(i => LocationUtils.CalculateDistanceInMeters(Logic.Logic.Instance.BotSettings.DefaultLatitude, Logic.Logic.Instance.BotSettings.DefaultLongitude, i.Latitude, i.Longitude) <= Logic.Logic.Instance.BotSettings.MaxWalkingRadiusInMeters).ToArray();
                        Logger.ColoredConsoleWrite(ConsoleColor.White, string.Format("Got new Pokestop Count: {0}, unfiltered: {1}", filteredPokeStops.Length, pokeStops.Length));

                        for (int i = filteredPokeStops.Length - 1; i >= 0; i--)
                        {
                            var pokeStop = filteredPokeStops[i];
                            if (pokeStop.Id != null)
                            {
                                var pokeStopMaker = new GMarkerGoogle(new PointLatLng(pokeStop.Latitude, pokeStop.Longitude), Properties.MapData.pokestop);
                                if (pokeStop.ActiveFortModifier.Count > 0)
                                {
                                    pokeStopMaker = new GMarkerGoogle(new PointLatLng(pokeStop.Latitude, pokeStop.Longitude), Properties.MapData.lured_pokestop);
                                }

                                pokeStopMaker.ToolTipText  = string.Format("{0}\n{1},{2}", LocationUtils.FindAddress(pokeStop.Latitude, pokeStop.Longitude), pokeStop.Latitude, pokeStop.Longitude);
                                pokeStopMaker.ToolTip.Font = new System.Drawing.Font("Arial", 12, System.Drawing.GraphicsUnit.Pixel);
                                pokeStopMaker.ToolTipMode  = MarkerTooltipMode.OnMouseOver;
                                _pokeStopsMarks.Add(pokeStop.Id, pokeStopMaker);
                                _pokeStopsOverlay.Markers.Add(pokeStopMaker);
                            }
                            else
                            {
                                Logger.ColoredConsoleWrite(ConsoleColor.DarkRed, string.Format("Ignore this: pokeStop.Id is null."));
                            }
                        }
                        if (!map.Overlays.Contains(_pokeStopsOverlay))
                        {
                            map.Overlays.Add(_pokeStopsOverlay);
                        }
                        _pokeStopsOverlay.IsVisibile = true;
                    }
                    else
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.DarkRed, string.Format("Ignore this: pokeStops length is 0."));
                    }
                }
                catch (Exception e)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.DarkRed, "Ignore this: sending exception information to log file.");
                    Logger.AddLog(string.Format("Error in HandlePokeStop: {0}", e.ToString()));
                }
            }));
        }
Exemplo n.º 7
0
        public static ulong CatchPokemon(ulong encounterId, string spawnpointId, PokemonId pokeid, double pokeLong = 0, double pokeLat = 0, bool goBack = false, double returnLatitude = -1, double returnLongitude = -1, int luredPoke = 0)
        {
            ulong             ret = 0;
            EncounterResponse encounterPokemonResponse;

            //Offset Miss count here to account for user setting.
            var missCount = 0;

            if (GlobalVars.Max_Missed_throws <= 1)
            {
                missCount = 2;
            }

            if (GlobalVars.Max_Missed_throws == 2)
            {
                missCount = 1;
            }

            var forceHit = false;

            try
            {
                if (luredPoke == 0)
                {
                    encounterPokemonResponse = client.Encounter.EncounterPokemon(encounterId, spawnpointId).Result;
                }
                else if (luredPoke == 1)
                {
                    var DiscEncounterPokemonResponse = client.Encounter.EncounterLurePokemon(encounterId, spawnpointId);
                    encounterPokemonResponse        = new EncounterResponse();
                    encounterPokemonResponse.Status = DiskEncounterResultToEncounterStatus(DiscEncounterPokemonResponse.Result);

                    if (DiscEncounterPokemonResponse.Result == DiskEncounterResponse.Types.Result.Success)
                    {
                        encounterPokemonResponse.WildPokemon             = new WildPokemon();
                        encounterPokemonResponse.WildPokemon.EncounterId = encounterId;
                        encounterPokemonResponse.WildPokemon.PokemonData = DiscEncounterPokemonResponse.PokemonData;
                        encounterPokemonResponse.CaptureProbability      = new POGOProtos.Data.Capture.CaptureProbability();
                        encounterPokemonResponse.CaptureProbability.CaptureProbability_.Add(1.0F);
                    }
                }
                else
                {
                    var IncenseEncounterPokemonResponse = client.Encounter.EncounterIncensePokemon(encounterId, spawnpointId);
                    encounterPokemonResponse        = new EncounterResponse();
                    encounterPokemonResponse.Status = IncenseEncounterResultToEncounterStatus(IncenseEncounterPokemonResponse.Result);

                    if (IncenseEncounterPokemonResponse.Result == IncenseEncounterResponse.Types.Result.IncenseEncounterSuccess)
                    {
                        encounterPokemonResponse.WildPokemon             = new WildPokemon();
                        encounterPokemonResponse.WildPokemon.EncounterId = encounterId;
                        encounterPokemonResponse.WildPokemon.PokemonData = IncenseEncounterPokemonResponse.PokemonData;
                        encounterPokemonResponse.CaptureProbability      = IncenseEncounterPokemonResponse.CaptureProbability;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Error: Logic.cs - CatchPokemon - encounter: {ex.Message}");
                if (goBack)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Cyan, $"(SNIPING) Go to {returnLatitude} / {returnLongitude} before starting the capture.");
                    Logger.ColoredConsoleWrite(ConsoleColor.Cyan, LocationUtils.FindAddress(returnLatitude, returnLongitude));
                    LocationUtils.updatePlayerLocation(client, returnLatitude, returnLongitude, GlobalVars.altitude);
                    var tmpMap = client.Map.GetMapObjects(true);
                }
                return(ret);
            }

            if (goBack)
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Cyan, $"(SNIPING) Go to {returnLatitude} / {returnLongitude} before starting the capture.");
                Logger.ColoredConsoleWrite(ConsoleColor.Cyan, LocationUtils.FindAddress(returnLatitude, returnLongitude));
                LocationUtils.updatePlayerLocation(client, returnLatitude, returnLongitude, GlobalVars.altitude);
                var tmpMap = client.Map.GetMapObjects(true);
            }

            if (encounterPokemonResponse.Status == EncounterResponse.Types.Status.EncounterSuccess)
            {
                if (SkippedPokemon.Contains(encounterPokemonResponse.WildPokemon.EncounterId))
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "Previously Skipped this Pokemon - Skipping Again!");
                    return(0);
                }

                var bestPokeball = GetBestBall(encounterPokemonResponse?.WildPokemon, false);

                var iv = PokemonGo.RocketAPI.PokemonInfo.CalculatePokemonPerfection(encounterPokemonResponse.WildPokemon.PokemonData);
                var strIVPerfection = iv.ToString("0.00");
                if (bestPokeball == ItemId.ItemUnknown)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"No Pokeballs! - missed {pokeid} CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} IV {strIVPerfection}%");
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Detected all balls out of stock - disabling pokemon catch until restock of at least 1 ball type occurs");

                    Logic.Instance.pokeballoutofstock = true;
                    AllowCatchPokemon = false;

                    return(0);
                }

                var inventoryBerries = client.Inventory.GetItems();
                var probability      = encounterPokemonResponse?.CaptureProbability?.CaptureProbability_?.FirstOrDefault();
                var probability100   = Math.Round(probability.Value * 100);

                Logger.ColoredConsoleWrite(ConsoleColor.Magenta, $"Encountered {pokeid} CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} IV {strIVPerfection}% Probability {probability100}%");
                if (encounterPokemonResponse.WildPokemon.PokemonData != null)
                {
                    SaveLocations(encounterPokemonResponse.WildPokemon, iv, probability100);
                }

                if (encounterPokemonResponse.WildPokemon.PokemonData != null &&
                    encounterPokemonResponse.WildPokemon.PokemonData.Cp >= GlobalVars.MinCPtoCatch &&
                    probability100 >= GlobalVars.MinProbToCatch &&
                    iv >= GlobalVars.MinIVtoCatch)
                {
                    var usedBerry = false;
                    var escaped   = false;
                    CatchPokemonResponse caughtPokemonResponse;
                    var inventory = client.Inventory.GetItems();
                    var razz      = inventory.FirstOrDefault(p => p.ItemId == ItemId.ItemRazzBerry);
                    var pinap     = inventory.FirstOrDefault(p => p.ItemId == ItemId.ItemPinapBerry);
                    var nanab     = inventory.FirstOrDefault(p => p.ItemId == ItemId.ItemNanabBerry);

                    do
                    {
                        // Check if the best ball is still valid
                        if (bestPokeball == ItemId.ItemUnknown)
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Red, $"No Pokeballs! - missed {pokeid} CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} IV {strIVPerfection}%");
                            Logger.ColoredConsoleWrite(ConsoleColor.Red, "Detected all balls out of stock - disabling pokemon catch until restock of at least 1 ball type occurs");

                            Logic.Instance.pokeballoutofstock = true;
                            AllowCatchPokemon = false;

                            return(0);
                        }


                        if (GlobalVars.UseRazzBerry && !usedBerry && (probability.Value < GlobalVars.razzberry_chance))
                        {
                            if (razz != null && razz.Count > 0)
                            {
                                //Throw berry
                                var useRazzberry = client.Encounter.UseItemEncounter(encounterId, ItemId.ItemRazzBerry, spawnpointId);
                                if (useRazzberry.Status == UseItemEncounterResponse.Types.Status.Success)
                                {
                                    razz.Count = razz.Count - 1;
                                    Logger.Info($"We used a Razz Berry. Remaining: {razz.Count}.");
                                    usedBerry = true;
                                }
                                else
                                {
                                    Logger.Info("RazzBerry Status: " + useRazzberry.Status);
                                }

                                RandomHelper.RandomSleep(250);
                            }
                            if (!client.Player.PlayerResponse.PlayerData.TutorialState.Contains(TutorialState.PokemonBerry))
                            {
                                Logic.Instance.Tutorial.MarkTutorialAsDone(TutorialState.PokemonBerry, client);
                            }
                        }

                        if (GlobalVars.PokemonPinap.Contains(pokeid) && !usedBerry)
                        {
                            try {
                                if (pinap != null && pinap.Count > 0)
                                {
                                    // Use a pinap
                                    var res = client.Encounter.UseItemEncounter(encounterId, ItemId.ItemPinapBerry, spawnpointId);
                                    if (res.Status == UseItemEncounterResponse.Types.Status.Success)
                                    {
                                        pinap.Count = pinap.Count - 1;
                                        Logger.Info($"We used a Pinap Berry. Remaining: {pinap.Count}.");
                                        usedBerry = true;
                                    }
                                    else
                                    {
                                        Logger.Info("PinapBerry Status: " + res.Status);
                                    }
                                    RandomHelper.RandomSleep(250);
                                }
                            } catch (Exception ex1) {
                                Logger.Debug("" + ex1);
                            }
                        }

                        var r = new Random();

                        if (GlobalVars.UseNanabBerry && !usedBerry)
                        {
                            try {
                                var reallyUseIt = (r.Next(0, 100) <= GlobalVars.NanabPercent);
                                if (GlobalVars.NanabPercent == 100 || reallyUseIt)
                                {
                                    if (nanab != null && nanab.Count > 0)
                                    {
                                        var res = client.Encounter.UseItemEncounter(encounterId, ItemId.ItemNanabBerry, spawnpointId);
                                        if (res.Status == UseItemEncounterResponse.Types.Status.Success)
                                        {
                                            nanab.Count = nanab.Count - 1;
                                            Logger.Info($"We used a Nabab Berry. Remaining: {nanab.Count}.");
                                            usedBerry = true;
                                        }
                                        else
                                        {
                                            Logger.Info("Status: " + res.Status);
                                        }
                                        RandomHelper.RandomSleep(250);
                                    }
                                }
                            } catch (Exception ex1) {
                                Logger.Debug("" + ex1);
                            }
                        }
                        // limit number of balls wasted by misses and log for UX because fools be tripin
                        switch (missCount)
                        {
                        case 0:
                            if (bestPokeball == ItemId.ItemMasterBall)
                            {
                                Logger.ColoredConsoleWrite(ConsoleColor.Magenta, "No messing around with your Master Balls! Forcing a hit on target.");
                                forceHit = true;
                            }
                            break;

                        case 1:
                            if (bestPokeball == ItemId.ItemUltraBall)
                            {
                                Logger.ColoredConsoleWrite(ConsoleColor.Magenta, "Not wasting more of your Ultra Balls! Forcing a hit on target.");
                                forceHit = true;
                            }
                            break;

                        case 2:
                            //adding another chance of forcing hit here to improve overall odds after 2 misses
                            var rInt = r.Next(0, 2);
                            forceHit |= rInt == 1;
                            break;

                        default:
                            // default to force hit after 3 wasted balls of any kind.
                            Logger.ColoredConsoleWrite(ConsoleColor.Magenta, "Enough misses! Forcing a hit on target.");
                            forceHit = true;
                            break;
                        }
                        if (missCount > 0)
                        {
                            //adding another chance of forcing hit here to improve overall odds after 1st miss
                            var rInt = r.Next(0, 3);
                            if (rInt == 1)
                            {
                                // lets hit
                                forceHit = true;
                            }
                        }

                        caughtPokemonResponse = CatchPokemonWithRandomVariables(encounterId, spawnpointId, bestPokeball, forceHit);
                        if (caughtPokemonResponse == null)
                        {
                            caughtPokemonResponse = new CatchPokemonResponse();
                        }

                        if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed)
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Magenta, $"Missed { pokeid} while using {bestPokeball}");
                            missCount++;
                            RandomHelper.RandomSleep(1500, 3000);
                        }
                        else if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchEscape)
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Magenta, $"{pokeid} escaped while using {bestPokeball}");
                            usedBerry = false;
                            escaped   = true;
                            //reset forceHit in case we randomly triggered on last throw.
                            forceHit = false;
                            RandomHelper.RandomSleep(1500, 3000);
                        }
                        // Update the best ball to ensure we can still throw
                        bestPokeball = GetBestBall(encounterPokemonResponse?.WildPokemon, escaped);
                    } while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed || caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchEscape);

                    if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess)
                    {
                        ret = caughtPokemonResponse.CapturedPokemonId;

                        if (GlobalVars.ShowPokemons)
                        {
                            Logic.Instance.DeletePokemonFromMap(encounterPokemonResponse.WildPokemon.SpawnPointId);
                        }

                        var curDate = DateTime.Now;
                        Task.Factory.StartNew(() => infoObservable.PushNewHuntStats($"{pokeLat}/{pokeLong};{pokeid};{curDate.Ticks};{curDate}" + Environment.NewLine));

                        var date = DateTime.Now;
                        if (caughtPokemonResponse.CaptureAward.Xp.Sum() >= 500)
                        {
                            if (GlobalVars.LogPokemons)
                            {
                                File.AppendAllText(GlobalVars.FileForPokemonsCaught, $"[{date}] Caught new {pokeid} (CP: {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} | IV: {strIVPerfection}% | Pokeball used: {bestPokeball} | XP: {caughtPokemonResponse.CaptureAward.Xp.Sum()}) " + Environment.NewLine);
                            }
                            Logger.ColoredConsoleWrite(ConsoleColor.Gray, $"Caught {pokeid} CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} IV {strIVPerfection}% got {caughtPokemonResponse.CaptureAward.Xp.Sum()} XP | {caughtPokemonResponse.CaptureAward.Candy.Sum()} Candies | {caughtPokemonResponse.CaptureAward.Stardust.Sum()} Stardust");
                            Setout.pokemonCatchCount++;
                            Setout.SaveSession();
                            // Wrong: TutorialState.PokemonCapture is not for the first wild pokemon caught.
                            // if (!client.Player.PlayerResponse.PlayerData.TutorialState.Contains(TutorialState.PokemonCapture)) Logic.Instance.Tutorial.MarkTutorialAsDone(TutorialState.PokemonCapture, client, pokeid);
                        }
                        else
                        {
                            if (GlobalVars.LogPokemons)
                            {
                                File.AppendAllText(GlobalVars.FileForPokemonsCaught, $"[{date}] Caught {pokeid} (CP: {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} | IV: {strIVPerfection}% | Pokeball used: {bestPokeball} | XP: {caughtPokemonResponse.CaptureAward.Xp.Sum()}) " + Environment.NewLine);
                            }
                            Logger.ColoredConsoleWrite(ConsoleColor.Gray, $"Caught {pokeid} CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} IV {strIVPerfection}% got {caughtPokemonResponse.CaptureAward.Xp.Sum()} XP | {caughtPokemonResponse.CaptureAward.Candy.Sum()} Candies | {caughtPokemonResponse.CaptureAward.Stardust.Sum()} Stardust");
                            Setout.pokemonCatchCount++;
                            Setout.SaveSession();

                            if (Logic.Instance.Telegram != null)
                            {
                                Logic.Instance.Telegram.sendInformationText(TelegramUtil.TelegramUtilInformationTopics.Catch, pokeid, encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp, strIVPerfection, bestPokeball, caughtPokemonResponse.CaptureAward.Xp.Sum());
                            }
                        }
                        Logic.Instance.BotStats.AddPokemon(1);
                        Logic.Instance.BotStats.AddExperience(caughtPokemonResponse.CaptureAward.Xp.Sum());
                        Logic.Instance.BotStats.AddStardust(caughtPokemonResponse.CaptureAward.Stardust.Sum());
                        Setout.RefreshConsoleTitle(client);
                        RandomHelper.RandomSleep(1500, 2000);
                    }
                    else
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.DarkYellow, $"{pokeid} CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} IV {strIVPerfection}% got away while using {bestPokeball}..");
                        Logic.FailedSoftban++;
                        if (Logic.FailedSoftban > 10)
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Soft Ban Detected - Stopping Bot to prevent perma-ban. Try again in 4-24 hours and be more careful next time!");
                            Setout.LimitReached("");
                        }
                    }
                }
                else
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Magenta, "Pokemon CP or IV or Prob lower than Configured Min to Catch - Skipping Pokemon");
                    SkippedPokemon.Add(encounterPokemonResponse.WildPokemon.EncounterId);
                }
            }
            else if (encounterPokemonResponse.Status == EncounterResponse.Types.Status.PokemonInventoryFull)
            {
                Logger.Warning("You have no free space for new pokemons...transfer some as soon as possible.");
            }
            else
            {
                Logger.Debug(encounterPokemonResponse.Status.ToString());
            }
            return(ret);
        }
Exemplo n.º 8
0
        public static string FormatMessage(WildPokemon wildPokemon, double dbliv, double probability)
        {
            PokemonData pokemonData = wildPokemon?.PokemonData;
            var         iv          = (int)dbliv;
            var         ivIcon      = (iv >= 90 ? iv == 100 ? ":100:" : ":ok_hand:" : "");
            var         prob        = (int)probability;
            var         cp          = pokemonData.Cp;
            var         level       = PokemonInfo.GetLevel(pokemonData);
            var         gender      = "";
            var         genderIcon  = "";

            if (pokemonData.PokemonDisplay.Gender == Gender.Male)
            {
                genderIcon = "♂";
                gender     = " " + pokemonData.PokemonDisplay.Gender;
            }
            else if (pokemonData.PokemonDisplay.Gender == Gender.Female)
            {
                genderIcon = "♀";
                gender     = " " + pokemonData.PokemonDisplay.Gender;
            }
            var form = "";

            if (pokemonData.PokemonDisplay.Form != Form.Unset)
            {
                form = $" ({pokemonData.PokemonDisplay.Form})";
                form = form.Replace("Unown", "");
            }
            var costume    = pokemonData.PokemonDisplay.Costume.ToString();
            var address    = LocationUtils.FindAddress(wildPokemon.Latitude, wildPokemon.Longitude);
            var despawn    = StringUtils.TimeMStoString(wildPokemon.LastModifiedTimestampMs, @"mm\:ss");
            var tillhidden = StringUtils.TimeMStoString(wildPokemon.TimeTillHiddenMs, @"mm\:ss");
            var move1      = pokemonData.Move1;
            var move2      = pokemonData.Move2;
            var shiny      = (pokemonData.PokemonDisplay.Shiny?"shiny":"");

            var shinyIcon = (shiny == "")?"":"✵";


            var message = "{EncounterId}= {ivIcon} {shinyIcon}**{name}**{genderIcon}{form} {lat}, {lon} ({address}) IV: {iv}% LV: {level} **CP: {cp}**{gender} {move1}/{move2} Costume: {costume} Prob: {prob}% {despawn} {tillhidden} {shiny}";

            message = message.Replace("{EncounterId}", "" + wildPokemon.EncounterId);
            message = message.Replace("{name}", "" + pokemonData.PokemonId);
            message = message.Replace("{iv}", "" + iv);
            message = message.Replace("{ivIcon}", "" + ivIcon);
            message = message.Replace("{prob}", "" + prob);
            message = message.Replace("{cp}", "" + cp);

            message = message.Replace("{level}", "" + level);
            message = message.Replace("{gender}", "" + gender);
            message = message.Replace("{genderIcon}", "" + genderIcon);
            message = message.Replace("{form}", "" + form);
            message = message.Replace("{costume}", "" + costume);

            message = message.Replace("{lat}", "" + wildPokemon.Latitude.ToString(CultureInfo.InvariantCulture));
            message = message.Replace("{lon}", "" + wildPokemon.Longitude.ToString(CultureInfo.InvariantCulture));
            message = message.Replace("{address}", "" + address);

            message = message.Replace("{despawn}", "" + despawn);
            message = message.Replace("{tillhidden}", "" + tillhidden);
            message = message.Replace("{move1}", "" + move1);
            message = message.Replace("{move2}", "" + move2);
            message = message.Replace("{shiny}", "" + shiny);
            message = message.Replace("{shinyIcon}", "" + shinyIcon);
            return(message);
        }
Exemplo n.º 9
0
        private void InfoObservable_HandleUpdatePokeGym(FortData pokeGym)
        {
            Invoke(new MethodInvoker(() => {
                var bitmap = Properties.MapData.pokegym;
                var color  = Color.Black;
                switch (pokeGym.OwnedByTeam)
                {
                case POGOProtos.Enums.TeamColor.Blue:
                    bitmap = Properties.MapData.pokegym_blue;
                    color  = Color.Blue;
                    break;

                case POGOProtos.Enums.TeamColor.Red:
                    bitmap = Properties.MapData.pokegym_red;
                    color  = Color.Red;
                    break;

                case POGOProtos.Enums.TeamColor.Yellow:
                    bitmap = Properties.MapData.pokegym_yellow;
                    color  = Color.Yellow;
                    break;
                }

                var str                   = string.Format("Level:{0} ({1})", GetLevel(pokeGym.GymPoints), pokeGym.GymPoints);
                var pokeGymMaker          = new GMarkerGoogle(new PointLatLng(pokeGym.Latitude, pokeGym.Longitude), bitmap);
                pokeGymMaker.ToolTipText  = string.Format("{0}\n{1}, {2}\n{3}\nID: {4}", LocationUtils.FindAddress(pokeGym.Latitude, pokeGym.Longitude), pokeGym.Latitude, pokeGym.Longitude, str, pokeGym.Id);
                pokeGymMaker.ToolTip.Font = new System.Drawing.Font("Arial", 12, System.Drawing.GraphicsUnit.Pixel);
                pokeGymMaker.ToolTipMode  = MarkerTooltipMode.OnMouseOver;

                if (_pokeGymsMarks.ContainsKey(pokeGym.Id))
                {
                    var markerToDel = _pokeGymsMarks[pokeGym.Id];
                    if (_pokeGymsOverlay.Markers.Contains(markerToDel))
                    {
                        _pokeGymsOverlay.Markers.Remove(markerToDel);
                    }
                    _pokeGymsMarks.Remove(pokeGym.Id);
                }
                _pokeGymsMarks.Add(pokeGym.Id, pokeGymMaker);
                _pokeGymsOverlay.Markers.Add(pokeGymMaker);

                // Show Guard
                GMarkerGoogle guardPokemonMarker;
                Bitmap pokebitMap = PokeImgManager.GetPokemonMediumImage(pokeGym.GuardPokemonId);

                var offsetY = 0;
                if (pokebitMap != null)
                {
                    for (int idx = 0; idx < pokebitMap.Width; idx++)
                    {
                        pokebitMap.SetPixel(idx, 0, color);
                        pokebitMap.SetPixel(idx, pokebitMap.Height - 1, color);
                    }
                    for (int idx = 0; idx < pokebitMap.Height; idx++)
                    {
                        pokebitMap.SetPixel(0, idx, color);
                        pokebitMap.SetPixel(pokebitMap.Width - 1, idx, color);
                    }
                    var ImageSize      = new System.Drawing.Size(pokebitMap.Width, pokebitMap.Height);
                    guardPokemonMarker = new GMarkerGoogle(new PointLatLng(pokeGym.Latitude, pokeGym.Longitude), pokebitMap);
                    offsetY            = 5 - pokebitMap.Height / 2;
                }
                else
                {
                    guardPokemonMarker = new GMarkerGoogle(new PointLatLng(pokeGym.Latitude, pokeGym.Longitude), GMarkerGoogleType.green_small);
                }
                guardPokemonMarker.Offset = new Point(-bitmap.Width / 2 - 8, offsetY - bitmap.Height);

                if (_pokeGymsMarks.ContainsKey(pokeGym.Id + "-" + pokeGym.GuardPokemonId))
                {
                    var markerToDel = _pokeGymsMarks[pokeGym.Id + "-" + pokeGym.GuardPokemonId];
                    if (_pokeGymsOverlay.Markers.Contains(markerToDel))
                    {
                        _pokeGymsOverlay.Markers.Remove(markerToDel);
                    }
                    _pokeGymsMarks.Remove(pokeGym.Id + "-" + pokeGym.GuardPokemonId);
                }
                _pokeGymsMarks.Add(pokeGym.Id + "-" + pokeGym.GuardPokemonId, guardPokemonMarker);
                _pokeGymsOverlay.Markers.Add(guardPokemonMarker);
            }));
        }
Exemplo n.º 10
0
        private void InfoObservable_HandlePokeStop(FortData pokeStop, bool visited = false, string info = "")
        {
            Invoke(new MethodInvoker(() => {
                if (pokeStop.Id != null)
                {
                    var latLng = new PointLatLng(pokeStop.Latitude, pokeStop.Longitude);
                    var poke   = (visited)? Properties.MapData.visited_pokestop:Properties.MapData.pokestop;
                    if (pokeStop.ActiveFortModifier.Count > 0)
                    {
                        poke = (visited)? Properties.MapData.visited_lured_pokestop: Properties.MapData.lured_pokestop;
                    }
                    var pokeStopMaker = new GMarkerGoogle(latLng, poke);

                    var tooltipText = "";
                    if (_pokeStopsMarks.ContainsKey(pokeStop.Id))
                    {
                        var markerToDel = _pokeStopsMarks[pokeStop.Id];
                        tooltipText     = markerToDel.ToolTipText;
                        if (_pokeStopsOverlay.Markers.Contains(markerToDel))
                        {
                            _pokeStopsOverlay.Markers.Remove(markerToDel);
                        }
                        _pokeStopsMarks.Remove(pokeStop.Id);
                    }
                    else
                    {
                        if (info == "")
                        {
                            pokeStopMaker.ToolTipText = string.Format("{0}\n{1},{2}", LocationUtils.FindAddress(pokeStop.Latitude, pokeStop.Longitude), pokeStop.Latitude, pokeStop.Longitude);
                        }
                    }
                    if (info != "")
                    {
                        pokeStopMaker.ToolTipText = info;
                    }
                    pokeStopMaker.ToolTip.Font = new System.Drawing.Font("Arial", 12, System.Drawing.GraphicsUnit.Pixel);
                    pokeStopMaker.ToolTipMode  = MarkerTooltipMode.OnMouseOver;

                    _pokeStopsMarks.Add(pokeStop.Id, pokeStopMaker);
                    _pokeStopsOverlay.Markers.Add(pokeStopMaker);
                    if (visited)
                    {
                        Task.Delay(300000)
                        .ContinueWith(t => InfoObservable_HandlePokeStop(pokeStop, false, pokeStopMaker.ToolTipText));
                    }
                }
                else
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.DarkRed, string.Format("Ignore this: pokeStop.Id is null."));
                }
            }));
        }
Exemplo n.º 11
0
        public void Execute()
        {
            EnabledButton(false, th.TS("Reloading Pokemon list."));
            try
            {
                client = Logic.Logic.objClient;
                if (client.ReadyToUse)
                {
                    RandomHelper.RandomSleep(1000, 1200);

                    var pokemons        = client.Inventory.GetPokemons();
                    var pokemonSettings = Setout.GetPokemonSettings();
                    var pokemonFamilies = Setout.GetPokemonFamilies();
                    var profile         = client.Player;

                    try{
                        PokemonListView.BeginUpdate();
                    }catch (Exception ex1) {
                        Logger.ExceptionInfo(ex1.ToString());
                    }

                    PokemonListView.Items.Clear();

                    foreach (var pokemon in pokemons)
                    {
                        var listViewItem = new ListViewItem();
                        listViewItem.UseItemStyleForSubItems = false;

                        listViewItem.Tag = pokemon;
                        var currentCandy = pokemonFamilies
                                           .Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
                                           .Select(f => f.Candy_)
                                           .First();

                        var specSymbol = "";
                        if (pokemon.Favorite == 1)
                        {
                            specSymbol = "★";
                        }

                        if ((profile.PlayerResponse.PlayerData.BuddyPokemon != null) && (profile.PlayerResponse.PlayerData.BuddyPokemon.Id == pokemon.Id))
                        {
                            specSymbol = "☉";
                        }
                        listViewItem.Text = specSymbol + th.TS(pokemon.PokemonId.ToString());


                        listViewItem.ToolTipText = StringUtils.ConvertTimeMSinString(pokemon.CreationTimeMs, "dd/MM/yyyy HH:mm:ss");
                        if (pokemon.Nickname != "")
                        {
                            listViewItem.ToolTipText += th.TS("\n+Nickname: {0}", pokemon.Nickname);
                        }

                        var isbad = (pokemon.IsBad)?"Yes":"No";
                        listViewItem.SubItems.Add("" + isbad);

                        listViewItem.SubItems.Add(string.Format("{0}", pokemon.Cp));

                        if (checkBox_ShortName.Checked)
                        {
                            listViewItem.SubItems.Add(string.Format("{0}% {1}{2}{3} ({4})", PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0"), pokemon.IndividualAttack.ToString("X"), pokemon.IndividualDefense.ToString("X"), pokemon.IndividualStamina.ToString("X"), (45 - pokemon.IndividualAttack - pokemon.IndividualDefense - pokemon.IndividualStamina)));
                        }
                        else
                        {
                            listViewItem.SubItems.Add(string.Format("{0}% {1}-{2}-{3}", PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0"), pokemon.IndividualAttack, pokemon.IndividualDefense, pokemon.IndividualStamina));
                        }
                        listViewItem.SubItems.Add(string.Format("{0}", PokemonInfo.GetLevel(pokemon)));

                        # region Evolve Column
                        var settings    = pokemonSettings.FirstOrDefault(x => x.PokemonId == pokemon.PokemonId);
                        var familyCandy = pokemonFamilies.FirstOrDefault(x => x.FamilyId == settings.FamilyId);
                        listViewItem.SubItems.Add("");
                        var    numOfEvolves = 0;
                        String strEvolves   = EvolvesToString(pokemon, settings, familyCandy, out numOfEvolves);
                        // Colour Management
                        listViewItem.SubItems[listViewItem.SubItems.Count - 1].ForeColor = Color.DarkRed;
                        if (numOfEvolves == 1)
                        {
                            listViewItem.SubItems[listViewItem.SubItems.Count - 1].ForeColor = Color.ForestGreen;
                        }
                        else if (numOfEvolves > 1)
                        {
                            listViewItem.SubItems[listViewItem.SubItems.Count - 1].ForeColor = Color.LightPink;
                        }
                        listViewItem.SubItems[listViewItem.SubItems.Count - 1].Text = $"{strEvolves} | C:{familyCandy.Candy_}";
                        # endregion Evolve Column

                        listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.HeightM, 2)));
                        listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.WeightKg, 2)));
                        listViewItem.SubItems.Add(string.Format("{0}/{1}", pokemon.Stamina, pokemon.StaminaMax));
                        listViewItem.SubItems.Add(string.Format("{0}", pokemon.Move1));
                        listViewItem.SubItems.Add(string.Format("{0} ({1})", pokemon.Move2, PokemonInfo.GetAttack(pokemon.Move2)));
                        listViewItem.SubItems.Add(string.Format("{0}", (int)pokemon.PokemonId));
                        listViewItem.SubItems.Add(string.Format("{0}", PokemonInfo.CalculatePokemonPerfectionCP(pokemon).ToString("0.00")));

                        AdditionalPokeData addData = additionalPokeData.FirstOrDefault(x => x.PokedexNumber == (int)pokemon.PokemonId);
                        if (addData != null)
                        {
                            listViewItem.SubItems.Add(addData.Type1);
                            listViewItem.SubItems.Add(addData.Type2);
                        }
                        else
                        {
                            listViewItem.SubItems.Add("");
                            listViewItem.SubItems.Add("");
                        }
                        // NOTE: yyyy/MM/dd is inverted order to can sort correctly as text.
                        listViewItem.SubItems.Add(StringUtils.ConvertTimeMSinString(pokemon.CreationTimeMs, "yyyy/MM/dd HH:mm:ss"));
                        listViewItem.SubItems.Add(th.TS(pokemon.Pokeball.ToString().Replace("Item", "")));
                        listViewItem.SubItems.Add("" + pokemon.NumUpgrades);
                        listViewItem.SubItems.Add("" + pokemon.BattlesAttacked);
                        listViewItem.SubItems.Add("" + pokemon.BattlesDefended);
                        listViewItem.SubItems.Add("" + pokemon.DeployedFortId);
                        if (pokemon.DeployedFortId != "")
                        {
                            listViewItem.SubItems[0].BackColor = Color.Bisque;
                        }

                        var CapturedLatlng = S2Helper.GetLatLng(pokemon.CapturedCellId);
                        listViewItem.SubItems.Add(LocationUtils.FindAddress(CapturedLatlng[0], CapturedLatlng[1]));
                        listViewItem.SubItems.Add("" + pokemon.PokemonDisplay.Gender);
                        var str = "";
                        if (pokemon.PokemonDisplay.Costume != Costume.Unset)
                        {
                            str = pokemon.PokemonDisplay.Costume.ToString();
                        }
                        listViewItem.SubItems.Add("" + str);
                        var form = "";
                        if (pokemon.PokemonDisplay.Form != POGOProtos.Enums.Form.Unset)
                        {
                            form = pokemon.PokemonDisplay.Form.ToString().Replace("Unown", "").Replace("ExclamationPoint", "!").Replace("QuestionMark", "?");
                        }
                        listViewItem.SubItems.Add("" + form);

                        var shiny = (pokemon.PokemonDisplay.Shiny)?"Yes":"No";
                        listViewItem.SubItems.Add("" + shiny);

                        listViewItem.SubItems.Add("" + pokemon.BuddyCandyAwarded);
                        listViewItem.SubItems.Add("" + pokemon.BuddyTotalKmWalked);
                        listViewItem.SubItems.Add("" + pokemon.Id.ToString("X"));

                        var special = "";
                        if (GlobalVars.UseSpritesFolder)
                        {
                            if (pokemon.PokemonId == PokemonId.Unown)
                            {
                                special = form.ToLower();
                            }
                            else if (shiny == "Yes")
                            {
                                special = "s";
                            }
                            else if (pokemon.PokemonDisplay.Costume != Costume.Unset)
                            {
                                special = pokemon.PokemonDisplay.Costume.ToString().ToLower();
                            }
                        }

                        listViewItem.ImageKey = pokemon.PokemonId + special;

                        PokemonListView.Items.Add(listViewItem);
                    }
                    try{
                        PokemonListView.EndUpdate();
                    }catch (Exception ex1) {
                        Logger.ExceptionInfo(ex1.ToString());
                    }
                    PokemonListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    EnabledButton(true);
                    statusTexbox.Text = string.Empty;
                    RefreshTitle();
                }
Exemplo n.º 12
0
        public void Execute(PokemonId pokeid, GeoCoordinate remoteCoords)
        {
            var returnCoords = new GeoCoordinate();

            returnCoords.Latitude  = _client.CurrentLatitude;
            returnCoords.Longitude = _client.CurrentLongitude;
            returnCoords.Altitude  = _client.CurrentAltitude;

            var distanceToTarget = LocationUtils.CalculateDistanceInMeters(returnCoords, remoteCoords);

            if (distanceToTarget > 100000)
            {
                Logger.Warning("Distance greater than 100 kms. Skipping Snipe.");
                return;
            }


            //LocationUtils.updatePlayerLocation(_client, returnCoords.Latitude, returnCoords.Longitude, returnCoords.Altitude);

            if (_botSettings == null && _client == null)
            {
                SendToLog($" client or settings are not set");
                return;
            }

            try {
                remoteCoords.Altitude = LocationUtils.GetAltitude(remoteCoords.Latitude, remoteCoords.Longitude);

                SendToLog($"Trying to capture {pokeid}  at { remoteCoords.Latitude } / {remoteCoords.Longitude}");
                SendToLog(LocationUtils.FindAddress(remoteCoords.Latitude, remoteCoords.Longitude));
                LocationUtils.updatePlayerLocation(_client, remoteCoords.Latitude, remoteCoords.Longitude, remoteCoords.Altitude, false);
                var gmp = _client.Map.GetMapObjects(true).Result;

                SendToLog($"We are at sniping location...");
                SendToLog($"Waiting {GlobalVars.SnipeOpts.WaitSecond} seconds for Pokemon to appear...");
                RandomHelper.RandomSleep(GlobalVars.SnipeOpts.WaitSecond * 1000);

                var catchedID = 0UL;
                if (pokeid == PokemonId.Missingno)
                {
                    catchedID = TrySnipeGym(remoteCoords, returnCoords);
                }
                else
                {
                    RandomHelper.RandomSleep(1000);
                    catchedID = TrySnipePokemons(pokeid, remoteCoords, returnCoords);
                }

                LocationUtils.updatePlayerLocation(_client, returnCoords.Latitude, returnCoords.Longitude, returnCoords.Altitude);
                gmp = _client.Map.GetMapObjects(true).Result;

                SendToLog($"Location after Snipe : {_client.CurrentLatitude} / {_client.CurrentLongitude} / {_client.CurrentAltitude}");
                SendToLog(LocationUtils.FindAddress(_client.CurrentLatitude, _client.CurrentLongitude));

                if ((catchedID > 0) && GlobalVars.SnipeOpts.TransferIt && pokeid != PokemonId.Missingno)
                {
                    var trResult = Logic.objClient.Inventory.ReleasePokemon(catchedID);
                    if (trResult.Result == ReleasePokemonResponse.Types.Result.Success)
                    {
                        SendToLog("Pokemon was transfered.");
                        SendToLog("Candies awarded: " + trResult.CandyAwarded);
                    }
                }

                RandomHelper.RandomSleep(20000, 22000);  // Avoid cache after snipe
            } catch (Exception ex) {
                Logger.ExceptionInfo(ex.ToString());
                SendToLog($"Go to {returnCoords.Latitude} / {returnCoords.Longitude} / {returnCoords.Altitude}.");
                LocationUtils.updatePlayerLocation(_client, returnCoords.Latitude, returnCoords.Longitude, returnCoords.Altitude);
                var gmp = _client.Map.GetMapObjects(true).Result;
            }

            GlobalVars.SnipeOpts.Enabled    = false;
            GlobalVars.SnipeOpts.ID         = PokemonId.Missingno;
            GlobalVars.SnipeOpts.Location   = null;
            GlobalVars.SnipeOpts.WaitSecond = 6;
            GlobalVars.SnipeOpts.NumTries   = 3;
        }
Exemplo n.º 13
0
        private void InfoObservable_HandleUpdatePokeGym(FortData pokeGym)
        {
            Invoke(new MethodInvoker(() => {
                var bitmap = Properties.MapData.pokegym;
                var color  = Color.Black;
                switch (pokeGym.OwnedByTeam)
                {
                case POGOProtos.Enums.TeamColor.Blue:
                    bitmap = Properties.MapData.pokegym_blue;
                    color  = Color.Blue;
                    break;

                case POGOProtos.Enums.TeamColor.Red:
                    bitmap = Properties.MapData.pokegym_red;
                    color  = Color.Red;
                    break;

                case POGOProtos.Enums.TeamColor.Yellow:
                    bitmap = Properties.MapData.pokegym_yellow;
                    color  = Color.Yellow;
                    break;
                }

                var str          = "";
                var pokeGymMaker = new GMarkerGoogle(new PointLatLng(pokeGym.Latitude, pokeGym.Longitude), bitmap);
                if (pokeGym.RaidInfo != null)
                {
                    str = string.Format("Raid Info: {0}, level: {1}, starts: {2}, ends: {3}"
                                        , pokeGym.RaidInfo.RaidPokemon?.PokemonId
                                        , pokeGym.RaidInfo.RaidLevel
                                        , StringUtils.TimeMStoString(pokeGym.RaidInfo.RaidBattleMs, @"mm\:ss")
                                        , StringUtils.TimeMStoString(pokeGym.RaidInfo.RaidEndMs, @"mm\:ss"));
                }
                pokeGymMaker.ToolTipText  = string.Format("{0}\n{1}, {2}\n{3}\nID: {4}", LocationUtils.FindAddress(pokeGym.Latitude, pokeGym.Longitude), pokeGym.Latitude, pokeGym.Longitude, str, pokeGym.Id);
                pokeGymMaker.ToolTip.Font = new System.Drawing.Font("Arial", 12, System.Drawing.GraphicsUnit.Pixel);
                pokeGymMaker.ToolTipMode  = MarkerTooltipMode.OnMouseOver;


                if (_pokeGymsMarks.ContainsKey(pokeGym.Id))
                {
                    var markerToDel = _pokeGymsMarks[pokeGym.Id];
                    if (_pokeGymsOverlay.Markers.Contains(markerToDel))
                    {
                        _pokeGymsOverlay.Markers.Remove(markerToDel);
                    }
                    _pokeGymsMarks.Remove(pokeGym.Id);
                }
                _pokeGymsMarks.Add(pokeGym.Id, pokeGymMaker);
                _pokeGymsOverlay.Markers.Add(pokeGymMaker);

                #region Show Guard
                if (_pokeGymsMarks.ContainsKey(pokeGym.Id + "-Guard"))
                {
                    var markerToDel = _pokeGymsMarks[pokeGym.Id + "-Guard"];
                    if (_pokeGymsOverlay.Markers.Contains(markerToDel))
                    {
                        _pokeGymsOverlay.Markers.Remove(markerToDel);
                    }
                    _pokeGymsMarks.Remove(pokeGym.Id + "-Guard");
                }
                GMarkerGoogle guardPokemonMarker;
                var pokeID = pokeGym.GuardPokemonId;
                if (pokeGym.RaidInfo != null && pokeGym.RaidInfo.RaidPokemon != null)
                {
                    pokeID = pokeGym.RaidInfo.RaidPokemon.PokemonId;
                }
                Bitmap pokebitMap = PokeImgManager.GetPokemonMediumImage(pokeID);
                var offsetY       = 0;
                if (pokebitMap != null)
                {
                    for (int idx = 0; idx < pokebitMap.Width; idx++)
                    {
                        pokebitMap.SetPixel(idx, 0, color);
                        pokebitMap.SetPixel(idx, pokebitMap.Height - 1, color);
                    }
                    for (int idx = 0; idx < pokebitMap.Height; idx++)
                    {
                        pokebitMap.SetPixel(0, idx, color);
                        pokebitMap.SetPixel(pokebitMap.Width - 1, idx, color);
                    }
                    var ImageSize             = new System.Drawing.Size(pokebitMap.Width, pokebitMap.Height);
                    guardPokemonMarker        = new GMarkerGoogle(new PointLatLng(pokeGym.Latitude, pokeGym.Longitude), pokebitMap);
                    offsetY                   = 5 - pokebitMap.Height / 2;
                    guardPokemonMarker.Offset = new Point(-bitmap.Width / 2 - 8, offsetY - bitmap.Height);

                    _pokeGymsMarks.Add(pokeGym.Id + "-Guard", guardPokemonMarker);
                    _pokeGymsOverlay.Markers.Add(guardPokemonMarker);
                }
                #endregion Show Guard

                #region Show fighting
                if (_pokeGymsMarks.ContainsKey(pokeGym.Id + "-Fighting"))
                {
                    var markerToDel = _pokeGymsMarks[pokeGym.Id + "-Fighting"];
                    if (_pokeGymsOverlay.Markers.Contains(markerToDel))
                    {
                        _pokeGymsOverlay.Markers.Remove(markerToDel);
                    }
                    _pokeGymsMarks.Remove(pokeGym.Id + "-Fighting");
                }
                GMarkerGoogle FightingMarker;
                if (pokeGym.IsInBattle)
                {
                    for (int idx = 0; idx < pokebitMap.Width; idx++)
                    {
                        pokebitMap.SetPixel(idx, 0, color);
                        pokebitMap.SetPixel(idx, pokebitMap.Height - 1, color);
                    }
                    for (int idx = 0; idx < pokebitMap.Height; idx++)
                    {
                        pokebitMap.SetPixel(0, idx, color);
                        pokebitMap.SetPixel(pokebitMap.Width - 1, idx, color);
                    }
                    FightingMarker = new GMarkerGoogle(new PointLatLng(pokeGym.Latitude, pokeGym.Longitude), GMarkerGoogleType.red_small);
                    if (pokebitMap != null)
                    {
                        FightingMarker.Offset = new Point(-bitmap.Width / 2, 5 - pokebitMap.Height * 2);
                    }

                    _pokeGymsMarks.Add(pokeGym.Id + "-Fighting", FightingMarker);
                    _pokeGymsOverlay.Markers.Add(FightingMarker);
                }
                #endregion Show figting
                #region is raid
                if (_pokeGymsMarks.ContainsKey(pokeGym.Id + "-Raid"))
                {
                    var markerToDel = _pokeGymsMarks[pokeGym.Id + "-Raid"];
                    if (_pokeGymsOverlay.Markers.Contains(markerToDel))
                    {
                        _pokeGymsOverlay.Markers.Remove(markerToDel);
                    }
                    _pokeGymsMarks.Remove(pokeGym.Id + "-Raid");
                }
                GMarkerGoogle RaidMarker;
                if (pokeGym.RaidInfo != null)
                {
                    for (int idx = 0; idx < pokebitMap.Width; idx++)
                    {
                        pokebitMap.SetPixel(idx, 0, color);
                        pokebitMap.SetPixel(idx, pokebitMap.Height - 1, color);
                    }
                    for (int idx = 0; idx < pokebitMap.Height; idx++)
                    {
                        pokebitMap.SetPixel(0, idx, color);
                        pokebitMap.SetPixel(pokebitMap.Width - 1, idx, color);
                    }
                    var raidMarkerType = GMarkerGoogleType.pink;
                    if (((int)pokeGym.RaidInfo.RaidLevel >= 3) && ((int)pokeGym.RaidInfo.RaidLevel <= 4))
                    {
                        raidMarkerType = GMarkerGoogleType.yellow;
                    }
                    if ((int)pokeGym.RaidInfo.RaidLevel >= 5)
                    {
                        raidMarkerType = GMarkerGoogleType.blue;
                    }

                    RaidMarker = new GMarkerGoogle(new PointLatLng(pokeGym.Latitude, pokeGym.Longitude), raidMarkerType);
                    if (pokebitMap != null)
                    {
                        RaidMarker.Offset = new Point(-bitmap.Width / 2, 5 - pokebitMap.Height * 2);
                    }

                    _pokeGymsMarks.Add(pokeGym.Id + "-Raid", RaidMarker);
                    _pokeGymsOverlay.Markers.Add(RaidMarker);
                }
                #endregion is raid
            }));
        }