diff --git a/pokemongo_bot/cell_workers/evolve_pokemon.py b/pokemongo_bot/cell_workers/evolve_pokemon.py index bb1f1d2b6f..78b31a9d4c 100644 --- a/pokemongo_bot/cell_workers/evolve_pokemon.py +++ b/pokemongo_bot/cell_workers/evolve_pokemon.py @@ -3,11 +3,13 @@ from pokemongo_bot.inventory import Pokemon from pokemongo_bot.item_list import Item from pokemongo_bot.base_task import BaseTask +from pokemongo_bot.datastore import Datastore - -class EvolvePokemon(BaseTask): +class EvolvePokemon(Datastore, BaseTask): SUPPORTED_TASK_API_VERSION = 1 - + def __init__(self, bot, config): + super(EvolvePokemon, self).__init__(bot, config) + def initialize(self): self.api = self.bot.api self.evolve_all = self.config.get('evolve_all', []) @@ -113,6 +115,8 @@ def _execute_pokemon_evolve(self, pokemon, cache): 'xp': '?' } ) + with self.bot.database as conn: + conn.execute('''INSERT INTO evolve_log (pokemon, iv, cp) VALUES (?, ?, ?)''', (pokemon.name, pokemon.iv, pokemon.cp)) awarded_candies = response_dict.get('responses', {}).get('EVOLVE_POKEMON', {}).get('candy_awarded', 0) inventory.candies().get(pokemon.pokemon_id).consume(pokemon.evolution_cost - awarded_candies) inventory.pokemons().remove(pokemon.unique_id) diff --git a/pokemongo_bot/cell_workers/migrations/evolve_log.py b/pokemongo_bot/cell_workers/migrations/evolve_log.py new file mode 100644 index 0000000000..54b4a7a6de --- /dev/null +++ b/pokemongo_bot/cell_workers/migrations/evolve_log.py @@ -0,0 +1,5 @@ +from yoyo import step + +step( + "CREATE TABLE evolve_log (pokemon text, iv real, cp real, dated datetime DEFAULT CURRENT_TIMESTAMP)" +) diff --git a/pokemongo_bot/cell_workers/migrations/pokestop_log.py b/pokemongo_bot/cell_workers/migrations/pokestop_log.py new file mode 100644 index 0000000000..3c310bd3b9 --- /dev/null +++ b/pokemongo_bot/cell_workers/migrations/pokestop_log.py @@ -0,0 +1,5 @@ +from yoyo import step + +step( + "CREATE TABLE pokestop_log (pokestop text, exp real, items text, dated datetime DEFAULT CURRENT_TIMESTAMP)" +) diff --git a/pokemongo_bot/cell_workers/migrations/transfer_log.py b/pokemongo_bot/cell_workers/migrations/transfer_log.py new file mode 100644 index 0000000000..3c661eac66 --- /dev/null +++ b/pokemongo_bot/cell_workers/migrations/transfer_log.py @@ -0,0 +1,5 @@ +from yoyo import step + +step( + "CREATE TABLE transfer_log (pokemon text, iv real, cp real, dated datetime DEFAULT CURRENT_TIMESTAMP)" +) diff --git a/pokemongo_bot/cell_workers/spin_fort.py b/pokemongo_bot/cell_workers/spin_fort.py index f49d2c1408..b68bd31339 100644 --- a/pokemongo_bot/cell_workers/spin_fort.py +++ b/pokemongo_bot/cell_workers/spin_fort.py @@ -79,12 +79,16 @@ def work(self): 'items': items_awarded } ) + with self.bot.database as conn: + conn.execute('''INSERT INTO pokestop_log (pokestop, exp, items) VALUES (?, ?, ?)''', (fort_name, str(experience_awarded), str(items_awarded))) else: self.emit_event( 'pokestop_empty', formatted='Found nothing in pokestop {pokestop}.', data={'pokestop': fort_name} ) + with self.bot.database as conn: + conn.execute('''INSERT INTO pokestop_log (pokestop) VALUES (?)''', (fort_name)) pokestop_cooldown = spin_details.get( 'cooldown_complete_timestamp_ms') self.bot.fort_timeouts.update({fort["id"]: pokestop_cooldown}) diff --git a/pokemongo_bot/cell_workers/transfer_pokemon.py b/pokemongo_bot/cell_workers/transfer_pokemon.py index 1dfad06d52..8b3affed6f 100644 --- a/pokemongo_bot/cell_workers/transfer_pokemon.py +++ b/pokemongo_bot/cell_workers/transfer_pokemon.py @@ -5,10 +5,13 @@ from pokemongo_bot.human_behaviour import action_delay from pokemongo_bot.base_task import BaseTask from pokemongo_bot.inventory import Pokemons, Pokemon, Attack +from pokemongo_bot.datastore import Datastore -class TransferPokemon(BaseTask): +class TransferPokemon(Datastore, BaseTask): SUPPORTED_TASK_API_VERSION = 1 - + + def __init__(self, bot, config): + super(TransferPokemon, self).__init__(bot, config) def initialize(self): self.transfer_wait_min = self.config.get('transfer_wait_min', 1) self.transfer_wait_max = self.config.get('transfer_wait_max', 4) @@ -175,6 +178,8 @@ def release_pokemon(self, pokemon): 'dps': pokemon.moveset.dps } ) + with self.bot.database as conn: + conn.execute('''INSERT INTO transfer_log (pokemon, iv, cp) VALUES (?, ?, ?)''', (pokemon.name, pokemon.iv, pokemon.cp)) action_delay(self.transfer_wait_min, self.transfer_wait_max) def _get_release_config_for(self, pokemon):