コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: xzxzxc/checkers
        public void TestWhiteSimpleBackwardKill()
        {
            int[][] whiteChs = new int[1][];
            whiteChs[0] = new[] { 3, 3 };
            int[][] blackChs = new int[2][];
            blackChs[0] = new[] { 4, 4 };
            blackChs[1] = new[] { 2, 4 };
            TableCells.Create(GenerateArrayCellImplementations());
            Game.StartTestlGame(whiteChs, blackChs);
            int counter = 0;

            foreach (Move move in GameDataHandler.WhiteCheckers[0].AllowedMoves)
            {
                if (move.ToCell == TableCells.Cell[5, 5])
                {
                    if (move.Killed.Contains(TableCells.Cell[4, 4].Checker))
                    {
                        counter++;
                    }
                }
                if (move.ToCell == TableCells.Cell[1, 5])
                {
                    if (move.Killed.Contains(TableCells.Cell[2, 4].Checker))
                    {
                        counter++;
                    }
                }
            }
            Game.Clear();
            Assert.AreEqual(counter, 2);
        }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: xzxzxc/checkers
        public void TestWhiteQueenTrippleKill()
        {
            int[][] whiteChs = new int[1][];
            whiteChs[0] = new[] { 2, 5 };
            int[][] blackChs = new int[3][];
            blackChs[0] = new[] { 1, 4 };
            blackChs[1] = new[] { 2, 1 };
            blackChs[2] = new[] { 5, 2 };
            TableCells.Create(GenerateArrayCellImplementations());
            Game.StartTestlGame(new int[0][], blackChs, whiteChs);
            int counter = 0;

            foreach (Move move in GameDataHandler.WhiteCheckers[0].AllowedMoves)
            {
                if (move.ToCell == TableCells.Cell[7, 4])
                {
                    if (move.Killed.Contains(TableCells.Cell[1, 4].Checker))
                    {
                        if (move.Killed.Contains(TableCells.Cell[2, 1].Checker))
                        {
                            if (move.Killed.Contains(TableCells.Cell[5, 2].Checker))
                            {
                                counter++;
                            }
                        }
                    }
                }
            }
            Game.Clear();
            Assert.AreEqual(counter, 1);
        }
コード例 #3
0
ファイル: GameForm.Designer.cs プロジェクト: xzxzxc/checkers
        private void InitializeField()
        {
            this.SuspendLayout();

            this._fieldBox          = new PictureBox();
            this._fieldBox.Location = new Point(0, 25);
            this._fieldBox.Name     = "Field";
            this._fieldBox.Size     = new Size(600, 600);
            this.Controls.Add(this._fieldBox);

            TableCells.Create(GenerateArrayCellImplementations());

            for (byte i = 0; i < 8; i++)
            {
                for (byte j = 0; j < 8; j++)
                {
                    this._fieldBox.Controls.Add((PictureBox)TableCells.Cell[i, j].GetImage());
                }
            }

            this.ResumeLayout(false);
        }
コード例 #4
0
ファイル: UnitTest1.cs プロジェクト: xzxzxc/checkers
        public void TestBlackSimpleGo()
        {
            int[][] blackChs = new int[1][];
            blackChs[0] = new[] { 3, 3 };
            TableCells.Create(GenerateArrayCellImplementations());
            Game.StartTestlGame(new int[0][], blackChs, isWhite: false);
            int counter = 0;

            foreach (Move move in GameDataHandler.BlackCheckers[0].AllowedMoves)
            {
                if (move.ToCell == TableCells.Cell[4, 4])
                {
                    counter++;
                }
                if (move.ToCell == TableCells.Cell[2, 4])
                {
                    counter++;
                }
            }
            Game.Clear();
            Assert.AreEqual(counter, 2);
        }
コード例 #5
0
ファイル: UnitTest1.cs プロジェクト: xzxzxc/checkers
        public void TestWhiteQueenGo()
        {
            int[][] whiteChs = new int[1][];
            whiteChs[0] = new[] { 4, 4 };
            TableCells.Create(GenerateArrayCellImplementations());
            Game.StartTestlGame(new int[0][], new int[0][], whiteChs);
            int counter = 0;

            foreach (Move move in GameDataHandler.WhiteCheckers[0].AllowedMoves)
            {
                if (move.ToCell == TableCells.Cell[2, 2])
                {
                    counter++;
                }
                if (move.ToCell == TableCells.Cell[6, 2])
                {
                    counter++;
                }
            }
            Game.Clear();
            Assert.AreEqual(counter, 2);
        }