예제 #1
0
파일: deck.py 프로젝트: MatTerra/ManVsVirus
 def deserialize(cls, data: dict) -> Deck:
     deck = Deck()
     deck.drawn = [Card.deserialize(serialized_card) for serialized_card in
                   data.get('drawn')]
     deck.cards = [Card.deserialize(serialized_card) for serialized_card in
                   data.get('cards')]
     return deck
예제 #2
0
 def deserialize(cls, data: dict, board: Board) -> Player:
     player_id = data['id']
     player_role = {Player.ROLES[key]: key
                    for key in Player.ROLES}[data['role']]
     player_location = board.locations[data['location']]
     player_cards = list()
     for serialized_card in data['cards']:
         deserialized_card = Card.deserialize(serialized_card)
         player_cards.append(deserialized_card)
     player = Player(id_=player_id,
                     role=player_role,
                     board=board,
                     location=player_location)
     player.cards = player_cards
     return player
예제 #3
0
 def test_deserialization(self, check_card: Card):
     card_serialized = check_card.serialize()
     card_deserialized = Card.deserialize(card_serialized)
     assert card_deserialized == check_card