コード例 #1
0
 public void TestKing_Position()
 {
     for (int i = 0; i < 100; i++)
     {
         Random random = new Random();
         int row = random.Next(0, 7);
         int col = random.Next(0, 7);
         Position position = new Position(row, col);
         King king = new King(position);
         Assert.AreEqual<Position>(king.Position, position, "King`s position is not working correctly");
     }
 }
コード例 #2
0
ファイル: Figure.cs プロジェクト: rusev-s/Nickel-Team-Project
        public Figure(Position position, char symbol)
        {
            this.Position = position;

            //if (((int)symbol >= (int)'a') && ((int)'z' <= (int)symbol))) ||
            //    ((int)symbol >= (int)'A' &&  (int)'Z' <= (int)symbol))
            if ((symbol >= 'A' && symbol <= 'Z') || (symbol >= 'a' && symbol <= 'z'))
            {
                this.symbolRepresentation = symbol;
            }
            else
            {
                throw new ArgumentOutOfRangeException("Not valid figure symbol");
            }
        }
コード例 #3
0
ファイル: Engine.cs プロジェクト: rusev-s/Nickel-Team-Project
 private bool IsValidGameBoardCell(Position position)
 {
     bool valid = this.gameBoard.IsInGameField(position) && this.gameBoard[position.Row, position.Column] == ' ';
     return valid;
 }
コード例 #4
0
ファイル: Engine.cs プロジェクト: rusev-s/Nickel-Team-Project
        /// <summary>
        /// Gets the displacement for figure movement
        /// </summary>
        private Position GetDisplacement(Direction direction)
        {
            Position displacement = null;
            switch (direction)
            {
                case Direction.DL:
                    displacement = new Position(1, -2);
                    break;
                case Direction.DR:
                    displacement = new Position(1, 2);
                    break;
                case Direction.UL:
                    displacement = new Position(-1, -2);
                    break;
                case Direction.UR:
                    displacement = new Position(-1, 2);
                    break;
                default:
                    throw new ArgumentException("Invalid direction for displacement!");
            }

            return displacement;
        }
コード例 #5
0
        public void DrawGameBoard()
        {
            Console.WriteLine();
            for (int row = 0; row < gameBoard.GetLength(0); row++)
            {
                for (int col = 0; col < gameBoard.GetLength(1); col++)
                {
                    Position positionCell = new Position(row, col);
                    bool isCellIn = IsInGameField(positionCell);
                    if (isCellIn)
                    {
                        if (row % 2 == 0)
                        {
                            if (col % 4 == 0)
                            {
                                Console.BackgroundColor = ConsoleColor.Green;
                                Console.ForegroundColor = ConsoleColor.Black;
                                Console.Write(gameBoard[row, col]);
                                Console.ResetColor();
                            }
                            else if (col % 2 == 0)
                            {
                                Console.BackgroundColor = ConsoleColor.Blue;
                                Console.ForegroundColor = ConsoleColor.Black;
                                Console.Write(gameBoard[row, col]);
                                Console.ResetColor();
                            }
                            else //if (col % 2 != 0)
                            {
                                Console.Write(gameBoard[row, col]);
                            }
                        }
                        else if (col % 4 == 0)
                        {
                            Console.BackgroundColor = ConsoleColor.Blue;
                            Console.ForegroundColor = ConsoleColor.Black;
                            Console.Write(gameBoard[row, col]);
                            Console.ResetColor();
                        }
                        else if (col % 2 == 0)
                        {
                            Console.BackgroundColor = ConsoleColor.Green;
                            Console.ForegroundColor = ConsoleColor.Black;
                            Console.Write(gameBoard[row, col]);
                            Console.ResetColor();
                        }
                        else //if (col % 2 != 0)
                        {
                            Console.Write(gameBoard[row, col]);
                        }
                    }
                    else
                    {
                        Console.Write(gameBoard[row, col]);
                    }

                }
                Console.WriteLine();
                Console.ResetColor();
            }
            Console.WriteLine();
        }
コード例 #6
0
        public bool IsInGameField(Position position)
        {
            int positonRow = position.Row;
            bool isRowInBoard = (positonRow >= topLeft.Row) && (positonRow <= bottomLeft.Row);
            int positonCol = position.Column;
            bool isColInBoard = (positonCol >= topLeft.Column) && (positonCol <= topRight.Column);
            bool isValidPosition = isRowInBoard && isColInBoard;

            return isValidPosition;
        }
コード例 #7
0
ファイル: King.cs プロジェクト: rusev-s/Nickel-Team-Project
 public King(Position position)
     : base(position, kingSymbol)
 {
     this.ExistingMoves = new bool[] { true, true, true, true };
 }
コード例 #8
0
ファイル: Pawn.cs プロジェクト: rusev-s/Nickel-Team-Project
 public Pawn(Position position, char pawnSymbol)
     : base(position, pawnSymbol)
 {
     this.ExistingMoves = new bool[] { true, true };
 }