mirror of
https://github.com/0O0o0oOoO00/Alas.git
synced 2026-05-14 14:39:25 +08:00
fix: override original method to bypass opsi backdoor
This commit is contained in:
@@ -815,6 +815,61 @@ class ConfigUpdater:
|
||||
return data
|
||||
|
||||
|
||||
class ConfigUpdater(ConfigUpdater):
|
||||
def config_update(self, old, is_template=False):
|
||||
"""
|
||||
Args:
|
||||
old (dict):
|
||||
is_template (bool):
|
||||
|
||||
Returns:
|
||||
dict:
|
||||
"""
|
||||
new = {}
|
||||
|
||||
for keys, data in deep_iter(self.args, depth=3):
|
||||
value = deep_get(old, keys=keys, default=data['value'])
|
||||
typ = data['type']
|
||||
display = data.get('display')
|
||||
if is_template or value is None or value == '' \
|
||||
or typ in ['lock', 'state'] or (display == 'hide' and typ != 'stored'):
|
||||
value = data['value']
|
||||
value = parse_value(value, data=data)
|
||||
deep_set(new, keys=keys, value=value)
|
||||
|
||||
# AzurStatsID
|
||||
if is_template:
|
||||
deep_set(new, 'Alas.DropRecord.AzurStatsID', None)
|
||||
else:
|
||||
deep_default(new, 'Alas.DropRecord.AzurStatsID', random_id())
|
||||
|
||||
# In the original method,
|
||||
# when OpsiHazard1Leveling is enabled,
|
||||
# the OpsiMeowfficerFarming will be set to enabled
|
||||
|
||||
# Update to latest event
|
||||
server = to_server(deep_get(new, 'Alas.Emulator.PackageName', 'cn'))
|
||||
if not is_template:
|
||||
for task in EVENTS + RAIDS + COALITIONS:
|
||||
opts = deep_get(self.args, keys=f'{task}.Campaign.Event.option_{server}', default=[])
|
||||
if not deep_get(new, keys=f'{task}.Campaign.Event', default='campaign_main') in opts:
|
||||
deep_set(new,
|
||||
keys=f'{task}.Campaign.Event',
|
||||
value=opts[0])
|
||||
|
||||
for task in ['GemsFarming']:
|
||||
if deep_get(new, keys=f'{task}.Campaign.Event', default='campaign_main') != 'campaign_main':
|
||||
deep_set(new,
|
||||
keys=f'{task}.Campaign.Event',
|
||||
value=deep_get(self.args, f'{task}.Campaign.Event.option_{server}')[0])
|
||||
# War archive does not allow campaign_main
|
||||
for task in WAR_ARCHIVES:
|
||||
if deep_get(new, keys=f'{task}.Campaign.Event', default='campaign_main') == 'campaign_main':
|
||||
deep_set(new,
|
||||
keys=f'{task}.Campaign.Event',
|
||||
value=deep_get(self.args, f'{task}.Campaign.Event.option_{server}')[0])
|
||||
|
||||
|
||||
FULL_CONFIG_IMPORT = '''
|
||||
# This file was automatically generated by module/config/config_updater.py.
|
||||
# Don't modify it manually.
|
||||
|
||||
@@ -941,6 +941,36 @@ class OSMap(OSFleet, Map, GlobeCamera, StrategicSearchHandler):
|
||||
|
||||
|
||||
class OSMap(OSMap):
|
||||
def map_rescan(self, rescan_mode='full', drop=None):
|
||||
if self.zone.is_port:
|
||||
logger.info('Current zone is a port, do not need rescan')
|
||||
return False
|
||||
|
||||
# In the original method,
|
||||
# when OpsiHazard1Leveling is turned on and the OpsiMeowfficerFarming is not turned on,
|
||||
# the map will not be rescanned
|
||||
|
||||
for _ in range(5):
|
||||
if not self._solved_fleet_mechanism:
|
||||
self.fleet_set(self.config.OpsiFleet_Fleet)
|
||||
else:
|
||||
self.fleet_set(self.get_second_fleet())
|
||||
if not self.is_in_task_explore and len(self._solved_map_event):
|
||||
logger.info('Solved a map event and not in OpsiExplore, stop rescan')
|
||||
logger.attr('Solved_map_event', self._solved_map_event)
|
||||
self.fleet_set(self.config.OpsiFleet_Fleet)
|
||||
return False
|
||||
result = self.map_rescan_once(rescan_mode=rescan_mode, drop=drop)
|
||||
if not result:
|
||||
logger.attr('Solved_map_event', self._solved_map_event)
|
||||
self.fleet_set(self.config.OpsiFleet_Fleet)
|
||||
return True
|
||||
|
||||
logger.attr('Solved_map_event', self._solved_map_event)
|
||||
logger.warning('Too many trial on map rescan, stop')
|
||||
self.fleet_set(self.config.OpsiFleet_Fleet)
|
||||
return False
|
||||
|
||||
def os_auto_search_daemon(self, drop=None, strategic=False, skip_first_screenshot=True):
|
||||
logger.hr('OS auto search', level=2)
|
||||
self.on_auto_search_battle_count_reset()
|
||||
|
||||
@@ -501,8 +501,29 @@ class ActionPointHandler(UI, MapEventHandler):
|
||||
|
||||
|
||||
class ActionPointHandler(ActionPointHandler):
|
||||
def my_action_point_update(self):
|
||||
"""
|
||||
Returns:
|
||||
int: Total action points, including ap boxes.
|
||||
"""
|
||||
items = ACTION_POINT_ITEMS.predict(self.device.image, name=False, amount=True)
|
||||
box = [item.amount for item in items]
|
||||
current = OCR_ACTION_POINT_REMAIN.ocr(self.device.image)
|
||||
total = current
|
||||
if self.config.OS_ACTION_POINT_BOX_USE:
|
||||
total += np.sum(np.array(box) * tuple(ACTION_POINT_BOX.values()))
|
||||
oil = box[0]
|
||||
|
||||
logger.info(f'Action points: {current}({total}), oil: {oil}')
|
||||
self._action_point_current = current
|
||||
self._action_point_box = box
|
||||
self._action_point_total = total
|
||||
|
||||
# In the original method, when the total amount exceeds 3000,
|
||||
# the OpsiGeneral.DoRandomMapEvent will be turned off
|
||||
|
||||
def action_point_update(self):
|
||||
ret = super().action_point_update()
|
||||
ret = self.my_action_point_update()
|
||||
|
||||
self.config.log_res.Oil = self._action_point_box[0]
|
||||
self.config.log_res.ActionPoint = {
|
||||
|
||||
Reference in New Issue
Block a user