Прежде всего, вам необходимо прочитать ввод за символом. Поскольку вы уже взяли слово, вам нужно начать с индекса 0 и продолжить переход к следующему символу в do-while l oop. Для этого:
String[] action = {"x", "u", "d", "l", "r", "s", "h", "e"};
System.out.println("Please enter an action:");
Scanner sc = new Scanner(System.in);
String input = sc.next();
char selection;
int i = 0;
do{
selection = input.charAt(i++);
switch(selection){
case 'x': System.out.print("Bye!");
break;
case 'u' : System.out.print("You go one square up.");
break;
case 'd': System.out.print("You go one square down.");
break;
case 'l': System.out.print("You go one square left.");
break;
case 'r': System.out.print("You go one square right.");
break;
case 's': System.out.print("You search the square for treasure. You find nothing.");
break;
case 'h': System.out.print("You hide, waiting for enemies to come by. It gets boring after about an hour and a half, so you give up.");
break;
case 'e': System.out.print("You eat some food. You regain 0 hit points");
break;
case 'z':
break;
default:
System.out.println("I dont understand");
break;
}
} while (i < input.length() && selection != 'z');
В while()
должно быть другое условие, чтобы избежать превышения размера входной строки. Кроме того, я не мог понять, зачем вам массив String action
, который вы создали в начале.