Example #1
0
 def test_serialization(self):
   self.deck.draw_cards(5)
   self.deck.shuffle()
   serial = self.deck.serialize()
   restored = Deck.deserialize(serial)
   self.eq(self.deck.cheat, restored.cheat)
   self.eq(self.deck.deck, restored.deck)
Example #2
0
 def test_cheat_serialization(self):
   cards = [Card.from_id(cid) for cid in [12, 15, 17]]
   cheat = Deck(cheat=True, cheat_card_ids=[12, 15, 17])
   serial = cheat.serialize()
   restored = Deck.deserialize(serial)
   self.eq(cheat.deck, restored.deck)
   self.eq(cheat.cheat, restored.cheat)
   self.eq(cheat.cheat_card_ids, restored.cheat_card_ids)
Example #3
0
 def deserialize(self, serial):
     deck = Deck.deserialize(serial[2])
     community_card = [Card.from_id(cid) for cid in serial[3]]
     table = self(cheat_deck=deck)
     table.dealer_btn = serial[0]
     table.seats = Seats.deserialize(serial[1])
     table._community_card = community_card
     table._blind_pos = serial[4]
     return table