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); }
public GameRunner(IOutputHandler outputHandler) { _outputHandler = outputHandler; _worldHandler = new WorldHandler(new Random()); _character = new Character(new Inventory()); _currentWorld = _worldHandler.GenerateWorld(); }
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}"); }