Add: 收菜模块, 收食堂小卖部和任务

- 独立出处理物品掉落和舰娘掉落的方法
This commit is contained in:
LmeSzinc 2020-03-30 14:00:39 +08:00 committed by LmeSzinc
parent 8366d7a258
commit 1921142369
19 changed files with 149 additions and 8 deletions

BIN
assets/reward/COIN.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
assets/reward/OIL.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

BIN
assets/ui/MISSION_CHECK.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

BIN
assets/ui/REWARD_CHECK.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -53,6 +53,11 @@ class AzurLaneAutoScript:
az = CampaignRun(self.config) az = CampaignRun(self.config)
az.run(self.config.CAMPAIGN_EVENT) az.run(self.config.CAMPAIGN_EVENT)
def reward(self):
from module.reward.reward import Reward
az = Reward(self.config)
az.run()
def event_daily_ab(self): def event_daily_ab(self):
from module.event.campaign_ab import CampaignAB from module.event.campaign_ab import CampaignAB
az = CampaignAB(self.config) az = CampaignAB(self.config)
@ -79,5 +84,5 @@ class AzurLaneAutoScript:
az.retire_ships(amount=2000) az.retire_ships(amount=2000)
# alas = AzurLaneAutoScript() alas = AzurLaneAutoScript()
# alas.retire() alas.reward()

View File

@ -181,7 +181,7 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
if self.handle_battle_status(save_get_items=save_get_items): if self.handle_battle_status(save_get_items=save_get_items):
break break
def handle_battle_status(self, save_get_items): def handle_battle_status(self, save_get_items=False):
""" """
Args: Args:
save_get_items (bool): save_get_items (bool):
@ -199,6 +199,27 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
return False return False
def handle_get_items(self, save_get_items=False):
"""
Args:
save_get_items (bool):
Returns:
bool:
"""
if self.appear_then_click(GET_ITEMS_1, screenshot=save_get_items, genre='get_items', offset=5):
return True
if self.appear_then_click(GET_ITEMS_2, screenshot=save_get_items, genre='get_items', offset=5):
return False
return False
def handle_get_ship(self):
if self.appear_then_click(GET_SHIP):
return True
return False
def combat_status(self, save_get_items=False, expected_end=None): def combat_status(self, save_get_items=False, expected_end=None):
""" """
Args: Args:
@ -210,13 +231,11 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
self.device.screenshot() self.device.screenshot()
# Combat status # Combat status
if self.appear_then_click(GET_ITEMS_1, screenshot=save_get_items, genre='get_items', offset=5): if self.handle_get_items(save_get_items=save_get_items):
continue
if self.appear_then_click(GET_ITEMS_2, screenshot=save_get_items, genre='get_items', offset=5):
continue continue
if self.handle_battle_status(save_get_items=save_get_items): if self.handle_battle_status(save_get_items=save_get_items):
continue continue
if self.appear_then_click(GET_SHIP): if self.handle_get_ship():
continue continue
if self.appear_then_click(EXP_INFO_S): if self.appear_then_click(EXP_INFO_S):
self.device.sleep((0.25, 0.5)) self.device.sleep((0.25, 0.5))

11
module/reward/assets.py Normal file
View File

@ -0,0 +1,11 @@
from module.base.button import Button
from module.base.template import Template
# This file is generated by module.dev_tools.asset_extract.
# 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')
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')
OIL = Button(area=(162, 64, 182, 91), color=(71, 72, 71), button=(162, 64, 182, 91), file='./assets/reward/OIL.png')

47
module/reward/mission.py Normal file
View File

@ -0,0 +1,47 @@
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

36
module/reward/oil.py Normal file
View File

@ -0,0 +1,36 @@
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

8
module/reward/reward.py Normal file
View File

@ -0,0 +1,8 @@
from module.reward.oil import RewardOil
from module.reward.mission import RewardMission
class Reward(RewardOil, RewardMission):
def run(self):
self.reward_oil()
self.reward_mission()

View File

@ -15,5 +15,10 @@ FLEET_CHECK = Button(area=(1044, 641, 1243, 702), color=(237, 186, 112), button=
GOTO_MAIN = Button(area=(1230, 17, 1253, 45), color=(112, 132, 159), button=(1228, 18, 1255, 49), file='./assets/ui/GOTO_MAIN.png') GOTO_MAIN = Button(area=(1230, 17, 1253, 45), color=(112, 132, 159), button=(1228, 18, 1255, 49), file='./assets/ui/GOTO_MAIN.png')
MAIN_GOTO_CAMPAIGN = Button(area=(1008, 289, 1154, 435), color=(216, 171, 99), button=(1008, 289, 1154, 435), file='./assets/ui/MAIN_GOTO_CAMPAIGN.png') MAIN_GOTO_CAMPAIGN = Button(area=(1008, 289, 1154, 435), color=(216, 171, 99), button=(1008, 289, 1154, 435), file='./assets/ui/MAIN_GOTO_CAMPAIGN.png')
MAIN_GOTO_FLEET = Button(area=(733, 359, 987, 435), color=(110, 166, 234), button=(733, 359, 987, 435), file='./assets/ui/MAIN_GOTO_FLEET.png') MAIN_GOTO_FLEET = Button(area=(733, 359, 987, 435), color=(110, 166, 234), button=(733, 359, 987, 435), file='./assets/ui/MAIN_GOTO_FLEET.png')
MAIN_GOTO_MISSION = Button(area=(816, 666, 932, 713), color=(93, 110, 140), button=(816, 666, 932, 713), file='./assets/ui/MAIN_GOTO_MISSION.png')
MAIN_GOTO_REWARD = Button(area=(11, 139, 30, 189), color=(69, 81, 115), button=(11, 139, 30, 189), file='./assets/ui/MAIN_GOTO_REWARD.png')
MISSION_CHECK = Button(area=(120, 15, 173, 40), color=(141, 156, 194), button=(120, 15, 173, 40), file='./assets/ui/MISSION_CHECK.png')
OCR_OIL_CV = Button(area=(634, 27, 714, 48), color=(93, 95, 109), button=(634, 27, 714, 48), file='./assets/ui/OCR_OIL_CV.png') OCR_OIL_CV = Button(area=(634, 27, 714, 48), color=(93, 95, 109), button=(634, 27, 714, 48), file='./assets/ui/OCR_OIL_CV.png')
REWARD_CHECK = Button(area=(302, 119, 371, 195), color=(146, 118, 120), button=(302, 119, 371, 195), file='./assets/ui/REWARD_CHECK.png')
REWARD_GOTO_MAIN = Button(area=(1037, 611, 1107, 656), color=(134, 122, 127), button=(1037, 611, 1107, 656), file='./assets/ui/REWARD_GOTO_MAIN.png')
SP_CHECK = Button(area=(123, 63, 206, 109), color=(95, 110, 145), button=(123, 63, 206, 109), file='./assets/ui/SP_CHECK.png') SP_CHECK = Button(area=(123, 63, 206, 109), color=(95, 110, 145), button=(123, 63, 206, 109), file='./assets/ui/SP_CHECK.png')

View File

@ -60,3 +60,13 @@ page_sp = Page(SP_CHECK)
page_sp.link(button=GOTO_MAIN, destination=page_main) page_sp.link(button=GOTO_MAIN, destination=page_main)
page_sp.link(button=BACK_ARROW, destination=page_campaign) page_sp.link(button=BACK_ARROW, destination=page_campaign)
page_campaign.link(button=CAMPAIGN_GOTO_EVENT, destination=page_sp) page_campaign.link(button=CAMPAIGN_GOTO_EVENT, destination=page_sp)
# Reward
page_reward = Page(REWARD_CHECK)
page_reward.link(button=REWARD_GOTO_MAIN, destination=page_main)
page_main.link(button=MAIN_GOTO_REWARD, destination=page_reward)
# Mission
page_mission = Page(MISSION_CHECK)
page_mission.link(button=GOTO_MAIN, destination=page_main)
page_main.link(button=MAIN_GOTO_MISSION, destination=page_mission)

View File

@ -7,7 +7,7 @@ from module.ui.page import *
class UI(ModuleBase): class UI(ModuleBase):
ui_pages = [page_main, page_campaign, page_fleet, page_exercise, page_daily, page_event, page_sp] ui_pages = [page_main, page_campaign, page_fleet, page_exercise, page_daily, page_event, page_sp, page_mission]
ui_current: Page ui_current: Page
def ui_page_appear(self, page): def ui_page_appear(self, page):