Пример #1
0
    def test_mock_play_whole_deck(self):
        random.seed(0)
        s2 = sorry.strategy(self.g)
        p2 = sorry.player("Joe", "GREEN", s2)
        s2.set_player(p2)
        self.g._players = [self.p, p2]
        deck = [
            sorry.card1(),
            sorry.card2(),
            sorry.card3(),
            sorry.card4(),
            sorry.card5(),
            sorry.card7(),
            sorry.card8(),
            sorry.card10(),
            sorry.card11(),
            sorry.cardsorry(),
            sorry.card12()
        ]
        for i in xrange(161):
            card1 = deck[random.randint(0, len(deck) - 1)]
            card2 = deck[random.randint(0, len(deck) - 1)]
            s2.apply(card1)
            print card1
            print p2.positions()
            self.s.apply(card2)
            print card2
            print self.p.positions()

        self.assertTrue(self.p.is_win())
        self.assertTrue(p2.is_win())
Пример #2
0
 def test_move_11_strategy_1(self):
     card = sorry.card11()
     card1 = sorry.card1()
     s2 = sorry.strategy(self.g)
     p2 = sorry.player("Joe", "GREEN", s2)
     s2.set_player(p2)
     s2._player._pawns[0].position = 32
     self.g._players = [self.p, p2]
     self.s.apply(card1)
     self.s.apply(card)
     self.assertEqual(self.s._player.pawns[0].position, 32)
     self.assertEqual(s2._player.pawns[0].position, 3)
Пример #3
0
    def test_card1_2_common_strategy(self):
        card = sorry.card1()
        out = False
        self.s.card1_2_common_strategy(card)
        for pawn in self.s._player.pawns:
            if pawn.position > 0:
                out = True
        self.assertTrue(out)

        i = 0
        self.s.card1_2_common_strategy(card)
        for pawn in self.s._player.pawns:
            i += pawn.position
        self.assertEqual(i, 1)
Пример #4
0
    def test_mock_play_1(self):
        g = sorry.game()
        s1 = sorry.strategy(g)
        s2 = sorry.strategy(g)
        p1 = sorry.player("Bob", "YELLOW", s1)
        p2 = sorry.player("Joe", "GREEN", s2)
        s1.set_player(p1)
        s2.set_player(p2)
        card = sorry.card1()

        for i in xrange(160):
            s1.apply(card)
            s2.apply(card)

        self.assertTrue(p1.is_win())
        self.assertTrue(p2.is_win())
Пример #5
0
    def test_mock_play_7(self):
        g = sorry.game()
        s1 = sorry.strategy(g)
        s2 = sorry.strategy(g)
        p1 = sorry.player("Bob", "YELLOW", s1)
        p2 = sorry.player("Joe", "GREEN", s2)
        s1.set_player(p1)
        s2.set_player(p2)
        card = sorry.card7()
        card_out = sorry.card1()

        for i in xrange(11):
            if not self.avaliable_pawns(p1.pawns):
                s1.apply(card_out)
                s2.apply(card_out)
                continue
            s1.apply(card)
            s2.apply(card)

        self.assertEqual(p1.pawns[0].position, 163)
        self.assertEqual(p2.pawns[0].position, 178)
Пример #6
0
    def test_mock_play_5(self):
        g = sorry.game()
        s1 = sorry.strategy(g)
        s2 = sorry.strategy(g)
        p1 = sorry.player("Bob", "YELLOW", s1)
        p2 = sorry.player("Joe", "GREEN", s2)
        s1.set_player(p1)
        s2.set_player(p2)
        card = sorry.card5()
        card_out = sorry.card1()

        for i in xrange(56):
            if not self.avaliable_pawns(p1.pawns):
                s1.apply(card_out)
                s2.apply(card_out)
                continue
            s1.apply(card)
            s2.apply(card)

        self.assertTrue(p1.is_win())
        self.assertTrue(p2.is_win())
Пример #7
0
 def test_move_11_strategy_2(self):
     card = sorry.card11()
     card1 = sorry.card1()
     self.s.apply(card1)
     self.s.apply(card)
     self.assertEqual(self.p.pawns[0].position, 14)
Пример #8
0
 def test_move_10_startegy_1(self):
     card1 = sorry.card10()
     card2 = sorry.card1()
     self.s.apply(card2)
     self.s.apply(card1)
     self.assertEqual(self.s._player._pawns[0].position, 13)
Пример #9
0
 def test_move_backwards_strategy_2(self):
     card1 = sorry.card1()
     card2 = sorry.card4()
     self.s.card1_2_common_strategy(card1)
     self.s.move_backwards_strategy(card2)
     self.assertEqual(self.s._player._pawns[0].position, 3)
Пример #10
0
 def test_only_move_cards_common_strategy_1(self):
     card1 = sorry.card3()
     card2 = sorry.card1()
     self.s.card1_2_common_strategy(card2)
     self.s.only_move_cards_common_strategy(card1)
     self.assertEqual(self.s._player._pawns[0].position, 6)
Пример #11
0
 def test_card1_2(self):
     c = sorry.card1()
     c.apply(self.p2, None, c.CARD_MODE[0], self.b)
     self.assertEqual(self.p2.position, 3)
Пример #12
0
 def test_card1_1(self):
     c = sorry.card1()
     c.apply(self.p1, None, c.CARD_MODE[1], self.b)
     self.assertEqual(self.p1.position, 4)