public Paths PathsFrom(BoardLocation location, int forPlayer)
        {
            var paths = new Paths();

            var playerIdx = (Colours)forPlayer;

            foreach (var dest in new[]
            {
                location.MoveRight(playerIdx, 2),
                location.MoveLeft(playerIdx, 2),
            })
            {
                if (dest != null)
                {
                    var side = dest.X > location.X
                            ? ChessMoveTypes.CastleKingSide
                            : ChessMoveTypes.CastleQueenSide;

                    paths.Add(new Path {
                        BoardMove.Create(location, dest, (int)side)
                    });
                }
            }

            return(paths);
        }
Esempio n. 2
0
        public Paths PathsFrom(BoardLocation location, int forPlayer)
        {
            var paths     = new Paths();
            var playerIdx = (Colours)forPlayer;

            foreach (var dest in new[]
            {
                location.MoveForward(playerIdx),
                location.MoveForward(playerIdx)?.MoveRight(playerIdx),
                location.MoveRight(playerIdx),
                location.MoveBack(playerIdx)?.MoveRight(playerIdx),
                location.MoveBack(playerIdx),
                location.MoveBack(playerIdx)?.MoveLeft(playerIdx),
                location.MoveLeft(playerIdx),
                location.MoveLeft(playerIdx)?.MoveForward(playerIdx)
            })
            {
                if (dest != null)
                {
                    paths.Add(new Path {
                        BoardMove.Create(location, dest, (int)ChessMoveTypes.KingMove)
                    });
                }
            }

            return(paths);
        }
 public static BoardLocation KnightHorizontalMove(this BoardLocation location, Colours colour, bool forward, bool right)
 => location.MoveRight(colour, forward ? 2 : -2)?.MoveForward(colour, right ? 1 : -1);