Beispiel #1
0
def main(ini_name=''):
    if not ini_name:
        ini_name = pyw_name
    config_file = f'./config/{ini_name}.ini'
    config = get_config(ini_name.lower())

    # Load translation dictionary
    dic_gui_to_ini = dic_tchi_to_eng  # GUI translation dictionary here.
    dic_gui_to_ini.update(dic_event[server.server])
    dic_ini_to_gui = {v: k for k, v in dic_gui_to_ini.items()}
    # Event list
    event_folder = [
        f for f in dic_event[server.server].values() if f.startswith('event_')
    ]
    event_latest = event_folder[-1]
    event_folder = [dic_ini_to_gui.get(f, f) for f in event_folder][::-1]
    event_latest = dic_ini_to_gui.get(event_latest, event_latest)
    # Archives list
    archives_folder = [
        f for f in dic_event[server.server].values()
        if f.startswith('war_archives_')
    ]
    archives_folder = [dic_ini_to_gui.get(f, f) for f in archives_folder][::-1]
    # Raid list
    raid_folder = [
        f for f in dic_event[server.server].values() if f.startswith('raid_')
    ]
    raid_latest = raid_folder[-1]
    raid_folder = [dic_ini_to_gui.get(f, f) for f in raid_folder][::-1]
    raid_latest = dic_ini_to_gui.get(raid_latest, raid_latest)
    # Research preset list
    research_preset = [
        dic_ini_to_gui.get(f, f)
        for f in ['customized'] + list(DICT_FILTER_PRESET.keys())
    ]
    # Translate settings in ini file
    saved_config = {}
    for opt, option in config.items():
        for key, value in option.items():
            key = dic_ini_to_gui.get(key, key)
            if value in dic_ini_to_gui:
                value = dic_ini_to_gui.get(value, value)
            if value == 'None':
                value = ''
            saved_config[key] = value
    message = ('藍疊模擬器:\t127.0.0.1:5555\n'
               '夜神模擬器:\t127.0.0.1:62001\n'
               'MuMu模擬器:\t127.0.0.1:7555\n'
               '逍遙模擬器:\t127.0.0.1:21503\n'
               '雷電模擬器:\temulator-5554\n')

    def default(name):
        """Get default value in .ini file.
        Args:
            name (str): option, in chinese.

        Returns:
            str: Default value, in chinese.
        """
        name = name.strip('-')
        return saved_config.get(name, '')

    def choice_list(total):
        return [str(index) for index in range(1, total + 1)]

    # Don't use checkbox in gooey, use drop box instead.
    # https://github.com/chriskiehl/Gooey/issues/148
    # https://github.com/chriskiehl/Gooey/issues/485

    parser = GooeyParser(
        description=
        f'AzurLaneAutoScript, An Azur Lane automation tool. Config: {config_file}\n功能都是分別保存和執行的, 修改設定後別忘了點擊"開始"來保存'
    )
    subs = parser.add_subparsers(help='commands', dest='command')

    # ==========出擊設定==========
    setting_parser = subs.add_parser('出擊設定')

    # 選擇關卡
    stage = setting_parser.add_argument_group(
        '關卡設定', '需要執行一次來保存選項', gooey_options={'label_color': '#931D03'})
    stage.add_argument('--啟用停止條件',
                       default=default('--啟用停止條件'),
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--啟用異常處理',
                       default=default('--啟用異常處理'),
                       choices=['是', '否'],
                       help='處理部分異常, 執行出錯時撤退',
                       gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--使用周回模式',
                       default=default('--使用周回模式'),
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})

    stop = stage.add_argument_group('停止條件',
                                    '出發後不會馬上停止, 會先完成目前出擊, 不需要就填0',
                                    gooey_options={'label_color': '#931D03'})
    stop.add_argument('--如果出擊數大於',
                      default=default('--如果出擊數大於'),
                      help='會沿用先前設定, 完成出擊將扣除次數, 直至為零',
                      gooey_options={'label_color': '#4B5F83'})
    stop.add_argument(
        '--如果時間超過',
        default=default('--如果時間超過'),
        help='使用未來24小時內的時間, 會沿用先前設定, 觸發後清零, 建議提前10分鐘左右, 以完成目前出擊。格式 14:59',
        gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果石油低於',
                      default=default('--如果石油低於'),
                      gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果獲得新船',
                      default=default('--如果獲得新船'),
                      choices=['是', '否'],
                      help='獲得新船後進入收穫循環',
                      gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果地圖開荒',
                      default=default('--如果地圖開荒'),
                      choices=['否', '地圖通關', '地圖三星', '地圖安海不打三星', '地圖安海'],
                      help='如果已滿足, 無視此設定',
                      gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果觸發心情控制',
                      default=default('--如果觸發心情控制'),
                      choices=['是', '否'],
                      help='若是, 等待回復, 完成本次, 停止\n若否, 等待回復, 完成本次, 繼續',
                      gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果到達120級',
                      default=default('--如果到達120級'),
                      choices=['是', '否'],
                      help='當艦船從119級升至120級时: \n若是, 完成本次, 停止出擊\n若否, 繼續出擊',
                      gooey_options={'label_color': '#4B5F83'})
    # stop.add_argument('--如果船塢已滿', default=default('--如果船塢已滿'), choices=['是', '否'])

    # 出擊艦隊
    fleet = setting_parser.add_argument_group(
        '出擊艦隊',
        '暫不支援備用道中隊, 非活動圖或周回模式會忽略步長設定',
        gooey_options={'label_color': '#931D03'})
    fleet.add_argument('--啟用艦隊控制',
                       default=default('--啟用艦隊控制'),
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    fleet.add_argument('--啟用陣容鎖定',
                       default=default('--啟用陣容鎖定'),
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})

    f1 = fleet.add_argument_group('道中隊',
                                  gooey_options={'label_color': '#931D03'})
    f1.add_argument('--艦隊編號1',
                    default=default('--艦隊編號1'),
                    choices=['1', '2', '3', '4', '5', '6'],
                    gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--艦隊陣型1',
                    default=default('--艦隊陣型1'),
                    choices=['單縱陣', '復縱陣', '輪型陣'],
                    gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--自律模式1',
                    default=default('--自律模式1'),
                    choices=['自律', '手操', '中路站樁', '躲左下角'],
                    gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--艦隊步長1',
                    default=default('--艦隊步長1'),
                    choices=['1', '2', '3', '4', '5', '6'],
                    gooey_options={'label_color': '#4B5F83'})

    f2 = fleet.add_argument_group('BOSS队',
                                  gooey_options={'label_color': '#931D03'})
    f2.add_argument('--艦隊編號2',
                    default=default('--艦隊編號2'),
                    choices=['不使用', '1', '2', '3', '4', '5', '6'],
                    gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--艦隊陣型2',
                    default=default('--艦隊陣型2'),
                    choices=['單縱陣', '復縱陣', '輪型陣'],
                    gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--自律模式2',
                    default=default('--自律模式2'),
                    choices=['自律', '手操', '中路站樁', '躲左下角'],
                    gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--艦隊步長2',
                    default=default('--艦隊步長2'),
                    choices=['1', '2', '3', '4', '5', '6'],
                    gooey_options={'label_color': '#4B5F83'})

    f3 = fleet.add_argument_group('备用道中队',
                                  gooey_options={'label_color': '#931D03'})
    f3.add_argument('--艦隊編號3',
                    default=default('--艦隊編號3'),
                    choices=['不使用', '1', '2', '3', '4', '5', '6'],
                    gooey_options={'label_color': '#4B5F83'})
    f3.add_argument('--艦隊陣型3',
                    default=default('--艦隊陣型3'),
                    choices=['單縱陣', '復縱陣', '輪型陣'],
                    gooey_options={'label_color': '#4B5F83'})
    f3.add_argument('--自律模式3',
                    default=default('--自律模式3'),
                    choices=['自律', '手操', '中路站樁', '躲左下角'],
                    gooey_options={'label_color': '#4B5F83'})
    f3.add_argument('--艦隊步長3',
                    default=default('--艦隊步長3'),
                    choices=['1', '2', '3', '4', '5', '6'],
                    gooey_options={'label_color': '#4B5F83'})

    # 潛艇設定
    submarine = setting_parser.add_argument_group(
        '潛艇設定', '僅支援:不使用、僅狩獵、每戰出擊', gooey_options={'label_color': '#931D03'})
    submarine.add_argument('--艦隊編號4',
                           default=default('--艦隊編號4'),
                           choices=['不使用', '1', '2'],
                           gooey_options={'label_color': '#4B5F83'})
    submarine.add_argument(
        '--潛艇出擊方案',
        default=default('--潛艇出擊方案'),
        choices=['不使用', '僅狩獵', '每戰出擊', '空彈出擊', 'BOSS戰出擊', 'BOSS戰BOSS出現後招喚'],
        gooey_options={'label_color': '#4B5F83'})

    # 心情控制
    emotion = setting_parser.add_argument_group(
        '心情控制', gooey_options={'label_color': '#931D03'})
    emotion.add_argument('--啟用心情消耗',
                         default=default('--啟用心情消耗'),
                         choices=['是', '否'],
                         gooey_options={'label_color': '#4B5F83'})
    emotion.add_argument('--無視紅臉出擊警告',
                         default=default('--無視紅臉出擊警告'),
                         choices=['是', '否'],
                         gooey_options={'label_color': '#4B5F83'})

    e1 = emotion.add_argument_group('道中隊',
                                    gooey_options={'label_color': '#931D03'})
    e1.add_argument('--心情回復1',
                    default=default('--心情回復1'),
                    choices=['未放置於後宅', '後宅一樓', '後宅二樓'],
                    gooey_options={'label_color': '#4B5F83'})
    e1.add_argument('--心情控制1',
                    default=default('--心情控制1'),
                    choices=['保持經驗加成', '防止綠臉', '防止黃臉', '防止紅臉'],
                    gooey_options={'label_color': '#4B5F83'})
    e1.add_argument('--全員已婚1',
                    default=default('--全員已婚1'),
                    choices=['是', '否'],
                    gooey_options={'label_color': '#4B5F83'})

    e2 = emotion.add_argument_group('BOSS隊',
                                    gooey_options={'label_color': '#931D03'})
    e2.add_argument('--心情回復2',
                    default=default('--心情回復2'),
                    choices=['未放置於後宅', '後宅一樓', '後宅二樓'],
                    gooey_options={'label_color': '#4B5F83'})
    e2.add_argument('--心情控制2',
                    default=default('--心情控制2'),
                    choices=['保持經驗加成', '防止綠臉', '防止黃臉', '防止紅臉'],
                    gooey_options={'label_color': '#4B5F83'})
    e2.add_argument('--全員已婚2',
                    default=default('--全員已婚2'),
                    choices=['是', '否'],
                    gooey_options={'label_color': '#4B5F83'})

    e3 = emotion.add_argument_group('備用道中隊',
                                    '會在主隊觸發心情控制時使用',
                                    gooey_options={'label_color': '#931D03'})
    e3.add_argument('--心情回復3',
                    default=default('--心情回復3'),
                    choices=['未放置於後宅', '後宅一樓', '後宅二樓'],
                    gooey_options={'label_color': '#4B5F83'})
    e3.add_argument('--心情控制3',
                    default=default('--心情控制3'),
                    choices=['保持經驗加成', '防止綠臉', '防止黃臉', '防止紅臉'],
                    gooey_options={'label_color': '#4B5F83'})
    e3.add_argument('--全員已婚3',
                    default=default('--全員已婚3'),
                    choices=['是', '否'],
                    gooey_options={'label_color': '#4B5F83'})

    # 血量平衡
    hp = setting_parser.add_argument_group(
        '血量控制', '需關閉艦隊鎖定才能生效', gooey_options={'label_color': '#931D03'})
    hp.add_argument('--啟用血量平衡',
                    default=default('--啟用血量平衡'),
                    choices=['是', '否'],
                    gooey_options={'label_color': '#4B5F83'})
    hp.add_argument('--啟用低血量撤退',
                    default=default('--啟用低血量撤退'),
                    choices=['是', '否'],
                    gooey_options={'label_color': '#4B5F83'})
    hp_balance = hp.add_argument_group(
        '血量平衡', '', gooey_options={'label_color': '#4B5F83'})
    hp_balance.add_argument('--先鋒血量平衡閾值',
                            default=default('--先鋒血量平衡閾值'),
                            help='血量差值大於閾值時, 換位',
                            gooey_options={'label_color': '#4B5F83'})
    hp_balance.add_argument('--先鋒血量權重',
                            default=default('--先鋒血量權重'),
                            help='先鋒肉度有差別時應修改, 格式 1000,1000,1000',
                            gooey_options={'label_color': '#4B5F83'})
    hp_add = hp.add_argument_group('緊急維修',
                                   '',
                                   gooey_options={'label_color': '#4B5F83'})
    hp_add.add_argument('--緊急維修單人閾值',
                        default=default('--緊急維修單人閾值'),
                        help='單人低於閾值時使用',
                        gooey_options={'label_color': '#4B5F83'})
    hp_add.add_argument('--緊急維修全隊閾值',
                        default=default('--緊急維修全隊閾值'),
                        help='前排全部或後排全部低於閾值時使用',
                        gooey_options={'label_color': '#4B5F83'})
    hp_withdraw = hp.add_argument_group(
        '低血量撤退', '', gooey_options={'label_color': '#4B5F83'})
    hp_withdraw.add_argument('--低血量撤退閾值',
                             default=default('--低血量撤退閾值'),
                             help='任意一人血量低於閾值時, 撤退',
                             gooey_options={'label_color': '#4B5F83'})

    # 退役選項
    retire = setting_parser.add_argument_group(
        '退役設定', '', gooey_options={'label_color': '#931D03'})
    retire.add_argument('--啟用退役',
                        default=default('--啟用退役'),
                        choices=['是', '否'],
                        gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--退役方案',
                        default=default('--退役方案'),
                        choices=['強化角色', '一鍵退役', '傳統退役'],
                        help='若選擇強化, 當強化材料不足時, 將使用一鍵退役',
                        gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--退役數量',
                        default=default('--退役數量'),
                        choices=['退役全部', '退役10個'],
                        gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--強化常用角色',
                        default=default('--強化常用角色'),
                        choices=['是', '否'],
                        gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--強化過濾字符串',
                        default=default('--強化過濾字符串'),
                        help='格式: "cv > bb > ...", 留空則使用默認強化方式',
                        gooey_options={'label_color': '#4B5F83'})

    rarity = retire.add_argument_group(
        '退役稀有度',
        '暫不支援艦種選擇, 使用一鍵退役時忽略以下選項',
        gooey_options={'label_color': '#931D03'})
    rarity.add_argument('--退役白皮',
                        default=default('--退役白皮'),
                        choices=['是', '否'],
                        help='N',
                        gooey_options={'label_color': '#4B5F83'})
    rarity.add_argument('--退役藍皮',
                        default=default('--退役藍皮'),
                        choices=['是', '否'],
                        help='R',
                        gooey_options={'label_color': '#4B5F83'})
    # rarity.add_argument('--退役紫皮', default=default('--退役紫皮'), choices=['是', '否'], help='SR', gooey_options={'label_color': '#4B5F83'})
    # rarity.add_argument('--退役金皮', default=default('--退役金皮'), choices=['是', '否'], help='SSR', gooey_options={'label_color': '#4B5F83'})

    # 掉落記錄
    drop = setting_parser.add_argument_group(
        '掉落記錄',
        '保存掉落物品的截圖, 啟用後會放緩結算時的點擊速度',
        gooey_options={'label_color': '#931D03'})
    drop.add_argument('--啟用掉落記錄',
                      default=default('--啟用掉落記錄'),
                      choices=['是', '否'],
                      gooey_options={'label_color': '#4B5F83'})
    drop.add_argument('--掉落保存目錄',
                      default=default('--掉落保存目錄'),
                      gooey_options={'label_color': '#4B5F83'})

    # clear = setting_parser.add_argument_group('開荒模式', '未開荒地圖會在完成後停止, 已開荒的地圖會忽略此選項, 無腦開就結束了')
    # clear.add_argument('--啟用開荒', default=default('--啟用開荒'), choices=['是', '否'])
    # clear.add_argument('--開荒停止條件', default=default('--開荒停止條件'), choices=['地圖通關', '地圖三星', '地圖安海'])
    # clear.add_argument('--地圖全清星星', default=default('--地圖全清星星'), choices=['第一個', '第二個', '第三個', '不使用'], help='第幾顆星星是擊破所有敵艦')

    # ==========收成設定==========
    reward_parser = subs.add_parser('收成設定')
    reward_condition = reward_parser.add_argument_group(
        '觸發條件',
        '需要執行一次來保存選項, 執行後會進入掛機收成模式',
        gooey_options={'label_color': '#931D03'})
    reward_condition.add_argument('--啟用收穫',
                                  default=default('--啟用收穫'),
                                  choices=['是', '否'],
                                  gooey_options={'label_color': '#4B5F83'})
    reward_condition.add_argument('--收成間隔',
                                  default=default('--收成間隔'),
                                  help='每隔多少分鐘觸發收成, 推薦使用時間區間, 比如"10, 40"',
                                  gooey_options={'label_color': '#4B5F83'})
    reward_condition.add_argument('--收成間隔關閉遊戲',
                                  default=default('--收成間隔關閉遊戲'),
                                  choices=['是', '否'],
                                  gooey_options={'label_color': '#4B5F83'})
    reward_condition.add_argument('--啟用每日收穫',
                                  default=default('--啟用每日收穫'),
                                  choices=['是', '否'],
                                  help='將每日任務困難演習作為收穫的一部份來執行',
                                  gooey_options={'label_color': '#4B5F83'})

    reward_general = reward_parser.add_argument_group(
        '日常收穫', '', gooey_options={'label_color': '#931D03'})
    reward_general.add_argument('--啟用石油收穫',
                                default=default('--啟用石油收穫'),
                                choices=['是', '否'],
                                gooey_options={'label_color': '#4B5F83'})
    reward_general.add_argument('--啟用物資收穫',
                                default=default('--啟用物資收穫'),
                                choices=['是', '否'],
                                gooey_options={'label_color': '#4B5F83'})
    reward_general.add_argument('--啟用任務收穫',
                                default=default('--啟用任務收穫'),
                                choices=['是', '否'],
                                gooey_options={'label_color': '#4B5F83'})

    reward_dorm = reward_parser.add_argument_group(
        '後宅設定', '', gooey_options={'label_color': '#931D03'})
    reward_dorm.add_argument('--啟用後宅收穫',
                             default=default('--啟用後宅收穫'),
                             choices=['是', '否'],
                             help='收穫好感度和家具幣',
                             gooey_options={'label_color': '#4B5F83'})
    reward_dorm.add_argument('--啟用後宅餵食',
                             default=default('--啟用後宅餵食'),
                             choices=['是', '否'],
                             help='後宅餵食',
                             gooey_options={'label_color': '#4B5F83'})
    reward_dorm.add_argument('--後宅收穫間隔',
                             default=default('--後宅收穫間隔'),
                             help='每隔多少分鐘觸發, 推薦使用時間區間, 比如"10, 40"',
                             gooey_options={'label_color': '#4B5F83'})
    reward_dorm.add_argument(
        '--後宅餵食間隔',
        default=default('--後宅餵食間隔'),
        help=
        '每隔多少分鐘觸發, 推薦使用時間區間, 比如"10, 40"\n後宅六船時, 使用六種食物分別需要間隔大於\n(14, 28, 42, 70, 139, 278)',
        gooey_options={'label_color': '#4B5F83'})
    reward_dorm.add_argument('--後宅餵食優先',
                             default=default('--後宅餵食優先'),
                             help='仿照科研過濾字符串',
                             gooey_options={'label_color': '#4B5F83'})

    reward_commission = reward_parser.add_argument_group(
        '委託設定', '', gooey_options={'label_color': '#931D03'})
    reward_commission.add_argument('--啟用委託收穫',
                                   default=default('--啟用委託收穫'),
                                   choices=['是', '否'],
                                   gooey_options={'label_color': '#4B5F83'})
    reward_commission.add_argument('--委託時間限制',
                                   default=default('--委託時間限制'),
                                   help='忽略完成時間超過限制的委託, 格式:23:30, 不需要就填0',
                                   gooey_options={'label_color': '#4B5F83'})

    priority1 = reward_commission.add_argument_group(
        '委託耗時優先級', '', gooey_options={'label_color': '#931D03'})
    priority1.add_argument('--委託耗時小於2h',
                           default=default('--委託耗時小於2h'),
                           help='',
                           gooey_options={'label_color': '#4B5F83'})
    priority1.add_argument('--委託耗時超過6h',
                           default=default('--委託耗時超過6h'),
                           help='',
                           gooey_options={'label_color': '#4B5F83'})
    priority1.add_argument('--委託過期小於2h',
                           default=default('--委託過期小於2h'),
                           help='',
                           gooey_options={'label_color': '#4B5F83'})
    priority1.add_argument('--委託過期大於6h',
                           default=default('--委託過期大於6h'),
                           help='',
                           gooey_options={'label_color': '#4B5F83'})

    priority2 = reward_commission.add_argument_group(
        '日常委託優先級', '', gooey_options={'label_color': '#931D03'})
    priority2.add_argument('--日常委託',
                           default=default('--日常委託'),
                           help='日常資源開發, 高階戰術研發',
                           gooey_options={'label_color': '#4B5F83'})
    priority2.add_argument('--主要委託',
                           default=default('--主要委託'),
                           help='1200油/1000油委託',
                           gooey_options={'label_color': '#4B5F83'})

    priority3 = reward_commission.add_argument_group(
        '額外委託優先級', '', gooey_options={'label_color': '#931D03'})
    priority3.add_argument('--鑽頭類額外委託',
                           default=default('--鑽頭類額外委託'),
                           help='短距離航行訓練, 近海防衛巡邏',
                           gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--部件類額外委託',
                           default=default('--部件類額外委託'),
                           help='礦脈護衛委託, 林木護衛委託',
                           gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--魔方類額外委託',
                           default=default('--魔方類額外委託'),
                           help='艦隊高階演習, 艦隊護衛演習',
                           gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--石油類額外委託',
                           default=default('--石油類額外委託'),
                           help='小型油田開發, 大型油田開發',
                           gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--教材類額外委託',
                           default=default('--教材類額外委託'),
                           help='小型商船護衛, 大型商船護衛',
                           gooey_options={'label_color': '#4B5F83'})

    priority4 = reward_commission.add_argument_group(
        '緊急委託優先級', '', gooey_options={'label_color': '#931D03'})
    priority4.add_argument('--鑽頭類緊急委託',
                           default=default('--鑽頭類緊急委託'),
                           help='保衛運輸部隊, 殲滅敵精銳部隊',
                           gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--部件類緊急委託',
                           default=default('--部件類緊急委託'),
                           help='支援維拉維拉島, 支援恐班納',
                           gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--魔方類緊急委託',
                           default=default('--魔方類緊急委託'),
                           help='解救商船, 敵襲',
                           gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--教材類緊急委託',
                           default=default('--教材類緊急委託'),
                           help='支援土豪爾島, 支援萌島',
                           gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--裝備類緊急委託',
                           default=default('--裝備類緊急委託'),
                           help='BIW裝備運輸, NYB裝備研發',
                           gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--鑽石類緊急委託',
                           default=default('--鑽石類緊急委託'),
                           help='BIW要員護衛, NYB巡視護衛',
                           gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--觀艦類緊急委託',
                           default=default('--觀艦類緊急委託'),
                           help='小型觀艦儀式, 同盟觀艦儀式',
                           gooey_options={'label_color': '#4B5F83'})

    reward_tactical = reward_parser.add_argument_group(
        '戰術學院', '只支援續技能書, 不支援學新技能', gooey_options={'label_color': '#931D03'})
    reward_tactical.add_argument('--啟用戰術學院收穫',
                                 default=default('--啟用戰術學院收穫'),
                                 choices=['是', '否'],
                                 gooey_options={'label_color': '#4B5F83'})
    # reward_tactical.add_argument('--戰術學院夜間時段', default=default('--戰術學院夜間時段'), help='格式 23:30-06:30')
    reward_tactical.add_argument('--技能書優先使用同類型',
                                 default=default('--技能書優先使用同類型'),
                                 choices=['是', '否'],
                                 help='選是, 優先使用有150%加成的\n選否, 優先使用同稀有度的技能書',
                                 gooey_options={'label_color': '#4B5F83'})
    reward_tactical.add_argument(
        '--技能書最大稀有度',
        default=default('--技能書最大稀有度'),
        choices=['3', '2', '1'],
        help='最高使用T幾的技能書\nT3是金書, T2是紫書, T1是藍書\n最大值需要大於等於最小值',
        gooey_options={'label_color': '#4B5F83'})
    reward_tactical.add_argument('--技能書最小稀有度',
                                 default=default('--技能書最小稀有度'),
                                 choices=['3', '2', '1'],
                                 help='最低使用T幾的技能書\n',
                                 gooey_options={'label_color': '#4B5F83'})
    # reward_tactical.add_argument('--技能書夜間稀有度', default=default('--技能書夜間稀有度'), choices=['3', '2', '1'])
    # reward_tactical.add_argument('--技能書夜間優先使用同類型', default=default('--技能書夜間優先使用同類型'), choices=['是', '否'])
    reward_tactical.add_argument('--如果無技能書可用',
                                 default=default('--如果無技能書可用'),
                                 choices=['停止學習', '使用第一本'],
                                 gooey_options={'label_color': '#4B5F83'})

    reward_research = reward_parser.add_argument_group(
        '科研項目',
        '科研預設選擇為自定義時, 須先閱讀 doc/filter_string_en_cn.md',
        gooey_options={'label_color': '#931D03'})
    reward_research.add_argument('--啟用科研項目收穫',
                                 default=default('--啟用科研項目收穫'),
                                 choices=['是', '否'],
                                 gooey_options={'label_color': '#4B5F83'})
    research_input = reward_research.add_argument_group(
        '科研投入', '', gooey_options={'label_color': '#931D03'})
    research_input.add_argument('--科研項目使用魔方',
                                default=default('--科研項目使用魔方'),
                                choices=['是', '否'],
                                gooey_options={'label_color': '#4B5F83'})
    research_input.add_argument('--科研項目使用金幣',
                                default=default('--科研項目使用金幣'),
                                choices=['是', '否'],
                                gooey_options={'label_color': '#4B5F83'})
    research_input.add_argument('--科研項目使用部件',
                                default=default('--科研項目使用部件'),
                                choices=['是', '否'],
                                gooey_options={'label_color': '#4B5F83'})
    research_output = reward_research.add_argument_group(
        '科研產出', '', gooey_options={'label_color': '#931D03'})
    research_output.add_argument('--科研項目選擇預設',
                                 default=default('--科研項目選擇預設'),
                                 choices=research_preset,
                                 gooey_options={'label_color': '#4B5F83'})
    research_output.add_argument('--科研過濾字符串',
                                 default=default('--科研過濾字符串'),
                                 help='僅在科研預設選擇為自定義時啟用',
                                 gooey_options={'label_color': '#4B5F83'})

    reward_buy = reward_parser.add_argument_group(
        '商店購買', '如果已經買過則自動跳過', gooey_options={'label_color': '#931D03'})
    reward_buy.add_argument('--買指揮喵',
                            default=default('--買指揮喵'),
                            help='從0到15, 不需要就填0',
                            gooey_options={'label_color': '#4B5F83'})

    reward_data_key = reward_parser.add_argument_group(
        '作戰檔案', '如果已經領取則自動跳過', gooey_options={'label_color': '#931D03'})
    reward_data_key.add_argument('--啟用檔案密鑰收穫',
                                 default=default('--啟用檔案密鑰收穫'),
                                 help='領取作戰檔案的檔案密鑰',
                                 choices=['是', '否'],
                                 gooey_options={'label_color': '#4B5F83'})

    # ==========設備設定==========
    emulator_parser = subs.add_parser('設備設定')
    emulator = emulator_parser.add_argument_group(
        '模擬器',
        '需要運行一次來保存選項, 會檢查遊戲是否啟動\n若啟動了遊戲, 觸發一次收菜',
        gooey_options={'label_color': '#931D03'})
    emulator.add_argument('--設備',
                          default=default('--設備'),
                          help='例如 127.0.0.1:62001',
                          gooey_options={'label_color': '#4B5F83'})
    emulator.add_argument('--包名',
                          default=default('--包名'),
                          help='',
                          gooey_options={'label_color': '#4B5F83'})
    emulator.add_argument(
        '默認serial列表',
        default=message,
        widget='Textarea',
        help="以下是一些常見模擬器的默認serial\n如果你使用了模擬器多開, 它們將不使用默認的serial",
        gooey_options={
            'height': 150,
            'show_help': True,
            'show_label': True,
            'readonly': True,
            'label_color': '#4B5F83'
        })

    debug = emulator_parser.add_argument_group(
        '調試設定', '', gooey_options={'label_color': '#931D03'})
    debug.add_argument('--出錯時保存log和截圖',
                       default=default('--出錯時保存log和截圖'),
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    debug.add_argument('--保存透視識別出錯的圖像',
                       default=default('--保存透視識別出錯的圖像'),
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})

    adb = emulator_parser.add_argument_group(
        'ADB設定', '', gooey_options={'label_color': '#931D03'})
    adb.add_argument('--設備截圖方案',
                     default=default('--設備截圖方案'),
                     choices=['aScreenCap', 'uiautomator2', 'ADB'],
                     help='速度: aScreenCap >> uiautomator2 > ADB',
                     gooey_options={'label_color': '#4B5F83'})
    adb.add_argument('--設備控制方案',
                     default=default('--設備控制方案'),
                     choices=['minitouch', 'uiautomator2', 'ADB'],
                     help='速度: minitouch >> uiautomator2 >> ADB',
                     gooey_options={'label_color': '#4B5F83'})
    adb.add_argument('--戰鬥中截圖間隔',
                     default=default('--戰鬥中截圖間隔'),
                     help='戰鬥中放慢截圖速度, 降低CPU使用',
                     gooey_options={'label_color': '#4B5F83'})

    update = emulator_parser.add_argument_group(
        '更新檢查', '', gooey_options={'label_color': '#931D03'})
    update.add_argument('--啟用更新檢查',
                        default=default('--啟用更新檢查'),
                        choices=['是', '否'],
                        gooey_options={'label_color': '#4B5F83'})
    update.add_argument('--更新檢查方法',
                        default=default('--更新檢查方法'),
                        choices=['api', 'web'],
                        help='使用api時建議填寫tokens, 使用web則不需要',
                        gooey_options={'label_color': '#4B5F83'})
    update.add_argument(
        '--github_token',
        default=default('--github_token'),
        help='Github API限制為每小時60次, 獲取tokens https://github.com/settings/tokens',
        gooey_options={'label_color': '#4B5F83'})
    update.add_argument(
        '--更新檢查代理',
        default=default('--更新檢查代理'),
        help=
        '本地http或socks代理, 如果github很慢, 請使用代理, example: http://127.0 .0.1:10809',
        gooey_options={'label_color': '#4B5F83'})

    # ==========每日任務==========
    daily_parser = subs.add_parser('每日任務困難演習')

    # 選擇每日
    daily = daily_parser.add_argument_group(
        '選擇每日', '每日任務, 演習, 困難圖', gooey_options={'label_color': '#931D03'})
    daily.add_argument('--打每日',
                       default=default('--打每日'),
                       help='若當天有記錄, 則跳過',
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打困難',
                       default=default('--打困難'),
                       help='若當天有記錄, 則跳過',
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打演習',
                       default=default('--打演習'),
                       help='若在刷新後有記錄, 則跳過',
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打共鬥每日15次',
                       default=default('--打共鬥每日15次'),
                       help='若當天有記錄, 則跳過',
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打活動圖每日三倍PT',
                       default=default('--打活動圖每日三倍PT'),
                       help='若當天有記錄, 則跳過',
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打活動每日SP圖',
                       default=default('--打活動每日SP圖'),
                       help='若當天有記錄, 則跳過',
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})

    # 每日設定
    daily_task = daily_parser.add_argument_group(
        '每日設定', '不支援潛艇每日', gooey_options={'label_color': '#931D03'})
    daily_task.add_argument('--戰術研修',
                            default=default('--戰術研修'),
                            choices=['航空', '砲擊', '雷擊'],
                            gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--斬首行動',
                            default=default('--斬首行動'),
                            choices=['第一個', '第二個', '第三個'],
                            gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--商船護航',
                            default=default('--商船護航'),
                            choices=['第一個', '第二個', '第三個'],
                            gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--海域突進',
                            default=default('--海域突進'),
                            choices=['第一個', '第二個', '第三個'],
                            gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument(
        '--每日艦隊',
        default=default('--每日艦隊'),
        help=
        '如果使用同一隊, 填艦隊編號, 例如5\n如果使用不同隊, 用半形逗號分割, 順序為商船護送, 海域突進, 斬首行動, 戰術研修\n例如5, 5, 5, 6',
        gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument(
        '--每日艦隊快速換裝',
        default=default('--每日艦隊快速換裝'),
        help='打之前換裝備, 打完後卸裝備, 不需要就填0 \n半形逗號分割, 例如3, 1, 0, 1, 1, 0',
        gooey_options={'label_color': '#4B5F83'})

    # 困難設定
    hard = daily_parser.add_argument_group(
        '困難設定',
        '需要開啟週回模式, 暫時僅支援 10-4',
        gooey_options={'label_color': '#931D03'})
    hard.add_argument('--困難地圖',
                      default=default('--困難地圖'),
                      help='比如 10-4',
                      gooey_options={'label_color': '#4B5F83'})
    hard.add_argument('--困難艦隊',
                      default=default('--困難艦隊'),
                      choices=['1', '2'],
                      gooey_options={'label_color': '#4B5F83'})
    hard.add_argument(
        '--困難艦隊快速換裝',
        default=default('--困難艦隊快速換裝'),
        help='打之前換裝備, 打完後卸裝備, 不需要就填0\n半形逗號分割, 例如3, 1, 0, 1, 1, 0',
        gooey_options={'label_color': '#4B5F83'})

    # 演習設定
    exercise = daily_parser.add_argument_group(
        '演習設定', '', gooey_options={'label_color': '#931D03'})
    exercise.add_argument('--演習對手選擇',
                          default=default('--演習對手選擇'),
                          choices=['經驗最多', '最簡單', '先最簡單再經驗最多'],
                          help='',
                          gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演習次數保留',
                          default=default('--演習次數保留'),
                          help='暫時僅支援保留0個',
                          gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演習嘗試次數',
                          default=default('--演習嘗試次數'),
                          help='每個對手的嘗試次數, 打不過就換',
                          gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演習SL閾值',
                          default=default('--演習SL閾值'),
                          help='HP<閾值時撤退',
                          gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演習低血量確認時長',
                          default=default('--演習低血量確認時長'),
                          help='HP低於閾值後, 過一定時長才會撤退\n推薦1.0 ~ 3.0',
                          gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument(
        '--演習快速換裝',
        default=default('--演習快速換裝'),
        help='打之前換裝備, 打完後卸裝備, 不需要就填0\n半形逗號分割, 例如3, 1, 0, 1, 1, 0',
        gooey_options={'label_color': '#4B5F83'})

    # 每日活動圖三倍PT
    event_bonus = daily_parser.add_argument_group(
        '活動設定', '', gooey_options={'label_color': '#931D03'})
    event_bonus.add_argument('--活動獎勵章節',
                             default=default('--活動獎勵章節'),
                             choices=['AB圖', 'ABCD圖', 'T圖', 'HT圖'],
                             help='有額外PT獎勵章節',
                             gooey_options={'label_color': '#4B5F83'})
    event_bonus.add_argument('--活動SP圖道中隊',
                             default=default('--活動SP圖道中隊'),
                             choices=['1', '2'],
                             help='',
                             gooey_options={'label_color': '#4B5F83'})
    event_bonus.add_argument('--活動名稱ab',
                             default=event_latest,
                             choices=event_folder,
                             help='例如 event_20200326_cn',
                             gooey_options={'label_color': '#4B5F83'})

    # 共鬥每日設定
    raid_bonus = daily_parser.add_argument_group(
        '共鬥設定', '', gooey_options={'label_color': '#931D03'})
    raid_bonus.add_argument('--共鬥每日名稱',
                            default=raid_latest,
                            choices=raid_folder,
                            help='',
                            gooey_options={'label_color': '#4B5F83'})
    raid_bonus.add_argument('--共鬥困難',
                            default=default('--共鬥困難'),
                            choices=['是', '否'],
                            help='',
                            gooey_options={'label_color': '#4B5F83'})
    raid_bonus.add_argument('--共鬥普通',
                            default=default('--共鬥普通'),
                            choices=['是', '否'],
                            help='',
                            gooey_options={'label_color': '#4B5F83'})
    raid_bonus.add_argument('--共鬥簡單',
                            default=default('--共鬥簡單'),
                            choices=['是', '否'],
                            help='',
                            gooey_options={'label_color': '#4B5F83'})

    # # ==========每日活動圖三倍PT==========
    # event_ab_parser = subs.add_parser('每日活動圖三倍PT')
    # event_name = event_ab_parser.add_argument_group('選擇活動', '')
    # event_name.add_argument('--活動名稱ab', default=event_latest, choices=event_folder, help='例如 event_20200326_cn')

    # ==========主線圖==========
    main_parser = subs.add_parser('主線圖')
    # 選擇關卡
    stage = main_parser.add_argument_group(
        '選擇關卡', '', gooey_options={'label_color': '#931D03'})
    stage.add_argument('--主線地圖出擊',
                       default=default('--主線地圖出擊'),
                       help='例如 7-2',
                       gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--主線地圖模式',
                       default=default('--主線地圖模式'),
                       help='僅困難圖開荒時使用, 週回模式後請使用每日困難',
                       choices=['普通', '困難'],
                       gooey_options={'label_color': '#4B5F83'})

    # ==========活動圖==========
    event_parser = subs.add_parser('活動圖')

    description = """
    出擊未優化關卡或地圖未達到安全海域時, 使用開荒模式運行(較慢)
    """
    event = event_parser.add_argument_group(
        '選擇關卡',
        '\n'.join([line.strip() for line in description.strip().split('\n')]),
        gooey_options={'label_color': '#931D03'})
    event.add_argument('--活動地圖',
                       default=default('--活動地圖'),
                       help='輸入地圖名稱, 不分大小寫, 例如D3, SP3, HT6',
                       gooey_options={'label_color': '#4B5F83'})
    event.add_argument('--活動名稱',
                       default=event_latest,
                       choices=event_folder,
                       help='例如 event_20200312_cn',
                       gooey_options={'label_color': '#4B5F83'})

    # ==========潛艇圖==========
    sos_parser = subs.add_parser('潛艇圖')
    sos = sos_parser.add_argument_group(
        '潛艇圖設定',
        '設定每張潛艇圖的隊伍, 順序: 一隊二隊潛艇隊\n例如"4, 6", "4, 0", "4, 6, 1"\n填0跳過不打',
        gooey_options={'label_color': '#931D03'})
    sos.add_argument('--第3章潛艇圖隊伍',
                     default=default('--第3章潛艇圖隊伍'),
                     gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第4章潛艇圖隊伍',
                     default=default('--第4章潛艇圖隊伍'),
                     gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第5章潛艇圖隊伍',
                     default=default('--第5章潛艇圖隊伍'),
                     gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第6章潛艇圖隊伍',
                     default=default('--第6章潛艇圖隊伍'),
                     gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第7章潛艇圖隊伍',
                     default=default('--第7章潛艇圖隊伍'),
                     gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第8章潛艇圖隊伍',
                     default=default('--第8章潛艇圖隊伍'),
                     gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第9章潛艇圖隊伍',
                     default=default('--第9章潛艇圖隊伍'),
                     gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第10章潛艇圖隊伍',
                     default=default('--第10章潛艇圖隊伍'),
                     gooey_options={'label_color': '#4B5F83'})

    # ==========war_archives==
    war_archives_parser = subs.add_parser('war_archives')
    war_archives = war_archives_parser.add_argument_group(
        'war archives settings',
        'Type a stage and select a corresponding event for that stage',
        gooey_options={'label_color': '#931D03'})
    war_archives.add_argument(
        '--war_archives_stage',
        default=default('--war_archives_stage'),
        help='Type stage name, not case sensitive, E.g D3, SP3, HT6',
        gooey_options={'label_color': '#4B5F83'})
    war_archives.add_argument('--war_archives_name',
                              default=default('--war_archives_name'),
                              choices=archives_folder,
                              help='There a dropdown menu with many options',
                              gooey_options={'label_color': '#4B5F83'})

    # ==========共鬥活動==========
    raid_parser = subs.add_parser('共鬥活動')
    raid = raid_parser.add_argument_group(
        '選擇共鬥', '', gooey_options={'label_color': '#931D03'})
    raid.add_argument('--共鬥名稱',
                      default=raid_latest,
                      choices=raid_folder,
                      help='',
                      gooey_options={'label_color': '#4B5F83'})
    raid.add_argument('--共鬥難度',
                      default=default('--共鬥難度'),
                      choices=['困難', '普通', '簡單'],
                      help='',
                      gooey_options={'label_color': '#4B5F83'})
    raid.add_argument('--共鬥使用挑戰券',
                      default=default('--共鬥使用挑戰券'),
                      choices=['是', '否'],
                      help='',
                      gooey_options={'label_color': '#4B5F83'})

    # ==========半自動==========
    semi_parser = subs.add_parser('半自動輔助點擊')
    semi = semi_parser.add_argument_group(
        '半自動模式',
        '手動選敵, 自動結算, 用於出擊未適配的圖',
        gooey_options={'label_color': '#931D03'})
    semi.add_argument('--進圖準備',
                      default=default('--進圖準備'),
                      help='',
                      choices=['是', '否'],
                      gooey_options={'label_color': '#4B5F83'})
    semi.add_argument('--跳過劇情',
                      default=default('--跳過劇情'),
                      help='注意, 這會自動確認所有提示框, 包括紅臉出擊',
                      choices=['是', '否'],
                      gooey_options={'label_color': '#4B5F83'})

    # ==========1-1Affinity farming==========
    c_1_1_parser = subs.add_parser('1-1伏擊刷好感')
    c_1_1 = c_1_1_parser.add_argument_group(
        '1-1伏擊刷好感',
        '會自動關閉週回模式\n有MVP, 8場戰鬥漲1點好感, 無MVP, 16場戰鬥漲1點好感',
        gooey_options={'label_color': '#931D03'})
    c_1_1.add_argument('--刷好感戰斗場數',
                       default=default('--刷好感戰斗場數'),
                       help='例如: 32',
                       gooey_options={'label_color': '#4B5F83'})

    # ==========7-2三戰撿垃圾==========
    c_7_2_parser = subs.add_parser('7-2三戰撿垃圾')
    c_7_2 = c_7_2_parser.add_argument_group(
        '7-2三戰撿垃圾', '', gooey_options={'label_color': '#931D03'})
    c_7_2.add_argument('--BOSS隊踩A3',
                       default=default('--BOSS隊踩A3'),
                       choices=['是', '否'],
                       help='A3有敵人就G3, C3, E3',
                       gooey_options={'label_color': '#4B5F83'})

    # ==========12-2打中型練級==========
    c_12_2_parser = subs.add_parser('12-2打中型練級')
    c_12_2 = c_12_2_parser.add_argument_group(
        '12-2索敵設定', '', gooey_options={'label_color': '#931D03'})
    c_12_2.add_argument('--大型敵人忍耐',
                        default=default('--大型敵人忍耐'),
                        choices=['0', '1', '2', '10'],
                        help='最多打多少戰大型敵人, 不挑敵人選10',
                        gooey_options={'label_color': '#4B5F83'})

    # ==========12-4打大型練級==========
    c_12_4_parser = subs.add_parser('12-4打大型練級')
    c_12_4 = c_12_4_parser.add_argument_group(
        '12-4索敵設定', '需保證隊伍有一定強度', gooey_options={'label_color': '#931D03'})
    c_12_4.add_argument('--非大型敵人進圖忍耐',
                        default=default('--非大型敵人進圖忍耐'),
                        choices=['0', '1', '2'],
                        help='忍受進場多少戰沒有大型',
                        gooey_options={'label_color': '#4B5F83'})
    c_12_4.add_argument('--非大型敵人撤退忍耐',
                        default=default('--非大型敵人撤退忍耐'),
                        choices=['0', '1', '2', '10'],
                        help='沒有大型之後還會打多少戰, 不挑敵人選10',
                        gooey_options={'label_color': '#4B5F83'})
    c_12_4.add_argument('--撿彈藥124',
                        default=default('--撿彈藥124'),
                        choices=['2', '3', '4', '5'],
                        help='多少戰後撿彈藥',
                        gooey_options={'label_color': '#4B5F83'})

    args = parser.parse_args()

    # Convert option from chinese to english.
    out = {}
    for key, value in vars(args).items():
        key = dic_gui_to_ini.get(key, key)
        value = dic_gui_to_ini.get(value, value)
        out[key] = value
    args = out

    # Update option to .ini file.
    command = args['command'].capitalize()
    config['Command']['command'] = command
    for key, value in args.items():
        config[command][key] = str(value)
    config.write(codecs.open(config_file, "w+", "utf8"))

    # Call AzurLaneAutoScript
    alas = AzurLaneAutoScript(ini_name=ini_name)
    alas.run(command=command)
Beispiel #2
0
def main(ini_name=''):
    if not ini_name:
        ini_name = pyw_name
    config_file = f'./config/{ini_name}.ini'
    config = get_config(ini_name.lower())

    event_folder = [
        f for f in os.listdir('./campaign')
        if f.startswith('event_') and f.split('_')[-1] == server.server
    ]
    event_latest = sorted([f for f in event_folder], reverse=True)[0]
    event_folder = [dic_eng_to_true_eng.get(f, f) for f in event_folder][::-1]
    event_latest = dic_eng_to_true_eng.get(event_latest, event_latest)

    raid_latest = 'Air_Raid_Drills_with_Essex'

    saved_config = {}
    for opt, option in config.items():
        for key, value in option.items():
            key = dic_eng_to_true_eng.get(key, key)
            if value in dic_eng_to_true_eng:
                value = dic_eng_to_true_eng.get(value, value)
            if value == 'None':
                value = ''

            saved_config[key] = value

    def default(name):
        """Get default value in .ini file.
        Args:
            name (str): option, in chinese.

        Returns:
            str: Default value, in chinese.
        """
        name = name.strip('-')
        return saved_config.get(name, '')

    def choice_list(total):
        return [str(index) for index in range(1, total + 1)]

    # Don't use checkbox in gooey, use drop box instead.
    # https://github.com/chriskiehl/Gooey/issues/148
    # https://github.com/chriskiehl/Gooey/issues/485

    parser = GooeyParser(
        description=
        f'AzurLaneAutoScript, An Azur Lane automation tool. Config: {config_file}'
    )
    subs = parser.add_subparsers(help='commands', dest='command')

    # ==========setting==========
    setting_parser = subs.add_parser('setting')

    # 选择关卡
    stage = setting_parser.add_argument_group(
        'Level settings', 'Need to Press start to save your settings.')
    stage.add_argument('--enable_stop_condition',
                       default=default('--enable_stop_condition'),
                       choices=['yes', 'no'])
    stage.add_argument(
        '--enable_exception',
        default=default('--enable_exception'),
        choices=['yes', 'no'],
        help=
        'Enable or disable some exceptions, ALAS will withdraw from the map when it occurs instead of stopping'
    )
    stage.add_argument('--enable_fast_forward',
                       default=default('--enable_fast_forward'),
                       choices=['yes', 'no'],
                       help='Enable or disable clearing mode')

    stop = stage.add_argument_group(
        'Stop condition',
        'After triggering, it will not stop immediately. It will complete the current attack first, and fill in 0 if it is not needed.'
    )
    stop.add_argument(
        '--if_count_greater_than',
        default=default('--if_count_greater_than'),
        help=
        'The previous setting will be used, and the number\n of deductions will be deducted after completion of the attack until it is cleared.'
    )
    stop.add_argument(
        '--if_time_reach',
        default=default('--if_time_reach'),
        help=
        'Use the time within the next 24 hours, the previous setting will be used, and it will be cleared\n after the trigger. It is recommended to advance about\n 10 minutes to complete the current attack. Format 14:59'
    )
    stop.add_argument('--if_oil_lower_than',
                      default=default('--if_oil_lower_than'))
    stop.add_argument(
        '--if_trigger_emotion_control',
        default=default('--if_trigger_emotion_control'),
        choices=['yes', 'no'],
        help=
        'If yes, wait for reply, complete this time, stop \nIf no, wait for reply, complete this time, continue'
    )
    # stop.add_argument('--if_dock_full', default=default('--if_dock_full'), choices=['yes', 'no'])

    # 出击舰队
    fleet = setting_parser.add_argument_group(
        'Attack fleet',
        'No support for alternate lane squadrons, inactive map or weekly mode will ignore the step setting'
    )
    fleet.add_argument('--enable_fleet_control',
                       default=default('--enable_fleet_control'),
                       choices=['yes', 'no'])
    fleet.add_argument('--enable_map_fleet_lock',
                       default=default('--enable_map_fleet_lock'),
                       choices=['yes', 'no'])

    f1 = fleet.add_argument_group(
        'Mob Fleet',
        'Players can choose a formation before battle. Though it has no effect appearance-wise, the formations applies buffs to certain stats.\nLine Ahead: Increases Firepower and Torpedo by 15%, but reduces Evasion by 10% (Applies only to Vanguard fleet)\nDouble Line: Increases Evasion by 30%, but decreases Firepower and Torpedo by 5% (Applies only to Vanguard fleet)\nDiamond: Increases Anti-Air by 20% (no penalties, applies to entire fleet)'
    )
    f1.add_argument('--fleet_index_1',
                    default=default('--fleet_index_1'),
                    choices=['1', '2', '3', '4', '5', '6'])
    f1.add_argument('--fleet_formation_1',
                    default=default('--fleet_formation_1'),
                    choices=['Line Ahead', 'Double Line', 'Diamond'])
    f1.add_argument(
        '--fleet_step_1',
        default=default('--fleet_step_1'),
        choices=['1', '2', '3', '4', '5', '6'],
        help=
        'In event map, fleet has limit on moving, so fleet_step is how far can a fleet goes in one operation, if map cleared, it will be ignored'
    )

    f2 = fleet.add_argument_group('Boss Fleet')
    f2.add_argument('--fleet_index_2',
                    default=default('--fleet_index_2'),
                    choices=['1', '2', '3', '4', '5', '6'])
    f2.add_argument('--fleet_formation_2',
                    default=default('--fleet_formation_2'),
                    choices=['Line Ahead', 'Double Line', 'Diamond'])
    f2.add_argument(
        '--fleet_step_2',
        default=default('--fleet_step_2'),
        choices=['1', '2', '3', '4', '5', '6'],
        help=
        'In event map, fleet has limit on moving, so fleet_step is how far can a fleet goes in one operation, if map cleared, it will be ignored'
    )

    f3 = fleet.add_argument_group('Alternate Mob Fleet')
    f3.add_argument('--fleet_index_3',
                    default=default('--fleet_index_3'),
                    choices=['1', '2', '3', '4', '5', '6'])
    f3.add_argument('--fleet_formation_3',
                    default=default('--fleet_formation_3'),
                    choices=['Line Ahead', 'Double Line', 'Diamond'])
    f3.add_argument(
        '--fleet_step_3',
        default=default('--fleet_step_3'),
        choices=['1', '2', '3', '4', '5', '6'],
        help=
        'In event map, fleet has limit on moving, so fleet_step is how far can a fleet goes in one operation, if map cleared, it will be ignored'
    )

    f4 = fleet.add_argument_group('Auto-mode')
    f4.add_argument(
        '--combat_auto_mode',
        default=default('--combat_auto_mode'),
        choices=['combat_auto', 'combat_manual', 'stand_still_in_the_middle'])

    # 潜艇设置
    submarine = setting_parser.add_argument_group(
        'Submarine settings',
        'Only supported: hunt_only, do_not_use and every_combat')
    submarine.add_argument('--fleet_index_4',
                           default=default('--fleet_index_4'),
                           choices=['do_not_use', '1', '2'])
    submarine.add_argument('--submarine_mode',
                           default=default('--submarine_mode'),
                           choices=[
                               'do_not_use', 'hunt_only', 'every_combat',
                               'when_no_ammo', 'when_boss_combat',
                               'when_boss_combat_boss_appear'
                           ])

    # 心情控制
    emotion = setting_parser.add_argument_group('Mood control')
    emotion.add_argument('--enable_emotion_reduce',
                         default=default('--enable_emotion_reduce'),
                         choices=['yes', 'no'])
    emotion.add_argument('--ignore_low_emotion_warn',
                         default=default('--ignore_low_emotion_warn'),
                         choices=['yes', 'no'])

    e1 = emotion.add_argument_group('Mob Fleet')
    e1.add_argument(
        '--emotion_recover_1',
        default=default('--emotion_recover_1'),
        choices=['not_in_dormitory', 'dormitory_floor_1', 'dormitory_floor_2'])
    e1.add_argument('--emotion_control_1',
                    default=default('--emotion_control_1'),
                    choices=[
                        'keep_high_emotion', 'avoid_green_face',
                        'avoid_yellow_face', 'avoid_red_face'
                    ])
    e1.add_argument('--hole_fleet_married_1',
                    default=default('--hole_fleet_married_1'),
                    choices=['yes', 'no'])

    e2 = emotion.add_argument_group('BOSS Fleet')
    e2.add_argument(
        '--emotion_recover_2',
        default=default('--emotion_recover_2'),
        choices=['not_in_dormitory', 'dormitory_floor_1', 'dormitory_floor_2'])
    e2.add_argument('--emotion_control_2',
                    default=default('--emotion_control_2'),
                    choices=[
                        'keep_high_emotion', 'avoid_green_face',
                        'avoid_yellow_face', 'avoid_red_face'
                    ])
    e2.add_argument('--hole_fleet_married_2',
                    default=default('--hole_fleet_married_2'),
                    choices=['yes', 'no'])

    e3 = emotion.add_argument_group(
        'Alternate Mob Fleet',
        'Will be used when the first team triggers mood control')
    e3.add_argument(
        '--emotion_recover_3',
        default=default('--emotion_recover_3'),
        choices=['not_in_dormitory', 'dormitory_floor_1', 'dormitory_floor_2'])
    e3.add_argument('--emotion_control_3',
                    default=default('--emotion_control_3'),
                    choices=[
                        'keep_high_emotion', 'avoid_green_face',
                        'avoid_yellow_face', 'avoid_red_face'
                    ])
    e3.add_argument('--hole_fleet_married_3',
                    default=default('--hole_fleet_married_3'),
                    choices=['yes', 'no'])

    # 血量平衡
    hp = setting_parser.add_argument_group(
        'HP control', 'Fleet lock must be turned off to take effect')
    hp.add_argument('--enable_hp_balance',
                    default=default('--enable_hp_balance'),
                    choices=['yes', 'no'])
    hp.add_argument('--enable_low_hp_withdraw',
                    default=default('--enable_low_hp_withdraw'),
                    choices=['yes', 'no'])
    hp_balance = hp.add_argument_group('HP Balance', '')
    hp_balance.add_argument(
        '--scout_hp_difference_threshold',
        default=default('--scout_hp_difference_threshold'),
        help=
        'When the difference in HP volume is greater than the threshold, transpose'
    )
    hp_balance.add_argument(
        '--scout_hp_weights',
        default=default('--scout_hp_weights'),
        help=
        'Should be repaired when there is a difference in Vanguard, format 1000,1000,1000'
    )
    hp_add = hp.add_argument_group('Emergency repair', '')
    hp_add.add_argument(
        '--emergency_repair_single_threshold',
        default=default('--emergency_repair_single_threshold'),
        help='Used when single shipgirl is below the threshold')
    hp_add.add_argument(
        '--emergency_repair_hole_threshold',
        default=default('--emergency_repair_hole_threshold'),
        help='Used when all front rows or all back rows are below the threshold'
    )
    hp_withdraw = hp.add_argument_group('Low HP volume withdrawal', '')
    hp_withdraw.add_argument('--low_hp_withdraw_threshold',
                             default=default('--low_hp_withdraw_threshold'),
                             help='When HP is below the threshold, retreat')

    # 退役选项
    retire = setting_parser.add_argument_group('Retirement settings', '')
    retire.add_argument('--enable_retirement',
                        default=default('--enable_retirement'),
                        choices=['yes', 'no'])
    retire.add_argument('--retire_method',
                        default=default('--retire_method'),
                        choices=['enhance', 'one_click_retire', 'old_retire'])
    retire.add_argument('--retire_amount',
                        default=default('--retire_amount'),
                        choices=['retire_all', 'retire_10'])
    retire.add_argument('--enhance_favourite',
                        default=default('--enhance_favourite'),
                        choices=['yes', 'no'])

    rarity = retire.add_argument_group(
        'Retirement rarity',
        'The ship type selection is not supported yet. Ignore the following options when using one-key retirement'
    )
    rarity.add_argument('--retire_n',
                        default=default('--retire_n'),
                        choices=['yes', 'no'],
                        help='N')
    rarity.add_argument('--retire_r',
                        default=default('--retire_r'),
                        choices=['yes', 'no'],
                        help='R')
    rarity.add_argument('--retire_sr',
                        default=default('--retire_sr'),
                        choices=['yes', 'no'],
                        help='SR')
    rarity.add_argument('--retire_ssr',
                        default=default('--retire_ssr'),
                        choices=['yes', 'no'],
                        help='SSR')

    # 掉落记录
    drop = setting_parser.add_argument_group(
        'Drop record',
        'Save screenshots of dropped items, which will slow down the click speed when settlement is enabled'
    )
    drop.add_argument('--enable_drop_screenshot',
                      default=default('--enable_drop_screenshot'),
                      choices=['yes', 'no'])
    drop.add_argument('--drop_screenshot_folder',
                      default=default('--drop_screenshot_folder'))

    clear = setting_parser.add_argument_group(
        'Wasteland mode',
        'Unopened maps will stop after completion. Opened maps will ignore options, and its done if you do not open up'
    )
    clear.add_argument('--enable_map_clear_mode',
                       default=default('--enable_map_clear_mode'),
                       choices=['yes', 'no'])
    clear.add_argument('--clear_mode_stop_condition',
                       default=default('--clear_mode_stop_condition'),
                       choices=['map_100', 'map_3_star', 'map_green'])
    clear.add_argument(
        '--map_star_clear_all',
        default=default('--map_star_clear_all'),
        choices=['index_1', 'index_2', 'index_3', 'do_not_use'],
        help='The first few stars are to destroy all enemy ships')

    # ==========reward==========
    reward_parser = subs.add_parser('reward')
    reward_condition = reward_parser.add_argument_group(
        'Triggering conditions',
        'Need to Press start to save your settings, after running it will enter the on-hook vegetable collection mode'
    )
    reward_condition.add_argument('--enable_reward',
                                  default=default('--enable_reward'),
                                  choices=['yes', 'no'])
    reward_condition.add_argument(
        '--reward_interval',
        default=default('--reward_interval'),
        choices=['20', '30', '60'],
        help='How many minutes to trigger collection')

    reward_oil = reward_parser.add_argument_group('Oil supplies', '')
    reward_oil.add_argument('--enable_oil_reward',
                            default=default('--enable_oil_reward'),
                            choices=['yes', 'no'])
    reward_oil.add_argument('--enable_coin_reward',
                            default=default('--enable_coin_reward'),
                            choices=['yes', 'no'])

    reward_mission = reward_parser.add_argument_group('mission rewards', '')
    reward_mission.add_argument('--enable_mission_reward',
                                default=default('--enable_mission_reward'),
                                choices=['yes', 'no'])

    reward_commission = reward_parser.add_argument_group(
        'Commission settings', '')
    reward_commission.add_argument(
        '--enable_commission_reward',
        default=default('--enable_commission_reward'),
        choices=['yes', 'no'])
    reward_commission.add_argument(
        '--commission_time_limit',
        default=default('--commission_time_limit'),
        help=
        'Ignore orders whose completion time exceeds the limit, Format: 23:30. Fill in 0 if it is not needed'
    )

    priority1 = reward_commission.add_argument_group(
        'Commission priority by time duration', '')
    priority1.add_argument('--duration_shorter_than_2',
                           default=default('--duration_shorter_than_2'),
                           help='')
    priority1.add_argument('--duration_longer_than_6',
                           default=default('--duration_longer_than_6'),
                           help='')
    priority1.add_argument('--expire_shorter_than_2',
                           default=default('--expire_shorter_than_2'),
                           help='')
    priority1.add_argument('--expire_longer_than_6',
                           default=default('--expire_longer_than_6'),
                           help='')

    priority2 = reward_commission.add_argument_group(
        'Daily Commission priority', '')
    priority2.add_argument(
        '--daily_comm',
        default=default('--daily_comm'),
        help=
        'Daily resource development, high-level tactical research and development'
    )
    priority2.add_argument('--major_comm',
                           default=default('--major_comm'),
                           help='1200 oil / 1000 oil commission')

    priority3 = reward_commission.add_argument_group(
        'Additional commission priority', '')
    priority3.add_argument(
        '--extra_drill',
        default=default('--extra_drill'),
        help='Short-range Sailing Training, Coastal Defense Patrol')
    priority3.add_argument(
        '--extra_part',
        default=default('--extra_part'),
        help='Small Merchant Escort, Forest Protection Commission')
    priority3.add_argument(
        '--extra_cube',
        default=default('--extra_cube'),
        help='Fleet Exercise Ⅲ, Fleet Escort ExerciseFleet Exercise Ⅲ')
    priority3.add_argument(
        '--extra_oil',
        default=default('--extra_oil'),
        help='Small-scale Oil Extraction, Large-scale Oil Extraction')
    priority3.add_argument('--extra_book',
                           default=default('--extra_book'),
                           help='Small Merchant Escort, Large Merchant Escort')

    priority4 = reward_commission.add_argument_group(
        'Urgent commission priority', '')
    priority4.add_argument(
        '--urgent_drill',
        default=default('--urgent_drill'),
        help='Defend the transport troops, annihilate the enemy elite troops')
    priority4.add_argument(
        '--urgent_part',
        default=default('--urgent_part'),
        help='Support Vila Vela Island, support terror Banner')
    priority4.add_argument('--urgent_cube',
                           default=default('--urgent_cube'),
                           help='Rescue merchant ship, enemy attack')
    priority4.add_argument('--urgent_book',
                           default=default('--urgent_book'),
                           help='Support Tuhaoer Island, support Moe Island')
    priority4.add_argument('--urgent_box',
                           default=default('--urgent_box'),
                           help='BIW Gear Transport, NYB Gear Transport')
    priority4.add_argument('--urgent_gem',
                           default=default('--urgent_gem'),
                           help='BIW VIP Escort, NYB VIP Escort')
    priority4.add_argument(
        '--urgent_ship',
        default=default('--urgent_ship'),
        help=
        'Small Launch Ceremony, Fleet Launch Ceremony, Alliance Launch Ceremony'
    )

    reward_tactical = reward_parser.add_argument_group(
        'Classroom',
        'Only support continuation of skill books, not new skills')
    reward_tactical.add_argument('--enable_tactical_reward',
                                 default=default('--enable_tactical_reward'),
                                 choices=['yes', 'no'])
    reward_tactical.add_argument('--tactical_night_range',
                                 default=default('--tactical_night_range'),
                                 help='Format 23:30-06:30')
    reward_tactical.add_argument(
        '--tactical_book_tier',
        default=default('--tactical_book_tier'),
        choices=['3', '2', '1'],
        help=
        'Wich skill book will use first\nT3 is a gold book, T2 is a purple book, T1 is a blue book'
    )
    reward_tactical.add_argument(
        '--tactical_exp_first',
        default=default('--tactical_exp_first'),
        choices=['yes', 'no'],
        help=
        'Choose Yes, give priority to the 150% bonus \nSelect No, give priority to the skills book with the same rarity'
    )
    reward_tactical.add_argument('--tactical_book_tier_night',
                                 default=default('--tactical_book_tier_night'),
                                 choices=['3', '2', '1'])
    reward_tactical.add_argument('--tactical_exp_first_night',
                                 default=default('--tactical_exp_first_night'),
                                 choices=['yes', 'no'])

    # ==========emulator==========
    emulator_parser = subs.add_parser('emulator')
    emulator = emulator_parser.add_argument_group(
        'Emulator',
        'Need to Press start to save your settings, it will check whether the game is started \nIf the game has not started, it will be started'
    )
    emulator.add_argument(
        '--serial',
        default=default('--serial'),
        help='Bluestacks 127.0.0.1:5555 \nNox 127.0.0.1:62001')
    emulator.add_argument('--package_name',
                          default='com.YoStarEN.AzurLane',
                          help='')

    debug = emulator_parser.add_argument_group('Debug settings', '')
    debug.add_argument(
        '--enable_error_log_and_screenshot_save',
        default=default('--enable_error_log_and_screenshot_save'),
        choices=['yes', 'no'])
    debug.add_argument(
        '--enable_perspective_error_image_save',
        default=default('--enable_perspective_error_image_save'),
        choices=['yes', 'no'])

    adb = emulator_parser.add_argument_group('ADB settings', '')
    adb.add_argument('--device_screenshot_method',
                     default=default('--device_screenshot_method'),
                     choices=['aScreenCap', 'uiautomator2', 'ADB'],
                     help='Speed: aScreenCap >> uiautomator2 > ADB')
    adb.add_argument('--device_control_method',
                     default=default('--device_control_method'),
                     choices=['uiautomator2', 'ADB'],
                     help='Speed: uiautomator2 >> ADB')
    adb.add_argument(
        '--combat_screenshot_interval',
        default=default('--combat_screenshot_interval'),
        help='Slow down the screenshot speed during battle and reduce CPU')

    update = emulator_parser.add_argument_group('ALAS Update Check', '')
    update.add_argument('--enable_update_check',
                        default=default('--enable_update_check'),
                        choices=['yes', 'no'])
    update.add_argument('--update_method',
                        default=default('--update_method'),
                        choices=['api', 'web'],
                        help='')
    update.add_argument(
        '--github_token',
        default=default('--github_token'),
        help='To generate your token visit https://github.com/settings/tokens')
    update.add_argument(
        '--update_proxy',
        default=default('--update_proxy'),
        help='Local http or socks proxy, example: http://127.0.0.1:10809')

    # ==========每日任务==========
    daily_parser = subs.add_parser('daily')

    # 选择每日
    daily = daily_parser.add_argument_group(
        'Choose daily', 'Daily tasks, exercises, difficulty charts')
    daily.add_argument('--enable_daily_mission',
                       default=default('--enable_daily_mission'),
                       help='If there are records on the day, skip',
                       choices=['yes', 'no'])
    daily.add_argument('--enable_hard_campaign',
                       default=default('--enable_hard_campaign'),
                       help='If there are records on the day, skip',
                       choices=['yes', 'no'])
    daily.add_argument('--enable_exercise',
                       default=default('--enable_exercise'),
                       help='If there is a record after refreshing, skip',
                       choices=['yes', 'no'])
    daily.add_argument('--enable_event_ab',
                       default=default('--enable_event_ab'),
                       help='If there is a record after refreshing, skip',
                       choices=['yes', 'no'])
    daily.add_argument('--enable_raid_daily',
                       default=default('--enable_raid_daily'),
                       help='If there is a record after refreshing, skip',
                       choices=['yes', 'no'])

    # 每日设置
    daily_task = daily_parser.add_argument_group(
        'Daily settings', 'Does not support submarine daily')
    daily_task.add_argument(
        '--tactical_training',
        default=default('--tactical_training'),
        choices=['daily_air', 'daily_gun', 'daily_torpedo'])
    daily_task.add_argument('--fierce_assault',
                            default=default('--fierce_assault'),
                            choices=['index_1', 'index_2', 'index_3'])
    daily_task.add_argument('--escort_mission',
                            default=default('--escort_mission'),
                            choices=['index_1', 'index_2', 'index_3'])
    daily_task.add_argument('--advance_mission',
                            default=default('--advance_mission'),
                            choices=['index_1', 'index_2', 'index_3'])
    daily_task.add_argument('--daily_fleet',
                            default=default('--daily_fleet'),
                            choices=['1', '2', '3', '4', '5', '6'])
    daily_task.add_argument(
        '--daily_equipment',
        default=default('--daily_equipment'),
        help=
        'Change equipment before playing, unload equipment after playing, do not need to fill in 0 \ncomma, such as 3, 1, 0, 1, 1, 0'
    )

    # 困难设置
    hard = daily_parser.add_argument_group(
        'Difficult setting',
        'Need to turn on weekly mode, only support 10-1, 10-2 and 10-4 temporarily'
    )
    hard.add_argument('--hard_campaign',
                      default=default('--hard_campaign'),
                      help='For example 10-4')
    hard.add_argument('--hard_fleet',
                      default=default('--hard_fleet'),
                      choices=['1', '2'])
    hard.add_argument(
        '--hard_equipment',
        default=default('--hard_equipment'),
        help=
        'Change equipment before playing, unload equipment after playing, do not need to fill in 0 \ncomma, such as 3, 1, 0, 1, 1, 0'
    )

    # 演习设置
    exercise = daily_parser.add_argument_group(
        'Exercise settings',
        'Only support the most experience for the time being')
    exercise.add_argument(
        '--exercise_choose_mode',
        default=default('--exercise_choose_mode'),
        choices=['max_exp', 'max_ranking', 'good_opponent', 'easiest'],
        help='Only support the most experience for the time being')
    exercise.add_argument('--exercise_preserve',
                          default=default('--exercise_preserve'),
                          help='Only 0 are temporarily reserved')
    exercise.add_argument('--exercise_try',
                          default=default('--exercise_try'),
                          help='The number of attempts by each opponent')
    exercise.add_argument('--exercise_hp_threshold',
                          default=default('--exercise_hp_threshold'),
                          help='HHP <Retreat at Threshold')
    exercise.add_argument(
        '--exercise_low_hp_confirm',
        default=default('--exercise_low_hp_confirm'),
        help=
        'After HP is below the threshold, it will retreat after a certain period of time \nRecommended 1.0 ~ 3.0'
    )
    exercise.add_argument(
        '--exercise_equipment',
        default=default('--exercise_equipment'),
        help=
        'Change equipment before playing, unload equipment after playing, do not need to fill in 0 \ncomma, such as 3, 1, 0, 1, 1, 0'
    )

    event_bonus = daily_parser.add_argument_group(
        'Event Daily Bonus', 'bonus for first clear each day')
    event_bonus.add_argument('--event_name_ab',
                             default=event_latest,
                             choices=event_folder,
                             help='There a dropdown menu with many options')

    # Raid daily
    raid_bonus = daily_parser.add_argument_group('Raid settings', '')
    raid_bonus.add_argument('--raid_daily_name',
                            default=raid_latest,
                            choices=[raid_latest],
                            help='')
    raid_bonus.add_argument('--raid_hard',
                            default=default('--raid_hard'),
                            choices=['yes', 'no'],
                            help='')
    raid_bonus.add_argument('--raid_normal',
                            default=default('--raid_normal'),
                            choices=['yes', 'no'],
                            help='')
    raid_bonus.add_argument('--raid_easy',
                            default=default('--raid_easy'),
                            choices=['yes', 'no'],
                            help='')

    # ==========event_daily_ab==========
    # event_ab_parser = subs.add_parser('event_daily_bonus')
    # event_name = event_ab_parser.add_argument_group('Choose an event', 'bonus for first clear each day')
    # event_name.add_argument('--event_name_ab', default=event_latest, choices=event_folder, help='There a dropdown menu with many options')
    # event_name.add_argument('--enable_hard_bonus', default=default('--enable_hard_bonus'), choices=['yes', 'no'], help='Will enable Daily bonus for Event hard maps') # Trying implement all event maps

    # ==========main==========
    main_parser = subs.add_parser('Main_campaign')
    # 选择关卡
    stage = main_parser.add_argument_group(
        'Choose a level',
        'Main campaign, Currently, not all maps are being supported, check the folder /doc/development_en.md to know how add new maps'
    )
    stage.add_argument('--main_stage',
                       default=default('--main_stage'),
                       help='E.g 7-2')
    stage.add_argument('--campaign_mode',
                       default=default('--campaign_mode'),
                       help='Useful if you want to clear a hard mode map',
                       choices=['normal', 'hard'])

    # ==========event==========
    event_parser = subs.add_parser('event')

    description = """
    Support "Iris of Light and Dark Rerun" (event_20200521_en), optimized for D2
    """
    event = event_parser.add_argument_group(
        'Choose a level',
        '\n'.join([line.strip() for line in description.strip().split('\n')]))
    event.add_argument('--event_stage',
                       default=default('--event_stage'),
                       choices=[
                           'a1', 'a2', 'a3', 'b1', 'b2', 'b3', 'c1', 'c2',
                           'c3', 'd1', 'd2', 'd3'
                       ],
                       help='E.g d3')
    event.add_argument('--sp_stage',
                       default=default('--sp_stage'),
                       choices=['sp1', 'sp2', 'sp3'],
                       help='E.g sp3')
    event.add_argument('--event_name',
                       default=event_latest,
                       choices=event_folder,
                       help='There a dropdown menu with many options')

    # ==========Raid==========
    raid_parser = subs.add_parser('raid')
    raid = raid_parser.add_argument_group('Choose a raid', '')
    raid.add_argument('--raid_name',
                      default=raid_latest,
                      choices=[raid_latest],
                      help='')
    raid.add_argument('--raid_mode',
                      default=default('--raid_mode'),
                      choices=['hard', 'normal', 'easy'],
                      help='')
    raid.add_argument('--raid_use_ticket',
                      default=default('--raid_use_ticket'),
                      choices=['yes', 'no'],
                      help='')

    # ==========半自动==========
    semi_parser = subs.add_parser('semi_auto')
    semi = semi_parser.add_argument_group(
        'Semi-automatic mode',
        'Manual selection of enemies, automatic settlement, used to attack unsuited pictures'
    )
    semi.add_argument('--enable_semi_map_preparation',
                      default=default('--enable_semi_map_preparation'),
                      help='',
                      choices=['yes', 'no'])
    semi.add_argument(
        '--enable_semi_story_skip',
        default=default('--enable_semi_story_skip'),
        help=
        'Note that this will automatically confirm all the prompt boxes, including the red face attack',
        choices=['yes', 'no'])

    # ==========c72_mystery_farming==========
    c_7_2_parser = subs.add_parser('c7-2_mystery_farming')
    c_7_2 = c_7_2_parser.add_argument_group('c72_mystery_farming', '')
    c_7_2.add_argument('--boss_fleet_step_on_a3',
                       default=default('--boss_fleet_step_on_a3'),
                       choices=['yes', 'no'],
                       help='A3 has enemies, G3, C3, E3')

    # ==========c122_leveling==========
    c_12_2_parser = subs.add_parser('c12-2_leveling')
    c_12_2 = c_12_2_parser.add_argument_group('12-2 enemy search settings', '')
    c_12_2.add_argument(
        '--s3_enemy_tolerance',
        default=default('--s3_enemy_tolerance'),
        choices=['0', '1', '2', '10'],
        help='The maximum number of battles to fight against large enemies')

    # ==========c124_leveling==========
    c_12_4_parser = subs.add_parser('c12-4_leveling')
    c_12_4 = c_12_4_parser.add_argument_group(
        '12-4 Search enemy settings',
        'Need to ensure that the team has a certain strength')
    c_12_4.add_argument('--non_s3_enemy_enter_tolerance',
                        default=default('--non_s3_enemy_enter_tolerance'),
                        choices=['0', '1', '2'],
                        help='Avoid enemy too strong')
    c_12_4.add_argument(
        '--non_s3_enemy_withdraw_tolerance',
        default=default('--non_s3_enemy_withdraw_tolerance'),
        choices=['0', '1', '2', '10'],
        help='How many battles will be fought after there is no large scale')
    c_12_4.add_argument('--ammo_pick_up_124',
                        default=default('--ammo_pick_up_124'),
                        choices=['2', '3', '4', '5'],
                        help='How much ammunition to pick after the battle')

    args = parser.parse_args()

    # Convert option from chinese to english.
    out = {}
    for key, value in vars(args).items():
        key = dic_true_eng_to_eng.get(key, key)
        value = dic_true_eng_to_eng.get(value, value)
        out[key] = value
    args = out

    # Update option to .ini file.
    command = args['command'].capitalize()
    config['Command']['command'] = command
    for key, value in args.items():
        config[command][key] = str(value)
    config.write(codecs.open(config_file, "w+", "utf8"))

    # Call AzurLaneAutoScript
    alas = AzurLaneAutoScript(ini_name=ini_name)
    alas.run(command=command)
def main(ini_name=''):
    if not ini_name:
        ini_name = pyw_name
    config_file = f'./config/{ini_name}.ini'
    config = get_config(ini_name.lower())

    # Load translation dictionary
    dic_gui_to_ini = dic_chi_to_eng  # GUI translation dictionary here.
    dic_gui_to_ini.update(dic_event[server.server])
    dic_ini_to_gui = {v: k for k, v in dic_gui_to_ini.items()}
    # Event list
    event_folder = [
        f for f in dic_event[server.server].values() if f.startswith('event_')
    ]
    event_latest = sorted([f for f in event_folder], reverse=True)[0]
    event_folder = [dic_ini_to_gui.get(f, f) for f in event_folder][::-1]
    event_latest = dic_ini_to_gui.get(event_latest, event_latest)
    # Raid list
    raid_folder = [
        f for f in dic_event[server.server].values() if f.startswith('raid_')
    ]
    raid_latest = sorted([f for f in raid_folder], reverse=True)[0]
    raid_folder = [dic_ini_to_gui.get(f, f) for f in raid_folder][::-1]
    raid_latest = dic_ini_to_gui.get(raid_latest, raid_latest)
    # Research preset list
    research_preset = [
        dic_ini_to_gui.get(f, f)
        for f in ['customized'] + list(DICT_FILTER_PRESET.keys())
    ]
    # Translate settings in ini file
    saved_config = {}
    for opt, option in config.items():
        for key, value in option.items():
            key = dic_ini_to_gui.get(key, key)
            if value in dic_ini_to_gui:
                value = dic_ini_to_gui.get(value, value)
            if value == 'None':
                value = ''
            saved_config[key] = value
    message = ('蓝叠模拟器:\t127.0.0.1:5555\n'
               '夜神模拟器:\t127.0.0.1:62001\n'
               'MuMu模拟器:\t127.0.0.1:7555\n'
               '逍遥模拟器:\t127.0.0.1:21503\n'
               '雷电模拟器:\temulator-5554\n')

    def default(name):
        """Get default value in .ini file.
        Args:
            name (str): option, in chinese.

        Returns:
            str: Default value, in chinese.
        """
        name = name.strip('-')
        return saved_config.get(name, '')

    def choice_list(total):
        return [str(index) for index in range(1, total + 1)]

    # Don't use checkbox in gooey, use drop box instead.
    # https://github.com/chriskiehl/Gooey/issues/148
    # https://github.com/chriskiehl/Gooey/issues/485

    parser = GooeyParser(
        description=
        f'AzurLaneAutoScript, An Azur Lane automation tool. Config: {config_file}\n功能都是分别保存和运行的, 修改设置后别忘了点击"开始"来保存'
    )
    subs = parser.add_subparsers(help='commands', dest='command')

    # ==========出击设置==========
    setting_parser = subs.add_parser('出击设置')

    # 选择关卡
    stage = setting_parser.add_argument_group(
        '关卡设置', '需要运行一次来保存选项', gooey_options={'label_color': '#931D03'})
    stage.add_argument('--启用停止条件',
                       default=default('--启用停止条件'),
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--启用异常处理',
                       default=default('--启用异常处理'),
                       choices=['是', '否'],
                       help='处理部分异常, 运行出错时撤退',
                       gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--使用周回模式',
                       default=default('--使用周回模式'),
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})

    stop = stage.add_argument_group('停止条件',
                                    '触发后不会马上停止会先完成当前出击, 不需要就填0',
                                    gooey_options={'label_color': '#931D03'})
    stop.add_argument('--如果出击次数大于',
                      default=default('--如果出击次数大于'),
                      help='会沿用先前设置, 完成出击将扣除次数, 直至清零',
                      gooey_options={'label_color': '#4B5F83'})
    stop.add_argument(
        '--如果时间超过',
        default=default('--如果时间超过'),
        help='使用未来24小时内的时间, 会沿用先前设置, 触发后清零. 建议提前10分钟左右, 以完成当前出击. 格式 14:59',
        gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果石油低于',
                      default=default('--如果石油低于'),
                      gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果地图开荒',
                      default=default('--如果地图开荒'),
                      choices=['否', '地图通关', '地图三星', '地图绿海不打三星', '地图绿海'],
                      help='如果已经满足, 无视此设置',
                      gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果触发心情控制',
                      default=default('--如果触发心情控制'),
                      choices=['是', '否'],
                      help='若是, 等待回复, 完成本次, 停止\n若否, 等待回复, 完成本次, 继续',
                      gooey_options={'label_color': '#4B5F83'})
    # stop.add_argument('--如果船舱已满', default=default('--如果船舱已满'), choices=['是', '否'])

    # 出击舰队
    fleet = setting_parser.add_argument_group(
        '出击舰队',
        '暂不支持备用道中队, 非活动图或周回模式会忽略步长设置',
        gooey_options={'label_color': '#931D03'})
    fleet.add_argument('--启用舰队控制',
                       default=default('--启用舰队控制'),
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    fleet.add_argument('--启用阵容锁定',
                       default=default('--启用阵容锁定'),
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})

    f1 = fleet.add_argument_group('道中队',
                                  gooey_options={'label_color': '#931D03'})
    f1.add_argument('--舰队编号1',
                    default=default('--舰队编号1'),
                    choices=['1', '2', '3', '4', '5', '6'],
                    gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--舰队阵型1',
                    default=default('--舰队阵型1'),
                    choices=['单纵阵', '复纵阵', '轮形阵'],
                    gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--自律模式1',
                    default=default('--自律模式1'),
                    choices=['自律', '手操', '中路站桩', '躲左下角'],
                    gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--舰队步长1',
                    default=default('--舰队步长1'),
                    choices=['1', '2', '3', '4', '5', '6'],
                    gooey_options={'label_color': '#4B5F83'})

    f2 = fleet.add_argument_group('BOSS队',
                                  gooey_options={'label_color': '#931D03'})
    f2.add_argument('--舰队编号2',
                    default=default('--舰队编号2'),
                    choices=['不使用', '1', '2', '3', '4', '5', '6'],
                    gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--舰队阵型2',
                    default=default('--舰队阵型2'),
                    choices=['单纵阵', '复纵阵', '轮形阵'],
                    gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--自律模式2',
                    default=default('--自律模式2'),
                    choices=['自律', '手操', '中路站桩', '躲左下角'],
                    gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--舰队步长2',
                    default=default('--舰队步长2'),
                    choices=['1', '2', '3', '4', '5', '6'],
                    gooey_options={'label_color': '#4B5F83'})

    f3 = fleet.add_argument_group('备用道中队',
                                  gooey_options={'label_color': '#931D03'})
    f3.add_argument('--舰队编号3',
                    default=default('--舰队编号3'),
                    choices=['不使用', '1', '2', '3', '4', '5', '6'],
                    gooey_options={'label_color': '#4B5F83'})
    f3.add_argument('--舰队阵型3',
                    default=default('--舰队阵型3'),
                    choices=['单纵阵', '复纵阵', '轮形阵'],
                    gooey_options={'label_color': '#4B5F83'})
    f3.add_argument('--自律模式3',
                    default=default('--自律模式3'),
                    choices=['自律', '手操', '中路站桩', '躲左下角'],
                    gooey_options={'label_color': '#4B5F83'})
    f3.add_argument('--舰队步长3',
                    default=default('--舰队步长3'),
                    choices=['1', '2', '3', '4', '5', '6'],
                    gooey_options={'label_color': '#4B5F83'})

    # 潜艇设置
    submarine = setting_parser.add_argument_group(
        '潜艇设置',
        '仅支持: 不使用, 仅狩猎, 每战出击',
        gooey_options={'label_color': '#931D03'})
    submarine.add_argument('--舰队编号4',
                           default=default('--舰队编号4'),
                           choices=['不使用', '1', '2'],
                           gooey_options={'label_color': '#4B5F83'})
    submarine.add_argument(
        '--潜艇出击方案',
        default=default('--潜艇出击方案'),
        choices=['不使用', '仅狩猎', '每战出击', '空弹出击', 'BOSS战出击', 'BOSS战BOSS出现后召唤'],
        gooey_options={'label_color': '#4B5F83'})

    # 心情控制
    emotion = setting_parser.add_argument_group(
        '心情控制', gooey_options={'label_color': '#931D03'})
    emotion.add_argument('--启用心情消耗',
                         default=default('--启用心情消耗'),
                         choices=['是', '否'],
                         gooey_options={'label_color': '#4B5F83'})
    emotion.add_argument('--无视红脸出击警告',
                         default=default('--无视红脸出击警告'),
                         choices=['是', '否'],
                         gooey_options={'label_color': '#4B5F83'})

    e1 = emotion.add_argument_group('道中队',
                                    gooey_options={'label_color': '#931D03'})
    e1.add_argument('--心情回复1',
                    default=default('--心情回复1'),
                    choices=['未放置于后宅', '后宅一楼', '后宅二楼'],
                    gooey_options={'label_color': '#4B5F83'})
    e1.add_argument('--心情控制1',
                    default=default('--心情控制1'),
                    choices=['保持经验加成', '防止绿脸', '防止黄脸', '防止红脸'],
                    gooey_options={'label_color': '#4B5F83'})
    e1.add_argument('--全员已婚1',
                    default=default('--全员已婚1'),
                    choices=['是', '否'],
                    gooey_options={'label_color': '#4B5F83'})

    e2 = emotion.add_argument_group('BOSS队',
                                    gooey_options={'label_color': '#931D03'})
    e2.add_argument('--心情回复2',
                    default=default('--心情回复2'),
                    choices=['未放置于后宅', '后宅一楼', '后宅二楼'],
                    gooey_options={'label_color': '#4B5F83'})
    e2.add_argument('--心情控制2',
                    default=default('--心情控制2'),
                    choices=['保持经验加成', '防止绿脸', '防止黄脸', '防止红脸'],
                    gooey_options={'label_color': '#4B5F83'})
    e2.add_argument('--全员已婚2',
                    default=default('--全员已婚2'),
                    choices=['是', '否'],
                    gooey_options={'label_color': '#4B5F83'})

    e3 = emotion.add_argument_group('备用道中队',
                                    '会在主队触发心情控制时使用',
                                    gooey_options={'label_color': '#931D03'})
    e3.add_argument('--心情回复3',
                    default=default('--心情回复3'),
                    choices=['未放置于后宅', '后宅一楼', '后宅二楼'],
                    gooey_options={'label_color': '#4B5F83'})
    e3.add_argument('--心情控制3',
                    default=default('--心情控制3'),
                    choices=['保持经验加成', '防止绿脸', '防止黄脸', '防止红脸'],
                    gooey_options={'label_color': '#4B5F83'})
    e3.add_argument('--全员已婚3',
                    default=default('--全员已婚3'),
                    choices=['是', '否'],
                    gooey_options={'label_color': '#4B5F83'})

    # 血量平衡
    hp = setting_parser.add_argument_group(
        '血量控制', '需关闭舰队锁定才能生效', gooey_options={'label_color': '#931D03'})
    hp.add_argument('--启用血量平衡',
                    default=default('--启用血量平衡'),
                    choices=['是', '否'],
                    gooey_options={'label_color': '#4B5F83'})
    hp.add_argument('--启用低血量撤退',
                    default=default('--启用低血量撤退'),
                    choices=['是', '否'],
                    gooey_options={'label_color': '#4B5F83'})
    hp_balance = hp.add_argument_group(
        '血量平衡', '', gooey_options={'label_color': '#4B5F83'})
    hp_balance.add_argument('--先锋血量平衡阈值',
                            default=default('--先锋血量平衡阈值'),
                            help='血量差值大于阈值时, 换位',
                            gooey_options={'label_color': '#4B5F83'})
    hp_balance.add_argument('--先锋血量权重',
                            default=default('--先锋血量权重'),
                            help='先锋肉度有差别时应修改, 格式 1000,1000,1000',
                            gooey_options={'label_color': '#4B5F83'})
    hp_add = hp.add_argument_group('紧急维修',
                                   '',
                                   gooey_options={'label_color': '#4B5F83'})
    hp_add.add_argument('--紧急维修单人阈值',
                        default=default('--紧急维修单人阈值'),
                        help='单人低于阈值时使用',
                        gooey_options={'label_color': '#4B5F83'})
    hp_add.add_argument('--紧急维修全队阈值',
                        default=default('--紧急维修全队阈值'),
                        help='前排全部或后排全部低于阈值时使用',
                        gooey_options={'label_color': '#4B5F83'})
    hp_withdraw = hp.add_argument_group(
        '低血量撤退', '', gooey_options={'label_color': '#4B5F83'})
    hp_withdraw.add_argument('--低血量撤退阈值',
                             default=default('--低血量撤退阈值'),
                             help='任意一人血量低于阈值时, 撤退',
                             gooey_options={'label_color': '#4B5F83'})

    # 退役选项
    retire = setting_parser.add_argument_group(
        '退役设置', '', gooey_options={'label_color': '#931D03'})
    retire.add_argument('--启用退役',
                        default=default('--启用退役'),
                        choices=['是', '否'],
                        gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--退役方案',
                        default=default('--退役方案'),
                        choices=['强化角色', '一键退役', '传统退役'],
                        gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--退役数量',
                        default=default('--退役数量'),
                        choices=['退役全部', '退役10个'],
                        gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--强化常用角色',
                        default=default('--强化常用角色'),
                        choices=['是', '否'],
                        gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--强化过滤字符串',
                        default=default('--强化过滤字符串'),
                        help='格式: "cv > bb > ...", 留空则使用默认强化方式',
                        gooey_options={'label_color': '#4B5F83'})

    rarity = retire.add_argument_group(
        '退役稀有度',
        '暂不支持舰种选择, 使用一键退役时忽略以下选项',
        gooey_options={'label_color': '#931D03'})
    rarity.add_argument('--退役白皮',
                        default=default('--退役白皮'),
                        choices=['是', '否'],
                        help='N',
                        gooey_options={'label_color': '#4B5F83'})
    rarity.add_argument('--退役蓝皮',
                        default=default('--退役蓝皮'),
                        choices=['是', '否'],
                        help='R',
                        gooey_options={'label_color': '#4B5F83'})
    rarity.add_argument('--退役紫皮',
                        default=default('--退役紫皮'),
                        choices=['是', '否'],
                        help='SR',
                        gooey_options={'label_color': '#4B5F83'})
    rarity.add_argument('--退役金皮',
                        default=default('--退役金皮'),
                        choices=['是', '否'],
                        help='SSR',
                        gooey_options={'label_color': '#4B5F83'})

    # 掉落记录
    drop = setting_parser.add_argument_group(
        '掉落记录',
        '保存掉落物品的截图, 启用后会放缓结算时的点击速度',
        gooey_options={'label_color': '#931D03'})
    drop.add_argument('--启用掉落记录',
                      default=default('--启用掉落记录'),
                      choices=['是', '否'],
                      gooey_options={'label_color': '#4B5F83'})
    drop.add_argument('--掉落保存目录',
                      default=default('--掉落保存目录'),
                      gooey_options={'label_color': '#4B5F83'})

    # clear = setting_parser.add_argument_group('开荒模式', '未开荒地图会在完成后停止, 已开荒的地图会忽略选项, 无脑开就完事了')
    # clear.add_argument('--启用开荒', default=default('--启用开荒'), choices=['是', '否'])
    # clear.add_argument('--开荒停止条件', default=default('--开荒停止条件'), choices=['地图通关', '地图三星', '地图绿海'])
    # clear.add_argument('--地图全清星星', default=default('--地图全清星星'), choices=['第一个', '第二个', '第三个', '不使用'], help='第几颗星星是击破所有敌舰')

    # ==========收菜设置==========
    reward_parser = subs.add_parser('收菜设置')
    reward_condition = reward_parser.add_argument_group(
        '触发条件',
        '需要运行一次来保存选项, 运行后会进入挂机收菜模式',
        gooey_options={'label_color': '#931D03'})
    reward_condition.add_argument('--启用收获',
                                  default=default('--启用收获'),
                                  choices=['是', '否'],
                                  gooey_options={'label_color': '#4B5F83'})
    reward_condition.add_argument('--收菜间隔',
                                  default=default('--收菜间隔'),
                                  help='每隔多少分钟触发收菜, 推荐使用时间区间, 比如"10, 40"',
                                  gooey_options={'label_color': '#4B5F83'})
    reward_condition.add_argument('--收菜间隔关闭游戏',
                                  default=default('--收菜间隔关闭游戏'),
                                  choices=['是', '否'],
                                  gooey_options={'label_color': '#4B5F83'})
    reward_condition.add_argument('--启用每日收获',
                                  default=default('--启用每日收获'),
                                  choices=['是', '否'],
                                  help='将每日任务困难演习作为收获的一部分来运行',
                                  gooey_options={'label_color': '#4B5F83'})

    reward_oil = reward_parser.add_argument_group(
        '石油物资', '', gooey_options={'label_color': '#931D03'})
    reward_oil.add_argument('--启用石油收获',
                            default=default('--启用石油收获'),
                            choices=['是', '否'],
                            gooey_options={'label_color': '#4B5F83'})
    reward_oil.add_argument('--启用物资收获',
                            default=default('--启用物资收获'),
                            choices=['是', '否'],
                            gooey_options={'label_color': '#4B5F83'})

    reward_mission = reward_parser.add_argument_group(
        '任务奖励', '', gooey_options={'label_color': '#931D03'})
    reward_mission.add_argument('--启用任务收获',
                                default=default('--启用任务收获'),
                                choices=['是', '否'],
                                gooey_options={'label_color': '#4B5F83'})

    reward_commission = reward_parser.add_argument_group(
        '委托设置', '', gooey_options={'label_color': '#931D03'})
    reward_commission.add_argument('--启用委托收获',
                                   default=default('--启用委托收获'),
                                   choices=['是', '否'],
                                   gooey_options={'label_color': '#4B5F83'})
    reward_commission.add_argument('--委托时间限制',
                                   default=default('--委托时间限制'),
                                   help='忽略完成时间超过限制的委托, 格式: 23:30, 不需要就填0',
                                   gooey_options={'label_color': '#4B5F83'})

    priority1 = reward_commission.add_argument_group(
        '委托耗时优先级', '', gooey_options={'label_color': '#931D03'})
    priority1.add_argument('--委托耗时小于2h',
                           default=default('--委托耗时小于2h'),
                           help='',
                           gooey_options={'label_color': '#4B5F83'})
    priority1.add_argument('--委托耗时超过6h',
                           default=default('--委托耗时超过6h'),
                           help='',
                           gooey_options={'label_color': '#4B5F83'})
    priority1.add_argument('--委托过期小于2h',
                           default=default('--委托过期小于2h'),
                           help='',
                           gooey_options={'label_color': '#4B5F83'})
    priority1.add_argument('--委托过期大于6h',
                           default=default('--委托过期大于6h'),
                           help='',
                           gooey_options={'label_color': '#4B5F83'})

    priority2 = reward_commission.add_argument_group(
        '日常委托优先级', '', gooey_options={'label_color': '#931D03'})
    priority2.add_argument('--日常委托',
                           default=default('--日常委托'),
                           help='日常资源开发, 高阶战术研发',
                           gooey_options={'label_color': '#4B5F83'})
    priority2.add_argument('--主要委托',
                           default=default('--主要委托'),
                           help='1200油/1000油委托',
                           gooey_options={'label_color': '#4B5F83'})

    priority3 = reward_commission.add_argument_group(
        '额外委托优先级', '', gooey_options={'label_color': '#931D03'})
    priority3.add_argument('--钻头类额外委托',
                           default=default('--钻头类额外委托'),
                           help='短距离航行训练, 近海防卫巡逻',
                           gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--部件类额外委托',
                           default=default('--部件类额外委托'),
                           help='矿脉护卫委托, 林木护卫委托',
                           gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--魔方类额外委托',
                           default=default('--魔方类额外委托'),
                           help='舰队高阶演习, 舰队护卫演习',
                           gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--石油类额外委托',
                           default=default('--石油类额外委托'),
                           help='小型油田开发, 大型油田开发',
                           gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--教材类额外委托',
                           default=default('--教材类额外委托'),
                           help='小型商船护卫, 大型商船护卫',
                           gooey_options={'label_color': '#4B5F83'})

    priority4 = reward_commission.add_argument_group(
        '紧急委托优先级', '', gooey_options={'label_color': '#931D03'})
    priority4.add_argument('--钻头类紧急委托',
                           default=default('--钻头类紧急委托'),
                           help='保卫运输部队, 歼灭敌精锐部队',
                           gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--部件类紧急委托',
                           default=default('--部件类紧急委托'),
                           help='支援维拉维拉岛, 支援恐班纳',
                           gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--魔方类紧急委托',
                           default=default('--魔方类紧急委托'),
                           help='解救商船, 敌袭',
                           gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--教材类紧急委托',
                           default=default('--教材类紧急委托'),
                           help='支援土豪尔岛, 支援萌岛',
                           gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--装备类紧急委托',
                           default=default('--装备类紧急委托'),
                           help='BIW装备运输, NYB装备研发',
                           gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--钻石类紧急委托',
                           default=default('--钻石类紧急委托'),
                           help='BIW要员护卫, NYB巡视护卫',
                           gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--观舰类紧急委托',
                           default=default('--观舰类紧急委托'),
                           help='小型观舰仪式, 同盟观舰仪式',
                           gooey_options={'label_color': '#4B5F83'})

    reward_tactical = reward_parser.add_argument_group(
        '战术学院', '只支持续技能书, 不支持学新技能', gooey_options={'label_color': '#931D03'})
    reward_tactical.add_argument('--启用战术学院收获',
                                 default=default('--启用战术学院收获'),
                                 choices=['是', '否'],
                                 gooey_options={'label_color': '#4B5F83'})
    # reward_tactical.add_argument('--战术学院夜间时段', default=default('--战术学院夜间时段'), help='格式 23:30-06:30')
    reward_tactical.add_argument('--技能书优先使用同类型',
                                 default=default('--技能书优先使用同类型'),
                                 choices=['是', '否'],
                                 help='选是, 优先使用有150%加成的\n选否, 优先使用同稀有度的技能书',
                                 gooey_options={'label_color': '#4B5F83'})
    reward_tactical.add_argument(
        '--技能书最大稀有度',
        default=default('--技能书最大稀有度'),
        choices=['3', '2', '1'],
        help='最高使用T几的技能书\nT3是金书, T2是紫书, T1是蓝书\n最大值需要大于等于最小值',
        gooey_options={'label_color': '#4B5F83'})
    reward_tactical.add_argument('--技能书最小稀有度',
                                 default=default('--技能书最小稀有度'),
                                 choices=['3', '2', '1'],
                                 help='最低使用T几的技能书\n',
                                 gooey_options={'label_color': '#4B5F83'})
    # reward_tactical.add_argument('--技能书夜间稀有度', default=default('--技能书夜间稀有度'), choices=['3', '2', '1'])
    # reward_tactical.add_argument('--技能书夜间优先使用同类型', default=default('--技能书夜间优先使用同类型'), choices=['是', '否'])
    reward_tactical.add_argument('--如果无技能书可用',
                                 default=default('--如果无技能书可用'),
                                 choices=['停止学习', '使用第一本'],
                                 gooey_options={'label_color': '#4B5F83'})

    reward_research = reward_parser.add_argument_group(
        '科研项目',
        '科研预设选择为自定义时, 须先阅读 doc/filter_string_en_cn.md',
        gooey_options={'label_color': '#931D03'})
    reward_research.add_argument('--启用科研项目收获',
                                 default=default('--启用科研项目收获'),
                                 choices=['是', '否'],
                                 gooey_options={'label_color': '#4B5F83'})
    research_input = reward_research.add_argument_group(
        '科研投入', '', gooey_options={'label_color': '#931D03'})
    research_input.add_argument('--科研项目使用魔方',
                                default=default('--科研项目使用魔方'),
                                choices=['是', '否'],
                                gooey_options={'label_color': '#4B5F83'})
    research_input.add_argument('--科研项目使用金币',
                                default=default('--科研项目使用金币'),
                                choices=['是', '否'],
                                gooey_options={'label_color': '#4B5F83'})
    research_input.add_argument('--科研项目使用部件',
                                default=default('--科研项目使用部件'),
                                choices=['是', '否'],
                                gooey_options={'label_color': '#4B5F83'})
    research_output = reward_research.add_argument_group(
        '科研产出', '', gooey_options={'label_color': '#931D03'})
    research_output.add_argument('--科研项目选择预设',
                                 default=default('--科研项目选择预设'),
                                 choices=research_preset,
                                 gooey_options={'label_color': '#4B5F83'})
    research_output.add_argument('--科研过滤字符串',
                                 default=default('--科研过滤字符串'),
                                 help='仅在科研预设选择为自定义时启用',
                                 gooey_options={'label_color': '#4B5F83'})

    reward_buy = reward_parser.add_argument_group(
        '商店购买', '如果已经买过则自动跳过', gooey_options={'label_color': '#931D03'})
    reward_buy.add_argument('--买指挥喵',
                            default=default('--买指挥喵'),
                            help='从0到15, 不需要就填0',
                            gooey_options={'label_color': '#4B5F83'})

    # ==========设备设置==========
    emulator_parser = subs.add_parser('设备设置')
    emulator = emulator_parser.add_argument_group(
        '模拟器',
        '需要运行一次来保存选项, 会检查游戏是否启动\n若启动了游戏, 触发一次收菜',
        gooey_options={'label_color': '#931D03'})
    emulator.add_argument('--设备',
                          default=default('--设备'),
                          help='例如 127.0.0.1:62001',
                          gooey_options={'label_color': '#4B5F83'})
    emulator.add_argument('--包名',
                          default=default('--包名'),
                          help='',
                          gooey_options={'label_color': '#4B5F83'})
    emulator.add_argument(
        '默认serial列表',
        default=message,
        widget='Textarea',
        help="以下是一些常见模拟器的默认serial\n如果你使用了模拟器多开, 它们将不使用默认的serial",
        gooey_options={
            'height': 150,
            'show_help': True,
            'show_label': True,
            'readonly': True,
            'label_color': '#4B5F83'
        })

    debug = emulator_parser.add_argument_group(
        '调试设置', '', gooey_options={'label_color': '#931D03'})
    debug.add_argument('--出错时保存log和截图',
                       default=default('--出错时保存log和截图'),
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    debug.add_argument('--保存透视识别出错的图像',
                       default=default('--保存透视识别出错的图像'),
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})

    adb = emulator_parser.add_argument_group(
        'ADB设置', '', gooey_options={'label_color': '#931D03'})
    adb.add_argument('--设备截图方案',
                     default=default('--设备截图方案'),
                     choices=['aScreenCap', 'uiautomator2', 'ADB'],
                     help='速度: aScreenCap >> uiautomator2 > ADB',
                     gooey_options={'label_color': '#4B5F83'})
    adb.add_argument('--设备控制方案',
                     default=default('--设备控制方案'),
                     choices=['minitouch', 'uiautomator2', 'ADB'],
                     help='速度: minitouch >> uiautomator2 >> ADB',
                     gooey_options={'label_color': '#4B5F83'})
    adb.add_argument('--战斗中截图间隔',
                     default=default('--战斗中截图间隔'),
                     help='战斗中放慢截图速度, 降低CPU使用',
                     gooey_options={'label_color': '#4B5F83'})

    update = emulator_parser.add_argument_group(
        '更新检查', '', gooey_options={'label_color': '#931D03'})
    update.add_argument('--启用更新检查',
                        default=default('--启用更新检查'),
                        choices=['是', '否'],
                        gooey_options={'label_color': '#4B5F83'})
    update.add_argument('--更新检查方法',
                        default=default('--更新检查方法'),
                        choices=['api', 'web'],
                        help='使用api时建议填写tokens, 使用web则不需要',
                        gooey_options={'label_color': '#4B5F83'})
    update.add_argument(
        '--github_token',
        default=default('--github_token'),
        help='Github API限制为每小时60次, 获取tokens https://github.com/settings/tokens',
        gooey_options={'label_color': '#4B5F83'})
    update.add_argument(
        '--更新检查代理',
        default=default('--更新检查代理'),
        help=
        '本地http或socks代理, 如果github很慢, 请使用代理, example: http://127.0.0.1:10809',
        gooey_options={'label_color': '#4B5F83'})

    # ==========每日任务==========
    daily_parser = subs.add_parser('每日任务困难演习')

    # 选择每日
    daily = daily_parser.add_argument_group(
        '选择每日', '每日任务, 演习, 困难图', gooey_options={'label_color': '#931D03'})
    daily.add_argument('--打每日',
                       default=default('--打每日'),
                       help='若当天有记录, 则跳过',
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打困难',
                       default=default('--打困难'),
                       help='若当天有记录, 则跳过',
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打演习',
                       default=default('--打演习'),
                       help='若在刷新后有记录, 则跳过',
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打共斗每日15次',
                       default=default('--打共斗每日15次'),
                       help='若当天有记录, 则跳过',
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打活动图每日三倍PT',
                       default=default('--打活动图每日三倍PT'),
                       help='若当天有记录, 则跳过',
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打活动每日SP图',
                       default=default('--打活动每日SP图'),
                       help='若当天有记录, 则跳过',
                       choices=['是', '否'],
                       gooey_options={'label_color': '#4B5F83'})

    # 每日设置
    daily_task = daily_parser.add_argument_group(
        '每日设置', '不支持潜艇每日', gooey_options={'label_color': '#931D03'})
    daily_task.add_argument('--战术研修',
                            default=default('--战术研修'),
                            choices=['航空', '炮击', '雷击'],
                            gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--斩首行动',
                            default=default('--斩首行动'),
                            choices=['第一个', '第二个', '第三个'],
                            gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--商船护航',
                            default=default('--商船护航'),
                            choices=['第一个', '第二个', '第三个'],
                            gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--海域突进',
                            default=default('--海域突进'),
                            choices=['第一个', '第二个', '第三个'],
                            gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument(
        '--每日舰队',
        default=default('--每日舰队'),
        help=
        '如果使用同一队, 填舰队编号, 例如 5\n如果使用不同队, 用逗号分割, 顺序为商船护送, 海域突进, 斩首行动, 战术研修\n例如 5, 5, 5, 6',
        gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument(
        '--每日舰队快速换装',
        default=default('--每日舰队快速换装'),
        help='打之前换装备, 打完后卸装备, 不需要就填0\n逗号分割, 例如 3, 1, 0, 1, 1, 0',
        gooey_options={'label_color': '#4B5F83'})

    # 困难设置
    hard = daily_parser.add_argument_group(
        '困难设置',
        '需要开启周回模式, 暂时仅支持 10-4',
        gooey_options={'label_color': '#931D03'})
    hard.add_argument('--困难地图',
                      default=default('--困难地图'),
                      help='比如 10-4',
                      gooey_options={'label_color': '#4B5F83'})
    hard.add_argument('--困难舰队',
                      default=default('--困难舰队'),
                      choices=['1', '2'],
                      gooey_options={'label_color': '#4B5F83'})
    hard.add_argument('--困难舰队快速换装',
                      default=default('--困难舰队快速换装'),
                      help='打之前换装备, 打完后卸装备, 不需要就填0\n逗号分割, 例如 3, 1, 0, 1, 1, 0',
                      gooey_options={'label_color': '#4B5F83'})

    # 演习设置
    exercise = daily_parser.add_argument_group(
        '演习设置', '', gooey_options={'label_color': '#931D03'})
    exercise.add_argument('--演习对手选择',
                          default=default('--演习对手选择'),
                          choices=['经验最多', '最简单', '先最简单再经验最多'],
                          help='',
                          gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演习次数保留',
                          default=default('--演习次数保留'),
                          help='暂时仅支持保留0个',
                          gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演习尝试次数',
                          default=default('--演习尝试次数'),
                          help='每个对手的尝试次数, 打不过就换',
                          gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演习SL阈值',
                          default=default('--演习SL阈值'),
                          help='HP<阈值时撤退',
                          gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演习低血量确认时长',
                          default=default('--演习低血量确认时长'),
                          help='HP低于阈值后, 过一定时长才会撤退\n推荐 1.0 ~ 3.0',
                          gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument(
        '--演习快速换装',
        default=default('--演习快速换装'),
        help='打之前换装备, 打完后卸装备, 不需要就填0\n逗号分割, 例如 3, 1, 0, 1, 1, 0',
        gooey_options={'label_color': '#4B5F83'})

    # 每日活动图三倍PT
    event_bonus = daily_parser.add_argument_group(
        '活动设置', '', gooey_options={'label_color': '#931D03'})
    event_bonus.add_argument('--活动奖励章节',
                             default=default('--活动奖励章节'),
                             choices=['AB图', 'ABCD图'],
                             help='有额外PT奖励章节',
                             gooey_options={'label_color': '#4B5F83'})
    event_bonus.add_argument('--活动SP图道中队',
                             default=default('--活动SP图道中队'),
                             choices=['1', '2'],
                             help='',
                             gooey_options={'label_color': '#4B5F83'})
    event_bonus.add_argument('--活动名称ab',
                             default=event_latest,
                             choices=event_folder,
                             help='例如 event_20200326_cn',
                             gooey_options={'label_color': '#4B5F83'})

    # 共斗每日设置
    raid_bonus = daily_parser.add_argument_group(
        '共斗设置', '', gooey_options={'label_color': '#931D03'})
    raid_bonus.add_argument('--共斗每日名称',
                            default=raid_latest,
                            choices=raid_folder,
                            help='',
                            gooey_options={'label_color': '#4B5F83'})
    raid_bonus.add_argument('--共斗困难',
                            default=default('--共斗困难'),
                            choices=['是', '否'],
                            help='',
                            gooey_options={'label_color': '#4B5F83'})
    raid_bonus.add_argument('--共斗普通',
                            default=default('--共斗普通'),
                            choices=['是', '否'],
                            help='',
                            gooey_options={'label_color': '#4B5F83'})
    raid_bonus.add_argument('--共斗简单',
                            default=default('--共斗简单'),
                            choices=['是', '否'],
                            help='',
                            gooey_options={'label_color': '#4B5F83'})

    # # ==========每日活动图三倍PT==========
    # event_ab_parser = subs.add_parser('每日活动图三倍PT')
    # event_name = event_ab_parser.add_argument_group('选择活动', '')
    # event_name.add_argument('--活动名称ab', default=event_latest, choices=event_folder, help='例如 event_20200326_cn')

    # ==========主线图==========
    main_parser = subs.add_parser('主线图')
    # 选择关卡
    stage = main_parser.add_argument_group(
        '选择关卡', '', gooey_options={'label_color': '#931D03'})
    stage.add_argument('--主线地图出击',
                       default=default('--主线地图出击'),
                       help='例如 7-2',
                       gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--主线地图模式',
                       default=default('--主线地图模式'),
                       help='仅困难图开荒时使用, 周回模式后请使用每日困难',
                       choices=['普通', '困难'],
                       gooey_options={'label_color': '#4B5F83'})

    # ==========活动图==========
    event_parser = subs.add_parser('活动图')

    description = """
    出击未优化关卡或地图未达到安全海域时, 使用开荒模式运行(较慢)
    """
    event = event_parser.add_argument_group(
        '选择关卡',
        '\n'.join([line.strip() for line in description.strip().split('\n')]),
        gooey_options={'label_color': '#931D03'})
    event.add_argument('--活动地图',
                       default=default('--活动地图'),
                       choices=[
                           'A1', 'A2', 'A3', 'A4', 'B1', 'B2', 'B3', 'B4',
                           'C1', 'C2', 'C3', 'C4', 'D1', 'D2', 'D3', 'D4', 'SP'
                       ],
                       help='例如 D3',
                       gooey_options={'label_color': '#4B5F83'})
    event.add_argument('--sp地图',
                       default=default('--sp地图'),
                       choices=['SP1', 'SP2', 'SP3'],
                       help='例如 SP3',
                       gooey_options={'label_color': '#4B5F83'})
    event.add_argument('--活动名称',
                       default=event_latest,
                       choices=event_folder,
                       help='例如 event_20200312_cn',
                       gooey_options={'label_color': '#4B5F83'})

    # ==========共斗活动==========
    raid_parser = subs.add_parser('共斗活动')
    raid = raid_parser.add_argument_group(
        '选择共斗', '', gooey_options={'label_color': '#931D03'})
    raid.add_argument('--共斗名称',
                      default=raid_latest,
                      choices=raid_folder,
                      help='',
                      gooey_options={'label_color': '#4B5F83'})
    raid.add_argument('--共斗难度',
                      default=default('--共斗难度'),
                      choices=['困难', '普通', '简单'],
                      help='',
                      gooey_options={'label_color': '#4B5F83'})
    raid.add_argument('--共斗使用挑战券',
                      default=default('--共斗使用挑战券'),
                      choices=['是', '否'],
                      help='',
                      gooey_options={'label_color': '#4B5F83'})

    # ==========半自动==========
    semi_parser = subs.add_parser('半自动辅助点击')
    semi = semi_parser.add_argument_group(
        '半自动模式',
        '手动选敌, 自动结算, 用于出击未适配的图',
        gooey_options={'label_color': '#931D03'})
    semi.add_argument('--进图准备',
                      default=default('--进图准备'),
                      help='',
                      choices=['是', '否'],
                      gooey_options={'label_color': '#4B5F83'})
    semi.add_argument('--跳过剧情',
                      default=default('--跳过剧情'),
                      help='注意, 这会自动确认所有提示框, 包括红脸出击',
                      choices=['是', '否'],
                      gooey_options={'label_color': '#4B5F83'})

    # ==========1-1Affinity farming==========
    c_1_1_parser = subs.add_parser('1-1伏击刷好感')
    c_1_1 = c_1_1_parser.add_argument_group(
        '1-1伏击刷好感',
        '会自动关闭周回模式\n有MVP, 8场战斗涨1点好感, 无MVP, 16场战斗涨1点好感',
        gooey_options={'label_color': '#931D03'})
    c_1_1.add_argument('--刷好感战斗场数',
                       default=default('--刷好感战斗场数'),
                       help='例如: 32',
                       gooey_options={'label_color': '#4B5F83'})

    # ==========7-2三战拣垃圾==========
    c_7_2_parser = subs.add_parser('7-2三战拣垃圾')
    c_7_2 = c_7_2_parser.add_argument_group(
        '7-2三战拣垃圾', '', gooey_options={'label_color': '#931D03'})
    c_7_2.add_argument('--BOSS队踩A3',
                       default=default('--BOSS队踩A3'),
                       choices=['是', '否'],
                       help='A3有敌人就G3, C3, E3',
                       gooey_options={'label_color': '#4B5F83'})

    # ==========12-2打中型练级==========
    c_12_2_parser = subs.add_parser('12-2打中型练级')
    c_12_2 = c_12_2_parser.add_argument_group(
        '12-2索敌设置', '', gooey_options={'label_color': '#931D03'})
    c_12_2.add_argument('--大型敌人忍耐',
                        default=default('--大型敌人忍耐'),
                        choices=['0', '1', '2', '10'],
                        help='最多打多少战大型敌人, 不挑敌人选10',
                        gooey_options={'label_color': '#4B5F83'})

    # ==========12-4打大型练级==========
    c_12_4_parser = subs.add_parser('12-4打大型练级')
    c_12_4 = c_12_4_parser.add_argument_group(
        '12-4索敌设置', '需保证队伍有一定强度', gooey_options={'label_color': '#931D03'})
    c_12_4.add_argument('--非大型敌人进图忍耐',
                        default=default('--非大型敌人进图忍耐'),
                        choices=['0', '1', '2'],
                        help='忍受进场多少战没有大型',
                        gooey_options={'label_color': '#4B5F83'})
    c_12_4.add_argument('--非大型敌人撤退忍耐',
                        default=default('--非大型敌人撤退忍耐'),
                        choices=['0', '1', '2', '10'],
                        help='没有大型之后还会打多少战, 不挑敌人选10',
                        gooey_options={'label_color': '#4B5F83'})
    c_12_4.add_argument('--拣弹药124',
                        default=default('--拣弹药124'),
                        choices=['2', '3', '4', '5'],
                        help='多少战后拣弹药',
                        gooey_options={'label_color': '#4B5F83'})

    args = parser.parse_args()

    # Convert option from chinese to english.
    out = {}
    for key, value in vars(args).items():
        key = dic_gui_to_ini.get(key, key)
        value = dic_gui_to_ini.get(value, value)
        out[key] = value
    args = out

    # Update option to .ini file.
    command = args['command'].capitalize()
    config['Command']['command'] = command
    for key, value in args.items():
        config[command][key] = str(value)
    config.write(codecs.open(config_file, "w+", "utf8"))

    # Call AzurLaneAutoScript
    alas = AzurLaneAutoScript(ini_name=ini_name)
    alas.run(command=command)
Beispiel #4
0
 def load_config_file(self, name='alas'):
     self.CONFIG_FILE = f'./config/{name}.ini'
     self.config = get_config(ini_name=name)
     self.load_from_config(self.config)
     self.config_check()
def main(ini_name=''):
    if not ini_name:
        ini_name = pyw_name
    config_file = f'./config/{ini_name}.ini'
    config = get_config(ini_name.lower())

    # Load translation dictionary
    dic_gui_to_ini = dic_true_eng_to_eng  # GUI translation dictionary here.
    dic_gui_to_ini.update(dic_event[server.server])
    dic_ini_to_gui = {v: k for k, v in dic_gui_to_ini.items()}
    # Event list
    event_folder = [f for f in dic_event[server.server].values() if f.startswith('event_')]
    event_latest = sorted([f for f in event_folder], reverse=True)[0]
    event_folder = [dic_ini_to_gui.get(f, f) for f in event_folder][::-1]
    event_latest = dic_ini_to_gui.get(event_latest, event_latest)
    # Raid list
    raid_folder = [f for f in dic_event[server.server].values() if f.startswith('raid_')]
    raid_latest = sorted([f for f in raid_folder], reverse=True)[0]
    raid_folder = [dic_ini_to_gui.get(f, f) for f in raid_folder][::-1]
    raid_latest = dic_ini_to_gui.get(raid_latest, raid_latest)
    # Research preset list
    research_preset = [dic_ini_to_gui.get(f, f) for f in ['customized'] + list(DICT_FILTER_PRESET.keys())]
    # Translate settings in ini file
    saved_config = {}
    for opt, option in config.items():
        for key, value in option.items():
            key = dic_ini_to_gui.get(key, key)
            if value in dic_ini_to_gui:
                value = dic_ini_to_gui.get(value, value)
            if value == 'None':
                value = ''
            saved_config[key] = value
    message = (
        'BlueStacks:\t127.0.0.1:5555\n'
        'NoxPlayer:\t127.0.0.1:62001\n'
        'MuMuPlayer:\t127.0.0.1:7555\n'
        'MemuPlayer:\t127.0.0.1:21503\n'
        'LDPlayer:\t\temulator-5554\n'
    )

    def default(name):
        """Get default value in .ini file.
        Args:
            name (str): option, in chinese.

        Returns:
            str: Default value, in chinese.
        """
        name = name.strip('-')
        return saved_config.get(name, '')

    def choice_list(total):
        return [str(index) for index in range(1, total + 1)]

    # Don't use checkbox in gooey, use drop box instead.
    # https://github.com/chriskiehl/Gooey/issues/148
    # https://github.com/chriskiehl/Gooey/issues/485

    parser = GooeyParser(description=f'AzurLaneAutoScript, An Azur Lane automation tool. Config: {config_file}\nDo not forget to Press start button to save your settings in each function that modifies')
    subs = parser.add_subparsers(help='commands', dest='command')

    # ==========setting==========
    setting_parser = subs.add_parser('setting')

    # 选择关卡
    stage = setting_parser.add_argument_group('Level settings', 'Need to Press start to save your settings.', gooey_options={'label_color': '#931D03'})
    stage.add_argument('--enable_stop_condition', default=default('--enable_stop_condition'), choices=['yes', 'no'], help='If enabled will start reward loop when triggered any filter below', gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--enable_exception', default=default('--enable_exception'), choices=['yes', 'no'], help='Enable or disable some exceptions, ALAS will withdraw from the map when it occurs instead of stopping', gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--enable_fast_forward', default=default('--enable_fast_forward'), choices=['yes', 'no'], help='Enable or disable clearing mode', gooey_options={'label_color': '#4B5F83'})

    stop = stage.add_argument_group('Stop condition', 'After triggering, it will not stop immediately. It will complete the current attack first, Set 0 to disable', gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--if_count_greater_than', default=default('--if_count_greater_than'), help='How many map completions\n until ALAS enter in Reward loop.', gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--if_time_reach', default=default('--if_time_reach'), help='How many time in minutes run ALAS until stop\n. It is recommended about\n 10 minutes to complete the current attack. Format 14:59', gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--if_oil_lower_than', default=default('--if_oil_lower_than'), help='Will enter in reward loop when\ntriggered Oil limit', gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--if_map_reach', default=default('--if_map_reach'), choices=['no', 'map_100', 'map_3_star', 'map_green_without_3_star', 'map_green'], help='If already reached, ignore this setting', gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--if_trigger_emotion_control', default=default('--if_trigger_emotion_control'), choices=['yes', 'no'], help='Will enter in reward loop when\ntriggered Mood limit', gooey_options={'label_color': '#4B5F83'})
    # stop.add_argument('--if_dock_full', default=default('--if_dock_full'), choices=['yes', 'no'])

    # 出击舰队
    fleet = setting_parser.add_argument_group('Attack fleet', 'No support for alternate lane squadrons, inactive map or weekly mode will ignore the step setting', gooey_options={'label_color': '#931D03'})
    fleet.add_argument('--enable_fleet_control', default=default('--enable_fleet_control'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    fleet.add_argument('--enable_map_fleet_lock', default=default('--enable_map_fleet_lock'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})

    f1 = fleet.add_argument_group('Mob Fleet', 'Players can choose a formation before battle. Though it has no effect appearance-wise, the formations applies buffs to certain stats.\nLine Ahead: Increases Firepower and Torpedo by 15%, but reduces Evasion by 10% (Applies only to Vanguard fleet)\nDouble Line: Increases Evasion by 30%, but decreases Firepower and Torpedo by 5% (Applies only to Vanguard fleet)\nDiamond: Increases Anti-Air by 20% (no penalties, applies to entire fleet)', gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--fleet_index_1', default=default('--fleet_index_1'), choices=['1', '2', '3', '4', '5', '6'], gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--fleet_formation_1', default=default('--fleet_formation_1'), choices=['Line Ahead', 'Double Line', 'Diamond'], gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--fleet_auto_mode_1', default=default('--fleet_auto_mode_1'), choices=['combat_auto', 'combat_manual', 'stand_still_in_the_middle', 'hide_in_bottom_left'], gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--fleet_step_1', default=default('--fleet_step_1'), choices=['1', '2', '3', '4', '5', '6'], help='In event map, fleet has limit on moving, so fleet_step is how far can a fleet goes in one operation, if map cleared, it will be ignored', gooey_options={'label_color': '#4B5F83'})

    f2 = fleet.add_argument_group('Boss Fleet', gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--fleet_index_2', default=default('--fleet_index_2'), choices=['1', '2', '3', '4', '5', '6'], gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--fleet_formation_2', default=default('--fleet_formation_2'), choices=['Line Ahead', 'Double Line', 'Diamond'], gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--fleet_auto_mode_2', default=default('--fleet_auto_mode_2'), choices=['combat_auto', 'combat_manual', 'stand_still_in_the_middle', 'hide_in_bottom_left'], gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--fleet_step_2', default=default('--fleet_step_2'), choices=['1', '2', '3', '4', '5', '6'], help='In event map, fleet has limit on moving, so fleet_step is how far can a fleet goes in one operation, if map cleared, it will be ignored', gooey_options={'label_color': '#4B5F83'})

    f3 = fleet.add_argument_group('Alternate Mob Fleet', 'It hasnt been implemented yet', gooey_options={'label_color': '#4B5F83'})
    f3.add_argument('--fleet_index_3', default=default('--fleet_index_3'), choices=['1', '2', '3', '4', '5', '6'], gooey_options={'label_color': '#4B5F83'})
    f3.add_argument('--fleet_formation_3', default=default('--fleet_formation_3'), choices=['Line Ahead', 'Double Line', 'Diamond'], gooey_options={'label_color': '#4B5F83'})
    f3.add_argument('--fleet_auto_mode_3', default=default('--fleet_auto_mode_3'), choices=['combat_auto', 'combat_manual', 'stand_still_in_the_middle', 'hide_in_bottom_left'], gooey_options={'label_color': '#4B5F83'})
    f3.add_argument('--fleet_step_3', default=default('--fleet_step_3'), choices=['1', '2', '3', '4', '5', '6'], help='In event map, fleet has limit on moving, so fleet_step is how far can a fleet goes in one operation, if map cleared, it will be ignored', gooey_options={'label_color': '#4B5F83'})

    # 潜艇设置
    submarine = setting_parser.add_argument_group('Submarine settings', 'Only supported: hunt_only, do_not_use and every_combat', gooey_options={'label_color': '#931D03'})
    submarine.add_argument('--fleet_index_4', default=default('--fleet_index_4'), choices=['do_not_use', '1', '2'], gooey_options={'label_color': '#4B5F83'})
    submarine.add_argument('--submarine_mode', default=default('--submarine_mode'), choices=['do_not_use', 'hunt_only', 'every_combat', 'when_no_ammo', 'when_boss_combat', 'when_boss_combat_boss_appear'], gooey_options={'label_color': '#4B5F83'})

    # 心情控制
    emotion = setting_parser.add_argument_group('Mood control', gooey_options={'label_color': '#931D03'})
    emotion.add_argument('--enable_emotion_reduce', default=default('--enable_emotion_reduce'), help='Set No to disable MOOD control by ALAS', choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    emotion.add_argument('--ignore_low_emotion_warn', default=default('--ignore_low_emotion_warn'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})

    e1 = emotion.add_argument_group('Mob Fleet', 'Emotion limit:\nkeep_high_emotion: 120\navoid_green_face: 40\navoid_yellow_face: 30\navoid_red_face: 2', gooey_options={'label_color': '#4B5F83'})
    e1.add_argument('--emotion_recover_1', default=default('--emotion_recover_1'), choices=['not_in_dormitory', 'dormitory_floor_1', 'dormitory_floor_2'], gooey_options={'label_color': '#4B5F83'})
    e1.add_argument('--emotion_control_1', default=default('--emotion_control_1'), choices=['keep_high_emotion', 'avoid_green_face', 'avoid_yellow_face', 'avoid_red_face'], gooey_options={'label_color': '#4B5F83'})
    e1.add_argument('--hole_fleet_married_1', default=default('--hole_fleet_married_1'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})

    e2 = emotion.add_argument_group('BOSS Fleet', gooey_options={'label_color': '#4B5F83'})
    e2.add_argument('--emotion_recover_2', default=default('--emotion_recover_2'), choices=['not_in_dormitory', 'dormitory_floor_1', 'dormitory_floor_2'], gooey_options={'label_color': '#4B5F83'})
    e2.add_argument('--emotion_control_2', default=default('--emotion_control_2'), choices=['keep_high_emotion', 'avoid_green_face', 'avoid_yellow_face', 'avoid_red_face'], gooey_options={'label_color': '#4B5F83'})
    e2.add_argument('--hole_fleet_married_2', default=default('--hole_fleet_married_2'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})

    e3 = emotion.add_argument_group('Alternate Mob Fleet', 'Will be used when the first team triggers mood control', gooey_options={'label_color': '#4B5F83'})
    e3.add_argument('--emotion_recover_3', default=default('--emotion_recover_3'), choices=['not_in_dormitory', 'dormitory_floor_1', 'dormitory_floor_2'], gooey_options={'label_color': '#4B5F83'})
    e3.add_argument('--emotion_control_3', default=default('--emotion_control_3'), choices=['keep_high_emotion', 'avoid_green_face', 'avoid_yellow_face', 'avoid_red_face'], gooey_options={'label_color': '#4B5F83'})
    e3.add_argument('--hole_fleet_married_3', default=default('--hole_fleet_married_3'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})

    # 血量平衡
    hp = setting_parser.add_argument_group('HP control', 'Fleet lock must be turned off to take effect', gooey_options={'label_color': '#931D03'})
    hp.add_argument('--enable_hp_balance', default=default('--enable_hp_balance'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    hp.add_argument('--enable_low_hp_withdraw', default=default('--enable_low_hp_withdraw'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    hp_balance = hp.add_argument_group('HP Balance', '', gooey_options={'label_color': '#4B5F83'})
    hp_balance.add_argument('--scout_hp_difference_threshold', default=default('--scout_hp_difference_threshold'), help='When the difference in HP volume is greater than the threshold, transpose', gooey_options={'label_color': '#4B5F83'})
    hp_balance.add_argument('--scout_hp_weights', default=default('--scout_hp_weights'), help='Should be repaired when there is a difference in Vanguard, format 1000,1000,1000', gooey_options={'label_color': '#4B5F83'})
    hp_add = hp.add_argument_group('Emergency repair', '', gooey_options={'label_color': '#4B5F83'})
    hp_add.add_argument('--emergency_repair_single_threshold', default=default('--emergency_repair_single_threshold'), help='Used when single shipgirl is below the threshold', gooey_options={'label_color': '#4B5F83'})
    hp_add.add_argument('--emergency_repair_hole_threshold', default=default('--emergency_repair_hole_threshold'), help='Used when all front rows or all back rows are below the threshold', gooey_options={'label_color': '#4B5F83'})
    hp_withdraw = hp.add_argument_group('Low HP volume withdrawal', '', gooey_options={'label_color': '#4B5F83'})
    hp_withdraw.add_argument('--low_hp_withdraw_threshold', default=default('--low_hp_withdraw_threshold'), help='When HP is below the threshold, retreat', gooey_options={'label_color': '#4B5F83'})

    # 退役选项
    retire = setting_parser.add_argument_group('Retirement settings', '', gooey_options={'label_color': '#931D03'})
    retire.add_argument('--enable_retirement', default=default('--enable_retirement'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--retire_method', default=default('--retire_method'), choices=['enhance', 'one_click_retire', 'old_retire'], gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--retire_amount', default=default('--retire_amount'), choices=['retire_all', 'retire_10'], gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--enhance_favourite', default=default('--enhance_favourite'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--enhance_order_string', default=default('--enhance_order_string'), help='Use example format "cv > bb > ..." may omit a ship type category altogether to skip otherwise leave blank to use default enhance method', gooey_options={'label_color': '#4B5F83'})

    rarity = retire.add_argument_group('Retirement rarity', 'The ship type selection is not supported yet. Ignore the following options when using one-key retirement', gooey_options={'label_color': '#4B5F83'})
    rarity.add_argument('--retire_n', default=default('--retire_n'), choices=['yes', 'no'], help='N', gooey_options={'label_color': '#4B5F83'})
    rarity.add_argument('--retire_r', default=default('--retire_r'), choices=['yes', 'no'], help='R', gooey_options={'label_color': '#4B5F83'})
    rarity.add_argument('--retire_sr', default=default('--retire_sr'), choices=['yes', 'no'], help='SR', gooey_options={'label_color': '#4B5F83'})
    rarity.add_argument('--retire_ssr', default=default('--retire_ssr'), choices=['yes', 'no'], help='SSR', gooey_options={'label_color': '#4B5F83'})

    # 掉落记录
    drop = setting_parser.add_argument_group('Drop record', 'Save screenshots of dropped items, which will slow down the click speed when settlement is enabled', gooey_options={'label_color': '#931D03'})
    drop.add_argument('--enable_drop_screenshot', default=default('--enable_drop_screenshot'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    drop.add_argument('--drop_screenshot_folder', default=default('--drop_screenshot_folder'), gooey_options={'label_color': '#4B5F83'})

    # clear = setting_parser.add_argument_group('Wasteland mode', 'Unopened maps will stop after completion. Opened maps will ignore options, and its done if you do not open up')
    # clear.add_argument('--enable_map_clear_mode', default=default('--enable_map_clear_mode'), choices=['yes', 'no'])
    # clear.add_argument('--clear_mode_stop_condition', default=default('--clear_mode_stop_condition'), choices=['map_100', 'map_3_star', 'map_green'])
    # clear.add_argument('--map_star_clear_all', default=default('--map_star_clear_all'), choices=['index_1', 'index_2', 'index_3', 'do_not_use'], help='The first few stars are to destroy all enemy ships')


    # ==========reward==========
    reward_parser = subs.add_parser('reward')
    reward_condition = reward_parser.add_argument_group('Triggering conditions', 'Need to Press start to save your settings, after running it will enter the on-hook vegetable collection mode', gooey_options={'label_color': '#931D03'})
    reward_condition.add_argument('--enable_reward', default=default('--enable_reward'),
                                  choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    reward_condition.add_argument('--reward_interval', default=default('--reward_interval'),
                                  help='How many minutes to trigger collection. Recommend to set a time range, such as "10, 40"', gooey_options={'label_color': '#4B5F83'})
    reward_condition.add_argument('--reward_stop_game_during_interval',
                                  default=default('--reward_stop_game_during_interval'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    reward_condition.add_argument('--enable_daily_reward', default=default('--enable_daily_reward'), choices=['yes', 'no'],
                                  help='Run daily as a part of reward', gooey_options={'label_color': '#4B5F83'})

    reward_oil = reward_parser.add_argument_group('Oil supplies', '', gooey_options={'label_color': '#931D03'})
    reward_oil.add_argument('--enable_oil_reward', default=default('--enable_oil_reward'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    reward_oil.add_argument('--enable_coin_reward', default=default('--enable_coin_reward'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})

    reward_mission = reward_parser.add_argument_group('mission rewards', '', gooey_options={'label_color': '#931D03'})
    reward_mission.add_argument('--enable_mission_reward', default=default('--enable_mission_reward'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})

    reward_commission = reward_parser.add_argument_group('Commission settings', '', gooey_options={'label_color': '#931D03'})
    reward_commission.add_argument('--enable_commission_reward', default=default('--enable_commission_reward'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    reward_commission.add_argument('--commission_time_limit', default=default('--commission_time_limit'),
                                   help='Ignore orders whose completion time exceeds the limit, Format: 23:30. Fill in 0 if it is not needed', gooey_options={'label_color': '#4B5F83'})

    priority1 = reward_commission.add_argument_group('Commission priority by time duration', '', gooey_options={'label_color': '#931D03'})
    priority1.add_argument('--duration_shorter_than_2', default=default('--duration_shorter_than_2'), help='', gooey_options={'label_color': '#4B5F83'})
    priority1.add_argument('--duration_longer_than_6', default=default('--duration_longer_than_6'), help='', gooey_options={'label_color': '#4B5F83'})
    priority1.add_argument('--expire_shorter_than_2', default=default('--expire_shorter_than_2'), help='', gooey_options={'label_color': '#4B5F83'})
    priority1.add_argument('--expire_longer_than_6', default=default('--expire_longer_than_6'), help='', gooey_options={'label_color': '#4B5F83'})

    priority2 = reward_commission.add_argument_group('Daily Commission priority', '', gooey_options={'label_color': '#931D03'})
    priority2.add_argument('--daily_comm', default=default('--daily_comm'), help='Daily resource development, high-level tactical research and development', gooey_options={'label_color': '#4B5F83'})
    priority2.add_argument('--major_comm', default=default('--major_comm'), help='1200 oil / 1000 oil commission', gooey_options={'label_color': '#4B5F83'})

    priority3 = reward_commission.add_argument_group('Additional commission priority', '', gooey_options={'label_color': '#931D03'})
    priority3.add_argument('--extra_drill', default=default('--extra_drill'), help='Short-range Sailing Training, Coastal Defense Patrol', gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--extra_part', default=default('--extra_part'), help='Small Merchant Escort, Forest Protection Commission', gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--extra_cube', default=default('--extra_cube'), help='Fleet Exercise Ⅲ, Fleet Escort ExerciseFleet Exercise Ⅲ', gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--extra_oil', default=default('--extra_oil'), help='Small-scale Oil Extraction, Large-scale Oil Extraction', gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--extra_book', default=default('--extra_book'), help='Small Merchant Escort, Large Merchant Escort', gooey_options={'label_color': '#4B5F83'})

    priority4 = reward_commission.add_argument_group('Urgent commission priority', '', gooey_options={'label_color': '#931D03'})
    priority4.add_argument('--urgent_drill', default=default('--urgent_drill'), help='Defend the transport troops, annihilate the enemy elite troops', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--urgent_part', default=default('--urgent_part'), help='Support Vila Vela Island, support terror Banner', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--urgent_cube', default=default('--urgent_cube'), help='Rescue merchant ship, enemy attack', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--urgent_book', default=default('--urgent_book'), help='Support Tuhaoer Island, support Moe Island', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--urgent_box', default=default('--urgent_box'), help='BIW Gear Transport, NYB Gear Transport', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--urgent_gem', default=default('--urgent_gem'), help='BIW VIP Escort, NYB VIP Escort', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--urgent_ship', default=default('--urgent_ship'), help='Small Launch Ceremony, Fleet Launch Ceremony, Alliance Launch Ceremony', gooey_options={'label_color': '#4B5F83'})

    reward_tactical = reward_parser.add_argument_group('Classroom', 'Only support continuation of skill books, not new skills', gooey_options={'label_color': '#931D03'})
    reward_tactical.add_argument('--enable_tactical_reward', default=default('--enable_tactical_reward'),
                                 choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    reward_tactical.add_argument('--tactical_exp_first', default=default('--tactical_exp_first'),
                                 choices=['yes', 'no'], help='Choose Yes, give priority to the 150% bonus \nSelect No, give priority to the skills book with the same rarity', gooey_options={'label_color': '#4B5F83'})
    # reward_tactical.add_argument('--tactical_night_range', default=default('--tactical_night_range'), help='Format 23:30-06:30')
    reward_tactical.add_argument('--tactical_book_tier_max', default=default('--tactical_book_tier_max'),
                                 choices=['3', '2', '1'], help='Wich skill book will use first\nT3 is a gold book, T2 is a purple book, T1 is a blue book\ntier_max should greater than or equal to tier_min', gooey_options={'label_color': '#4B5F83'})
    reward_tactical.add_argument('--tactical_book_tier_min', default=default('--tactical_book_tier_min'),
                                 choices=['3', '2', '1'], help='Minimal tier to choose.', gooey_options={'label_color': '#4B5F83'})
    # reward_tactical.add_argument('--tactical_book_tier_night', default=default('--tactical_book_tier_night'), choices=['3', '2', '1'])
    # reward_tactical.add_argument('--tactical_exp_first_night', default=default('--tactical_exp_first_night'), choices=['yes', 'no'])
    reward_tactical.add_argument('--tactical_if_no_book_satisfied', default=default('--tactical_if_no_book_satisfied'),
                                 choices=['cancel_tactical', 'use_the_first_book'], gooey_options={'label_color': '#4B5F83'})

    reward_research = reward_parser.add_argument_group('Research', 'If set research_filter_preset=customized, read https://github.com/LmeSzinc/AzurLaneAutoScript/wiki/filter_string_en first', gooey_options={'label_color': '#931D03'})
    reward_research.add_argument('--enable_research_reward', default=default('--enable_research_reward'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    research_input = reward_research.add_argument_group('Research input', '', gooey_options={'label_color': '#4B5F83'})
    research_input.add_argument('--research_use_cube', default=default('--research_use_cube'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    research_input.add_argument('--research_use_coin', default=default('--research_use_coin'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    research_input.add_argument('--research_use_part', default=default('--research_use_part'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    research_output = reward_research.add_argument_group('Research output', '', gooey_options={'label_color': '#4B5F83'})
    research_output.add_argument('--research_filter_preset', default=default('--research_filter_preset'),
                                 choices=research_preset, gooey_options={'label_color': '#4B5F83'})
    research_output.add_argument('--research_filter_string', default=default('--research_filter_string'),
                                 help='Only if you are using custom preset.', gooey_options={'label_color': '#4B5F83'})

    reward_buy = reward_parser.add_argument_group('Buy', 'If already bought, skip', gooey_options={'label_color': '#931D03'})
    reward_buy.add_argument('--buy_meowfficer', default=default('--buy_meowfficer'), help='From 0 to 15. If no need, fill 0.', gooey_options={'label_color': '#4B5F83'})

    # ==========emulator==========
    emulator_parser = subs.add_parser('emulator')
    emulator = emulator_parser.add_argument_group('Emulator', 'Need to Press start to save your settings, it will check whether the game is started \nIf the game has not started, it will be started', gooey_options={'label_color': '#931D03'})
    emulator.add_argument('--serial', default=default('--serial'),
                          help='', gooey_options={'label_color': '#4B5F83'})
    emulator.add_argument('--package_name', default='com.YoStarEN.AzurLane', help='', gooey_options={'label_color': '#4B5F83'})
    emulator.add_argument(
        'default_serial_list',
        default=message,
        widget='Textarea',
        help="Some default SERIAL for most popular emulators, Only base values and may change according to the version you use",
        gooey_options={
            'height': 150,
            'show_help': True,
            'show_label': True,
            'readonly': True,
            'label_color': '#4B5F83'
        }
    )

    debug = emulator_parser.add_argument_group('Debug settings', '', gooey_options={'label_color': '#931D03'})
    debug.add_argument('--enable_error_log_and_screenshot_save', default=default('--enable_error_log_and_screenshot_save'),
                       choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    debug.add_argument('--enable_perspective_error_image_save', default=default('--enable_perspective_error_image_save'),
                       choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})

    adb = emulator_parser.add_argument_group('ADB settings', '', gooey_options={'label_color': '#931D03'})
    adb.add_argument('--device_screenshot_method', default=default('--device_screenshot_method'),
                     choices=['aScreenCap', 'uiautomator2', 'ADB'], help='Speed: aScreenCap >> uiautomator2 > ADB', gooey_options={'label_color': '#4B5F83'})
    adb.add_argument('--device_control_method', default=default('--device_control_method'),
                     choices=['minitouch','uiautomator2', 'ADB'], help='Speed: minitouch >> uiautomator2 >> ADB', gooey_options={'label_color': '#4B5F83'})
    adb.add_argument('--combat_screenshot_interval', default=default('--combat_screenshot_interval'),
                     help='Slow down the screenshot speed during battle and reduce CPU', gooey_options={'label_color': '#4B5F83'})

    update = emulator_parser.add_argument_group('ALAS Update Check', '', gooey_options={'label_color': '#931D03'})
    update.add_argument('--enable_update_check', default=default('--enable_update_check'),
                        choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    update.add_argument('--update_method', default=default('--update_method'),
                        choices=['api', 'web'], help='', gooey_options={'label_color': '#4B5F83'})
    update.add_argument('--github_token', default=default('--github_token'),
                        help='To generate your token visit https://github.com/settings/tokens or Help menu above', gooey_options={'label_color': '#4B5F83'})
    update.add_argument('--update_proxy', default=default('--update_proxy'),
                        help='Local http or socks proxy, example: http://127.0.0.1:10809', gooey_options={'label_color': '#4B5F83'})

    # ==========每日任务==========
    daily_parser = subs.add_parser('daily')

    # 选择每日
    daily = daily_parser.add_argument_group('Choose daily', 'Daily tasks, exercises, difficulty charts', gooey_options={'label_color': '#931D03'})
    daily.add_argument('--enable_daily_mission', default=default('--enable_daily_mission'),
                       help='If there are records on the day, skip', choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--enable_hard_campaign', default=default('--enable_hard_campaign'),
                       help='If there are records on the day, skip', choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--enable_exercise', default=default('--enable_exercise'),
                       help='If there is a record after refreshing, skip', choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--enable_raid_daily', default=default('--enable_raid_daily'),
                       help='If there is a record after refreshing, skip', choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--enable_event_ab', default=default('--enable_event_ab'),
                       help='If there is a record after refreshing, skip', choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--enable_event_sp', default=default('--enable_event_sp'),
                       help='If there is a record after refreshing, skip', choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})

    # 每日设置
    daily_task = daily_parser.add_argument_group('Daily settings', 'Does not support submarine daily', gooey_options={'label_color': '#931D03'})
    daily_task.add_argument('--tactical_training', default=default('--tactical_training'),
                            choices=['daily_air', 'daily_gun', 'daily_torpedo'], gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--fierce_assault', default=default('--fierce_assault'),
                            choices=['high_level', 'medium_level', 'low_level', 'index_1', 'index_2', 'index_3'], gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--escort_mission', default=default('--escort_mission'),
                            choices=['firepower_high_level', 'air_high_level', 'firepower_low_level', 'index_1', 'index_2', 'index_3'], gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--advance_mission', default=default('--advance_mission'),
                            choices=['high_level', 'medium_level', 'low_level', 'index_1', 'index_2', 'index_3'], gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--daily_fleet', default=default('--daily_fleet'),
                            help='If use one fleet, fill in the index of the fleet, such as 5\nIf use different fleets in different daily, separate index with commas, order: Escort Mission, Advance Mission, Fierce Assault, Tactical Training, such as 5, 5, 5, 6', gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--daily_equipment', default=default('--daily_equipment'),
                            help='Change equipment before playing, unload equipment after playing, do not need to fill in 0 \ncomma, such as 3, 1, 0, 1, 1, 0', gooey_options={'label_color': '#4B5F83'})

    # 困难设置
    hard = daily_parser.add_argument_group('Difficult setting', 'Need to turn on weekly mode', gooey_options={'label_color': '#931D03'})
    hard.add_argument('--hard_campaign', default=default('--hard_campaign'),
                      help='For example 10-4', gooey_options={'label_color': '#4B5F83'})
    hard.add_argument('--hard_fleet', default=default('--hard_fleet'),
                      choices=['1', '2'], help='For 10-2 hard, Set Fleet 2', gooey_options={'label_color': '#4B5F83'})
    hard.add_argument('--hard_equipment', default=default('--hard_equipment'),
                      help='Change equipment before playing, unload equipment after playing, do not need to fill in 0 \ncomma, such as 3, 1, 0, 1, 1, 0', gooey_options={'label_color': '#4B5F83'})

    # 演习设置
    exercise = daily_parser.add_argument_group('Exercise settings', '', gooey_options={'label_color': '#931D03'})
    exercise.add_argument('--exercise_choose_mode', default=default('--exercise_choose_mode'),
                          choices=['max_exp', 'easiest', 'easiest_else_exp'], help='', gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--exercise_preserve', default=default('--exercise_preserve'),
                          help='Only 0 are temporarily reserved', gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--exercise_try', default=default('--exercise_try'), help='The number of attempts by each opponent', gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--exercise_hp_threshold', default=default('--exercise_hp_threshold'),
                          help='HHP <Retreat at Threshold', gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--exercise_low_hp_confirm', default=default('--exercise_low_hp_confirm'),
                          help='After HP is below the threshold, it will retreat after a certain period of time \nRecommended 1.0 ~ 3.0', gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--exercise_equipment', default=default('--exercise_equipment'),
                          help='Change equipment before playing, unload equipment after playing, do not need to fill in 0 \ncomma, such as 3, 1, 0, 1, 1, 0', gooey_options={'label_color': '#4B5F83'})

    # event_daily_ab
    event_bonus = daily_parser.add_argument_group('Event Daily Bonus', 'bonus for first clear each day', gooey_options={'label_color': '#931D03'})
    event_bonus.add_argument('--event_ab_chapter', default=default('--event_ab_chapter'), choices=['chapter_ab', 'chapter_abcd', 'chapter_t', 'chapter_ht'],
                             help='Chapter with PT bonus', gooey_options={'label_color': '#4B5F83'})
    event_bonus.add_argument('--event_sp_mob_fleet', default=default('--event_sp_mob_fleet'), choices=['1', '2'],
                             help='', gooey_options={'label_color': '#4B5F83'})
    event_bonus.add_argument('--event_name_ab', default=event_latest, choices=event_folder,
                             help='There a dropdown menu with many options', gooey_options={'label_color': '#4B5F83'})

    # Raid daily
    raid_bonus = daily_parser.add_argument_group('Raid settings', '', gooey_options={'label_color': '#931D03'})
    raid_bonus.add_argument('--raid_daily_name', default=raid_latest, choices=raid_folder, help='', gooey_options={'label_color': '#4B5F83'})
    raid_bonus.add_argument('--raid_hard', default=default('--raid_hard'), choices=['yes', 'no'], help='', gooey_options={'label_color': '#4B5F83'})
    raid_bonus.add_argument('--raid_normal', default=default('--raid_normal'), choices=['yes', 'no'], help='', gooey_options={'label_color': '#4B5F83'})
    raid_bonus.add_argument('--raid_easy', default=default('--raid_easy'), choices=['yes', 'no'], help='', gooey_options={'label_color': '#4B5F83'})

    # ==========event_daily_ab==========
    # event_ab_parser = subs.add_parser('event_daily_bonus')
    # event_name = event_ab_parser.add_argument_group('Choose an event', 'bonus for first clear each day')
    # event_name.add_argument('--event_name_ab', default=event_latest, choices=event_folder, help='There a dropdown menu with many options')
    # event_name.add_argument('--enable_hard_bonus', default=default('--enable_hard_bonus'), choices=['yes', 'no'], help='Will enable Daily bonus for Event hard maps') # Trying implement all event maps

    # ==========main==========
    main_parser = subs.add_parser('Main_campaign')
    # 选择关卡
    stage = main_parser.add_argument_group('Choose a level',
                                           'Main campaign, Currently, not all maps are being supported, check the folder /doc/development_en.md to know how add new maps',
                                           gooey_options={'label_color': '#931D03'})
    stage.add_argument('--main_stage', default=default('--main_stage'), help='E.g 7-2',
                       gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--campaign_mode', default=default('--campaign_mode'), help='Useful if you want to clear a hard mode map',
                       choices=['normal', 'hard'], gooey_options={'label_color': '#4B5F83'})

    # ==========event==========
    event_parser = subs.add_parser('event')

    description = """

    """
    event = event_parser.add_argument_group(
        'Choose a level', '\n'.join([line.strip() for line in description.strip().split('\n')]), gooey_options={'label_color': '#931D03'})
    event.add_argument('--event_stage', default=default('--event_stage'), help='Type stage name, not case sensitive, E.g D3 HT6', gooey_options={'label_color': '#4B5F83'})
    event.add_argument('--event_name', default=event_latest, choices=event_folder, help='There a dropdown menu with many options', gooey_options={'label_color': '#4B5F83'})

    # ==========Raid==========
    raid_parser = subs.add_parser('raid')
    raid = raid_parser.add_argument_group('Choose a raid', '', gooey_options={'label_color': '#931D03'})
    raid.add_argument('--raid_name', default=raid_latest, choices=raid_folder, help='', gooey_options={'label_color': '#4B5F83'})
    raid.add_argument('--raid_mode', default=default('--raid_mode'), choices=['hard', 'normal', 'easy'], help='', gooey_options={'label_color': '#4B5F83'})
    raid.add_argument('--raid_use_ticket', default=default('--raid_use_ticket'), choices=['yes', 'no'], help='', gooey_options={'label_color': '#4B5F83'})

    # ==========半自动==========
    semi_parser = subs.add_parser('semi_auto')
    semi = semi_parser.add_argument_group('Semi-automatic mode', 'Manual selection of enemies, automatic settlement, used to attack unsuited pictures', gooey_options={'label_color': '#931D03'})
    semi.add_argument('--enable_semi_map_preparation', default=default('--enable_semi_map_preparation'), help='',
                      choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
    semi.add_argument('--enable_semi_story_skip', default=default('--enable_semi_story_skip'), help='Note that this will automatically confirm all the prompt boxes, including the red face attack',
                      choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})

    # ==========c11_affinity_farming==========
    c_1_1_parser = subs.add_parser('c1-1_affinity_farming')
    c_1_1 = c_1_1_parser.add_argument_group('c1-1_affinity_farming', 'Will auto turn off clearing mode\nWith MVP, 8 battle to 1 affnity. Without MVP, 16 battle to 1 affnity.',
                                            gooey_options={'label_color': '#931D03'})
    c_1_1.add_argument('--affinity_battle_count', default=default('--affinity_battle_count'), help='Example: 32', gooey_options={'label_color': '#4B5F83'})

    # ==========c72_mystery_farming==========
    c_7_2_parser = subs.add_parser('c7-2_mystery_farming')
    c_7_2 = c_7_2_parser.add_argument_group('c7-2_mystery_farming', '', gooey_options={'label_color': '#931D03'})
    c_7_2.add_argument('--boss_fleet_step_on_a3', default=default('--boss_fleet_step_on_a3'),
                       choices=['yes', 'no'], help='A3 has enemies, G3, C3, E3', gooey_options={'label_color': '#4B5F83'})

    # ==========c122_leveling==========
    c_12_2_parser = subs.add_parser('c12-2_leveling')
    c_12_2 = c_12_2_parser.add_argument_group('12-2 enemy search settings', '', gooey_options={'label_color': '#931D03'})
    c_12_2.add_argument('--s3_enemy_tolerance', default=default('--s3_enemy_tolerance'),
                        choices=['0', '1', '2', '10'], help='The maximum number of battles to fight against large enemies', gooey_options={'label_color': '#4B5F83'})

    # ==========c124_leveling==========
    c_12_4_parser = subs.add_parser('c12-4_leveling')
    c_12_4 = c_12_4_parser.add_argument_group('12-4 Search enemy settings', 'Need to ensure that the team has a certain strength', gooey_options={'label_color': '#931D03'})
    c_12_4.add_argument('--non_s3_enemy_enter_tolerance', default=default('--non_s3_enemy_enter_tolerance'),
                        choices=['0', '1', '2'], help='Avoid enemy too strong', gooey_options={'label_color': '#4B5F83'})
    c_12_4.add_argument('--non_s3_enemy_withdraw_tolerance', default=default('--non_s3_enemy_withdraw_tolerance'),
                        choices=['0', '1', '2', '10'], help='How many battles will be fought after there is no large scale enemy', gooey_options={'label_color': '#4B5F83'})
    c_12_4.add_argument('--ammo_pick_up_124', default=default('--ammo_pick_up_124'),
                        choices=['2', '3', '4', '5'], help='How many battles before pick ammo, the recommended is 3', gooey_options={'label_color': '#4B5F83'})

    args = parser.parse_args()

    # Convert option from chinese to english.
    out = {}
    for key, value in vars(args).items():
        key = dic_gui_to_ini.get(key, key)
        value = dic_gui_to_ini.get(value, value)
        out[key] = value
    args = out

    # Update option to .ini file.
    command = args['command'].capitalize()
    config['Command']['command'] = command
    for key, value in args.items():
        config[command][key] = str(value)
    config.write(codecs.open(config_file, "w+", "utf8"))

    # Call AzurLaneAutoScript
    alas = AzurLaneAutoScript(ini_name=ini_name)
    alas.run(command=command)
Beispiel #6
0
def main(ini_name=''):
    if not ini_name:
        ini_name = pyw_name
    config_file = f'./config/{ini_name}.ini'
    config = get_config(ini_name.lower())

    event_folder = [f for f in os.listdir('./campaign') if f.startswith('event_') and f.split('_')[-1] == server.server]
    event_latest = sorted([f for f in event_folder], reverse=True)[0]
    event_folder = [dic_eng_to_chi.get(f, f) for f in event_folder][::-1]
    event_latest = dic_eng_to_chi.get(event_latest, event_latest)

    raid_latest = '复刻特别演习埃塞克斯级'

    saved_config = {}
    for opt, option in config.items():
        for key, value in option.items():
            key = dic_eng_to_chi.get(key, key)
            if value in dic_eng_to_chi:
                value = dic_eng_to_chi.get(value, value)
            if value == 'None':
                value = ''

            saved_config[key] = value

    def default(name):
        """Get default value in .ini file.
        Args:
            name (str): option, in chinese.

        Returns:
            str: Default value, in chinese.
        """
        name = name.strip('-')
        return saved_config.get(name, '')

    def choice_list(total):
        return [str(index) for index in range(1, total + 1)]

    # Don't use checkbox in gooey, use drop box instead.
    # https://github.com/chriskiehl/Gooey/issues/148
    # https://github.com/chriskiehl/Gooey/issues/485

    parser = GooeyParser(description=f'AzurLaneAutoScript, An Azur Lane automation tool. Config: {config_file}')
    subs = parser.add_subparsers(help='commands', dest='command')

    # ==========出击设置==========
    setting_parser = subs.add_parser('出击设置')

    # 选择关卡
    stage = setting_parser.add_argument_group('关卡设置', '需要运行一次来保存选项')
    stage.add_argument('--启用停止条件', default=default('--启用停止条件'), choices=['是', '否'])
    stage.add_argument('--启用异常处理', default=default('--启用异常处理'), choices=['是', '否'], help='处理部分异常, 运行出错时撤退')
    stage.add_argument('--使用周回模式', default=default('--使用周回模式'), choices=['是', '否'])

    stop = stage.add_argument_group('停止条件', '触发后不会马上停止会先完成当前出击, 不需要就填0')
    stop.add_argument('--如果出击次数大于', default=default('--如果出击次数大于'), help='会沿用先前设置, 完成出击将扣除次数, 直至清零')
    stop.add_argument('--如果时间超过', default=default('--如果时间超过'), help='使用未来24小时内的时间, 会沿用先前设置, 触发后清零. 建议提前10分钟左右, 以完成当前出击. 格式 14:59')
    stop.add_argument('--如果石油低于', default=default('--如果石油低于'))
    stop.add_argument('--如果触发心情控制', default=default('--如果触发心情控制'), choices=['是', '否'], help='若是, 等待回复, 完成本次, 停止\n若否, 等待回复, 完成本次, 继续')
    # stop.add_argument('--如果船舱已满', default=default('--如果船舱已满'), choices=['是', '否'])

    # 出击舰队
    fleet = setting_parser.add_argument_group('出击舰队', '暂不支持备用道中队, 非活动图或周回模式会忽略步长设置')
    fleet.add_argument('--启用舰队控制', default=default('--启用舰队控制'), choices=['是', '否'])
    fleet.add_argument('--启用阵容锁定', default=default('--启用阵容锁定'), choices=['是', '否'])

    f1 = fleet.add_argument_group('道中队')
    f1.add_argument('--舰队编号1', default=default('--舰队编号1'), choices=['1', '2', '3', '4', '5', '6'])
    f1.add_argument('--舰队阵型1', default=default('--舰队阵型1'), choices=['单纵阵', '复纵阵', '轮形阵'])
    f1.add_argument('--舰队步长1', default=default('--舰队步长1'), choices=['1', '2', '3', '4', '5', '6'])

    f2 = fleet.add_argument_group('BOSS队')
    f2.add_argument('--舰队编号2', default=default('--舰队编号2'), choices=['不使用', '1', '2', '3', '4', '5', '6'])
    f2.add_argument('--舰队阵型2', default=default('--舰队阵型2'), choices=['单纵阵', '复纵阵', '轮形阵'])
    f2.add_argument('--舰队步长2', default=default('--舰队步长2'), choices=['1', '2', '3', '4', '5', '6'])

    f3 = fleet.add_argument_group('备用道中队')
    f3.add_argument('--舰队编号3', default=default('--舰队编号3'), choices=['不使用', '1', '2', '3', '4', '5', '6'])
    f3.add_argument('--舰队阵型3', default=default('--舰队阵型3'), choices=['单纵阵', '复纵阵', '轮形阵'])
    f3.add_argument('--舰队步长3', default=default('--舰队步长3'), choices=['1', '2', '3', '4', '5', '6'])

    f4 = fleet.add_argument_group('自律模式')
    f4.add_argument('--战斗自律模式', default=default('--战斗自律模式'), choices=['自律', '手操', '中路站桩'])

    # 潜艇设置
    submarine = setting_parser.add_argument_group('潜艇设置', '仅支持: 不使用, 仅狩猎, 每战出击')
    submarine.add_argument('--舰队编号4', default=default('--舰队编号4'), choices=['不使用', '1', '2'])
    submarine.add_argument('--潜艇出击方案', default=default('--潜艇出击方案'), choices=['不使用', '仅狩猎', '每战出击', '空弹出击', 'BOSS战出击', 'BOSS战BOSS出现后召唤'])

    # 心情控制
    emotion = setting_parser.add_argument_group('心情控制')
    emotion.add_argument('--启用心情消耗', default=default('--启用心情消耗'), choices=['是', '否'])
    emotion.add_argument('--无视红脸出击警告', default=default('--无视红脸出击警告'), choices=['是', '否'])

    e1 = emotion.add_argument_group('道中队')
    e1.add_argument('--心情回复1', default=default('--心情回复1'), choices=['未放置于后宅', '后宅一楼', '后宅二楼'])
    e1.add_argument('--心情控制1', default=default('--心情控制1'), choices=['保持经验加成', '防止绿脸', '防止黄脸', '防止红脸'])
    e1.add_argument('--全员已婚1', default=default('--全员已婚1'), choices=['是', '否'])

    e2 = emotion.add_argument_group('BOSS队')
    e2.add_argument('--心情回复2', default=default('--心情回复2'), choices=['未放置于后宅', '后宅一楼', '后宅二楼'])
    e2.add_argument('--心情控制2', default=default('--心情控制2'), choices=['保持经验加成', '防止绿脸', '防止黄脸', '防止红脸'])
    e2.add_argument('--全员已婚2', default=default('--全员已婚2'), choices=['是', '否'])

    e3 = emotion.add_argument_group('备用道中队', '会在主队触发心情控制时使用')
    e3.add_argument('--心情回复3', default=default('--心情回复3'), choices=['未放置于后宅', '后宅一楼', '后宅二楼'])
    e3.add_argument('--心情控制3', default=default('--心情控制3'), choices=['保持经验加成', '防止绿脸', '防止黄脸', '防止红脸'])
    e3.add_argument('--全员已婚3', default=default('--全员已婚3'), choices=['是', '否'])

    # 血量平衡
    hp = setting_parser.add_argument_group('血量控制', '需关闭舰队锁定才能生效')
    hp.add_argument('--启用血量平衡', default=default('--启用血量平衡'), choices=['是', '否'])
    hp.add_argument('--启用低血量撤退', default=default('--启用低血量撤退'), choices=['是', '否'])
    hp_balance = hp.add_argument_group('血量平衡', '')
    hp_balance.add_argument('--先锋血量平衡阈值', default=default('--先锋血量平衡阈值'), help='血量差值大于阈值时, 换位')
    hp_balance.add_argument('--先锋血量权重', default=default('--先锋血量权重'), help='先锋肉度有差别时应修改, 格式 1000,1000,1000')
    hp_add = hp.add_argument_group('紧急维修', '')
    hp_add.add_argument('--紧急维修单人阈值', default=default('--紧急维修单人阈值'), help='单人低于阈值时使用')
    hp_add.add_argument('--紧急维修全队阈值', default=default('--紧急维修全队阈值'), help='前排全部或后排全部低于阈值时使用')
    hp_withdraw = hp.add_argument_group('低血量撤退', '')
    hp_withdraw.add_argument('--低血量撤退阈值', default=default('--低血量撤退阈值'), help='任意一人血量低于阈值时, 撤退')

    # 退役选项
    retire = setting_parser.add_argument_group('退役设置', '')
    retire.add_argument('--启用退役', default=default('--启用退役'), choices=['是', '否'])
    retire.add_argument('--退役方案', default=default('--退役方案'), choices=['强化角色', '一键退役', '传统退役'])
    retire.add_argument('--退役数量', default=default('--退役数量'), choices=['退役全部', '退役10个'])
    retire.add_argument('--强化常用角色', default=default('--强化常用角色'), choices=['是', '否'])

    rarity = retire.add_argument_group('退役稀有度', '暂不支持舰种选择, 使用一键退役时忽略以下选项')
    rarity.add_argument('--退役白皮', default=default('--退役白皮'), choices=['是', '否'], help='N')
    rarity.add_argument('--退役蓝皮', default=default('--退役蓝皮'), choices=['是', '否'], help='R')
    rarity.add_argument('--退役紫皮', default=default('--退役紫皮'), choices=['是', '否'], help='SR')
    rarity.add_argument('--退役金皮', default=default('--退役金皮'), choices=['是', '否'], help='SSR')

    # 掉落记录
    drop = setting_parser.add_argument_group('掉落记录', '保存掉落物品的截图, 启用后会放缓结算时的点击速度')
    drop.add_argument('--启用掉落记录', default=default('--启用掉落记录'), choices=['是', '否'])
    drop.add_argument('--掉落保存目录', default=default('--掉落保存目录'))

    clear = setting_parser.add_argument_group('开荒模式', '未开荒地图会在完成后停止, 已开荒的地图会忽略选项, 无脑开就完事了')
    clear.add_argument('--启用开荒', default=default('--启用开荒'), choices=['是', '否'])
    clear.add_argument('--开荒停止条件', default=default('--开荒停止条件'), choices=['地图通关', '地图三星', '地图绿海'])
    clear.add_argument('--地图全清星星', default=default('--地图全清星星'), choices=['第一个', '第二个', '第三个', '不使用'], help='第几颗星星是击破所有敌舰')

    # ==========收菜设置==========
    reward_parser = subs.add_parser('收菜设置')
    reward_condition = reward_parser.add_argument_group('触发条件', '需要运行一次来保存选项, 运行后会进入挂机收菜模式')
    reward_condition.add_argument('--启用收获', default=default('--启用收获'), choices=['是', '否'])
    reward_condition.add_argument('--收菜间隔', default=default('--收菜间隔'), choices=['20', '30', '60'], help='每隔多少分钟触发收菜')
    reward_condition.add_argument('--启用每日收获', default=default('--启用每日收获'), choices=['是', '否'], help='将每日任务困难演习作为收获的一部分来运行')

    reward_oil = reward_parser.add_argument_group('石油物资', '')
    reward_oil.add_argument('--启用石油收获', default=default('--启用石油收获'), choices=['是', '否'])
    reward_oil.add_argument('--启用物资收获', default=default('--启用物资收获'), choices=['是', '否'])

    reward_mission = reward_parser.add_argument_group('任务奖励', '')
    reward_mission.add_argument('--启用任务收获', default=default('--启用任务收获'), choices=['是', '否'])

    reward_commission = reward_parser.add_argument_group('委托设置', '')
    reward_commission.add_argument('--启用委托收获', default=default('--启用委托收获'), choices=['是', '否'])
    reward_commission.add_argument('--委托时间限制', default=default('--委托时间限制'), help='忽略完成时间超过限制的委托, 格式: 23:30, 不需要就填0')

    priority1 = reward_commission.add_argument_group('委托耗时优先级', '')
    priority1.add_argument('--委托耗时小于2h', default=default('--委托耗时小于2h'), help='')
    priority1.add_argument('--委托耗时超过6h', default=default('--委托耗时超过6h'), help='')
    priority1.add_argument('--委托过期小于2h', default=default('--委托过期小于2h'), help='')
    priority1.add_argument('--委托过期大于6h', default=default('--委托过期大于6h'), help='')

    priority2 = reward_commission.add_argument_group('日常委托优先级', '')
    priority2.add_argument('--日常委托', default=default('--日常委托'), help='日常资源开发, 高阶战术研发')
    priority2.add_argument('--主要委托', default=default('--主要委托'), help='1200油/1000油委托')

    priority3 = reward_commission.add_argument_group('额外委托优先级', '')
    priority3.add_argument('--钻头类额外委托', default=default('--钻头类额外委托'), help='短距离航行训练, 近海防卫巡逻')
    priority3.add_argument('--部件类额外委托', default=default('--部件类额外委托'), help='矿脉护卫委托, 林木护卫委托')
    priority3.add_argument('--魔方类额外委托', default=default('--魔方类额外委托'), help='舰队高阶演习, 舰队护卫演习')
    priority3.add_argument('--石油类额外委托', default=default('--石油类额外委托'), help='小型油田开发, 大型油田开发')
    priority3.add_argument('--教材类额外委托', default=default('--教材类额外委托'), help='小型商船护卫, 大型商船护卫')

    priority4 = reward_commission.add_argument_group('紧急委托优先级', '')
    priority4.add_argument('--钻头类紧急委托', default=default('--钻头类紧急委托'), help='保卫运输部队, 歼灭敌精锐部队')
    priority4.add_argument('--部件类紧急委托', default=default('--部件类紧急委托'), help='支援维拉维拉岛, 支援恐班纳')
    priority4.add_argument('--魔方类紧急委托', default=default('--魔方类紧急委托'), help='解救商船, 敌袭')
    priority4.add_argument('--教材类紧急委托', default=default('--教材类紧急委托'), help='支援土豪尔岛, 支援萌岛')
    priority4.add_argument('--装备类紧急委托', default=default('--装备类紧急委托'), help='BIW装备运输, NYB装备研发')
    priority4.add_argument('--钻石类紧急委托', default=default('--钻石类紧急委托'), help='BIW要员护卫, NYB巡视护卫')
    priority4.add_argument('--观舰类紧急委托', default=default('--观舰类紧急委托'), help='小型观舰仪式, 同盟观舰仪式')

    reward_tactical = reward_parser.add_argument_group('战术学院', '只支持续技能书, 不支持学新技能')
    reward_tactical.add_argument('--启用战术学院收获', default=default('--启用战术学院收获'), choices=['是', '否'])
    reward_tactical.add_argument('--战术学院夜间时段', default=default('--战术学院夜间时段'), help='格式 23:30-06:30')
    reward_tactical.add_argument('--技能书稀有度', default=default('--技能书稀有度'), choices=['3', '2', '1'], help='最多使用T几的技能书\nT3是金书, T2是紫书, T1是蓝书')
    reward_tactical.add_argument('--技能书优先使用同类型', default=default('--技能书优先使用同类型'), choices=['是', '否'], help='选是, 优先使用有150%加成的\n选否, 优先使用同稀有度的技能书')
    reward_tactical.add_argument('--技能书夜间稀有度', default=default('--技能书夜间稀有度'), choices=['3', '2', '1'])
    reward_tactical.add_argument('--技能书夜间优先使用同类型', default=default('--技能书夜间优先使用同类型'), choices=['是', '否'])

    # ==========设备设置==========
    emulator_parser = subs.add_parser('设备设置')
    emulator = emulator_parser.add_argument_group('模拟器', '需要运行一次来保存选项, 会检查游戏是否启动\n若启动了游戏, 触发一次收菜')
    emulator.add_argument('--设备', default=default('--设备'), help='例如 127.0.0.1:62001')
    emulator.add_argument('--包名', default=default('--包名'), help='')

    debug = emulator_parser.add_argument_group('调试设置', '')
    debug.add_argument('--出错时保存log和截图', default=default('--出错时保存log和截图'), choices=['是', '否'])
    debug.add_argument('--保存透视识别出错的图像', default=default('--保存透视识别出错的图像'), choices=['是', '否'])

    adb = emulator_parser.add_argument_group('ADB设置', '')
    adb.add_argument('--设备截图方案', default=default('--设备截图方案'), choices=['aScreenCap', 'uiautomator2', 'ADB'], help='速度: aScreenCap >> uiautomator2 > ADB')
    adb.add_argument('--设备控制方案', default=default('--设备控制方案'), choices=['uiautomator2', 'ADB'], help='速度: uiautomator2 >> ADB')
    adb.add_argument('--战斗中截图间隔', default=default('--战斗中截图间隔'), help='战斗中放慢截图速度, 降低CPU使用')
    
    update = emulator_parser.add_argument_group('更新检查', '')
    update.add_argument('--启用更新检查', default=default('--启用更新检查'), choices=['是', '否'])
    update.add_argument('--更新检查方法', default=default('--更新检查方法'), choices=['api', 'web'], help='使用api时建议填写tokens, 使用web则不需要')
    update.add_argument('--github_token', default=default('--github_token'), help='Github API限制为每小时60次, 获取tokens https://github.com/settings/tokens')
    update.add_argument('--更新检查代理', default=default('--更新检查代理'), help='本地http或socks代理, 如果github很慢, 请使用代理, example: http://127.0.0.1:10809')

    # ==========每日任务==========
    daily_parser = subs.add_parser('每日任务困难演习')

    # 选择每日
    daily = daily_parser.add_argument_group('选择每日', '每日任务, 演习, 困难图')
    daily.add_argument('--打每日', default=default('--打每日'), help='若当天有记录, 则跳过', choices=['是', '否'])
    daily.add_argument('--打困难', default=default('--打困难'), help='若当天有记录, 则跳过', choices=['是', '否'])
    daily.add_argument('--打演习', default=default('--打演习'), help='若在刷新后有记录, 则跳过', choices=['是', '否'])
    daily.add_argument('--打活动图每日三倍PT', default=default('--打活动图每日三倍PT'), help='若当天有记录, 则跳过', choices=['是', '否'])
    daily.add_argument('--打共斗每日15次', default=default('--打共斗每日15次'), help='若当天有记录, 则跳过', choices=['是', '否'])

    # 每日设置
    daily_task = daily_parser.add_argument_group('每日设置', '不支持潜艇每日')
    daily_task.add_argument('--战术研修', default=default('--战术研修'), choices=['航空', '炮击', '雷击'])
    daily_task.add_argument('--斩首行动', default=default('--斩首行动'), choices=['第一个', '第二个', '第三个'])
    daily_task.add_argument('--商船护航', default=default('--商船护航'), choices=['第一个', '第二个', '第三个'])
    daily_task.add_argument('--海域突进', default=default('--海域突进'), choices=['第一个', '第二个', '第三个'])
    daily_task.add_argument('--每日舰队', default=default('--每日舰队'), choices=['1', '2', '3', '4', '5', '6'])
    daily_task.add_argument('--每日舰队快速换装', default=default('--每日舰队快速换装'), help='打之前换装备, 打完后卸装备, 不需要就填0\n逗号分割, 例如 3, 1, 0, 1, 1, 0')

    # 困难设置
    hard = daily_parser.add_argument_group('困难设置', '需要开启周回模式, 暂时仅支持 10-4')
    hard.add_argument('--困难地图', default=default('--困难地图'), help='比如 10-4')
    hard.add_argument('--困难舰队', default=default('--困难舰队'), choices=['1', '2'])
    hard.add_argument('--困难舰队快速换装', default=default('--困难舰队快速换装'), help='打之前换装备, 打完后卸装备, 不需要就填0\n逗号分割, 例如 3, 1, 0, 1, 1, 0')

    # 演习设置
    exercise = daily_parser.add_argument_group('演习设置', '暂时仅支持经验最多')
    exercise.add_argument('--演习对手选择', default=default('--演习对手选择'), choices=['经验最多', '排名最前', '福利队'], help='暂时仅支持经验最多')
    exercise.add_argument('--演习次数保留', default=default('--演习次数保留'), help='暂时仅支持保留0个')
    exercise.add_argument('--演习尝试次数', default=default('--演习尝试次数'), help='每个对手的尝试次数, 打不过就换')
    exercise.add_argument('--演习SL阈值', default=default('--演习SL阈值'), help='HP<阈值时撤退')
    exercise.add_argument('--演习低血量确认时长', default=default('--演习低血量确认时长'), help='HP低于阈值后, 过一定时长才会撤退\n推荐 1.0 ~ 3.0')
    exercise.add_argument('--演习快速换装', default=default('--演习快速换装'), help='打之前换装备, 打完后卸装备, 不需要就填0\n逗号分割, 例如 3, 1, 0, 1, 1, 0')

    event_bonus = daily_parser.add_argument_group('活动设置', '')
    event_bonus.add_argument('--活动名称ab', default=event_latest, choices=event_folder, help='例如 event_20200326_cn')

    # 共斗每日设置
    raid_bonus = daily_parser.add_argument_group('共斗设置', '')
    raid_bonus.add_argument('--共斗每日名称', default=raid_latest, choices=[raid_latest], help='')
    raid_bonus.add_argument('--共斗困难', default=default('--共斗困难'), choices=['是', '否'], help='')
    raid_bonus.add_argument('--共斗普通', default=default('--共斗普通'), choices=['是', '否'], help='')
    raid_bonus.add_argument('--共斗简单', default=default('--共斗简单'), choices=['是', '否'], help='')

    # # ==========每日活动图三倍PT==========
    # event_ab_parser = subs.add_parser('每日活动图三倍PT')
    # event_name = event_ab_parser.add_argument_group('选择活动', '')
    # event_name.add_argument('--活动名称ab', default=event_latest, choices=event_folder, help='例如 event_20200326_cn')

    # ==========主线图==========
    main_parser = subs.add_parser('主线图')
    # 选择关卡
    stage = main_parser.add_argument_group('选择关卡', '主线图出击, 目前仅支持前六章和7-2')
    stage.add_argument('--主线地图出击', default=default('--主线地图出击'), help='例如 7-2')
    stage.add_argument('--主线地图模式', default=default('--主线地图模式'), help='仅困难图开荒时使用, 周回模式后请使用每日困难', choices=['普通', '困难'])

    # ==========活动图==========
    event_parser = subs.add_parser('活动图')

    description = """
    支持「峡湾间的反击」(event_20200603_cn), 针对SP1-SP3有优化
    出击未优化关卡或地图未达到安全海域时, 使用开荒模式运行(较慢)
    """
    event = event_parser.add_argument_group(
        '选择关卡', '\n'.join([line.strip() for line in description.strip().split('\n')]))
    event.add_argument('--活动地图', default=default('--活动地图'),
                             choices=['a1', 'a2', 'a3', 'b1', 'b2', 'b3', 'c1', 'c2', 'c3', 'd1', 'd2', 'd3'],
                             help='例如 d3')
    event.add_argument('--sp地图', default=default('--sp地图'),
                             choices=['sp1', 'sp2', 'sp3'],
                             help='例如 sp3')
    event.add_argument('--活动名称', default=event_latest, choices=event_folder, help='例如 event_20200312_cn')

    # ==========共斗活动==========
    raid_parser = subs.add_parser('共斗活动')
    raid = raid_parser.add_argument_group('选择共斗', '')
    raid.add_argument('--共斗名称', default=raid_latest, choices=[raid_latest], help='')
    raid.add_argument('--共斗难度', default=default('--共斗难度'), choices=['困难', '普通', '简单'], help='')
    raid.add_argument('--共斗使用挑战券', default=default('--共斗使用挑战券'), choices=['是', '否'], help='')

    # ==========半自动==========
    semi_parser = subs.add_parser('半自动辅助点击')
    semi = semi_parser.add_argument_group('半自动模式', '手动选敌, 自动结算, 用于出击未适配的图')
    semi.add_argument('--进图准备', default=default('--进图准备'), help='', choices=['是', '否'])
    semi.add_argument('--跳过剧情', default=default('--跳过剧情'), help='注意, 这会自动确认所有提示框, 包括红脸出击', choices=['是', '否'])

    # ==========7-2三战拣垃圾==========
    c_7_2_parser = subs.add_parser('7-2三战拣垃圾')
    c_7_2 = c_7_2_parser.add_argument_group('7-2三战拣垃圾', '')
    c_7_2.add_argument('--BOSS队踩A3', default=default('--BOSS队踩A3'), choices=['是', '否'], help='A3有敌人就G3, C3, E3')

    # ==========12-2打中型练级==========
    c_12_2_parser = subs.add_parser('12-2打中型练级')
    c_12_2 = c_12_2_parser.add_argument_group('12-2索敌设置', '')
    c_12_2.add_argument('--大型敌人忍耐', default=default('--大型敌人忍耐'), choices=['0', '1', '2', '10'], help='最多打多少战大型敌人, 不挑敌人选10')

    # ==========12-4打大型练级==========
    c_12_4_parser = subs.add_parser('12-4打大型练级')
    c_12_4 = c_12_4_parser.add_argument_group('12-4索敌设置', '需保证队伍有一定强度')
    c_12_4.add_argument('--非大型敌人进图忍耐', default=default('--非大型敌人进图忍耐'), choices=['0', '1', '2'], help='忍受进场多少战没有大型')
    c_12_4.add_argument('--非大型敌人撤退忍耐', default=default('--非大型敌人撤退忍耐'), choices=['0', '1', '2', '10'], help='没有大型之后还会打多少战, 不挑敌人选10')
    c_12_4.add_argument('--拣弹药124', default=default('--拣弹药124'), choices=['2', '3', '4', '5'], help='多少战后拣弹药')

    args = parser.parse_args()

    # Convert option from chinese to english.
    out = {}
    for key, value in vars(args).items():
        key = dic_chi_to_eng.get(key, key)
        value = dic_chi_to_eng.get(value, value)
        out[key] = value
    args = out

    # Update option to .ini file.
    command = args['command'].capitalize()
    config['Command']['command'] = command
    for key, value in args.items():
        config[command][key] = str(value)
    config.write(codecs.open(config_file, "w+", "utf8"))

    # Call AzurLaneAutoScript
    alas = AzurLaneAutoScript(ini_name=ini_name)
    alas.run(command=command)
Beispiel #7
0
def main(ini_name=''):
    if not ini_name:
        ini_name = pyw_name
    config_file = f'./config/{ini_name}.ini'
    config = get_config(ini_name.lower())

    # Load translation dictionary
    dic_gui_to_ini = dic_tchi_to_eng  # GUI translation dictionary here.
    dic_gui_to_ini.update(dic_event[server.server])
    dic_gui_to_ini.update(dic_archives[server.server])
    dic_ini_to_gui = {v: k for k, v in dic_gui_to_ini.items()}
    # Event list
    event_folder = [f for f in dic_event[server.server].values() if f.startswith('event_')]
    event_latest = event_folder[-1]
    event_folder = [dic_ini_to_gui.get(f, f) for f in event_folder][::-1]
    event_latest = dic_ini_to_gui.get(event_latest, event_latest)
    # Archives list
    archives_folder = [f for f in dic_archives[server.server].values() if f.startswith('war_archives_')]
    archives_folder = [dic_ini_to_gui.get(f, f) for f in archives_folder][::-1]
    # Raid list
    raid_folder = [f for f in dic_event[server.server].values() if f.startswith('raid_')]
    raid_latest = raid_folder[-1]
    raid_folder = [dic_ini_to_gui.get(f, f) for f in raid_folder][::-1]
    raid_latest = dic_ini_to_gui.get(raid_latest, raid_latest)
    # Research preset list
    research_preset = [dic_ini_to_gui.get(f, f) for f in ['customized'] + list(DICT_FILTER_PRESET.keys())]
    # Translate settings in ini file
    saved_config = {}
    for opt, option in config.items():
        for key, value in option.items():
            key = dic_ini_to_gui.get(key, key)
            if value in dic_ini_to_gui:
                value = dic_ini_to_gui.get(value, value)
            if value == 'None':
                value = ''
            saved_config[key] = value
    message = (
        '藍疊模擬器:\t127.0.0.1:5555\n'
        '夜神模擬器:\t127.0.0.1:62001\n'
        'MuMu模擬器:\t127.0.0.1:7555\n'
        '逍遙模擬器:\t127.0.0.1:21503\n'
        '雷電模擬器:\temulator-5554\n'
    )

    def default(name):
        """Get default value in .ini file.
        Args:
            name (str): option, in chinese.

        Returns:
            str: Default value, in chinese.
        """
        name = name.strip('-')
        return saved_config.get(name, '')

    def choice_list(total):
        return [str(index) for index in range(1, total + 1)]

    # Don't use checkbox in gooey, use drop box instead.
    # https://github.com/chriskiehl/Gooey/issues/148
    # https://github.com/chriskiehl/Gooey/issues/485

    parser = GooeyParser(description=f'AzurLaneAutoScript, An Azur Lane automation tool. Config: {config_file}\n功能都是分別保存和執行的, 修改設定後別忘了點擊"開始"來保存')
    subs = parser.add_subparsers(help='commands', dest='command')

    # ==========出擊設定==========
    setting_parser = subs.add_parser('出擊設定')

    # 選擇關卡
    stage = setting_parser.add_argument_group('關卡設定', '需要執行一次來保存選項', gooey_options={'label_color': '#931D03'})
    stage.add_argument('--啟用彈窗提醒', default=default('--啟用彈窗提醒'), choices=['是', '否'], help='開啟彈窗提醒,僅windows10可用', gooey_options={'label_color': '#4B5F83'})
    # stage.add_argument('--啟用停止條件', default=default('--啟用停止條件'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--啟用異常處理', default=default('--啟用異常處理'), choices=['是', '否'], help='處理部分異常, 執行出錯時撤退', gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--使用周回模式', default=default('--使用周回模式'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--enable_2x_book', default=default('--enable_2x_book'), choices=['是', '否'], help='Enable or disable 2x book (spends 2x oil/emotion for 2x item drops)', gooey_options={'label_color': '#4B5F83'})

    stop = stage.add_argument_group('停止條件', '出發後不會馬上停止, 會先完成目前出擊, 不需要就填0', gooey_options={'label_color': '#931D03'})
    stop.add_argument('--如果出擊數大於', default=default('--如果出擊數大於'), help='會沿用先前設定, 完成出擊將扣除次數, 直至為零', gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果時間超過', default=default('--如果時間超過'), help='使用未來24小時內的時間, 會沿用先前設定, 觸發後清零, 建議提前10分鐘左右, 以完成目前出擊。格式 14:59', gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果石油低於', default=default('--如果石油低於'), gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果獲得新船', default=default('--如果獲得新船'), choices=['是', '否'],
                      help='獲得新船後進入收穫循環',
                      gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果地圖開荒', default=default('--如果地圖開荒'), choices=['否', '地圖通關', '地圖三星', '地圖安海不打三星', '地圖安海'], help='', gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果觸發心情控制', default=default('--如果觸發心情控制'), choices=['是', '否'], help='若是, 等待回復, 完成本次, 停止\n若否, 等待回復, 完成本次, 繼續', gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果到達120級', default=default('--如果到達120級'), choices=['是', '否'], help='當艦船從119級升至120級时: \n若是, 完成本次, 停止出擊\n若否, 繼續出擊', gooey_options={'label_color': '#4B5F83'})
    # stop.add_argument('--如果船塢已滿', default=default('--如果船塢已滿'), choices=['是', '否'])

    # 出擊艦隊
    fleet = setting_parser.add_argument_group('出擊艦隊', '非活動圖或周回模式會忽略步長設定', gooey_options={'label_color': '#931D03'})
    fleet.add_argument('--啟用陣容鎖定', default=default('--啟用陣容鎖定'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    fleet.add_argument('--啟用困難圖艦隊反轉', default=default('--啟用困難圖艦隊反轉'), choices=['是', '否'], help='使用二隊打道中, 一隊打BOSS, 僅困難圖和活動困難圖生效, 開啟自律尋敵時此項不生效', gooey_options={'label_color': '#4B5F83'})
    fleet.add_argument('--啟用自律尋敵', default=default('--啟用自律尋敵'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    fleet.add_argument('--自律尋敵設置', default=default('--自律尋敵設置'), choices=['一隊道中二隊BOSS', '一隊BOSS二隊道中', '一隊全部二隊待機', '一隊待機二隊全部'], gooey_options={'label_color': '#4B5F83'})

    f1 = fleet.add_argument_group('道中隊', '開啟自律尋敵時, 這是一隊', gooey_options={'label_color': '#931D03'})
    f1.add_argument('--艦隊編號1', default=default('--艦隊編號1'), choices=['1', '2', '3', '4', '5', '6'], gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--艦隊陣型1', default=default('--艦隊陣型1'), choices=['單縱陣', '復縱陣', '輪型陣'], gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--自律模式1', default=default('--自律模式1'), choices=['自律', '手操', '中路站樁', '躲左下角'], gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--艦隊步長1', default=default('--艦隊步長1'), choices=['1', '2', '3', '4', '5', '6'], gooey_options={'label_color': '#4B5F83'})

    f2 = fleet.add_argument_group('BOSS队', '開啟自律尋敵時, 這是二隊', gooey_options={'label_color': '#931D03'})
    f2.add_argument('--艦隊編號2', default=default('--艦隊編號2'), choices=['不使用', '1', '2', '3', '4', '5', '6'], gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--艦隊陣型2', default=default('--艦隊陣型2'), choices=['單縱陣', '復縱陣', '輪型陣'], gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--自律模式2', default=default('--自律模式2'), choices=['自律', '手操', '中路站樁', '躲左下角'], gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--艦隊步長2', default=default('--艦隊步長2'), choices=['1', '2', '3', '4', '5', '6'], gooey_options={'label_color': '#4B5F83'})

    # 潛艇設定
    submarine = setting_parser.add_argument_group('潛艇設定', '僅支援:不使用、僅狩獵、每戰出擊', gooey_options={'label_color': '#931D03'})
    submarine.add_argument('--艦隊編號4', default=default('--艦隊編號4'), choices=['不使用', '1', '2'], gooey_options={'label_color': '#4B5F83'})
    submarine.add_argument('--潛艇出擊方案', default=default('--潛艇出擊方案'), choices=['不使用', '僅狩獵', '每戰出擊', '空彈出擊', 'BOSS戰出擊', 'BOSS戰BOSS出現後招喚'], gooey_options={'label_color': '#4B5F83'})

    # 心情控制
    emotion = setting_parser.add_argument_group('心情控制', gooey_options={'label_color': '#931D03'})
    emotion.add_argument('--啟用心情消耗', default=default('--啟用心情消耗'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    emotion.add_argument('--無視紅臉出擊警告', default=default('--無視紅臉出擊警告'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    e1 = emotion.add_argument_group('道中隊', gooey_options={'label_color': '#931D03'})
    e1.add_argument('--心情回復1', default=default('--心情回復1'), choices=['未放置於後宅', '後宅一樓', '後宅二樓'], gooey_options={'label_color': '#4B5F83'})
    e1.add_argument('--心情控制1', default=default('--心情控制1'), choices=['保持經驗加成', '防止綠臉', '防止黃臉', '防止紅臉'], gooey_options={'label_color': '#4B5F83'})
    e1.add_argument('--全員已婚1', default=default('--全員已婚1'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    e2 = emotion.add_argument_group('BOSS隊', gooey_options={'label_color': '#931D03'})
    e2.add_argument('--心情回復2', default=default('--心情回復2'), choices=['未放置於後宅', '後宅一樓', '後宅二樓'], gooey_options={'label_color': '#4B5F83'})
    e2.add_argument('--心情控制2', default=default('--心情控制2'), choices=['保持經驗加成', '防止綠臉', '防止黃臉', '防止紅臉'], gooey_options={'label_color': '#4B5F83'})
    e2.add_argument('--全員已婚2', default=default('--全員已婚2'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    # 血量平衡
    hp = setting_parser.add_argument_group('血量控制', '需關閉艦隊鎖定才能生效', gooey_options={'label_color': '#931D03'})
    hp.add_argument('--啟用血量平衡', default=default('--啟用血量平衡'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    hp.add_argument('--啟用低血量撤退', default=default('--啟用低血量撤退'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    hp_balance = hp.add_argument_group('血量平衡', '', gooey_options={'label_color': '#4B5F83'})
    hp_balance.add_argument('--先鋒血量平衡閾值', default=default('--先鋒血量平衡閾值'), help='血量差值大於閾值時, 換位', gooey_options={'label_color': '#4B5F83'})
    hp_balance.add_argument('--先鋒血量權重', default=default('--先鋒血量權重'), help='先鋒肉度有差別時應修改, 格式 1000,1000,1000', gooey_options={'label_color': '#4B5F83'})
    hp_add = hp.add_argument_group('緊急維修', '', gooey_options={'label_color': '#4B5F83'})
    hp_add.add_argument('--緊急維修單人閾值', default=default('--緊急維修單人閾值'), help='單人低於閾值時使用', gooey_options={'label_color': '#4B5F83'})
    hp_add.add_argument('--緊急維修全隊閾值', default=default('--緊急維修全隊閾值'), help='前排全部或後排全部低於閾值時使用', gooey_options={'label_color': '#4B5F83'})
    hp_withdraw = hp.add_argument_group('低血量撤退', '', gooey_options={'label_color': '#4B5F83'})
    hp_withdraw.add_argument('--低血量撤退閾值', default=default('--低血量撤退閾值'), help='任意一人血量低於閾值時, 撤退', gooey_options={'label_color': '#4B5F83'})

    # 退役選項
    retire = setting_parser.add_argument_group('退役設定', '', gooey_options={'label_color': '#931D03'})
    retire.add_argument('--啟用退役', default=default('--啟用退役'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--退役方案', default=default('--退役方案'), choices=['強化角色', '一鍵退役', '傳統退役'], help='若選擇強化, 當強化材料不足時, 將使用一鍵退役', gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--退役數量', default=default('--退役數量'), choices=['退役全部', '退役10個'], gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--強化常用角色', default=default('--強化常用角色'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--強化過濾字符串', default=default('--強化過濾字符串'), help='格式: "cv > bb > ...", 留空則使用默認強化方式', gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--強化每分類數量', default=default('--強化每分類數量'), help='每個艦船分類最多強化多少艦船, 在戰鬥中的艦船會被跳過且不計入', gooey_options={'label_color': '#4B5F83'})

    rarity = retire.add_argument_group('退役稀有度', '暫不支援艦種選擇, 使用一鍵退役時忽略以下選項', gooey_options={'label_color': '#931D03'})
    rarity.add_argument('--退役白皮', default=default('--退役白皮'), choices=['是', '否'], help='N', gooey_options={'label_color': '#4B5F83'})
    rarity.add_argument('--退役藍皮', default=default('--退役藍皮'), choices=['是', '否'], help='R', gooey_options={'label_color': '#4B5F83'})
    # rarity.add_argument('--退役紫皮', default=default('--退役紫皮'), choices=['是', '否'], help='SR', gooey_options={'label_color': '#4B5F83'})
    # rarity.add_argument('--退役金皮', default=default('--退役金皮'), choices=['是', '否'], help='SSR', gooey_options={'label_color': '#4B5F83'})

    # 掉落記錄
    drop = setting_parser.add_argument_group('掉落記錄', '保存掉落物品的截圖, 啟用後會放緩結算時的點擊速度', gooey_options={'label_color': '#931D03'})
    drop.add_argument('--啟用掉落記錄', default=default('--啟用掉落記錄'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    drop.add_argument('--掉落保存目錄', default=default('--掉落保存目錄'), gooey_options={'label_color': '#4B5F83'})

    # clear = setting_parser.add_argument_group('開荒模式', '未開荒地圖會在完成後停止, 已開荒的地圖會忽略此選項, 無腦開就結束了')
    # clear.add_argument('--啟用開荒', default=default('--啟用開荒'), choices=['是', '否'])
    # clear.add_argument('--開荒停止條件', default=default('--開荒停止條件'), choices=['地圖通關', '地圖三星', '地圖安海'])
    # clear.add_argument('--地圖全清星星', default=default('--地圖全清星星'), choices=['第一個', '第二個', '第三個', '不使用'], help='第幾顆星星是擊破所有敵艦')

    # ==========收成設定==========
    reward_parser = subs.add_parser('收成設定')
    reward_condition = reward_parser.add_argument_group('觸發條件', '需要執行一次來保存選項, 執行後會進入掛機收成模式', gooey_options={'label_color': '#931D03'})
    reward_condition.add_argument('--啟用收穫', default=default('--啟用收穫'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_condition.add_argument('--收成間隔', default=default('--收成間隔'), help='每隔多少分鐘觸發收成, 推薦使用時間區間, 比如"10, 40"', gooey_options={'label_color': '#4B5F83'})
    reward_condition.add_argument('--收成間隔關閉遊戲', default=default('--收成間隔關閉遊戲'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_condition.add_argument('--啟用每日收穫', default=default('--啟用每日收穫'), choices=['是', '否'], help='將每日任務困難演習作為收穫的一部份來執行', gooey_options={'label_color': '#4B5F83'})

    reward_general = reward_parser.add_argument_group('日常收穫', '', gooey_options={'label_color': '#931D03'})
    reward_general.add_argument('--啟用石油收穫', default=default('--啟用石油收穫'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_general.add_argument('--啟用物資收穫', default=default('--啟用物資收穫'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_general.add_argument('--啟用任務收穫', default=default('--啟用任務收穫'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_general.add_argument('--啟用檔案密鑰收穫', default=default('--啟用檔案密鑰收穫'), help='領取作戰檔案的檔案密鑰', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    reward_dorm = reward_parser.add_argument_group('後宅設定', '', gooey_options={'label_color': '#931D03'})
    reward_dorm.add_argument('--啟用後宅收穫', default=default('--啟用後宅收穫'), choices=['是', '否'], help='收穫好感度和家具幣', gooey_options={'label_color': '#4B5F83'})
    reward_dorm.add_argument('--啟用後宅餵食', default=default('--啟用後宅餵食'), choices=['是', '否'], help='後宅餵食', gooey_options={'label_color': '#4B5F83'})
    reward_dorm.add_argument('--後宅收穫間隔', default=default('--後宅收穫間隔'),
                             help='每隔多少分鐘觸發, 推薦使用時間區間, 比如"10, 40"', gooey_options={'label_color': '#4B5F83'})
    reward_dorm.add_argument('--後宅餵食間隔', default=default('--後宅餵食間隔'),
                             help='每隔多少分鐘觸發, 推薦使用時間區間, 比如"10, 40"\n後宅六船時, 使用六種食物分別需要間隔大於\n(14, 28, 42, 70, 139, 278)', gooey_options={'label_color': '#4B5F83'})
    reward_dorm.add_argument('--後宅餵食優先', default=default('--後宅餵食優先'), help='仿照科研過濾字符串', gooey_options={'label_color': '#4B5F83'})

    reward_commission = reward_parser.add_argument_group('委託設定', '', gooey_options={'label_color': '#931D03'})
    reward_commission.add_argument('--啟用委託收穫', default=default('--啟用委託收穫'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_commission.add_argument('--委託時間限制', default=default('--委託時間限制'), help='忽略完成時間超過限制的委託, 格式:23:30, 不需要就填0', gooey_options={'label_color': '#4B5F83'})

    priority1 = reward_commission.add_argument_group('委託耗時優先級', '', gooey_options={'label_color': '#931D03'})
    priority1.add_argument('--委託耗時小於2h', default=default('--委託耗時小於2h'), help='', gooey_options={'label_color': '#4B5F83'})
    priority1.add_argument('--委託耗時超過6h', default=default('--委託耗時超過6h'), help='', gooey_options={'label_color': '#4B5F83'})
    priority1.add_argument('--委託過期小於2h', default=default('--委託過期小於2h'), help='', gooey_options={'label_color': '#4B5F83'})
    priority1.add_argument('--委託過期大於6h', default=default('--委託過期大於6h'), help='', gooey_options={'label_color': '#4B5F83'})

    priority2 = reward_commission.add_argument_group('日常委託優先級', '', gooey_options={'label_color': '#931D03'})
    priority2.add_argument('--日常委託', default=default('--日常委託'), help='日常資源開發, 高階戰術研發', gooey_options={'label_color': '#4B5F83'})
    priority2.add_argument('--主要委託', default=default('--主要委託'), help='1200油/1000油委託', gooey_options={'label_color': '#4B5F83'})

    priority3 = reward_commission.add_argument_group('額外委託優先級', '', gooey_options={'label_color': '#931D03'})
    priority3.add_argument('--鑽頭類額外委託', default=default('--鑽頭類額外委託'), help='短距離航行訓練, 近海防衛巡邏', gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--部件類額外委託', default=default('--部件類額外委託'), help='礦脈護衛委託, 林木護衛委託', gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--魔方類額外委託', default=default('--魔方類額外委託'), help='艦隊高階演習, 艦隊護衛演習', gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--石油類額外委託', default=default('--石油類額外委託'), help='小型油田開發, 大型油田開發', gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--教材類額外委託', default=default('--教材類額外委託'), help='小型商船護衛, 大型商船護衛', gooey_options={'label_color': '#4B5F83'})

    priority4 = reward_commission.add_argument_group('緊急委託優先級', '', gooey_options={'label_color': '#931D03'})
    priority4.add_argument('--鑽頭類緊急委託', default=default('--鑽頭類緊急委託'), help='保衛運輸部隊, 殲滅敵精銳部隊', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--部件類緊急委託', default=default('--部件類緊急委託'), help='支援維拉維拉島, 支援恐班納', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--魔方類緊急委託', default=default('--魔方類緊急委託'), help='解救商船, 敵襲', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--教材類緊急委託', default=default('--教材類緊急委託'), help='支援土豪爾島, 支援萌島', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--裝備類緊急委託', default=default('--裝備類緊急委託'), help='BIW裝備運輸, NYB裝備研發', gooey_options={'label_color': '#4B5F83' })
    priority4.add_argument('--鑽石類緊急委託', default=default('--鑽石類緊急委託'), help='BIW要員護衛, NYB巡視護衛', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--觀艦類緊急委託', default=default('--觀艦類緊急委託'), help='小型觀艦儀式, 同盟觀艦儀式', gooey_options={'label_color': '#4B5F83'})

    reward_tactical = reward_parser.add_argument_group('戰術學院', '只支援續技能書, 不支援學新技能', gooey_options={'label_color': '#931D03'})
    reward_tactical.add_argument('--啟用戰術學院收穫', default=default('--啟用戰術學院收穫'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83' })
    # reward_tactical.add_argument('--戰術學院夜間時段', default=default('--戰術學院夜間時段'), help='格式 23:30-06:30')
    reward_tactical.add_argument('--技能書優先使用同類型', default=default('--技能書優先使用同類型'), choices=['是', '否'], help='選是, 優先使用有150%加成的\n選否, 優先使用同稀有度的技能書', gooey_options={'label_color': '#4B5F83'})
    reward_tactical.add_argument('--技能書最大稀有度', default=default('--技能書最大稀有度'), choices=['3', '2', '1'], help='最高使用T幾的技能書\nT3是金書, T2是紫書, T1是藍書\n最大值需要大於等於最小值', gooey_options={'label_color': '#4B5F83'})
    reward_tactical.add_argument('--技能書最小稀有度', default=default('--技能書最小稀有度'), choices=['3', '2', '1'], help='最低使用T幾的技能書\n', gooey_options={'label_color': '#4B5F83'})
    # reward_tactical.add_argument('--技能書夜間稀有度', default=default('--技能書夜間稀有度'), choices=['3', '2', '1'])
    # reward_tactical.add_argument('--技能書夜間優先使用同類型', default=default('--技能書夜間優先使用同類型'), choices=['是', '否'])
    reward_tactical.add_argument('--如果無技能書可用', default=default('--如果無技能書可用'), choices=['停止學習', '使用第一本'], gooey_options={'label_color': '#4B5F83'})

    reward_research = reward_parser.add_argument_group('科研項目', '科研預設選擇為自定義時, 須先閱讀 doc/filter_string_en_cn.md', gooey_options={'label_color': '#931D03'})
    reward_research.add_argument('--啟用科研項目收穫', default=default('--啟用科研項目收穫'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83' })
    research_input = reward_research.add_argument_group('科研投入', '', gooey_options={'label_color': '#931D03'})
    research_input.add_argument('--科研項目使用魔方', default=default('--科研項目使用魔方'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83' })
    research_input.add_argument('--科研項目使用金幣', default=default('--科研項目使用金幣'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83' })
    research_input.add_argument('--科研項目使用部件', default=default('--科研項目使用部件'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83' })
    research_output = reward_research.add_argument_group('科研產出', '', gooey_options={'label_color': '#931D03'})
    research_output.add_argument('--科研項目選擇預設', default=default('--科研項目選擇預設'), choices=research_preset, gooey_options={'label_color': '#4B5F83'})
    research_output.add_argument('--科研過濾字符串', default=default('--科研過濾字符串'), help='僅在科研預設選擇為自定義時啟用', gooey_options={'label_color': '#4B5F83'})

    reward_meowfficer = reward_parser.add_argument_group('商店購買', '如果已經買過則自動跳過', gooey_options={'label_color': '#931D03'})
    reward_meowfficer.add_argument('--買指揮喵', default=default('--買指揮喵'), help='從0到15, 不需要就填0', gooey_options={'label_color': '#4B5F83'})
    reward_meowfficer.add_argument('--訓練指揮喵', default=default('--訓練指揮喵'), help='啟用指揮喵訓練, 每天收一隻, 週日收穫全部', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    reward_guild = reward_parser.add_argument_group('大艦隊', '檢查大艦隊後勤和大艦隊作戰', gooey_options={'label_color': '#931D03'})
    reward_guild.add_argument('--啟用大艦隊後勤', default=default('--啟用大艦隊後勤'), help='領取大艦隊任務, 提交籌備物資, 領取艦隊獎勵', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_guild.add_argument('--啟用大艦隊作戰', default=default('--啟用大艦隊作戰'), help='執行大艦隊作戰派遣, 打大艦隊BOSS', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_guild.add_argument('--大艦隊收穫間隔', default=default('--大艦隊收穫間隔'), help='每隔多少分鐘觸發, 推薦使用時間區間, 比如"10, 40"', gooey_options={'label_color': '#4B5F83'})
    reward_guild_logistics_items = reward_guild.add_argument_group('籌備物品提交順序', '可用字符: t1, t2, t3, oxycola, coolant, coins, oil, and merit. 省略某個字符來跳過該物品的提交', gooey_options={'label_color': '#4B5F83'})
    reward_guild_logistics_items.add_argument('--物品提交順序', default=default('--物品提交順序'), gooey_options={'label_color': '#4B5F83'})
    reward_guild_logistics_plates = reward_guild.add_argument_group('籌備部件提交順序', '可用字符: torpedo, antiair, plane, gun, and general. 省略某個字符來跳過該物品的提交', gooey_options={'label_color': '#4B5F83'})
    reward_guild_logistics_plates.add_argument('--部件提交順序T1', default=default('--部件提交順序T1'), gooey_options={'label_color': '#4B5F83'})
    reward_guild_logistics_plates.add_argument('--部件提交順序T2', default=default('--部件提交順序T2'), gooey_options={'label_color': '#4B5F83'})
    reward_guild_logistics_plates.add_argument('--部件提交順序T3', default=default('--部件提交順序T3'), gooey_options={'label_color': '#4B5F83'})
    reward_guild_operations_join = reward_guild.add_argument_group('Operations guild join threshold',
                        'Enter between 0 and 1\nEx) \'0.5\' join if current progress roughly less than half or \'1\' join regardless of progress', gooey_options={'label_color': '#4B5F83'})
    reward_guild_operations_join.add_argument('--guild_operations_join_threshold', default=default('--guild_operations_join_threshold'), gooey_options={'label_color': '#4B5F83'})
    reward_guild_operations_boss = reward_guild.add_argument_group('Operations guild raid boss input', '', gooey_options={'label_color': '#4B5F83'})
    reward_guild_operations_boss.add_argument('--啟用大艦隊BOSS出擊', default=default('--啟用大艦隊BOSS出擊'), help='自動打大艦隊BOSS, 需要預先在遊戲內設置隊伍', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_guild_operations_boss.add_argument('--啟用大艦隊BOSS隊伍推薦', default=default('--啟用大艦隊BOSS隊伍推薦'), help='使用遊戲自動推薦的隊伍打BOSS', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    # ==========設備設定==========
    emulator_parser = subs.add_parser('設備設定')
    emulator = emulator_parser.add_argument_group('模擬器', '需要運行一次來保存選項, 會檢查遊戲是否啟動\n若啟動了遊戲, 觸發一次收菜', gooey_options={'label_color': '#931D03'})
    emulator.add_argument('--設備', default=default('--設備'), help='例如 127.0.0.1:62001', gooey_options={'label_color': '#4B5F83'})
    emulator.add_argument('--包名', default=default('--包名'), help='', gooey_options={'label_color': '#4B5F83'})
    emulator.add_argument(
        '默認serial列表',
        default=message,
        widget='Textarea',
        help="以下是一些常見模擬器的默認serial\n如果你使用了模擬器多開, 它們將不使用默認的serial",
        gooey_options={
            'height': 150,
            'show_help': True,
            'show_label': True,
            'readonly': True,
            'label_color': '#4B5F83'
        }
    )

    debug = emulator_parser.add_argument_group('調試設定', '', gooey_options={'label_color': '#931D03'})
    debug.add_argument('--出錯時保存log和截圖', default=default('--出錯時保存log和截圖'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    debug.add_argument('--保存透視識別出錯的圖像', default=default('--保存透視識別出錯的圖像'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    adb = emulator_parser.add_argument_group('ADB設定', '', gooey_options={'label_color': '#931D03'})
    adb.add_argument('--設備截圖方案', default=default('--設備截圖方案'), choices=['aScreenCap', 'uiautomator2', 'ADB'], help='速度: aScreenCap >> uiautomator2 > ADB', gooey_options={'label_color': '#4B5F83'})
    adb.add_argument('--設備控制方案', default=default('--設備控制方案'), choices=['minitouch','uiautomator2', 'ADB'], help='速度: minitouch >> uiautomator2 >> ADB', gooey_options={'label_color': '#4B5F83'})
    adb.add_argument('--戰鬥中截圖間隔', default=default('--戰鬥中截圖間隔'), help='戰鬥中放慢截圖速度, 降低CPU使用', gooey_options={'label_color': '#4B5F83'})

    update = emulator_parser.add_argument_group('更新檢查', '', gooey_options={'label_color': '#931D03'})
    update.add_argument('--啟用更新檢查', default=default('--啟用更新檢查'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    update.add_argument('--更新檢查方法', default=default('--更新檢查方法'), choices=['api', 'web'], help='使用api時建議填寫tokens, 使用web則不需要', gooey_options={'label_color': '#4B5F83'})
    update.add_argument('--github_token', default=default('--github_token'), help='Github API限制為每小時60次, 獲取tokens https://github.com/settings/tokens', gooey_options= {'label_color': '#4B5F83'})
    update.add_argument('--更新檢查代理', default=default('--更新檢查代理'), help='本地http或socks代理, 如果github很慢, 請使用代理, example: http://127.0 .0.1:10809', gooey_options={'label_color': '#4B5F83'})

    # ==========每日任務==========
    daily_parser = subs.add_parser('每日任務困難演習')

    # 選擇每日
    daily = daily_parser.add_argument_group('選擇每日', '每日任務, 演習, 困難圖', gooey_options={'label_color': '#931D03'})
    daily.add_argument('--打每日', default=default('--打每日'), help='若當天有記錄, 則跳過', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打困難', default=default('--打困難'), help='若當天有記錄, 則跳過', choices=['是', '否'], gooey_options= {'label_color': '#4B5F83'})
    daily.add_argument('--打演習', default=default('--打演習'), help='若在刷新後有記錄, 則跳過', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打共鬥每日15次', default=default('--打共鬥每日15次'), help='若當天有記錄, 則跳過', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打活動圖每日三倍PT', default=default('--打活動圖每日三倍PT'), help='若當天有記錄, 則跳過', choices= ['是', '否'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打活動每日SP圖', default=default('--打活動每日SP圖'), help='若當天有記錄, 則跳過', choices=['是' , '否'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打大世界餘燼信標支援', default=default('--打大世界餘燼信標支援'), help='若當天有記錄, 則跳過', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    # 每日設定
    daily_task = daily_parser.add_argument_group('每日設定', '', gooey_options={'label_color': '#931D03'})
    daily_task.add_argument('--使用每日掃蕩', default=default('--使用每日掃蕩'), help='每日掃蕩可用時使用掃蕩', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--戰術研修', default=default('--戰術研修'), choices=['航空', '砲擊', '雷擊'], gooey_options={'label_color': '#4B5F83' })
    daily_task.add_argument('--斬首行動', default=default('--斬首行動'), choices=['第一個', '第二個', '第三個'], gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--破交作戰', default=default('--破交作戰'), choices=['第一個', '第二個', '第三個'], help='需要解鎖掃蕩, 未解鎖時跳過', gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--商船護航', default=default('--商船護航'), choices=['第一個', '第二個', '第三個'], gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--海域突進', default=default('--海域突進'), choices=['第一個', '第二個', '第三個'], gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--每日艦隊', default=default('--每日艦隊'), help='如果使用同一隊, 填艦隊編號, 例如5\n如果使用不同隊, 用半形逗號分割, 順序為商船護送, 海域突進, 斬首行動, 戰術研修\n例如5, 5, 5, 6', gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--每日艦隊快速換裝', default=default('--每日艦隊快速換裝'), help='打之前換裝備, 打完後卸裝備, 不需要就填0 \n半形逗號分割, 例如3, 1, 0, 1, 1, 0', gooey_options={'label_color': '#4B5F83'})

    # 困難設定
    hard = daily_parser.add_argument_group('困難設定', '需要地圖達到週回模式', gooey_options={'label_color': '#931D03'})
    hard.add_argument('--困難地圖', default=default('--困難地圖'), help='比如 10-4', gooey_options={'label_color': '#4B5F83'})
    hard.add_argument('--困難艦隊', default=default('--困難艦隊'), choices=['1', '2'], gooey_options={'label_color': '#4B5F83'})
    hard.add_argument('--困難艦隊快速換裝', default=default('--困難艦隊快速換裝'), help='打之前換裝備, 打完後卸裝備, 不需要就填0\n半形逗號分割, 例如3, 1, 0, 1, 1, 0', gooey_options={'label_color': '#4B5F83'})


    # 演習設定
    exercise = daily_parser.add_argument_group('演習設定', '', gooey_options={'label_color': '#931D03'})
    exercise.add_argument('--演習對手選擇', default=default('--演習對手選擇'), choices=['經驗最多', '最簡單', '最左边', '先最簡單再經驗最多'], help= '', gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演習次數保留', default=default('--演習次數保留'), help='例如 1, 表示打到1/10停止', gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演習嘗試次數', default=default('--演習嘗試次數'), help='每個對手的嘗試次數, 打不過就換', gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演習SL閾值', default=default('--演習SL閾值'), help='HP<閾值時撤退', gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演習低血量確認時長', default=default('--演習低血量確認時長'), help='HP低於閾值後, 過一定時長才會撤退\n推薦1.0 ~ 3.0', gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演習快速換裝', default=default('--演習快速換裝'), help='打之前換裝備, 打完後卸裝備, 不需要就填0\n半形逗號分割, 例如3, 1, 0, 1, 1, 0', gooey_options={'label_color': '#4B5F83'})

    # 每日活動圖三倍PT
    event_bonus = daily_parser.add_argument_group('活動設定', '', gooey_options={'label_color': '#931D03'})
    event_bonus.add_argument('--活動獎勵章節', default=default('--活動獎勵章節'), choices=['AB圖', 'ABCD圖', 'T圖', 'HT圖'], help ='有額外PT獎勵章節', gooey_options={'label_color': '#4B5F83'})
    event_bonus.add_argument('--活動SP圖道中隊', default=default('--活動SP圖道中隊'), choices=['1', '2'], help='', gooey_options={'label_color': '#4B5F83'})
    event_bonus.add_argument('--活動名稱ab', default=event_latest, choices=event_folder, help='例如 event_20200326_cn', gooey_options={'label_color': '#4B5F83'})

    # 共鬥每日設定
    raid_bonus = daily_parser.add_argument_group('共鬥設定', '', gooey_options={'label_color': '#931D03'})
    raid_bonus.add_argument('--共鬥每日名稱', default=raid_latest, choices=raid_folder, help='', gooey_options={'label_color': '#4B5F83'})
    raid_bonus.add_argument('--共鬥困難', default=default('--共鬥困難'), choices=['是', '否'], help='', gooey_options={'label_color': '#4B5F83'})
    raid_bonus.add_argument('--共鬥普通', default=default('--共鬥普通'), choices=['是', '否'], help='', gooey_options={'label_color': '#4B5F83'})
    raid_bonus.add_argument('--共鬥簡單', default=default('--共鬥簡單'), choices=['是', '否'], help='', gooey_options={'label_color': '#4B5F83'})

    # 大世界每日設置
    raid_bonus = daily_parser.add_argument_group('大世界設置', '', gooey_options={'label_color': '#931D03'})
    raid_bonus.add_argument('--大世界信標支援強度', default=default('--大世界信標支援強度'), help='尋找大於等於此強度的信標', gooey_options={'label_color': '#4B5F83'})

    # # ==========每日活動圖三倍PT==========
    # event_ab_parser = subs.add_parser('每日活動圖三倍PT')
    # event_name = event_ab_parser.add_argument_group('選擇活動', '')
    # event_name.add_argument('--活動名稱ab', default=event_latest, choices=event_folder, help='例如 event_20200326_cn')

    # ==========主線圖==========
    main_parser = subs.add_parser('主線圖')
    # 選擇關卡
    stage = main_parser.add_argument_group('選擇關卡', '', gooey_options={'label_color': '#931D03'})
    stage.add_argument('--主線地圖出擊', default=default('--主線地圖出擊'), help='例如 7-2', gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--主線地圖模式', default=default('--主線地圖模式'), help='僅困難圖開荒時使用, 週回模式後請使用每日困難', choices=['普通', '困難'], gooey_options={'label_color': '#4B5F83'})

    # ==========活動圖==========
    event_parser = subs.add_parser('活動圖')

    description = """
    出擊未優化關卡或地圖未達到安全海域時, 使用開荒模式運行(較慢)
    """
    event = event_parser.add_argument_group(
        '選擇關卡', '\n'.join([line.strip() for line in description.strip().split('\n')]), gooey_options={'label_color': '#931D03'})
    event.add_argument('--活動地圖', default=default('--活動地圖'), help='輸入地圖名稱, 不分大小寫, 例如D3, SP3, HT6', gooey_options={'label_color': '#4B5F83'})
    event.add_argument('--活動名稱', default=event_latest, choices=event_folder, help='例如 event_20200312_cn', gooey_options={'label_color': '#4B5F83'})

    # ==========潛艇圖==========
    sos_parser = subs.add_parser('潛艇圖')
    sos = sos_parser.add_argument_group(
        '潛艇圖設定', '設定每張潛艇圖的隊伍, 順序: 一隊二隊潛艇隊\n例如"4, 6", "4, 0", "4, 6, 1"\n填0跳過不打', gooey_options={'label_color': '#931D03'})
    sos.add_argument('--第3章潛艇圖隊伍', default=default('--第3章潛艇圖隊伍'), gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第4章潛艇圖隊伍', default=default('--第4章潛艇圖隊伍'), gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第5章潛艇圖隊伍', default=default('--第5章潛艇圖隊伍'), gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第6章潛艇圖隊伍', default=default('--第6章潛艇圖隊伍'), gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第7章潛艇圖隊伍', default=default('--第7章潛艇圖隊伍'), gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第8章潛艇圖隊伍', default=default('--第8章潛艇圖隊伍'), gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第9章潛艇圖隊伍', default=default('--第9章潛艇圖隊伍'), gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第10章潛艇圖隊伍', default=default('--第10章潛艇圖隊伍'), gooey_options={'label_color': '#4B5F83'})

    # ==========作戰檔案==========
    war_archives_parser = subs.add_parser('作戰檔案')
    war_archives = war_archives_parser.add_argument_group(
        '作戰檔案設置', '輸入地圖名稱, 然後選擇對應的活動', gooey_options={'label_color': '#931D03'})
    war_archives.add_argument('--作戰檔案地圖', default=default('--作戰檔案地圖'), help='輸入地圖名稱, 不分大小寫, 例如D3, SP3, HT6', gooey_options={'label_color': '#4B5F83'})
    war_archives.add_argument('--作戰檔案活動', default=default('--作戰檔案活動'), choices=archives_folder, help='在下拉菜單中選擇活動', gooey_options={'label_color': '#4B5F83'})

    # ==========共鬥活動==========
    raid_parser = subs.add_parser('共鬥活動')
    raid = raid_parser.add_argument_group('選擇共鬥', '', gooey_options={'label_color': '#931D03'})
    raid.add_argument('--共鬥名稱', default=raid_latest, choices=raid_folder, help='', gooey_options={'label_color': '#4B5F83'})
    raid.add_argument('--共鬥難度', default=default('--共鬥難度'), choices=['困難', '普通', '簡單'], help='', gooey_options={'label_color': '#4B5F83'})
    raid.add_argument('--共鬥使用挑戰券', default=default('--共鬥使用挑戰券'), choices=['是', '否'], help='', gooey_options={'label_color': '#4B5F83'})

    # ==========半自動==========
    semi_parser = subs.add_parser('半自動輔助點擊')
    semi = semi_parser.add_argument_group('半自動模式', '手動選敵, 自動結算, 用於出擊未適配的圖', gooey_options={'label_color': '#931D03'})
    semi.add_argument('--進圖準備', default=default('--進圖準備'), help='', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    semi.add_argument('--跳過劇情', default=default('--跳過劇情'), help='注意, 這會自動確認所有提示框, 包括紅臉出擊', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    # ==========1-1Affinity farming==========
    c_1_1_parser = subs.add_parser('1-1伏擊刷好感')
    c_1_1 = c_1_1_parser.add_argument_group('1-1伏擊刷好感', '會自動關閉週回模式\n有MVP, 8場戰鬥漲1點好感, 無MVP, 16場戰鬥漲1點好感', gooey_options={'label_color': '#931D03'})
    c_1_1.add_argument('--刷好感戰斗場數', default=default('--刷好感戰斗場數'), help='例如: 32', gooey_options={'label_color': '#4B5F83'})

    # ==========7-2三戰撿垃圾==========
    c_7_2_parser = subs.add_parser('7-2三戰撿垃圾')
    c_7_2 = c_7_2_parser.add_argument_group('7-2三戰撿垃圾', '', gooey_options={'label_color': '#931D03'})
    c_7_2.add_argument('--BOSS隊踩A3', default=default('--BOSS隊踩A3'), choices=['是', '否'], help='A3有敵人就G3, C3, E3', gooey_options={'label_color': '#4B5F83'})

    # ==========12-2打中型練級==========
    c_12_2_parser = subs.add_parser('12-2打中型練級')
    c_12_2 = c_12_2_parser.add_argument_group('12-2索敵設定', '', gooey_options={'label_color': '#931D03'})
    c_12_2.add_argument('--大型敵人忍耐', default=default('--大型敵人忍耐'), choices=['0', '1', '2', '10'], help='最多打多少戰大型敵人, 不挑敵人選10', gooey_options={'label_color': '#4B5F83'})

    # ==========12-4打大型練級==========
    c_12_4_parser = subs.add_parser('12-4打大型練級')
    c_12_4 = c_12_4_parser.add_argument_group('12-4索敵設定', '需保證隊伍有一定強度', gooey_options={'label_color': '#931D03'})
    c_12_4.add_argument('--非大型敵人進圖忍耐', default=default('--非大型敵人進圖忍耐'), choices=['0', '1', '2'], help='忍受進場多少戰沒有大型', gooey_options={'label_color': '#4B5F83'})
    c_12_4.add_argument('--非大型敵人撤退忍耐', default=default('--非大型敵人撤退忍耐'), choices=['0', '1', '2', '10'], help ='沒有大型之後還會打多少戰, 不挑敵人選10', gooey_options={'label_color': '#4B5F83'})
    c_12_4.add_argument('--撿彈藥124', default=default('--撿彈藥124'), choices=['2', '3', '4', '5'], help='多少戰後撿彈藥', gooey_options={'label_color': '#4B5F83'})

    # ==========OS semi auto==========
    os_semi_parser = subs.add_parser('大世界輔助點擊')
    os_semi = os_semi_parser.add_argument_group('大世界輔助點擊', '自動點擊戰鬥準備和戰鬥結算\n僅推薦在普通海域和安全海域中開啟', gooey_options={'label_color': '#931D03'})
    os_semi.add_argument('--大世界跳過劇情', default=default('--大世界跳過劇情'), choices=['是', '否'], help='注意, 這會自動點擊地圖交互的選項', gooey_options={'label_color': '#4B5F83'})

    # ==========OS clear map==========
    # os_semi_parser = subs.add_parser('大世界地圖全清')
    # os_semi = os_semi_parser.add_argument_group('大世界地圖全清', '僅在安全海域中使用, 在普通海域使用時需要先執行空域搜索\n使用方法: 先手動進入地圖, 再運行\n運行結束後, 最好手動檢查是否有遺漏', gooey_options={'label_color': '#931D03'})
    # os_semi.add_argument('--打大世界餘燼信標', default=default('--打大世界餘燼信標'), choices=['是', '否'], help='信標數據滿了之後, 打飛龍', gooey_options={'label_color': '#4B5F83'})

    # ==========OS fully auto==========
    os_parser = subs.add_parser('大世界全自動')
    os = os_parser.add_argument_group('大世界全自動', '運行順序: 接每日買補給 > 做每日 > 打隱秘海域 > 短貓相接\n港口補給是有限池, 總量恆定隨機出現, 想要買好東西需要全買\n商店優先級格式: ActionPoint > PurpleCoins > TuringSample > RepairPack', gooey_options={'label_color': '#931D03'})
    os.add_argument('--在每日中完成大世界', default=default('--在每日中完成大世界'), choices=['是', '否'], help='將大世界全自動作為每日的一部分來完成', gooey_options={'label_color': '#4B5F83'})

    os_daily = os.add_argument_group('大世界每日', '', gooey_options={'label_color': '#931D03'})
    os_daily.add_argument('--大世界接每日任務', default=default('--大世界接每日任務'), choices=['是', '否'], help='在港口領取每日任務', gooey_options={'label_color': '#4B5F83'})
    os_daily.add_argument('--大世界完成每日', default=default('--大世界完成每日'), choices=['是', '否'], help='前往每日的海域, 並清理', gooey_options={'label_color': '#4B5F83'})
    os_daily.add_argument('--大世界港口補給', default=default('--大世界港口補給'), choices=['是', '否'], help='買光所有的港口補給', gooey_options={'label_color': '#4B5F83'})
    os_daily.add_argument('--打大世界餘燼信標', default=default('--打大世界餘燼信標'), choices=['是', '否'], help='信標數據滿了之後, 打飛龍', gooey_options={'label_color': '#4B5F83'})

    os_farm = os.add_argument_group('打大世界', '', gooey_options={'label_color': '#931D03'})
    os_farm.add_argument('--打大世界隱秘海域', default=default('--打大世界隱秘海域'), choices=['是', '否'], help='[開發中]清理所有隱秘海域', gooey_options={'label_color': '#4B5F83'})
    os_farm.add_argument('--大世界短貓相接', default=default('--大世界短貓相接'), choices=['是', '否'], help='反复打圖揀貓點', gooey_options={'label_color': '#4B5F83'})
    os_farm.add_argument('--短貓相接侵蝕等級', default=default('--短貓相接侵蝕等級'), choices=['1', '2', '3', '4', '5', '6'], help='侵蝕3和5有更高的貓點/行動力比, 建議選侵蝕5', gooey_options={'label_color': '#4B5F83'})

    os_setting = os.add_argument_group('大世界設置', '', gooey_options={'label_color': '#931D03'})
    os_setting.add_argument('--大世界買行動力', default=default('--大世界買行動力'), choices=['是', '否'], help='用石油買行動力, 先買再開箱子', gooey_options={'label_color': '#4B5F83'})
    os_setting.add_argument('--大世界行動力保留', default=default('--大世界行動力保留'), help='低於此值後停止, 含行動力箱子', gooey_options={'label_color': '#4B5F83'})

    os_shop = os.add_argument_group('大世界商店', '', gooey_options={'label_color': '#931D03'})
    os_shop.add_argument('--明石商店購買', default=default('--明石商店購買'), choices=['是', '否'], help='', gooey_options={'label_color': '#4B5F83'})
    os_shop.add_argument('--明石商店優先級', default=default('--明石商店優先級'), help='', gooey_options={'label_color': '#4B5F83'})

    args = parser.parse_args()

    # Convert option from chinese to english.
    out = {}
    for key, value in vars(args).items():
        key = dic_gui_to_ini.get(key, key)
        value = dic_gui_to_ini.get(value, value)
        out[key] = value
    args = out

    # Update option to .ini file.
    command = args['command'].capitalize()
    config['Command']['command'] = command
    for key, value in args.items():
        config[command][key] = str(value)
    config.write(codecs.open(config_file, "w+", "utf8"))

    # Call AzurLaneAutoScript
    alas = AzurLaneAutoScript(ini_name=ini_name)
    alas.run(command=command)
Beispiel #8
0
def main(ini_name=''):
    if not ini_name:
        ini_name = pyw_name
    config_file = f'./config/{ini_name}.ini'
    config = get_config(ini_name.lower())

    # Load translation dictionary
    dic_gui_to_ini = dic_chi_to_eng  # GUI translation dictionary here.
    dic_gui_to_ini.update(dic_event[server.server])
    dic_gui_to_ini.update(dic_archives[server.server])
    dic_ini_to_gui = {v: k for k, v in dic_gui_to_ini.items()}
    # Event list
    event_folder = [f for f in dic_event[server.server].values() if f.startswith('event_')]
    event_latest = event_folder[-1]
    event_folder = [dic_ini_to_gui.get(f, f) for f in event_folder][::-1]
    event_latest = dic_ini_to_gui.get(event_latest, event_latest)
    # Archives list
    archives_folder = [f for f in dic_archives[server.server].values() if f.startswith('war_archives_')]
    archives_folder = [dic_ini_to_gui.get(f, f) for f in archives_folder][::-1]
    # Raid list
    raid_folder = [f for f in dic_event[server.server].values() if f.startswith('raid_')]
    raid_latest = raid_folder[-1]
    raid_folder = [dic_ini_to_gui.get(f, f) for f in raid_folder][::-1]
    raid_latest = dic_ini_to_gui.get(raid_latest, raid_latest)
    # Research preset list
    research_preset = [dic_ini_to_gui.get(f, f) for f in ['customized'] + list(DICT_FILTER_PRESET.keys())]
    # Translate settings in ini file
    saved_config = {}
    for opt, option in config.items():
        for key, value in option.items():
            key = dic_ini_to_gui.get(key, key)
            if value in dic_ini_to_gui:
                value = dic_ini_to_gui.get(value, value)
            if value == 'None':
                value = ''
            saved_config[key] = value
    message = (
        '蓝叠模拟器:\t127.0.0.1:5555\n'
        '夜神模拟器:\t127.0.0.1:62001\n'
        'MuMu模拟器:\t127.0.0.1:7555\n'
        '逍遥模拟器:\t127.0.0.1:21503\n'
        '雷电模拟器:\temulator-5554\n'
    )

    def default(name):
        """Get default value in .ini file.
        Args:
            name (str): option, in chinese.

        Returns:
            str: Default value, in chinese.
        """
        name = name.strip('-')
        return saved_config.get(name, '')

    def choice_list(total):
        return [str(index) for index in range(1, total + 1)]

    # Don't use checkbox in gooey, use drop box instead.
    # https://github.com/chriskiehl/Gooey/issues/148
    # https://github.com/chriskiehl/Gooey/issues/485

    parser = GooeyParser(description=f'AzurLaneAutoScript, An Azur Lane automation tool. Config: {config_file}\n功能都是分别保存和运行的, 修改设置后别忘了点击"开始"来保存')
    subs = parser.add_subparsers(help='commands', dest='command')

    # ==========出击设置==========
    setting_parser = subs.add_parser('出击设置')

    # 选择关卡
    stage = setting_parser.add_argument_group('关卡设置', '需要运行一次来保存选项', gooey_options={'label_color': '#931D03'})
    stage.add_argument('--启用弹窗提醒', default=default('--启用弹窗提醒'), choices=['是', '否'], help='开启弹窗提醒, 仅 windows10 可用', gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--启用停止条件', default=default('--启用停止条件'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--启用异常处理', default=default('--启用异常处理'), choices=['是', '否'], help='处理部分异常, 运行出错时撤退', gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--使用周回模式', default=default('--使用周回模式'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    stop = stage.add_argument_group('停止条件', '触发后不会马上停止会先完成当前出击, 不需要就填0', gooey_options={'label_color': '#931D03'})
    stop.add_argument('--如果出击次数大于', default=default('--如果出击次数大于'), help='会沿用先前设置, 完成出击将扣除次数, 直至清零', gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果时间超过', default=default('--如果时间超过'), help='使用未来24小时内的时间, 会沿用先前设置, 触发后清零. 建议提前10分钟左右, 以完成当前出击. 格式 14:59', gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果石油低于', default=default('--如果石油低于'), gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果获得新船', default=default('--如果获得新船'), choices=['是', '否'],
                      help='获得新船后进入收获循环',
                      gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果地图开荒', default=default('--如果地图开荒'), choices=['否', '地图通关', '地图三星', '地图绿海不打三星', '地图绿海'], help='', gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果触发心情控制', default=default('--如果触发心情控制'), choices=['是', '否'], help='若是, 等待回复, 完成本次, 停止\n若否, 等待回复, 完成本次, 继续', gooey_options={'label_color': '#4B5F83'})
    stop.add_argument('--如果到达120级', default=default('--如果到达120级'), choices=['是', '否'], help='当舰船从119级升至120级时: \n若是, 完成本次, 停止出击\n若否, 继续出击', gooey_options={'label_color': '#4B5F83'})
    # stop.add_argument('--如果船舱已满', default=default('--如果船舱已满'), choices=['是', '否'])

    # 出击舰队
    fleet = setting_parser.add_argument_group('出击舰队', '非活动图或周回模式会忽略步长设置', gooey_options={'label_color': '#931D03'})
    fleet.add_argument('--启用阵容锁定', default=default('--启用阵容锁定'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    fleet.add_argument('--启用困难图舰队反转', default=default('--启用困难图舰队反转'), choices=['是', '否'], help='使用二队打道中, 一队打BOSS, 仅困难图和活动困难图生效, 开启自律寻敌时此项不生效', gooey_options={'label_color': '#4B5F83'})
    fleet.add_argument('--启用自律寻敌', default=default('--启用自律寻敌'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    fleet.add_argument('--自律寻敌设置', default=default('--自律寻敌设置'), choices=['一队道中二队BOSS', '一队BOSS二队道中', '一队全部二队待机', '一队待机二队全部'], gooey_options={'label_color': '#4B5F83'})

    f1 = fleet.add_argument_group('道中队', '开启自律寻敌时, 这是一队', gooey_options={'label_color': '#931D03'})
    f1.add_argument('--舰队编号1', default=default('--舰队编号1'), choices=['1', '2', '3', '4', '5', '6'], gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--舰队阵型1', default=default('--舰队阵型1'), choices=['单纵阵', '复纵阵', '轮形阵'], gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--自律模式1', default=default('--自律模式1'), choices=['自律', '手操', '中路站桩', '躲左下角'], gooey_options={'label_color': '#4B5F83'})
    f1.add_argument('--舰队步长1', default=default('--舰队步长1'), choices=['1', '2', '3', '4', '5', '6'], gooey_options={'label_color': '#4B5F83'})

    f2 = fleet.add_argument_group('BOSS队', '开启自律寻敌时, 这是二队', gooey_options={'label_color': '#931D03'})
    f2.add_argument('--舰队编号2', default=default('--舰队编号2'), choices=['不使用', '1', '2', '3', '4', '5', '6'], gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--舰队阵型2', default=default('--舰队阵型2'), choices=['单纵阵', '复纵阵', '轮形阵'], gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--自律模式2', default=default('--自律模式2'), choices=['自律', '手操', '中路站桩', '躲左下角'], gooey_options={'label_color': '#4B5F83'})
    f2.add_argument('--舰队步长2', default=default('--舰队步长2'), choices=['1', '2', '3', '4', '5', '6'], gooey_options={'label_color': '#4B5F83'})

    # 潜艇设置
    submarine = setting_parser.add_argument_group('潜艇设置', '仅支持: 不使用, 仅狩猎, 每战出击', gooey_options={'label_color': '#931D03'})
    submarine.add_argument('--舰队编号4', default=default('--舰队编号4'), choices=['不使用', '1', '2'], gooey_options={'label_color': '#4B5F83'})
    submarine.add_argument('--潜艇出击方案', default=default('--潜艇出击方案'), choices=['不使用', '仅狩猎', '每战出击', '空弹出击', 'BOSS战出击', 'BOSS战BOSS出现后召唤'], gooey_options={'label_color': '#4B5F83'})

    # 心情控制
    emotion = setting_parser.add_argument_group('心情控制', gooey_options={'label_color': '#931D03'})
    emotion.add_argument('--启用心情消耗', default=default('--启用心情消耗'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    emotion.add_argument('--无视红脸出击警告', default=default('--无视红脸出击警告'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    e1 = emotion.add_argument_group('道中队', gooey_options={'label_color': '#931D03'})
    e1.add_argument('--心情回复1', default=default('--心情回复1'), choices=['未放置于后宅', '后宅一楼', '后宅二楼'], gooey_options={'label_color': '#4B5F83'})
    e1.add_argument('--心情控制1', default=default('--心情控制1'), choices=['保持经验加成', '防止绿脸', '防止黄脸', '防止红脸'], gooey_options={'label_color': '#4B5F83'})
    e1.add_argument('--全员已婚1', default=default('--全员已婚1'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    e2 = emotion.add_argument_group('BOSS队', gooey_options={'label_color': '#931D03'})
    e2.add_argument('--心情回复2', default=default('--心情回复2'), choices=['未放置于后宅', '后宅一楼', '后宅二楼'], gooey_options={'label_color': '#4B5F83'})
    e2.add_argument('--心情控制2', default=default('--心情控制2'), choices=['保持经验加成', '防止绿脸', '防止黄脸', '防止红脸'], gooey_options={'label_color': '#4B5F83'})
    e2.add_argument('--全员已婚2', default=default('--全员已婚2'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    # 血量平衡
    hp = setting_parser.add_argument_group('血量控制', '需关闭舰队锁定才能生效', gooey_options={'label_color': '#931D03'})
    hp.add_argument('--启用血量平衡', default=default('--启用血量平衡'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    hp.add_argument('--启用低血量撤退', default=default('--启用低血量撤退'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    hp_balance = hp.add_argument_group('血量平衡', '', gooey_options={'label_color': '#4B5F83'})
    hp_balance.add_argument('--先锋血量平衡阈值', default=default('--先锋血量平衡阈值'), help='血量差值大于阈值时, 换位', gooey_options={'label_color': '#4B5F83'})
    hp_balance.add_argument('--先锋血量权重', default=default('--先锋血量权重'), help='先锋肉度有差别时应修改, 格式 1000,1000,1000', gooey_options={'label_color': '#4B5F83'})
    hp_add = hp.add_argument_group('紧急维修', '', gooey_options={'label_color': '#4B5F83'})
    hp_add.add_argument('--紧急维修单人阈值', default=default('--紧急维修单人阈值'), help='单人低于阈值时使用', gooey_options={'label_color': '#4B5F83'})
    hp_add.add_argument('--紧急维修全队阈值', default=default('--紧急维修全队阈值'), help='前排全部或后排全部低于阈值时使用', gooey_options={'label_color': '#4B5F83'})
    hp_withdraw = hp.add_argument_group('低血量撤退', '', gooey_options={'label_color': '#4B5F83'})
    hp_withdraw.add_argument('--低血量撤退阈值', default=default('--低血量撤退阈值'), help='任意一人血量低于阈值时, 撤退', gooey_options={'label_color': '#4B5F83'})

    # 退役选项
    retire = setting_parser.add_argument_group('退役设置', '', gooey_options={'label_color': '#931D03'})
    retire.add_argument('--启用退役', default=default('--启用退役'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--退役方案', default=default('--退役方案'), choices=['强化角色', '一键退役', '传统退役'], help='若选择强化, 当强化材料不足时, 将使用一键退役', gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--退役数量', default=default('--退役数量'), choices=['退役全部', '退役10个'], gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--强化常用角色', default=default('--强化常用角色'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--强化过滤字符串', default=default('--强化过滤字符串'), help='格式: "cv > bb > ...", 留空则使用默认强化方式', gooey_options={'label_color': '#4B5F83'})
    retire.add_argument('--强化每分类数量', default=default('--强化每分类数量'), help='每个舰船分类最多强化多少舰船, 在战斗中的舰船会被跳过且不计入', gooey_options={'label_color': '#4B5F83'})

    rarity = retire.add_argument_group('退役稀有度', '暂不支持舰种选择, 使用一键退役时忽略以下选项', gooey_options={'label_color': '#931D03'})
    rarity.add_argument('--退役白皮', default=default('--退役白皮'), choices=['是', '否'], help='N', gooey_options={'label_color': '#4B5F83'})
    rarity.add_argument('--退役蓝皮', default=default('--退役蓝皮'), choices=['是', '否'], help='R', gooey_options={'label_color': '#4B5F83'})
    # rarity.add_argument('--退役紫皮', default=default('--退役紫皮'), choices=['是', '否'], help='SR', gooey_options={'label_color': '#4B5F83'})
    # rarity.add_argument('--退役金皮', default=default('--退役金皮'), choices=['是', '否'], help='SSR', gooey_options={'label_color': '#4B5F83'})

    # 掉落记录
    drop = setting_parser.add_argument_group('掉落记录', '保存掉落物品的截图, 启用后会放缓结算时的点击速度', gooey_options={'label_color': '#931D03'})
    drop.add_argument('--启用掉落记录', default=default('--启用掉落记录'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    drop.add_argument('--掉落保存目录', default=default('--掉落保存目录'), gooey_options={'label_color': '#4B5F83'})

    # clear = setting_parser.add_argument_group('开荒模式', '未开荒地图会在完成后停止, 已开荒的地图会忽略选项, 无脑开就完事了')
    # clear.add_argument('--启用开荒', default=default('--启用开荒'), choices=['是', '否'])
    # clear.add_argument('--开荒停止条件', default=default('--开荒停止条件'), choices=['地图通关', '地图三星', '地图绿海'])
    # clear.add_argument('--地图全清星星', default=default('--地图全清星星'), choices=['第一个', '第二个', '第三个', '不使用'], help='第几颗星星是击破所有敌舰')

    # ==========收菜设置==========
    reward_parser = subs.add_parser('收菜设置')
    reward_condition = reward_parser.add_argument_group('触发条件', '需要运行一次来保存选项, 运行后会进入挂机收菜模式', gooey_options={'label_color': '#931D03'})
    reward_condition.add_argument('--启用收获', default=default('--启用收获'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_condition.add_argument('--收菜间隔', default=default('--收菜间隔'), help='每隔多少分钟触发收菜, 推荐使用时间区间, 比如"10, 40"', gooey_options={'label_color': '#4B5F83'})
    reward_condition.add_argument('--收菜间隔关闭游戏', default=default('--收菜间隔关闭游戏'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_condition.add_argument('--启用每日收获', default=default('--启用每日收获'), choices=['是', '否'], help='将每日任务困难演习作为收获的一部分来运行', gooey_options={'label_color': '#4B5F83'})

    reward_general = reward_parser.add_argument_group('日常收获', '', gooey_options={'label_color': '#931D03'})
    reward_general.add_argument('--启用石油收获', default=default('--启用石油收获'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_general.add_argument('--启用物资收获', default=default('--启用物资收获'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_general.add_argument('--启用任务收获', default=default('--启用任务收获'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_general.add_argument('--启用档案密钥收获', default=default('--启用档案密钥收获'), help='领取作战档案的档案密钥, 如果已经领取则自动跳过', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})


    reward_dorm = reward_parser.add_argument_group('后宅设置', '', gooey_options={'label_color': '#931D03'})
    reward_dorm.add_argument('--启用后宅收获', default=default('--启用后宅收获'), choices=['是', '否'], help='收获好感度和家具币', gooey_options={'label_color': '#4B5F83'})
    reward_dorm.add_argument('--启用后宅喂食', default=default('--启用后宅喂食'), choices=['是', '否'], help='后宅喂食', gooey_options={'label_color': '#4B5F83'})
    reward_dorm.add_argument('--后宅收获间隔', default=default('--后宅收获间隔'),
                             help='每隔多少分钟触发, 推荐使用时间区间, 比如"10, 40"', gooey_options={'label_color': '#4B5F83'})
    reward_dorm.add_argument('--后宅喂食间隔', default=default('--后宅喂食间隔'),
                             help='每隔多少分钟触发, 推荐使用时间区间, 比如"10, 40"\n后宅六船时, 使用六种食物分别需要间隔大于\n(14, 28, 42, 70, 139, 278)', gooey_options={'label_color': '#4B5F83'})
    reward_dorm.add_argument('--后宅喂食优先', default=default('--后宅喂食优先'), help='仿照科研过滤字符串', gooey_options={'label_color': '#4B5F83'})

    reward_commission = reward_parser.add_argument_group('委托设置', '', gooey_options={'label_color': '#931D03'})
    reward_commission.add_argument('--启用委托收获', default=default('--启用委托收获'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_commission.add_argument('--委托时间限制', default=default('--委托时间限制'), help='忽略完成时间超过限制的委托, 格式: 23:30, 不需要就填0', gooey_options={'label_color': '#4B5F83'})

    priority1 = reward_commission.add_argument_group('委托耗时优先级', '', gooey_options={'label_color': '#931D03'})
    priority1.add_argument('--委托耗时小于2h', default=default('--委托耗时小于2h'), help='', gooey_options={'label_color': '#4B5F83'})
    priority1.add_argument('--委托耗时超过6h', default=default('--委托耗时超过6h'), help='', gooey_options={'label_color': '#4B5F83'})
    priority1.add_argument('--委托过期小于2h', default=default('--委托过期小于2h'), help='', gooey_options={'label_color': '#4B5F83'})
    priority1.add_argument('--委托过期大于6h', default=default('--委托过期大于6h'), help='', gooey_options={'label_color': '#4B5F83'})

    priority2 = reward_commission.add_argument_group('日常委托优先级', '', gooey_options={'label_color': '#931D03'})
    priority2.add_argument('--日常委托', default=default('--日常委托'), help='日常资源开发, 高阶战术研发', gooey_options={'label_color': '#4B5F83'})
    priority2.add_argument('--主要委托', default=default('--主要委托'), help='1200油/1000油委托', gooey_options={'label_color': '#4B5F83'})

    priority3 = reward_commission.add_argument_group('额外委托优先级', '', gooey_options={'label_color': '#931D03'})
    priority3.add_argument('--钻头类额外委托', default=default('--钻头类额外委托'), help='短距离航行训练, 近海防卫巡逻', gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--部件类额外委托', default=default('--部件类额外委托'), help='矿脉护卫委托, 林木护卫委托', gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--魔方类额外委托', default=default('--魔方类额外委托'), help='舰队高阶演习, 舰队护卫演习', gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--石油类额外委托', default=default('--石油类额外委托'), help='小型油田开发, 大型油田开发', gooey_options={'label_color': '#4B5F83'})
    priority3.add_argument('--教材类额外委托', default=default('--教材类额外委托'), help='小型商船护卫, 大型商船护卫', gooey_options={'label_color': '#4B5F83'})

    priority4 = reward_commission.add_argument_group('紧急委托优先级', '', gooey_options={'label_color': '#931D03'})
    priority4.add_argument('--钻头类紧急委托', default=default('--钻头类紧急委托'), help='保卫运输部队, 歼灭敌精锐部队', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--部件类紧急委托', default=default('--部件类紧急委托'), help='支援维拉维拉岛, 支援恐班纳', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--魔方类紧急委托', default=default('--魔方类紧急委托'), help='解救商船, 敌袭', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--教材类紧急委托', default=default('--教材类紧急委托'), help='支援土豪尔岛, 支援萌岛', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--装备类紧急委托', default=default('--装备类紧急委托'), help='BIW装备运输, NYB装备研发', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--钻石类紧急委托', default=default('--钻石类紧急委托'), help='BIW要员护卫, NYB巡视护卫', gooey_options={'label_color': '#4B5F83'})
    priority4.add_argument('--观舰类紧急委托', default=default('--观舰类紧急委托'), help='小型观舰仪式, 同盟观舰仪式', gooey_options={'label_color': '#4B5F83'})

    reward_tactical = reward_parser.add_argument_group('战术学院', '只支持续技能书, 不支持学新技能', gooey_options={'label_color': '#931D03'})
    reward_tactical.add_argument('--启用战术学院收获', default=default('--启用战术学院收获'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    # reward_tactical.add_argument('--战术学院夜间时段', default=default('--战术学院夜间时段'), help='格式 23:30-06:30')
    reward_tactical.add_argument('--技能书优先使用同类型', default=default('--技能书优先使用同类型'), choices=['是', '否'], help='选是, 优先使用有150%加成的\n选否, 优先使用同稀有度的技能书', gooey_options={'label_color': '#4B5F83'})
    reward_tactical.add_argument('--技能书最大稀有度', default=default('--技能书最大稀有度'), choices=['3', '2', '1'], help='最高使用T几的技能书\nT3是金书, T2是紫书, T1是蓝书\n最大值需要大于等于最小值', gooey_options={'label_color': '#4B5F83'})
    reward_tactical.add_argument('--技能书最小稀有度', default=default('--技能书最小稀有度'), choices=['3', '2', '1'], help='最低使用T几的技能书\n', gooey_options={'label_color': '#4B5F83'})
    # reward_tactical.add_argument('--技能书夜间稀有度', default=default('--技能书夜间稀有度'), choices=['3', '2', '1'])
    # reward_tactical.add_argument('--技能书夜间优先使用同类型', default=default('--技能书夜间优先使用同类型'), choices=['是', '否'])
    reward_tactical.add_argument('--如果无技能书可用', default=default('--如果无技能书可用'), choices=['停止学习', '使用第一本'], gooey_options={'label_color': '#4B5F83'})

    reward_research = reward_parser.add_argument_group('科研项目', '科研预设选择为自定义时, 须先阅读 doc/filter_string_en_cn.md', gooey_options={'label_color': '#931D03'})
    reward_research.add_argument('--启用科研项目收获', default=default('--启用科研项目收获'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    research_input = reward_research.add_argument_group('科研投入', '', gooey_options={'label_color': '#931D03'})
    research_input.add_argument('--科研项目使用魔方', default=default('--科研项目使用魔方'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    research_input.add_argument('--科研项目使用金币', default=default('--科研项目使用金币'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    research_input.add_argument('--科研项目使用部件', default=default('--科研项目使用部件'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    research_output = reward_research.add_argument_group('科研产出', '', gooey_options={'label_color': '#931D03'})
    research_output.add_argument('--科研项目选择预设', default=default('--科研项目选择预设'), choices=research_preset, gooey_options={'label_color': '#4B5F83'})
    research_output.add_argument('--科研过滤字符串', default=default('--科研过滤字符串'), help='仅在科研预设选择为自定义时启用', gooey_options={'label_color': '#4B5F83'})

    reward_meowfficer = reward_parser.add_argument_group('商店购买', '如果已经买过则自动跳过', gooey_options={'label_color': '#931D03'})
    reward_meowfficer.add_argument('--买指挥喵', default=default('--买指挥喵'), help='从0到15, 不需要就填0', gooey_options={'label_color': '#4B5F83'})
    reward_meowfficer.add_argument('--训练指挥喵', default=default('--训练指挥喵'), help='启用指挥喵训练, 每天收一只, 周日收获全部', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    reward_guild = reward_parser.add_argument_group('大舰队', '检查大舰队后勤和大舰队作战', gooey_options={'label_color': '#931D03'})
    reward_guild.add_argument('--启用大舰队后勤', default=default('--启用大舰队后勤'), help='领取大舰队任务, 提交筹备物资, 领取舰队奖励', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_guild.add_argument('--启用大舰队作战', default=default('--启用大舰队作战'), help='执行大舰队作战派遣, 打大舰队BOSS', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_guild.add_argument('--大舰队收获间隔', default=default('--大舰队收获间隔'), help='每隔多少分钟触发, 推荐使用时间区间, 比如"10, 40"', gooey_options={'label_color': '#4B5F83'})
    reward_guild_logistics_items = reward_guild.add_argument_group('筹备物品提交顺序', '可用字符: t1, t2, t3, oxycola, coolant, coins, oil, and merit. 省略某个字符来跳过该物品的提交', gooey_options={'label_color': '#4B5F83'})
    reward_guild_logistics_items.add_argument('--物品提交顺序', default=default('--物品提交顺序'), gooey_options={'label_color': '#4B5F83'})
    reward_guild_logistics_plates = reward_guild.add_argument_group('筹备部件提交顺序', '可用字符: torpedo, antiair, plane, gun, and general. 省略某个字符来跳过该物品的提交', gooey_options={'label_color': '#4B5F83'})
    reward_guild_logistics_plates.add_argument('--部件提交顺序T1', default=default('--部件提交顺序T1'), gooey_options={'label_color': '#4B5F83'})
    reward_guild_logistics_plates.add_argument('--部件提交顺序T2', default=default('--部件提交顺序T2'), gooey_options={'label_color': '#4B5F83'})
    reward_guild_logistics_plates.add_argument('--部件提交顺序T3', default=default('--部件提交顺序T3'), gooey_options={'label_color': '#4B5F83'})
    reward_guild_operations_boss = reward_guild.add_argument_group('大舰队BOSS', '', gooey_options={'label_color': '#4B5F83'})
    reward_guild_operations_boss.add_argument('--启用大舰队BOSS出击', default=default('--启用大舰队BOSS出击'), help='自动打大舰队BOSS, 需要预先在游戏内设置队伍', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    reward_guild_operations_boss.add_argument('--启用大舰队BOSS队伍推荐', default=default('--启用大舰队BOSS队伍推荐'), help='使用游戏自动推荐的队伍打BOSS', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    # ==========设备设置==========
    emulator_parser = subs.add_parser('设备设置')
    emulator = emulator_parser.add_argument_group('模拟器', '需要运行一次来保存选项, 会检查游戏是否启动\n若启动了游戏, 触发一次收菜', gooey_options={'label_color': '#931D03'})
    emulator.add_argument('--设备', default=default('--设备'), help='例如 127.0.0.1:62001', gooey_options={'label_color': '#4B5F83'})
    emulator.add_argument('--包名', default=default('--包名'), help='', gooey_options={'label_color': '#4B5F83'})
    emulator.add_argument(
        '默认serial列表',
        default=message,
        widget='Textarea',
        help="以下是一些常见模拟器的默认serial\n如果你使用了模拟器多开, 它们将不使用默认的serial",
        gooey_options={
            'height': 150,
            'show_help': True,
            'show_label': True,
            'readonly': True,
            'label_color': '#4B5F83'
        }
    )

    debug = emulator_parser.add_argument_group('调试设置', '', gooey_options={'label_color': '#931D03'})
    debug.add_argument('--出错时保存log和截图', default=default('--出错时保存log和截图'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    debug.add_argument('--保存透视识别出错的图像', default=default('--保存透视识别出错的图像'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    adb = emulator_parser.add_argument_group('ADB设置', '', gooey_options={'label_color': '#931D03'})
    adb.add_argument('--设备截图方案', default=default('--设备截图方案'), choices=['aScreenCap', 'uiautomator2', 'ADB'], help='速度: aScreenCap >> uiautomator2 > ADB', gooey_options={'label_color': '#4B5F83'})
    adb.add_argument('--设备控制方案', default=default('--设备控制方案'), choices=['minitouch','uiautomator2', 'ADB'], help='速度: minitouch >> uiautomator2 >> ADB', gooey_options={'label_color': '#4B5F83'})
    adb.add_argument('--战斗中截图间隔', default=default('--战斗中截图间隔'), help='战斗中放慢截图速度, 降低CPU使用', gooey_options={'label_color': '#4B5F83'})

    update = emulator_parser.add_argument_group('更新检查', '', gooey_options={'label_color': '#931D03'})
    update.add_argument('--启用更新检查', default=default('--启用更新检查'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    update.add_argument('--更新检查方法', default=default('--更新检查方法'), choices=['api', 'web'], help='使用api时建议填写tokens, 使用web则不需要', gooey_options={'label_color': '#4B5F83'})
    update.add_argument('--github_token', default=default('--github_token'), help='Github API限制为每小时60次, 获取tokens https://github.com/settings/tokens', gooey_options={'label_color': '#4B5F83'})
    update.add_argument('--更新检查代理', default=default('--更新检查代理'), help='本地http或socks代理, 如果github很慢, 请使用代理, example: http://127.0.0.1:10809', gooey_options={'label_color': '#4B5F83'})

    # ==========每日任务==========
    daily_parser = subs.add_parser('每日任务困难演习')

    # 选择每日
    daily = daily_parser.add_argument_group('选择每日', '每日任务, 演习, 困难图', gooey_options={'label_color': '#931D03'})
    daily.add_argument('--打每日', default=default('--打每日'), help='若当天有记录, 则跳过', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打困难', default=default('--打困难'), help='若当天有记录, 则跳过', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打演习', default=default('--打演习'), help='若在刷新后有记录, 则跳过', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打共斗每日15次', default=default('--打共斗每日15次'), help='若当天有记录, 则跳过', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打活动图每日三倍PT', default=default('--打活动图每日三倍PT'), help='若当天有记录, 则跳过', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打活动每日SP图', default=default('--打活动每日SP图'), help='若当天有记录, 则跳过', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    daily.add_argument('--打大世界余烬信标支援', default=default('--打大世界余烬信标支援'), help='若当天有记录, 则跳过', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    # 每日设置
    daily_task = daily_parser.add_argument_group('每日设置', '不支持潜艇每日', gooey_options={'label_color': '#931D03'})
    daily_task.add_argument('--战术研修', default=default('--战术研修'), choices=['航空', '炮击', '雷击'], gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--斩首行动', default=default('--斩首行动'), choices=['第一个', '第二个', '第三个'], gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--商船护航', default=default('--商船护航'), choices=['第一个', '第二个', '第三个'], gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--海域突进', default=default('--海域突进'), choices=['第一个', '第二个', '第三个'], gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--每日舰队', default=default('--每日舰队'), help='如果使用同一队, 填舰队编号, 例如 5\n如果使用不同队, 用逗号分割, 顺序为商船护送, 海域突进, 斩首行动, 战术研修\n例如 5, 5, 5, 6', gooey_options={'label_color': '#4B5F83'})
    daily_task.add_argument('--每日舰队快速换装', default=default('--每日舰队快速换装'), help='打之前换装备, 打完后卸装备, 不需要就填0\n逗号分割, 例如 3, 1, 0, 1, 1, 0', gooey_options={'label_color': '#4B5F83'})

    # 困难设置
    hard = daily_parser.add_argument_group('困难设置', '需要地图达到周回模式', gooey_options={'label_color': '#931D03'})
    hard.add_argument('--困难地图', default=default('--困难地图'), help='比如 10-4', gooey_options={'label_color': '#4B5F83'})
    hard.add_argument('--困难舰队', default=default('--困难舰队'), choices=['1', '2'], gooey_options={'label_color': '#4B5F83'})
    hard.add_argument('--困难舰队快速换装', default=default('--困难舰队快速换装'), help='打之前换装备, 打完后卸装备, 不需要就填0\n逗号分割, 例如 3, 1, 0, 1, 1, 0', gooey_options={'label_color': '#4B5F83'})

    # 演习设置
    exercise = daily_parser.add_argument_group('演习设置', '', gooey_options={'label_color': '#931D03'})
    exercise.add_argument('--演习对手选择', default=default('--演习对手选择'), choices=['经验最多', '最简单', '最左边', '先最简单再经验最多'], help='', gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演习次数保留', default=default('--演习次数保留'), help='例如 1, 表示打到1/10停止', gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演习尝试次数', default=default('--演习尝试次数'), help='每个对手的尝试次数, 打不过就换', gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演习SL阈值', default=default('--演习SL阈值'), help='HP<阈值时撤退', gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演习低血量确认时长', default=default('--演习低血量确认时长'), help='HP低于阈值后, 过一定时长才会撤退\n推荐 1.0 ~ 3.0', gooey_options={'label_color': '#4B5F83'})
    exercise.add_argument('--演习快速换装', default=default('--演习快速换装'), help='打之前换装备, 打完后卸装备, 不需要就填0\n逗号分割, 例如 3, 1, 0, 1, 1, 0', gooey_options={'label_color': '#4B5F83'})

    # 每日活动图三倍PT
    event_bonus = daily_parser.add_argument_group('活动设置', '', gooey_options={'label_color': '#931D03'})
    event_bonus.add_argument('--活动奖励章节', default=default('--活动奖励章节'), choices=['AB图', 'ABCD图', 'T图', 'HT图'], help='有额外PT奖励章节', gooey_options={'label_color': '#4B5F83'})
    event_bonus.add_argument('--活动SP图道中队', default=default('--活动SP图道中队'), choices=['1', '2'], help='', gooey_options={'label_color': '#4B5F83'})
    event_bonus.add_argument('--活动名称ab', default=event_latest, choices=event_folder, help='例如 event_20200326_cn', gooey_options={'label_color': '#4B5F83'})

    # 共斗每日设置
    raid_bonus = daily_parser.add_argument_group('共斗设置', '', gooey_options={'label_color': '#931D03'})
    raid_bonus.add_argument('--共斗每日名称', default=raid_latest, choices=raid_folder, help='', gooey_options={'label_color': '#4B5F83'})
    raid_bonus.add_argument('--共斗困难', default=default('--共斗困难'), choices=['是', '否'], help='', gooey_options={'label_color': '#4B5F83'})
    raid_bonus.add_argument('--共斗普通', default=default('--共斗普通'), choices=['是', '否'], help='', gooey_options={'label_color': '#4B5F83'})
    raid_bonus.add_argument('--共斗简单', default=default('--共斗简单'), choices=['是', '否'], help='', gooey_options={'label_color': '#4B5F83'})

    # 大世界每日设置
    raid_bonus = daily_parser.add_argument_group('大世界设置', '', gooey_options={'label_color': '#931D03'})
    raid_bonus.add_argument('--大世界信标支援强度', default=default('--大世界信标支援强度'), help='寻找大于等于此强度的信标', gooey_options={'label_color': '#4B5F83'})

    # # ==========每日活动图三倍PT==========
    # event_ab_parser = subs.add_parser('每日活动图三倍PT')
    # event_name = event_ab_parser.add_argument_group('选择活动', '')
    # event_name.add_argument('--活动名称ab', default=event_latest, choices=event_folder, help='例如 event_20200326_cn')

    # ==========主线图==========
    main_parser = subs.add_parser('主线图')
    # 选择关卡
    stage = main_parser.add_argument_group('选择关卡', '', gooey_options={'label_color': '#931D03'})
    stage.add_argument('--主线地图出击', default=default('--主线地图出击'), help='例如 7-2', gooey_options={'label_color': '#4B5F83'})
    stage.add_argument('--主线地图模式', default=default('--主线地图模式'), help='仅困难图开荒时使用, 周回模式后请使用每日困难', choices=['普通', '困难'], gooey_options={'label_color': '#4B5F83'})

    # ==========活动图==========
    event_parser = subs.add_parser('活动图')

    description = """
    出击未优化关卡或地图未达到安全海域时, 使用开荒模式运行(较慢)
    """
    event = event_parser.add_argument_group(
        '选择关卡', '\n'.join([line.strip() for line in description.strip().split('\n')]), gooey_options={'label_color': '#931D03'})
    event.add_argument('--活动地图', default=default('--活动地图'), help='输入地图名称, 不分大小写, 例如 D3, SP3, HT6', gooey_options={'label_color': '#4B5F83'})
    event.add_argument('--活动名称', default=event_latest, choices=event_folder, help='例如 event_20200312_cn', gooey_options={'label_color': '#4B5F83'})

    # ==========潜艇图==========
    sos_parser = subs.add_parser('潜艇图')
    sos = sos_parser.add_argument_group(
        '潜艇图设置', '设置每张潜艇图的队伍, 顺序: 一队二队潜艇队\n例如 "4, 6", "4, 0", "4, 6, 1"\n填0跳过不打', gooey_options={'label_color': '#931D03'})
    sos.add_argument('--第3章潜艇图队伍', default=default('--第3章潜艇图队伍'), gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第4章潜艇图队伍', default=default('--第4章潜艇图队伍'), gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第5章潜艇图队伍', default=default('--第5章潜艇图队伍'), gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第6章潜艇图队伍', default=default('--第6章潜艇图队伍'), gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第7章潜艇图队伍', default=default('--第7章潜艇图队伍'), gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第8章潜艇图队伍', default=default('--第8章潜艇图队伍'), gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第9章潜艇图队伍', default=default('--第9章潜艇图队伍'), gooey_options={'label_color': '#4B5F83'})
    sos.add_argument('--第10章潜艇图队伍', default=default('--第10章潜艇图队伍'), gooey_options={'label_color': '#4B5F83'})

    # ==========作战档案==========
    war_archives_parser = subs.add_parser('作战档案')
    war_archives = war_archives_parser.add_argument_group(
        '作战档案设置', '输入地图名称, 然后选择对应的活动', gooey_options={'label_color': '#931D03'})
    war_archives.add_argument('--作战档案地图', default=default('--作战档案地图'), help='输入地图名称, 不分大小写, 例如 D3, SP3, HT6', gooey_options={'label_color': '#4B5F83'})
    war_archives.add_argument('--作战档案活动', default=default('--作战档案活动'), choices=archives_folder, help='在下拉菜单中选择活动', gooey_options={'label_color': '#4B5F83'})

    # ==========共斗活动==========
    raid_parser = subs.add_parser('共斗活动')
    raid = raid_parser.add_argument_group('选择共斗', '', gooey_options={'label_color': '#931D03'})
    raid.add_argument('--共斗名称', default=raid_latest, choices=raid_folder, help='', gooey_options={'label_color': '#4B5F83'})
    raid.add_argument('--共斗难度', default=default('--共斗难度'), choices=['困难', '普通', '简单'], help='', gooey_options={'label_color': '#4B5F83'})
    raid.add_argument('--共斗使用挑战券', default=default('--共斗使用挑战券'), choices=['是', '否'], help='', gooey_options={'label_color': '#4B5F83'})

    # ==========半自动==========
    semi_parser = subs.add_parser('半自动辅助点击')
    semi = semi_parser.add_argument_group('半自动模式', '手动选敌, 自动结算, 用于出击未适配的图', gooey_options={'label_color': '#931D03'})
    semi.add_argument('--进图准备', default=default('--进图准备'), help='', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
    semi.add_argument('--跳过剧情', default=default('--跳过剧情'), help='注意, 这会自动确认所有提示框, 包括红脸出击', choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})

    # ==========1-1Affinity farming==========
    c_1_1_parser = subs.add_parser('1-1伏击刷好感')
    c_1_1 = c_1_1_parser.add_argument_group('1-1伏击刷好感', '会自动关闭周回模式\n有MVP, 8场战斗涨1点好感, 无MVP, 16场战斗涨1点好感', gooey_options={'label_color': '#931D03'})
    c_1_1.add_argument('--刷好感战斗场数', default=default('--刷好感战斗场数'), help='例如: 32', gooey_options={'label_color': '#4B5F83'})

    # ==========7-2三战拣垃圾==========
    c_7_2_parser = subs.add_parser('7-2三战拣垃圾')
    c_7_2 = c_7_2_parser.add_argument_group('7-2三战拣垃圾', '', gooey_options={'label_color': '#931D03'})
    c_7_2.add_argument('--BOSS队踩A3', default=default('--BOSS队踩A3'), choices=['是', '否'], help='A3有敌人就G3, C3, E3', gooey_options={'label_color': '#4B5F83'})

    # ==========12-2打中型练级==========
    c_12_2_parser = subs.add_parser('12-2打中型练级')
    c_12_2 = c_12_2_parser.add_argument_group('12-2索敌设置', '', gooey_options={'label_color': '#931D03'})
    c_12_2.add_argument('--大型敌人忍耐', default=default('--大型敌人忍耐'), choices=['0', '1', '2', '10'], help='最多打多少战大型敌人, 不挑敌人选10', gooey_options={'label_color': '#4B5F83'})

    # ==========12-4打大型练级==========
    c_12_4_parser = subs.add_parser('12-4打大型练级')
    c_12_4 = c_12_4_parser.add_argument_group('12-4索敌设置', '需保证队伍有一定强度', gooey_options={'label_color': '#931D03'})
    c_12_4.add_argument('--非大型敌人进图忍耐', default=default('--非大型敌人进图忍耐'), choices=['0', '1', '2'], help='忍受进场多少战没有大型', gooey_options={'label_color': '#4B5F83'})
    c_12_4.add_argument('--非大型敌人撤退忍耐', default=default('--非大型敌人撤退忍耐'), choices=['0', '1', '2', '10'], help='没有大型之后还会打多少战, 不挑敌人选10', gooey_options={'label_color': '#4B5F83'})
    c_12_4.add_argument('--拣弹药124', default=default('--拣弹药124'), choices=['2', '3', '4', '5'], help='多少战后拣弹药', gooey_options={'label_color': '#4B5F83'})

    # ==========OS semi auto==========
    os_semi_parser = subs.add_parser('大世界辅助点击')
    os_semi = os_semi_parser.add_argument_group('大世界辅助点击', '自动点击战斗准备和战斗结算\n仅推荐在普通海域和安全海域中开启', gooey_options={'label_color': '#931D03'})
    os_semi.add_argument('--大世界跳过剧情', default=default('--大世界跳过剧情'), choices=['是', '否'], help='注意, 这会自动点击地图交互的选项', gooey_options={'label_color': '#4B5F83'})

    # ==========OS clear map==========
    os_semi_parser = subs.add_parser('大世界地图全清')
    os_semi = os_semi_parser.add_argument_group('大世界地图全清', '仅在安全海域中使用, 在普通海域使用时需要先执行空域搜索\n使用方法: 先手动进入地图, 再运行\n运行结束后, 最好手动检查是否有遗漏', gooey_options={'label_color': '#931D03'})
    os_semi.add_argument('--打大世界余烬信标', default=default('--打大世界余烬信标'), choices=['是', '否'], help='信标数据满了之后, 打飞龙', gooey_options={'label_color': '#4B5F83'})

    args = parser.parse_args()

    # Convert option from chinese to english.
    out = {}
    for key, value in vars(args).items():
        key = dic_gui_to_ini.get(key, key)
        value = dic_gui_to_ini.get(value, value)
        out[key] = value
    args = out

    # Update option to .ini file.
    command = args['command'].capitalize()
    config['Command']['command'] = command
    for key, value in args.items():
        config[command][key] = str(value)
    config.write(codecs.open(config_file, "w+", "utf8"))

    # Call AzurLaneAutoScript
    alas = AzurLaneAutoScript(ini_name=ini_name)
    alas.run(command=command)