if(MIDAS == undefined) { var MIDAS = {}; } MIDAS.GameDecider = function(gameConsole, inputParser, gameState) { var self = this; this.decide = function(message) { var gameCommands = gameState.getCommandList(); var gameDescriptions = gameState.getCommandDescriptions(); var commandObject = inputParser.parse(message, gameCommands); console.log(commandObject); if(commandObject.error) { if (commandObject.errorMessage == "help") { gameConsole.output("The commands available to you are:"); gameConsole.output("----------------------------------"); gameConsole.output("help - Lists all possible commands"); for(var i = 0; i < gameCommands.length; i++) { gameConsole.output(gameCommands[i] + " - " + gameDescriptions[i]); } gameConsole.output("----------------------------------"); } else { gameConsole.output("I don't understand \"" + commandObject.errorMessage + "\"."); } } else { gameState.handleCommandInput(commandObject); } }; };