-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task EvolvePokemon should give us a status updates so we know it is w…
…orking (#5570) * Task EvolvePokemon should give us a status updates so we know it is working * Task EvolvePokemon should give us a status updates so we know it is working * Task EvolvePokemon should give us a status updates so we know it is working * Task EvolvePokemon should give us a status updates so we know it is working * Task EvolvePokemon should give us a status updates so we know it is working
- Loading branch information
1 parent
f9bd89d
commit c53a57e
Showing
5 changed files
with
32 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ def __init__(self, bot, config): | |
|
||
def initialize(self): | ||
self.start_time = 0 | ||
self.next_log_update = None | ||
self.log_interval = self.config.get('log_interval', 120) | ||
self.evolve_list = self.config.get('evolve_list', []) | ||
self.donot_evolve_list = self.config.get('donot_evolve_list', []) | ||
self.min_evolve_speed = self.config.get('min_evolve_speed', 25) | ||
|
@@ -41,7 +43,7 @@ def initialize(self): | |
def _validate_config(self): | ||
if isinstance(self.evolve_list, basestring): | ||
self.evolve_list = [str(pokemon_name).lower().strip() for pokemon_name in self.evolve_list.split(',')] | ||
|
||
if isinstance(self.donot_evolve_list, basestring): | ||
self.donot_evolve_list = [str(pokemon_name).lower().strip() for pokemon_name in self.donot_evolve_list.split(',')] | ||
|
||
|
@@ -65,19 +67,37 @@ def work(self): | |
candy = inventory.candies().get(pokemon.pokemon_id) | ||
pokemon_to_be_evolved = pokemon_to_be_evolved + min(candy.quantity / (pokemon.evolution_cost - 1), filtered_dict[pokemon.pokemon_id]) | ||
|
||
if pokemon_to_be_evolved >= self.min_pokemon_to_be_evolved: | ||
self._log_update_if_should(pokemon_to_be_evolved, self.min_pokemon_to_be_evolved) | ||
|
||
has_minimum_to_evolve = pokemon_to_be_evolved >= self.min_pokemon_to_be_evolved | ||
if has_minimum_to_evolve: | ||
if self.use_lucky_egg: | ||
self._use_lucky_egg() | ||
cache = {} | ||
for pokemon in filtered_list: | ||
if pokemon.can_evolve_now(): | ||
self._execute_pokemon_evolve(pokemon, cache) | ||
|
||
def _log_update_if_should(self, has, needs): | ||
self._compute_next_log_update() | ||
if self._should_log_update: | ||
This comment has been minimized.
Sorry, something went wrong. |
||
self.emit_event( | ||
'pokemon_evolve_check', | ||
formatted='Evolvable: {has}/{need}', | ||
This comment has been minimized.
Sorry, something went wrong.
alexyaoyang
Contributor
|
||
data={'has': has, 'needs': needs} | ||
) | ||
|
||
def _compute_next_log_update(self): | ||
self.next_log_update = datetime.now() + timedelta(seconds=self.log_interval) | ||
This comment has been minimized.
Sorry, something went wrong.
ukos-git
Contributor
|
||
|
||
def _should_log_update(self): | ||
return datetime.now() >= self.next_log_update | ||
|
||
def _should_run(self): | ||
if not self.evolve_list or self.evolve_list[0] == 'none': | ||
return False | ||
return True | ||
|
||
def _use_lucky_egg(self): | ||
using_lucky_egg = time.time() - self.start_time < 1800 | ||
if using_lucky_egg: | ||
|
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
@thejamespinto Needs brackets here too:
if self._should_log_update():