MCPcopy Create free account
hub / github.com/runhey/OnmyojiAutoScript / run_utilize

Method run_utilize

tasks/KekkaiUtilize/script_task.py:340–438  ·  view source on GitHub ↗

执行寄养 :param shikigami_class: :param friend: :param rule: :return:

(self, friend: SelectFriendList = SelectFriendList.SAME_SERVER,
                    shikigami_class: ShikigamiClass = ShikigamiClass.N,
                    shikigami_order: int = 7)

Source from the content-addressed store, hash-verified

338 return result
339
340 def run_utilize(self, friend: SelectFriendList = SelectFriendList.SAME_SERVER,
341 shikigami_class: ShikigamiClass = ShikigamiClass.N,
342 shikigami_order: int = 7):
343 """
344 执行寄养
345 :param shikigami_class:
346 :param friend:
347 :param rule:
348 :return:
349 """
350 def _current_select_best(last_best: CardClass or None) -> CardClass | None:
351 """
352 当前选中的最好的卡,(会自动和记录的最好的比较)
353 包括点击这种卡
354 :return: 返回当前选中的最好的卡, 如果什么的都没有,返回None
355 """
356 self.screenshot()
357 target = self.order_targets.find_anyone(self.device.image)
358 if target is None:
359 logger.info('No target card found')
360 return None
361 card_class = target_to_card_class(target)
362 logger.info('Current find best card: %s', target)
363 # 如果当前的卡比记录的最好的卡还要好,那么就更新最好的卡
364 if last_best is not None:
365 last_index = self.order_cards.index(last_best)
366 current_index = self.order_cards.index(card_class)
367 if current_index > last_index:
368 # 不比上一张卡好就退出不执行操作
369 logger.info('Current card is not better than last best card')
370 return last_best
371 logger.info('Current select card: %s', card_class)
372
373 self.appear_then_click(target, interval=0.3)
374 # 验证这张卡 的等级是否一致
375 # while 1:
376 # self.screenshot()
377 return card_class
378
379 logger.hr('Start utilize')
380 self.switch_friend_list(friend)
381 card_best = None
382 swipe_count = 0
383 while 1:
384 self.screenshot()
385 current_card = _current_select_best(card_best)
386
387 if current_card is None:
388 break
389 else:
390 card_best = current_card
391
392 # 超过十次就退出
393 if swipe_count > 10:
394 logger.warning('Swipe count is more than 10')
395 break
396
397 # 一直向下滑动

Callers 1

runMethod · 0.95

Calls 8

switch_friend_listMethod · 0.95
sleepMethod · 0.80
appearMethod · 0.80
appear_then_clickMethod · 0.80
set_shikigamiMethod · 0.80
screenshotMethod · 0.45
swipeMethod · 0.45

Tested by

no test coverage detected