예제 #1
0
        public void TestMove()
        {
            Line L = new Line(
                new Corner(new System.Drawing.Point(1, 1), _gameBoard, System.Drawing.Color.Black),
                new Corner(new System.Drawing.Point(1, 2), _gameBoard, System.Drawing.Color.Black)
                );

            Player P = new InkInputPlayer("andrew", "P1", System.Drawing.Color.Blue, _gamePanel.inkPanel, _gameBoard);

            Move M = new Move(L, P);

            _gameBoard.MakeMove(M, P);

            Assert.IsNotNull(_gameBoard.Moves[0]);

            Assert.AreEqual(
                _gameBoard.Moves[0].GetLine().GetStart().GetLocation().X,
                M.GetLine().GetStart().GetLocation().X
                );

            Assert.AreEqual(
                _gameBoard.Moves[0].GetLine().GetStart().GetLocation().Y,
                M.GetLine().GetStart().GetLocation().Y
                );

            Assert.AreEqual(_gameBoard.Moves[0].GetPlayer().GetDisplayName(), "andrew");

            Assert.AreEqual(_gameBoard.Moves[0].GetPlayer().GetInitials(), "P1");
        }
예제 #2
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            GameBoard gb = new GameBoard(
                int.Parse(cbBoardHeight.Text, CultureInfo.CurrentCulture),
                int.Parse(cbBoardWidth.Text, CultureInfo.CurrentCulture)
                );

            GamePanel f = new GamePanel();

            Player[] players = new Player[2];

            switch (this.cbPlayer1Type.SelectedIndex)
            {
            case 0:                     // human
                players[0] = new InkInputPlayer(txtPlayer1Name.Text, "P1", Color.Tomato, f.inkPanel, gb);
                break;
            }

            switch (this.cbPlayer2Type.SelectedIndex)
            {
            case 0:                     // human
                players[1] = new InkInputPlayer(txtPlayer2Name.Text, "P2", Color.Navy, f.inkPanel, gb);
                break;
            }

            Game g = new Game(players, gb);

            g.SetFreeMoveOnScore(cbFreeMove.Checked);
            f.Initialize(g);
            f.ShowDialog();
        }
예제 #3
0
        public void TestBox()
        {
            Line L1 = new Line(
                new Corner(new System.Drawing.Point(1, 1), _gameBoard, System.Drawing.Color.Black),
                new Corner(new System.Drawing.Point(1, 2), _gameBoard, System.Drawing.Color.Black)
                );

            Line L2 = new Line(
                new Corner(new System.Drawing.Point(1, 2), _gameBoard, System.Drawing.Color.Black),
                new Corner(new System.Drawing.Point(2, 2), _gameBoard, System.Drawing.Color.Black)
                );

            Line L3 = new Line(
                new Corner(new System.Drawing.Point(2, 2), _gameBoard, System.Drawing.Color.Black),
                new Corner(new System.Drawing.Point(2, 1), _gameBoard, System.Drawing.Color.Black)
                );

            Line L4 = new Line(
                new Corner(new System.Drawing.Point(2, 1), _gameBoard, System.Drawing.Color.Black),
                new Corner(new System.Drawing.Point(1, 1), _gameBoard, System.Drawing.Color.Black)
                );

            Player P1 = new InkInputPlayer("andrew", "P1", System.Drawing.Color.Blue, _gamePanel.inkPanel, _gameBoard);
            Player P2 = new InkInputPlayer("johndoe", "P2", System.Drawing.Color.Red, _gamePanel.inkPanel, _gameBoard);

            Move M1 = new Move(L1, P1);
            Move M2 = new Move(L2, P2);
            Move M3 = new Move(L3, P1);
            Move M4 = new Move(L4, P2);

            _gameBoard.MakeMove(M1, P1);
            _gameBoard.MakeMove(M2, P2);
            _gameBoard.MakeMove(M3, P1);
            _gameBoard.MakeMove(M4, P2);

            //Assert that the fourth move has created a box.
            Assert.IsNotNull(_gameBoard.BoxesCreatedByMove(M4, P2));
        }