示例#1
0
        public void Advance(IPlayer player, int pieceIndex)
        {
            player.Pieces = player.Pieces
                            .Select((pieceLocation, index) =>
            {
                if (index == pieceIndex)
                {
                    if (pieceLocation == -1)
                    {
                        pieceLocation = ColorPositions.StartPosition(player.Color);
                    }

                    var nextLocation = pieceLocation + player.PreviousDieRoll;
                    if (!ColorPositions.OutsideWinningPosition(player.Color, nextLocation))
                    {
                        return(nextLocation);
                    }
                }

                return(pieceLocation);
            })
                            .ToArray();
        }
示例#2
0
 public bool HasWon(IPlayer player)
 {
     return(player.Pieces.Intersect(ColorPositions.WinPositions(player.Color)).Count() == 4);
 }