From 294c8a1f0031d175bdbc4cd52671ec905b0d2b7a Mon Sep 17 00:00:00 2001 From: positnuec <93694981+positnuec@users.noreply.github.com> Date: Sun, 16 Aug 2026 17:05:31 +0800 Subject: [PATCH] Feat: migrate OpsiShop delay limit from absolute date to days before reset --- config/template.json | 2 +- module/config/argument/args.json | 2 +- module/config/argument/argument.yaml | 2 +- module/config/config_generated.py | 2 +- module/config/config_updater.py | 1 + module/config/i18n/en-US.json | 6 +++--- module/config/i18n/ja-JP.json | 6 +++--- module/config/i18n/zh-CN.json | 6 +++--- module/config/i18n/zh-TW.json | 6 +++--- module/config/redirect_utils/utils.py | 11 +++++++++++ module/os/tasks/shop.py | 8 ++++---- 11 files changed, 32 insertions(+), 20 deletions(-) diff --git a/config/template.json b/config/template.json index e623d10f8..5e810f89a 100644 --- a/config/template.json +++ b/config/template.json @@ -2206,7 +2206,7 @@ "OpsiShop": { "PresetFilter": "max_benefit_meta", "CustomFilter": "LoggerAbyssalT6 > LoggerAbyssalT5 > LoggerAbyssalT4 > LoggerObscureT6 > LoggerObscureT5 > LoggerObscureT4 > LoggerObscureT3 > ActionPoint > PurpleCoins\n> GearDesignPlanT3 > PlateRandomT4 > DevelopmentMaterialT3 > GearDesignPlanT2 > GearPart\n> OrdnanceTestingReportT3 > OrdnanceTestingReportT2 > DevelopmentMaterialT2 > OrdnanceTestingReportT1\n> METARedBook > CrystallizedHeatResistantSteel > NanoceramicAlloy > NeuroplasticProstheticArm > SupercavitationGenerator", - "DisableBeforeDate": 0 + "DisableBeforeResetDays": 0 }, "Storage": { "Storage": {} diff --git a/module/config/argument/args.json b/module/config/argument/args.json index 39843ca36..5b41113f0 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -14364,7 +14364,7 @@ "type": "textarea", "value": "LoggerAbyssalT6 > LoggerAbyssalT5 > LoggerAbyssalT4 > LoggerObscureT6 > LoggerObscureT5 > LoggerObscureT4 > LoggerObscureT3 > ActionPoint > PurpleCoins\n> GearDesignPlanT3 > PlateRandomT4 > DevelopmentMaterialT3 > GearDesignPlanT2 > GearPart\n> OrdnanceTestingReportT3 > OrdnanceTestingReportT2 > DevelopmentMaterialT2 > OrdnanceTestingReportT1\n> METARedBook > CrystallizedHeatResistantSteel > NanoceramicAlloy > NeuroplasticProstheticArm > SupercavitationGenerator" }, - "DisableBeforeDate": { + "DisableBeforeResetDays": { "type": "input", "value": 0 } diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 62d5afb52..3ecffb4b9 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -1019,7 +1019,7 @@ OpsiShop: > GearDesignPlanT3 > PlateRandomT4 > DevelopmentMaterialT3 > GearDesignPlanT2 > GearPart > OrdnanceTestingReportT3 > OrdnanceTestingReportT2 > DevelopmentMaterialT2 > OrdnanceTestingReportT1 > METARedBook > CrystallizedHeatResistantSteel > NanoceramicAlloy > NeuroplasticProstheticArm > SupercavitationGenerator - DisableBeforeDate: 0 + DisableBeforeResetDays: 0 OpsiVoucher: Filter: |- LoggerAbyssal > LoggerObscure > Book > Coin > Fragment diff --git a/module/config/config_generated.py b/module/config/config_generated.py index b86ea14df..6d8fc6628 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -624,7 +624,7 @@ class GeneratedConfig: # Group `OpsiShop` OpsiShop_PresetFilter = 'max_benefit_meta' # max_benefit, max_benefit_meta, no_meta, all, custom OpsiShop_CustomFilter = 'LoggerAbyssalT6 > LoggerAbyssalT5 > LoggerAbyssalT4 > LoggerObscureT6 > LoggerObscureT5 > LoggerObscureT4 > LoggerObscureT3 > ActionPoint > PurpleCoins\n> GearDesignPlanT3 > PlateRandomT4 > DevelopmentMaterialT3 > GearDesignPlanT2 > GearPart\n> OrdnanceTestingReportT3 > OrdnanceTestingReportT2 > DevelopmentMaterialT2 > OrdnanceTestingReportT1\n> METARedBook > CrystallizedHeatResistantSteel > NanoceramicAlloy > NeuroplasticProstheticArm > SupercavitationGenerator' - OpsiShop_DisableBeforeDate = 0 + OpsiShop_DisableBeforeResetDays = 0 # Group `OpsiVoucher` OpsiVoucher_Filter = 'LoggerAbyssal > LoggerObscure > Book > Coin > Fragment' diff --git a/module/config/config_updater.py b/module/config/config_updater.py index 546ca703c..e1f15d6f6 100644 --- a/module/config/config_updater.py +++ b/module/config/config_updater.py @@ -608,6 +608,7 @@ class ConfigUpdater: # ('Coalition.Coalition.Mode', 'Coalition.Coalition.Mode', coalition_to_frostfall), # 2025.06.26 # ('Coalition.Coalition.Mode', 'Coalition.Coalition.Mode', coalition_to_little_academy), + ('OpsiShop.OpsiShop.DisableBeforeDate', 'OpsiShop.OpsiShop.DisableBeforeResetDays', date_to_reset_days), ] # redirection += [ diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index eae7036f7..c0f416ab5 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -6631,9 +6631,9 @@ "name": "Custom Research Priority", "help": "To use your own filter, set \"OpSi Shop Filter Select\" to \"custom\". All options have been defined at " }, - "DisableBeforeDate": { - "name": "Don't Buy from OpSi Shop before Date X of Every Month", - "help": "Starting from the day after the specified date, buy OpSi shop once a day; saving as 0 implies unlimited date (purchase every day)" + "DisableBeforeResetDays": { + "name": "Buy from OpSi Shop only on the Last X Days of Every Month", + "help": "e.g. X=3: in a 30-day month, buy only on the 28th, 29th and 30th\n0 means no limit, purchase every day" } }, "OpsiVoucher": { diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index 939249223..c212e89bf 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -6631,9 +6631,9 @@ "name": "OpsiShop.CustomFilter.name", "help": "OpsiShop.CustomFilter.help" }, - "DisableBeforeDate": { - "name": "OpsiShop.DisableBeforeDate.name", - "help": "OpsiShop.DisableBeforeDate.help" + "DisableBeforeResetDays": { + "name": "OpsiShop.DisableBeforeResetDays.name", + "help": "OpsiShop.DisableBeforeResetDays.help" } }, "OpsiVoucher": { diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index fb039c464..58111bd87 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -6631,9 +6631,9 @@ "name": "自定义过滤器", "help": "使用自定义过滤器需将 \"港口商店过滤器\" 设置为 \"自定义\",并阅读 https://github.com/LmeSzinc/AzurLaneAutoScript/wiki/filter_string_cn" }, - "DisableBeforeDate": { - "name": "每月 X 号前,不购买大世界商店", - "help": "从指定日期的后一天开始,每天买一次大世界商店\n0 表示不限制,每天都购买" + "DisableBeforeResetDays": { + "name": "仅在每月最后 X 天购买", + "help": "例如 X=3:当月为30天时,仅在28、29、30号购买\n0 表示不限制,每天都购买" } }, "OpsiVoucher": { diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 9814ff5fb..fb6ac7e8f 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -6631,9 +6631,9 @@ "name": "自定義過濾器", "help": "使用自定義過濾器需將 \"港口商店過濾器\" 設定為 \"自定義\",並閱讀 https://github.com/LmeSzinc/AzurLaneAutoScript/wiki/filter_string_cn" }, - "DisableBeforeDate": { - "name": "每月 X 號前,不購買大世界商店", - "help": "從指定日期的後一天開始,每天買一次大世界商店\n0 表示不限制,每天都購買" + "DisableBeforeResetDays": { + "name": "僅在每月最後 X 天購買", + "help": "例如 X=3:當月為30天時,僅在28、29、30號購買\n0 表示不限制,每天都購買" } }, "OpsiVoucher": { diff --git a/module/config/redirect_utils/utils.py b/module/config/redirect_utils/utils.py index a7eb53074..48f12f5a5 100644 --- a/module/config/redirect_utils/utils.py +++ b/module/config/redirect_utils/utils.py @@ -144,3 +144,14 @@ def submarine_mode_redirect(value): 'every_combat': ('do_not_use', 'every_combat'), } return mapping.get(value, ('do_not_use', 'do_not_use')) + + +def date_to_reset_days(value): + """ + OpsiShop.DisableBeforeDate -> OpsiShop.DisableBeforeResetDays + Old config uses date of month (31 days based), new config uses days before reset. + """ + if value == 0: + return 0 + else: + return 31 - value diff --git a/module/os/tasks/shop.py b/module/os/tasks/shop.py index b2671d3eb..eda30d0f3 100644 --- a/module/os/tasks/shop.py +++ b/module/os/tasks/shop.py @@ -14,10 +14,10 @@ class OpsiShop(OSMap): If not having enough yellow coins or purple coins, skip buying supplies in next port. """ logger.hr('OS port daily', level=1) - today = datetime.now().day - limit = self.config.OpsiShop_DisableBeforeDate - if today <= limit: - logger.info(f'Delay Opsi shop, today\'s date {today} <= limit {limit}') + remain = (get_os_next_reset().date() - datetime.now().date()).days + limit = self.config.OpsiShop_DisableBeforeResetDays + if limit > 0 and remain > limit: + logger.info(f'Delay Opsi shop, reset remain {remain} days > limit {limit} days') self.config.task_delay(server_update=True) self.config.task_stop()