Skip to content

Commit

Permalink
Merge pull request #5564 from Anakin5/po
Browse files Browse the repository at this point in the history
Fix crash with upgrade pokemon
  • Loading branch information
Yves Henri authored Sep 20, 2016
2 parents 1d67155 + 53748f6 commit 8f82b36
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion configs/config.json.optimizer.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"mode": "overall",
"top": 1,
"sort": ["max_cp", "cp"],
"evolve": false,
"buddy": {"candy": -124}
},
{
Expand All @@ -50,7 +51,8 @@
{
"mode": "by_family",
"top": 1,
"sort": ["cp"]
"sort": ["cp"],
"evolve": false
}
]
}
Expand Down
6 changes: 4 additions & 2 deletions docs/pokemon_optimizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ It will also collect the candies from your Buddy and select the next buddy.
"mode": "overall",
"top": 1,
"sort": ["max_cp", "cp"],
"evolve": false,
"buddy": {"candy": -124}
},
{
Expand All @@ -97,7 +98,8 @@ It will also collect the candies from your Buddy and select the next buddy.
{
"mode": "by_family",
"top": 1,
"sort": ["cp"]
"sort": ["cp"],
"evolve": false
}
]
}
Expand Down Expand Up @@ -167,7 +169,7 @@ It can help you rectify your configuration or guide you during manual transfer.
### evolve
| Parameter | Possible values | Default |
|-----------|-----------------|---------|
| `evolve` | `true`, `false` | `false` |
| `evolve` | `true`, `false` | `true` |

The `evolve` parameter activate or deactivate the evolution of Pokemon.

Expand Down
10 changes: 5 additions & 5 deletions pokemongo_bot/cell_workers/pokemon_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def initialize(self):
self.config_upgrade = self.config.get("upgrade", False)
self.config_upgrade_level = self.config.get("upgrade_level", 30)
self.config_groups = self.config.get("groups", {"gym": ["Dragonite", "Snorlax", "Lapras", "Arcanine"]})
self.config_rules = self.config.get("rules", [{"mode": "overall", "top": 1, "sort": ["max_cp", "cp"], "buddy": {"candy": -124}},
self.config_rules = self.config.get("rules", [{"mode": "overall", "top": 1, "sort": ["max_cp", "cp"], "evolve": False, "buddy": {"candy": -124}},
{"mode": "by_family", "top": 3, "names": ["gym"], "sort": ["iv", "ncp"], "evolve": {"iv": 0.9, "ncp": 0.9}, "upgrade": {"iv": 0.9, "ncp": 0.9}},
{"mode": "by_family", "top": 1, "sort": ["iv"], "evolve": {"iv": 0.9}},
{"mode": "by_family", "top": 1, "sort": ["ncp"], "evolve": {"ncp": 0.9}},
{"mode": "by_family", "top": 1, "sort": ["cp"]}])
{"mode": "by_family", "top": 1, "sort": ["cp"], "evolve": False}])

if (not self.config_may_use_lucky_egg) and self.config_evolve_only_with_lucky_egg:
self.config_evolve = False
Expand Down Expand Up @@ -167,7 +167,7 @@ def work(self):
if (not self.lock_buddy) and (len(buddy_all) > 0):
new_buddy = buddy_all[0]

if self.buddy["id"] != new_buddy.unique_id:
if (not self.buddy) or (self.buddy["id"] != new_buddy.unique_id):
self.set_buddy_pokemon(new_buddy)

if self.get_pokemon_slot_left() > self.config_min_slots_left:
Expand Down Expand Up @@ -508,8 +508,8 @@ def get_evolution_plan(self, family_id, family_list, keep, try_evolve, try_upgra
full_upgrade_candy_cost = 0
full_upgrade_stardust_cost = 0

for i in range(pokemon.level, upgrade_level, 0.5):
upgrade_cost = self.pokemon_upgrade_cost[2 * (i - 1)]
for i in range(int(pokemon.level * 2), int(upgrade_level * 2)):
upgrade_cost = self.pokemon_upgrade_cost[i - 2]
full_upgrade_candy_cost += upgrade_cost[0]
full_upgrade_stardust_cost += upgrade_cost[1]

Expand Down

0 comments on commit 8f82b36

Please sign in to comment.