2023-10-02 18:25:22 +00:00
|
|
|
from module.base.utils import color_similar, get_color
|
2023-11-02 10:56:20 +00:00
|
|
|
from module.logger import logger
|
2023-06-16 19:15:26 +00:00
|
|
|
from tasks.base.ui import UI
|
2023-10-02 18:25:22 +00:00
|
|
|
from tasks.combat.assets.assets_combat_interact import DUNGEON_COMBAT_INTERACT, MAP_LOADING
|
2023-11-02 10:56:20 +00:00
|
|
|
from tasks.combat.assets.assets_combat_prepare import COMBAT_PREPARE
|
2023-10-02 18:25:22 +00:00
|
|
|
from tasks.map.assets.assets_map_control import A_BUTTON
|
2023-11-02 17:55:28 +00:00
|
|
|
from tasks.rogue.assets.assets_rogue_weekly import REWARD_ENTER
|
2023-06-16 19:15:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
class CombatInteract(UI):
|
2023-10-07 04:35:02 +00:00
|
|
|
def handle_combat_interact(self, interval=2):
|
2023-06-16 19:15:26 +00:00
|
|
|
"""
|
|
|
|
Returns:
|
|
|
|
bool: If clicked.
|
|
|
|
"""
|
2023-10-07 04:35:02 +00:00
|
|
|
if self.appear_then_click(DUNGEON_COMBAT_INTERACT, interval=interval):
|
2023-06-16 19:15:26 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
2023-10-02 18:25:22 +00:00
|
|
|
|
2023-11-02 10:56:20 +00:00
|
|
|
def combat_enter_from_map(self, skip_first_screenshot=True):
|
|
|
|
"""
|
|
|
|
Pages:
|
|
|
|
in: page_main, DUNGEON_COMBAT_INTERACT
|
|
|
|
out: COMBAT_PREPARE
|
2023-11-02 17:55:28 +00:00
|
|
|
or REWARD_ENTER
|
2023-11-02 10:56:20 +00:00
|
|
|
"""
|
|
|
|
logger.info('Combat enter from map')
|
|
|
|
while 1:
|
|
|
|
if skip_first_screenshot:
|
|
|
|
skip_first_screenshot = False
|
|
|
|
else:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
|
|
|
if self.appear(COMBAT_PREPARE):
|
|
|
|
# Confirm page loaded
|
|
|
|
if self.image_color_count(COMBAT_PREPARE.button, color=(230, 230, 230), threshold=240, count=400):
|
|
|
|
logger.info(f'At {COMBAT_PREPARE}')
|
|
|
|
break
|
2023-11-02 17:55:28 +00:00
|
|
|
# is_page_rogue_main()
|
|
|
|
if self.match_template_color(REWARD_ENTER):
|
|
|
|
logger.info(f'At rogue {REWARD_ENTER}')
|
|
|
|
break
|
2023-11-02 10:56:20 +00:00
|
|
|
if self.handle_combat_interact():
|
|
|
|
continue
|
|
|
|
|
2023-10-02 18:25:22 +00:00
|
|
|
def is_map_loading(self):
|
|
|
|
if self.appear(MAP_LOADING, similarity=0.75):
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
def is_map_loading_black(self):
|
|
|
|
color = get_color(self.device.image, A_BUTTON.area)
|
|
|
|
if color_similar(color, (0, 0, 0)):
|
|
|
|
return True
|
|
|
|
return False
|