mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 22:37:02 -04:00
Code improvement for city state border conflict.
This commit is contained in:
parent
ad54fb3c56
commit
cb867f0066
@ -245,28 +245,15 @@ class NextTurnAutomation{
|
|||||||
private fun updateDiplomaticRelationship(civInfo: CivilizationInfo) {
|
private fun updateDiplomaticRelationship(civInfo: CivilizationInfo) {
|
||||||
// Check if city-state invaded by other civs
|
// Check if city-state invaded by other civs
|
||||||
if (civInfo.isCityState()) {
|
if (civInfo.isCityState()) {
|
||||||
var militaryUnitsInBorder = HashMap<String, Int>()
|
for (civ in civInfo.gameInfo.civilizations) {
|
||||||
for (city in civInfo.cities) {
|
if (civ == civInfo || civ.isBarbarianCivilization()) continue
|
||||||
for (tile in city.getTiles()) {
|
val diplomacy = civInfo.getDiplomacyManager(civ)!!
|
||||||
val troop = tile.militaryUnit
|
if (diplomacy.diplomaticStatus == DiplomaticStatus.War) continue
|
||||||
if (troop != null && troop.owner != civInfo.civName) {
|
|
||||||
if (militaryUnitsInBorder.containsKey(troop.owner)) {
|
|
||||||
militaryUnitsInBorder[troop.owner] = militaryUnitsInBorder[troop.owner]!! + 1
|
|
||||||
} else {
|
|
||||||
militaryUnitsInBorder[troop.owner] = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (otherCivName in militaryUnitsInBorder.filter { it.value > 0 }.keys) {
|
val unitsInBorder = civ.getCivUnits().count { !it.type.isCivilian() && it.getTile().getOwner() == civInfo }
|
||||||
val otherCiv = civInfo.gameInfo.getCivilization(otherCivName)
|
if (unitsInBorder > 0 && diplomacy.influence < 30f) {
|
||||||
if (!otherCiv.isBarbarianCivilization()) {
|
diplomacy.influence -= 10f
|
||||||
val diplo = civInfo.getDiplomacyManager(otherCiv)
|
civ.popupAlerts.add(PopupAlert(AlertType.BorderConflict,civInfo.civName))
|
||||||
if (diplo.diplomaticStatus != DiplomaticStatus.War) {
|
|
||||||
diplo.influence -= 10f
|
|
||||||
otherCiv.popupAlerts.add(PopupAlert(AlertType.BorderConflict,civInfo.civName))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user