public async Task SetServer()
        {
            var serverRequest = RequestBuilder.GetInitialRequest(_accessToken, _settings.AuthType, _currentLat, _currentLng, 10,
                                                                 RequestType.GET_PLAYER, RequestType.GET_HATCHED_OBJECTS, RequestType.GET_INVENTORY,
                                                                 RequestType.CHECK_AWARDED_BADGES, RequestType.DOWNLOAD_SETTINGS);
            var serverResponse = await _httpClient.PostProto(Resources.RpcUrl, serverRequest);

            _unknownAuth = new Request.Types.UnknownAuth
            {
                Unknown71 = serverResponse.Auth.Unknown71,
                Timestamp = serverResponse.Auth.Timestamp,
                Unknown73 = serverResponse.Auth.Unknown73
            };

            _apiUrl = serverResponse.ApiUrl;
        }
Example #2
0
 public static Request GetRequest(Request.Types.UnknownAuth unknownAuth, double lat, double lng, double altitude, params Request.Types.Requests[] customRequests)
 {
     return(new Request()
     {
         Altitude = Utils.FloatAsUlong(altitude),
         Unknownauth = unknownAuth,
         Latitude = Utils.FloatAsUlong(lat),
         Longitude = Utils.FloatAsUlong(lng),
         RpcId = 1469378659230941192,
         Unknown1 = 2,
         Unknown12 = 989, //Required otherwise we receive incompatible protocol
         Requests =
         {
             customRequests
         }
     });
 }
Example #3
0
        public async Task <ProfileResponse> GetProfile()
        {
            var profileRequest = RequestBuilder.GetInitialRequest(_accessToken, _authType, _currentLat, _currentLng, 10,
                                                                  new Request.Types.Requests()
            {
                Type = (int)RequestType.GET_PLAYER
            });
            var profileResponse =
                await _httpClient.PostProto <Request, ProfileResponse>($"https://{_apiUrl}/rpc", profileRequest);

            _unknownAuth = new Request.Types.UnknownAuth()
            {
                Unknown71 = profileResponse.Auth.Unknown71,
                Timestamp = profileResponse.Auth.Timestamp,
                Unknown73 = profileResponse.Auth.Unknown73,
            };
            return(profileResponse);
        }
Example #4
0
        public async Task SetServer()
        {
            var serverRequest = RequestBuilder.GetInitialRequest(AccessToken, _authType, CurrentLat, CurrentLng, CurrentAltitude,
                                                                 RequestType.GET_PLAYER, RequestType.GET_HATCHED_OBJECTS, RequestType.GET_INVENTORY,
                                                                 RequestType.CHECK_AWARDED_BADGES, RequestType.DOWNLOAD_SETTINGS);
            var serverResponse = await _httpClient.PostProto <Request>(Resources.RpcUrl, serverRequest);

            if (serverResponse.Auth == null)
            {
                throw new AccessTokenExpiredException();
            }

            _unknownAuth = new Request.Types.UnknownAuth()
            {
                Unknown71 = serverResponse.Auth.Unknown71,
                Timestamp = serverResponse.Auth.Timestamp,
                Unknown73 = serverResponse.Auth.Unknown73,
            };

            _apiUrl = serverResponse.ApiUrl;
        }
Example #5
0
        public static async Task UseRazzBerry(HttpClient client, string _apiUrl, ulong encounterId, string spawnPointGuid, Request.Types.UnknownAuth _unknownAuth, double _currentLat, double _currentLng)
        {
            IEnumerable <GeneratedCode.Item> myItems = await GetItems(client, _apiUrl, _unknownAuth, _currentLat, _currentLng);

            IEnumerable <GeneratedCode.Item> RazzBerries = myItems.Where(i => (ItemId)i.Item_ == ItemId.ItemRazzBerry);

            GeneratedCode.Item RazzBerry = RazzBerries.FirstOrDefault();
            if (RazzBerry != null)
            {
                UseItemCaptureRequest useRazzBerry = await UseCaptureItem(client, _apiUrl, encounterId, AllEnum.ItemId.ItemRazzBerry, spawnPointGuid, _unknownAuth, _currentLat, _currentLng);

                await Task.Delay(2000);
            }
        }
Example #6
0
        public async Task SetServer()
        {
            var serverRequest = RequestBuilder.GetInitialRequest(_accessToken, _authType, _currentLat, _currentLng, 10,
                RequestType.GET_PLAYER, RequestType.GET_HATCHED_OBJECTS, RequestType.GET_INVENTORY,
                RequestType.CHECK_AWARDED_BADGES, RequestType.DOWNLOAD_SETTINGS);
            var serverResponse = await _httpClient.PostProto<Request>(Resources.RpcUrl, serverRequest);
            _unknownAuth = new Request.Types.UnknownAuth()
            {
                Unknown71 = serverResponse.Auth.Unknown71,
                Timestamp = serverResponse.Auth.Timestamp,
                Unknown73 = serverResponse.Auth.Unknown73,
            };

            _apiUrl = serverResponse.ApiUrl;
        }
Example #7
0
        public async Task SetServer()
        {
            var serverRequest = RequestBuilder.GetInitialRequest(AccessToken, _authType, CurrentLat, CurrentLng, 10,
                RequestType.GET_PLAYER, RequestType.GET_HATCHED_OBJECTS, RequestType.GET_INVENTORY,
                RequestType.CHECK_AWARDED_BADGES, RequestType.DOWNLOAD_SETTINGS);
            var serverResponse = await _httpClient.PostProto<Request>(Resources.RpcUrl, serverRequest);

            if (serverResponse.Auth == null)
                throw new AccessTokenExpiredException();

            _unknownAuth = new Request.Types.UnknownAuth()
            {
                Unknown71 = serverResponse.Auth.Unknown71,
                Timestamp = serverResponse.Auth.Timestamp,
                Unknown73 = serverResponse.Auth.Unknown73,
            };

            _apiUrl = serverResponse.ApiUrl;
            if (_apiUrl != "")
            { 
                Logger.ColoredConsoleWrite(ConsoleColor.Green, "We got the API Url: " + _apiUrl);
            } else
            {
                Logger.Error("PokemonGo Servers are probably Offline.");
            }
        }
Example #8
0
        public static async Task <DownloadSettingsResponse> GetSettings(HttpClient client, string _apiUrl, Request.Types.UnknownAuth _unknownAuth, double _currentLat, double _currentLng)
        {
            var settingsRequest = RequestBuilder.GetRequest(_unknownAuth, _currentLat, _currentLng, 10,
                                                            RequestType.DOWNLOAD_SETTINGS);

            return
                (await
                 client.PostProtoPayload <Request, DownloadSettingsResponse>($"https://{_apiUrl}/rpc",
                                                                             settingsRequest));
        }
Example #9
0
        public static async Task <Item> GetBestBall(HttpClient client, string _apiUrl, Request.Types.UnknownAuth _unknownAuth, double _currentLat, double _currentLng, int?pokemonCP)
        {
            var inventory = await GetInventory(client, _apiUrl, _unknownAuth, _currentLat, _currentLng);

            var ballCollection = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Item)
                                 .Where(p => p != null)
                                 .GroupBy(i => (Item)i.Item_)
                                 .Select(kvp => new { ItemId = kvp.Key, Amount = kvp.Sum(x => x.Count) })
                                 .Where(y => y.ItemId == Item.ITEM_POKE_BALL ||
                                        y.ItemId == Item.ITEM_GREAT_BALL ||
                                        y.ItemId == Item.ITEM_ULTRA_BALL ||
                                        y.ItemId == Item.ITEM_MASTER_BALL);

            var pokeBallsCount = ballCollection.Where(p => p.ItemId == Item.ITEM_POKE_BALL).
                                 DefaultIfEmpty(new { ItemId = Item.ITEM_POKE_BALL, Amount = 0 }).FirstOrDefault().Amount;
            var greatBallsCount = ballCollection.Where(p => p.ItemId == Item.ITEM_GREAT_BALL).
                                  DefaultIfEmpty(new { ItemId = Item.ITEM_GREAT_BALL, Amount = 0 }).FirstOrDefault().Amount;
            var ultraBallsCount = ballCollection.Where(p => p.ItemId == Item.ITEM_ULTRA_BALL).
                                  DefaultIfEmpty(new { ItemId = Item.ITEM_ULTRA_BALL, Amount = 0 }).FirstOrDefault().Amount;
            var masterBallsCount = ballCollection.Where(p => p.ItemId == Item.ITEM_MASTER_BALL).
                                   DefaultIfEmpty(new { ItemId = Item.ITEM_MASTER_BALL, Amount = 0 }).FirstOrDefault().Amount;

            // Use better balls for high CP pokemon
            if (masterBallsCount > 0 && pokemonCP >= 1000)
            {
                return(Item.ITEM_MASTER_BALL);
            }

            if (ultraBallsCount > 0 && pokemonCP >= 600)
            {
                return(Item.ITEM_ULTRA_BALL);
            }

            if (greatBallsCount > 0 && pokemonCP >= 350)
            {
                return(Item.ITEM_GREAT_BALL);
            }

            // If low CP pokemon, but no more pokeballs; only use better balls if pokemon are of semi-worthy quality
            if (pokeBallsCount > 0)
            {
                return(Item.ITEM_POKE_BALL);
            }
            else if ((greatBallsCount < 40 && pokemonCP >= 200) || greatBallsCount >= 40)
            {
                return(Item.ITEM_GREAT_BALL);
            }
            else if (ultraBallsCount > 0 && pokemonCP >= 500)
            {
                return(Item.ITEM_ULTRA_BALL);
            }
            else if (masterBallsCount > 0 && pokemonCP >= 700)
            {
                return(Item.ITEM_MASTER_BALL);
            }

            return(Item.ITEM_POKE_BALL);
        }
Example #10
0
        public async Task <CatchPokemonResponse> CatchPokemon(HttpClient client, string _apiUrl, ulong encounterId, string spawnPointGuid, double pokemonLat,
                                                              double pokemonLng, Enums.Item pokeball, int?pokemonCP, Request.Types.UnknownAuth _unknownAuth, double _currentLat, double _currentLng)
        {
            var customRequest = new Request.Types.CatchPokemonRequest
            {
                EncounterId           = encounterId,
                Pokeball              = (int)PlayerUtils.GetBestBall(client, _apiUrl, _unknownAuth, _currentLat, _currentLng, pokemonCP).Result,
                SpawnPointGuid        = spawnPointGuid,
                HitPokemon            = 1,
                NormalizedReticleSize = Helpers.Extensions.FloatAsUlong(1.950),
                SpinModifier          = Helpers.Extensions.FloatAsUlong(1),
                NormalizedHitPosition = Helpers.Extensions.FloatAsUlong(1)
            };

            var catchPokemonRequest = RequestBuilder.GetRequest(_unknownAuth, _currentLat, _currentLng, 30,
                                                                new Request.Types.Requests
            {
                Type    = (int)RequestType.CATCH_POKEMON,
                Message = customRequest.ToByteString()
            });

            return
                (await
                 client.PostProtoPayload <Request, CatchPokemonResponse>($"https://{_apiUrl}/rpc",
                                                                         catchPokemonRequest));
        }
Example #11
0
        public async Task <GetMapObjectsResponse> GetMapObjects(HttpClient client, string _apiUrl, Request.Types.UnknownAuth _unknownAuth, double _currentLat, double _currentLng)
        {
            var customRequest = new Request.Types.MapObjectsRequest
            {
                CellIds =
                    ByteString.CopyFrom(
                        Protos.EncodeUlongList(S2Utils.GetNearbyCellIds(_currentLng,
                                                                        _currentLat))),
                Latitude  = Helpers.Extensions.FloatAsUlong(_currentLat),
                Longitude = Helpers.Extensions.FloatAsUlong(_currentLng),
                Unknown14 = ByteString.CopyFromUtf8("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")
            };

            var mapRequest = RequestBuilder.GetRequest(_unknownAuth, _currentLat, _currentLng, 10,
                                                       new Request.Types.Requests
            {
                Type    = (int)RequestType.GET_MAP_OBJECTS,
                Message = customRequest.ToByteString()
            },
                                                       new Request.Types.Requests {
                Type = (int)RequestType.GET_HATCHED_OBJECTS
            },
                                                       new Request.Types.Requests
            {
                Type    = (int)RequestType.GET_INVENTORY,
                Message = new Request.Types.Time {
                    Time_ = DateTime.UtcNow.ToUnixTime()
                }.ToByteString()
            },
                                                       new Request.Types.Requests {
                Type = (int)RequestType.CHECK_AWARDED_BADGES
            },
                                                       new Request.Types.Requests
            {
                Type    = (int)RequestType.DOWNLOAD_SETTINGS,
                Message =
                    new Request.Types.SettingsGuid
                {
                    Guid = ByteString.CopyFromUtf8("4a2e9bc330dae60e7b74fc85b98868ab4700802e")
                }.ToByteString()
            });

            return
                (await client.PostProtoPayload <Request, GetMapObjectsResponse>($"https://{_apiUrl}/rpc", mapRequest));
        }
Example #12
0
        public static async Task <UseItemCaptureRequest> UseCaptureItem(HttpClient client, string _apiUrl, ulong encounterId, AllEnum.ItemId itemId, string spawnPointGuid, Request.Types.UnknownAuth _unknownAuth, double _currentLat, double _currentLng)
        {
            var customRequest = new UseItemCaptureRequest
            {
                EncounterId    = encounterId,
                ItemId         = itemId,
                SpawnPointGuid = spawnPointGuid
            };

            var useItemRequest = RequestBuilder.GetRequest(_unknownAuth, _currentLat, _currentLng, 30,
                                                           new Request.Types.Requests()
            {
                Type    = (int)RequestType.USE_ITEM_CAPTURE,
                Message = customRequest.ToByteString()
            });

            return(await client.PostProtoPayload <Request, UseItemCaptureRequest>($"https://{_apiUrl}/rpc", useItemRequest));
        }
 public async Task<ProfileResponse> GetProfile()
 {
     var profileRequest = RequestBuilder.GetInitialRequest(_accessToken, _authType, _currentLat, _currentLng, 10,
         new Request.Types.Requests() {Type = (int) RequestType.GET_PLAYER});
     var profileResponse =
         await _httpClient.PostProto<Request, ProfileResponse>($"https://{_apiUrl}/rpc", profileRequest);
     _unknownAuth = new Request.Types.UnknownAuth()
     {
         Unknown71 = profileResponse.Auth.Unknown71,
         Timestamp = profileResponse.Auth.Timestamp,
         Unknown73 = profileResponse.Auth.Unknown73,
     };
     return profileResponse;
 }
Example #14
0
        public static async Task <GetInventoryResponse> GetInventory(HttpClient client, string _apiUrl, Request.Types.UnknownAuth _unknownAuth, double _currentLat, double _currentLng)
        {
            var inventoryRequest = RequestBuilder.GetRequest(_unknownAuth, _currentLat, _currentLng, 30,
                                                             RequestType.GET_INVENTORY);

            return
                (await
                 client.PostProtoPayload <Request, GetInventoryResponse>($"https://{_apiUrl}/rpc",
                                                                         inventoryRequest));
        }
Example #15
0
        public static async Task <IEnumerable <GeneratedCode.Item> > GetItems(HttpClient client, string _apiUrl, Request.Types.UnknownAuth _unknownAuth, double _currentLat, double _currentLng)
        {
            var inventory = await GetInventory(client, _apiUrl, _unknownAuth, _currentLat, _currentLng);

            return(inventory.InventoryDelta.InventoryItems
                   .Select(i => i.InventoryItemData?.Item)
                   .Where(p => p != null));
        }
Example #16
0
        public static async Task <Response.Types.Unknown6> RecycleItem(HttpClient client, string _apiUrl, AllEnum.ItemId itemId, int amount, Request.Types.UnknownAuth _unknownAuth, double _currentLat, double _currentLng)
        {
            var customRequest = new InventoryItemData.RecycleInventoryItem
            {
                ItemId = (AllEnum.ItemId)Enum.Parse(typeof(AllEnum.ItemId), itemId.ToString()),
                Count  = amount
            };

            var releasePokemonRequest = RequestBuilder.GetRequest(_unknownAuth, _currentLat, _currentLng, 30,
                                                                  new Request.Types.Requests()
            {
                Type    = (int)RequestType.RECYCLE_INVENTORY_ITEM,
                Message = customRequest.ToByteString()
            });

            return(await client.PostProtoPayload <Request, Response.Types.Unknown6>($"https://{_apiUrl}/rpc", releasePokemonRequest));
        }
Example #17
0
        public async Task <EvolvePokemonOut> EvolvePokemon(HttpClient client, string _apiUrl, ulong pokemonId, Request.Types.UnknownAuth _unknownAuth, double _currentLat, double _currentLng)
        {
            var customRequest = new EvolvePokemon
            {
                PokemonId = pokemonId
            };

            var releasePokemonRequest = RequestBuilder.GetRequest(_unknownAuth, _currentLat, _currentLng, 30,
                                                                  new Request.Types.Requests
            {
                Type    = (int)RequestType.EVOLVE_POKEMON,
                Message = customRequest.ToByteString()
            });

            return
                (await
                 client.PostProtoPayload <Request, EvolvePokemonOut>($"https://{_apiUrl}/rpc",
                                                                     releasePokemonRequest));
        }
Example #18
0
        public async Task <EncounterResponse> EncounterPokemon(HttpClient client, string _apiUrl, ulong encounterId, string spawnPointGuid, Request.Types.UnknownAuth _unknownAuth, double _currentLat, double _currentLng)
        {
            var customRequest = new Request.Types.EncounterRequest
            {
                EncounterId      = encounterId,
                SpawnpointId     = spawnPointGuid,
                PlayerLatDegrees = Helpers.Extensions.FloatAsUlong(_currentLat),
                PlayerLngDegrees = Helpers.Extensions.FloatAsUlong(_currentLng)
            };

            var encounterResponse = RequestBuilder.GetRequest(_unknownAuth, _currentLat, _currentLng, 30,
                                                              new Request.Types.Requests
            {
                Type    = (int)RequestType.ENCOUNTER,
                Message = customRequest.ToByteString()
            });

            return
                (await
                 client.PostProtoPayload <Request, EncounterResponse>($"https://{_apiUrl}/rpc", encounterResponse));
        }
Example #19
0
        public static async Task <UseItemRequest> UseItemXpBoost(HttpClient client, string _apiUrl, ItemId itemId, Request.Types.UnknownAuth _unknownAuth, double _currentLat, double _currentLng)
        {
            var customRequest = new UseItemRequest
            {
                ItemId = itemId,
            };

            var useItemRequest = RequestBuilder.GetRequest(_unknownAuth, _currentLat, _currentLng, 30,
                                                           new Request.Types.Requests
            {
                Type    = (int)RequestType.USE_ITEM_XP_BOOST,
                Message = customRequest.ToByteString()
            });

            return
                (await
                 client.PostProtoPayload <Request, UseItemRequest>($"https://{_apiUrl}/rpc",
                                                                   useItemRequest));
        }
Example #20
0
        public static async Task <GetPlayerResponse> GetProfile(HttpClient client, string _accessToken, AuthType _authType, string _apiUrl, Request.Types.UnknownAuth _unknownAuth, double _currentLat, double _currentLng)
        {
            var profileRequest = RequestBuilder.GetInitialRequest(_accessToken, _authType, _currentLat, _currentLng, 10,
                                                                  new Request.Types.Requests {
                Type = (int)RequestType.GET_PLAYER
            });

            return
                (await client.PostProtoPayload <Request, GetPlayerResponse>($"https://{_apiUrl}/rpc", profileRequest));
        }
Example #21
0
        public async Task SetServer()
        {
            var serverRequest = RequestBuilder.GetInitialRequest(AccessToken, _authType, CurrentLat, CurrentLng, CurrentAltitude,
                RequestType.GET_PLAYER, RequestType.GET_HATCHED_OBJECTS, RequestType.GET_INVENTORY,
                RequestType.CHECK_AWARDED_BADGES, RequestType.DOWNLOAD_SETTINGS);
            var serverResponse = await _httpClient.PostProto(Resources.RpcUrl, serverRequest);

            if (serverResponse.Auth == null)
                throw new AccessTokenExpiredException();

            _unknownAuth = new Request.Types.UnknownAuth
            {
                Unknown71 = serverResponse.Auth.Unknown71,
                Timestamp = serverResponse.Auth.Timestamp,
                Unknown73 = serverResponse.Auth.Unknown73
            };

            _apiUrl = serverResponse.ApiUrl;
        }
Example #22
0
        public static async Task <FortSearchResponse> SearchFort(HttpClient client, string _apiUrl, string fortId, double fortLat, double fortLng, Request.Types.UnknownAuth _unknownAuth, double _currentLat, double _currentLng)
        {
            var customRequest = new Request.Types.FortSearchRequest
            {
                Id               = ByteString.CopyFromUtf8(fortId),
                FortLatDegrees   = Helpers.Extensions.FloatAsUlong(fortLat),
                FortLngDegrees   = Helpers.Extensions.FloatAsUlong(fortLng),
                PlayerLatDegrees = Helpers.Extensions.FloatAsUlong(_currentLat),
                PlayerLngDegrees = Helpers.Extensions.FloatAsUlong(_currentLng)
            };

            var fortDetailRequest = RequestBuilder.GetRequest(_unknownAuth, _currentLat, _currentLng, 30,
                                                              new Request.Types.Requests
            {
                Type    = (int)RequestType.FORT_SEARCH,
                Message = customRequest.ToByteString()
            });

            return
                (await
                 client.PostProtoPayload <Request, FortSearchResponse>($"https://{_apiUrl}/rpc",
                                                                       fortDetailRequest));
        }