|
@@ -7,6 +7,7 @@
|
|
|
from datetime import datetime, timedelta
|
|
from datetime import datetime, timedelta
|
|
|
import random
|
|
import random
|
|
|
import numpy as np
|
|
import numpy as np
|
|
|
|
|
+import time
|
|
|
from enum import Enum
|
|
from enum import Enum
|
|
|
from cached_property import cached_property
|
|
from cached_property import cached_property
|
|
|
from time import sleep
|
|
from time import sleep
|
|
@@ -124,42 +125,82 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AbyssShadowsAssets):
|
|
|
self.wait_until_disappear(self.I_WAIT_TO_START)
|
|
self.wait_until_disappear(self.I_WAIT_TO_START)
|
|
|
self.device.stuck_record_clear()
|
|
self.device.stuck_record_clear()
|
|
|
|
|
|
|
|
- # 准备攻打精英、副将、首领
|
|
|
|
|
- while 1:
|
|
|
|
|
- # 点击战报按钮
|
|
|
|
|
- find_list = [EmemyType.BOSS, EmemyType.GENERAL, EmemyType.ELITE]
|
|
|
|
|
- for enemy_type in find_list:
|
|
|
|
|
- # 寻找敌人并开始战斗,
|
|
|
|
|
- if not self.find_enemy(enemy_type):
|
|
|
|
|
- logger.warning(f"Failed to find {enemy_type.name} enemy, exit")
|
|
|
|
|
|
|
+ # 未开启智能伤害准备攻打精英、副将、首领
|
|
|
|
|
+ if not cfg.abyss_shadows_combat_time.CombatTime_enable:
|
|
|
|
|
+ while 1:
|
|
|
|
|
+ # 点击战报按钮
|
|
|
|
|
+ find_list = [EmemyType.BOSS, EmemyType.GENERAL, EmemyType.ELITE]
|
|
|
|
|
+ for enemy_type in find_list:
|
|
|
|
|
+ # 寻找敌人并开始战斗,
|
|
|
|
|
+ if not self.find_enemy(enemy_type):
|
|
|
|
|
+ logger.warning(f"Failed to find {enemy_type.name} enemy, exit")
|
|
|
|
|
+ break
|
|
|
|
|
+ logger.info(f"Current fight times: boss {self.boss_fight_count} times, general {self.general_fight_count} times, elite {self.elite_fight_count} times")
|
|
|
|
|
+ # 正常应该打完一个区域了,检查攻打次数,如没打够则切换到下一个区域,默认神龙 -> 孔雀 -> 白藏主 -> 黑豹
|
|
|
|
|
+ if self.boss_fight_count >= 2 and self.general_fight_count >= 4 and self.elite_fight_count >= 6:
|
|
|
|
|
+ success = True
|
|
|
|
|
+ break
|
|
|
|
|
+ else:
|
|
|
|
|
+ #切换区域之前关闭战报
|
|
|
|
|
+ self.appear_then_click(self.I_ABYSS_MAP_EXIT, interval=1)
|
|
|
|
|
+ current_area = self.check_current_area()
|
|
|
|
|
+ logger.info(f"Current area is {current_area}, switch to next area")
|
|
|
|
|
+ if current_area == AreaType.DRAGON:
|
|
|
|
|
+ self.change_area(AreaType.PEACOCK)
|
|
|
|
|
+ continue
|
|
|
|
|
+ elif current_area == AreaType.PEACOCK:
|
|
|
|
|
+ self.change_area(AreaType.FOX)
|
|
|
|
|
+ continue
|
|
|
|
|
+ elif current_area == AreaType.FOX:
|
|
|
|
|
+ self.change_area(AreaType.LEOPARD)
|
|
|
|
|
+ continue
|
|
|
|
|
+ else:
|
|
|
|
|
+ logger.warning("All enemy types have been defeated, but not enough emeny to fight, exit")
|
|
|
|
|
+ break
|
|
|
|
|
+
|
|
|
|
|
+ # 开启智能伤害
|
|
|
|
|
+ if cfg.abyss_shadows_combat_time.CombatTime_enable:
|
|
|
|
|
+ while True:
|
|
|
|
|
+ # 1. 先攻打 1 个 BOSS
|
|
|
|
|
+ if self.boss_fight_count < 2:
|
|
|
|
|
+ self.boss_fight_count = self.fight_and_switch(EmemyType.BOSS, 2, self.boss_fight_count,
|
|
|
|
|
+ lambda: self.switch_area())
|
|
|
|
|
+
|
|
|
|
|
+ # 2. 攻打 2 个 GENERAL
|
|
|
|
|
+ if self.general_fight_count < 4:
|
|
|
|
|
+ self.general_fight_count = self.fight_and_switch(EmemyType.GENERAL, 4, self.general_fight_count,
|
|
|
|
|
+ lambda: self.switch_area())
|
|
|
|
|
+
|
|
|
|
|
+ # 3. 攻打 3 个 ELITE
|
|
|
|
|
+ if self.elite_fight_count < 6:
|
|
|
|
|
+ self.elite_fight_count = self.fight_and_switch(EmemyType.ELITE, 6, self.elite_fight_count,
|
|
|
|
|
+ lambda: self.switch_area())
|
|
|
|
|
+
|
|
|
|
|
+ # 检查是否已完成所有任务
|
|
|
|
|
+ print(f"Current fight times: boss {self.boss_fight_count} times, general {self.general_fight_count} times, elite {self.elite_fight_count} times")
|
|
|
|
|
+ if self.boss_fight_count >= 2 and self.general_fight_count >= 4 and self.elite_fight_count >= 6:
|
|
|
|
|
+ logger.info("All fights completed")
|
|
|
|
|
+ success = True
|
|
|
break
|
|
break
|
|
|
- logger.info(f"Current fight times: boss {self.boss_fight_count} times, general {self.general_fight_count} times, elite {self.elite_fight_count} times")
|
|
|
|
|
- # 正常应该打完一个区域了,检查攻打次数,如没打够则切换到下一个区域,默认神龙 -> 孔雀 -> 白藏主 -> 黑豹
|
|
|
|
|
- if self.boss_fight_count >= 2 and self.general_fight_count >= 4 and self.elite_fight_count >= 6:
|
|
|
|
|
- success = True
|
|
|
|
|
- break
|
|
|
|
|
- else:
|
|
|
|
|
- current_area = self.check_current_area()
|
|
|
|
|
- logger.info(f"Current area is {current_area}, switch to next area")
|
|
|
|
|
- if current_area == AreaType.DRAGON:
|
|
|
|
|
- self.change_area(AreaType.PEACOCK)
|
|
|
|
|
- continue
|
|
|
|
|
- elif current_area == AreaType.PEACOCK:
|
|
|
|
|
- self.change_area(AreaType.FOX)
|
|
|
|
|
- continue
|
|
|
|
|
- elif current_area == AreaType.FOX:
|
|
|
|
|
- self.change_area(AreaType.LEOPARD)
|
|
|
|
|
- continue
|
|
|
|
|
else:
|
|
else:
|
|
|
|
|
+ #没打满我也没办法就最后一张图,看看有没有剩余的吧没有也不想跑了
|
|
|
|
|
+ find_list = [EmemyType.BOSS, EmemyType.GENERAL, EmemyType.ELITE]
|
|
|
|
|
+ for enemy_type in find_list:
|
|
|
|
|
+ # 寻找敌人并开始战斗,
|
|
|
|
|
+ if not self.find_enemy(enemy_type):
|
|
|
|
|
+ logger.warning(f"Failed to find {enemy_type.name} enemy, exit")
|
|
|
|
|
+ break
|
|
|
|
|
+ logger.info(f"Current fight times: boss {self.boss_fight_count} times, general {self.general_fight_count} times, elite {self.elite_fight_count} times")
|
|
|
logger.warning("All enemy types have been defeated, but not enough emeny to fight, exit")
|
|
logger.warning("All enemy types have been defeated, but not enough emeny to fight, exit")
|
|
|
|
|
+ success = True
|
|
|
break
|
|
break
|
|
|
-
|
|
|
|
|
|
|
|
|
|
# 保持好习惯,一个任务结束了就返回到庭院,方便下一任务的开始
|
|
# 保持好习惯,一个任务结束了就返回到庭院,方便下一任务的开始
|
|
|
self.goto_main()
|
|
self.goto_main()
|
|
|
|
|
|
|
|
# 设置下次运行时间
|
|
# 设置下次运行时间
|
|
|
if success:
|
|
if success:
|
|
|
|
|
+ print("我要重新设置时间了")
|
|
|
if today == 4:
|
|
if today == 4:
|
|
|
# 周五推迟到周六
|
|
# 周五推迟到周六
|
|
|
logger.info(f"The next abyss shadows day is Saturday")
|
|
logger.info(f"The next abyss shadows day is Saturday")
|
|
@@ -176,6 +217,47 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AbyssShadowsAssets):
|
|
|
self.set_next_run(task='AbyssShadows', finish=True, server=True, success=False)
|
|
self.set_next_run(task='AbyssShadows', finish=True, server=True, success=False)
|
|
|
raise TaskEnd
|
|
raise TaskEnd
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ #攻击并进行区域切换
|
|
|
|
|
+ def fight_and_switch(self, enemy_type, required_count, fight_count, next_area_func):
|
|
|
|
|
+ while fight_count < required_count: # 0-2
|
|
|
|
|
+ if not self.find_enemy(enemy_type):
|
|
|
|
|
+ logger.warning(f"Failed to find {enemy_type.name} enemy, exit")
|
|
|
|
|
+ return fight_count
|
|
|
|
|
+ else:
|
|
|
|
|
+ if enemy_type == EmemyType.BOSS:
|
|
|
|
|
+ fight_count += 1
|
|
|
|
|
+ elif enemy_type == EmemyType.GENERAL:
|
|
|
|
|
+ fight_count += 2
|
|
|
|
|
+ elif enemy_type == EmemyType.ELITE:
|
|
|
|
|
+ fight_count += 3
|
|
|
|
|
+ logger.info(
|
|
|
|
|
+ f"Current fight times: boss {self.boss_fight_count} times, general {self.general_fight_count} times, elite {self.elite_fight_count} times")
|
|
|
|
|
+
|
|
|
|
|
+ # 完成攻打后切换区域
|
|
|
|
|
+ current_area = self.check_current_area()
|
|
|
|
|
+ if fight_count < required_count and current_area != AreaType.LEOPARD:
|
|
|
|
|
+ next_area_func()
|
|
|
|
|
+ return fight_count
|
|
|
|
|
+
|
|
|
|
|
+ def switch_area(self):
|
|
|
|
|
+ #确保没有战报页面
|
|
|
|
|
+ self.appear_then_click(self.I_ABYSS_MAP_EXIT, interval=1)
|
|
|
|
|
+ current_area = self.check_current_area()
|
|
|
|
|
+ logger.info(f"Current area is {current_area}, switch to next area")
|
|
|
|
|
+ if current_area == AreaType.DRAGON:
|
|
|
|
|
+ self.change_area(AreaType.PEACOCK)
|
|
|
|
|
+ elif current_area == AreaType.PEACOCK:
|
|
|
|
|
+ self.change_area(AreaType.FOX)
|
|
|
|
|
+ elif current_area == AreaType.FOX:
|
|
|
|
|
+ self.change_area(AreaType.LEOPARD)
|
|
|
|
|
+ else:
|
|
|
|
|
+ logger.warning("All areas have been completed, exit")
|
|
|
|
|
+ raise StopIteration # 退出循环
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
def check_current_area(self) -> AreaType:
|
|
def check_current_area(self) -> AreaType:
|
|
|
''' 获取当前区域
|
|
''' 获取当前区域
|
|
|
:return AreaType
|
|
:return AreaType
|
|
@@ -198,6 +280,9 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AbyssShadowsAssets):
|
|
|
:return
|
|
:return
|
|
|
'''
|
|
'''
|
|
|
while 1:
|
|
while 1:
|
|
|
|
|
+ # 确保切换区域前不在战报页面
|
|
|
|
|
+ if self.appear_then_click(self.I_ABYSS_MAP_EXIT, interval=1):
|
|
|
|
|
+ continue
|
|
|
self.screenshot()
|
|
self.screenshot()
|
|
|
# 判断当前区域是否正确
|
|
# 判断当前区域是否正确
|
|
|
current_area = self.check_current_area()
|
|
current_area = self.check_current_area()
|
|
@@ -208,7 +293,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AbyssShadowsAssets):
|
|
|
self.select_boss(area_name)
|
|
self.select_boss(area_name)
|
|
|
logger.info(f"Switch to {area_name.name}")
|
|
logger.info(f"Switch to {area_name.name}")
|
|
|
continue
|
|
continue
|
|
|
- # 点击战报按钮
|
|
|
|
|
|
|
+ # 点击更换领域按钮
|
|
|
if self.appear_then_click(self.I_CHANGE_AREA,interval=4):
|
|
if self.appear_then_click(self.I_CHANGE_AREA,interval=4):
|
|
|
logger.info(f"Click {self.I_CHANGE_AREA.name}")
|
|
logger.info(f"Click {self.I_CHANGE_AREA.name}")
|
|
|
continue
|
|
continue
|
|
@@ -222,8 +307,6 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AbyssShadowsAssets):
|
|
|
logger.info("Exiting abyss_shadows")
|
|
logger.info("Exiting abyss_shadows")
|
|
|
self.ui_goto(page_main)
|
|
self.ui_goto(page_main)
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
def goto_abyss_shadows(self) -> bool:
|
|
def goto_abyss_shadows(self) -> bool:
|
|
|
''' 进入狭间
|
|
''' 进入狭间
|
|
|
:return bool
|
|
:return bool
|
|
@@ -307,7 +390,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AbyssShadowsAssets):
|
|
|
logger.info(f"Run boss fight")
|
|
logger.info(f"Run boss fight")
|
|
|
if self.click_emeny_area(CilckArea.BOSS):
|
|
if self.click_emeny_area(CilckArea.BOSS):
|
|
|
logger.info(f"Click {CilckArea.BOSS.name}")
|
|
logger.info(f"Click {CilckArea.BOSS.name}")
|
|
|
- self.run_general_battle_back()
|
|
|
|
|
|
|
+ self.run_general_battle_back(Monster_type="BOSS")
|
|
|
self.boss_fight_count += 1
|
|
self.boss_fight_count += 1
|
|
|
logger.info(f'Fight, boss_fight_count {self.boss_fight_count} times')
|
|
logger.info(f'Fight, boss_fight_count {self.boss_fight_count} times')
|
|
|
else:
|
|
else:
|
|
@@ -328,7 +411,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AbyssShadowsAssets):
|
|
|
if self.click_emeny_area(general):
|
|
if self.click_emeny_area(general):
|
|
|
logger.info(f"Click {general.name}")
|
|
logger.info(f"Click {general.name}")
|
|
|
self.general_fight_count += 1
|
|
self.general_fight_count += 1
|
|
|
- self.run_general_battle_back()
|
|
|
|
|
|
|
+ self.run_general_battle_back(Monster_type="GENERAL")
|
|
|
logger.info(f'Fight, general_fight_count {self.general_fight_count} times')
|
|
logger.info(f'Fight, general_fight_count {self.general_fight_count} times')
|
|
|
return True
|
|
return True
|
|
|
|
|
|
|
@@ -347,7 +430,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AbyssShadowsAssets):
|
|
|
if self.click_emeny_area(elite):
|
|
if self.click_emeny_area(elite):
|
|
|
logger.info(f"Click {elite.name}")
|
|
logger.info(f"Click {elite.name}")
|
|
|
self.elite_fight_count += 1
|
|
self.elite_fight_count += 1
|
|
|
- self.run_general_battle_back()
|
|
|
|
|
|
|
+ self.run_general_battle_back(Monster_type="ELITE")
|
|
|
logger.info(f'Fight, elite_fight_count {self.elite_fight_count} times')
|
|
logger.info(f'Fight, elite_fight_count {self.elite_fight_count} times')
|
|
|
return True
|
|
return True
|
|
|
|
|
|
|
@@ -418,20 +501,46 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AbyssShadowsAssets):
|
|
|
|
|
|
|
|
return suceess
|
|
return suceess
|
|
|
|
|
|
|
|
- def run_general_battle_back(self) -> bool:
|
|
|
|
|
|
|
+ def run_general_battle_back(self, Monster_type: str) -> bool:
|
|
|
"""
|
|
"""
|
|
|
重写父类方法,因为狭间暗域的准备和战斗流程不一样
|
|
重写父类方法,因为狭间暗域的准备和战斗流程不一样
|
|
|
进入挑战然后直接返回
|
|
进入挑战然后直接返回
|
|
|
:param config:
|
|
:param config:
|
|
|
:return:
|
|
:return:
|
|
|
"""
|
|
"""
|
|
|
|
|
+ cfg: AbyssShadows = self.config.abyss_shadows
|
|
|
while 1:
|
|
while 1:
|
|
|
|
|
+ #确保进入战斗
|
|
|
self.screenshot()
|
|
self.screenshot()
|
|
|
- if self.appear_then_click(self.I_PREPARE_HIGHLIGHT, interval=1.5):
|
|
|
|
|
- continue
|
|
|
|
|
- if not self.appear(self.I_PRESET):
|
|
|
|
|
|
|
+ if self.wait_until_appear(self.I_EQUIPPING, wait_time=4):
|
|
|
|
|
+ self.click(self.I_EQUIPPING, interval=1.5)
|
|
|
|
|
+ if not self.appear(self.I_EQUIPPING):
|
|
|
break
|
|
break
|
|
|
- logger.info(f"Click {self.I_PREPARE_HIGHLIGHT.name}")
|
|
|
|
|
|
|
+ logger.info(f"Click {self.I_EQUIPPING.name}")
|
|
|
|
|
+ logger.info(f"点击准备了")
|
|
|
|
|
+
|
|
|
|
|
+ # 进入战斗后,开始计时
|
|
|
|
|
+ start_time = time.time()
|
|
|
|
|
+ if cfg.abyss_shadows_combat_time.CombatTime_enable:
|
|
|
|
|
+ self.device.stuck_record_add('BATTLE_STATUS_S')
|
|
|
|
|
+ if Monster_type == "BOSS": # BOSS战斗
|
|
|
|
|
+ combat_time = cfg.abyss_shadows_combat_time.boss_combat_time
|
|
|
|
|
+ elif Monster_type == "GENERAL": # 是副将战斗
|
|
|
|
|
+ combat_time = cfg.abyss_shadows_combat_time.general_combat_time
|
|
|
|
|
+ elif Monster_type == "ELITE": # 精英战斗
|
|
|
|
|
+ combat_time = cfg.abyss_shadows_combat_time.elite_combat_time
|
|
|
|
|
+ else:
|
|
|
|
|
+ combat_time = 60 # 默认为 60 秒
|
|
|
|
|
+ # 等待设定的战斗时间
|
|
|
|
|
+ while time.time() - start_time < combat_time:
|
|
|
|
|
+ self.screenshot()
|
|
|
|
|
+ if self.appear_then_click(self.I_WIN, interval=1.5):
|
|
|
|
|
+ break
|
|
|
|
|
+ logger.info("Combat time ended, proceeding to exit.")
|
|
|
|
|
+ self.device.stuck_record_clear()
|
|
|
|
|
+ # 战斗提前结束这时没有返回按钮
|
|
|
|
|
+ if self.appear_then_click(self.I_WIN, interval=1.5):
|
|
|
|
|
+ return True
|
|
|
|
|
|
|
|
# 点击返回
|
|
# 点击返回
|
|
|
while 1:
|
|
while 1:
|