From 0d2db648a80a3f69f48376f7383114c0bf184b14 Mon Sep 17 00:00:00 2001 From: guoh064 <50830808+guoh064@users.noreply.github.com> Date: Thu, 29 Aug 2024 13:15:28 +0800 Subject: [PATCH] Feature: better new ship handle --- config/template.json | 1 + module/combat/combat.py | 33 +++++++++++++++++++++++----- module/config/argument/args.json | 8 +++++++ module/config/argument/argument.yaml | 3 +++ module/config/config_generated.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 +++++ 9 files changed, 65 insertions(+), 5 deletions(-) diff --git a/config/template.json b/config/template.json index bd93fe74d4..b8a94560a6 100644 --- a/config/template.json +++ b/config/template.json @@ -33,6 +33,7 @@ "ResearchRecord": "do_not", "CommissionRecord": "do_not", "CombatRecord": "do_not", + "NewShipRecord": "do_not", "OpsiRecord": "do_not", "MeowfficerBuy": "do_not", "MeowfficerTalent": "do_not" diff --git a/module/combat/combat.py b/module/combat/combat.py index f19e884b3b..78af2d13b8 100644 --- a/module/combat/combat.py +++ b/module/combat/combat.py @@ -373,7 +373,7 @@ def handle_exp_info(self): return False - def handle_get_ship(self, drop=None): + def handle_get_ship(self, drop=None, skip_first_screenshot=True): """ Args: drop (DropImage): @@ -381,15 +381,38 @@ def handle_get_ship(self, drop=None): Returns: bool: """ - if self.appear_then_click(GET_SHIP, interval=1): + if not self.appear(GET_SHIP, interval=5): + return False + + if 'save' in self.config.DropRecord_NewShipRecord: + confirm_timer = Timer(3) + else: + confirm_timer = Timer(1) + + confirm_timer.start() + while 1: + if skip_first_screenshot: + skip_first_screenshot = False + else: + self.device.screenshot() + + # End + if confirm_timer.reached(): + break + if self.appear(NEW_SHIP): logger.info('Get a new SHIP') if drop: drop.handle_add(self) + with self.stat.new( + genre='new_ship', + method=self.config.DropRecord_NewShipRecord + ) as drop2: + drop2.handle_add(self, before=1.0) self.config.GET_SHIP_TRIGGERED = True - return True - - return False + break + self.device.click(GET_SHIP) + return True def handle_combat_mis_click(self): """ diff --git a/module/config/argument/args.json b/module/config/argument/args.json index 8d9b66a9c0..e31984e176 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -260,6 +260,14 @@ "save" ] }, + "NewShipRecord": { + "type": "select", + "value": "do_not", + "option": [ + "do_not", + "save" + ] + }, "OpsiRecord": { "type": "select", "value": "do_not", diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 9b48894914..cc3612f282 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -111,6 +111,9 @@ DropRecord: CombatRecord: value: do_not option: [ do_not, save ] + NewShipRecord: + value: do_not + option: [ do_not, save ] OpsiRecord: value: do_not option: [ do_not, save, upload, save_and_upload ] diff --git a/module/config/config_generated.py b/module/config/config_generated.py index 2200caec34..7f7c885ec0 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -50,6 +50,7 @@ class GeneratedConfig: DropRecord_ResearchRecord = 'do_not' # do_not, save, upload, save_and_upload DropRecord_CommissionRecord = 'do_not' # do_not, save, upload, save_and_upload DropRecord_CombatRecord = 'do_not' # do_not, save + DropRecord_NewShipRecord = 'do_not' # do_not, save DropRecord_OpsiRecord = 'do_not' # do_not, save, upload, save_and_upload DropRecord_MeowfficerBuy = 'do_not' # do_not, save DropRecord_MeowfficerTalent = 'do_not' # do_not, save, upload, save_and_upload diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 9ce7448e98..3a80f9a936 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -553,6 +553,12 @@ "do_not": "Do nothing", "save": "Save" }, + "NewShipRecord": { + "name": "New Ship Record", + "help": "", + "do_not": "Do nothing", + "save": "Save" + }, "OpsiRecord": { "name": "OpSi Record", "help": "", diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index c5827cda0a..8f3ca43411 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -553,6 +553,12 @@ "do_not": "do_not", "save": "save" }, + "NewShipRecord": { + "name": "DropRecord.NewShipRecord.name", + "help": "DropRecord.NewShipRecord.help", + "do_not": "do_not", + "save": "save" + }, "OpsiRecord": { "name": "DropRecord.OpsiRecord.name", "help": "DropRecord.OpsiRecord.help", diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index b5e8888cc5..e48b327742 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -553,6 +553,12 @@ "do_not": "无操作", "save": "保存" }, + "NewShipRecord": { + "name": "新船只掉落截图", + "help": "", + "do_not": "无操作", + "save": "保存" + }, "OpsiRecord": { "name": "大世界掉落截图", "help": "", diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 311590977b..9357c3f004 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -553,6 +553,12 @@ "do_not": "無操作", "save": "保存" }, + "NewShipRecord": { + "name": "新船掉落截圖", + "help": "", + "do_not": "無操作", + "save": "保存" + }, "OpsiRecord": { "name": "大世界掉落截圖", "help": "",