/*
Copyright (C) 2005 David Green <green@couchpotato.net>
All Rights Reserved.

This file is part of Aelfengard.

Aelfengard is proprietary software. You may not redistribute it without
prior written permission from the copyright holder.
*/

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[] { "" };
    }

}