mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -04:00
Solved crash where city states would try to gift great people without cities
This commit is contained in:
parent
692cbaa84a
commit
3afe7af431
@ -10,10 +10,6 @@ AI accepts research agreement offers
|
||||
|
||||
Buildings from era are applied before buildings from policies
|
||||
|
||||
Translations update
|
||||
|
||||
Updated Hungarian Translates - By JurDan775
|
||||
|
||||
By SomeTroglodyte:
|
||||
- Civilopedia phase 8 - Nations and Promotions
|
||||
- UnitActionType now knows keys, sounds and most icons
|
||||
|
@ -608,11 +608,14 @@ class CivilizationInfo {
|
||||
for (flag in flagsCountdown.keys.toList()) {
|
||||
|
||||
if (flag == CivFlags.cityStateGreatPersonGift.name) {
|
||||
val cityStateAllies = getKnownCivs().filter { it.isCityState() && it.getAllyCiv() == civName }.count()
|
||||
val cityStateAllies =
|
||||
getKnownCivs().filter { it.isCityState() && it.getAllyCiv() == civName }
|
||||
|
||||
if (cityStateAllies >= 1) flagsCountdown[flag] = flagsCountdown[flag]!! - 1
|
||||
if (cityStateAllies.any()) flagsCountdown[flag] = flagsCountdown[flag]!! - 1
|
||||
|
||||
if (flagsCountdown[flag]!! < min(cityStateAllies, 10)) {
|
||||
if (flagsCountdown[flag]!! < min(cityStateAllies.count(), 10) && cities.isNotEmpty()
|
||||
&& cityStateAllies.any { it.cities.isNotEmpty() }
|
||||
) {
|
||||
gainGreatPersonFromCityState()
|
||||
flagsCountdown[flag] = turnsForGreatPersonFromCityState()
|
||||
}
|
||||
@ -779,7 +782,7 @@ class CivilizationInfo {
|
||||
|
||||
/** Gain a random great person from a random city state */
|
||||
private fun gainGreatPersonFromCityState() {
|
||||
val givingCityState = getKnownCivs().filter { it.isCityState() && it.getAllyCiv() == civName}.random()
|
||||
val givingCityState = getKnownCivs().filter { it.isCityState() && it.getAllyCiv() == civName && it.cities.isNotEmpty()}.random()
|
||||
var giftableUnits = gameInfo.ruleSet.units.values.filter { it.isGreatPerson() }
|
||||
if (!gameInfo.hasReligionEnabled()) giftableUnits = giftableUnits.filterNot { it.uniques.contains("Great Person - [Faith]")}
|
||||
if (giftableUnits.isEmpty()) // For badly defined mods that don't have great people but do have the policy that makes city states grant them
|
||||
|
Loading…
x
Reference in New Issue
Block a user