/// <summary> /// Choose a province to be the new capital /// </summary> private void SelectNewCapital() { // there is no need to change the capital if (_provinces.ContainsKey(_data.capital)) { return; } // there is no province to make the capital if (_provinces.Count == 0) { _data.capital = 0; return; } List <Province> provinces = new List <Province>(_provinces.Values); // at this point we know that there is at lest one province Province bestMatch = provinces[0]; // chose the one with the highest income // NOTE: it's possible to take into account distance from enemies // and/or troops on the map as well for (int i = 1; i < provinces.Count; i++) { if (provinces[i].GetBaseIncome() > bestMatch.GetBaseIncome()) { bestMatch = provinces[i]; } } _data.capital = bestMatch.GetId(); return; }