Invading city-state border will damage relationship.
This commit is contained in:
parent
30531316d2
commit
ad54fb3c56
4 changed files with 43 additions and 7 deletions
|
@ -1,14 +1,12 @@
|
|||
package com.unciv.logic.automation
|
||||
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.PlayerType
|
||||
import com.unciv.logic.civilization.TradeRequest
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomacyFlags
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||
import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.logic.trade.*
|
||||
import com.unciv.Constants
|
||||
import com.unciv.logic.civilization.*
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tech.Technology
|
||||
import com.unciv.models.gamebasics.tr
|
||||
|
@ -24,6 +22,7 @@ class NextTurnAutomation{
|
|||
|
||||
chooseTechToResearch(civInfo)
|
||||
adoptPolicy(civInfo)
|
||||
updateDiplomaticRelationship(civInfo)
|
||||
declareWar(civInfo)
|
||||
automateCityBombardment(civInfo)
|
||||
buyBuildingOrUnit(civInfo)
|
||||
|
@ -243,6 +242,36 @@ class NextTurnAutomation{
|
|||
}
|
||||
}
|
||||
|
||||
private fun updateDiplomaticRelationship(civInfo: CivilizationInfo) {
|
||||
// Check if city-state invaded by other civs
|
||||
if (civInfo.isCityState()) {
|
||||
var militaryUnitsInBorder = HashMap<String, Int>()
|
||||
for (city in civInfo.cities) {
|
||||
for (tile in city.getTiles()) {
|
||||
val troop = tile.militaryUnit
|
||||
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 otherCiv = civInfo.gameInfo.getCivilization(otherCivName)
|
||||
if (!otherCiv.isBarbarianCivilization()) {
|
||||
val diplo = civInfo.getDiplomacyManager(otherCiv)
|
||||
if (diplo.diplomaticStatus != DiplomaticStatus.War) {
|
||||
diplo.influence -= 10f
|
||||
otherCiv.popupAlerts.add(PopupAlert(AlertType.BorderConflict,civInfo.civName))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun declareWar(civInfo: CivilizationInfo) {
|
||||
if (civInfo.isCityState()) return
|
||||
if (civInfo.cities.isNotEmpty() && civInfo.diplomacy.isNotEmpty()) {
|
||||
|
|
|
@ -4,7 +4,8 @@ enum class AlertType{
|
|||
WarDeclaration,
|
||||
Defeated,
|
||||
FirstContact,
|
||||
CityConquered
|
||||
CityConquered,
|
||||
BorderConflict
|
||||
}
|
||||
|
||||
class PopupAlert {
|
||||
|
|
|
@ -240,9 +240,6 @@ class DiplomacyManager() {
|
|||
thirdCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.WarMongerer,5f)
|
||||
else thirdCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.WarMongerer,-5f)
|
||||
}
|
||||
|
||||
//Damage diplomatic relationship
|
||||
otherCivDiplomacy.influence = -50f
|
||||
}
|
||||
|
||||
fun makePeace(){
|
||||
|
|
|
@ -63,6 +63,15 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
|||
close()
|
||||
})
|
||||
}
|
||||
AlertType.BorderConflict -> {
|
||||
val translatedNation = worldScreen.gameInfo.getCivilization(popupAlert.value).getTranslatedNation()
|
||||
addLeaderName(translatedNation)
|
||||
addGoodSizedLabel("Remove your troops in our border immediately!").row()
|
||||
val responseTable = Table()
|
||||
responseTable.add(getCloseButton("Sorry."))
|
||||
responseTable.add(getCloseButton("Never!"))
|
||||
add(responseTable)
|
||||
}
|
||||
}
|
||||
open()
|
||||
isOpen = true
|
||||
|
|
Loading…
Reference in a new issue