Add border conflict counter for periodly popup.

This commit is contained in:
Duan Tao 2019-05-08 18:14:50 +08:00 committed by Yair Morgenstern
parent 06f25b5b5b
commit ff508f22b0
2 changed files with 19 additions and 4 deletions

View File

@ -246,14 +246,29 @@ class NextTurnAutomation{
// Check if city-state invaded by other civs
if (civInfo.isCityState()) {
for (civ in civInfo.gameInfo.civilizations) {
if (civ == civInfo || civ.isBarbarianCivilization()) continue
var needClearCounter = false
if (civ == civInfo || civ.isBarbarianCivilization() || !civInfo.getKnownCivs().contains(civ)) continue
val diplomacy = civInfo.getDiplomacyManager(civ)!!
if (diplomacy.diplomaticStatus == DiplomaticStatus.War) continue
if (diplomacy.diplomaticStatus == DiplomaticStatus.War) {
needClearCounter = true
}
val unitsInBorder = civ.getCivUnits().count { !it.type.isCivilian() && it.getTile().getOwner() == civInfo }
if (unitsInBorder > 0 && diplomacy.influence < 30f) {
diplomacy.influence -= 10f
civ.popupAlerts.add(PopupAlert(AlertType.BorderConflict,civInfo.civName))
if (!diplomacy.flagsCountdown.containsKey("BorderConflict")
|| diplomacy.flagsCountdown["BorderConflict"]!! <= 0) {
civ.popupAlerts.add(PopupAlert(AlertType.BorderConflict,civInfo.civName))
diplomacy.flagsCountdown["BorderConflict"] = 10
} else {
diplomacy.flagsCountdown["BorderConflict"]!!.minus(1)
}
} else {
needClearCounter = true
}
if (needClearCounter && diplomacy.flagsCountdown.containsKey("BorderConflict")) {
diplomacy.flagsCountdown.remove("BorderConflict")
}
}
}

View File

@ -403,7 +403,7 @@ class MapUnit {
currentMovement = getMaxMovement().toFloat()
attacksThisTurn=0
val tileOwner = getTile().getOwner()
if(tileOwner!=null && !civInfo.canEnterTiles(tileOwner)) // if an enemy city expanded onto this tile while I was in it
if(tileOwner!=null && !civInfo.canEnterTiles(tileOwner) && !tileOwner.isCityState()) // if an enemy city expanded onto this tile while I was in it
movementAlgs().teleportToClosestMoveableTile()
doPreTurnAction()
}