2020-04-09 13:22:01 +00:00
|
|
|
from module.base.base import ModuleBase
|
|
|
|
from module.base.switch import Switch
|
2020-04-18 16:49:33 +00:00
|
|
|
from module.base.utils import color_bar_percentage
|
2020-04-09 13:22:01 +00:00
|
|
|
from module.handler.assets import *
|
|
|
|
from module.logger import logger
|
|
|
|
|
|
|
|
fast_forward = Switch('Fast_Forward')
|
|
|
|
fast_forward.add_status('on', check_button=FAST_FORWARD_ON)
|
|
|
|
fast_forward.add_status('off', check_button=FAST_FORWARD_OFF)
|
|
|
|
fleet_lock = Switch('Fleet_Lock')
|
|
|
|
fleet_lock.add_status('on', check_button=FLEET_LOCKED)
|
|
|
|
fleet_lock.add_status('off', check_button=FLEET_UNLOCKED)
|
|
|
|
|
|
|
|
|
|
|
|
class FastForwardHandler(ModuleBase):
|
2020-04-24 07:26:11 +00:00
|
|
|
map_clear_record = None
|
|
|
|
|
2020-04-09 13:22:01 +00:00
|
|
|
def handle_fast_forward(self):
|
2020-04-14 09:32:26 +00:00
|
|
|
if not self.appear(MAP_STAR_1) or not self.appear(MAP_STAR_2) or not self.appear(MAP_STAR_3):
|
2020-04-24 09:57:40 +00:00
|
|
|
self.config.ENABLE_FAST_FORWARD = False
|
2020-04-14 09:32:26 +00:00
|
|
|
logger.info('Campaign is not 3-star cleared.')
|
|
|
|
return False
|
|
|
|
if not self.appear(MAP_GREEN):
|
2020-04-24 09:57:40 +00:00
|
|
|
self.config.ENABLE_FAST_FORWARD = False
|
2020-04-14 09:32:26 +00:00
|
|
|
logger.info('Campaign is not green sea.')
|
|
|
|
return False
|
|
|
|
|
2020-04-09 13:22:01 +00:00
|
|
|
if not fast_forward.appear(main=self):
|
|
|
|
self.config.ENABLE_FAST_FORWARD = False
|
|
|
|
logger.info('No fast forward mode.')
|
|
|
|
return False
|
|
|
|
|
2020-04-22 17:58:35 +00:00
|
|
|
logger.info('Set fast forward.')
|
|
|
|
self.config.MAP_HAS_FLEET_STEP = False
|
2020-04-24 07:26:11 +00:00
|
|
|
self.config.MAP_HAS_MOVABLE_ENEMY = False
|
2020-04-09 13:22:01 +00:00
|
|
|
if self.config.ENABLE_FAST_FORWARD:
|
|
|
|
self.config.MAP_HAS_AMBUSH = False
|
|
|
|
status = 'on'
|
|
|
|
else:
|
|
|
|
# When disable fast forward, MAP_HAS_AMBUSH depends on map settings.
|
|
|
|
# self.config.MAP_HAS_AMBUSH = True
|
|
|
|
status = 'off'
|
|
|
|
changed = fast_forward.set(status=status, main=self)
|
|
|
|
return changed
|
|
|
|
|
|
|
|
def handle_map_fleet_lock(self):
|
|
|
|
if not fleet_lock.appear(main=self):
|
|
|
|
logger.info('No fleet lock option.')
|
|
|
|
return False
|
2020-04-10 10:39:47 +00:00
|
|
|
|
2020-04-09 13:22:01 +00:00
|
|
|
logger.info('fleet_lock')
|
2020-04-10 10:39:47 +00:00
|
|
|
self.config.MAP_HAS_AMBUSH = False
|
2020-04-09 13:22:01 +00:00
|
|
|
status = 'on' if self.config.ENABLE_MAP_FLEET_LOCK else 'off'
|
|
|
|
changed = fleet_lock.set(status=status, main=self)
|
|
|
|
return changed
|
2020-04-18 16:49:33 +00:00
|
|
|
|
2020-04-24 07:26:11 +00:00
|
|
|
def triggered_map_clear_mode_stop(self):
|
2020-04-18 16:49:33 +00:00
|
|
|
if not self.config.ENABLE_MAP_CLEAR_MODE:
|
|
|
|
return False
|
|
|
|
|
|
|
|
percent = color_bar_percentage(self.device.image, area=MAP_CLEAR_PERCENTAGE.area, prev_color=(231, 170, 82))
|
2020-04-21 15:10:58 +00:00
|
|
|
logger.attr('Map_clear', f'{int(percent * 100)}%')
|
2020-04-18 16:49:33 +00:00
|
|
|
if self.config.CLEAR_MODE_STOP_CONDITION == 'map_100':
|
|
|
|
if percent > 0.95:
|
2020-04-24 07:26:11 +00:00
|
|
|
return True
|
2020-04-18 16:49:33 +00:00
|
|
|
|
|
|
|
if self.config.CLEAR_MODE_STOP_CONDITION == 'map_3_star':
|
2020-04-24 07:26:11 +00:00
|
|
|
if self.appear(MAP_STAR_1) and self.appear(MAP_STAR_2) and self.appear(MAP_STAR_3) and percent > 0.95:
|
|
|
|
return True
|
2020-04-18 16:49:33 +00:00
|
|
|
|
|
|
|
if self.config.CLEAR_MODE_STOP_CONDITION in ['map_3_star', 'map_green'] and self.config.MAP_STAR_CLEAR_ALL:
|
|
|
|
button = [MAP_STAR_1, MAP_STAR_2, MAP_STAR_3][self.config.MAP_STAR_CLEAR_ALL - 1]
|
|
|
|
self.config.MAP_CLEAR_ALL_THIS_TIME = not self.appear(button)
|
|
|
|
logger.attr('MAP_CLEAR_ALL_THIS_TIME', self.config.MAP_CLEAR_ALL_THIS_TIME)
|
|
|
|
|
|
|
|
if self.config.CLEAR_MODE_STOP_CONDITION == 'map_green':
|
|
|
|
if self.appear(MAP_GREEN):
|
2020-04-24 07:26:11 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
def handle_map_clear_mode_stop(self):
|
|
|
|
if self.map_clear_record is True:
|
|
|
|
return False
|
|
|
|
|
|
|
|
flag = self.triggered_map_clear_mode_stop()
|
|
|
|
if self.map_clear_record is None:
|
|
|
|
self.map_clear_record = flag
|
|
|
|
elif self.map_clear_record is False and flag:
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|