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

pokemon optimizer stardust count fix #5230

Merged
merged 1 commit into from
Sep 6, 2016
Merged
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
14 changes: 4 additions & 10 deletions pokemongo_bot/cell_workers/pokemon_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def initialize(self):
self.max_pokemon_storage = inventory.get_pokemon_inventory_size()
self.last_pokemon_count = 0
self.pokemon_names = [p.name for p in inventory.pokemons().STATIC_DATA]
self.stardust_count = 0
self.ongoing_stardust_count = 0

pokemon_upgrade_cost_file = os.path.join(_base_dir, "data", "pokemon_upgrade_cost.json")
Expand Down Expand Up @@ -167,8 +166,7 @@ def open_inventory(self):
setattr(pokemon, "dps_attack", pokemon.moveset.dps_attack)
setattr(pokemon, "dps_defense", pokemon.moveset.dps_defense)

self.stardust_count = self.get_stardust_count()
self.ongoing_stardust_count = self.stardust_count
self.ongoing_stardust_count = self.bot.stardust

def get_colorlist_names(self, names):
whitelist_names = []
Expand Down Expand Up @@ -456,7 +454,7 @@ def apply_optimization(self, transfer, evolve, upgrade, xp):
for pokemon in xp:
self.evolve_pokemon(pokemon)

self.logger.info("Upgrading %s Pokemon [%s stardust]", len(upgrade), self.stardust_count)
self.logger.info("Upgrading %s Pokemon [%s stardust]", len(upgrade), self.bot.stardust)

for pokemon in upgrade:
self.upgrade_pokemon(pokemon)
Expand Down Expand Up @@ -610,15 +608,15 @@ def upgrade_pokemon(self, pokemon):

if self.config_upgrade and (not self.bot.config.test):
candy.consume(upgrade_candy_cost)
self.stardust_count -= upgrade_stardust_cost
self.bot.stardust -= upgrade_stardust_cost

self.emit_event("pokemon_upgraded",
formatted="Upgraded {pokemon} [IV {iv}] [CP {cp}] [{candy} candies] [{stardust} stardust]",
data={"pokemon": pokemon.name,
"iv": pokemon.iv,
"cp": pokemon.cp,
"candy": candy.quantity,
"stardust": self.stardust_count})
"stardust": self.bot.stardust})

if self.config_upgrade and (not self.bot.config.test):
inventory.pokemons().remove(pokemon.unique_id)
Expand All @@ -629,7 +627,3 @@ def upgrade_pokemon(self, pokemon):
action_delay(self.config_transfer_wait_min, self.config_transfer_wait_max)

return True

def get_stardust_count(self):
response_dict = self.bot.api.get_player()
return response_dict.get("responses", {}).get("GET_PLAYER", {}).get("player_data", {}).get("currencies", [{}, {}])[1].get("amount", 0)