From 2fe80a09c3e60eda6fb2d9777ed46345191d48b3 Mon Sep 17 00:00:00 2001 From: Jan-Pascal van Best Date: Mon, 26 Sep 2016 21:50:55 +0200 Subject: [PATCH 1/2] Rename loiter to wander --- docs/configuration_files.md | 10 +++++----- pokemongo_bot/cell_workers/follow_path.py | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/docs/configuration_files.md b/docs/configuration_files.md index f74b9a1500..d22a6b7d5e 100644 --- a/docs/configuration_files.md +++ b/docs/configuration_files.md @@ -882,8 +882,8 @@ This task is an upgrade version of the MoveToMapPokemon task. It will fetch poke Walk to the specified locations loaded from .gpx or .json file. It is highly recommended to use website such as [GPSies](http://www.gpsies.com) which allow you to export your created track in JSON file. Note that you'll have to first convert its JSON file into the format that the bot can understand. See [Example of pier39.json] below for the content. I had created a simple python script to do the conversion. -The json file can contain for each point an optional `loiter` field. This -indicated the number of seconds the bot should loiter after reaching the point. +The json file can contain for each point an optional `wander` field. This +indicated the number of seconds the bot should wander after reaching the point. During this time, the next Task in the configuration file is executed, e.g. a MoveToFort task. This allows the bot to walk around the waypoint looking for forts for a limited time. @@ -902,9 +902,9 @@ forts for a limited time. ### Notice If you use the `single` `path_mode` without e.g. a `MoveToFort` task, your bot with /not move at all/ when the path is finished. Similarly, if you use the -`loiter` option in your json path file without a following `MoveToFort` or -similar task, your bot will not move during the loitering period. Please -make sure, when you use `single` mode or the `loiter` option, that another +`wander` option in your json path file without a following `MoveToFort` or +similar task, your bot will not move during the wandering period. Please +make sure, when you use `single` mode or the `wander` option, that another move-type task follows the `FollowPath` task in your `config.json`. ### Sample Configuration diff --git a/pokemongo_bot/cell_workers/follow_path.py b/pokemongo_bot/cell_workers/follow_path.py index 3bdea10e21..dc5e2545e1 100644 --- a/pokemongo_bot/cell_workers/follow_path.py +++ b/pokemongo_bot/cell_workers/follow_path.py @@ -18,7 +18,7 @@ from datetime import datetime as dt, timedelta STATUS_MOVING = 0 -STATUS_LOITERING = 1 +STATUS_WANDERING = 1 STATUS_FINISHED = 2 class FollowPath(BaseTask): @@ -28,7 +28,7 @@ def initialize(self): self._process_config() self.points = self.load_path() self.status = STATUS_MOVING - self.loiter_end_time = 0 + self.wander_end_time = 0 self.distance_unit = self.bot.config.distance_unit self.append_unit = False @@ -139,11 +139,11 @@ def endLaps(self): self.bot.login() def work(self): - # If done or loitering allow the next task to run + # If done or wandering allow the next task to run if self.status == STATUS_FINISHED: return WorkerResult.SUCCESS - if self.status == STATUS_LOITERING and time.time() < self.loiter_end_time: + if self.status == STATUS_WANDERING and time.time() < self.wander_end_time: return WorkerResult.RUNNING last_lat, last_lng, last_alt = self.bot.position @@ -190,11 +190,13 @@ def work(self): } ) - if (self.bot.config.walk_min > 0 and is_at_destination) or (self.status == STATUS_LOITERING and time.time() >= self.loiter_end_time): - if "loiter" in point and self.status != STATUS_LOITERING: - self.logger.info("Loitering for {} seconds...".format(point["loiter"])) - self.status = STATUS_LOITERING - self.loiter_end_time = time.time() + point["loiter"] + if (self.bot.config.walk_min > 0 and is_at_destination) or (self.status == STATUS_WANDERING and time.time() >= self.wander_end_time): + if "loiter" in point: + self.logger.warning("'loiter' is obsolete, please change to 'wander' in {}".format(self.path_file)) + if "wander" in point and self.status != STATUS_WANDERING: + self.logger.info("Wandering for {} seconds...".format(point["wander"])) + self.status = STATUS_WANDERING + self.wander_end_time = time.time() + point["wander"] return WorkerResult.RUNNING if (self.ptr + 1) == len(self.points): if self.path_mode == 'single': From 25a11d9f4c3b2d7de083e4d393197be3393e04aa Mon Sep 17 00:00:00 2001 From: Jan-Pascal van Best Date: Mon, 26 Sep 2016 21:51:48 +0200 Subject: [PATCH 2/2] Fix wandering, behave like loitering was originally supposed to work --- pokemongo_bot/cell_workers/follow_path.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pokemongo_bot/cell_workers/follow_path.py b/pokemongo_bot/cell_workers/follow_path.py index dc5e2545e1..d0819531eb 100644 --- a/pokemongo_bot/cell_workers/follow_path.py +++ b/pokemongo_bot/cell_workers/follow_path.py @@ -144,7 +144,7 @@ def work(self): return WorkerResult.SUCCESS if self.status == STATUS_WANDERING and time.time() < self.wander_end_time: - return WorkerResult.RUNNING + return WorkerResult.SUCCESS last_lat, last_lng, last_alt = self.bot.position @@ -197,7 +197,7 @@ def work(self): self.logger.info("Wandering for {} seconds...".format(point["wander"])) self.status = STATUS_WANDERING self.wander_end_time = time.time() + point["wander"] - return WorkerResult.RUNNING + return WorkerResult.SUCCESS if (self.ptr + 1) == len(self.points): if self.path_mode == 'single': self.status = STATUS_FINISHED