Skip to content

Commit b4e7cf8

Browse files
committed
add func ensure_main
1 parent 8b1f622 commit b4e7cf8

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/tasks/BaseDNATask.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,30 @@ def __init__(self, *args, **kwargs):
1818
self.afk_config = self.get_global_config('挂机设置')
1919
self.old_mouse_pos = None
2020
self.next_monthly_card_start = 0
21+
self._logged_in = False
2122

2223
def in_team(self) -> bool:
2324
if self.find_one('lv_text', threshold=0.8):
2425
return True
2526
return False
2627

28+
def ensure_main(self, esc=True, time_out=30):
29+
self.info_set('current task', 'wait main')
30+
if not self.wait_until(lambda: self.is_main(esc=esc), time_out=time_out, raise_if_not_found=False):
31+
raise Exception('Please start in game world and in team!')
32+
self.info_set('current task', 'in main')
33+
34+
def is_main(self, esc=True):
35+
if self.in_team():
36+
self._logged_in = True
37+
return True
38+
if self.handle_monthly_card():
39+
return True
40+
# if self.wait_login():
41+
# return True
42+
if esc:
43+
self.back(after_sleep=1.5)
44+
2745
def find_start_btn(self, threshold: float = 0, box: Box | None = None, template = None) -> Box | None:
2846
if isinstance(box, Box):
2947
self.draw_boxes(box.name, box, "blue")

0 commit comments

Comments
 (0)