Ejemplo n.º 1
0
        public void TestFreezeContent01()
        {
            Tetromino  block = new Tetromino(7, TetrisGame.NB_ROWS - 1, TetrominoType.Square);
            TetrisGame game  = new TetrisGame();

            bool[,] logicalGameBoard = game.GetLogicalGameBoard();

            game.FreezeContent(TetrisGame.NB_ROWS - 1, 7);
            Assert.IsFalse(logicalGameBoard[TetrisGame.NB_ROWS - 1, 7]);
        }
Ejemplo n.º 2
0
        public void TestFreezeContent02()
        {
            // ppoulin
            // Test redondant avec le précédent.
            // Je ne comprends pas la situation que tu as voulu tester

            Tetromino  block = new Tetromino(9, 18, TetrominoType.Square);
            TetrisGame game  = new TetrisGame();

            bool[,] logicalGameBoard = game.GetLogicalGameBoard();
            game.FreezeContent(19, 9);
            Assert.IsFalse(logicalGameBoard[19, 9]);
        }
Ejemplo n.º 3
0
        public void TestTetrisGameCtor()
        {
            TetrisGame game = new TetrisGame();

            bool[,] logicalGameBoard = game.GetLogicalGameBoard();

            for (int i = 0; i < logicalGameBoard.GetLength(0); i++)
            {
                for (int j = 0; j < logicalGameBoard.GetLength(1); j++)
                {
                    Assert.IsTrue(logicalGameBoard[i, j] == true);
                }
            }
        }
Ejemplo n.º 4
0
        // ppoulin
        // Faute de français
        //Fonction CanMoveRight : Cette méthode vérifie si le tetromino peux encore descendre en bouger vers la droite,
        //                        en prenant compte de ses petits blocs.
        //Paramètres rentrés : - TetrisGame game : La partie de tetris qui est en cours.
        //Visibilité : publique
        //
        //Aucune valeur de retour.
        public bool CanMoveRight(TetrisGame game)
        {
            int potentialNextRow    = topLeftRowOffset + b1.GetParentRowOffset();
            int potentialNextColumn = topLeftColumnOffset + b1.GetParentColumnOffset() + 2;

            bool[,] logicalGameBoard = game.GetLogicalGameBoard();

            if ((potentialNextColumn < TetrisGame.NB_COLUMNS) && (topLeftColumnOffset < TetrisGame.NB_COLUMNS))
            {
                if (logicalGameBoard[potentialNextRow, potentialNextColumn] == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
        public void TestIsRowCompleted()
        {
            TetrisGame game = new TetrisGame();

            bool[,] logicalGameBoard = game.GetLogicalGameBoard();
            //Blocs de test générés. À décommenter s'il y a lieu.
            int j = 2;

            for (j = 2; j < logicalGameBoard.GetLength(1); j++)
            {
                logicalGameBoard[TetrisGame.NB_ROWS - 1, j] = false;
                logicalGameBoard[TetrisGame.NB_ROWS - 2, j] = false;
            }
            Tetromino block = new Tetromino(0, TetrisGame.NB_ROWS - 2, TetrominoType.Square);

            for (int k = 0; k < logicalGameBoard.GetLength(1) - 1; k++)
            {
                Assert.IsFalse(logicalGameBoard[TetrisGame.NB_ROWS - 1, k]);
                Assert.IsFalse(logicalGameBoard[TetrisGame.NB_ROWS - 2, k]);
            }
            // ppoulin
            // Ce test ne teste pas la méthode IsRowCompleted
        }
Ejemplo n.º 6
0
        // ppoulin
        // Faute de français
        //Fonction CanMoveDown : Cette méthode vérifie si le tetromino peux encore descendre en bas,
        //                       en prenant compte de ses petits blocs.
        //Paramètres rentrés : - TetrisGame game : La partie de tetris qui est en cours.
        //Visibilité : publique
        //
        //Aucune valeur de retour.
        public bool CanMoveDown(TetrisGame game)                                          //Conçu en colaborationa avec Thomas Gauthier-Cossette
        {
            int potentialNextRowB1    = topLeftRowOffset + b1.GetParentRowOffset() + 2;   //L'éventuelle rangée que le bloc pourrait atteindre.
            int potentialNextColumnB1 = topLeftColumnOffset + b1.GetParentColumnOffset(); //L'éventuelle colonne que le bloc pourrait atteindre.

            int potentialNextRowB3    = topLeftRowOffset + b3.GetParentRowOffset() + 2;
            int potentialNextColumnB3 = topLeftColumnOffset + b3.GetParentColumnOffset();

            bool[,] logicalGameBoard = game.GetLogicalGameBoard();                                                                                                  //Le tableau logique de la partie.

            if (potentialNextRowB1 < TetrisGame.NB_ROWS && topLeftRowOffset < TetrisGame.NB_ROWS)                                                                   //On s'assure de ne pas dépasser la limite inférieur de l'écran.
            {
                if ((logicalGameBoard[potentialNextRowB1, potentialNextColumnB1] == true) && (logicalGameBoard[potentialNextRowB3, potentialNextColumnB3] == true)) //On s'assure qu'il n'y a pas de bloc gelé en dessous.
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            return(false);
        }