Search in sources :

Example 1 with DiskEncounterResponse

use of POGOProtos.Networking.Responses.DiskEncounterResponseOuterClass.DiskEncounterResponse in project PokeGOAPI-Java by Grover-c13.

the class DiskEncounter method encounter.

@Override
public EncounterResult encounter() throws RequestFailedException {
    DiskEncounterMessage message = DiskEncounterMessage.newBuilder().setEncounterId(pokemon.encounterId).setFortId(pokemon.spawnPointId).setPlayerLatitude(api.latitude).setPlayerLongitude(api.longitude).build();
    ServerRequest request = new ServerRequest(RequestType.DISK_ENCOUNTER, message);
    ByteString responseData = api.requestHandler.sendServerRequests(request, true);
    try {
        DiskEncounterResponse response = DiskEncounterResponse.parseFrom(responseData);
        encounterResult = EncounterResult.from(response.getResult());
        activeItem = response.getActiveItem();
        captureProbabilities = response.getCaptureProbability();
        encounteredPokemon = response.getPokemonData();
    } catch (InvalidProtocolBufferException e) {
        throw new RequestFailedException(e);
    }
    return encounterResult;
}
Also used : RequestFailedException(com.pokegoapi.exceptions.request.RequestFailedException) ByteString(com.google.protobuf.ByteString) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) DiskEncounterMessage(POGOProtos.Networking.Requests.Messages.DiskEncounterMessageOuterClass.DiskEncounterMessage) DiskEncounterResponse(POGOProtos.Networking.Responses.DiskEncounterResponseOuterClass.DiskEncounterResponse) ServerRequest(com.pokegoapi.main.ServerRequest)

Aggregations

DiskEncounterMessage (POGOProtos.Networking.Requests.Messages.DiskEncounterMessageOuterClass.DiskEncounterMessage)1 DiskEncounterResponse (POGOProtos.Networking.Responses.DiskEncounterResponseOuterClass.DiskEncounterResponse)1 ByteString (com.google.protobuf.ByteString)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 RequestFailedException (com.pokegoapi.exceptions.request.RequestFailedException)1 ServerRequest (com.pokegoapi.main.ServerRequest)1