private void PerformNextTurnCycle() { _turnTimer.Stop(); // Check to make sure there is a living hero left. If not, stop the timer, and end the game. // This has to be above all of the turn loops to make sure that the "Hero is dead" action comes up for each one. if (!_quest.AreAnyHeroesAlive) { if (HeroesLose != null) { HeroesLose(this, new EventArgs()); } } else { TurnStepAction action = _currentTurnTaker.DoTakeTurnStep(_questAnalyzer, _chanceProvider); if (action == null) // The current player has no more steps to take { _currentTurnTakerIndex++; if (_currentTurnTakerIndex > _turnTakers.Count - 1) { _currentTurnTakerIndex = 0; } _currentTurnTaker = _turnTakers[_currentTurnTakerIndex]; _currentTurnTaker.StartTurn(); PerformNextTurnCycle(); } else { action.Complete += OnCurrentActionCommitComplete; action.Commit(_quest, _storyTeller); } RenderQuestBoard(); } }
private void BeginTurnCycle() { _storyTeller.StoryComplete -= OnQuestIntroductionStoryComplete; _turnTakers.Clear(); foreach (Hero hero in _quest.Heroes) { _turnTakers.Add(hero); } foreach (Monster monster in _quest.Monsters) { _turnTakers.Add(monster); } // Make the first person in the list the current player _currentTurnTakerIndex = 0; _currentTurnTaker = _turnTakers[_currentTurnTakerIndex]; _currentTurnTaker.StartTurn(); _questAnalyzer = new QuestAnalyzer(_quest); PerformNextTurnCycle(); // Immediately take one turn }