Exemple #1
0
        public static IEnumerable <Move> FindMovesAlongDirection(this Checkerboard checkerboard, Pawn pawn, Position delta)
        {
            var currPosition = pawn.Position + delta;

            while (Checkerboard.Exists(currPosition))
            {
                if (checkerboard.IsOccupied(currPosition, out Pawn currPosPawn))
                {
                    if (currPosPawn.AreOppositeColor(pawn))
                    {
                        yield return(checkerboard.GetMove(pawn, currPosition, currPosPawn));
                    }
                    break;
                }
                else if (checkerboard.IsEmptyButExists(currPosition))
                {
                    yield return(checkerboard.GetMove(pawn, currPosition));
                }
                currPosition += delta;
            }
        }