mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-12 16:59:11 +07:00
Discourage spreading religion to civs we've promised to not do so
This commit is contained in:
@ -2,6 +2,7 @@ package com.unciv.logic.automation.unit
|
|||||||
|
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
import com.unciv.logic.city.City
|
import com.unciv.logic.city.City
|
||||||
|
import com.unciv.logic.civilization.diplomacy.DiplomacyFlags
|
||||||
import com.unciv.logic.map.mapunit.MapUnit
|
import com.unciv.logic.map.mapunit.MapUnit
|
||||||
import com.unciv.models.UnitActionType
|
import com.unciv.models.UnitActionType
|
||||||
import com.unciv.models.ruleset.unique.UniqueType
|
import com.unciv.models.ruleset.unique.UniqueType
|
||||||
@ -17,6 +18,18 @@ object ReligiousUnitAutomation {
|
|||||||
it.religion.getMajorityReligion() != unit.civ.religionManager.religion
|
it.religion.getMajorityReligion() != unit.civ.religionManager.religion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Lowest value will be chosen */
|
||||||
|
fun rankCityForReligionSpread(city: City): Int {
|
||||||
|
var rank = city.getCenterTile().aerialDistanceTo(unit.getTile())
|
||||||
|
|
||||||
|
val diplomacyManager = unit.civ.getDiplomacyManager(city.civ)
|
||||||
|
if (diplomacyManager?.hasFlag(DiplomacyFlags.AgreedToNotSpreadReligion) == true){
|
||||||
|
rank += 10 // Greatly discourage, but if the other options are too far away we'll take it anyway
|
||||||
|
}
|
||||||
|
|
||||||
|
return rank
|
||||||
|
}
|
||||||
|
|
||||||
val city =
|
val city =
|
||||||
if (ourCitiesWithoutReligion.any())
|
if (ourCitiesWithoutReligion.any())
|
||||||
ourCitiesWithoutReligion.minByOrNull { it.getCenterTile().aerialDistanceTo(unit.getTile()) }
|
ourCitiesWithoutReligion.minByOrNull { it.getCenterTile().aerialDistanceTo(unit.getTile()) }
|
||||||
@ -24,7 +37,7 @@ object ReligiousUnitAutomation {
|
|||||||
.filter { it.religion.getMajorityReligion() != unit.civ.religionManager.religion }
|
.filter { it.religion.getMajorityReligion() != unit.civ.religionManager.religion }
|
||||||
.filter { it.civ.knows(unit.civ) && !it.civ.isAtWarWith(unit.civ) }
|
.filter { it.civ.knows(unit.civ) && !it.civ.isAtWarWith(unit.civ) }
|
||||||
.filterNot { it.religion.isProtectedByInquisitor(unit.religion) }
|
.filterNot { it.religion.isProtectedByInquisitor(unit.religion) }
|
||||||
.minByOrNull { it.getCenterTile().aerialDistanceTo(unit.getTile()) }
|
.minByOrNull { rankCityForReligionSpread(it) }
|
||||||
|
|
||||||
if (city == null) return
|
if (city == null) return
|
||||||
val destination = city.getTiles()
|
val destination = city.getTiles()
|
||||||
|
Reference in New Issue
Block a user