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

Fix crash with upgrade pokemon #5564

Merged
merged 2 commits into from
Sep 20, 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
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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what kind of crash is it fixing? I don't see any difference between old and new code - it looks exactly the same (steps are twice as big, but "*2" is omitted when the couner variable is used, so...)

Can you show the logfile with the crash?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot create a range with a decimal step

full_upgrade_candy_cost += upgrade_cost[0]
full_upgrade_stardust_cost += upgrade_cost[1]

Expand Down