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

Only work on forts when there is space in the bag. Do not switch mode #1237

Merged
merged 2 commits into from
Jul 27, 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
18 changes: 11 additions & 7 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def start(self):
random.seed()

def take_step(self):
self.process_cells(work_on_forts=True)
self.process_cells()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

work_on_forts was no longer set to False anywhere, since some of the changes yesterday.


def process_cells(self, work_on_forts=True):
def process_cells(self):
location = self.position[0:2]
cells = self.find_close_cells(*location)

Expand All @@ -64,7 +64,7 @@ def process_cells(self, work_on_forts=True):

# Have the worker treat the whole area as a single cell.
self.work_on_cell({"forts": forts, "wild_pokemons": wild_pokemons,
"catchable_pokemons": catchable_pokemons}, location, work_on_forts)
"catchable_pokemons": catchable_pokemons}, location)

def update_web_location(self, cells=[], lat=None, lng=None, alt=None):
# we can call the function with no arguments and still get the position and map_cells
Expand Down Expand Up @@ -156,7 +156,7 @@ def find_close_cells(self, lat, lng):
)
return map_cells

def work_on_cell(self, cell, position, work_on_forts=1):
def work_on_cell(self, cell, position):
# Check if session token has expired
self.check_session(position)

Expand All @@ -174,8 +174,11 @@ def work_on_cell(self, cell, position, work_on_forts=1):
if worker.work() == WorkerResult.RUNNING:
return

if ((self.config.mode == "all" or
self.config.mode == "farm") and work_on_forts):

number_of_things_gained_by_stop = 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this variable do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just make it clear why the number is there.


if ((self.get_inventory_count('item') < self._player['max_item_storage'] - 5) and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually possible for stops to give out more than 5 items. I've seen it give out 6 in the actual game.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think I've seen someone say 7 on reddit. I'd be happy to set it to that, but I was kinda trying to go with the average case instead of the best case.

(self.config.mode == "all" or self.config.mode == "farm")):
if 'forts' in cell:
# Only include those with a lat/long
forts = [fort
Expand Down Expand Up @@ -273,7 +276,8 @@ def _print_character_info(self):
currency_2 = "0"

if response_dict:
player = response_dict['responses']['GET_PLAYER']['player_data']
self._player = response_dict['responses']['GET_PLAYER']['player_data']
player = self._player
else:
logger.log("The API didn't return player info, servers are unstable - retrying.", 'red')
sleep(5)
Expand Down
3 changes: 1 addition & 2 deletions pokemongo_bot/cell_workers/seen_fort_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ def work(self):
format_time((pokestop_cooldown / 1000) -
seconds_since_epoch)))
elif spin_result == 4:
logger.log("Inventory is full, switching to catch mode...", 'red')
self.config.mode = 'poke'
logger.log("Inventory is full", 'red')
else:
logger.log("Unknown spin result: " + str(spin_result), 'red')

Expand Down