Skip to content

Commit 60e3034

Browse files
committed
測試月卡功能代碼
1 parent 6d24c72 commit 60e3034

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/tasks/BaseDNATask.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def check_for_monthly_card(self):
151151
start = time.time()
152152
ret = self.handle_monthly_card()
153153
cost = time.time() - start
154+
logger.info(f'check_for_monthly_card: ret {ret} cost {cost}')
154155
return ret, cost
155156
# start = time.time()
156157
# logger.info(f'check_for_monthly_card start check')
@@ -166,6 +167,7 @@ def check_for_monthly_card(self):
166167
return False, 0
167168

168169
def should_check_monthly_card(self):
170+
logger.info(f'next_monthly_card_start: {self.next_monthly_card_start} time left: {time.time() - self.next_monthly_card_start}')
169171
if self.next_monthly_card_start > 0:
170172
if 0 < time.time() - self.next_monthly_card_start < 120:
171173
return True
@@ -185,16 +187,22 @@ def set_check_monthly_card(self, next_day=False):
185187
logger.info('set next monthly card start time to {}'.format(next_monthly_card_start_date_time))
186188
else:
187189
self.next_monthly_card_start = 0
190+
logger.info('set next monthly card start to {}'.format(self.next_monthly_card_start))
188191

189192
def handle_monthly_card(self):
190193
monthly_card = self.find_one('monthly_card', threshold=0.8)
191-
# self.screenshot('monthly_card1')
194+
if not hasattr(self, '_last_monthly_card_check_time'):
195+
self._last_monthly_card_check_time = 0
196+
now = time.time()
197+
if now - self._last_monthly_card_check_time >= 10:
198+
self._last_monthly_card_check_time = now
199+
self.screenshot('monthly_card1')
192200
ret = monthly_card is not None
193201
if ret:
194202
self.wait_until(self.in_team, time_out=10,
195203
post_action=lambda: self.click_relative(0.50, 0.89, after_sleep=1))
196204
self.set_check_monthly_card(next_day=True)
197-
logger.debug(f'check_monthly_card {monthly_card}')
205+
logger.info(f'check_monthly_card {monthly_card}')
198206
return ret
199207

200208
def find_track_point(self, threshold: float = 0, box: Box | None = None, template=None, frame_processor=None,

0 commit comments

Comments
 (0)