Exemplo n.º 1
0
 // Creates a machine playerInfo
 public PlayerInfo(bool i_Human, Checkers.ePlayerTag i_PlayerTag)
 {
     Name      = k_ComputerName;
     Human     = i_Human;
     Score     = 0;
     PlayerTag = i_PlayerTag;
 }
Exemplo n.º 2
0
 // Creates a human playerInfo
 public PlayerInfo(string i_PlayerName, bool i_Human, Checkers.ePlayerTag i_PlayerTag)
 {
     Name      = i_PlayerName;
     Human     = i_Human;
     Score     = 0;
     PlayerTag = i_PlayerTag;
 }
Exemplo n.º 3
0
        // Fills the pieces lists of each player by checking the pieces positions on the board, only used in the beginning of a match
        public List <Checkers.Piece> BuildPlayerPiecesList(Checkers.ePlayerTag i_CurrentPlayer)
        {
            List <Checkers.Piece> listOfPieces = new List <Checkers.Piece>(getNumberOfInitialPieces());
            int cellIndex = 0;

            for (int row = 0; row < (int)r_BoardSize; ++row)
            {
                for (int col = 0; col < (int)r_BoardSize; ++col)
                {
                    if (isPieceBelongsToPlayer(r_BoardMatrix[row, col], i_CurrentPlayer))
                    {
                        listOfPieces.Add(new Checkers.Piece(i_CurrentPlayer));
                        listOfPieces[cellIndex++].CurrPosition = new Position(row, col);
                    }
                }
            }

            return(listOfPieces);
        }
Exemplo n.º 4
0
        // Used by the function that builds the pieces lists according to the positions on the board
        private bool isPieceBelongsToPlayer(eCellMode i_Cell, Checkers.ePlayerTag i_Player)
        {
            bool pieceBelongToPlayer;

            switch (i_Player)
            {
            case Checkers.ePlayerTag.First:
                pieceBelongToPlayer = i_Cell == eCellMode.Player1Piece || i_Cell == eCellMode.Player1King;
                break;

            case Checkers.ePlayerTag.Second:
                pieceBelongToPlayer = i_Cell == eCellMode.Player2Piece || i_Cell == eCellMode.Player2King;
                break;

            default:
                throw new InvalidEnumArgumentException();
            }

            return(pieceBelongToPlayer);
        }