Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 新增设置, 支持在每日胖次捞完的时候停止常规图任务 #148

Merged
merged 12 commits into from
Jan 23, 2025
Binary file added autowsgr/data/images/fight_result/LOOT.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions autowsgr/game/game_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,17 @@ def match_night(timer: Timer, is_night):
def click_result(timer: Timer, max_times=1):
"""点击加速两页战果界面"""
timer.wait_images(IMG.fight_image[14])
looted = False
while timer.wait_image(IMG.fight_image[14], timeout=0.5):
if not looted:
if timer.image_exist(IMG.fight_result['LOOT'], need_screen_shot=True):
timer.got_loot_num += 1
timer.logger.info(f'捞到胖次! 当前胖次数:{timer.got_loot_num}')
looted = True
else:
timer.logger.debug('没有识别到胖次')
else:
timer.logger.debug('已经识别过胖次')
timer.click(915, 515, delay=0.25, times=1)


Expand Down
23 changes: 19 additions & 4 deletions autowsgr/scripts/daily_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def run(self):

# 自动出征
if self.config.auto_normal_fight:
while self._has_unfinished() and self._ship_max():
while self._has_unfinished() and self._ship_max() and self._loot_max():
task_id = self._get_unfinished()

plan = self.fight_plans[task_id]
Expand Down Expand Up @@ -115,12 +115,19 @@ def run(self):
def _has_unfinished(self) -> bool:
return any(times[0] < times[1] for times in self.fight_complete_times)

def _get_unfinished_plan_description(self, i: int) -> str:
plan_str = ''
plan_str += f'正在执行的PLAN: {self.fight_complete_times[i][2]}, '
plan_str += f'已出击次数/目标次数: {self.fight_complete_times[i][0]}/{self.fight_complete_times[i][1]}, '
plan_str += f'消耗快修数量: {self.timer.quick_repaired_cost}, '
plan_str += f'已掉落船数量: {self.timer.got_ship_num}, '
plan_str += f'已掉落胖次数量: {self.timer.got_loot_num}'
return plan_str

def _get_unfinished(self) -> int:
for i, times in enumerate(self.fight_complete_times):
if times[0] < times[1]:
self.timer.logger.info(
f'正在执行的PLAN:{self.fight_complete_times[i][2]}, 已出击次数:{self.fight_complete_times[i][0]}, 目标次数:{self.fight_complete_times[i][1]}, 消耗快修数量:{self.timer.quick_repaired_cost}, 已掉落船数量:{self.timer.got_ship_num}',
)
self.timer.logger.info(self._get_unfinished_plan_description(i))
return i
raise ValueError('没有未完成的任务')

Expand All @@ -145,6 +152,14 @@ def _ship_max(self) -> bool:
self.timer.logger.info('船只数量已达到上限,结束出征')
return False

def _loot_max(self) -> bool:
if not self.config.stop_max_loot:
return True
if self.timer.got_loot_num < 50:
return True
self.timer.logger.info('胖次数量已达到上限,结束出征')
return False

def check_exercise(self) -> None:
# 判断在哪个时间段
now_time = time.localtime(time.time())
Expand Down
2 changes: 2 additions & 0 deletions autowsgr/user_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class DailyAutomationConfig(BaseConfig):
"""快修消耗上限,达到时终止常规战出征。不填则无上限"""
stop_max_ship: bool = False
"""是否获取完当天上限500船后终止常规战出征"""
stop_max_loot: bool = False
"""是否获取完当天上限50胖次后终止常规战出征"""


@dataclass(frozen=True)
Expand Down
7 changes: 5 additions & 2 deletions examples/user_settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@ daily_automation:
- [8-5AI, 2, 250] # 6鱼

# 快修消耗上限,达到时终止常规战出征。
# 注释掉或者填 None 则无上限
quick_repair_limit: None
# 在选项前添加 # 注释掉, 或填写 null 则无上限
quick_repair_limit: null

# 捞到每天最大舰船(500)时停止
stop_max_ship: True

# 捞到每天最大胖次(50)时停止
stop_max_loot: True

# ========= 决战设置 =========
decisive_battle:
# 决战章节,请保证为 [1, 6] 中的整数. Defaults to 6.
Expand Down
Loading