Ejemplo n.º 1
0
 public bool IsAvailableMove(Corner start, Corner end)
 {
     return(IsAvailableMove(new Move(new Line(start, end))));
 }
Ejemplo n.º 2
0
        Box CreateBox(IMove move, BoxDirection direction, Player player)
        {
            bool   wouldBox = false;
            Corner ul = null, ur = null, ll = null, lr = null;

            switch (direction)
            {
            case BoxDirection.Up:
            {
                if (!(move.Line as Line).Vertical)
                {
                    ll = move.Line.Start as Corner;
                    ul = GetCornerFromDirection(ll, BoxDirection.Up);
                    lr = move.Line.End as Corner;
                    ur = GetCornerFromDirection(lr, BoxDirection.Up);
                }
            }
            break;

            case BoxDirection.Down:
            {
                if (!(move.Line as Line).Vertical)
                {
                    ul = move.Line.Start as Corner;
                    ur = move.Line.End as Corner;
                    ll = GetCornerFromDirection(ul, BoxDirection.Down);
                    lr = GetCornerFromDirection(ur, BoxDirection.Down);
                }
            }
            break;

            case BoxDirection.Left:
            {
                if ((move.Line as Line).Vertical)
                {
                    ur = move.Line.Start as Corner;
                    lr = move.Line.End as Corner;
                    ul = GetCornerFromDirection(ur, BoxDirection.Left);
                    ll = GetCornerFromDirection(lr, BoxDirection.Left);
                }
            }
            break;

            case BoxDirection.Right:
            {
                if ((move.Line as Line).Vertical)
                {
                    ul = move.Line.Start as Corner;
                    ll = move.Line.End as Corner;
                    ur = GetCornerFromDirection(ul, BoxDirection.Right);
                    lr = GetCornerFromDirection(ll, BoxDirection.Right);
                }
            }
            break;

            default:
                throw new ArgumentException("Direction must be one of Up, Down, Left, Right");
            }

            Box box = null;

            if (ul != null && ur != null && ll != null && lr != null)
            {
                wouldBox = MakesBox(ul, ur, ll, lr, move as Move);
                if (wouldBox)
                {
                    box = new Box(ul, ur, lr, ll, player, this);
                }
            }

            return(box);
        }