Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[newFeature] setFavoritePokemon #219

Closed
@SonnyX

Description

@SonnyX

Description:
Add a method to set the Pokemon as a favorite.

Expected behavior:
When true it becomes favorite, when false it clears it.

Should be placed at Pokemon.java, please add it without breaking checkStyleMain :)

    /**
    * Function to mark the pokemon as favorite or not.
    *
    * @param markFavorite Mark Pokemon as Favorite?
    * @return the SetFavoritePokemonResponse.Result
    * @throws LoginFailedException  the login failed exception
    * @throws RemoteServerException the remote server exception
    */
    public SetFavoritePokemonResponse.Result setFavoritePokemon(boolean markFavorite) 
            throws LoginFailedException, RemoteServerException {
        SetFavoritePokemonMessage reqMsg = SetFavoritePokemonMessage.newBuilder()
                .setPokemonId(getId())
                .setIsFavorite(markFavorite)
                .build();

        ServerRequest serverRequest = new ServerRequest(RequestType.SET_FAVORITE_POKEMON, reqMsg);
        pgo.getRequestHandler().sendServerRequests(serverRequest);

        SetFavoritePokemonResponse response;
        try {
            response = SetFavoritePokemonResponse.parseFrom(serverRequest.getData());
        } catch (InvalidProtocolBufferException e) {
            throw new RemoteServerException(e);
        }

        pgo.getInventories().getPokebank().removePokemon(this);
        pgo.getInventories().updateInventories();

        return response.getResult();
    }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions