Skip to content

Commit

Permalink
Fix no reaction to any reach discards
Browse files Browse the repository at this point in the history
  • Loading branch information
shinkuan committed Feb 3, 2024
1 parent dbc8ca1 commit 20e6bcb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions majsoul2mjai.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(self) -> None:
self.mjai_message = []
self.lastDiscard = None
self.reach = False
self.accept_reach = None
self.operation = {}
self.AllReady = False
self.temp = {}
Expand Down Expand Up @@ -149,6 +150,10 @@ def input(self, parse_msg: dict) -> dict | None:
else:
raise

if self.accept_reach is not None:
self.mjai_message.append(self.accept_reach)
self.accept_reach = None

# According to mjai.app, in the case of an ankan, the dora event comes first, followed by the tsumo event.
if 'data' in parse_msg['data']:
if 'doras' in parse_msg['data']['data']:
Expand Down Expand Up @@ -201,12 +206,10 @@ def input(self, parse_msg: dict) -> dict | None:
}
)
if parse_msg['data']['data']['isLiqi']:
self.mjai_message.append(
{
'type': 'reach_accepted',
'actor': actor
}
)
self.accept_reach = {
'type': 'reach_accepted',
'actor': actor
}
if actor == self.seat:
if self.my_tsumohai != "?":
self.my_tehais.append(self.my_tsumohai)
Expand Down Expand Up @@ -282,7 +285,7 @@ def input(self, parse_msg: dict) -> dict | None:
actor = parse_msg['data']['data']['seat']
match parse_msg['data']['data']['type']:
case OperationAnGangAddGang.AnGang:
consumed = [MS_TILE_2_MJAI_TILE[parse_msg['data']['data']['tiles']]]*4
consumed = [MS_TILE_2_MJAI_TILE[parse_msg['data']['data']['tiles']].replace("r","")]*4
if parse_msg['data']['data']['tiles'][0] == '5' and parse_msg['data']['data']['tiles'][1] != 'z':
consumed[0] += 'r'
self.mjai_message.append(
Expand Down

0 comments on commit 20e6bcb

Please sign in to comment.