mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 05:14:32 -04:00
Resolved error where missionary cost was determined by Capital, and not by cities it could actually be constructed in
This commit is contained in:
parent
6054b32f92
commit
e510bf4929
@ -4,7 +4,7 @@ object BuildConfig {
|
||||
const val kotlinVersion = "1.7.0"
|
||||
const val appName = "Unciv"
|
||||
const val appCodeNumber = 743
|
||||
const val appVersion = "4.1.22"
|
||||
const val appVersion = "4.2.0"
|
||||
|
||||
const val gdxVersion = "1.11.0"
|
||||
const val roboVMVersion = "2.3.1"
|
||||
|
@ -105,12 +105,15 @@ object ReligionAutomation {
|
||||
if (civInfo.religionManager.religionState < ReligionState.Religion) return
|
||||
var missionaries = civInfo.gameInfo.ruleSet.units.values.filter { unit ->
|
||||
unit.getMatchingUniques(UniqueType.CanActionSeveralTimes).filter { it.params[0] == Constants.spreadReligion }.any()
|
||||
}.map { it.name }
|
||||
missionaries = missionaries.map { civInfo.getEquivalentUnit(it).name }
|
||||
}
|
||||
missionaries = missionaries.map { civInfo.getEquivalentUnit(it) }
|
||||
|
||||
val missionaryConstruction = missionaries
|
||||
.map { civInfo.cities.first().cityConstructions.getConstruction(it) as INonPerpetualConstruction }
|
||||
.filter { unit -> civInfo.cities.any { unit.isPurchasable(it.cityConstructions) && unit.canBePurchasedWithStat(it, Stat.Faith) } }
|
||||
.minByOrNull { it.getStatBuyCost(civInfo.getCapital()!!, Stat.Faith)!! }
|
||||
// Get list of cities it can be built in
|
||||
.associateBy({unit -> unit}) { unit -> civInfo.cities.filter { unit.isPurchasable(it.cityConstructions) && unit.canBePurchasedWithStat(it, Stat.Faith) } }
|
||||
.filter { it.value.isNotEmpty() }
|
||||
// And from that list determine the cheapest price
|
||||
.minByOrNull { it.value.minOf { city -> it.key.getStatBuyCost(city, Stat.Faith)!! }}?.key
|
||||
?: return
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user