-
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.
* added better rng * forgot adding * rework on polyline * remove wrong files... * remove wrong files... * reverting unnecessory change... * minor fix * get the CI pass * fix test * minor fix
- Loading branch information
1 parent
a58d437
commit b60cefd
Showing
12 changed files
with
106 additions
and
39 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
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
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
6 changes: 3 additions & 3 deletions
6
tests/step_walker_test.py → pokemongo_bot/test/step_walker_test.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
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,2 +0,0 @@ | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from pokemongo_bot.human_behaviour import sleep | ||
from pokemongo_bot.step_walker import StepWalker | ||
from polyline_generator import Polyline | ||
|
||
from pokemongo_bot.walkers.step_walker import StepWalker | ||
from polyline_generator import PolylineObjectHandler | ||
from pokemongo_bot.cell_workers.utils import distance | ||
from pokemongo_bot.constants import Constants | ||
|
||
class PolylineWalker(StepWalker): | ||
''' | ||
Heavy multi-botting can cause issue, since the directions API has limits. | ||
''' | ||
|
||
def __init__(self, bot, speed, dest_lat, dest_lng): | ||
def __init__(self, bot, speed, dest_lat, dest_lng, parent): | ||
super(PolylineWalker, self).__init__(bot, speed, dest_lat, dest_lng) | ||
self.polyline_walker = Polyline((self.api._position_lat, self.api._position_lng), | ||
(self.destLat, self.destLng), self.speed) | ||
self.bot.event_manager.emit( | ||
'polyline_request', | ||
sender=self, | ||
level='info', | ||
formatted="{url}", | ||
data={'url': self.polyline_walker.URL} | ||
self.polyline_walker = PolylineObjectHandler.cached_polyline(bot, (self.api._position_lat, self.api._position_lng), | ||
(self.destLat, self.destLng), self.speed, parent) | ||
self.dist = distance( | ||
self.bot.position[0], | ||
self.bot.position[1], | ||
dest_lat, | ||
dest_lng | ||
) | ||
|
||
def step(self): | ||
cLat, cLng = self.api._position_lat, self.api._position_lng | ||
while (cLat, cLng) != self.polyline_walker.get_pos()[0]: | ||
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() | ||
return True | ||
|
||
if self.dist < 10: # 10m, add config? set it at constants? | ||
PolylineObjectHandler.delete_cache(self.polyline_walker) | ||
return True | ||
|
||
self.polyline_walker.unpause() | ||
sleep(1) | ||
self.polyline_walker.pause() | ||
cLat, cLng = self.polyline_walker.get_pos()[0] | ||
_, _, alt = self.api.get_position() | ||
self.api.set_position(cLat, cLng, alt) | ||
self.bot.heartbeat() | ||
return False | ||
|
4 changes: 2 additions & 2 deletions
4
pokemongo_bot/step_walker.py → pokemongo_bot/walkers/step_walker.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
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,15 @@ | ||
from pokemongo_bot.walkers.polyline_walker import PolylineWalker | ||
from pokemongo_bot.walkers.step_walker import StepWalker | ||
|
||
def walker_factory(name, bot, speed, dest_lat, dest_lng, *args, **kwargs): | ||
''' | ||
Charlie and the Walker Factory | ||
''' | ||
if 'StepWalker' == name: | ||
ret = StepWalker(bot, speed, dest_lat, dest_lng) | ||
elif 'PolylineWalker' == name: | ||
try: | ||
ret = PolylineWalker(bot, speed, dest_lat, dest_lng, *args, **kwargs) | ||
except: | ||
ret = StepWalker(bot, speed, dest_lat, dest_lng) | ||
return ret |