Search in sources :

Example 1 with IncenseEncounterResponse

use of POGOProtos.Networking.Responses.IncenseEncounterResponseOuterClass.IncenseEncounterResponse in project PokeGOAPI-Java by Grover-c13.

the class IncenseEncounter method encounter.

@Override
public EncounterResult encounter() throws RequestFailedException {
    IncenseEncounterMessage message = IncenseEncounterMessage.newBuilder().setEncounterId(pokemon.getEncounterId()).setEncounterLocation(pokemon.getSpawnPointId()).build();
    ServerRequest request = new ServerRequest(RequestType.INCENSE_ENCOUNTER, message);
    ByteString responseData = api.getRequestHandler().sendServerRequests(request, true);
    try {
        IncenseEncounterResponse response = IncenseEncounterResponse.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 : IncenseEncounterResponse(POGOProtos.Networking.Responses.IncenseEncounterResponseOuterClass.IncenseEncounterResponse) RequestFailedException(com.pokegoapi.exceptions.request.RequestFailedException) ByteString(com.google.protobuf.ByteString) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) IncenseEncounterMessage(POGOProtos.Networking.Requests.Messages.IncenseEncounterMessageOuterClass.IncenseEncounterMessage) ServerRequest(com.pokegoapi.main.ServerRequest)

Aggregations

IncenseEncounterMessage (POGOProtos.Networking.Requests.Messages.IncenseEncounterMessageOuterClass.IncenseEncounterMessage)1 IncenseEncounterResponse (POGOProtos.Networking.Responses.IncenseEncounterResponseOuterClass.IncenseEncounterResponse)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