Opt: Raise error when user running a hard mode but haven't prepared the fleets
BIN
assets/cn/map/FLEET_1_HARD_SATIESFIED.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
assets/cn/map/FLEET_1_RECOMMEND.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
assets/cn/map/FLEET_2_HARD_SATIESFIED.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
assets/cn/map/FLEET_2_RECOMMEND.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
assets/cn/map/SUBMARINE_HARD_SATIESFIED.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
assets/cn/map/SUBMARINE_RECOMMEND.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
assets/en/map/FLEET_1_HARD_SATIESFIED.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
assets/en/map/FLEET_2_HARD_SATIESFIED.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
assets/en/map/SUBMARINE_HARD_SATIESFIED.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
assets/jp/map/FLEET_1_HARD_SATIESFIED.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
assets/jp/map/FLEET_2_HARD_SATIESFIED.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
assets/jp/map/SUBMARINE_HARD_SATIESFIED.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
assets/tw/map/FLEET_1_HARD_SATIESFIED.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
assets/tw/map/FLEET_2_HARD_SATIESFIED.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
assets/tw/map/SUBMARINE_HARD_SATIESFIED.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
@ -7,11 +7,15 @@ from module.base.template import Template
|
||||
FLEET_1_BAR = Button(area={'cn': (1015, 244, 1186, 447), 'en': (998, 247, 1169, 492), 'jp': (1015, 244, 1186, 489), 'tw': (1015, 244, 1186, 489)}, color={'cn': (180, 170, 150), 'en': (177, 169, 155), 'jp': (177, 169, 155), 'tw': (176, 168, 154)}, button={'cn': (1015, 244, 1186, 447), 'en': (998, 247, 1169, 492), 'jp': (1015, 244, 1186, 489), 'tw': (1015, 244, 1186, 489)}, file={'cn': './assets/cn/map/FLEET_1_BAR.png', 'en': './assets/en/map/FLEET_1_BAR.png', 'jp': './assets/jp/map/FLEET_1_BAR.png', 'tw': './assets/tw/map/FLEET_1_BAR.png'})
|
||||
FLEET_1_CHOOSE = Button(area={'cn': (1026, 167, 1088, 224), 'en': (1008, 170, 1071, 227), 'jp': (1024, 165, 1090, 226), 'tw': (1024, 165, 1090, 226)}, color={'cn': (209, 164, 104), 'en': (198, 149, 84), 'jp': (199, 158, 103), 'tw': (207, 164, 105)}, button={'cn': (1026, 167, 1088, 224), 'en': (1008, 170, 1071, 227), 'jp': (1024, 165, 1090, 226), 'tw': (1024, 165, 1090, 226)}, file={'cn': './assets/cn/map/FLEET_1_CHOOSE.png', 'en': './assets/en/map/FLEET_1_CHOOSE.png', 'jp': './assets/jp/map/FLEET_1_CHOOSE.png', 'tw': './assets/tw/map/FLEET_1_CHOOSE.png'})
|
||||
FLEET_1_CLEAR = Button(area={'cn': (1109, 167, 1170, 224), 'en': (1090, 170, 1153, 227), 'jp': (1108, 165, 1169, 226), 'tw': (1106, 165, 1172, 226)}, color={'cn': (155, 154, 155), 'en': (138, 140, 142), 'jp': (150, 151, 153), 'tw': (154, 154, 156)}, button={'cn': (1109, 167, 1170, 224), 'en': (1090, 170, 1153, 227), 'jp': (1108, 165, 1169, 226), 'tw': (1106, 165, 1172, 226)}, file={'cn': './assets/cn/map/FLEET_1_CLEAR.png', 'en': './assets/en/map/FLEET_1_CLEAR.png', 'jp': './assets/jp/map/FLEET_1_CLEAR.png', 'tw': './assets/tw/map/FLEET_1_CLEAR.png'})
|
||||
FLEET_1_HARD_SATIESFIED = Button(area={'cn': (208, 134, 227, 267), 'en': (208, 134, 227, 267), 'jp': (208, 134, 227, 267), 'tw': (208, 134, 227, 267)}, color={'cn': (87, 67, 63), 'en': (87, 67, 63), 'jp': (87, 67, 63), 'tw': (87, 67, 63)}, button={'cn': (208, 134, 227, 267), 'en': (208, 134, 227, 267), 'jp': (208, 134, 227, 267), 'tw': (208, 134, 227, 267)}, file={'cn': './assets/cn/map/FLEET_1_HARD_SATIESFIED.png', 'en': './assets/en/map/FLEET_1_HARD_SATIESFIED.png', 'jp': './assets/jp/map/FLEET_1_HARD_SATIESFIED.png', 'tw': './assets/tw/map/FLEET_1_HARD_SATIESFIED.png'})
|
||||
FLEET_1_IN_USE = Button(area={'cn': (389, 158, 472, 241), 'en': (389, 158, 472, 241), 'jp': (389, 158, 472, 241), 'tw': (389, 158, 472, 241)}, color={'cn': (147, 161, 160), 'en': (147, 161, 160), 'jp': (147, 161, 160), 'tw': (147, 161, 160)}, button={'cn': (389, 158, 472, 241), 'en': (389, 158, 472, 241), 'jp': (389, 158, 472, 241), 'tw': (389, 158, 472, 241)}, file={'cn': './assets/cn/map/FLEET_1_IN_USE.png', 'en': './assets/en/map/FLEET_1_IN_USE.png', 'jp': './assets/jp/map/FLEET_1_IN_USE.png', 'tw': './assets/tw/map/FLEET_1_IN_USE.png'})
|
||||
FLEET_1_RECOMMEND = Button(area={'cn': (1031, 182, 1076, 202), 'en': (1031, 182, 1076, 202), 'jp': (1031, 182, 1076, 202), 'tw': (1031, 182, 1076, 202)}, color={'cn': (243, 221, 177), 'en': (243, 221, 177), 'jp': (243, 221, 177), 'tw': (243, 221, 177)}, button={'cn': (1031, 182, 1076, 202), 'en': (1031, 182, 1076, 202), 'jp': (1031, 182, 1076, 202), 'tw': (1031, 182, 1076, 202)}, file={'cn': './assets/cn/map/FLEET_1_RECOMMEND.png', 'en': './assets/cn/map/FLEET_1_RECOMMEND.png', 'jp': './assets/cn/map/FLEET_1_RECOMMEND.png', 'tw': './assets/cn/map/FLEET_1_RECOMMEND.png'})
|
||||
FLEET_2_BAR = Button(area={'cn': (1015, 377, 1186, 622), 'en': (998, 380, 1169, 625), 'jp': (1015, 377, 1186, 622), 'tw': (1015, 377, 1186, 622)}, color={'cn': (178, 169, 154), 'en': (179, 170, 154), 'jp': (177, 169, 154), 'tw': (177, 168, 153)}, button={'cn': (1015, 377, 1186, 622), 'en': (998, 380, 1169, 625), 'jp': (1015, 377, 1186, 622), 'tw': (1015, 377, 1186, 622)}, file={'cn': './assets/cn/map/FLEET_2_BAR.png', 'en': './assets/en/map/FLEET_2_BAR.png', 'jp': './assets/jp/map/FLEET_2_BAR.png', 'tw': './assets/tw/map/FLEET_2_BAR.png'})
|
||||
FLEET_2_CHOOSE = Button(area={'cn': (1026, 300, 1088, 357), 'en': (1008, 303, 1071, 360), 'jp': (1024, 298, 1090, 359), 'tw': (1024, 298, 1090, 359)}, color={'cn': (208, 164, 103), 'en': (197, 148, 83), 'jp': (198, 158, 103), 'tw': (206, 163, 105)}, button={'cn': (1026, 300, 1088, 357), 'en': (1008, 303, 1071, 360), 'jp': (1024, 298, 1090, 359), 'tw': (1024, 298, 1090, 359)}, file={'cn': './assets/cn/map/FLEET_2_CHOOSE.png', 'en': './assets/en/map/FLEET_2_CHOOSE.png', 'jp': './assets/jp/map/FLEET_2_CHOOSE.png', 'tw': './assets/tw/map/FLEET_2_CHOOSE.png'})
|
||||
FLEET_2_CLEAR = Button(area={'cn': (1108, 300, 1170, 357), 'en': (1090, 303, 1153, 360), 'jp': (1108, 298, 1169, 359), 'tw': (1106, 298, 1172, 359)}, color={'cn': (153, 153, 154), 'en': (138, 139, 142), 'jp': (150, 151, 153), 'tw': (153, 154, 156)}, button={'cn': (1108, 300, 1170, 357), 'en': (1090, 303, 1153, 360), 'jp': (1108, 298, 1169, 359), 'tw': (1106, 298, 1172, 359)}, file={'cn': './assets/cn/map/FLEET_2_CLEAR.png', 'en': './assets/en/map/FLEET_2_CLEAR.png', 'jp': './assets/jp/map/FLEET_2_CLEAR.png', 'tw': './assets/tw/map/FLEET_2_CLEAR.png'})
|
||||
FLEET_2_HARD_SATIESFIED = Button(area={'cn': (208, 267, 227, 401), 'en': (208, 267, 227, 401), 'jp': (208, 267, 227, 401), 'tw': (208, 267, 227, 401)}, color={'cn': (93, 73, 64), 'en': (93, 73, 64), 'jp': (93, 73, 64), 'tw': (93, 73, 64)}, button={'cn': (208, 267, 227, 401), 'en': (208, 267, 227, 401), 'jp': (208, 267, 227, 401), 'tw': (208, 267, 227, 401)}, file={'cn': './assets/cn/map/FLEET_2_HARD_SATIESFIED.png', 'en': './assets/en/map/FLEET_2_HARD_SATIESFIED.png', 'jp': './assets/jp/map/FLEET_2_HARD_SATIESFIED.png', 'tw': './assets/tw/map/FLEET_2_HARD_SATIESFIED.png'})
|
||||
FLEET_2_IN_USE = Button(area={'cn': (389, 351, 472, 385), 'en': (389, 351, 472, 385), 'jp': (389, 351, 472, 385), 'tw': (389, 351, 472, 385)}, color={'cn': (125, 130, 124), 'en': (125, 130, 124), 'jp': (125, 130, 124), 'tw': (125, 130, 124)}, button={'cn': (389, 351, 472, 385), 'en': (389, 351, 472, 385), 'jp': (389, 351, 472, 385), 'tw': (389, 351, 472, 385)}, file={'cn': './assets/cn/map/FLEET_2_IN_USE.png', 'en': './assets/en/map/FLEET_2_IN_USE.png', 'jp': './assets/jp/map/FLEET_2_IN_USE.png', 'tw': './assets/tw/map/FLEET_2_IN_USE.png'})
|
||||
FLEET_2_RECOMMEND = Button(area={'cn': (1031, 315, 1076, 335), 'en': (1031, 315, 1076, 335), 'jp': (1031, 315, 1076, 335), 'tw': (1031, 315, 1076, 335)}, color={'cn': (243, 221, 177), 'en': (243, 221, 177), 'jp': (243, 221, 177), 'tw': (243, 221, 177)}, button={'cn': (1031, 315, 1076, 335), 'en': (1031, 315, 1076, 335), 'jp': (1031, 315, 1076, 335), 'tw': (1031, 315, 1076, 335)}, file={'cn': './assets/cn/map/FLEET_2_RECOMMEND.png', 'en': './assets/cn/map/FLEET_2_RECOMMEND.png', 'jp': './assets/cn/map/FLEET_2_RECOMMEND.png', 'tw': './assets/cn/map/FLEET_2_RECOMMEND.png'})
|
||||
FLEET_NUM_1 = Button(area={'cn': (213, 76, 224, 101), 'en': (213, 76, 224, 101), 'jp': (213, 76, 224, 101), 'tw': (213, 76, 224, 101)}, color={'cn': (51, 143, 186), 'en': (51, 143, 186), 'jp': (51, 143, 186), 'tw': (51, 143, 186)}, button={'cn': (213, 76, 224, 101), 'en': (213, 76, 224, 101), 'jp': (213, 76, 224, 101), 'tw': (213, 76, 224, 101)}, file={'cn': './assets/cn/map/FLEET_NUM_1.png', 'en': './assets/en/map/FLEET_NUM_1.png', 'jp': './assets/jp/map/FLEET_NUM_1.png', 'tw': './assets/tw/map/FLEET_NUM_1.png'})
|
||||
FLEET_NUM_2 = Button(area={'cn': (212, 75, 226, 101), 'en': (212, 75, 226, 101), 'jp': (212, 75, 226, 101), 'tw': (212, 75, 226, 101)}, color={'cn': (52, 150, 194), 'en': (52, 150, 194), 'jp': (52, 150, 194), 'tw': (52, 150, 194)}, button={'cn': (212, 75, 226, 101), 'en': (212, 75, 226, 101), 'jp': (212, 75, 226, 101), 'tw': (212, 75, 226, 101)}, file={'cn': './assets/cn/map/FLEET_NUM_2.png', 'en': './assets/en/map/FLEET_NUM_2.png', 'jp': './assets/jp/map/FLEET_NUM_2.png', 'tw': './assets/tw/map/FLEET_NUM_2.png'})
|
||||
FLEET_PREPARATION = Button(area={'cn': (965, 578, 1162, 637), 'en': (969, 576, 1160, 637), 'jp': (983, 583, 1140, 632), 'tw': (964, 577, 1163, 638)}, color={'cn': (236, 186, 116), 'en': (233, 175, 90), 'jp': (232, 181, 102), 'tw': (235, 186, 114)}, button={'cn': (965, 578, 1162, 637), 'en': (969, 576, 1160, 637), 'jp': (983, 583, 1140, 632), 'tw': (964, 577, 1163, 638)}, file={'cn': './assets/cn/map/FLEET_PREPARATION.png', 'en': './assets/en/map/FLEET_PREPARATION.png', 'jp': './assets/jp/map/FLEET_PREPARATION.png', 'tw': './assets/tw/map/FLEET_PREPARATION.png'})
|
||||
@ -24,6 +28,8 @@ MAP_PREPARATION_CANCEL = Button(area={'cn': (234, 12, 278, 47), 'en': (234, 12,
|
||||
SUBMARINE_BAR = Button(area={'cn': (1015, 525, 1186, 602), 'en': (998, 528, 1169, 605), 'jp': (1015, 524, 1186, 602), 'tw': (1015, 525, 1186, 602)}, color={'cn': (193, 178, 146), 'en': (192, 177, 145), 'jp': (193, 177, 145), 'tw': (192, 177, 146)}, button={'cn': (1015, 525, 1186, 602), 'en': (998, 528, 1169, 605), 'jp': (1015, 524, 1186, 602), 'tw': (1015, 525, 1186, 602)}, file={'cn': './assets/cn/map/SUBMARINE_BAR.png', 'en': './assets/en/map/SUBMARINE_BAR.png', 'jp': './assets/jp/map/SUBMARINE_BAR.png', 'tw': './assets/tw/map/SUBMARINE_BAR.png'})
|
||||
SUBMARINE_CHOOSE = Button(area={'cn': (1026, 448, 1088, 505), 'en': (1008, 451, 1071, 508), 'jp': (1024, 446, 1090, 506), 'tw': (1024, 446, 1090, 506)}, color={'cn': (200, 157, 99), 'en': (197, 148, 83), 'jp': (198, 156, 100), 'tw': (206, 163, 103)}, button={'cn': (1026, 448, 1088, 505), 'en': (1008, 451, 1071, 508), 'jp': (1024, 446, 1090, 506), 'tw': (1024, 446, 1090, 506)}, file={'cn': './assets/cn/map/SUBMARINE_CHOOSE.png', 'en': './assets/en/map/SUBMARINE_CHOOSE.png', 'jp': './assets/jp/map/SUBMARINE_CHOOSE.png', 'tw': './assets/tw/map/SUBMARINE_CHOOSE.png'})
|
||||
SUBMARINE_CLEAR = Button(area={'cn': (1109, 448, 1170, 505), 'en': (1091, 451, 1153, 508), 'jp': (1108, 446, 1169, 506), 'tw': (1106, 446, 1172, 506)}, color={'cn': (153, 153, 154), 'en': (139, 140, 142), 'jp': (148, 149, 151), 'tw': (152, 153, 155)}, button={'cn': (1109, 448, 1170, 505), 'en': (1091, 451, 1153, 508), 'jp': (1108, 446, 1169, 506), 'tw': (1106, 446, 1172, 506)}, file={'cn': './assets/cn/map/SUBMARINE_CLEAR.png', 'en': './assets/en/map/SUBMARINE_CLEAR.png', 'jp': './assets/jp/map/SUBMARINE_CLEAR.png', 'tw': './assets/tw/map/SUBMARINE_CLEAR.png'})
|
||||
SUBMARINE_HARD_SATIESFIED = Button(area={'cn': (208, 414, 227, 547), 'en': (208, 414, 227, 547), 'jp': (208, 414, 227, 547), 'tw': (208, 414, 227, 547)}, color={'cn': (39, 62, 98), 'en': (39, 62, 98), 'jp': (39, 62, 98), 'tw': (39, 62, 98)}, button={'cn': (208, 414, 227, 547), 'en': (208, 414, 227, 547), 'jp': (208, 414, 227, 547), 'tw': (208, 414, 227, 547)}, file={'cn': './assets/cn/map/SUBMARINE_HARD_SATIESFIED.png', 'en': './assets/en/map/SUBMARINE_HARD_SATIESFIED.png', 'jp': './assets/jp/map/SUBMARINE_HARD_SATIESFIED.png', 'tw': './assets/tw/map/SUBMARINE_HARD_SATIESFIED.png'})
|
||||
SUBMARINE_IN_USE = Button(area={'cn': (453, 438, 538, 523), 'en': (453, 438, 538, 523), 'jp': (453, 438, 538, 523), 'tw': (453, 438, 538, 523)}, color={'cn': (118, 114, 124), 'en': (118, 114, 124), 'jp': (118, 114, 124), 'tw': (118, 114, 124)}, button={'cn': (453, 438, 538, 523), 'en': (453, 438, 538, 523), 'jp': (453, 438, 538, 523), 'tw': (453, 438, 538, 523)}, file={'cn': './assets/cn/map/SUBMARINE_IN_USE.png', 'en': './assets/en/map/SUBMARINE_IN_USE.png', 'jp': './assets/jp/map/SUBMARINE_IN_USE.png', 'tw': './assets/tw/map/SUBMARINE_IN_USE.png'})
|
||||
SUBMARINE_RECOMMEND = Button(area={'cn': (1035, 462, 1080, 483), 'en': (1035, 462, 1080, 483), 'jp': (1035, 462, 1080, 483), 'tw': (1035, 462, 1080, 483)}, color={'cn': (242, 219, 174), 'en': (242, 219, 174), 'jp': (242, 219, 174), 'tw': (242, 219, 174)}, button={'cn': (1035, 462, 1080, 483), 'en': (1035, 462, 1080, 483), 'jp': (1035, 462, 1080, 483), 'tw': (1035, 462, 1080, 483)}, file={'cn': './assets/cn/map/SUBMARINE_RECOMMEND.png', 'en': './assets/cn/map/SUBMARINE_RECOMMEND.png', 'jp': './assets/cn/map/SUBMARINE_RECOMMEND.png', 'tw': './assets/cn/map/SUBMARINE_RECOMMEND.png'})
|
||||
SWITCH_OVER = Button(area={'cn': (947, 654, 1118, 706), 'en': (945, 647, 1119, 702), 'jp': (946, 653, 1119, 707), 'tw': (947, 654, 1118, 706)}, color={'cn': (144, 158, 198), 'en': (139, 154, 194), 'jp': (142, 156, 195), 'tw': (144, 158, 198)}, button={'cn': (947, 654, 1118, 706), 'en': (945, 647, 1119, 702), 'jp': (946, 653, 1119, 707), 'tw': (947, 654, 1118, 706)}, file={'cn': './assets/cn/map/SWITCH_OVER.png', 'en': './assets/en/map/SWITCH_OVER.png', 'jp': './assets/jp/map/SWITCH_OVER.png', 'tw': './assets/tw/map/SWITCH_OVER.png'})
|
||||
WITHDRAW = Button(area={'cn': (749, 654, 921, 707), 'en': (748, 652, 922, 702), 'jp': (748, 653, 921, 707), 'tw': (749, 654, 921, 707)}, color={'cn': (213, 124, 124), 'en': (211, 124, 124), 'jp': (210, 122, 122), 'tw': (213, 124, 124)}, button={'cn': (749, 654, 921, 707), 'en': (748, 652, 922, 702), 'jp': (748, 653, 921, 707), 'tw': (749, 654, 921, 707)}, file={'cn': './assets/cn/map/WITHDRAW.png', 'en': './assets/en/map/WITHDRAW.png', 'jp': './assets/jp/map/WITHDRAW.png', 'tw': './assets/tw/map/WITHDRAW.png'})
|
||||
|
@ -1,10 +1,11 @@
|
||||
import numpy as np
|
||||
from scipy import signal
|
||||
|
||||
from module.base.base import ModuleBase
|
||||
from module.base.button import Button
|
||||
from module.base.timer import Timer
|
||||
from module.base.utils import *
|
||||
from module.exception import RequestHumanTakeover
|
||||
from module.handler.info_handler import InfoHandler
|
||||
from module.logger import logger
|
||||
from module.map.assets import *
|
||||
|
||||
@ -15,19 +16,23 @@ class FleetOperator:
|
||||
FLEET_BAR_ACTIVE_STD = 45 # Active: 67, inactive: 12.
|
||||
FLEET_IN_USE_STD = 27 # In use 52, not in use (3, 6).
|
||||
|
||||
def __init__(self, choose, bar, clear, in_use, main):
|
||||
def __init__(self, choose, recommend, bar, clear, in_use, hard_satisfied, main):
|
||||
"""
|
||||
Args:
|
||||
choose (Button): Button to activate or deactivate dropdown menu.
|
||||
recommend (Button): Button to recommend ships.
|
||||
bar (Button): Dropdown menu for fleet selection。
|
||||
clear (Button): Button to clear current fleet.
|
||||
in_use (Button): Button to detect if it's using current fleet.
|
||||
main (ModuleBase): Alas module.
|
||||
hard_satisfied (Button): Area to detect if fleet satiesfies hard restrictions.
|
||||
main (InfoHandler): Alas module.
|
||||
"""
|
||||
self._choose = choose
|
||||
self._recommend = recommend
|
||||
self._bar = bar
|
||||
self._clear = clear
|
||||
self._in_use = in_use
|
||||
self._hard_satisfied = hard_satisfied
|
||||
self.main = main
|
||||
|
||||
def __str__(self):
|
||||
@ -74,7 +79,43 @@ class FleetOperator:
|
||||
Returns:
|
||||
bool: If current fleet is allow to be chosen.
|
||||
"""
|
||||
return self.main.appear(self._choose)
|
||||
return self.main.appear(self._choose, threshold=30)
|
||||
|
||||
def has_recommend(self):
|
||||
"""
|
||||
Returns:
|
||||
bool: Whether to have a recommend. If so, this stage is a hard campaign.
|
||||
"""
|
||||
return self.main.appear(self._recommend, offset=(20, 20))
|
||||
|
||||
def is_hard_satisfied(self):
|
||||
"""
|
||||
Detect how many light orange lines are there.
|
||||
Having lines means current map has stat limits and user has satisfied at least one of them,
|
||||
so this is a hard map.
|
||||
|
||||
Returns:
|
||||
bool: If current fleet satisfies hard restrictions.
|
||||
Or None if this is not a hard mode
|
||||
"""
|
||||
if not self.has_recommend():
|
||||
return None
|
||||
|
||||
area = self._hard_satisfied.area
|
||||
image = color_similarity_2d(self.main.image_crop(area), color=(249, 199, 0))
|
||||
height = np.max(image, axis=1)
|
||||
parameters = {'height': 180, 'distance': 5}
|
||||
peaks, _ = signal.find_peaks(height, **parameters)
|
||||
lines = len(peaks)
|
||||
# logger.attr('Light_orange_line', lines)
|
||||
return lines > 0
|
||||
|
||||
def raise_hard_not_satisfied(self):
|
||||
if self.is_hard_satisfied() is False:
|
||||
stage = self.main.config.Campaign_Name
|
||||
logger.critical(f'Stage "{stage}" is a hard mode, '
|
||||
f'please prepare your fleet "{str(self)}" in game before running Alas')
|
||||
raise RequestHumanTakeover
|
||||
|
||||
def clear(self, skip_first_screenshot=True):
|
||||
"""
|
||||
@ -92,6 +133,9 @@ class FleetOperator:
|
||||
if not self.in_use():
|
||||
break
|
||||
|
||||
# Popups when clearing hard fleets
|
||||
if self.main.handle_popup_confirm(str(self._clear)):
|
||||
continue
|
||||
# Click
|
||||
if click_timer.reached():
|
||||
main.device.click(self._clear)
|
||||
@ -213,28 +257,10 @@ class FleetOperator:
|
||||
self.click(index)
|
||||
|
||||
|
||||
class FleetPreparation(ModuleBase):
|
||||
class FleetPreparation(InfoHandler):
|
||||
map_fleet_checked = False
|
||||
map_is_hard_mode = False
|
||||
|
||||
def get_map_is_hard_mode(self):
|
||||
"""
|
||||
Detect how many light orange lines are there.
|
||||
Having lines means current map has stat limits and user has satisfied at least one of them,
|
||||
so this is a hard map.
|
||||
|
||||
Returns:
|
||||
bool:
|
||||
"""
|
||||
area = (208, 130, 226, 551)
|
||||
image = color_similarity_2d(self.image_crop(area), color=(249, 199, 0))
|
||||
height = np.max(image, axis=1)
|
||||
parameters = {'height': 180, 'distance': 5}
|
||||
peaks, _ = signal.find_peaks(height, **parameters)
|
||||
lines = len(peaks)
|
||||
logger.attr('Light_orange_line', lines)
|
||||
return lines > 0
|
||||
|
||||
def fleet_preparation(self):
|
||||
"""Change fleets.
|
||||
|
||||
@ -245,18 +271,39 @@ class FleetPreparation(ModuleBase):
|
||||
if self.map_fleet_checked:
|
||||
return False
|
||||
|
||||
self.map_is_hard_mode = self.get_map_is_hard_mode()
|
||||
fleet_1 = FleetOperator(
|
||||
choose=FLEET_1_CHOOSE, recommend=FLEET_1_RECOMMEND, bar=FLEET_1_BAR, clear=FLEET_1_CLEAR,
|
||||
in_use=FLEET_1_IN_USE, hard_satisfied=FLEET_1_HARD_SATIESFIED, main=self)
|
||||
fleet_2 = FleetOperator(
|
||||
choose=FLEET_2_CHOOSE, recommend=FLEET_2_RECOMMEND, bar=FLEET_2_BAR, clear=FLEET_2_CLEAR,
|
||||
in_use=FLEET_2_IN_USE, hard_satisfied=FLEET_2_HARD_SATIESFIED, main=self)
|
||||
submarine = FleetOperator(
|
||||
choose=SUBMARINE_CHOOSE, recommend=SUBMARINE_RECOMMEND, bar=SUBMARINE_BAR, clear=SUBMARINE_CLEAR,
|
||||
in_use=SUBMARINE_IN_USE, hard_satisfied=FLEET_1_HARD_SATIESFIED, main=self)
|
||||
|
||||
# Check if ship is prepared in hard mode
|
||||
h1, h2, h3 = fleet_1.is_hard_satisfied(), fleet_2.is_hard_satisfied(), submarine.is_hard_satisfied()
|
||||
logger.info(f'Hard satisfied: Fleet_1: {h1}, Fleet_2: {h2}, Submarine: {h3}')
|
||||
if self.config.SERVER in ['cn']:
|
||||
if self.config.Fleet_Fleet1:
|
||||
fleet_1.raise_hard_not_satisfied()
|
||||
if self.config.Fleet_Fleet2:
|
||||
fleet_2.raise_hard_not_satisfied()
|
||||
if self.config.Submarine_Fleet:
|
||||
submarine.raise_hard_not_satisfied()
|
||||
|
||||
# Skip fleet preparation in hard mode
|
||||
self.map_is_hard_mode = h1 or h2 or h3
|
||||
if self.map_is_hard_mode:
|
||||
logger.info('Hard Campaign. No fleet preparation')
|
||||
# Clear submarine if user did not set a submarine fleet
|
||||
if submarine.allow():
|
||||
if self.config.Submarine_Fleet:
|
||||
pass
|
||||
else:
|
||||
submarine.clear()
|
||||
return False
|
||||
|
||||
fleet_1 = FleetOperator(
|
||||
choose=FLEET_1_CHOOSE, bar=FLEET_1_BAR, clear=FLEET_1_CLEAR, in_use=FLEET_1_IN_USE, main=self)
|
||||
fleet_2 = FleetOperator(
|
||||
choose=FLEET_2_CHOOSE, bar=FLEET_2_BAR, clear=FLEET_2_CLEAR, in_use=FLEET_2_IN_USE, main=self)
|
||||
submarine = FleetOperator(
|
||||
choose=SUBMARINE_CHOOSE, bar=SUBMARINE_BAR, clear=SUBMARINE_CLEAR, in_use=SUBMARINE_IN_USE, main=self)
|
||||
|
||||
# Submarine.
|
||||
if submarine.allow():
|
||||
if self.config.Submarine_Fleet:
|
||||
|