コード例 #1
0
        private Score createInstances()
        {
            FakeBoard board = new FakeBoard(20, 10);

            this.board = board;
            return(new Score(board));
        }
コード例 #2
0
ファイル: BoardTest.cs プロジェクト: dimitrispy1/Tetris-Game
        public void TestClearLines()
        {
            FakeBoard c = createInstance() as FakeBoard;

            IShape current = null;

            while (!(current is ShapeI))
            {
                c = createInstance() as FakeBoard;

                current = c.shape;
            }

            ShapeProxy z = getProxy(c);

            Console.WriteLine("Board before drop of ShapeI");
            UtilityClass.DrawFakeBoardContents(c);

            z.Drop();

            Console.WriteLine("Button line should be clear and everthing should shft");
            UtilityClass.DrawFakeBoardContents(c);

            //check if line got cleared
            Assert.AreEqual(c[19, 0], Color.Transparent);

            //check if the top piece shifted 1 down

            Assert.AreEqual(c[1, 0], Color.DarkRed);
        }
コード例 #3
0
ファイル: BoardTest.cs プロジェクト: dimitrispy1/Tetris-Game
        public void TestGameOver()
        {
            FakeBoard board = createInstance() as FakeBoard;

            board.GameOver += FakeGameOverHandler;

            ShapeProxy z = getProxy(board);

            //shapes will be dropped so after 6-7 pieces the board should be full
            for (int i = 0; i < 15; i++)
            {
                z.Drop();
                UtilityClass.DrawFakeBoardContents(board);
            }
        }
コード例 #4
0
        public static void DrawFakeBoardContents(FakeBoard a)
        {
            for (int i = 0; i < 20; i++)
            {
                for (int y = 0; y < 10; y++)
                {
                    if (a.board[i, y] != Color.Transparent)
                        Console.Write("*");

                    else
                        Console.Write("-"); 
                }

                Console.Write("|\n");
            }
        }
コード例 #5
0
ファイル: BoardTest.cs プロジェクト: dimitrispy1/Tetris-Game
        public void TestBoardAddToPile()
        {
            FakeBoard board = createInstance() as FakeBoard;

            ShapeProxy a = getProxy(board);

            //make it so IShape wont clear line when dropped
            board.board[19, 0] = Color.Transparent;

            int  index  = 19;
            bool filled = false;

            IShape current = board.shape;

            Console.WriteLine("Board before the drop");
            UtilityClass.DrawFakeBoardContents(board);
            Console.WriteLine();


            for (int i = 0; i < 12; i++)
            {
                a.Drop();

                Console.WriteLine("Board AFTER the drop");
                UtilityClass.DrawFakeBoardContents(board);

                //check the middle or 1 to the right or left

                if (board[index, 5] != Color.Transparent ||
                    board[index, 5 + 1] != Color.Transparent ||
                    board[index, 5 - 1] != Color.Transparent)
                {
                    filled = true;
                }
                else
                {
                    filled = false;
                }


                index = index - 1;
                Console.WriteLine("Checking index = " + index);

                Assert.AreEqual(true, filled);
            }
        }
コード例 #6
0
        //************************************************************************************
        private ShapeProxy createInstance()
        {
            IBoard board = new FakeBoard(20, 10);

            boardInstance = (FakeBoard)board;

            FakeBoard fake = board as FakeBoard;

            fake.board[19, 0] = Color.DarkBlue;
            fake.board[19, 1] = Color.DarkBlue;
            fake.board[19, 2] = Color.DarkBlue;
            fake.board[19, 7] = Color.DarkBlue;
            fake.board[19, 8] = Color.DarkBlue;
            fake.board[19, 9] = Color.DarkBlue;


            ShapeProxy factory = (ShapeProxy)((FakeBoard)board).shapeFactory;

            return(factory);
        }
コード例 #7
0
ファイル: BoardTest.cs プロジェクト: dimitrispy1/Tetris-Game
        public IBoard createInstance()
        {
            FakeBoard b = new FakeBoard(20, 10);

            b.board[19, 0] = Color.DarkRed;
            b.board[19, 1] = Color.DarkRed;
            b.board[19, 2] = Color.DarkRed;

            b.board[19, 7] = Color.DarkRed;
            b.board[19, 8] = Color.DarkRed;
            b.board[19, 9] = Color.DarkRed;


            b.board[0, 0] = Color.DarkRed;
            b.board[0, 1] = Color.DarkRed;

            b.board[0, 8] = Color.DarkRed;
            b.board[0, 9] = Color.DarkRed;

            return(b);
        }
コード例 #8
0
ファイル: BoardTest.cs プロジェクト: dimitrispy1/Tetris-Game
 private ShapeProxy getProxy(FakeBoard a)
 {
     return(a.shapeFactory as ShapeProxy);
 }