/// <summary> /// Generate events that happen at the start of a turn /// </summary> private void GenerateStartOfTurnEvents() { _currentExpedition = new KeyValuePair <Unit, Province>(null, null); Faction currentFaction = GetCurrentFaction(); if (currentFaction.GetFavors() >= FAVORS_TO_START_AGE_OF_DIVINE && !currentFaction.HasReachedAgeOfDivine()) { currentFaction.RecordTheStartOfAgeOfDivine(); string message = "The age of divine has arrived!"; _currentEvents.Add(new GameEvent(message, 1)); // no more than one event per turn return; } // if turn is greater than the starting expeditions turn // and the faction has at least one hero // and the number of funded expeditions is less than max // then create a new dungeon exploration game event // in 90% of cases if (_data.turn > _data.startingExpeditionsTurn && Dice.RollDie(10) > 1 && currentFaction.GetExpeditionsNumber() < _data.expeditions[EXPEDITION_NUMBER - 1]) { List <KeyValuePair <Unit, Province> > heroes = GetCurrentFaction().GetHeroes(); if (heroes.Count > 0) { int random = Dice.RollDie(heroes.Count) - 1; ExpeditionEvent expedition = new ExpeditionEvent(heroes[random], EXPEDITION_COST); _currentEvents.Add(expedition); } } }
/// <summary> /// Resolve an event based on the option selected /// </summary> /// <param name="gameEvent">The game event to resolve</param> /// <param name="option">Option selected</param> public void ReactToAnEvent(GameEvent gameEvent, int option) { if (gameEvent is ExpeditionEvent && option == 0) { ExpeditionEvent trueEvent = (ExpeditionEvent)gameEvent; if (GetCurrentFaction().FundExpedition(trueEvent.GetCost())) { KeyValuePair <Unit, Province> details = trueEvent.GetExpeditionDetails(); Unit exploringHero = new Unit(details.Key); _currentExpedition = new KeyValuePair <Unit, Province>(exploringHero, details.Value); List <Unit> expeditionMembers = new List <Unit>(); expeditionMembers.Add(exploringHero); details.Value.RemoveUnits(expeditionMembers); } } _currentEvents.Remove(gameEvent); }