Skip to content

Commit

Permalink
Display current candy count after evolution and transfer (#4352)
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin5 authored and solderzzc committed Aug 20, 2016
1 parent 2afa041 commit a1c9419
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def _register_events(self):
)
self.event_manager.register_event(
'pokemon_evolved',
parameters=('pokemon', 'iv', 'cp', 'ncp', 'dps', 'xp')
parameters=('pokemon', 'iv', 'cp', 'xp')
)
self.event_manager.register_event('skip_evolve')
self.event_manager.register_event('threw_berry_failed', parameters=('status_code',))
Expand Down Expand Up @@ -435,7 +435,7 @@ def _register_events(self):
)
self.event_manager.register_event(
'pokemon_release',
parameters=('pokemon', 'iv', 'cp', 'ncp', 'dps')
parameters=('pokemon', 'iv', 'cp', 'candy')
)

# polyline walker
Expand Down
2 changes: 0 additions & 2 deletions pokemongo_bot/cell_workers/evolve_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ def _execute_pokemon_evolve(self, pokemon, cache):
'pokemon': pokemon.name,
'iv': pokemon.iv,
'cp': pokemon.cp,
'ncp': '?',
'dps': '?',
'xp': '?'
}
)
Expand Down
26 changes: 15 additions & 11 deletions pokemongo_bot/cell_workers/pokemon_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,18 +302,20 @@ def transfer_pokemon(self, pokemon):
if not response_dict:
return False

candy_awarded = response_dict.get("responses", {}).get("RELEASE_POKEMON", {}).get("candy_awarded", 0)
candy = inventory.candies().get(pokemon.pokemon_id)

if self.config_transfer and (not self.bot.config.test):
candy.add(candy_awarded)

self.emit_event("pokemon_release",
formatted="Exchanged {pokemon} [IV {iv}] [CP {cp}] [NCP {ncp}] [DPS {dps}]",
formatted="Exchanged {pokemon} [IV {iv}] [CP {cp}] [{candy} candies]",
data={"pokemon": pokemon.name,
"iv": pokemon.iv,
"cp": pokemon.cp,
"ncp": round(pokemon.ncp, 2),
"dps": round(pokemon.dps, 2)})
"candy": candy.quantity})

if self.config_transfer and (not self.bot.config.test):
candy = response_dict.get("responses", {}).get("RELEASE_POKEMON", {}).get("candy_awarded", 0)

inventory.candies().get(pokemon.pokemon_id).add(candy)
inventory.pokemons().remove(pokemon.unique_id)

with self.bot.database as db:
Expand Down Expand Up @@ -378,20 +380,22 @@ def evolve_pokemon(self, pokemon):
return False

xp = response_dict.get("responses", {}).get("EVOLVE_POKEMON", {}).get("experience_awarded", 0)
candy = response_dict.get("responses", {}).get("EVOLVE_POKEMON", {}).get("candy_awarded", 0)
candy_awarded = response_dict.get("responses", {}).get("EVOLVE_POKEMON", {}).get("candy_awarded", 0)
candy = inventory.candies().get(pokemon.pokemon_id)
evolution = response_dict.get("responses", {}).get("EVOLVE_POKEMON", {}).get("evolved_pokemon_data", {})

if self.config_evolve and (not self.bot.config.test):
candy.consume(pokemon.evolution_cost - candy_awarded)

self.emit_event("pokemon_evolved",
formatted="Evolved {pokemon} [IV {iv}] [CP {cp}] [NCP {ncp}] [DPS {dps}] [+{xp} xp]",
formatted="Evolved {pokemon} [IV {iv}] [CP {cp}] [{candy} candies] [+{xp} xp]",
data={"pokemon": pokemon.name,
"iv": pokemon.iv,
"cp": pokemon.cp,
"ncp": round(pokemon.ncp, 2),
"dps": round(pokemon.dps, 2),
"candy": candy.quantity,
"xp": xp})

if self.config_evolve and (not self.bot.config.test):
inventory.candies().get(pokemon.pokemon_id).consume(pokemon.evolution_cost - candy)
inventory.pokemons().remove(pokemon.unique_id)

new_pokemon = inventory.Pokemon(evolution)
Expand Down
7 changes: 3 additions & 4 deletions pokemongo_bot/cell_workers/transfer_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,12 @@ def release_pokemon(self, pokemon):
self.bot.metrics.released_pokemon()
self.emit_event(
'pokemon_release',
formatted='Exchanged {pokemon} [CP {cp}] [IV {iv}] for candy.',
formatted='Exchanged {pokemon} [IV {iv}] [CP {cp}] [{candy} candies]',
data={
'pokemon': pokemon.name,
'cp': pokemon.cp,
'iv': pokemon.iv,
'ncp': pokemon.cp_percent,
'dps': pokemon.moveset.dps
'cp': pokemon.cp,
'candy': candy.quantity
}
)
with self.bot.database as conn:
Expand Down

0 comments on commit a1c9419

Please sign in to comment.