|
@@ -7,6 +7,7 @@ import time
|
|
|
import random
|
|
import random
|
|
|
import numpy as np
|
|
import numpy as np
|
|
|
from enum import Enum
|
|
from enum import Enum
|
|
|
|
|
+from cached_property import cached_property
|
|
|
|
|
|
|
|
from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
|
|
from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
|
|
|
from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
|
|
from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
|
|
@@ -69,6 +70,14 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, DokanAssets):
|
|
|
team_switched: bool = False
|
|
team_switched: bool = False
|
|
|
green_mark_done: bool = False
|
|
green_mark_done: bool = False
|
|
|
|
|
|
|
|
|
|
+ @cached_property
|
|
|
|
|
+ def _attack_priorities(self) -> list:
|
|
|
|
|
+ return [self.I_RYOU_DOKAN_PRIORITY_0,
|
|
|
|
|
+ self.I_RYOU_DOKAN_PRIORITY_1,
|
|
|
|
|
+ self.I_RYOU_DOKAN_PRIORITY_2,
|
|
|
|
|
+ self.I_RYOU_DOKAN_PRIORITY_3,
|
|
|
|
|
+ self.I_RYOU_DOKAN_PRIORITY_4]
|
|
|
|
|
+
|
|
|
def run(self):
|
|
def run(self):
|
|
|
""" 道馆主函数
|
|
""" 道馆主函数
|
|
|
|
|
|
|
@@ -281,61 +290,36 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, DokanAssets):
|
|
|
else:
|
|
else:
|
|
|
return False
|
|
return False
|
|
|
|
|
|
|
|
- def dokan_choose_attack_priority(self, attack_priority: int):
|
|
|
|
|
|
|
+ def dokan_choose_attack_priority(self, attack_priority: int) -> bool:
|
|
|
''' 选择优先攻击
|
|
''' 选择优先攻击
|
|
|
: return
|
|
: return
|
|
|
'''
|
|
'''
|
|
|
- logger.info("选择优先攻击")
|
|
|
|
|
- ret = False
|
|
|
|
|
|
|
+ logger.hr('Try to choose attack priority')
|
|
|
max_try = 5
|
|
max_try = 5
|
|
|
|
|
|
|
|
if not self.appear_then_click(self.I_RYOU_DOKAN_PRIORITY, interval=2):
|
|
if not self.appear_then_click(self.I_RYOU_DOKAN_PRIORITY, interval=2):
|
|
|
logger.error(f"can not find dokan priority option button, choose attack priority process skipped")
|
|
logger.error(f"can not find dokan priority option button, choose attack priority process skipped")
|
|
|
- return ret
|
|
|
|
|
|
|
+ return False
|
|
|
|
|
|
|
|
logger.info(f"start select attack priority: {attack_priority}, remain try: {max_try}")
|
|
logger.info(f"start select attack priority: {attack_priority}, remain try: {max_try}")
|
|
|
|
|
+ try:
|
|
|
|
|
+ target_attack = self._attack_priorities[attack_priority]
|
|
|
|
|
+ except:
|
|
|
|
|
+ target_attack = self._attack_priorities[0]
|
|
|
|
|
|
|
|
while 1:
|
|
while 1:
|
|
|
- time.sleep(2)
|
|
|
|
|
self.screenshot()
|
|
self.screenshot()
|
|
|
if max_try <= 0:
|
|
if max_try <= 0:
|
|
|
logger.warn("give up priority selection!")
|
|
logger.warn("give up priority selection!")
|
|
|
break
|
|
break
|
|
|
|
|
|
|
|
- if attack_priority == 0:
|
|
|
|
|
- if self.appear_then_click(self.I_RYOU_DOKAN_PRIORITY_0, interval=1.8):
|
|
|
|
|
- logger.info(f"selected attack priority: {attack_priority}")
|
|
|
|
|
- else:
|
|
|
|
|
- continue
|
|
|
|
|
- elif attack_priority == 1:
|
|
|
|
|
- if self.appear_then_click(self.I_RYOU_DOKAN_PRIORITY_1, interval=1.8):
|
|
|
|
|
- logger.info(f"selected attack priority: {attack_priority}")
|
|
|
|
|
- else:
|
|
|
|
|
- continue
|
|
|
|
|
- elif attack_priority == 2:
|
|
|
|
|
- if self.appear_then_click(self.I_RYOU_DOKAN_PRIORITY_2, interval=1.8):
|
|
|
|
|
- logger.info(f"selected attack priority: {attack_priority}")
|
|
|
|
|
- else:
|
|
|
|
|
- continue
|
|
|
|
|
- elif attack_priority == 3:
|
|
|
|
|
- if self.appear_then_click(self.I_RYOU_DOKAN_PRIORITY_3, interval=1.8):
|
|
|
|
|
- logger.info(f"selected attack priority: {attack_priority}")
|
|
|
|
|
- else:
|
|
|
|
|
- continue
|
|
|
|
|
- elif attack_priority == 4:
|
|
|
|
|
- if self.appear_then_click(self.I_RYOU_DOKAN_PRIORITY_4, interval=1.8):
|
|
|
|
|
- logger.info(f"selected attack priority: {attack_priority}")
|
|
|
|
|
- else:
|
|
|
|
|
- continue
|
|
|
|
|
- else:
|
|
|
|
|
- self.appear_then_click(self.I_RYOU_DOKAN_PRIORITY_0, interval=1.8)
|
|
|
|
|
- logger.error(f"invalid attack priority setting: {attack_priority}")
|
|
|
|
|
|
|
+ if self.appear_then_click(target_attack, interval=1.8):
|
|
|
|
|
+ logger.info(f"selected attack priority: {attack_priority}")
|
|
|
|
|
+ max_try -= 1
|
|
|
|
|
|
|
|
self.attack_priority_selected = True
|
|
self.attack_priority_selected = True
|
|
|
- ret = True
|
|
|
|
|
- break
|
|
|
|
|
|
|
|
|
|
- return ret
|
|
|
|
|
|
|
+ return True
|
|
|
|
|
|
|
|
def anti_detect(self, random_move: bool = True, random_click: bool = True, random_delay: bool = True):
|
|
def anti_detect(self, random_move: bool = True, random_click: bool = True, random_delay: bool = True):
|
|
|
'''额外的防封测试
|
|
'''额外的防封测试
|
|
@@ -514,9 +498,6 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, DokanAssets):
|
|
|
return False, DokanScene.RYOU_DOKAN_SCENE_UNKNOWN
|
|
return False, DokanScene.RYOU_DOKAN_SCENE_UNKNOWN
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
def test_goto_main():
|
|
def test_goto_main():
|
|
|
from module.config.config import Config
|
|
from module.config.config import Config
|
|
|
from module.device.device import Device
|
|
from module.device.device import Device
|