使用Python語言填寫leepCoders的模型類
解析:
按照文檔的類關(guān)系和函數(shù),填寫代碼模板中的類
Card:卡牌類
play(self, player: Player, game: a2_support.CodersGame):#在玩家玩牌的時候調(diào)用,玩家丟棄手中的牌從牌堆中拾取新的牌。
action(self, player: Player, game:a2_support.CodersGame, slot: int): #使用特殊牌的時候被調(diào)用
str(self) -> str(Card()): #返回當(dāng)前牌的信息
__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: #返回牌堆中牌的數(shù)量
shuf?e(self): #洗牌
pick(self, amount: int=1) -> List[Card]: #取第一張卡并返回
add_card(self, card: Card): #在牌堆頂部添加一張卡
add_cards(self, cards: List[Card]): #在牌堆頂添加一列卡牌
copy(self, other_deck: Card): #從其他的牌堆中復(fù)制到當(dāng)前牌堆
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 #累計分數(shù)公式
涉及知識點:
python面向?qū)ο?、字符串處?/p>