package org.studiorailgun.sim.eval;

import org.studiorailgun.sim.eval.command.LookCommand;
import org.studiorailgun.sim.eval.command.SpeakCommand;
import org.studiorailgun.sim.eval.command.SystemCommand;
import org.studiorailgun.sim.eval.command.WalkCommand;
import org.studiorailgun.sim.eval.parse.CommandCategorizationModel;
import org.studiorailgun.sim.eval.parse.CommandCategorizationModel.CommandType;

/**
 * Parses game commands from the user
 */
public class GameCommandParser {

    /**
     * Initializes the command parser
     */
    public static void init(){
        CommandCategorizationModel.init();
    }
    
    /**
     * Parses the player's input
     * @param input The player's input
     */
    public static void parse(String input){
        CommandType type = CommandCategorizationModel.categorize(input);
        switch(type){

            case HELP: {
                SystemCommand.handle(input);
            } break;

            case LOOK: {
                LookCommand.handle(input);
            } break;

            case WALK: {
                WalkCommand.handle(input);
            } break;

            case SPEAK: {
                SpeakCommand.handle(input);
            } break;

            default: {
                String message = "Could not determine what the command was. \"" + input + "\" " + type;
                throw new Error(message);
            }
        }
    }

}
