def __init__(self, players, deck): """Constructor. Args: players: A list of Player objects. deck: The name of the deck for this game. """ # Container for state variables. self._state = utils.AttributeDict() # A unique ID for the game. self._id = uuid.uuid1() # The deck of cards to use. try: self._deck = Deck.fromjson(utils.CheckPath(deck + ".json", _DECK_DIR)) except IOError: raise ValueError("Invalid deck name '{}', deck not found".format(deck)) # The players of the game. if not players: raise ValueError("Players cannot be empty") self._players = players self._num_players = len(players) self._dealer = None
#!/usr/bin/env python2.7 # # Copyright 2013 Cards with Friends LLC. All Rights Reserved. """Tests for deck.""" __author__ = "[email protected] (Ben Razon)" from deck import Deck if __name__ == "__main__": d = Deck.fromjson("decks/standard.json") assert(d.name == "standard") assert(d.long_name == "Standard 52-Card Deck") # d.GetBackImage().show() cards = list(d) assert(len(cards) == 52) print cards