Esempio n. 1
0
        internal void Init(string gameFilePath, string gameStateFilePath, IGameIO gameIO)
        {
            try
            {
                _gameWorld = JsonConvert.DeserializeObject <World>(File.ReadAllText(gameFilePath));
                if (string.IsNullOrEmpty(gameStateFilePath))
                {
                    _gameState = new GameState
                    {
                        CurrentRoom   = _gameWorld.Defaults[StateKeys.EntryRoom],
                        PastIntro     = false,
                        Inventory     = new HashSet <string>(),
                        UnlockedExits = new Dictionary <string, Dictionary <string, bool> >()
                    };
                }

                _actionMap = new Dictionary <string, Action>
                {
                    { ReservedWords.Go, ProcessGo },
                    { ReservedWords.Look, ProcessLook },
                    { ReservedWords.Search, ProcessSearch },
                    { ReservedWords.Help, ProcessHelp }
                };

                if (gameIO == null)
                {
                    _gameIO = new ConsoleGameIO();
                }
            }
            catch (Exception)
            {
                //TODO: LOG
            }
        }
Esempio n. 2
0
 private void Error(string error)
 {
     if (_gameIO == null)
     {
         _gameIO = new ConsoleGameIO();
     }
     _gameIO.Error(error);
 }
Esempio n. 3
0
 public GameController(ICodeCreator builder, ICodeComparer comparer, IGuessTranslator trans, IGameIO consoleIO)
 {
     _guessTranslate = trans;
     _codeComparer   = comparer;
     _builder        = builder;
     _consoleIO      = consoleIO;
     _guesses        = new List <List <int> >();
     _feedbacks      = new List <string>();
 }
Esempio n. 4
0
 public Game(IGameIO io, IRandom?random = null)
 {
     _io     = io;
     _random = random ?? new NetStandardRandom();
 }
Esempio n. 5
0
 public void Setup()
 {
     _cIO = new ConsoleIO();
 }
Esempio n. 6
0
 public Game(IBoard board, IBoardAnalyzer analyzer, IGameIO io)
 {
     this.board    = board;
     this.analyzer = analyzer;
     this.io       = io;
 }