MCPcopy Index your code
hub / github.com/Grover-c13/PokeGOAPI-Java / Pokestop

Class Pokestop

src/main/java/com/pokegoapi/api/map/fort/Pokestop.java:44–259  ·  view source on GitHub ↗

Created by mjmfighter on 7/20/2016.

Source from the content-addressed store, hash-verified

42 * Created by mjmfighter on 7/20/2016.
43 */
44public class Pokestop {
45
46 private final PokemonGo api;
47 @Getter
48 private final FortDataOuterClass.FortData fortData;
49 @Getter
50 private long cooldownCompleteTimestampMs;
51
52
53 /**
54 * Instantiates a new Pokestop.
55 *
56 * @param api the api
57 * @param fortData the fort data
58 */
59 public Pokestop(PokemonGo api, FortDataOuterClass.FortData fortData) {
60 this.api = api;
61 this.fortData = fortData;
62 this.cooldownCompleteTimestampMs = fortData.getCooldownCompleteTimestampMs();
63 }
64
65 /**
66 * Returns whether or not a pokestop is in range.
67 *
68 * @return true when in range of player
69 */
70 public boolean inRange() {
71 S2LatLng pokestop = S2LatLng.fromDegrees(getLatitude(), getLongitude());
72 S2LatLng player = S2LatLng.fromDegrees(api.getLatitude(), api.getLongitude());
73 double distance = pokestop.getEarthDistance(player);
74 return distance < 30;
75 }
76
77 /**
78 * can user loot this from current position.
79 *
80 * @return true when lootable
81 */
82 public boolean canLoot() {
83 return canLoot(false);
84 }
85
86 /**
87 * Can loot boolean.
88 *
89 * @param ignoreDistance the ignore distance
90 * @return the boolean
91 */
92 public boolean canLoot(boolean ignoreDistance) {
93 boolean active = cooldownCompleteTimestampMs < api.currentTimeMillis();
94 if (!ignoreDistance) {
95 return active && inRange();
96 }
97 return active;
98 }
99
100 public String getId() {
101 return fortData.getId();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected