Skip to content

Commit

Permalink
解析雀魂牌谱未指定场次本场时发送这场游戏的场次本场信息
Browse files Browse the repository at this point in the history
  • Loading branch information
ssttkkl committed May 29, 2023
1 parent 793e2e3 commit 36170f9
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions nonebot_plugin_nagabus/matchers/naga_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def analyze_majsoul(bot: Bot, event: MessageEvent, matcher: Matcher, uuid:
kyoku_honba = []
for kyoku, honba in e.available_kyoku_honba:
if kyoku <= 3:
kyoku_honba.append(f"东{kyoku}{honba}本场")
kyoku_honba.append(f"东{kyoku + 1}{honba}本场")
elif kyoku <= 7:
kyoku_honba.append(f"南{kyoku - 3}{honba}本场")
else:
Expand Down Expand Up @@ -101,33 +101,29 @@ async def naga_analyze(bot: Bot, event: MessageEvent, matcher: Matcher, cmd_args

uuid = mat.group(0)

if len(args) < 2:
raise BadRequestError("请指定场次与本场")

kyoku = None
honba = None

mat = kyoku_honba_reg.search(args[1])
if not mat:
raise BadRequestError("请输入正确的场次与本场")

raw_wind, raw_kyoku, raw_honba = mat.groups()
if len(args) >= 2:
mat = kyoku_honba_reg.search(args[1])
if mat:
raw_wind, raw_kyoku, raw_honba = mat.groups()

try:
kyoku = decode_integer(raw_kyoku) - 1
if raw_wind == '南':
kyoku += 4
elif raw_wind == '西':
kyoku += 8
try:
kyoku = decode_integer(raw_kyoku) - 1
if raw_wind == '南':
kyoku += 4
elif raw_wind == '西':
kyoku += 8

honba = decode_integer(raw_honba)
except ValueError:
pass
honba = decode_integer(raw_honba)
except ValueError:
pass

if kyoku is None or honba is None:
raise BadRequestError("请输入正确的场次与本场")

await analyze_majsoul(bot, event, matcher, uuid, kyoku, honba)
await analyze_majsoul(bot, event, matcher, uuid, -1, -1) # 让其发送该局的场次本场信息
else:
await analyze_majsoul(bot, event, matcher, uuid, kyoku, honba)
elif "tenhou" in args[0]:
tenhou_url = args[0].strip()

Expand Down

0 comments on commit 36170f9

Please sign in to comment.