File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"""AutoWSGR — 战舰少女R 自动化框架 (v2)"""
22
3- __version__ = '2.1.5.post1 '
3+ __version__ = '2.1.5.post2 '
Original file line number Diff line number Diff line change @@ -66,12 +66,26 @@ class LootShipCount:
6666_FRACTION_RE = re .compile (r'(\d+)\s*[/|]\s*(\d+)' )
6767"""匹配 "X/Y" 格式的正则 (兼容 OCR 把 / 识别为 | 的情况)。"""
6868
69+ _KNOWN_DENOMS = (500 , 50 )
70+ """已知分母值, 用于 OCR 将 ``/`` 误识为 ``1`` 时的回退解析 (长的优先匹配)。"""
71+
6972
7073def _parse_fraction (text : str ) -> tuple [int , int ] | None :
7174 """解析 ``"123/500"`` 格式文本, 返回 ``(numerator, denominator)``。"""
7275 m = _FRACTION_RE .search (text )
7376 if m :
7477 return int (m .group (1 )), int (m .group (2 ))
78+
79+ # 回退: OCR 有时将 '/' 误识为 '1', 导致纯数字串如 "17150" (实为 "17/50")。
80+ # 尝试去掉已知分母前的多余 '1' 来还原。
81+ digits = '' .join (c for c in text if c .isdigit ())
82+ if digits :
83+ for denom in _KNOWN_DENOMS :
84+ suffix = '1' + str (denom )
85+ if digits .endswith (suffix ) and len (digits ) > len (suffix ):
86+ numerator = int (digits [: - len (suffix )])
87+ if numerator >= 0 and numerator <= denom :
88+ return numerator , denom
7589 return None
7690
7791
You can’t perform that action at this time.
0 commit comments