예제 #1
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)
예제 #2
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)
예제 #3
0
    def test_lookup(self):
        d = Deck()
        card = d.lookup("R5")[0]
        self.assertEqual(card.color, "R")
        self.assertEqual(card.value, "5")

        card = d.lookup("NW")[0]
        self.assertEqual(card.color, "N")
        self.assertEqual(card.value, "W")

        self.assertRaises(InvalidCard, d.lookup, "AA")

        card = d.lookup("NW")[0]
        card.status = 2
        self.assertEqual(len(d.lookup("NW")), 3)
예제 #4
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()
예제 #5
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)
예제 #6
0
 def test_dispose(self):
     d = Deck()
     d.dispose()
     self.assertEqual(len(d.cards), 0)