public Square(int i_BoardCol, int i_BoardRow, ePlayerColor i_PlayerColor) { m_Col = i_BoardCol; m_Row = i_BoardRow; m_SquareValue = i_PlayerColor; m_MyKingSign = m_SquareValue == ePlayerColor.White || m_SquareValue == ePlayerColor.WhiteKing ? ePlayerColor.WhiteKing : ePlayerColor.BlackKing; }
// Constructor internal Player(string i_Type, string i_Name, ePlayerColor i_Color) { this.m_Type = getTypeFromString(i_Type); this.m_Name = i_Name; this.m_Score = 0; this.m_Color = i_Color; }
public Checker(ePlayerColor i_Color, SquarePosition i_Position, eCheckerType i_Type = eCheckerType.Soldier) { m_Type = i_Type; m_Color = i_Color; m_Position = i_Position; m_PossibleMoves = new List <Move>(4); // maximum possible moves for one checker (when king) }
public void initializeBoard(int i_BoardSize) { m_CurrentMove = new Move(); m_CurrentTurn = ePlayerColor.White; m_Board = new Checker[i_BoardSize, i_BoardSize]; m_BlacksCounter = 0; m_WhitesCounter = 0; ColorToss(); for (int i = 0; i < (i_BoardSize / 2) - 1; i++) // initialize the black checkers on the board { for (int j = (i + 1) % 2; j < i_BoardSize; j += 2) { m_Board[i, j] = new Checker(ePlayerColor.Black, new SquarePosition(i, j)); m_BlacksCounter++; } } for (int i = i_BoardSize - 1; i > i_BoardSize / 2; i--) // initialize the white checkers on the board { for (int j = (i + 1) % 2; j < i_BoardSize; j += 2) { m_Board[i, j] = new Checker(ePlayerColor.White, new SquarePosition(i, j)); m_WhitesCounter++; } } }
public Player(Player i_Other) { this.r_PlayerName = i_Other.r_PlayerName; this.r_PlayerType = i_Other.r_PlayerType; this.r_PlayerNumber = i_Other.r_PlayerNumber; this.r_PlayerColor = i_Other.r_PlayerColor; this.m_PlayerScore = i_Other.m_PlayerScore; }
public Player(string i_PlayerName, ePlayerType i_PlayerType, ePlayerNumber i_PlayerNumber, ePlayerColor i_PlayerColor, int i_PlayerScore = k_InitialScore) { r_PlayerName = i_PlayerName; r_PlayerType = i_PlayerType; r_PlayerNumber = i_PlayerNumber; m_PlayerScore = i_PlayerScore; r_PlayerColor = i_PlayerColor; }
private static char figureSign(ePlayerColor i_Color) { char figure = 'O'; if (i_Color == ePlayerColor.White) { figure = 'X'; } return(figure); }
internal bool IsWithdrawLegal() { int whitePlayerScore = 0; int blackPlayerScore = 0; ePlayerColor currentPlayerColor = m_CurPlayer.Color; bool legalWithdraw = false; foreach (Board.BoardSquare square in m_Board.Matrix) { if (square.GetShape != eShape.Blank) { switch (square.GetShape) { case eShape.Black: blackPlayerScore++; break; case eShape.BlackKing: blackPlayerScore += 4; break; case eShape.White: whitePlayerScore++; break; case eShape.WhiteKing: whitePlayerScore += 4; break; } } } switch (currentPlayerColor) { case ePlayerColor.White: legalWithdraw = whitePlayerScore <= blackPlayerScore; break; case ePlayerColor.Black: legalWithdraw = whitePlayerScore >= blackPlayerScore; break; } return(legalWithdraw); }
private bool isOpponent(Board i_GameBoard, Square i_SquarePlayer) { bool result = false; int col = i_SquarePlayer.Col; int row = i_SquarePlayer.Row; if (!checkIfOutOfBounds(i_GameBoard.Size, col, row)) { ePlayerColor opponentSign = i_GameBoard[col, row].SquareValue; ePlayerColor myColor = SquareValue == ePlayerColor.White || SquareValue == ePlayerColor.WhiteKing ? ePlayerColor.White : ePlayerColor.Black; if ((char)opponentSign != (char)MyKingSign && (char)opponentSign != (char)myColor && (char)opponentSign != (char)ePlayerColor.Blank) { result = true; } } return(result); }
internal BoardSquare(eShape i_Shape, Location i_Location, ePlayerColor i_Color) { m_Checker = new Piece(i_Shape, i_Color); m_Coordinates = i_Location; }
internal void setBoardSquare(int i_Row, int i_Col, eShape i_Shape, ePlayerColor i_Color) { m_BoardSquares[i_Row, i_Col] = new BoardSquare(i_Shape, new Location(i_Row, i_Col), i_Color); }
public Player(string i_Name, ePlayerColor i_Color, bool i_isBot) { m_Name = i_Name; m_Color = i_Color; m_isBot = i_isBot; }
public void updateCurrentTurn() { m_CurrentTurn = (ePlayerColor)((int)m_CurrentTurn * -1); }
public ePlayerColor OppositeColor() { ePlayerColor color = (ePlayerColor)((int)m_Color * -1); return(color); }
internal Piece(Location i_Location, eShape i_Shape, ePlayerColor i_Color) { m_Shape = i_Shape; m_Color = i_Color; m_Location = i_Location; }