diff --git a/assets/cn/event_hospital/SIDEBAR_MORNING.png b/assets/cn/event_hospital/SIDEBAR_MORNING.png new file mode 100644 index 000000000..aa5999395 Binary files /dev/null and b/assets/cn/event_hospital/SIDEBAR_MORNING.png differ diff --git a/assets/cn/event_hospital/SIDEBAR_NIGHT.png b/assets/cn/event_hospital/SIDEBAR_NIGHT.png new file mode 100644 index 000000000..9c5131a3e Binary files /dev/null and b/assets/cn/event_hospital/SIDEBAR_NIGHT.png differ diff --git a/assets/cn/event_hospital/SIDEBAR_NOON.png b/assets/cn/event_hospital/SIDEBAR_NOON.png new file mode 100644 index 000000000..d35b53f73 Binary files /dev/null and b/assets/cn/event_hospital/SIDEBAR_NOON.png differ diff --git a/config/template.json b/config/template.json index f2b3e956f..f1fb19049 100644 --- a/config/template.json +++ b/config/template.json @@ -1254,7 +1254,8 @@ "ServerUpdate": "00:00" }, "Hospital": { - "UseRecommendFleet": true + "UseRecommendFleet": true, + "mapName": "0-T1" }, "StopCondition": { "OilLimit": 1000, @@ -1262,6 +1263,7 @@ "MapAchievement": "non_stop", "StageIncrease": false, "GetNewShip": false, + "EventSwitch": false, "ReachLevel": 0 }, "Emotion": { diff --git a/module/config/argument/args.json b/module/config/argument/args.json index 6931aaa55..8f8004690 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -6787,6 +6787,10 @@ "UseRecommendFleet": { "type": "checkbox", "value": true + }, + "mapName": { + "type": "input", + "value": "0-T1" } }, "StopCondition": { @@ -6821,6 +6825,10 @@ "value": false, "display": "hide" }, + "EventSwitch": { + "type": "checkbox", + "value": false + }, "ReachLevel": { "type": "input", "value": 0, diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 81b99a1b8..147222044 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -532,6 +532,7 @@ RaidDaily: hard > normal > easy Hospital: UseRecommendFleet: true + mapName: 0-T1 MaritimeEscort: Enable: true Coalition: diff --git a/module/config/config_generated.py b/module/config/config_generated.py index 8087278eb..9b0744a90 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -315,6 +315,7 @@ class GeneratedConfig: # Group `Hospital` Hospital_UseRecommendFleet = True + Hospital_mapName = '0-T1' # Group `MaritimeEscort` MaritimeEscort_Enable = True diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 54a722363..6d9e0d175 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -2125,6 +2125,10 @@ "UseRecommendFleet": { "name": "Use Fleet Recommendation", "help": "If turned off, you need to manually prepare fleets of all 15 stages in advance" + }, + "mapName": { + "name": "Hospital.mapName.name", + "help": "Hospital.mapName.help" } }, "MaritimeEscort": { diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index c7910f61d..26bd68b7e 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -2125,6 +2125,10 @@ "UseRecommendFleet": { "name": "Hospital.UseRecommendFleet.name", "help": "Hospital.UseRecommendFleet.help" + }, + "mapName": { + "name": "Hospital.mapName.name", + "help": "Hospital.mapName.help" } }, "MaritimeEscort": { diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index b38f99c34..2894dc899 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -2125,6 +2125,10 @@ "UseRecommendFleet": { "name": "使用舰队推荐", "help": "如果关闭,需要事先手动为所有15个关卡配队" + }, + "mapName": { + "name": "深谷来信关卡名称", + "help": "例如1-T3表示白天的T3关卡,开头的0,1,2,3分别对应不刷PT,白天,下午,晚上,-后面则是关卡名" } }, "MaritimeEscort": { diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index a94b48dd0..fc21e6d2b 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -2125,6 +2125,10 @@ "UseRecommendFleet": { "name": "使用艦隊推薦", "help": "如果關閉,需要事先手動為所有15個關卡配隊" + }, + "mapName": { + "name": "Hospital.mapName.name", + "help": "Hospital.mapName.help" } }, "MaritimeEscort": { diff --git a/module/event_hospital/assets.py b/module/event_hospital/assets.py index 4dc4ba643..15309ac8e 100644 --- a/module/event_hospital/assets.py +++ b/module/event_hospital/assets.py @@ -18,6 +18,13 @@ HOSPITAL_GOTO_DAILY = Button(area={'cn': (900, 658, 928, 688), 'en': (900, 658, INVEST_REWARD_RECEIVE = Button(area={'cn': (1113, 666, 1236, 690), 'en': (1113, 666, 1236, 690), 'jp': (1113, 666, 1236, 690), 'tw': (1113, 666, 1236, 690)}, color={'cn': (97, 99, 117), 'en': (97, 99, 117), 'jp': (97, 99, 117), 'tw': (97, 99, 117)}, button={'cn': (1113, 666, 1236, 690), 'en': (1113, 666, 1236, 690), 'jp': (1113, 666, 1236, 690), 'tw': (1113, 666, 1236, 690)}, file={'cn': './assets/cn/event_hospital/INVEST_REWARD_RECEIVE.png', 'en': './assets/cn/event_hospital/INVEST_REWARD_RECEIVE.png', 'jp': './assets/cn/event_hospital/INVEST_REWARD_RECEIVE.png', 'tw': './assets/cn/event_hospital/INVEST_REWARD_RECEIVE.png'}) INVEST_SCROLL = Button(area={'cn': (1200, 153, 1203, 642), 'en': (1200, 153, 1203, 642), 'jp': (1200, 153, 1203, 642), 'tw': (1200, 153, 1203, 642)}, color={'cn': (148, 136, 148), 'en': (148, 136, 148), 'jp': (148, 136, 148), 'tw': (148, 136, 148)}, button={'cn': (1200, 153, 1203, 642), 'en': (1200, 153, 1203, 642), 'jp': (1200, 153, 1203, 642), 'tw': (1200, 153, 1203, 642)}, file={'cn': './assets/cn/event_hospital/INVEST_SCROLL.png', 'en': './assets/cn/event_hospital/INVEST_SCROLL.png', 'jp': './assets/cn/event_hospital/INVEST_SCROLL.png', 'tw': './assets/cn/event_hospital/INVEST_SCROLL.png'}) INVEST_SEARCH = Button(area={'cn': (261, 135, 1187, 636), 'en': (261, 135, 1187, 636), 'jp': (261, 135, 1187, 636), 'tw': (261, 135, 1187, 636)}, color={'cn': (255, 255, 255), 'en': (255, 255, 255), 'jp': (255, 255, 255), 'tw': (255, 255, 255)}, button={'cn': (261, 135, 1187, 636), 'en': (261, 135, 1187, 636), 'jp': (261, 135, 1187, 636), 'tw': (261, 135, 1187, 636)}, file={'cn': './assets/cn/event_hospital/INVEST_SEARCH.png', 'en': './assets/cn/event_hospital/INVEST_SEARCH.png', 'jp': './assets/cn/event_hospital/INVEST_SEARCH.png', 'tw': './assets/cn/event_hospital/INVEST_SEARCH.png'}) +NEXT_SECRET_PAGE_BUTTON = Button(area={'cn': (1182, 347, 1212, 395), 'en': (1182, 347, 1212, 395), 'jp': (1182, 347, 1212, 395), 'tw': (1182, 347, 1212, 395)}, color={'cn': (166, 160, 166), 'en': (166, 160, 166), 'jp': (166, 160, 166), 'tw': (166, 160, 166)}, button={'cn': (1182, 347, 1212, 395), 'en': (1182, 347, 1212, 395), 'jp': (1182, 347, 1212, 395), 'tw': (1182, 347, 1212, 395)}, file={'cn': './assets/cn/event_hospital/NEXT_SECRET_PAGE_BUTTON.png', 'en': './assets/cn/event_hospital/NEXT_SECRET_PAGE_BUTTON.png', 'jp': './assets/cn/event_hospital/NEXT_SECRET_PAGE_BUTTON.png', 'tw': './assets/cn/event_hospital/NEXT_SECRET_PAGE_BUTTON.png'}) +RECORD_COLLECT = Button(area={'cn': (980, 541, 1151, 582), 'en': (980, 541, 1151, 582), 'jp': (980, 541, 1151, 582), 'tw': (980, 541, 1151, 582)}, color={'cn': (82, 76, 79), 'en': (82, 76, 79), 'jp': (82, 76, 79), 'tw': (82, 76, 79)}, button={'cn': (980, 541, 1151, 582), 'en': (980, 541, 1151, 582), 'jp': (980, 541, 1151, 582), 'tw': (980, 541, 1151, 582)}, file={'cn': './assets/cn/event_hospital/RECORD_COLLECT.png', 'en': './assets/cn/event_hospital/RECORD_COLLECT.png', 'jp': './assets/cn/event_hospital/RECORD_COLLECT.png', 'tw': './assets/cn/event_hospital/RECORD_COLLECT.png'}) +RECORD_END = Button(area={'cn': (955, 384, 1176, 460), 'en': (955, 384, 1176, 460), 'jp': (955, 384, 1176, 460), 'tw': (955, 384, 1176, 460)}, color={'cn': (143, 155, 204), 'en': (143, 155, 204), 'jp': (143, 155, 204), 'tw': (143, 155, 204)}, button={'cn': (955, 384, 1176, 460), 'en': (955, 384, 1176, 460), 'jp': (955, 384, 1176, 460), 'tw': (955, 384, 1176, 460)}, file={'cn': './assets/cn/event_hospital/RECORD_END.png', 'en': './assets/cn/event_hospital/RECORD_END.png', 'jp': './assets/cn/event_hospital/RECORD_END.png', 'tw': './assets/cn/event_hospital/RECORD_END.png'}) +RECORD_LIST = Button(area={'cn': (961, 163, 1169, 369), 'en': (961, 163, 1169, 369), 'jp': (961, 163, 1169, 369), 'tw': (961, 163, 1169, 369)}, color={'cn': (145, 141, 148), 'en': (145, 141, 148), 'jp': (145, 141, 148), 'tw': (145, 141, 148)}, button={'cn': (961, 163, 1169, 369), 'en': (961, 163, 1169, 369), 'jp': (961, 163, 1169, 369), 'tw': (961, 163, 1169, 369)}, file={'cn': './assets/cn/event_hospital/RECORD_LIST.png', 'en': './assets/cn/event_hospital/RECORD_LIST.png', 'jp': './assets/cn/event_hospital/RECORD_LIST.png', 'tw': './assets/cn/event_hospital/RECORD_LIST.png'}) +SIDEBAR_MORNING = Button(area={'cn': (24, 241, 56, 277), 'en': (24, 241, 56, 277), 'jp': (24, 241, 56, 277), 'tw': (24, 241, 56, 277)}, color={'cn': (80, 115, 196), 'en': (80, 115, 196), 'jp': (80, 115, 196), 'tw': (80, 115, 196)}, button={'cn': (24, 241, 56, 277), 'en': (24, 241, 56, 277), 'jp': (24, 241, 56, 277), 'tw': (24, 241, 56, 277)}, file={'cn': './assets/cn/event_hospital/SIDEBAR_MORNING.png', 'en': './assets/cn/event_hospital/SIDEBAR_MORNING.png', 'jp': './assets/cn/event_hospital/SIDEBAR_MORNING.png', 'tw': './assets/cn/event_hospital/SIDEBAR_MORNING.png'}) +SIDEBAR_NIGHT = Button(area={'cn': (24, 399, 54, 448), 'en': (24, 399, 54, 448), 'jp': (24, 399, 54, 448), 'tw': (24, 399, 54, 448)}, color={'cn': (59, 67, 59), 'en': (59, 67, 59), 'jp': (59, 67, 59), 'tw': (59, 67, 59)}, button={'cn': (24, 399, 54, 448), 'en': (24, 399, 54, 448), 'jp': (24, 399, 54, 448), 'tw': (24, 399, 54, 448)}, file={'cn': './assets/cn/event_hospital/SIDEBAR_NIGHT.png', 'en': './assets/cn/event_hospital/SIDEBAR_NIGHT.png', 'jp': './assets/cn/event_hospital/SIDEBAR_NIGHT.png', 'tw': './assets/cn/event_hospital/SIDEBAR_NIGHT.png'}) +SIDEBAR_NOON = Button(area={'cn': (24, 320, 54, 365), 'en': (24, 320, 54, 365), 'jp': (24, 320, 54, 365), 'tw': (24, 320, 54, 365)}, color={'cn': (78, 82, 75), 'en': (78, 82, 75), 'jp': (78, 82, 75), 'tw': (78, 82, 75)}, button={'cn': (24, 320, 54, 365), 'en': (24, 320, 54, 365), 'jp': (24, 320, 54, 365), 'tw': (24, 320, 54, 365)}, file={'cn': './assets/cn/event_hospital/SIDEBAR_NOON.png', 'en': './assets/cn/event_hospital/SIDEBAR_NOON.png', 'jp': './assets/cn/event_hospital/SIDEBAR_NOON.png', 'tw': './assets/cn/event_hospital/SIDEBAR_NOON.png'}) TAB_CHARACTER = Button(area={'cn': (263, 93, 409, 122), 'en': (263, 93, 409, 122), 'jp': (263, 93, 409, 122), 'tw': (263, 93, 409, 122)}, color={'cn': (185, 180, 191), 'en': (185, 180, 191), 'jp': (185, 180, 191), 'tw': (185, 180, 191)}, button={'cn': (263, 93, 409, 122), 'en': (263, 93, 409, 122), 'jp': (263, 93, 409, 122), 'tw': (263, 93, 409, 122)}, file={'cn': './assets/cn/event_hospital/TAB_CHARACTER.png', 'en': './assets/cn/event_hospital/TAB_CHARACTER.png', 'jp': './assets/cn/event_hospital/TAB_CHARACTER.png', 'tw': './assets/cn/event_hospital/TAB_CHARACTER.png'}) TAB_LOCATION = Button(area={'cn': (89, 93, 240, 121), 'en': (89, 93, 240, 121), 'jp': (89, 93, 240, 121), 'tw': (89, 93, 240, 121)}, color={'cn': (73, 108, 198), 'en': (73, 108, 198), 'jp': (73, 108, 198), 'tw': (73, 108, 198)}, button={'cn': (89, 93, 240, 121), 'en': (89, 93, 240, 121), 'jp': (89, 93, 240, 121), 'tw': (89, 93, 240, 121)}, file={'cn': './assets/cn/event_hospital/TAB_LOCATION.png', 'en': './assets/cn/event_hospital/TAB_LOCATION.png', 'jp': './assets/cn/event_hospital/TAB_LOCATION.png', 'tw': './assets/cn/event_hospital/TAB_LOCATION.png'}) TEMPLATE_INVEST = Template(file={'cn': './assets/cn/event_hospital/TEMPLATE_INVEST.png', 'en': './assets/en/event_hospital/TEMPLATE_INVEST.png', 'jp': './assets/jp/event_hospital/TEMPLATE_INVEST.png', 'tw': './assets/cn/event_hospital/TEMPLATE_INVEST.png'}) diff --git a/module/event_hospital/combat.py b/module/event_hospital/combat.py index 0d1b27590..2cb9be468 100644 --- a/module/event_hospital/combat.py +++ b/module/event_hospital/combat.py @@ -118,7 +118,16 @@ class HospitalCombat(Combat, HospitalUI, CampaignEvent): else: self.in_clue_confirm.reset() return False - + + def hospital_expected_end_combat(self): + """ + Returns: + bool: If combat ended + """ + if self.handle_combat_exit(): + return False + return False + def hospital_combat(self): """ Pages: diff --git a/module/event_hospital/hospital.py b/module/event_hospital/hospital.py index 518d776b8..7beff580d 100644 --- a/module/event_hospital/hospital.py +++ b/module/event_hospital/hospital.py @@ -45,6 +45,16 @@ HOSPITAL_TAB.add_state('LOCATION', check_button=TAB_LOCATION) HOSPITAL_TAB.add_state('CHARACTER', check_button=TAB_CHARACTER) +HOSPITAL_SIDEBAR = HospitalSwitch('HOSPITAL_SIDEBAR', is_selector=True) +HOSPITAL_SIDEBAR.add_state('MORNING', check_button=SIDEBAR_MORNING) +HOSPITAL_SIDEBAR.add_state('NOON', check_button=SIDEBAR_NOON) +HOSPITAL_SIDEBAR.add_state('NIGHT', check_button=SIDEBAR_NIGHT) +T1 = Button(area=(370, 268, 390, 290), color=(), button=(370, 268, 390, 290),name='T1') +T2 = Button(area=(250, 400, 270, 420), color=(), button=(250, 400, 270, 420),name='T2') +T3 = Button(area=(640, 530, 660, 550), color=(), button=(640, 530, 660, 550),name='T3') +T4 = Button(area=(990, 400, 1010, 420), color=(), button=(990, 400, 1010, 420),name='T4') + + class Hospital(HospitalClue, HospitalCombat): def daily_red_dot_appear(self): return self.image_color_count(DAILY_RED_DOT, color=(189, 69, 66), threshold=221, count=35) @@ -243,6 +253,56 @@ class Hospital(HospitalClue, HospitalCombat): swiped = True continue + def hospital_expected_end_combat(self): + """ + Returns: + bool: If combat ended + """ + if self.handle_combat_exit(): + return True + return False + + def ptRun(self): + time_map = {'1': 'MORNING', '2': 'NOON', '3': 'NIGHT'} + button_map = {'T1': T1, 'T2': T2, 'T3': T3, 'T4': T4} + time_period = self.config.Hospital_mapName.split('-')[0] + map_name = self.config.Hospital_mapName.split('-')[1].strip() + + + while 1: + self.device.screenshot() + + if self.event_time_limit_triggered(): + self.config.task_stop() + + # Log + logger.hr(f'{time_map.get(time_period)}_{map_name}', level=2) + # UI switches + if self.handle_combat_exit(): + continue + if self.ui_ensure(page_hospital): + continue + logger.warning("++++++++++++++++++++++++") + if self.event_pt_limit_triggered(): + logger.hr('Triggered stop condition: Event PT limit') + break + logger.warning("++++++++++++++++++++++++") + HOSPITAL_SIDEBAR.set(time_map.get(time_period), main=self) + self.device.click(button_map.get(map_name)) + + self.device.stuck_record_clear() + self.device.click_record_clear() + try: + self.combat(balance_hp=False, expected_end=self.hospital_expected_end_combat) + self.handle_combat_exit() + except ScriptEnd as e: + logger.hr('Script end') + logger.info(str(e)) + break + # Scheduler + if self.config.task_switched(): + self.config.task_stop() + def run(self): self.ui_ensure(page_hospital) self.daily_reward_receive() @@ -250,6 +310,9 @@ class Hospital(HospitalClue, HospitalCombat): self.clue_enter() try: self.loop_aside() + if not self.config.Hospital_mapName.startswith("0"): + self.clue_exit() + self.ptRun() # Scheduler self.config.task_delay(server_update=True) except OilExhausted: diff --git a/module/event_hospital/ui.py b/module/event_hospital/ui.py index ab8cc0f64..3785e9bfd 100644 --- a/module/event_hospital/ui.py +++ b/module/event_hospital/ui.py @@ -42,3 +42,22 @@ class HospitalUI(UI): if self.handle_get_clue(): return True return False + + def handle_combat_exit(self): + """ + Returns: + bool: If clicked + """ + if self.appear_then_click(HOSPITAL_BATTLE_EXIT, offset=(20, 20), interval=2): + return True + if self.appear(BATTLE_PREPARATION, offset=(30, 20), interval=2): + logger.info(f'{BATTLE_PREPARATION} -> {BACK}') + self.device.click(BACK) + return True + if self.appear(RAID_FLEET_PREPARATION, offset=(30, 30), interval=2): + logger.info(f'{RAID_FLEET_PREPARATION} -> {BACK}') + self.device.click(BACK) + return True + if self.handle_get_clue(): + return True + return False \ No newline at end of file