mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-15 02:09:21 +07:00
Newly Allied city states declare war on your enemies, even unmet ones (#5298)
* new allies dow, unmet civs meet first and then dow * no gifts for bad people
This commit is contained in:
@ -226,6 +226,17 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
||||
newAllyCiv.updateDetailedCivResources()
|
||||
for (unique in newAllyCiv.getMatchingUniques("Can spend Gold to annex or puppet a City-State that has been your ally for [] turns."))
|
||||
newAllyCiv.getDiplomacyManager(civInfo.civName).setFlag(DiplomacyFlags.MarriageCooldown, unique.params[0].toInt())
|
||||
|
||||
// Join the wars of our new ally - loop through all civs they are at war with
|
||||
for (newEnemy in civInfo.gameInfo.civilizations.filter { it.isAtWarWith(newAllyCiv) && it.isAlive() } ) {
|
||||
if (civInfo.knows(newEnemy) && !civInfo.isAtWarWith(newEnemy))
|
||||
civInfo.getDiplomacyManager(newEnemy).declareWar()
|
||||
else if (!civInfo.knows(newEnemy)) {
|
||||
// We have to meet first
|
||||
civInfo.makeCivilizationsMeet(newEnemy, warOnContact = true)
|
||||
civInfo.getDiplomacyManager(newEnemy).declareWar()
|
||||
}
|
||||
}
|
||||
}
|
||||
if (oldAllyName != null) {
|
||||
val oldAllyCiv = civInfo.gameInfo.getCivilization(oldAllyName)
|
||||
|
@ -450,12 +450,12 @@ class CivilizationInfo {
|
||||
return baseUnit
|
||||
}
|
||||
|
||||
fun makeCivilizationsMeet(otherCiv: CivilizationInfo) {
|
||||
meetCiv(otherCiv)
|
||||
otherCiv.meetCiv(this)
|
||||
fun makeCivilizationsMeet(otherCiv: CivilizationInfo, warOnContact: Boolean = false) {
|
||||
meetCiv(otherCiv, warOnContact)
|
||||
otherCiv.meetCiv(this, warOnContact)
|
||||
}
|
||||
|
||||
private fun meetCiv(otherCiv: CivilizationInfo) {
|
||||
private fun meetCiv(otherCiv: CivilizationInfo, warOnContact: Boolean = false) {
|
||||
diplomacy[otherCiv.civName] = DiplomacyManager(this, otherCiv.civName)
|
||||
.apply { diplomaticStatus = DiplomaticStatus.Peace }
|
||||
|
||||
@ -465,6 +465,7 @@ class CivilizationInfo {
|
||||
UncivGame.Current.settings.addCompletedTutorialTask("Meet another civilization")
|
||||
|
||||
if (!(isCityState() && otherCiv.isMajorCiv())) return
|
||||
if (warOnContact || otherCiv.isMinorCivAggressor()) return // No gift if they are bad people, or we are just about to be at war
|
||||
|
||||
val cityStateLocation = if (cities.isEmpty()) null else getCapital().location
|
||||
|
||||
|
@ -675,21 +675,32 @@ class DiplomacyManager() {
|
||||
}
|
||||
otherCivDiplomacy.removeFlag(DiplomacyFlags.ResearchAgreement)
|
||||
|
||||
// Go through our city state allies.
|
||||
if (!civInfo.isCityState()) {
|
||||
for (thirdCiv in civInfo.getKnownCivs()) {
|
||||
if (thirdCiv.isCityState() && thirdCiv.getAllyCiv() == civInfo.civName
|
||||
&& thirdCiv.knows(otherCiv)
|
||||
&& thirdCiv.getDiplomacyManager(otherCiv).canDeclareWar()) {
|
||||
thirdCiv.getDiplomacyManager(otherCiv).declareWar()
|
||||
if (thirdCiv.isCityState() && thirdCiv.getAllyCiv() == civInfo.civName) {
|
||||
if (thirdCiv.knows(otherCiv) && !thirdCiv.isAtWarWith(otherCiv))
|
||||
thirdCiv.getDiplomacyManager(otherCiv).declareWar()
|
||||
else if (!thirdCiv.knows(otherCiv)) {
|
||||
// Our city state ally has not met them yet, so they have to meet first
|
||||
thirdCiv.makeCivilizationsMeet(otherCiv, warOnContact = true)
|
||||
thirdCiv.getDiplomacyManager(otherCiv).declareWar()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Go through their city state allies.
|
||||
if (!otherCiv.isCityState()) {
|
||||
for (thirdCiv in otherCiv.getKnownCivs()) {
|
||||
if (thirdCiv.isCityState() && thirdCiv.getAllyCiv() == otherCiv.civName
|
||||
&& thirdCiv.knows(civInfo)
|
||||
&& thirdCiv.getDiplomacyManager(civInfo).canDeclareWar()) {
|
||||
thirdCiv.getDiplomacyManager(civInfo).declareWar()
|
||||
if (thirdCiv.isCityState() && thirdCiv.getAllyCiv() == otherCiv.civName) {
|
||||
if (thirdCiv.knows(civInfo) && !thirdCiv.isAtWarWith(civInfo))
|
||||
thirdCiv.getDiplomacyManager(civInfo).declareWar()
|
||||
else if (!thirdCiv.knows(civInfo)) {
|
||||
// Their city state ally has not met us yet, so we have to meet first
|
||||
thirdCiv.makeCivilizationsMeet(civInfo, warOnContact = true)
|
||||
thirdCiv.getDiplomacyManager(civInfo).declareWar()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user