-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* new PolylineWalker(StepWalker) Refactoring in the context of the new walker/navigator concept Fixes: - PolylineWalker class renamed to Polyline - new class PolylineWalker(StepWalker) - change few tests * fixed imports
- Loading branch information
1 parent
47cf9db
commit 9938957
Showing
5 changed files
with
47 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
pokemongo_bot/polyline_walker/__init__.py → pokemongo_bot/walkers/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
from polyline_generator import Polyline | ||
from polyline_walker import PolylineWalker | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
from polyline_generator import Polyline | ||
from math import ceil | ||
from pokemongo_bot.human_behaviour import sleep | ||
from pokemongo_bot.cell_workers.utils import i2f | ||
from pokemongo_bot.step_walker import StepWalker | ||
from pokemongo_bot import logger | ||
|
||
class PolylineWalker(StepWalker): | ||
|
||
def __init__(self, bot, speed, initLat, initLng, destLat, destLng): | ||
super(PolylineWalker, self).__init__(bot, speed, initLat, initLng, destLat, destLng) | ||
self.polyline_walker = Polyline((i2f(self.api._position_lat), i2f(self.api._position_lng)), | ||
(self.destLat, self.destLng), self.speed) | ||
logger.log('[#] {}'.format(self.polyline_walker.URL)) | ||
|
||
def step(self): | ||
self.polyline_walker.unpause() | ||
sleep(1) | ||
self.polyline_walker.pause() | ||
cLat, cLng = self.polyline_walker.get_pos()[0] | ||
self.api.set_position(round(cLat, 5), round(cLng, 5), 0) | ||
self.bot.heartbeat() | ||
if self.destLat == cLat and self.destLng == cLng: | ||
return True |