Update hand.py

dev
wsy182 2024-12-01 16:31:21 +08:00
parent 66310aa2f5
commit ea1a938aad
1 changed files with 3 additions and 0 deletions

View File

@ -83,3 +83,6 @@ class Hand:
""" 返回手牌的字符串表示 """ """ 返回手牌的字符串表示 """
tiles_str = ", ".join(str(tile) for tile in self.tiles) tiles_str = ", ".join(str(tile) for tile in self.tiles)
return f"手牌: [{tiles_str}], 牌的数量: {dict(self.tile_count)}" return f"手牌: [{tiles_str}], 牌的数量: {dict(self.tile_count)}"
def __iter__(self):
"""使 Hand 对象可迭代,直接迭代其 tiles 列表"""
return iter(self.tiles)