AIsOfCatan.Board.GetAllPieces C# (CSharp) Method

GetAllPieces() public method

public GetAllPieces ( ) : Piece>.Dictionary
return Piece>.Dictionary
        public Dictionary<Intersection, Piece> GetAllPieces()
        {
            return new Dictionary<Intersection, Piece>(settlements);
        }

Usage Example

Example #1
0
        public int GetPlayerScore(int playerId)
        {
            int result = 0;

            if (playerId == LargestArmyId)
            {
                result += 2;
            }
            if (playerId == LongestRoadId)
            {
                result += 2;
            }

            // add 2 for each city and 1 for each settlement
            Board.GetAllPieces().Where(p => p.Value.Player == playerId).ForEach(p => result += p.Value.Token == Token.City ? 2 : 1);

            return(result);
        }