Add: 增加了收菜模块的设置
- 增加了出击后定时回港收菜的功能 - 支持收食堂, 小卖部, 任务, 委托, 科研, 未支持委托派遣, 挂科研, 学技能 - 合并了收菜模块的文件 - 修正了收菜模块资源名称的拼写错误
BIN
assets/reward/EXP_INFO_S_REWARD.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
BIN
assets/reward/REWARD_1.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
assets/reward/REWARD_2.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
assets/reward/REWARD_3.png
Normal file
After Width: | Height: | Size: 8.4 KiB |
BIN
assets/reward/REWARD_SAVE_CLICK.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
@ -39,6 +39,14 @@ enable_drop_screenshot = no
|
||||
drop_screenshot_folder =
|
||||
command = setting
|
||||
|
||||
[Reward]
|
||||
command = reward
|
||||
enable_reward = yes
|
||||
reward_interval = 20
|
||||
enable_oil_reward = yes
|
||||
enable_coin_reward = yes
|
||||
enable_mission_reward = yes
|
||||
|
||||
[Emulator]
|
||||
command = emulator
|
||||
serial = 127.0.0.1:62001
|
||||
|
11
main.py
@ -12,6 +12,12 @@ class AzurLaneAutoScript:
|
||||
|
||||
logger.hr('Settings saved')
|
||||
|
||||
def reward(self):
|
||||
for key, value in self.config.config['Reward'].items():
|
||||
print(f'{key} = {value}')
|
||||
|
||||
logger.hr('Reward Settings saved')
|
||||
|
||||
def emulator(self):
|
||||
for key, value in self.config.config['Emulator'].items():
|
||||
print(f'{key} = {value}')
|
||||
@ -59,11 +65,6 @@ class AzurLaneAutoScript:
|
||||
az = CampaignRun(self.config)
|
||||
az.run(self.config.CAMPAIGN_EVENT, folder=self.config.EVENT_NAME)
|
||||
|
||||
def reward(self):
|
||||
from module.reward.reward import Reward
|
||||
az = Reward(self.config)
|
||||
az.run()
|
||||
|
||||
def event_daily_ab(self):
|
||||
from module.event.campaign_ab import CampaignAB
|
||||
az = CampaignAB(self.config)
|
||||
|
15
main.pyw
@ -140,7 +140,20 @@ def main():
|
||||
drop.add_argument('--启用掉落记录', default=default('--启用掉落记录'), choices=['是', '否'])
|
||||
drop.add_argument('--掉落保存目录', default=default('--掉落保存目录'))
|
||||
|
||||
# 模拟器
|
||||
# ==========收菜设置==========
|
||||
reward_parser = subs.add_parser('收菜设置')
|
||||
reward_condition = reward_parser.add_argument_group('触发条件', '')
|
||||
reward_condition.add_argument('--启用收获', default=default('--启用收获'), choices=['是', '否'])
|
||||
reward_condition.add_argument('--收菜间隔', default=default('--收菜间隔'), choices=['20', '30', '60'], help='每隔多少分钟触发收菜')
|
||||
|
||||
reward_oil = reward_parser.add_argument_group('石油物资', '')
|
||||
reward_oil.add_argument('--启用石油收获', default=default('--启用石油收获'), choices=['是', '否'])
|
||||
reward_oil.add_argument('--启用物资收获', default=default('--启用物资收获'), choices=['是', '否'])
|
||||
|
||||
reward_mission = reward_parser.add_argument_group('任务奖励', '')
|
||||
reward_mission.add_argument('--启用任务收获', default=default('--启用任务收获'), choices=['是', '否'])
|
||||
|
||||
# ==========模拟器==========
|
||||
emulator_parser = subs.add_parser('模拟器')
|
||||
emulator = emulator_parser.add_argument_group('模拟器', '')
|
||||
emulator.add_argument('--设备', default=default('--设备'), help='例如 127.0.0.1:62001')
|
||||
|
@ -9,11 +9,12 @@ from module.campaign.campaign_base import CampaignBase
|
||||
from module.campaign.campaign_ui import CampaignUI
|
||||
from module.config.config import AzurLaneConfig
|
||||
from module.logger import logger
|
||||
from module.reward.reward import Reward
|
||||
|
||||
OCR_OIL = Digit(OCR_OIL, letter=(247, 247, 247), back=(33, 36, 49), limit=25000, name='OCR_OIL')
|
||||
|
||||
|
||||
class CampaignRun(CampaignUI):
|
||||
class CampaignRun(CampaignUI, Reward):
|
||||
folder: str
|
||||
name: str
|
||||
stage: str
|
||||
@ -110,13 +111,11 @@ class CampaignRun(CampaignUI):
|
||||
self.load_campaign(name, folder=folder)
|
||||
self.run_count = 0
|
||||
while 1:
|
||||
self.device.screenshot()
|
||||
self.handle_reward()
|
||||
|
||||
# End
|
||||
if total and self.run_count == total:
|
||||
break
|
||||
if self.triggered_stop_condition():
|
||||
break
|
||||
|
||||
# Log
|
||||
logger.hr(name, level=1)
|
||||
@ -125,13 +124,20 @@ class CampaignRun(CampaignUI):
|
||||
else:
|
||||
logger.info(f'Count: [{self.run_count}]')
|
||||
|
||||
# Run
|
||||
# UI ensure
|
||||
self.device.screenshot()
|
||||
self.campaign.device.image = self.device.image
|
||||
if self.campaign.is_in_map():
|
||||
logger.info('Already in map, skip ensure_campaign_ui.')
|
||||
else:
|
||||
self.ensure_campaign_ui(name=self.stage)
|
||||
self.campaign.ENTRANCE = self.campaign_get_entrance(name=self.stage)
|
||||
|
||||
# End
|
||||
if self.triggered_stop_condition():
|
||||
break
|
||||
|
||||
# Run
|
||||
self.campaign.run()
|
||||
|
||||
# After run
|
||||
|
@ -231,6 +231,16 @@ class AzurLaneConfig:
|
||||
ENABLE_SEMI_MAP_PREPARATION = True
|
||||
ENABLE_SEMI_STORY_SKIP = True
|
||||
|
||||
"""
|
||||
module.reward
|
||||
"""
|
||||
ENABLE_REWARD = True
|
||||
REWARD_INTERVAL = 20
|
||||
REWARD_LAST_TIME = datetime.now()
|
||||
ENABLE_OIL_REWARD = True
|
||||
ENABLE_COIN_REWARD = True
|
||||
ENABLE_MISSION_REWARD = True
|
||||
|
||||
"""
|
||||
C_7_2_mystery_farming
|
||||
"""
|
||||
@ -327,6 +337,12 @@ class AzurLaneConfig:
|
||||
for r in ['n', 'r', 'sr', 'ssr']:
|
||||
self.__setattr__(f'RETIRE_{r.upper()}', to_bool(option[f'retire_{r}']))
|
||||
|
||||
# Reward
|
||||
option = config['Reward']
|
||||
self.REWARD_INTERVAL = int(option['reward_interval'])
|
||||
for attr in ['enable_reward', 'enable_oil_reward', 'enable_coin_reward', 'enable_mission_reward']:
|
||||
self.__setattr__(attr.upper(), to_bool(option[attr]))
|
||||
|
||||
option = config['Main']
|
||||
self.CAMPAIGN_NAME = option['main_stage']
|
||||
self.CAMPAIGN_NAME = 'campaign_' + self.CAMPAIGN_NAME.replace('-', '_')
|
||||
|
@ -25,6 +25,7 @@ dic_daily = {
|
||||
dic_chi_to_eng = {
|
||||
# Function
|
||||
'出击设置': 'setting',
|
||||
'收菜设置': 'reward',
|
||||
'模拟器': 'emulator',
|
||||
'每日任务': 'daily',
|
||||
'主线图': 'main',
|
||||
@ -70,6 +71,11 @@ dic_chi_to_eng = {
|
||||
'退役金皮': 'retire_ssr',
|
||||
'启用掉落记录': 'enable_drop_screenshot',
|
||||
'掉落保存目录': 'drop_screenshot_folder',
|
||||
'启用收获': 'enable_reward',
|
||||
'收菜间隔': 'reward_interval',
|
||||
'启用石油收获': 'enable_oil_reward',
|
||||
'启用物资收获': 'enable_coin_reward',
|
||||
'启用任务收获': 'enable_mission_reward',
|
||||
'设备': 'serial',
|
||||
'打每日': 'enable_daily_mission',
|
||||
'打困难': 'enable_hard_campaign',
|
||||
|
@ -5,7 +5,12 @@ from module.base.template import Template
|
||||
# Don't modified it manually.
|
||||
|
||||
COIN = Button(area=(403, 64, 436, 88), color=(226, 173, 72), button=(403, 64, 436, 88), file='./assets/reward/COIN.png')
|
||||
EXP_INFO_S_REWARD = Button(area=(498, 140, 557, 154), color=(233, 241, 127), button=(498, 140, 557, 154), file='./assets/reward/EXP_INFO_S_REWARD.png')
|
||||
MISSION_MULTI = Button(area=(1041, 8, 1101, 39), color=(226, 192, 142), button=(1041, 8, 1101, 39), file='./assets/reward/MISSION_MULTI.png')
|
||||
MISSION_NOTISE = Button(area=(940, 670, 945, 681), color=(183, 83, 66), button=(940, 670, 945, 681), file='./assets/reward/MISSION_NOTISE.png')
|
||||
MISSION_SINGAL = Button(area=(1093, 118, 1179, 177), color=(115, 155, 218), button=(1093, 118, 1179, 177), file='./assets/reward/MISSION_SINGAL.png')
|
||||
MISSION_NOTICE = Button(area=(940, 670, 945, 681), color=(183, 83, 66), button=(940, 670, 945, 681), file='./assets/reward/MISSION_NOTICE.png')
|
||||
MISSION_SIGNAL = Button(area=(1093, 118, 1179, 177), color=(115, 155, 218), button=(1093, 118, 1179, 177), file='./assets/reward/MISSION_SIGNAL.png')
|
||||
OIL = Button(area=(162, 64, 182, 91), color=(71, 72, 71), button=(162, 64, 182, 91), file='./assets/reward/OIL.png')
|
||||
REWARD_1 = Button(area=(383, 285, 503, 297), color=(238, 168, 81), button=(383, 285, 503, 297), file='./assets/reward/REWARD_1.png')
|
||||
REWARD_2 = Button(area=(383, 404, 503, 444), color=(233, 165, 67), button=(383, 404, 503, 444), file='./assets/reward/REWARD_2.png')
|
||||
REWARD_3 = Button(area=(383, 546, 503, 586), color=(234, 163, 69), button=(383, 546, 503, 586), file='./assets/reward/REWARD_3.png')
|
||||
REWARD_SAVE_CLICK = Button(area=(415, 184, 496, 214), color=(152, 150, 168), button=(415, 184, 496, 214), file='./assets/reward/REWARD_SAVE_CLICK.png')
|
||||
|
@ -1,47 +0,0 @@
|
||||
from module.ui.ui import page_mission
|
||||
from module.reward.assets import *
|
||||
from module.combat.combat import Combat
|
||||
from module.base.timer import Timer
|
||||
from module.logger import logger
|
||||
|
||||
|
||||
class RewardMission(Combat):
|
||||
def reward_mission(self):
|
||||
"""
|
||||
Returns:
|
||||
bool: If rewarded.
|
||||
"""
|
||||
logger.hr('Mission reward')
|
||||
if not self.appear(MISSION_NOTISE):
|
||||
logger.info('No mission reward')
|
||||
return False
|
||||
|
||||
self.ui_ensure(page_mission)
|
||||
|
||||
reward = False
|
||||
click_timer = Timer(1)
|
||||
click_timer.start()
|
||||
while 1:
|
||||
self.device.screenshot()
|
||||
|
||||
if self.handle_get_items(save_get_items=False):
|
||||
click_timer.reset()
|
||||
continue
|
||||
if self.handle_get_ship():
|
||||
click_timer.reset()
|
||||
continue
|
||||
if self.appear_then_click(MISSION_MULTI, interval=1):
|
||||
click_timer.reset()
|
||||
reward = True
|
||||
continue
|
||||
if self.appear_then_click(MISSION_SINGAL, interval=1):
|
||||
click_timer.reset()
|
||||
reward = True
|
||||
continue
|
||||
|
||||
# End
|
||||
if click_timer.reached():
|
||||
break
|
||||
|
||||
self.ui_goto_main()
|
||||
return reward
|
@ -1,36 +0,0 @@
|
||||
from module.ui.ui import UI, page_reward, page_main
|
||||
from module.reward.assets import *
|
||||
from module.base.timer import Timer
|
||||
from module.logger import logger
|
||||
|
||||
|
||||
class RewardOil(UI):
|
||||
def reward_oil(self):
|
||||
"""
|
||||
Returns:
|
||||
bool: If rewarded.
|
||||
"""
|
||||
logger.hr('Oil Reward')
|
||||
self.ui_ensure(page_reward)
|
||||
|
||||
reward = False
|
||||
click_timer = Timer(1)
|
||||
click_timer.start()
|
||||
while 1:
|
||||
self.device.screenshot()
|
||||
if self.appear_then_click(OIL, interval=1):
|
||||
click_timer.reset()
|
||||
reward = True
|
||||
continue
|
||||
if self.appear_then_click(COIN, interval=1):
|
||||
click_timer.reset()
|
||||
reward = True
|
||||
continue
|
||||
|
||||
# End
|
||||
if click_timer.reached():
|
||||
break
|
||||
|
||||
self.ui_current = page_reward
|
||||
self.ui_goto(page_main)
|
||||
return reward
|
@ -1,8 +1,114 @@
|
||||
from module.reward.oil import RewardOil
|
||||
from module.reward.mission import RewardMission
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from module.base.timer import Timer
|
||||
from module.combat.assets import *
|
||||
from module.logger import logger
|
||||
from module.reward.assets import *
|
||||
from module.ui.page import *
|
||||
from module.ui.ui import UI
|
||||
|
||||
|
||||
class Reward(RewardOil, RewardMission):
|
||||
def run(self):
|
||||
self.reward_oil()
|
||||
self.reward_mission()
|
||||
class Reward(UI):
|
||||
def reward(self):
|
||||
logger.hr('Reward start')
|
||||
self.ui_goto_main()
|
||||
self._reward_mission()
|
||||
|
||||
self.ui_goto(page_reward, skip_first_screenshot=True)
|
||||
|
||||
self._reward_receive()
|
||||
|
||||
self.ui_click(
|
||||
click_button=page_reward.links[page_main],
|
||||
check_button=page_main.check_button,
|
||||
appear_button=page_reward.check_button,
|
||||
skip_first_screenshot=True)
|
||||
logger.hr('Reward end')
|
||||
|
||||
def handle_reward(self):
|
||||
if not self.config.ENABLE_REWARD:
|
||||
return False
|
||||
if datetime.now() - self.config.REWARD_LAST_TIME < timedelta(minutes=self.config.REWARD_INTERVAL):
|
||||
return False
|
||||
|
||||
self.reward()
|
||||
|
||||
self.config.REWARD_LAST_TIME = datetime.now()
|
||||
return True
|
||||
|
||||
def _reward_receive(self):
|
||||
"""
|
||||
Returns:
|
||||
bool: If rewarded.
|
||||
"""
|
||||
logger.hr('Oil Reward')
|
||||
|
||||
reward = False
|
||||
exit_timer = Timer(1)
|
||||
click_timer = Timer(1)
|
||||
exit_timer.start()
|
||||
while 1:
|
||||
self.device.screenshot()
|
||||
|
||||
for button in [EXP_INFO_S_REWARD, GET_ITEMS_1, GET_ITEMS_2, GET_SHIP]:
|
||||
if self.appear(button, interval=1):
|
||||
self.device.click(REWARD_SAVE_CLICK)
|
||||
exit_timer.reset()
|
||||
reward = True
|
||||
continue
|
||||
|
||||
for button in [REWARD_1, REWARD_3, OIL, COIN]:
|
||||
if not click_timer.reached():
|
||||
continue
|
||||
if self.appear_then_click(button, interval=1):
|
||||
exit_timer.reset()
|
||||
click_timer.reset()
|
||||
reward = True
|
||||
continue
|
||||
|
||||
# End
|
||||
if exit_timer.reached():
|
||||
break
|
||||
|
||||
return reward
|
||||
|
||||
def _reward_mission(self):
|
||||
"""
|
||||
Returns:
|
||||
bool: If rewarded.
|
||||
"""
|
||||
logger.hr('Mission reward')
|
||||
if not self.appear(MISSION_NOTICE):
|
||||
logger.info('No mission reward')
|
||||
return False
|
||||
|
||||
self.ui_goto(page_mission, skip_first_screenshot=True)
|
||||
|
||||
reward = False
|
||||
exit_timer = Timer(1)
|
||||
click_timer = Timer(1)
|
||||
exit_timer.start()
|
||||
while 1:
|
||||
self.device.screenshot()
|
||||
|
||||
for button in [GET_ITEMS_1, GET_ITEMS_2, GET_SHIP]:
|
||||
if self.appear_then_click(button, interval=1):
|
||||
exit_timer.reset()
|
||||
reward = True
|
||||
continue
|
||||
|
||||
for button in [MISSION_MULTI, MISSION_SIGNAL]:
|
||||
if not click_timer.reached():
|
||||
continue
|
||||
if self.appear_then_click(button, interval=1):
|
||||
exit_timer.reset()
|
||||
click_timer.reset()
|
||||
reward = True
|
||||
continue
|
||||
|
||||
# End
|
||||
if exit_timer.reached():
|
||||
break
|
||||
|
||||
self.ui_goto(page_main, skip_first_screenshot=True)
|
||||
return reward
|
||||
|
@ -64,10 +64,11 @@ class UI(ModuleBase):
|
||||
|
||||
logger.info('Unable to goto page_main')
|
||||
|
||||
def ui_goto(self, destination):
|
||||
def ui_goto(self, destination, skip_first_screenshot=False):
|
||||
"""
|
||||
Args:
|
||||
destination (Page):
|
||||
skip_first_screenshot (bool):
|
||||
"""
|
||||
# Iter
|
||||
visited = [self.ui_current]
|
||||
@ -100,12 +101,15 @@ class UI(ModuleBase):
|
||||
logger.attr('UI route', ' - '.join([p.name for p in route]))
|
||||
|
||||
# Click
|
||||
skip = False
|
||||
for p1, p2 in zip(route[:-1], route[1:]):
|
||||
# self.ui_click(source=p1, destination=p2)
|
||||
self.ui_click(click_button=p1.links[p2], check_button=p2.check_button, offset=(20, 20), skip_first_screenshot=skip)
|
||||
self.ui_click(
|
||||
click_button=p1.links[p2],
|
||||
check_button=p2.check_button,
|
||||
offset=(20, 20),
|
||||
skip_first_screenshot=skip_first_screenshot)
|
||||
self.ui_current = p2
|
||||
skip = True
|
||||
skip_first_screenshot = True
|
||||
|
||||
# Reset
|
||||
for page in visited:
|
||||
|