private void Initialize(InitializeGameCommand command) { _gameState = command.GameData; foreach (var region in command.Regions) { _regions[region.Name] = region; } _clock = new Stopwatch(); _clock.Start(); }
/// <summary> /// Creates a command according to the user input /// </summary> /// <param name="command">Command to be created</param> /// <returns>The created command</returns> public ICommand GetCommand(string command) { if (!this.CommandsList.ContainsKey(command)) { ICommand commandExecutor = null; switch (command) { case "help": { commandExecutor = new CheatCommand(this.Data, this.Notifier, this.NumberGenerator); break; } case "start": { commandExecutor = new InitializeGameCommand(this.Data, this.Notifier, this.NumberGenerator); break; } case "commands": { commandExecutor = new DisplayCommandsListCommand(this.Notifier); break; } case "top": { commandExecutor = new DisplayScoreboardCommand(this.Scoreboard); break; } case "quit": { commandExecutor = new QuitGameCommand(this.Notifier); break; } case "exit": { commandExecutor = new ExitGameCommand(this.Notifier); break; } case "empty": { commandExecutor = new EmptyCommand(); break; } default: { commandExecutor = this.ProcessGuessAndReturnAppropriateCommand(command); break; } } this.CommandsList.Add(command, commandExecutor); return commandExecutor; } else { return this.CommandsList[command]; } }