|
|
@@ -10,17 +10,15 @@ from tasks.Component.GeneralBattle.assets import GeneralBattleAssets
|
|
|
from tasks.Component.GeneralBuff.config_buff import BuffClass
|
|
|
from tasks.Component.GeneralBuff.general_buff import GeneralBuff
|
|
|
|
|
|
-
|
|
|
from module.logger import logger
|
|
|
|
|
|
|
|
|
-
|
|
|
class GeneralBattle(GeneralBuff, GeneralBattleAssets):
|
|
|
"""
|
|
|
使用这个通用的战斗必须要求这个任务的config有config_general_battle
|
|
|
"""
|
|
|
|
|
|
- def run_general_battle(self, config: GeneralBattleConfig=None, buff: BuffClass or list[BuffClass]=None) -> bool:
|
|
|
+ def run_general_battle(self, config: GeneralBattleConfig = None, buff: BuffClass or list[BuffClass] = None) -> bool:
|
|
|
"""
|
|
|
运行脚本
|
|
|
:return:
|
|
|
@@ -32,7 +30,6 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
|
|
|
if config is None:
|
|
|
config = GeneralBattleConfig()
|
|
|
|
|
|
-
|
|
|
# 如果没有锁定队伍。那么可以根据配置设定队伍
|
|
|
if not config.lock_team_enable:
|
|
|
logger.info("Lock team is not enable")
|
|
|
@@ -46,11 +43,15 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
|
|
|
# 点击准备按钮
|
|
|
self.wait_until_appear(self.I_PREPARE_HIGHLIGHT)
|
|
|
self.wait_until_appear(self.I_BUFF)
|
|
|
+ occur_prepare_button = False
|
|
|
while 1:
|
|
|
self.screenshot()
|
|
|
if not self.appear(self.I_BUFF):
|
|
|
break
|
|
|
if self.appear_then_click(self.I_PREPARE_HIGHLIGHT, interval=1.5):
|
|
|
+ occur_prepare_button = True
|
|
|
+ continue
|
|
|
+ if occur_prepare_button and self.ocr_appear_click(self.O_BATTLE_PREPARE, interval=2):
|
|
|
continue
|
|
|
logger.info("Click prepare ensure button")
|
|
|
|
|
|
@@ -68,8 +69,7 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
|
|
|
else:
|
|
|
return False
|
|
|
|
|
|
-
|
|
|
- def run_general_battle_back(self, config: GeneralBattleConfig=None) -> bool:
|
|
|
+ def run_general_battle_back(self, config: GeneralBattleConfig = None) -> bool:
|
|
|
"""
|
|
|
进入挑战然后直接返回
|
|
|
:param config:
|
|
|
@@ -117,8 +117,7 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
|
|
|
|
|
|
return True
|
|
|
|
|
|
-
|
|
|
- def exit_battle(self, skip_first: bool=False) -> bool:
|
|
|
+ def exit_battle(self, skip_first: bool = False) -> bool:
|
|
|
"""
|
|
|
在战斗的时候强制退出战斗
|
|
|
:return:
|
|
|
@@ -150,7 +149,6 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
|
|
|
|
|
|
return True
|
|
|
|
|
|
-
|
|
|
def battle_wait(self, random_click_swipt_enable: bool) -> bool:
|
|
|
"""
|
|
|
等待战斗结束 !!!
|
|
|
@@ -221,15 +219,15 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
|
|
|
self.screenshot()
|
|
|
# 如果出现领奖励
|
|
|
action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
|
|
|
- if self.appear_then_click(self.I_REWARD, action=action_click ,interval=1.5) or \
|
|
|
- self.appear_then_click(self.I_REWARD_GOLD, action=action_click ,interval=1.5):
|
|
|
+ if self.appear_then_click(self.I_REWARD, action=action_click, interval=1.5) or \
|
|
|
+ self.appear_then_click(self.I_REWARD_GOLD, action=action_click, interval=1.5):
|
|
|
continue
|
|
|
if not self.appear(self.I_REWARD) and not self.appear(self.I_REWARD_GOLD):
|
|
|
break
|
|
|
|
|
|
return win
|
|
|
|
|
|
- def green_mark(self, enable: bool=False, mark_mode: GreenMarkType=GreenMarkType.GREEN_MAIN):
|
|
|
+ def green_mark(self, enable: bool = False, mark_mode: GreenMarkType = GreenMarkType.GREEN_MAIN):
|
|
|
"""
|
|
|
绿标, 如果不使能就直接返回
|
|
|
:param enable:
|
|
|
@@ -271,7 +269,7 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
|
|
|
# 点击绿标
|
|
|
self.device.click(x, y)
|
|
|
|
|
|
- def switch_preset_team(self, enable: bool=False, preset_group: int=1, preset_team: int=1):
|
|
|
+ def switch_preset_team(self, enable: bool = False, preset_group: int = 1, preset_team: int = 1):
|
|
|
"""
|
|
|
切换预设的队伍, 要求是在不锁定队伍时的情况下
|
|
|
:param enable:
|
|
|
@@ -368,9 +366,9 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
|
|
|
if is_screenshot:
|
|
|
self.screenshot()
|
|
|
if self.appear(self.I_FRIENDS) or \
|
|
|
- self.appear(self.I_WIN) or \
|
|
|
- self.appear(self.I_FALSE) or \
|
|
|
- self.appear(self.I_REWARD):
|
|
|
+ self.appear(self.I_WIN) or \
|
|
|
+ self.appear(self.I_FALSE) or \
|
|
|
+ self.appear(self.I_REWARD):
|
|
|
return True
|
|
|
else:
|
|
|
return False
|
|
|
@@ -443,7 +441,7 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
|
|
|
if self.appear_then_click(lock_image, interval=1):
|
|
|
continue
|
|
|
|
|
|
- def check_buff(self, buff: BuffClass or list[BuffClass]=None):
|
|
|
+ def check_buff(self, buff: BuffClass or list[BuffClass] = None):
|
|
|
"""
|
|
|
检测是否开启buff
|
|
|
:param buff:
|
|
|
@@ -485,11 +483,9 @@ class GeneralBattle(GeneralBuff, GeneralBattleAssets):
|
|
|
if __name__ == '__main__':
|
|
|
from module.config.config import Config
|
|
|
from module.device.device import Device
|
|
|
+
|
|
|
c = Config('oas1')
|
|
|
d = Device(c)
|
|
|
t = GeneralBattle(c, d)
|
|
|
|
|
|
t.check_buff([BuffClass.EXP_50, BuffClass.GOLD_50])
|
|
|
-
|
|
|
-
|
|
|
-
|