use of POGOProtos.Networking.Responses.EncounterResponseOuterClass.EncounterResponse in project PokeGOAPI-Java by Grover-c13.
the class Encounter method encounter.
/**
* Encounters this pokemon
*
* @return the result from the attempted encounter
* @throws RequestFailedException if the encounter request fails
*/
protected EncounterResult encounter() throws RequestFailedException {
EncounterMessage message = EncounterMessage.newBuilder().setEncounterId(pokemon.encounterId).setSpawnPointId(pokemon.spawnPointId).setPlayerLatitude(api.latitude).setPlayerLongitude(api.longitude).build();
ServerRequest request = new ServerRequest(RequestType.ENCOUNTER, message);
ByteString responseData = api.requestHandler.sendServerRequests(request, true);
try {
EncounterResponse response = EncounterResponse.parseFrom(responseData);
encounterResult = EncounterResult.from(response.getStatus());
activeItem = response.getActiveItem();
captureProbabilities = response.getCaptureProbability();
encounteredPokemon = response.getWildPokemon().getPokemonData();
} catch (InvalidProtocolBufferException e) {
throw new RequestFailedException(e);
}
return encounterResult;
}
Aggregations