1
1
This commit is contained in:
20
src/engine/mahjong_tile.py
Normal file
20
src/engine/mahjong_tile.py
Normal file
@@ -0,0 +1,20 @@
|
||||
class MahjongTile:
|
||||
SUITS = ['条', '筒', '万']
|
||||
|
||||
def __init__(self, suit, value):
|
||||
if suit not in self.SUITS or not (1 <= value <= 9):
|
||||
raise ValueError("Invalid tile")
|
||||
self.suit = suit
|
||||
self.value = value
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self.value}{self.suit}"
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.suit == other.suit and self.value == other.value
|
||||
|
||||
def __hash__(self):
|
||||
return hash((self.suit, self.value))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user