Пример #1
0
 def setUp(self):
     self.testPile = game.Pile()
     self.card_one = game.Card("Hearts", "Ace")
     self.card_two = game.Card("Spades", "Ace")
     self.testPile.cards.append(self.card_one)
     self.testPile.cards.append(self.card_two)
     self.topCards = self.testPile.getTopCards()
Пример #2
0
    def on_message(self, mesg):

        logging.info("got message %r", mesg)
        mesg = mesg.split(' ')

        if mesg[0] == 'add':
            HostHandler.Players[int(mesg[1])] = self
            HostHandler.PlayerToIdx[self] = int(mesg[1])

        if mesg[0] == 'bidStyle':
            _card = Game.Card(int(mesg[1]), game.hostNum)
            _playerId = HostHandler.PlayerToIdx[self]
            _hostCardN = game.players[_playerId].count(_card)
            #print _hostCardN
            #if _hostCardN ==1 :
            #    cardsMesg={ "style": game.players[i][cardidx].s, "num": game.players[i][cardidx].n }
            #    HostHandler.updater(cardsMesg)

            cardsMesg = {"style": int(mesg[1]), "num": game.hostNum}
            HostHandler.updater(cardsMesg)
Пример #3
0
 def test_hand_value(self):
     self.assertEqual(0, game.hand_value([]))
     self.assertEqual(10,
                      game.hand_value([game.Card('diamonds', '10', False)]))
     self.assertEqual(
         21,
         game.hand_value([
             game.Card('diamonds', '10', False),
             game.Card('diamonds', 'A', False)
         ]))
     self.assertEqual(
         12,
         game.hand_value([
             game.Card('diamonds', '10', False),
             game.Card('diamonds', 'A', False),
             game.Card('diamonds', 'A', False)
         ]))
Пример #4
0
 def testHasMatched2(self):
     self.testPile.cards.append(game.Card("Hearts", 2))
     self.assertFalse(self.testPile.hasMatched())
Пример #5
0
def create_sorted_game():
    players = game.Card.COLORS
    g = game.Game(players)
    # Distribute cards in a predefined manner
    g.cards = {c: [game.Card(i, c) for i in range(1, 14)] for c in g.players}
    return g