예제 #1
0
        public async Task <DownloadSettingsResponse> GetSettings()
        {
            var message = new DownloadSettingsMessage
            {
                Hash = "05daf51635c82611d1aac95c0b051d3ec088a930"
            };

            return(await _baseRpc.PostProtoPayload <Request, DownloadSettingsResponse>(RequestType.DownloadSettings, message));
        }
예제 #2
0
파일: ApiMisc.cs 프로젝트: wuyou/HaxtonBot
 public async Task <ClaimCodenameResponse> ClaimCodename(string codename)
 {
     return
         (await
          _baseRpc.PostProtoPayload <Request, ClaimCodenameResponse>(RequestType.ClaimCodename,
                                                                     new ClaimCodenameMessage()
     {
         Codename = codename
     }));
 }
예제 #3
0
        public async Task <GetMapObjectsResponse> GetMapObjects()
        {
            var getMapObjectsMessage = new GetMapObjectsMessage
            {
                CellId           = { S2Helper.GetNearbyCellIds(_client.CurrentLongitude, _client.CurrentLatitude) },
                SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                Latitude         = _client.CurrentLatitude,
                Longitude        = _client.CurrentLongitude
            };
            var getHatchedEggsMessage = new GetHatchedEggsMessage();
            var getInventoryMessage   = new GetInventoryMessage
            {
                LastTimestampMs = DateTime.UtcNow.ToUnixTime()
            };
            var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage();
            var downloadSettingsMessage   = new DownloadSettingsMessage
            {
                Hash = "05daf51635c82611d1aac95c0b051d3ec088a930"
            };

            var request = _baseRpc.RequestBuilder.GetRequestEnvelope(
                new Request
            {
                RequestType    = RequestType.GetMapObjects,
                RequestMessage = getMapObjectsMessage.ToByteString()
            },
                new Request
            {
                RequestType    = RequestType.GetHatchedEggs,
                RequestMessage = getHatchedEggsMessage.ToByteString()
            }, new Request
            {
                RequestType    = RequestType.GetInventory,
                RequestMessage = getInventoryMessage.ToByteString()
            }, new Request
            {
                RequestType    = RequestType.CheckAwardedBadges,
                RequestMessage = checkAwardedBadgesMessage.ToByteString()
            }, new Request
            {
                RequestType    = RequestType.DownloadSettings,
                RequestMessage = downloadSettingsMessage.ToByteString()
            });

            return(await _baseRpc.PostProtoPayload <Request, GetMapObjectsResponse>(request));
        }
예제 #4
0
        public async Task <FortDetailsResponse> GetFort(string fortId, double fortLatitude, double fortLongitude)
        {
            var message = new FortDetailsMessage
            {
                FortId    = fortId,
                Latitude  = fortLatitude,
                Longitude = fortLongitude
            };

            return(await _baseRpc.PostProtoPayload <Request, FortDetailsResponse>(RequestType.FortDetails, message));
        }
예제 #5
0
        public async Task <EncounterResponse> EncounterPokemon(ulong encounterId, string spawnPointGuid)
        {
            var message = new EncounterMessage
            {
                EncounterId     = encounterId,
                SpawnPointId    = spawnPointGuid,
                PlayerLatitude  = _client.CurrentLatitude,
                PlayerLongitude = _client.CurrentLongitude
            };

            return(await _baseRpc.PostProtoPayload <Request, EncounterResponse>(RequestType.Encounter, message));
        }
예제 #6
0
        public async Task <PlayerUpdateResponse> UpdatePlayerLocation(double latitude, double longitude, double altitude)
        {
            SetCoordinates(latitude, longitude, altitude);
            var message = new PlayerUpdateMessage
            {
                Latitude  = _client.CurrentLatitude,
                Longitude = _client.CurrentLongitude
            };

            var updatePlayerLocationRequestEnvelope = _baseRpc.RequestBuilder.GetRequestEnvelope(
                new Request
            {
                RequestType    = RequestType.PlayerUpdate,
                RequestMessage = message.ToByteString()
            });

            return(await _baseRpc.PostProtoPayload <Request, PlayerUpdateResponse>(updatePlayerLocationRequestEnvelope));
        }
예제 #7
0
        public async Task <ReleasePokemonResponse> TransferPokemon(ulong pokemonId)
        {
            var message = new ReleasePokemonMessage
            {
                PokemonId = pokemonId
            };

            return(await _baseRpc.PostProtoPayload <Request, ReleasePokemonResponse>(RequestType.ReleasePokemon, message));
        }
예제 #8
0
        public async Task <Tuple <GetMapObjectsResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse> > GetMapObjects()
        {
            while (CanGetMap == false)
            {
                await Task.Delay(150);
            }
            CanGetMap = false;
            var getMapObjectsMessage = new GetMapObjectsMessage
            {
                CellId           = { S2Helper.GetNearbyCellIds(_client.CurrentLongitude, _client.CurrentLatitude) },
                SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                Latitude         = _client.CurrentLatitude,
                Longitude        = _client.CurrentLongitude
            };
            var getHatchedEggsMessage = new GetHatchedEggsMessage();
            var getInventoryMessage   = new GetInventoryMessage
            {
                LastTimestampMs = DateTime.UtcNow.ToUnixTime()
            };
            var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage();
            var downloadSettingsMessage   = new DownloadSettingsMessage
            {
                Hash = "05daf51635c82611d1aac95c0b051d3ec088a930"
            };

            var request = _baseRpc.RequestBuilder.GetRequestEnvelope(
                new Request
            {
                RequestType    = RequestType.GetMapObjects,
                RequestMessage = getMapObjectsMessage.ToByteString()
            },
                new Request
            {
                RequestType    = RequestType.GetHatchedEggs,
                RequestMessage = getHatchedEggsMessage.ToByteString()
            }, new Request
            {
                RequestType    = RequestType.GetInventory,
                RequestMessage = getInventoryMessage.ToByteString()
            }, new Request
            {
                RequestType    = RequestType.CheckAwardedBadges,
                RequestMessage = checkAwardedBadgesMessage.ToByteString()
            }, new Request
            {
                RequestType    = RequestType.DownloadSettings,
                RequestMessage = downloadSettingsMessage.ToByteString()
            });

            var response = await _baseRpc.PostProtoPayload <Request, GetMapObjectsResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse>(request);

            _pokemons.AddRange(response.Item1.MapCells.SelectMany(x => x.CatchablePokemons));

            //var pokestops = response.Item1.MapCells.SelectMany(t => t.Forts).Where(x => x.Type == FortType.Checkpoint);
            //_pokestops.AddRange(pokestops);
            //var newMapObjects = response.MapCells.SelectMany(x => x.WildPokemons).Select(t => new MapPokemon()
            //{
            //    EncounterId = t.EncounterId,
            //    ExpirationTimestampMs = t.TimeTillHiddenMs,
            //    Latitude = t.Latitude,
            //    Longitude = t.Longitude,
            //    PokemonId = t.PokemonData.PokemonId,
            //    SpawnPointId = t.SpawnPointId
            //});
            //_pokemons.AddRange(newMapObjects);
            //var lurePokemon =
            //    response.MapCells.SelectMany(f => f.Forts).Where(t => t.LureInfo != null).Select(l => new MapPokemon()
            //    {
            //        EncounterId = l.LureInfo.EncounterId,
            //        ExpirationTimestampMs = l.LureInfo.LureExpiresTimestampMs,
            //        Latitude = l.Latitude,
            //        Longitude = l.Longitude,
            //        PokemonId = l.LureInfo.ActivePokemonId,
            //        SpawnPointId = l.Id
            //    });
            //_pokemons.AddRange(lurePokemon);
            _pokemons = _pokemons.Where(t => t.ExpirationTimestampMs > DateTime.UtcNow.ToUnixTime()).ToList();
            return(response);
        }