Example #1
0
        public bool Action(GameAction action)
        {
            switch (action)
            {
            case GameAction.Forward:
                _previousWorld = _currentWorld;
                _currentWorld  = _worldHandler.GenerateWorld();
                break;

            case GameAction.Back:
                SwitchWorlds();
                break;

            case GameAction.Fight:
                HandleFight();
                break;

            case GameAction.Observe:
                break;

            case GameAction.Exit:
                _outputHandler.Exit();
                return(false);
            }
            _outputHandler.Observe(_currentWorld.Observe());

            return(true);
        }
Example #2
0
        public GameRunner(IOutputHandler outputHandler)
        {
            _outputHandler = outputHandler;

            _worldHandler = new WorldHandler(new Random());
            _character    = new Character(new Inventory());

            _currentWorld = _worldHandler.GenerateWorld();
        }
Example #3
0
        public void WhenANewWorldIsCreated_ANewRandomMonsterIsPlacedInside_WithARandomLevel(int animal, int level, string expectedMonster)
        {
            var countOfMonsterNames = Enum.GetNames(typeof(MonsterName)).Length;

            _mockedLevelGenerator.Next(countOfMonsterNames).Returns(animal);
            _mockedLevelGenerator.Next(1, 10).Returns(level);
            var generatedWorld = _worldHandler.GenerateWorld();

            var worldObservation = generatedWorld.Observe();

            worldObservation.ShouldBe($"A world where there is a level {level} {expectedMonster}");
        }