Skip to content
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

Making the config file more user friendly for whitelist/nevertransfer… #225

Merged
merged 1 commit into from
Aug 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.properties.template
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ range=.004
#points in the map path
map_points=15
# Only whitelist certain pokemons
whitelisted_pokemon=10,13,16
whitelisted_pokemon=CATERPIE,WEEDLE,PIDGEY
# List of Pokémons ids to NEVER transfer, separated by commas.
never_transfer=
# Enable events notifications on console output
Expand Down
72 changes: 37 additions & 35 deletions src/main/java/dekk/pw/pokemate/Config.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dekk.pw.pokemate;

import POGOProtos.Enums.PokemonIdOuterClass;
import POGOProtos.Inventory.Item.ItemIdOuterClass;
import dekk.pw.pokemate.tasks.Navigate;

Expand All @@ -10,6 +11,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors;

/**
* Created by $ Tim Dekker on 7/23/2016.
Expand All @@ -28,10 +30,10 @@ public class Config {
private static boolean autoEvolving;
private static double range;
private static int mapPoints;
private static List<Integer> whiteListedPokemon;
private static List<Integer> ignoreCatchingPokemon;
private static List<Integer> neverTransferPokemon;
private static List<String> droppedItems;
private static List<String> whiteListedPokemon;
private static List<String> ignoreCatchingPokemon;
private static List<String> neverTransferPokemon;
private static List<String> droppedItems;
private static boolean consoleNotification;
private static boolean userInterfaceNotification;
private static boolean uiSystemNotification;
Expand All @@ -40,7 +42,7 @@ public class Config {
private static boolean eggsIncubating;
private static boolean eggsHatching;
private static boolean transferPrefersIV;
private static int cpMinimumForMessage;
private static int cpMinimumForMessage;
private static Navigate.NavigationType navigationType;
private static Properties properties = new Properties();
private static int minItemAmount;
Expand All @@ -65,29 +67,29 @@ public static void load(String configPath) {
//whitelist
String whiteList = properties.getProperty("whitelisted_pokemon", null);
whiteListedPokemon = new ArrayList<>();
fillList(whiteList, whiteListedPokemon);
fillListString(whiteList, whiteListedPokemon);
String neverTransferPokemonNames = properties.getProperty("never_transfer", null);
neverTransferPokemon = new ArrayList<>();
fillList(neverTransferPokemonNames, neverTransferPokemon);
fillListString(neverTransferPokemonNames, neverTransferPokemon);

//pokemon catching ignore
String ignoreCatch = properties.getProperty("ignore_catching_pokemon", null);
ignoreCatchingPokemon = new ArrayList<>();
fillList(ignoreCatch, ignoreCatchingPokemon);
fillListString(ignoreCatch, ignoreCatchingPokemon);
// named location
useCustomNamedLocation = Boolean.parseBoolean(properties.getProperty("use_location_name", "false"));
customNamedLocation = properties.getProperty("location_by_name");
// notification
consoleNotification = Boolean.parseBoolean(properties.getProperty("console_notification", "true"));
userInterfaceNotification = Boolean.parseBoolean(properties.getProperty("ui_notification", "true"));
uiSystemNotification = Boolean.parseBoolean(properties.getProperty("sys_notification", "false"));
// dropped items
dropItems = Boolean.parseBoolean(properties.getProperty("drop_items", "true"));
String droppedItemNames = properties.getProperty("drop_item_list", "ITEM_POTION,ITEM_SUPER_POTION,ITEM_MAX_POTION,ITEM_HYPER_POTION,ITEM_RAZZ_BERRY,ITEM_REVIVE,ITEM_MAX_REVIVE");
droppedItems = new ArrayList<>();
fillListString(droppedItemNames, droppedItems);
// minimum cp for message
cpMinimumForMessage = Integer.parseInt(properties.getProperty("minimum_cp_for_ui_message", "0"));
// dropped items
dropItems = Boolean.parseBoolean(properties.getProperty("drop_items", "true"));
String droppedItemNames = properties.getProperty("drop_item_list", "ITEM_POTION,ITEM_SUPER_POTION,ITEM_MAX_POTION,ITEM_HYPER_POTION,ITEM_RAZZ_BERRY,ITEM_REVIVE,ITEM_MAX_REVIVE");
droppedItems = new ArrayList<>();
fillListString(droppedItemNames, droppedItems);
// minimum cp for message
cpMinimumForMessage = Integer.parseInt(properties.getProperty("minimum_cp_for_ui_message", "0"));
navigationType = Navigate.NavigationType.valueOf(properties.getProperty("navigation_type","STREETS"));
minItemAmount = Integer.parseInt(properties.getProperty("minimum_item_amount", "0"));

Expand All @@ -107,8 +109,8 @@ private static void fillListString(String propertiesString, List<String> target)
}

Arrays.asList(propertiesString.split(",")).stream()
.filter(s -> s.length() > 0)
.forEach(target::add);
.filter(s -> s.length() > 0)
.forEach(target::add);
}

private static void fillList(String propertiesString, List<Integer> target) {
Expand All @@ -117,9 +119,9 @@ private static void fillList(String propertiesString, List<Integer> target) {
}

Arrays.asList(propertiesString.split(",")).stream()
.filter(s -> s.length() > 0)
.map(Integer::parseInt)
.forEach(target::add);
.filter(s -> s.length() > 0)
.map(Integer::parseInt)
.forEach(target::add);
}


Expand Down Expand Up @@ -176,19 +178,19 @@ public static int getMapPoints() {
}

public static boolean isWhitelistEnabled() {
List<Integer> poke = getWhitelistedPokemon();
List<PokemonIdOuterClass.PokemonId> poke = getWhitelistedPokemon();
return poke != null && poke.size() > 0;
}

public static List<Integer> getWhitelistedPokemon() {
return whiteListedPokemon;
public static List<PokemonIdOuterClass.PokemonId> getWhitelistedPokemon() {
return(whiteListedPokemon.stream().map(pokeId -> PokemonIdOuterClass.PokemonId.valueOf(pokeId)).collect(Collectors.toList()));
}

public static List<Integer> getNeverTransferPokemon() {
return neverTransferPokemon;
public static List<PokemonIdOuterClass.PokemonId> getNeverTransferPokemon() {
return(neverTransferPokemon.stream().map(pokeId -> PokemonIdOuterClass.PokemonId.valueOf(pokeId)).collect(Collectors.toList()));
}
public static List<Integer> getIgnoreCatchingPokemon() {
return ignoreCatchingPokemon;
public static List<PokemonIdOuterClass.PokemonId> getIgnoreCatchingPokemon() {
return(ignoreCatchingPokemon.stream().map(pokeId -> PokemonIdOuterClass.PokemonId.valueOf(pokeId)).collect(Collectors.toList()));
}


Expand Down Expand Up @@ -219,14 +221,14 @@ public static boolean isEggsIncubating() {
public static boolean isEggsHatching() {
return eggsHatching;
}
public static List<String> getDroppedItems() {
return droppedItems;
}
public static int getMinimumCPForMessage() {
return cpMinimumForMessage;
}

public static List<String> getDroppedItems() {
return droppedItems;
}

public static int getMinimumCPForMessage() {
return cpMinimumForMessage;
}

public static boolean isTransferPrefersIV() {
return transferPrefersIV;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dekk/pw/pokemate/tasks/CatchPokemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void run() {


private boolean shouldIgnore(final CatchablePokemon p) {
return !Config.getIgnoreCatchingPokemon().contains(p.getPokemonId().getNumber());
return !Config.getIgnoreCatchingPokemon().contains(p.getPokemonId());
}

private List<Pokemon> pokemons() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dekk/pw/pokemate/tasks/EvolvePokemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void run() {
try {
CopyOnWriteArrayList<Pokemon> pokeList = new CopyOnWriteArrayList<>(context.getApi().getInventories().getPokebank().getPokemons());
for (Pokemon pokemon : pokeList)
if (!Config.isWhitelistEnabled() || Config.getWhitelistedPokemon().contains(pokemon.getPokemonId().getNumber())) {
if (!Config.isWhitelistEnabled() || Config.getWhitelistedPokemon().contains(pokemon.getPokemonId())) {
int number = pokemon.getPokemonId().getNumber();
if (CANDY_AMOUNTS.containsKey(number)) {
int required = CANDY_AMOUNTS.get(number);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dekk/pw/pokemate/tasks/ReleasePokemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void run() {
list.stream().filter(p -> (minCP <= 1 || p.getCp() < minCP) &&
list.indexOf(p) < list.size() - 1 &&
context.getIvRatio(p) < Config.getIvRatio() &&
!Config.getNeverTransferPokemon().contains(p.getPokemonId().getNumber())).forEach(p -> {
!Config.getNeverTransferPokemon().contains(p.getPokemonId())).forEach(p -> {
//Passing this filter means they are not a 'perfect pokemon'
try {
p.transferPokemon();
Expand Down