package server.command;
import server.Player;
import server.Room;
import server.SyntaxException;
import common.Direction;
public class DirectionCommand extends Command {
private final Direction direction;
public DirectionCommand(Direction direction) {
super(CommandCategory.MOVEMENT, "Moves in the specified direction.");
this.direction = direction;
}
@Override
public void run(Player player) throws SyntaxException {
if (CommandProcessor.nextToken() != null) {
throw new SyntaxException();
}
Room room = player.getRoom();
Room newRoom = room.getAdjacentRoom(direction);
if (newRoom == null) {
player.sendText(true, "There is no exit in that direction.");
return;
}
player.move(direction);
}
@Override
public String[] getSyntax(Player player) {
return new String[] { "" };
}
}