Created by mjmfighter on 7/20/2016.
| 42 | * Created by mjmfighter on 7/20/2016. |
| 43 | */ |
| 44 | public 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(); |
nothing calls this directly
no outgoing calls
no test coverage detected