Add: Frame of preset commission filter

This commit is contained in:
SarContDeli 2022-10-21 21:00:18 +08:00
parent c9d296ad76
commit ca6810d569
13 changed files with 101 additions and 35 deletions

View File

@ -1048,7 +1048,8 @@
},
"Commission": {
"DoMajorCommission": false,
"CommissionFilter": "DailyEvent\n> Gem-8 > Gem-4 > Gem-2\n> NightDrill-8 > NightDrill-7 > NightDrill-6\n> ExtraDrill-0:20 > ExtraDrill-1 > ExtraDrill-2 > ExtraDrill-2:40 > ExtraDrill-3:20 > ExtraDrill-5:20\n> Box-6 > Box-3 > Box-1\n> DailyCube-0:30 > UrgentCube-1:30 > DailyCube-1:30 > UrgentCube-1:45 > UrgentCube-2:15 > UrgentCube-3\n> Major\n> DailyChip > DailyResource\n> UrgentBook-2:30 > UrgentBook-2 > UrgentBook-1:20 > UrgentBook-1:40\n> Daily-0:20 > Daily-0:30 > Daily-1:00 > Daily-1:30 > Daily-2:00\n> NightOil > NightCube\n> shortest"
"PresetFilter": "general",
"CustomFilter": "DailyEvent\n> Gem-8 > Gem-4 > Gem-2\n> NightDrill-8 > NightDrill-7 > NightDrill-6\n> ExtraDrill-0:20 > ExtraDrill-1 > ExtraDrill-2 > ExtraDrill-2:40 > ExtraDrill-3:20 > ExtraDrill-5:20\n> Box-6 > Box-3 > Box-1\n> DailyCube-0:30 > UrgentCube-1:30 > DailyCube-1:30 > UrgentCube-1:45 > UrgentCube-2:15 > UrgentCube-3\n> Major\n> DailyChip > DailyResource\n> UrgentBook-2:30 > UrgentBook-2 > UrgentBook-1:20 > UrgentBook-1:40\n> Daily-0:20 > Daily-0:30 > Daily-1:00 > Daily-1:30 > Daily-2:00\n> NightOil > NightCube\n> shortest"
},
"Storage": {
"Storage": {}

View File

@ -6,8 +6,9 @@ from module.base.timer import Timer
from module.base.utils import *
from module.combat.assets import *
from module.commission.assets import *
from module.commission.project import (COMMISSION_FILTER, SHORTEST_FILTER,
Commission)
from module.commission.preset import DICT_FILTER_PRESET, SHORTEST_FILTER
from module.commission.project import COMMISSION_FILTER, Commission
from module.config.config_generated import GeneratedConfig
from module.exception import GameStuckError
from module.handler.info_handler import InfoHandler
from module.logger import logger
@ -127,8 +128,22 @@ class RewardCommission(UI, InfoHandler):
np.sum([1 for c in total if c.status == 'running']))
logger.attr('Running', f'{running_count}/{self.max_commission}')
# Load filter string
preset = self.config.Commission_PresetFilter
if preset == 'custom':
string = self.config.Commission_CustomFilter
else:
if f'{preset}_24h' in DICT_FILTER_PRESET \
and self.config.cross_get(keys='GemsFarming.GemsFarming.CommissionLimit', default=False):
preset = f'{preset}_24h'
if preset not in DICT_FILTER_PRESET:
logger.warning(f'Preset not found: {preset}, use default preset')
preset = GeneratedConfig.Commission_PresetFilter
string = DICT_FILTER_PRESET[preset]
logger.attr('Commission Filter', preset)
# Filter
COMMISSION_FILTER.load(self.config.Commission_CommissionFilter)
COMMISSION_FILTER.load(string)
run = COMMISSION_FILTER.apply(total.grids, func=self._commission_check)
logger.attr('Filter_sort', ' > '.join([str(c) for c in run]))
run = SelectedGrids(run)

View File

@ -0,0 +1,22 @@
SHORTEST_FILTER = """
0:20 > 0:30
> 1 > 1:10 > 1:20 > 1:30 > 1:40 > 1:45
> 2 > 2:15 > 2:30 > 2:40
> 3 > 3:20
> 4 > 5 > 5:20
> 6 > 7 > 8 > 9 > 10 > 12
"""
DICT_FILTER_PRESET = {
'general': """DailyEvent
> Gem-8 > Gem-4 > Gem-2
> NightDrill-8 > NightDrill-7 > NightDrill-6
> ExtraDrill-0:20 > ExtraDrill-1 > ExtraDrill-2 > ExtraDrill-2:40 > ExtraDrill-3:20 > ExtraDrill-5:20
> Box-6 > Box-3 > Box-1
> DailyCube-0:30 > UrgentCube-1:30 > DailyCube-1:30 > UrgentCube-1:45 > UrgentCube-2:15 > UrgentCube-3
> Major
> DailyChip > DailyResource
> UrgentBook-2:30 > UrgentBook-2 > UrgentBook-1:20 > UrgentBook-1:40
> Daily-0:20 > Daily-0:30 > Daily-1:00 > Daily-1:30 > Daily-2:00
> NightOil > NightCube
> shortest"""
}

View File

@ -22,14 +22,6 @@ COMMISSION_FILTER = Filter(
attr=('category_str', 'genre_str', 'duration_hm', 'duration_hour'),
preset=('shortest',)
)
SHORTEST_FILTER = """
0:20 > 0:30
> 1 > 1:10 > 1:20 > 1:30 > 1:40 > 1:45
> 2 > 2:15 > 2:30 > 2:40
> 3 > 3:20
> 4 > 5 > 5:20
> 6 > 7 > 8 > 9 > 10 > 12
"""
class SuffixOcr(Ocr):

View File

@ -5577,7 +5577,15 @@
"type": "checkbox",
"value": false
},
"CommissionFilter": {
"PresetFilter": {
"type": "select",
"value": "general",
"option": [
"custom",
"general"
]
},
"CustomFilter": {
"type": "textarea",
"value": "DailyEvent\n> Gem-8 > Gem-4 > Gem-2\n> NightDrill-8 > NightDrill-7 > NightDrill-6\n> ExtraDrill-0:20 > ExtraDrill-1 > ExtraDrill-2 > ExtraDrill-2:40 > ExtraDrill-3:20 > ExtraDrill-5:20\n> Box-6 > Box-3 > Box-1\n> DailyCube-0:30 > UrgentCube-1:30 > DailyCube-1:30 > UrgentCube-1:45 > UrgentCube-2:15 > UrgentCube-3\n> Major\n> DailyChip > DailyResource\n> UrgentBook-2:30 > UrgentBook-2 > UrgentBook-1:20 > UrgentBook-1:40\n> Daily-0:20 > Daily-0:30 > Daily-1:00 > Daily-1:30 > Daily-2:00\n> NightOil > NightCube\n> shortest"
}

View File

@ -257,7 +257,12 @@ MaritimeEscort:
Commission:
DoMajorCommission: false
CommissionFilter: |-
PresetFilter:
value: general
option:
- custom
- general
CustomFilter: |-
DailyEvent
> Gem-8 > Gem-4 > Gem-2
> NightDrill-8 > NightDrill-7 > NightDrill-6

View File

@ -175,7 +175,8 @@ class GeneratedConfig:
# Group `Commission`
Commission_DoMajorCommission = False
Commission_CommissionFilter = 'DailyEvent\n> Gem-8 > Gem-4 > Gem-2\n> NightDrill-8 > NightDrill-7 > NightDrill-6\n> ExtraDrill-0:20 > ExtraDrill-1 > ExtraDrill-2 > ExtraDrill-2:40 > ExtraDrill-3:20 > ExtraDrill-5:20\n> Box-6 > Box-3 > Box-1\n> DailyCube-0:30 > UrgentCube-1:30 > DailyCube-1:30 > UrgentCube-1:45 > UrgentCube-2:15 > UrgentCube-3\n> Major\n> DailyChip > DailyResource\n> UrgentBook-2:30 > UrgentBook-2 > UrgentBook-1:20 > UrgentBook-1:40\n> Daily-0:20 > Daily-0:30 > Daily-1:00 > Daily-1:30 > Daily-2:00\n> NightOil > NightCube\n> shortest'
Commission_PresetFilter = 'general' # custom, general
Commission_CustomFilter = 'DailyEvent\n> Gem-8 > Gem-4 > Gem-2\n> NightDrill-8 > NightDrill-7 > NightDrill-6\n> ExtraDrill-0:20 > ExtraDrill-1 > ExtraDrill-2 > ExtraDrill-2:40 > ExtraDrill-3:20 > ExtraDrill-5:20\n> Box-6 > Box-3 > Box-1\n> DailyCube-0:30 > UrgentCube-1:30 > DailyCube-1:30 > UrgentCube-1:45 > UrgentCube-2:15 > UrgentCube-3\n> Major\n> DailyChip > DailyResource\n> UrgentBook-2:30 > UrgentBook-2 > UrgentBook-1:20 > UrgentBook-1:40\n> Daily-0:20 > Daily-0:30 > Daily-1:00 > Daily-1:30 > Daily-2:00\n> NightOil > NightCube\n> shortest'
# Group `Tactical`
Tactical_TacticalFilter = 'SameT4 > SameT3 > SameT2 > SameT1\n> BlueT2 > YellowT2 > RedT2\n> BlueT3 > YellowT3 > RedT3\n> BlueT4 > YellowT4 > RedT4\n> BlueT1 > YellowT1 > RedT1\n> first'

View File

@ -491,6 +491,8 @@ class ConfigUpdater:
('DataKey.Scheduler.Enable', 'Freebies.DataKey.Collect'),
('DataKey.DataKey.ForceGet', 'Freebies.DataKey.ForceCollect'),
('SupplyPack.SupplyPack.WeeklyFreeSupplyPack', 'Freebies.SupplyPack.Collect'),
('Alas.Emulator.PackageName', 'Alas.DropRecord.API', api_redirect),
('Commission.Commission.CommissionFilter', 'Commission.Commission.CustomFilter')
]
@cached_property

View File

@ -1163,9 +1163,15 @@
"name": "Do Major Commissions",
"help": "Enable allowance of undertaking 1200/1000 oil cost commissions; Commission Priority requires \"Major\" be included if enabled"
},
"CommissionFilter": {
"name": "Commission Priority",
"help": "Generally does not need to be modified or re-arranged but can do so if desired"
"PresetFilter": {
"name": "Preset Filter Select",
"help": "People without a basic knowledge of commission drops rates and spawn are recommended to use pre-optimized presets instead of writing custom filters",
"custom": "custom",
"general": "general"
},
"CustomFilter": {
"name": "Custom Commission Priority",
"help": "To use your own filter, set \"Preset Filter Select\" to \"custom\". All options have been defined at <https://github.com/LmeSzinc/AzurLaneAutoScript/wiki/filter_string_en>"
}
},
"Tactical": {

View File

@ -1163,9 +1163,15 @@
"name": "Commission.DoMajorCommission.name",
"help": "Commission.DoMajorCommission.help"
},
"CommissionFilter": {
"name": "Commission.CommissionFilter.name",
"help": "Commission.CommissionFilter.help"
"PresetFilter": {
"name": "Commission.PresetFilter.name",
"help": "Commission.PresetFilter.help",
"custom": "custom",
"general": "general"
},
"CustomFilter": {
"name": "Commission.CustomFilter.name",
"help": "Commission.CustomFilter.help"
}
},
"Tactical": {

View File

@ -1163,9 +1163,15 @@
"name": "做主要委托1200油/1000油委托",
"help": ""
},
"CommissionFilter": {
"PresetFilter": {
"name": "委托过滤器",
"help": "一般不需要修改"
"help": "如果对委托的产出和收益没有足够的了解,不建议编写自定义过滤器,建议使用预优化委托过滤器",
"custom": "自定义",
"general": "general"
},
"CustomFilter": {
"name": "自定义委托过滤器",
"help": "使用自定义过滤器需将 \"委托过滤器\" 设置为 \"自定义\",并阅读 https://github.com/LmeSzinc/AzurLaneAutoScript/wiki/filter_string_cn"
}
},
"Tactical": {

View File

@ -1163,9 +1163,15 @@
"name": "做主要委託 (1200油/1000油委託)",
"help": ""
},
"CommissionFilter": {
"name": "委託過濾器",
"help": "一般不需要修改"
"PresetFilter": {
"name": "委托過濾器",
"help": "如果對委托的產出和收益沒有足夠的了解,不建議編寫自定義過濾器,建議使用預優化委托過濾器",
"custom": "自定義",
"general": "general"
},
"CustomFilter": {
"name": "自定義委托過濾器",
"help": "使用自定義過濾器需將 \"委托過濾器\" 設置為 \"自定義\",並閱讀 https://github.com/LmeSzinc/AzurLaneAutoScript/wiki/filter_string_cn"
}
},
"Tactical": {

View File

@ -121,18 +121,14 @@ class ResearchSelector(ResearchUI):
if preset == 'custom':
string = self.config.Research_CustomFilter
if enforce:
value = GeneratedConfig.Research_PresetFilter
string = string.split()
string.append('>')
string.extend(DICT_FILTER_PRESET[value].split())
string = " ".join(string)
string = string + ' > ' + DICT_FILTER_PRESET[GeneratedConfig.Research_PresetFilter]
else:
if self.config.Research_UseCube == 'always_use' or enforce:
if f'{preset}_cube' in DICT_FILTER_PRESET:
preset = f'{preset}_cube'
if (self.config.Research_UseCube == 'always_use' or enforce) \
and f'{preset}_cube' in DICT_FILTER_PRESET:
preset = f'{preset}_cube'
if preset not in DICT_FILTER_PRESET:
logger.warning(f'Preset not found: {preset}, use default preset')
preset = 'series_5_blueprint_152'
preset = GeneratedConfig.Research_PresetFilter
string = DICT_FILTER_PRESET[preset]
logger.attr('Research preset', preset)