Skip to content

Commit

Permalink
fix to pause kirafan-bot on battle state
Browse files Browse the repository at this point in the history
  • Loading branch information
smallbomb committed Sep 10, 2021
1 parent 5cf0e80 commit 24e38a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/bot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from typeguard import typechecked
from defined import Optional, Tuple, Dict
from defined import Tuple, Dict
from data import uData
from wave import Wave, gen_circle_list
from icon import Icon
Expand Down Expand Up @@ -103,7 +103,7 @@ def update_waveID(self) -> bool:
return True
return False

def get_current_wave(self) -> Optional[Wave]:
def get_current_wave(self) -> Wave:
return self.waves[str(self.wave_id)]

def use_stamina(self) -> bool:
Expand Down Expand Up @@ -165,8 +165,10 @@ def time_in_range(start: datetime, end: datetime, now: datetime) -> bool:
end_time = datetime.strptime(str(datetime.now().date()) + "T" + end_clock, "%Y-%m-%dT%H:%M:%S")
now_time = datetime.now()
if time_in_range(start_time, end_time, datetime.now()):
self.objects['center'].click(3) # advoid auto mode
wait_until(end_time if end_time >= now_time else end_time + timedelta(days=1))
if self.get_current_wave().is_myTurn():
wait_until(end_time if end_time >= now_time else end_time + timedelta(days=1))
else:
self.objects['center'].click(3) # advoid auto mode
return True
return False

Expand Down
4 changes: 2 additions & 2 deletions src/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ def run():
logging.info(f'loop_count = {kirafan.loop_count} now')
while bot.is_running():
if _is_battle_now():
if kirafan.ck_timer_pause():
continue
if kirafan.wave_change_flag:
logging.info(f'wave({kirafan.wave_id}/{kirafan.wave_total}) now...')
if kirafan.ck_timer_pause():
continue
_handle_battle_flows()
else:
# is not battle (maybe transitions, loading, sp animation, crash ... etc)
Expand Down

0 comments on commit 24e38a2

Please sign in to comment.