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(); }
public bool HasWon(IPlayer player) { return(player.Pieces.Intersect(ColorPositions.WinPositions(player.Color)).Count() == 4); }