Example #1
0
        public void AllMovesWithinDirection()
        {
            Point start = new Point(2, 2);
            Point end   = new Point(4, 0);
            Point dir   = new Point(1, -1);

            var erg = start.AllMovesWithinDirection(end, dir);
            var res = erg.Count == 2;

            Assert.IsTrue(res);
        }
Example #2
0
        public override bool CanBeMovedToSquare(Square end)
        {
            var dir = ChooseRightDirection(end.Point);

            if (dir == null)
            {
                return(false);
            }

            if (dir.PosX != 0 && Point.GoToDirection(dir).Equals(end.Point) && end.Piece != null)
            {
                return(true);
            }

            var points = Point.AllMovesWithinDirection(end.Point, dir);

            if (dir.PosX == 0 && (points.Count == 1 ^ (points.Count == 2 && IsFirstMove)) && end.Piece == null)
            {
                return(true);
            }

            return(false);
        }