示例#1
0
 def json_to_dealer(cls, json_config):
     assert(cls.validate_configuration_json(json_config))
     players_interfaces = []
     num_players = len(json_config[0])
     for i in range(num_players):
         players_interfaces.append(Player())
     dealer = Dealer(players_interfaces)
     for i in range(num_players):
         dealer.players[i] = cls.json_to_player(json_config[0][i])
     dealer.watering_hole = json_config[1]
     deck = []
     for i in range(len(json_config[2])):
         deck.append(cls.json_to_trait_card(json_config[2][i]))
     dealer.deck = deck
     return dealer
示例#2
0
 def json_to_dealer(cls, json_config):
     """
     Converts a Configuration json input into a dealer with the game as
     described in the Configuration object.
     :param json_config: A Configuration [LOP, Natural, LOC], where LOP is a
     list of 3 to 8 Players, the Natural represents food in the watering hole,
     and the LOC is the deck of cards in the order they will appear.
     :return: A Dealer with the game configured properly to the given json_config.
     """
     assert(cls.validate_configuration_json(json_config))
     players_interfaces = []
     num_players = len(json_config[0])
     for i in range(num_players):
         players_interfaces.append(Player())
     dealer = Dealer(players_interfaces)
     for i in range(num_players):
         dealer.player_sets[i]['state'] = cls.json_to_player(json_config[0][i])
     dealer.watering_hole = json_config[1]
     deck = []
     for i in range(len(json_config[2])):
         deck.append(cls.json_to_trait_card(json_config[2][i]))
     dealer.deck = deck
     return dealer