Skip to content

Commit d436bbc

Browse files
committed
🐛 fix(commissions): 修复奖励数量识别
- 调整OCR正则表达式,以正确识别冒号后带空格的奖励数量 - 解决金任务中奖励数量识别失败的问题
1 parent 58e001c commit d436bbc

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/tasks/CommissionsTask.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,10 @@ def choose_letter(self, timeout=0):
249249
)
250250

251251
def choose_target_letter_reward(self):
252+
reward_pattern = re.compile(r'[::]\s*([0-9]+)')
252253
def get_rewards():
253254
box = self.box_of_screen(0.328, 0.643, 0.678, 0.672, hcenter=True, name="letter_reward")
254-
return self.ocr(box=box, match=re.compile(r'[::][0-9]+'))
255+
return self.ocr(box=box, match=reward_pattern)
255256

256257
start = time.time()
257258
while time.time() - start < 10:
@@ -262,19 +263,19 @@ def get_rewards():
262263
else:
263264
self.log_info("超时:未识别到3个奖励选项,使用默认奖励")
264265
return
265-
266+
266267
self.sleep(0.3)
267268
rewards = get_rewards()
268-
269+
269270
if len(rewards) != 3:
270271
self.log_info(f"异常:稳定后识别数量不符 (识别到 {len(rewards)} 个),使用默认奖励")
271272
return
272273

273274
rewards.sort(key=lambda reward: reward.x)
274-
275+
275276
parsed_items = []
276277
for idx, reward in enumerate(rewards):
277-
match = re.search(r'[::]([0-9]+)', reward.name)
278+
match = reward_pattern.search(reward.name)
278279
if not match:
279280
self.log_info(f"第 {idx + 1} 个奖励数量识别失败,使用默认奖励")
280281
return

0 commit comments

Comments
 (0)