Skip to content

Commit

Permalink
Merge pull request Grover-c13#178 from jabbink/feature/fetchPokemonById
Browse files Browse the repository at this point in the history
find Pokemon by ID
  • Loading branch information
jabbink authored Jul 24, 2016
2 parents 80c8052 + 562781f commit c347392
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/pokegoapi/api/inventory/Hatchery.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public List<HatchedEgg> queryHatchedEggs() throws RemoteServerException, LoginFa
} catch (InvalidProtocolBufferException e) {
throw new RemoteServerException(e);
}
instance.getInventories().updateInventories();
List<HatchedEgg> eggs = new ArrayList<HatchedEgg>();
for (int i = 0; i < response.getPokemonIdCount(); i++) {
eggs.add(new HatchedEgg(response.getPokemonId(i),
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/pokegoapi/api/inventory/PokeBank.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,19 @@ public boolean test(Pokemon pokemn) {
}
}).collect(Collectors.<Pokemon>toList());
}

/**
* Get a pokemon by id.
*
* @param id the id
* @return the pokemon
*/
public Pokemon getPokemonById(final Long id) {
for (Pokemon pokemon : pokemons) {
if (pokemon.getId() == id) {
return pokemon;
}
}
return null;
}
}
15 changes: 15 additions & 0 deletions src/main/java/com/pokegoapi/api/pokemon/HatchedEgg.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.pokegoapi.api.pokemon;

import lombok.AllArgsConstructor;
Expand Down

0 comments on commit c347392

Please sign in to comment.