diff --git a/assets/reward/COIN.png b/assets/reward/COIN.png new file mode 100644 index 000000000..a7af11215 Binary files /dev/null and b/assets/reward/COIN.png differ diff --git a/assets/reward/MISSION_MULTI.png b/assets/reward/MISSION_MULTI.png new file mode 100644 index 000000000..bdfaadd3d Binary files /dev/null and b/assets/reward/MISSION_MULTI.png differ diff --git a/assets/reward/MISSION_NOTISE.png b/assets/reward/MISSION_NOTISE.png new file mode 100644 index 000000000..c1b624f94 Binary files /dev/null and b/assets/reward/MISSION_NOTISE.png differ diff --git a/assets/reward/MISSION_SINGAL.png b/assets/reward/MISSION_SINGAL.png new file mode 100644 index 000000000..564ccb1bf Binary files /dev/null and b/assets/reward/MISSION_SINGAL.png differ diff --git a/assets/reward/OIL.png b/assets/reward/OIL.png new file mode 100644 index 000000000..62bed7db3 Binary files /dev/null and b/assets/reward/OIL.png differ diff --git a/assets/ui/MAIN_GOTO_MISSION.png b/assets/ui/MAIN_GOTO_MISSION.png new file mode 100644 index 000000000..99c326063 Binary files /dev/null and b/assets/ui/MAIN_GOTO_MISSION.png differ diff --git a/assets/ui/MAIN_GOTO_REWARD.png b/assets/ui/MAIN_GOTO_REWARD.png new file mode 100644 index 000000000..bb66709b1 Binary files /dev/null and b/assets/ui/MAIN_GOTO_REWARD.png differ diff --git a/assets/ui/MISSION_CHECK.png b/assets/ui/MISSION_CHECK.png new file mode 100644 index 000000000..4fd99eaf9 Binary files /dev/null and b/assets/ui/MISSION_CHECK.png differ diff --git a/assets/ui/REWARD_CHECK.png b/assets/ui/REWARD_CHECK.png new file mode 100644 index 000000000..56691c636 Binary files /dev/null and b/assets/ui/REWARD_CHECK.png differ diff --git a/assets/ui/REWARD_GOTO_MAIN.png b/assets/ui/REWARD_GOTO_MAIN.png new file mode 100644 index 000000000..1afb4308f Binary files /dev/null and b/assets/ui/REWARD_GOTO_MAIN.png differ diff --git a/main.py b/main.py index eb9dd39b7..9f7282f47 100644 --- a/main.py +++ b/main.py @@ -53,6 +53,11 @@ class AzurLaneAutoScript: az = CampaignRun(self.config) 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): from module.event.campaign_ab import CampaignAB az = CampaignAB(self.config) @@ -79,5 +84,5 @@ class AzurLaneAutoScript: az.retire_ships(amount=2000) -# alas = AzurLaneAutoScript() -# alas.retire() +alas = AzurLaneAutoScript() +alas.reward() diff --git a/module/combat/combat.py b/module/combat/combat.py index df39b7602..c68757bf5 100644 --- a/module/combat/combat.py +++ b/module/combat/combat.py @@ -181,7 +181,7 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem if self.handle_battle_status(save_get_items=save_get_items): break - def handle_battle_status(self, save_get_items): + def handle_battle_status(self, save_get_items=False): """ Args: save_get_items (bool): @@ -199,6 +199,27 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem 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): """ Args: @@ -210,13 +231,11 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem self.device.screenshot() # Combat status - if self.appear_then_click(GET_ITEMS_1, screenshot=save_get_items, genre='get_items', offset=5): - continue - if self.appear_then_click(GET_ITEMS_2, screenshot=save_get_items, genre='get_items', offset=5): + if self.handle_get_items(save_get_items=save_get_items): continue if self.handle_battle_status(save_get_items=save_get_items): continue - if self.appear_then_click(GET_SHIP): + if self.handle_get_ship(): continue if self.appear_then_click(EXP_INFO_S): self.device.sleep((0.25, 0.5)) diff --git a/module/reward/assets.py b/module/reward/assets.py new file mode 100644 index 000000000..89cd24b72 --- /dev/null +++ b/module/reward/assets.py @@ -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') diff --git a/module/reward/mission.py b/module/reward/mission.py new file mode 100644 index 000000000..9392e5f04 --- /dev/null +++ b/module/reward/mission.py @@ -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 diff --git a/module/reward/oil.py b/module/reward/oil.py new file mode 100644 index 000000000..323337fe6 --- /dev/null +++ b/module/reward/oil.py @@ -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 diff --git a/module/reward/reward.py b/module/reward/reward.py new file mode 100644 index 000000000..3ea5a19d2 --- /dev/null +++ b/module/reward/reward.py @@ -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() diff --git a/module/ui/assets.py b/module/ui/assets.py index 120becdc7..72f059c3d 100644 --- a/module/ui/assets.py +++ b/module/ui/assets.py @@ -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') 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_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') +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') diff --git a/module/ui/page.py b/module/ui/page.py index 2d069461a..b0bfb0e9b 100644 --- a/module/ui/page.py +++ b/module/ui/page.py @@ -60,3 +60,13 @@ page_sp = Page(SP_CHECK) page_sp.link(button=GOTO_MAIN, destination=page_main) page_sp.link(button=BACK_ARROW, destination=page_campaign) 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) diff --git a/module/ui/ui.py b/module/ui/ui.py index 1ef945c12..f4e87ba8e 100644 --- a/module/ui/ui.py +++ b/module/ui/ui.py @@ -7,7 +7,7 @@ from module.ui.page import * 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 def ui_page_appear(self, page):