Skip to content
Closed
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
17 changes: 13 additions & 4 deletions configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@
"config": {
"lure_attraction": true,
"lure_max_distance": 2000
}
},
{
"type": "FollowSpiral"
"type": "FollowSpiral",
"config": {
"diameter": 4,
"step_size": 70
}
}
],
"map_object_cache_time": 5,
"max_steps": 5,
"forts": {
"avoid_circles": true,
"max_circle_size": 50
Expand All @@ -78,8 +82,13 @@
"distance_unit": "km",
"reconnecting_timeout": 15,
"evolve_captured": "NONE",
"catch_randomize_reticle_factor": 1.0,
"catch_randomize_spin_factor": 1.0,
"catch_throw_parameters": {
"excellent_rate": 0.1,
"great_rate": 0.5,
"nice_rate": 0.3,
"normal_rate": 0.1,
"spin_success_rate" : 0.6,
},
"catch": {
"any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"},
"// Example of always catching Rattata:": {},
Expand Down
6 changes: 5 additions & 1 deletion configs/config.json.pokemon.example
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@
"type": "SpinFort"
},
{
"type": "MoveToFort"
"type": "MoveToFort",
"config":{
"lure_attraction": true,
"lure_max_distance": 2000
}
},
{
"type": "FollowSpiral"
Expand Down
68 changes: 40 additions & 28 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,6 @@ def init_config():
type=str,
default=None
)
add_config(
parser,
load,
short_flag="-ms",
long_flag="--max_steps",
help=
"Set the steps around your initial location(DEFAULT 5 mean 25 cells around your location)",
type=int,
default=50
)

add_config(
parser,
Expand Down Expand Up @@ -311,26 +301,55 @@ def init_config():
add_config(
parser,
load,
long_flag="--catch_randomize_reticle_factor",
help="Randomize factor for pokeball throwing accuracy (DEFAULT 1.0 means no randomize: always 'Excellent' throw. 0.0 randomizes between normal and 'Excellent' throw)",
long_flag="--map_object_cache_time",
help="Amount of seconds to keep the map object in cache (bypass Niantic throttling)",
type=float,
default=1.0
default=5.0
)
add_config(
parser,
load,
long_flag="--catch_randomize_spin_factor",
help="Randomize factor for pokeball curve throwing (DEFAULT 1.0 means no randomize: always perfect 'Super Spin' curve ball. 0.0 randomizes between normal and 'Super Spin' curve ball)",
short_flag="-cte",
long_flag="--catch_throw_parameters.excellent_rate",
help="Define the odd of performing an excellent throw",
type=float,
default=1.0
default=1,
)
add_config(
parser,
load,
long_flag="--map_object_cache_time",
help="Amount of seconds to keep the map object in cache (bypass Niantic throttling)",
short_flag="-ctg",
long_flag="--catch_throw_parameters.great_rate",
help="Define the odd of performing a great throw",
type=float,
default=5.0
default=0,
)
add_config(
parser,
load,
short_flag="-ctn",
long_flag="--catch_throw_parameters.nice_rate",
help="Define the odd of performing a nice throw",
type=float,
default=0,
)
add_config(
parser,
load,
short_flag="-ctm",
long_flag="--catch_throw_parameters.normal_rate",
help="Define the odd of performing a normal throw",
type=float,
default=0,
)
add_config(
parser,
load,
short_flag="-cts",
long_flag="--catch_throw_parameters.spin_success_rate",
help="Define the odds of performing a spin throw (Value between 0 (never) and 1 (always))",
type=float,
default=1,
)

# Start to parse other attrs
Expand All @@ -346,6 +365,7 @@ def init_config():
config.action_wait_min = load.get('action_wait_min', 1)
config.raw_tasks = load.get('tasks', [])
config.vips = load.get('vips',{})
config.catch_throw_parameters = load.get('catch_throw_parameters', {'excellent_rate': 1.0, 'spin_success_rate': 1.0})

if config.map_object_cache_time < 0.0:
parser.error("--map_object_cache_time is out of range! (should be >= 0.0)")
Expand All @@ -367,7 +387,7 @@ def task_configuration_error(flag_name):
""".format(flag_name))

old_flags = ['mode', 'catch_pokemon', 'spin_forts', 'forts_spin', 'hatch_eggs', 'release_pokemon', 'softban_fix',
'longer_eggs_first', 'evolve_speed', 'use_lucky_egg', 'item_filter', 'evolve_all', 'evolve_cp_min']
'longer_eggs_first', 'evolve_speed', 'use_lucky_egg', 'item_filter', 'evolve_all', 'evolve_cp_min', 'max_steps']
for flag in old_flags:
if flag in load:
task_configuration_error(flag)
Expand All @@ -390,14 +410,6 @@ def task_configuration_error(flag_name):
parser.error("Needs either --use-location-cache or --location.")
return None

if config.catch_randomize_reticle_factor < 0 or 1 < config.catch_randomize_reticle_factor:
parser.error("--catch_randomize_reticle_factor is out of range! (should be 0 <= catch_randomize_reticle_factor <= 1)")
return None

if config.catch_randomize_spin_factor < 0 or 1 < config.catch_randomize_spin_factor:
parser.error("--catch_randomize_spin_factor is out of range! (should be 0 <= catch_randomize_spin_factor <= 1)")
return None

# create web dir if not exists
try:
os.makedirs(web_dir)
Expand Down
44 changes: 22 additions & 22 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class PokemonGoBot(object):
def position(self):
return self.api._position_lat, self.api._position_lng, 0

@position.setter
def position(self, position_tuple):
self.api._position_lat, self.api._position_lng, self.api._position_alt = position_tuple

def __init__(self, config):
self.config = config
self.fort_timeouts = dict()
Expand Down Expand Up @@ -103,7 +107,7 @@ def get_meta_cell(self):
wild_pokemons += cell["wild_pokemons"]
if "catchable_pokemons" in cell and len(cell["catchable_pokemons"]):
catchable_pokemons += cell["catchable_pokemons"]

# If there are forts present in the cells sent from the server or we don't yet have any cell data, return all data retrieved
if len(forts) > 1 or not self.cell:
return {
Expand Down Expand Up @@ -138,14 +142,13 @@ def update_web_location(self, cells=[], lat=None, lng=None, alt=None):
if 'forts' in cell:
for fort in cell['forts']:
if fort.get('type') != 1:
self.api.get_gym_details(
response_gym_details = self.api.get_gym_details(
gym_id=fort.get('id'),
player_latitude=lng,
player_longitude=lat,
gym_latitude=fort.get('latitude'),
gym_longitude=fort.get('longitude')
)
response_gym_details = self.api.call()
fort['gym_details'] = response_gym_details.get(
'responses', {}
).get('GET_GYM_DETAILS', None)
Expand Down Expand Up @@ -239,6 +242,9 @@ def check_session(self, position):

if remaining_time < 60:
logger.log("Session stale, re-logging in", 'yellow')
position = self.position
self.api = ApiWrapper()
self.position = position
self.login()

@staticmethod
Expand All @@ -251,13 +257,13 @@ def is_numeric(s):

def login(self):
logger.log('Attempting login to Pokemon Go.', 'white')
self.api.reset_auth()
lat, lng = self.position[0:2]
self.api.set_position(lat, lng, 0)

while not self.api.login(self.config.auth_service,
str(self.config.username),
str(self.config.password)):
while not self.api.login(
self.config.auth_service,
str(self.config.username),
str(self.config.password)):

logger.log('[X] Login Error, server busy', 'red')
logger.log('[X] Waiting 10 seconds to try again', 'red')
Expand All @@ -267,7 +273,7 @@ def login(self):

def _setup_api(self):
# instantiate pgoapi
self.api = ApiWrapper(PGoApi())
self.api = ApiWrapper()

# provide player position on the earth
self._set_starting_position()
Expand All @@ -286,8 +292,7 @@ def _setup_api(self):
def _print_character_info(self):
# get player profile call
# ----------------------
self.api.get_player()
response_dict = self.api.call()
response_dict = self.api.get_player()
# print('Response dictionary: \n\r{}'.format(json.dumps(response_dict, indent=2)))
currency_1 = "0"
currency_2 = "0"
Expand Down Expand Up @@ -368,15 +373,11 @@ def _print_character_info(self):
logger.log('')

def use_lucky_egg(self):
self.api.use_item_xp_boost(item_id=301)
inventory_req = self.api.call()
return inventory_req
return self.api.use_item_xp_boost(item_id=301)

def get_inventory(self):
if self.latest_inventory is None:
self.api.get_inventory()
response = self.api.call()
self.latest_inventory = response
self.latest_inventory = self.api.get_inventory()
return self.latest_inventory

def update_inventory(self):
Expand Down Expand Up @@ -538,9 +539,10 @@ def heartbeat(self):
self.fort_timeouts = {id: timeout for id, timeout
in self.fort_timeouts.iteritems()
if timeout >= time.time() * 1000}
self.api.get_player()
self.api.check_awarded_badges()
self.api.call()
request = self.api.create_request()
request.get_player()
request.check_awarded_badges()
request.call()
self.update_web_location() # updates every tick

def get_inventory_count(self, what):
Expand Down Expand Up @@ -620,14 +622,12 @@ def get_map_objects(self, lat, lng, timestamp, cellid):
if time.time() - self.last_time_map_object < self.config.map_object_cache_time:
return self.last_map_object

self.api.get_map_objects(
self.last_map_object = self.api.get_map_objects(
latitude=f2i(lat),
longitude=f2i(lng),
since_timestamp_ms=timestamp,
cell_id=cellid
)

self.last_map_object = self.api.call()
self.last_time_map_object = time.time()

return self.last_map_object
Loading