Ejemplo n.º 1
0
    def test_next(self):
        d = Deck()
        d.deal(5)
        c = d.next()

        self.assertEqual(c.playerId, 0)

        for i in xrange(108 - 5 * 7 - 2):
            d.next()
Ejemplo n.º 2
0
    def test_toStr(self):
        d = Deck()
        s = d.toString()

        self.assertEqual(len(s), MAX_CARD * 2)

        d.deal(5)
        p1 = lambda cards: [c for c in cards if c.playerId == 1]

        s = d.toString(p1)

        self.assertEqual(len(s), 7 * 2)
Ejemplo n.º 3
0
    def test_deal(self):
        d = Deck()
        d.deal(5)

        p1 = [c for c in d.cards if c.playerId == 1]
        p2 = [c for c in d.cards if c.playerId == 2]
        p3 = [c for c in d.cards if c.playerId == 3]
        p4 = [c for c in d.cards if c.playerId == 4]
        p5 = [c for c in d.cards if c.playerId == 5]

        self.assertEqual(len(p1), 7)
        self.assertEqual(len(p2), 7)
        self.assertEqual(len(p3), 7)
        self.assertEqual(len(p4), 7)
        self.assertEqual(len(p5), 7)
Ejemplo n.º 4
0
    def test_reshuffle(self):
        d = Deck()
        d.deal(5)

        fc = [c for c in d.cards if c.status == 0]

        self.assertEqual(len(fc), 108 - 35)

        for i in xrange(108 - 35):
            c = d.next()
            c.status = 2

        fc = [c for c in d.cards if c.status == 0]

        self.assertEqual(len(fc), 0)

        d.reshuffle()

        fc = [c for c in d.cards if c.status == 0]

        self.assertEqual(len(fc), 108 - 35)