Search in sources :

Example 1 with ReleasePokemonMessage

use of POGOProtos.Networking.Requests.Messages.ReleasePokemonMessageOuterClass.ReleasePokemonMessage in project PokeGOAPI-Java by Grover-c13.

the class Pokemon method transferPokemon.

/**
 * Transfers the pokemon.
 *
 * @return the result
 * @throws RequestFailedException if an exception occurred while sending requests
 */
public Result transferPokemon() throws RequestFailedException {
    if (this.isFavorite() || this.isDeployed()) {
        return Result.FAILED;
    }
    ReleasePokemonMessage reqMsg = ReleasePokemonMessage.newBuilder().setPokemonId(getId()).build();
    ServerRequest serverRequest = new ServerRequest(RequestType.RELEASE_POKEMON, reqMsg);
    api.requestHandler.sendServerRequests(serverRequest, true);
    ReleasePokemonResponse response;
    try {
        response = ReleasePokemonResponse.parseFrom(serverRequest.getData());
    } catch (InvalidProtocolBufferException e) {
        return ReleasePokemonResponse.Result.FAILED;
    }
    if (response.getResult() == Result.SUCCESS) {
        api.inventories.pokebank.removePokemon(this);
    }
    return response.getResult();
}
Also used : ReleasePokemonMessage(POGOProtos.Networking.Requests.Messages.ReleasePokemonMessageOuterClass.ReleasePokemonMessage) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ReleasePokemonResponse(POGOProtos.Networking.Responses.ReleasePokemonResponseOuterClass.ReleasePokemonResponse) ServerRequest(com.pokegoapi.main.ServerRequest)

Aggregations

ReleasePokemonMessage (POGOProtos.Networking.Requests.Messages.ReleasePokemonMessageOuterClass.ReleasePokemonMessage)1 ReleasePokemonResponse (POGOProtos.Networking.Responses.ReleasePokemonResponseOuterClass.ReleasePokemonResponse)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 ServerRequest (com.pokegoapi.main.ServerRequest)1