Skip to content

Commit 784fe2a

Browse files
authored
Merge pull request #88 from jabbink/feature-catchWildPokemon
Add WildPokemon to Map.getCatchablePokemon, as they are catchable
2 parents 22c65b7 + 87345ee commit 784fe2a

File tree

2 files changed

+33
-22
lines changed

2 files changed

+33
-22
lines changed

src/main/java/com/pokegoapi/api/map/Map.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import POGOProtos.Map.Fort.FortTypeOuterClass;
55
import POGOProtos.Map.MapCellOuterClass;
66
import POGOProtos.Map.Pokemon.MapPokemonOuterClass;
7+
import POGOProtos.Map.Pokemon.WildPokemonOuterClass;
78
import POGOProtos.Networking.Requests.Messages.*;
89
import POGOProtos.Networking.Requests.RequestTypeOuterClass;
910
import POGOProtos.Networking.Responses.*;
@@ -59,12 +60,15 @@ private MapObjects getRetainedMapObject() throws LoginFailedException, RemoteSer
5960
* @return List<CatchablePokemon> at your current location
6061
*/
6162
public List<CatchablePokemon> getCatchablePokemon() throws LoginFailedException, RemoteServerException {
62-
List<CatchablePokemon> catchablePokemons = new ArrayList<CatchablePokemon>();
63+
List<CatchablePokemon> catchablePokemons = new ArrayList<>();
6364
MapObjects objects = getRetainedMapObject();
6465

6566
for (MapPokemonOuterClass.MapPokemon mapPokemon : objects.getCatchablePokemons()) {
6667
catchablePokemons.add(new CatchablePokemon(api, mapPokemon));
6768
}
69+
for (WildPokemonOuterClass.WildPokemon wildPokemon : objects.getWildPokemons()) {
70+
catchablePokemons.add(new CatchablePokemon(api, wildPokemon));
71+
}
6872

6973
return catchablePokemons;
7074
}

src/main/java/com/pokegoapi/api/map/Pokemon/CatchablePokemon.java

+28-21
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import POGOProtos.Enums.PokemonIdOuterClass;
44
import POGOProtos.Map.Pokemon.MapPokemonOuterClass.MapPokemon;
5+
import POGOProtos.Map.Pokemon.WildPokemonOuterClass.WildPokemon;
56
import POGOProtos.Networking.Requests.Messages.CatchPokemonMessageOuterClass;
67
import POGOProtos.Networking.Requests.Messages.EncounterMessageOuterClass;
78
import POGOProtos.Networking.Requests.RequestTypeOuterClass;
@@ -22,39 +23,45 @@
2223
public class CatchablePokemon {
2324
private static final String TAG = CatchablePokemon.class.getSimpleName();
2425
private final PokemonGo api;
25-
private final MapPokemon proto;
26+
27+
@Getter
28+
private final String spawnpointId;
29+
@Getter
30+
private final long encounterId;
31+
@Getter
32+
private final PokemonIdOuterClass.PokemonId pokemonId;
33+
@Getter
34+
private final long expirationTimestampMs;
35+
@Getter
36+
private final double latitude;
37+
@Getter
38+
private final double longitude;
2639

2740
@Getter
2841
private boolean encountered = false;
2942

3043
public CatchablePokemon(PokemonGo api, MapPokemon proto) {
3144
this.api = api;
32-
this.proto = proto;
33-
}
3445

35-
public String getSpawnpointId() {
36-
return proto.getSpawnpointId();
46+
this.spawnpointId = proto.getSpawnpointId();
47+
this.encounterId = proto.getEncounterId();
48+
this.pokemonId = proto.getPokemonId();
49+
this.expirationTimestampMs = proto.getExpirationTimestampMs();
50+
this.latitude = proto.getLatitude();
51+
this.longitude = proto.getLongitude();
3752
}
3853

39-
public long getEncounterId() {
40-
return proto.getEncounterId();
41-
}
42-
43-
public PokemonIdOuterClass.PokemonId getPokemonId() {
44-
return proto.getPokemonId();
45-
}
46-
47-
public long getExpirationTimestampMs() {
48-
return proto.getExpirationTimestampMs();
49-
}
54+
public CatchablePokemon(PokemonGo api, WildPokemon proto) {
55+
this.api = api;
5056

51-
public double getLatitude() {
52-
return proto.getLatitude();
57+
this.spawnpointId = proto.getSpawnpointId();
58+
this.encounterId = proto.getEncounterId();
59+
this.pokemonId = proto.getPokemonData().getPokemonId();
60+
this.expirationTimestampMs = proto.getTimeTillHiddenMs();
61+
this.latitude = proto.getLatitude();
62+
this.longitude = proto.getLongitude();
5363
}
5464

55-
public double getLongitude() {
56-
return proto.getLongitude();
57-
}
5865

5966
public EncounterResult encounterPokemon() throws LoginFailedException, RemoteServerException {
6067
EncounterMessageOuterClass.EncounterMessage reqMsg = EncounterMessageOuterClass.EncounterMessage.newBuilder()

0 commit comments

Comments
 (0)