-
Notifications
You must be signed in to change notification settings - Fork 330
Adding Sorting Map Objects #396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Grover-c13
merged 13 commits into
Grover-c13:Development
from
Cyperghost:Development-Cyperghost
Aug 1, 2016
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ae2f9c2
Adding map util to get distance between two points
5117384
Adding sorting function for objects in the map
a4af0d1
Adding the check if the user have enough poke ball´s
ca10c6c
Adding the check if the user have enough poke ball´s
0aab5ec
Merge branch 'cyperghost/Development' of https://github.com/Cyperghos…
b3e262d
Adding license
c2f783b
Fixing example class
5bff657
Fix code style
6a93bf4
Updating code style
71be3c5
Updating code style
53999ab
Merge branch 'Development' into cyperghost/Development
7f9599a
Merge commit '53999abb7af9a93e97bcd82b8a0fa304260948f2' into Developm…
b2c93f3
Fixing import
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,11 @@ | |
package com.pokegoapi.api.map; | ||
|
||
import POGOProtos.Map.SpawnPointOuterClass; | ||
import com.pokegoapi.util.MapPoint; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
public class Point { | ||
public class Point implements MapPoint{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. look above |
||
@Getter | ||
@Setter | ||
private double longitude; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,9 +35,11 @@ | |
import com.pokegoapi.api.inventory.ItemBag; | ||
import com.pokegoapi.api.inventory.Pokeball; | ||
import com.pokegoapi.exceptions.LoginFailedException; | ||
import com.pokegoapi.exceptions.NoSuchItemException; | ||
import com.pokegoapi.exceptions.RemoteServerException; | ||
import com.pokegoapi.main.AsyncServerRequest; | ||
import com.pokegoapi.util.FutureWrapper; | ||
import com.pokegoapi.util.MapPoint; | ||
import com.pokegoapi.util.Log; | ||
import com.pokegoapi.util.NestedFutureWrapper; | ||
import com.pokegoapi.util.PokemonFuture; | ||
|
@@ -50,7 +52,7 @@ | |
* The type Catchable pokemon. | ||
*/ | ||
@ToString | ||
public class CatchablePokemon { | ||
public class CatchablePokemon implements MapPoint{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. look above |
||
private static final String TAG = CatchablePokemon.class.getSimpleName(); | ||
private final PokemonGo api; | ||
|
||
|
@@ -174,19 +176,10 @@ public EncounterResult encounterPokemon() throws LoginFailedException, | |
* @throws RemoteServerException if the server failed to respond | ||
*/ | ||
public PokemonFuture<CatchResult> catchPokemonWithRazzBerryAsync() | ||
throws LoginFailedException, RemoteServerException { | ||
final Pokeball pokeball; | ||
throws LoginFailedException, RemoteServerException, NoSuchItemException { | ||
final Pokeball pokeball = getItemBall(); | ||
|
||
|
||
ItemBag bag = api.getInventories().getItemBag(); | ||
if (bag.getItem(ItemId.ITEM_POKE_BALL).getCount() > 0) { | ||
pokeball = Pokeball.POKEBALL; | ||
} else if (bag.getItem(ItemId.ITEM_GREAT_BALL).getCount() > 0) { | ||
pokeball = Pokeball.GREATBALL; | ||
} else if (bag.getItem(ItemId.ITEM_ULTRA_BALL).getCount() > 0) { | ||
pokeball = Pokeball.ULTRABALL; | ||
} else { | ||
pokeball = Pokeball.MASTERBALL; | ||
} | ||
return new NestedFutureWrapper<CatchItemResult, CatchResult>(useItemAsync(ItemId.ITEM_RAZZ_BERRY)) { | ||
@Override | ||
protected Future<CatchResult> handleFuture(CatchItemResult result) { | ||
|
@@ -199,27 +192,40 @@ protected Future<CatchResult> handleFuture(CatchItemResult result) { | |
} | ||
|
||
/** | ||
* Tries to catch a pokemon (will attempt to use a pokeball, if you have | ||
* none will use greatball etc) and uwill use a single razz berry if available. | ||
* Gets item ball to catch a pokemon | ||
* | ||
* @return CatchResult | ||
* @throws LoginFailedException if failed to login | ||
* @throws RemoteServerException if the server failed to respond | ||
* @return the item ball | ||
* @throws LoginFailedException the login failed exception | ||
* @throws RemoteServerException the remote server exception | ||
* @throws NoSuchItemException the no such item exception | ||
*/ | ||
public CatchResult catchPokemonWithRazzBerry() throws LoginFailedException, | ||
RemoteServerException { | ||
Pokeball pokeball; | ||
|
||
public Pokeball getItemBall() throws LoginFailedException, | ||
RemoteServerException, NoSuchItemException { | ||
ItemBag bag = api.getInventories().getItemBag(); | ||
if (bag.getItem(ItemId.ITEM_POKE_BALL).getCount() > 0) { | ||
pokeball = Pokeball.POKEBALL; | ||
return Pokeball.POKEBALL; | ||
} else if (bag.getItem(ItemId.ITEM_GREAT_BALL).getCount() > 0) { | ||
pokeball = Pokeball.GREATBALL; | ||
return Pokeball.GREATBALL; | ||
} else if (bag.getItem(ItemId.ITEM_ULTRA_BALL).getCount() > 0) { | ||
pokeball = Pokeball.ULTRABALL; | ||
return Pokeball.ULTRABALL; | ||
} else if (bag.getItem(ItemId.ITEM_MASTER_BALL).getCount() > 0) { | ||
return Pokeball.MASTERBALL; | ||
} else { | ||
pokeball = Pokeball.MASTERBALL; | ||
throw new NoSuchItemException(); | ||
} | ||
} | ||
|
||
/** | ||
* Tries to catch a pokemon (will attempt to use a pokeball, if you have | ||
* none will use greatball etc) and uwill use a single razz berry if available. | ||
* | ||
* @return CatchResult | ||
* @throws LoginFailedException if failed to login | ||
* @throws RemoteServerException if the server failed to respond | ||
*/ | ||
public CatchResult catchPokemonWithRazzBerry() throws LoginFailedException, | ||
RemoteServerException, NoSuchItemException { | ||
Pokeball pokeball = getItemBall(); | ||
|
||
useItem(ItemId.ITEM_RAZZ_BERRY); | ||
return catchPokemon(pokeball, -1, -1); | ||
|
@@ -234,21 +240,9 @@ public CatchResult catchPokemonWithRazzBerry() throws LoginFailedException, | |
* @throws RemoteServerException if the server failed to respond | ||
*/ | ||
public CatchResult catchPokemon() throws LoginFailedException, | ||
RemoteServerException { | ||
Pokeball pokeball; | ||
|
||
ItemBag bag = api.getInventories().getItemBag(); | ||
if (bag.getItem(ItemId.ITEM_POKE_BALL).getCount() > 0) { | ||
pokeball = Pokeball.POKEBALL; | ||
} else if (bag.getItem(ItemId.ITEM_GREAT_BALL).getCount() > 0) { | ||
pokeball = Pokeball.GREATBALL; | ||
} else if (bag.getItem(ItemId.ITEM_ULTRA_BALL).getCount() > 0) { | ||
pokeball = Pokeball.ULTRABALL; | ||
} else { | ||
pokeball = Pokeball.MASTERBALL; | ||
} | ||
RemoteServerException, NoSuchItemException { | ||
|
||
return catchPokemon(pokeball); | ||
return catchPokemon(getItemBall()); | ||
} | ||
|
||
/** | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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.util; | ||
|
||
/** | ||
* @author Olaf Braun - Software Development | ||
* @version 1.0 | ||
*/ | ||
public interface MapPoint { | ||
/** | ||
* Gets latitude. | ||
* | ||
* @return the latitude | ||
*/ | ||
double getLatitude(); | ||
|
||
/** | ||
* Gets longitude. | ||
* | ||
* @return the longitude | ||
*/ | ||
double getLongitude(); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add space between Point and {