Пример #1
0
    def test_move_with_pop(self):
        g = Game()
        g.nextPiece = 1
        g.move(4)

        expected = [[Game.EMPTY] * SIZE for x in range(SIZE)]
        self.assertEqual(g.board, expected)
Пример #2
0
    def test_drop(self):
        g = Game()
        g.board[4][0] = 2
        g.nextPiece = 3
        g.move(4)

        expected = [[Game.EMPTY] * SIZE for x in range(SIZE)]
        expected[4][0] = 3
        self.assertEqual(g.board, expected)
Пример #3
0
    def test_pop_gray(self):
        g = Game()
        g.board[4][0] = Game.GRAY
        g.nextPiece = 2
        g.getPiece = lambda: 4
        g.move(4)

        self.assertTrue(g.board[4][0] == 4)
        self.assertEqual(g.board[4][1], Game.EMPTY)
Пример #4
0
    def test_move_with_chain_pop(self):
        g = Game()
        g.board[0][0] = 2
        g.board[1][0] = 2
        g.board[4][0] = 2
        g.nextPiece = 3
        g.move(2)

        expected = [[Game.EMPTY] * SIZE for x in range(SIZE)]
        expected[4][0] = 2
        self.assertEqual(g.board, expected)
Пример #5
0
    def test_score(self):
        g = Game()
        g.board[0][0:3] = [4, 5, 7]
        g.board[1][0:3] = [4, 1, 4]
        g.board[2][0:2] = [6, 7]
        g.board[3][0] = 3
        g.board[4][0:2] = [6, 5]
        g.board[6][0:3] = [5, 4, 4]
        g.nextPiece = 5
        g.piecesInRound = 1
        g.score = 21
        g.move(3)

        expected = [[Game.EMPTY] * SIZE for x in range(SIZE)]
        expected[0][0:3] = [Game.DGRAY, 4, 7]
        expected[1][0:2] = [Game.GRAY, 1]
        expected[2][0:3] = [Game.DGRAY, 6, 7]
        expected[3][0:2] = [Game.DGRAY, 3]
        expected[4][0:2] = [Game.DGRAY, 6]
        expected[5][0] = Game.DGRAY
        expected[6][0:2] = [Game.DGRAY, 5]

        self.assertEqual(g.board, expected)
        self.assertEqual(g.score, 17198)