Skip to content

Commit

Permalink
Merge pull request #6034 from MerlionRock/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Jcolomar authored May 7, 2017
2 parents a33c6b4 + 823ae8c commit 59b3bc4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions configs/config.json.path.example
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
"path_start_mode": "first",
"path_file": "configs/path.example.json",
"number_lap": 10,
"disable_location_output": false,
"timer_restart_min": "00:10:00",
"timer_restart_max": "00:20:00"
}
Expand Down
1 change: 1 addition & 0 deletions docs/configuration_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ option.
- `first` - The bot will start at the first point of the path.
- `closest` - The bot will start the path at the point which is the closest to the current bot location.
* `path_file` - "/path/to/your/path.json"
* `disable_location_output` - true,false. Set to true if you do not want to see follow path updating information. Default false.

### Notice
If you use the `single` `path_mode` without e.g. a `MoveToFort` task, your bot
Expand Down
30 changes: 19 additions & 11 deletions pokemongo_bot/cell_workers/follow_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def initialize(self):

else:
self.ptr = 0

if self.disable_location_output:
self.emit_event(
'position_update',
formatted="Bot in follow path mode, position update disabled. You will not be inform of path taken by bot."
)

def _process_config(self):
self.path_file = self.config.get("path_file", None)
Expand All @@ -48,6 +54,7 @@ def _process_config(self):
self.timer_restart_max = getSeconds(self.config.get("timer_restart_max", "02:00:00"))
self.walker = self.config.get('walker', 'StepWalker')
self.disable_while_hunting = self.config.get("disable_while_hunting", True)
self.disable_location_output = self.config.get('disable_location_output', False)

if self.timer_restart_min > self.timer_restart_max:
raise ValueError('path timer_restart_min is bigger than path timer_restart_max') #TODO there must be a more elegant way to do it...
Expand Down Expand Up @@ -187,17 +194,18 @@ def work(self):
lat,
lng
)

self.emit_event(
'position_update',
formatted="Walking from {last_position} to {current_position}, distance left: ({distance} {distance_unit}) ..",
data={
'last_position': (last_lat, last_lng, last_alt),
'current_position': point["location"],
'distance': format_dist(dist,self.distance_unit,self.append_unit),
'distance_unit': self.distance_unit
}
)

if not self.disable_location_output:
self.emit_event(
'position_update',
formatted="Walking from {last_position} to {current_position}, distance left: ({distance} {distance_unit}) ..",
data={
'last_position': (last_lat, last_lng, last_alt),
'current_position': point["location"],
'distance': format_dist(dist,self.distance_unit,self.append_unit),
'distance_unit': self.distance_unit
}
)

if (self.bot.config.walk_min > 0 and is_at_destination) or (self.status in [STATUS_WANDERING, STATUS_LOITERING] and time.time() >= self.waiting_end_time):
if "loiter" in point and self.status != STATUS_LOITERING:
Expand Down

0 comments on commit 59b3bc4

Please sign in to comment.