/// <summary> /// Mark the fact that the faction advanced to the Age of Divine /// Add divine unit types /// Upgrade relevant unit types /// </summary> public void RecordTheStartOfAgeOfDivine() { _data.reachedDivine = true; Province capital = GetCapital(); List <UnitType> newUnitTypes = _race.GetUnitTypesJoiningForAgeOfDivine(); for (int i = 0; i < newUnitTypes.Count; i++) { capital.AddUnit(new Unit(newUnitTypes[i], 1)); } UpgradeUnitTypes(_race.GetAgeOfDivineUnitTypeUpgrades()); }
/// <summary> /// Generate events that happen at the end of a turn /// </summary> private void GenerateEndOfTurnEvents() { if (_currentExpedition.Key != null && _currentExpedition.Value != null) { Province province = GetCurrentFaction().GetCapital(); if (province == null) { province = _currentExpedition.Value; } // return the exporing hero province.AddUnit(_currentExpedition.Key); int expeditionsFunded = GetCurrentFaction().GetExpeditionsNumber(); // index < 0 means mismatch, no cigar int index = -1; for (int i = 0; i < EXPEDITION_NUMBER; i++) { if (expeditionsFunded == _data.expeditions[i]) { index = i; break; } } // the expedition is a success // a new hero is joining the worthy cause if (index >= 0) { List <UnitType> candidates = GetCurrentFaction().GetMagicians(); for (int i = 0; i < _data.casters.Length; i++) { UnitType caster = _unitTypes[_data.casters[i]]; if (candidates.Contains(caster)) { if (index == 0) { Unit newHero = GetCurrentFaction().CreateUnit(caster); province.AddUnit(newHero); string message = newHero.GetUnitType().GetName() + " emerges in " + province.GetName() + "!"; _currentEvents.Add(new GameEvent(message, 1)); break; } else { index--; } } } if (!GetCurrentFaction().HasRediscoveredMagic()) { GetCurrentFaction().RecordMagicRediscovery(); } } else { string message = "This expedition was a waste of money, but the next one will surely be a great success!"; _currentEvents.Add(new GameEvent(message, 1)); } } }