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

Tasks now extend a base task #2007

Merged
merged 1 commit into from
Jul 31, 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
7 changes: 2 additions & 5 deletions pokemongo_bot/cell_workers/catch_lured_pokemon.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from pokemongo_bot import logger
from pokemongo_bot.cell_workers.utils import fort_details
from pokemongo_bot.cell_workers.pokemon_catch_worker import PokemonCatchWorker
from pokemongo_bot.cell_workers.base_task import BaseTask


class CatchLuredPokemon(object):
def __init__(self, bot, config):
self.bot = bot

class CatchLuredPokemon(BaseTask):
def work(self):
lured_pokemon = self.get_lured_pokemon()
if lured_pokemon:
Expand Down
6 changes: 2 additions & 4 deletions pokemongo_bot/cell_workers/catch_visible_pokemon.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import json

from pokemongo_bot import logger
from pokemongo_bot.cell_workers.base_task import BaseTask
from pokemongo_bot.cell_workers.pokemon_catch_worker import PokemonCatchWorker
from utils import distance


class CatchVisiblePokemon(object):
def __init__(self, bot, config):
self.bot = bot

class CatchVisiblePokemon(BaseTask):
def work(self):
if 'catchable_pokemons' in self.bot.cell and len(self.bot.cell['catchable_pokemons']) > 0:
logger.log('Something rustles nearby!')
Expand Down
8 changes: 2 additions & 6 deletions pokemongo_bot/cell_workers/evolve_all.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
from pokemongo_bot import logger
from pokemongo_bot.human_behaviour import sleep
from pokemongo_bot.item_list import Item
from pokemongo_bot.cell_workers.base_task import BaseTask


class EvolveAll(object):
def __init__(self, bot, config):
self.api = bot.api
self.bot = bot

class EvolveAll(BaseTask):
def work(self):
if not self._should_run():
return
Expand Down
7 changes: 3 additions & 4 deletions pokemongo_bot/cell_workers/follow_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
import gpxpy.gpx
import json
import pokemongo_bot.logger as logger
from pokemongo_bot.cell_workers.base_task import BaseTask
from pokemongo_bot.cell_workers.utils import distance, i2f, format_dist
from pokemongo_bot.human_behaviour import sleep
from pokemongo_bot.step_walker import StepWalker
from pgoapi.utilities import f2i


class FollowPath(object):

def __init__(self, bot, config):
self.bot = bot
class FollowPath(BaseTask):
def initialize(self):
self.ptr = 0
self.points = self.load_path()

Expand Down
7 changes: 3 additions & 4 deletions pokemongo_bot/cell_workers/follow_spiral.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import pokemongo_bot.logger as logger
from pokemongo_bot.cell_workers.utils import distance, format_dist
from pokemongo_bot.step_walker import StepWalker
from pokemongo_bot.cell_workers.base_task import BaseTask


class FollowSpiral(object):
def __init__(self, bot, config):
self.bot = bot

class FollowSpiral(BaseTask):
def initialize(self):
self.steplimit = self.bot.config.max_steps
self.origin_lat = self.bot.position[0]
self.origin_lon = self.bot.position[1]
Expand Down
7 changes: 2 additions & 5 deletions pokemongo_bot/cell_workers/handle_soft_ban.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

from pokemongo_bot import logger
from pokemongo_bot.constants import Constants
from pokemongo_bot.cell_workers.base_task import BaseTask
from pokemongo_bot.cell_workers import MoveToFort
from pokemongo_bot.cell_workers.utils import distance
from pokemongo_bot.worker_result import WorkerResult


class HandleSoftBan(object):

def __init__(self, bot, config):
self.bot = bot

class HandleSoftBan(BaseTask):
def work(self):
if not self.should_run():
return
Expand Down
7 changes: 3 additions & 4 deletions pokemongo_bot/cell_workers/incubate_eggs.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from pokemongo_bot import logger
from pokemongo_bot.human_behaviour import sleep
from pokemongo_bot.cell_workers.base_task import BaseTask


class IncubateEggs(object):
class IncubateEggs(BaseTask):
last_km_walked = 0

def __init__(self, bot, config):
self.bot = bot
self.config = config
def initialize(self):
self.ready_incubators = []
self.used_incubators = []
self.eggs = []
Expand Down
7 changes: 2 additions & 5 deletions pokemongo_bot/cell_workers/move_to_fort.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
from pokemongo_bot.constants import Constants
from pokemongo_bot.step_walker import StepWalker
from pokemongo_bot.worker_result import WorkerResult
from pokemongo_bot.cell_workers.base_task import BaseTask
from utils import distance, format_dist, fort_details


class MoveToFort(object):

def __init__(self, bot, config):
self.bot = bot

class MoveToFort(BaseTask):
def should_run(self):
return (self.bot.has_space_for_loot()) or self.bot.softban

Expand Down
8 changes: 2 additions & 6 deletions pokemongo_bot/cell_workers/recycle_items.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from pokemongo_bot import logger
from pokemongo_bot.cell_workers.base_task import BaseTask


class RecycleItems(object):

def __init__(self, bot, config):
self.bot = bot

class RecycleItems(BaseTask):
def work(self):
self.bot.latest_inventory = None
item_count_dict = self.bot.item_inventory_count('all')
Expand Down
6 changes: 2 additions & 4 deletions pokemongo_bot/cell_workers/spin_fort.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
from pokemongo_bot.constants import Constants
from pokemongo_bot.human_behaviour import sleep
from pokemongo_bot.worker_result import WorkerResult
from pokemongo_bot.cell_workers.base_task import BaseTask
from utils import distance, format_time, fort_details


class SpinFort(object):
def __init__(self, bot, config):
self.bot = bot

class SpinFort(BaseTask):
def should_run(self):
return self.bot.has_space_for_loot()

Expand Down
8 changes: 2 additions & 6 deletions pokemongo_bot/cell_workers/transfer_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

from pokemongo_bot import logger
from pokemongo_bot.human_behaviour import action_delay
from pokemongo_bot.cell_workers.base_task import BaseTask


class TransferPokemon(object):

def __init__(self, bot, config):
self.bot = bot

class TransferPokemon(BaseTask):
def work(self):
pokemon_groups = self._release_pokemon_get_groups()
for pokemon_id in pokemon_groups:
Expand Down