-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fixed seperate transfer bug in worker #1286
Merged
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b4a619d
Merge remote-tracking branch 'refs/remotes/origin/dev' into transfer-…
fredrik-hellmangroup 2dfe6f2
seperate worker for transfering pokemons to professor
fredrik-hellmangroup 3b3dcd4
Fixed bug where config parameters wasnt checked
fredrik-hellmangroup 08b7a97
Initial_transfer renamed to release_pokemons
fredrik-hellmangroup 7ad1c2d
added back exception which was missing
fredrik-hellmangroup 69ee170
Default conf value and fixed typo
fredrik-hellmangroup d2f5a00
Capital leter
fredrik-hellmangroup e5b0984
missed to rename on some places
fredrik-hellmangroup 54a9a0b
Merge remote-tracking branch 'refs/remotes/origin/dev' into transfer-…
fredrik-hellmangroup bc6dca5
Log format update
fredrik-hellmangroup 8da686a
moved runtime error to evolved_capture statement
fredrik-hellmangroup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,15 @@ | |
from pokemongo_bot.human_behaviour import sleep | ||
from pokemongo_bot import logger | ||
|
||
class InitialTransferWorker(object): | ||
class PokemonTransferWorker(object): | ||
def __init__(self, bot): | ||
self.config = bot.config | ||
self.pokemon_list = bot.pokemon_list | ||
self.api = bot.api | ||
self.metrics = bot.metrics | ||
|
||
def work(self): | ||
if not self.config.initial_transfer: | ||
if not self.config.release_pokemons: | ||
return | ||
|
||
pokemon_groups = self._initial_transfer_get_groups() | ||
|
@@ -29,14 +30,9 @@ def work(self): | |
pokemon_data = pokemon_groups[id][pokemon_cp] | ||
pokemon_potential = self.get_pokemon_potential(pokemon_data) | ||
if self.should_release_pokemon(pokemon_name, pokemon_cp, pokemon_potential): | ||
message = 'Exchanging {} [CP {}] [Potential {}]'.format( | ||
pokemon_name, | ||
pokemon_cp, | ||
pokemon_potential | ||
) | ||
logger.log(message, 'red') | ||
self.api.release_pokemon( | ||
pokemon_id=pokemon_data['id']) | ||
logger.log('Exchanging {} [CP {}] [Potential {}] for candy!'.format( | ||
pokemon_name, pokemon_cp, pokemon_potential)) | ||
self.api.release_pokemon(pokemon_id=pokemon_data['id']) | ||
response_dict = self.api.call() | ||
sleep(2) | ||
|
||
|
@@ -75,7 +71,7 @@ def get_pokemon_potential(self, pokemon_data): | |
for individual_stat in iv_stats: | ||
try: | ||
total_iv += pokemon_data[individual_stat] | ||
except Exception: | ||
except: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @surfaace just one last detail to be good to go for me: put back There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good spot |
||
continue | ||
return round((total_iv / 45.0), 2) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's because I don't have a lot of state on this, but why are we raising a runtime error? Shouldn't the bot just "return" in this case?
I don't think workers should cause the bot to exit