Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified assets/en/retire/DOCK_AMOUNT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/en/retire/EMPTY_ENHANCE_SLOT_PLUS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
170 changes: 97 additions & 73 deletions module/combat/auto_search_combat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from module.handler.assets import AUTO_SEARCH_MAP_OPTION_ON
from module.logger import logger
from module.map.map_operation import MapOperation
from module.statistics.campaign_bonus import CampaignBonusStatistics


class AutoSearchCombat(MapOperation, Combat, CampaignStatus):
class AutoSearchCombat(MapOperation, Combat, CampaignStatus, CampaignBonusStatistics):
_auto_search_in_stage_timer = Timer(3, count=6)
_auto_search_status_confirm = False
auto_search_oil_limit_triggered = False
Expand Down Expand Up @@ -175,41 +176,53 @@ def auto_search_moving(self, skip_first_screenshot=True):
checked_fleet = False
checked_oil = False
checked_coin = False
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()

if self.is_auto_search_running():
checked_fleet = self.auto_search_watch_fleet(checked_fleet)
if not checked_oil or not checked_coin:
checked_oil = self.auto_search_watch_oil(checked_oil)
checked_coin = self.auto_search_watch_coin(checked_coin)
if self.handle_retirement():
self.map_offensive_auto_search()
# Map offensive ends at is_combat_loading
break
if self.handle_auto_search_map_option():
continue
if self.handle_combat_low_emotion():
self._auto_search_status_confirm = True
continue
if self.handle_story_skip():
continue
if self.handle_map_cat_attack():
continue
if self.handle_vote_popup():
continue
with self.stat.new(
genre=self.config.campaign_name, method=self.config.DropRecord_CombatRecord
) as drop:
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()

if self.is_auto_search_running():
checked_fleet = self.auto_search_watch_fleet(checked_fleet)
if not checked_oil or not checked_coin:
checked_oil = self.auto_search_watch_oil(checked_oil)
checked_coin = self.auto_search_watch_coin(checked_coin)
if self.handle_retirement():
self.map_offensive_auto_search()
# Map offensive ends at is_combat_loading
break
if self.handle_auto_search_map_option():
continue
if self.handle_combat_low_emotion():
self._auto_search_status_confirm = True
continue
if self.handle_story_skip():
continue
if self.handle_map_cat_attack():
continue
if self.handle_vote_popup():
continue

# End
if self.is_combat_loading():
break
if self.is_combat_executing():
logger.info('is_combat_executing')
break
if self.is_in_auto_search_menu() or self._handle_auto_search_menu_missing():
raise CampaignEnd
# End
if self.is_combat_loading():
break
if self.is_combat_executing():
logger.info('is_combat_executing')
break
if self.is_in_auto_search_menu() or self._handle_auto_search_menu_missing():
if drop and self.is_in_auto_search_menu():
while 1:
if self.wait_until_reward_stable() is True:
drop.handle_add(main=self)
else:
logger.info('area stable failed, this should not have happened, taking fallback screenshot')
drop.handle_add(main=self)
raise CampaignEnd

raise CampaignEnd

def auto_search_combat_execute(self, emotion_reduce, fleet_index):
"""
Expand Down Expand Up @@ -255,46 +268,57 @@ def auto_search_combat_execute(self, emotion_reduce, fleet_index):
if emotion_reduce:
self.emotion.reduce(fleet_index)
auto = self.config.Fleet_Fleet1Mode if fleet_index == 1 else self.config.Fleet_Fleet2Mode
with self.stat.new(
genre=self.config.campaign_name, method=self.config.DropRecord_CombatRecord
) as drop:
while 1:
self.device.screenshot()

while 1:
self.device.screenshot()

if self.handle_submarine_call(submarine_mode):
continue
if self.handle_combat_auto(auto):
continue
if self.handle_combat_manual(auto):
continue
if auto != 'combat_auto' and self.auto_mode_checked and self.is_combat_executing():
if self.handle_combat_weapon_release():
if self.handle_submarine_call(submarine_mode):
continue
# bunch of popup handlers
if self.handle_popup_confirm('AUTO_SEARCH_COMBAT_EXECUTE'):
continue
if self.handle_urgent_commission():
continue
if self.handle_story_skip():
continue
if self.handle_guild_popup_cancel():
continue
if self.handle_vote_popup():
continue
if self.handle_mission_popup_ack():
continue

# End
if self.is_in_auto_search_menu() or self._handle_auto_search_menu_missing():
self.device.screenshot_interval_set()
raise CampaignEnd
if self.is_combat_executing():
continue
if self.handle_get_ship():
continue
if self.appear(BATTLE_STATUS_S) or self.appear(BATTLE_STATUS_A) or self.appear(BATTLE_STATUS_B) \
or self.appear(EXP_INFO_S) or self.appear(EXP_INFO_A) or self.appear(EXP_INFO_B) \
or self.is_auto_search_running():
self.device.screenshot_interval_set()
break
if self.handle_combat_auto(auto):
continue
if self.handle_combat_manual(auto):
continue
if auto != 'combat_auto' and self.auto_mode_checked and self.is_combat_executing():
if self.handle_combat_weapon_release():
continue
# bunch of popup handlers
if self.handle_popup_confirm('AUTO_SEARCH_COMBAT_EXECUTE'):
continue
if self.handle_urgent_commission():
continue
if self.handle_story_skip():
continue
if self.handle_guild_popup_cancel():
continue
if self.handle_vote_popup():
continue
if self.handle_mission_popup_ack():
continue
# needed drop here too, since it fails proper leaving if handle_get_ship triggers (even if that was false)
# End
if self.is_in_auto_search_menu() or self._handle_auto_search_menu_missing():
self.device.screenshot_interval_set()
if drop and self.is_in_auto_search_menu():
while 1:
if self.wait_until_reward_stable() is True:
drop.handle_add(main=self)
else:
logger.info('area stable failed, this should not have happened, taking fallback screenshot')
drop.handle_add(main=self)
raise CampaignEnd

raise CampaignEnd
if self.is_combat_executing():
continue
if self.handle_get_ship():
continue
if self.appear(BATTLE_STATUS_S) or self.appear(BATTLE_STATUS_A) or self.appear(BATTLE_STATUS_B) \
or self.appear(EXP_INFO_S) or self.appear(EXP_INFO_A) or self.appear(EXP_INFO_B) \
or self.is_auto_search_running():
self.device.screenshot_interval_set()
break

def auto_search_combat_status(self, skip_first_screenshot=True):
"""
Expand Down
2 changes: 1 addition & 1 deletion module/handler/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# This file was automatically generated by dev_tools/button_extract.py.
# Don't modify it manually.

ANDROID_NO_RESPOND = Button(area={'cn': (341, 433, 391, 472), 'en': (341, 433, 391, 472), 'jp': (341, 433, 391, 472), 'tw': (341, 433, 391, 472)}, color={'cn': (217, 237, 235), 'en': (217, 237, 235), 'jp': (217, 237, 235), 'tw': (217, 237, 235)}, button={'cn': (341, 433, 391, 472), 'en': (341, 433, 391, 472), 'jp': (341, 433, 391, 472), 'tw': (341, 433, 391, 472)}, file={'cn': './assets/cn/handler/ANDROID_NO_RESPOND.png', 'en': './assets/en/handler/ANDROID_NO_RESPOND.png', 'jp': './assets/jp/handler/ANDROID_NO_RESPOND.png', 'tw': './assets/tw/handler/ANDROID_NO_RESPOND.png'})
AUTO_SEARCH_MAP_OPTION_OFF = Button(area={'cn': (1205, 549, 1275, 566), 'en': (1203, 552, 1277, 564), 'jp': (1204, 547, 1276, 568), 'tw': (1205, 546, 1275, 567)}, color={'cn': (196, 169, 169), 'en': (151, 132, 138), 'jp': (179, 153, 156), 'tw': (153, 132, 137)}, button={'cn': (1205, 549, 1275, 566), 'en': (1203, 552, 1277, 564), 'jp': (1204, 547, 1276, 568), 'tw': (1205, 546, 1275, 567)}, file={'cn': './assets/cn/handler/AUTO_SEARCH_MAP_OPTION_OFF.png', 'en': './assets/en/handler/AUTO_SEARCH_MAP_OPTION_OFF.png', 'jp': './assets/jp/handler/AUTO_SEARCH_MAP_OPTION_OFF.png', 'tw': './assets/tw/handler/AUTO_SEARCH_MAP_OPTION_OFF.png'})
AUTO_SEARCH_MAP_OPTION_ON = Button(area={'cn': (1205, 549, 1275, 566), 'en': (1203, 552, 1277, 564), 'jp': (1203, 547, 1276, 568), 'tw': (1204, 546, 1276, 567)}, color={'cn': (149, 176, 193), 'en': (113, 135, 157), 'jp': (132, 158, 177), 'tw': (110, 133, 156)}, button={'cn': (1205, 549, 1275, 566), 'en': (1203, 552, 1277, 564), 'jp': (1203, 547, 1276, 568), 'tw': (1204, 546, 1276, 567)}, file={'cn': './assets/cn/handler/AUTO_SEARCH_MAP_OPTION_ON.png', 'en': './assets/en/handler/AUTO_SEARCH_MAP_OPTION_ON.png', 'jp': './assets/jp/handler/AUTO_SEARCH_MAP_OPTION_ON.png', 'tw': './assets/tw/handler/AUTO_SEARCH_MAP_OPTION_ON.png'})
AUTO_SEARCH_MENU_CONTINUE = Button(area={'cn': (789, 610, 903, 638), 'en': (781, 612, 910, 634), 'jp': (859, 610, 973, 638), 'tw': (790, 610, 903, 638)}, color={'cn': (147, 182, 224), 'en': (159, 187, 224), 'jp': (139, 173, 218), 'tw': (148, 181, 222)}, button={'cn': (773, 598, 919, 646), 'en': (773, 598, 919, 647), 'jp': (845, 597, 990, 646), 'tw': (776, 601, 919, 645)}, file={'cn': './assets/cn/handler/AUTO_SEARCH_MENU_CONTINUE.png', 'en': './assets/en/handler/AUTO_SEARCH_MENU_CONTINUE.png', 'jp': './assets/jp/handler/AUTO_SEARCH_MENU_CONTINUE.png', 'tw': './assets/tw/handler/AUTO_SEARCH_MENU_CONTINUE.png'})
Expand Down Expand Up @@ -50,7 +51,6 @@
LOGIN_ANNOUNCE_2 = Button(area={'cn': (1193, 83, 1215, 105), 'en': (1193, 83, 1215, 105), 'jp': (1193, 83, 1215, 105), 'tw': (1193, 83, 1215, 105)}, color={'cn': (158, 170, 175), 'en': (158, 170, 175), 'jp': (158, 170, 175), 'tw': (158, 170, 175)}, button={'cn': (1171, 83, 1193, 105), 'en': (1171, 83, 1193, 105), 'jp': (1171, 83, 1193, 105), 'tw': (1171, 83, 1193, 105)}, file={'cn': './assets/cn/handler/LOGIN_ANNOUNCE_2.png', 'en': './assets/en/handler/LOGIN_ANNOUNCE_2.png', 'jp': './assets/jp/handler/LOGIN_ANNOUNCE_2.png', 'tw': './assets/tw/handler/LOGIN_ANNOUNCE_2.png'})
LOGIN_CHECK = Button(area={'cn': (1214, 653, 1268, 709), 'en': (1214, 653, 1268, 709), 'jp': (1214, 653, 1268, 709), 'tw': (1214, 653, 1268, 709)}, color={'cn': (203, 215, 230), 'en': (203, 215, 230), 'jp': (203, 215, 230), 'tw': (203, 215, 230)}, button={'cn': (416, 294, 534, 400), 'en': (1078, 591, 1168, 635), 'jp': (416, 294, 534, 400), 'tw': (416, 294, 534, 400)}, file={'cn': './assets/cn/handler/LOGIN_CHECK.png', 'en': './assets/en/handler/LOGIN_CHECK.png', 'jp': './assets/jp/handler/LOGIN_CHECK.png', 'tw': './assets/tw/handler/LOGIN_CHECK.png'})
LOGIN_GAME_UPDATE = Button(area={'cn': (700, 471, 873, 529), 'en': (726, 474, 850, 519), 'jp': (704, 475, 867, 525), 'tw': (706, 477, 866, 528)}, color={'cn': (238, 170, 78), 'en': (241, 169, 73), 'jp': (234, 167, 77), 'tw': (235, 169, 80)}, button={'cn': (700, 471, 873, 529), 'en': (726, 474, 850, 519), 'jp': (704, 475, 867, 525), 'tw': (706, 477, 866, 528)}, file={'cn': './assets/cn/handler/LOGIN_GAME_UPDATE.png', 'en': './assets/en/handler/LOGIN_GAME_UPDATE.png', 'jp': './assets/jp/handler/LOGIN_GAME_UPDATE.png', 'tw': './assets/tw/handler/LOGIN_GAME_UPDATE.png'})
ANDROID_NO_RESPOND = Button(area={'cn': (341, 433, 391, 472), 'en': (341, 433, 391, 472), 'jp': (341, 433, 391, 472), 'tw': (341, 433, 391, 472)}, color={'cn': (217, 237, 235), 'en': (217, 237, 235), 'jp': (217, 237, 235), 'tw': (217, 237, 235)}, button={'cn': (341, 433, 391, 472), 'en': (341, 433, 391, 472), 'jp': (341, 433, 391, 472), 'tw': (341, 433, 391, 472)}, file={'cn': './assets/cn/handler/ANDROID_NO_RESPOND.png', 'en': './assets/en/handler/ANDROID_NO_RESPOND.png', 'jp': './assets/jp/handler/ANDROID_NO_RESPOND.png', 'tw': './assets/tw/handler/ANDROID_NO_RESPOND.png'})
LOGIN_RETURN_INFO = Button(area={'cn': (960, 123, 1158, 333), 'en': (960, 123, 1158, 333), 'jp': (960, 123, 1158, 333), 'tw': (960, 123, 1158, 333)}, color={'cn': (170, 185, 166), 'en': (170, 185, 166), 'jp': (170, 185, 166), 'tw': (170, 185, 166)}, button={'cn': (960, 123, 1158, 333), 'en': (960, 123, 1158, 333), 'jp': (960, 123, 1158, 333), 'tw': (960, 123, 1158, 333)}, file={'cn': './assets/cn/handler/LOGIN_RETURN_INFO.png', 'en': './assets/en/handler/LOGIN_RETURN_INFO.png', 'jp': './assets/jp/handler/LOGIN_RETURN_INFO.png', 'tw': './assets/tw/handler/LOGIN_RETURN_INFO.png'})
LOGIN_RETURN_SIGN = Button(area={'cn': (1, 7, 104, 47), 'en': (1, 7, 118, 39), 'jp': (1, 7, 104, 47), 'tw': (1, 7, 104, 47)}, color={'cn': (158, 214, 229), 'en': (176, 223, 236), 'jp': (158, 214, 229), 'tw': (158, 214, 229)}, button={'cn': (1, 7, 104, 47), 'en': (1, 7, 118, 39), 'jp': (1, 7, 104, 47), 'tw': (1, 7, 104, 47)}, file={'cn': './assets/cn/handler/LOGIN_RETURN_SIGN.png', 'en': './assets/en/handler/LOGIN_RETURN_SIGN.png', 'jp': './assets/jp/handler/LOGIN_RETURN_SIGN.png', 'tw': './assets/tw/handler/LOGIN_RETURN_SIGN.png'})
MAINTENANCE_ANNOUNCE = Button(area={'cn': (923, 141, 990, 186), 'en': (923, 141, 990, 186), 'jp': (923, 141, 990, 186), 'tw': (923, 141, 990, 186)}, color={'cn': (207, 95, 91), 'en': (207, 95, 91), 'jp': (207, 95, 91), 'tw': (207, 95, 91)}, button={'cn': (923, 141, 990, 186), 'en': (923, 141, 990, 186), 'jp': (923, 141, 990, 186), 'tw': (923, 141, 990, 186)}, file={'cn': './assets/cn/handler/MAINTENANCE_ANNOUNCE.png', 'en': './assets/en/handler/MAINTENANCE_ANNOUNCE.png', 'jp': './assets/jp/handler/MAINTENANCE_ANNOUNCE.png', 'tw': './assets/tw/handler/MAINTENANCE_ANNOUNCE.png'})
Expand Down
Loading