public GameController(IGameEngine gameEngine, IInputHandler inputReader, IRenderer renderer) { this.gameEngine = gameEngine; this.inputReader = inputReader; this.renderer = renderer; this.currentCmd = null; }
/// <summary> /// Executes a given command /// </summary> /// <param name="userInput">Input command from the user</param> /// <returns>Executes the corresponding command</returns> public virtual string ExecuteCommand(string userInput) { switch (userInput) { case "restart": this.currentCmd = new RestartCommand(this.gameEngine); break; case "exit": this.currentCmd = new ExitCommand(this.gameEngine); break; case "top": this.currentCmd = new TopCommand(this.gameEngine); break; default: this.currentCmd = new MoveCellCommand(this.gameEngine, userInput); break; } return this.currentCmd.Execute(); }