使用Python语言填写leepCoders的模型类
解析:
按照文档的类关系和函数,填写代码模板中的类
Card:卡牌类
play(self, player: Player, game: a2_support.CodersGame):#在玩家玩牌的时候调用,玩家丢弃手中的牌从牌堆中拾取新的牌。
action(self, player: Player, game:a2_support.CodersGame, slot: int): #使用特殊牌的时候被调用
str(self) -> str(Card()): #返回当前牌的信息
__repr__(self) -> str:#同上
Deck:牌堆类
get_cards(self) -> List[Card]: #返回牌堆中的卡组列表
get_card(self, slot) -> Card: #返回指定的slot
top(self) -> Card: #返回最后添加的卡片
remove_card(self, slot): #删除指定slot的卡片
get_amount(self) -> int: #返回牌堆中牌的数量
shuffle(self): #洗牌
pick(self, amount: int=1) -> List[Card]: #取第一张卡并返回
add_card(self, card: Card): #在牌堆顶部添加一张卡
add_cards(self, cards: List[Card]): #在牌堆顶添加一列卡牌
copy(self, other_deck: Card): #从其他的牌堆中复制到当前牌堆
str(self) -> str: #返回牌堆中包含的卡牌的字符串表示
repr(self) -> str: #同上
Player:玩家类
get_name(self) -> str: #返回玩家名称
get_hand(self) -> Deck: #返回玩家的手牌
get_coders(self) -> Deck: #返回玩家手牌中的coderCard
has_won(self) -> bool: #如果玩家手中有4个或以上的coderCard,返回trueMarking:计分类
Total Mark = (functionality + style)/2 #累计分数公式
涉及知识点:
python面向对象、字符串处理