示例#1
0
        public static bool Move(Board board, String Direction)
        {
            var      c      = ExplicitCast.castAsCorrectPiece(board.ListOfPieces.FirstOrDefault(bp => bp.Type == 1));
            Position moveTo = GetPositionFromDirection(board, Direction);

            if (BoardController.IsExit(board, moveTo))
            {
                board.CharacterEscaped = true;
                return(true);
            }

            if (BoardController.IsOccupied(board, moveTo))
            {
                return(false);
            }

            if (!BoardController.WithinBounds(board, moveTo))
            {
                return(false);
            }

            BoardController.MovePiece(board, c.pos, moveTo);

            return(true);
        }
示例#2
0
        public static bool Attack(Board board, String Direction)
        {
            var      c        = ExplicitCast.castAsCorrectPiece(board.ListOfPieces.FirstOrDefault(bp => bp.Type == 1));
            Position attackTo = GetPositionFromDirection(board, Direction);

            if (BoardController.IsExit(board, attackTo))
            {
                return(false);
            }

            if (!BoardController.WithinBounds(board, attackTo))
            {
                return(false);
            }

            BoardController.Attack(board, attackTo);

            return(true);
        }