Longhorn-Riichi / Ronhorn

Longhorn Riichi's club bot. Includes global commands that provide mahjong utilities.
https://longhornriichi.com/ronhorn/
MIT License
7 stars 1 forks source link

*display tiles* command #25

Closed peter1357908 closed 1 year ago

peter1357908 commented 1 year ago

Like jekyll-mahjong, allowing sideways tiles.

EpicOrange commented 1 year ago
s = "12p78s 45p 7s"

def hand_to_tenhou(hand):
  ret = []
  suits = {"m": 10, "p": 20, "s": 30, "z": 40}
  curr_suit = ""
  for c in hand[::-1]:
    if c.isalpha():
      curr_suit = c
    else:
      tile = suits[curr_suit] + int(c)
      if tile in {10, 20, 30}:
        tile = 50 + (tile // 10)
      ret.append(tile)
  return ret[::-1]

hand, calls, winning_tile, *rest = map(hand_to_tenhou, s.split(" "))

print(hand)
print(calls)
print(winning_tile)
peter1357908 commented 1 year ago

Done in commit b1770d2