from collections import deque from src.engine.dizhu.utils import card_to_string class PlayerState: def __init__(self, hand_cards, role): self.hand_cards = hand_cards # 玩家手牌 self.role = role # "地主" 或 "农民" self.history = deque() # 出牌历史,使用 deque def get_hand_cards_as_strings(self): """ 获取玩家手牌的具体牌型字符串 :return: 手牌字符串列表 """ return [card_to_string(card) for card in self.hand_cards] def __repr__(self): """ 返回玩家的字符串表示,包括手牌和角色 """ hand_cards_str = ", ".join(self.get_hand_cards_as_strings()) return f"玩家角色: {self.role}, 手牌: [{hand_cards_str}]"