TechDebt: Made getDiplomacyManger() nullable (#11771)

* Made getDiplomacyManager nullable and added getDiplomacyMangerOrMeet

* Fixed AI Automation having problems when playing as a oneCityChallenger civ
This commit is contained in:
Oskar Niesen 2024-06-16 15:40:45 -05:00 committed by GitHub
parent c5d3bfca9d
commit bbea08364b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
48 changed files with 300 additions and 305 deletions

View File

@ -19,13 +19,14 @@ object DeclareWarPlanEvaluator {
* @return The movtivation of the plan. If it is > 0 then we can declare the war.
*/
fun evaluateTeamWarPlan(civInfo: Civilization, target: Civilization, teamCiv: Civilization, givenMotivation: Int?): Int {
val teamCivDiplo = civInfo.getDiplomacyManager(teamCiv)!!
if (civInfo.getPersonality()[PersonalityValue.DeclareWar] == 0f) return -1000
if (civInfo.getDiplomacyManager(teamCiv).isRelationshipLevelLT(RelationshipLevel.Neutral)) return -1000
if (teamCivDiplo.isRelationshipLevelLT(RelationshipLevel.Neutral)) return -1000
var motivation = givenMotivation
?: MotivationToAttackAutomation.hasAtLeastMotivationToAttack(civInfo, target, 0)
if (civInfo.getDiplomacyManager(teamCiv).isRelationshipLevelEQ(RelationshipLevel.Neutral)) motivation -= 5
if (teamCivDiplo.isRelationshipLevelEQ(RelationshipLevel.Neutral)) motivation -= 5
// Make sure that they can actually help us with the target
if (!teamCiv.threatManager.getNeighboringCivilizations().contains(target)) {
motivation -= 40
@ -70,13 +71,13 @@ object DeclareWarPlanEvaluator {
* @return The movtivation of the plan. If it is > 0 then we can declare the war.
*/
fun evaluateJoinWarPlan(civInfo: Civilization, target: Civilization, civToJoin: Civilization, givenMotivation: Int?): Int {
val thirdCivDiplo = civInfo.getDiplomacyManager(civToJoin)!!
if (civInfo.getPersonality()[PersonalityValue.DeclareWar] == 0f) return -1000
if (civInfo.getDiplomacyManager(civToJoin).isRelationshipLevelLE(RelationshipLevel.Favorable)) return -1000
if (thirdCivDiplo.isRelationshipLevelLE(RelationshipLevel.Favorable)) return -1000
var motivation = givenMotivation
?: MotivationToAttackAutomation.hasAtLeastMotivationToAttack(civInfo, target, 0)
// We need to be able to trust the thirdCiv at least somewhat
val thirdCivDiplo = civInfo.getDiplomacyManager(civToJoin)
if (thirdCivDiplo.diplomaticStatus != DiplomaticStatus.DefensivePact &&
thirdCivDiplo.opinionOfOtherCiv() + motivation * 2 < 80) {
motivation -= 80 - (thirdCivDiplo.opinionOfOtherCiv() + motivation * 2).toInt()
@ -116,7 +117,7 @@ object DeclareWarPlanEvaluator {
* @return The movtivation of the plan. If it is > 0 then we can declare the war.
*/
fun evaluateJoinOurWarPlan(civInfo: Civilization, target: Civilization, civToJoin: Civilization, givenMotivation: Int?): Int {
if (civInfo.getDiplomacyManager(civToJoin).isRelationshipLevelLT(RelationshipLevel.Favorable)) return -1000
if (civInfo.getDiplomacyManager(civToJoin)!!.isRelationshipLevelLT(RelationshipLevel.Favorable)) return -1000
var motivation = givenMotivation ?: 0
if (!civToJoin.threatManager.getNeighboringCivilizations().contains(target)) {
motivation -= 50
@ -146,7 +147,7 @@ object DeclareWarPlanEvaluator {
val motivation = givenMotivation
?: MotivationToAttackAutomation.hasAtLeastMotivationToAttack(civInfo, target, 0)
val diploManager = civInfo.getDiplomacyManager(target)
val diploManager = civInfo.getDiplomacyManager(target)!!
if (diploManager.hasFlag(DiplomacyFlags.WaryOf) && diploManager.getFlag(DiplomacyFlags.WaryOf) < 0) {
val turnsToPlan = (10 - (motivation / 10)).coerceAtLeast(3)
@ -168,7 +169,7 @@ object DeclareWarPlanEvaluator {
// TODO: We use negative values in WaryOf for now so that we aren't adding any extra fields to the save file
// This will very likely change in the future and we will want to build upon it
val diploManager = civInfo.getDiplomacyManager(target)
val diploManager = civInfo.getDiplomacyManager(target)!!
if (diploManager.hasFlag(DiplomacyFlags.WaryOf)) return 0
return motivation - 15

View File

@ -47,11 +47,11 @@ object DeclareWarTargetAutomation {
* Together we are stronger and are more likely to take down bigger threats.
*/
private fun tryTeamWar(civInfo: Civilization, target: Civilization, motivation: Int): Boolean {
val potentialAllies = civInfo.getDiplomacyManager(target).getCommonKnownCivs()
val potentialAllies = civInfo.getDiplomacyManager(target)!!.getCommonKnownCivs()
.filter {
it.isMajorCiv()
&& !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedJoinWarOffer)
&& civInfo.getDiplomacyManager(it).isRelationshipLevelGE(RelationshipLevel.Neutral)
&& !civInfo.getDiplomacyManager(it)!!.hasFlag(DiplomacyFlags.DeclinedJoinWarOffer)
&& civInfo.getDiplomacyManager(it)!!.isRelationshipLevelGE(RelationshipLevel.Neutral)
&& !it.isAtWarWith(target)
}.sortedByDescending { it.getStatForRanking(RankingType.Force) }
@ -75,11 +75,11 @@ object DeclareWarTargetAutomation {
* The next safest aproach is to join an existing war on the side of an ally that is already at war with [target].
*/
private fun tryJoinWar(civInfo: Civilization, target: Civilization, motivation: Int): Boolean {
val potentialAllies = civInfo.getDiplomacyManager(target).getCommonKnownCivs()
val potentialAllies = civInfo.getDiplomacyManager(target)!!.getCommonKnownCivs()
.filter {
it.isMajorCiv()
&& !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedJoinWarOffer)
&& civInfo.getDiplomacyManager(it).isRelationshipLevelGE(RelationshipLevel.Favorable)
&& !civInfo.getDiplomacyManager(it)!!.hasFlag(DiplomacyFlags.DeclinedJoinWarOffer)
&& civInfo.getDiplomacyManager(it)!!.isRelationshipLevelGE(RelationshipLevel.Favorable)
&& it.isAtWarWith(target)
} // Must be a civ not already at war with them
.sortedByDescending { it.getStatForRanking(RankingType.Force) }
@ -104,7 +104,7 @@ object DeclareWarTargetAutomation {
*/
private fun declareWar(civInfo: Civilization, target: Civilization, motivation: Int): Boolean {
if (DeclareWarPlanEvaluator.evaluateDeclareWarPlan(civInfo, target, motivation) > 0) {
civInfo.getDiplomacyManager(target).declareWar()
civInfo.getDiplomacyManager(target)!!.declareWar()
return true
}
return false
@ -116,7 +116,7 @@ object DeclareWarTargetAutomation {
private fun prepareWar(civInfo: Civilization, target: Civilization, motivation: Int): Boolean {
// TODO: We use negative values in WaryOf for now so that we aren't adding any extra fields to the save file
// This will very likely change in the future and we will want to build upon it
val diploManager = civInfo.getDiplomacyManager(target)
val diploManager = civInfo.getDiplomacyManager(target)!!
if (DeclareWarPlanEvaluator.evaluateStartPreparingWarPlan(civInfo, target, motivation) > 0) {
diploManager.setFlag(DiplomacyFlags.WaryOf, -1)
return true

View File

@ -28,9 +28,9 @@ object DiplomacyAutomation {
val civsThatWeCanDeclareFriendshipWith = civInfo.getKnownCivs()
.filter {
civInfo.diplomacyFunctions.canSignDeclarationOfFriendshipWith(it)
&& !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedDeclarationOfFriendship)
&& !civInfo.getDiplomacyManager(it)!!.hasFlag(DiplomacyFlags.DeclinedDeclarationOfFriendship)
}
.sortedByDescending { it.getDiplomacyManager(civInfo).relationshipLevel() }.toList()
.sortedByDescending { it.getDiplomacyManager(civInfo)!!.relationshipLevel() }.toList()
for (otherCiv in civsThatWeCanDeclareFriendshipWith) {
// Default setting is 2, this will be changed according to different civ.
if ((1..10).random() <= 2 && wantsToSignDeclarationOfFrienship(civInfo, otherCiv)) {
@ -40,7 +40,7 @@ object DiplomacyAutomation {
}
internal fun wantsToSignDeclarationOfFrienship(civInfo: Civilization, otherCiv: Civilization): Boolean {
val diploManager = civInfo.getDiplomacyManager(otherCiv)
val diploManager = civInfo.getDiplomacyManager(otherCiv)!!
if (diploManager.hasFlag(DiplomacyFlags.DeclinedDeclarationOfFriendship)) return false
// Shortcut, if it is below favorable then don't consider it
if (diploManager.isRelationshipLevelLT(RelationshipLevel.Favorable)) return false
@ -93,7 +93,7 @@ object DiplomacyAutomation {
// If they are the only non-friendly civ near us then they are the only civ to attack and expand into
if (civInfo.threatManager.getNeighboringCivilizations().none {
it.isMajorCiv() && it != otherCiv
&& civInfo.getDiplomacyManager(it).isRelationshipLevelLT(RelationshipLevel.Favorable)
&& civInfo.getDiplomacyManager(it)!!.isRelationshipLevelLT(RelationshipLevel.Favorable)
})
motivation -= 20
@ -108,10 +108,10 @@ object DiplomacyAutomation {
.filter {
it.isMajorCiv() && !civInfo.isAtWarWith(it)
&& it.hasUnique(UniqueType.EnablesOpenBorders)
&& !civInfo.getDiplomacyManager(it).hasOpenBorders
&& !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedOpenBorders)
&& !civInfo.getDiplomacyManager(it)!!.hasOpenBorders
&& !civInfo.getDiplomacyManager(it)!!.hasFlag(DiplomacyFlags.DeclinedOpenBorders)
&& !isTradeBeingOffered(civInfo, it, Constants.openBorders)
}.sortedByDescending { it.getDiplomacyManager(civInfo).relationshipLevel() }.toList()
}.sortedByDescending { it.getDiplomacyManager(civInfo)!!.relationshipLevel() }.toList()
for (otherCiv in civsThatWeCanOpenBordersWith) {
// Default setting is 3, this will be changed according to different civ.
@ -124,13 +124,13 @@ object DiplomacyAutomation {
otherCiv.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
} else {
// Remember this for a few turns to save computation power
civInfo.getDiplomacyManager(otherCiv).setFlag(DiplomacyFlags.DeclinedOpenBorders, 5)
civInfo.getDiplomacyManager(otherCiv)!!.setFlag(DiplomacyFlags.DeclinedOpenBorders, 5)
}
}
}
fun wantsToOpenBorders(civInfo: Civilization, otherCiv: Civilization): Boolean {
val diploManager = civInfo.getDiplomacyManager(otherCiv)
val diploManager = civInfo.getDiplomacyManager(otherCiv)!!
if (diploManager.hasFlag(DiplomacyFlags.DeclinedOpenBorders)) return false
if (diploManager.isRelationshipLevelLT(RelationshipLevel.Favorable)) return false
// Don't accept if they are at war with our friends, they might use our land to attack them
@ -150,7 +150,7 @@ object DiplomacyAutomation {
val canSignResearchAgreementCiv = civInfo.getKnownCivs()
.filter {
civInfo.diplomacyFunctions.canSignResearchAgreementsWith(it)
&& !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedResearchAgreement)
&& !civInfo.getDiplomacyManager(it)!!.hasFlag(DiplomacyFlags.DeclinedResearchAgreement)
&& !isTradeBeingOffered(civInfo, it, Constants.researchAgreement)
}
.sortedByDescending { it.stats.statsForNextTurn.science }
@ -173,8 +173,8 @@ object DiplomacyAutomation {
val canSignDefensivePactCiv = civInfo.getKnownCivs()
.filter {
civInfo.diplomacyFunctions.canSignDefensivePactWith(it)
&& !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedDefensivePact)
&& civInfo.getDiplomacyManager(it).opinionOfOtherCiv() < 70f
&& !civInfo.getDiplomacyManager(it)!!.hasFlag(DiplomacyFlags.DeclinedDefensivePact)
&& civInfo.getDiplomacyManager(it)!!.opinionOfOtherCiv() < 70f
&& !isTradeBeingOffered(civInfo, it, Constants.defensivePact)
}
@ -190,33 +190,32 @@ object DiplomacyAutomation {
otherCiv.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
} else {
// Remember this for a few turns to save computation power
civInfo.getDiplomacyManager(otherCiv).setFlag(DiplomacyFlags.DeclinedDefensivePact, 5)
civInfo.getDiplomacyManager(otherCiv)!!.setFlag(DiplomacyFlags.DeclinedDefensivePact, 5)
}
}
}
fun wantsToSignDefensivePact(civInfo: Civilization, otherCiv: Civilization): Boolean {
val diploManager = civInfo.getDiplomacyManager(otherCiv)
val diploManager = civInfo.getDiplomacyManager(otherCiv)!!
if (diploManager.hasFlag(DiplomacyFlags.DeclinedDefensivePact)) return false
if (diploManager.opinionOfOtherCiv() < 60f) return false
val commonknownCivs = diploManager.getCommonKnownCivs()
// If they have bad relations with any of our friends, don't consider it
for (thirdCiv in commonknownCivs) {
if (civInfo.getDiplomacyManager(thirdCiv).hasFlag(DiplomacyFlags.DeclarationOfFriendship)
&& thirdCiv.getDiplomacyManager(otherCiv).isRelationshipLevelLT(RelationshipLevel.Favorable))
// If they have bad relations with any of our friends, don't consider it
if (civInfo.getDiplomacyManager(thirdCiv)!!.hasFlag(DiplomacyFlags.DeclarationOfFriendship)
&& thirdCiv.getDiplomacyManager(otherCiv)!!.isRelationshipLevelLT(RelationshipLevel.Favorable))
return false
}
// If they have bad relations with any of our friends, don't consider it
for (thirdCiv in commonknownCivs) {
if (otherCiv.getDiplomacyManager(thirdCiv).hasFlag(DiplomacyFlags.DeclarationOfFriendship)
&& thirdCiv.getDiplomacyManager(civInfo).isRelationshipLevelLT(RelationshipLevel.Neutral))
// If they have bad relations with any of our friends, don't consider it
if (otherCiv.getDiplomacyManager(thirdCiv)!!.hasFlag(DiplomacyFlags.DeclarationOfFriendship)
&& thirdCiv.getDiplomacyManager(civInfo)!!.isRelationshipLevelLT(RelationshipLevel.Neutral))
return false
}
val defensivePacts = civInfo.diplomacy.count { it.value.hasFlag(DiplomacyFlags.DefensivePact) }
val otherCivNonOverlappingDefensivePacts = otherCiv.diplomacy.values.count {
it.hasFlag(DiplomacyFlags.DefensivePact)
&& (!it.otherCiv().knows(civInfo) || !it.otherCiv().getDiplomacyManager(civInfo).hasFlag(DiplomacyFlags.DefensivePact))
&& it.otherCiv().getDiplomacyManager(civInfo)?.hasFlag(DiplomacyFlags.DefensivePact) != true
}
val allCivs = civInfo.gameInfo.civilizations.count { it.isMajorCiv() } - 1 // Don't include us
val deadCivs = civInfo.gameInfo.civilizations.count { it.isMajorCiv() && !it.isAlive() }
@ -263,7 +262,7 @@ object DiplomacyAutomation {
//evaluate war
val targetCivs = civInfo.getKnownCivs()
.filterNot {
it == civInfo || it.cities.isEmpty() || !civInfo.getDiplomacyManager(it).canDeclareWar()
it == civInfo || it.cities.isEmpty() || !civInfo.getDiplomacyManager(it)!!.canDeclareWar()
|| it.cities.none { city -> civInfo.hasExplored(city.getCenterTile()) }
}
// If the AI declares war on a civ without knowing the location of any cities,
@ -285,9 +284,9 @@ object DiplomacyAutomation {
.map { it.value.otherCiv() }
.filterNot {
it == civInfo || it.isBarbarian() || it.cities.isEmpty()
|| it.getDiplomacyManager(civInfo).hasFlag(DiplomacyFlags.DeclaredWar)
|| civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclaredWar)
}.filter { !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedPeace) }
|| it.getDiplomacyManager(civInfo)!!.hasFlag(DiplomacyFlags.DeclaredWar)
|| civInfo.getDiplomacyManager(it)!!.hasFlag(DiplomacyFlags.DeclaredWar)
}.filter { !civInfo.getDiplomacyManager(it)!!.hasFlag(DiplomacyFlags.DeclinedPeace) }
// Don't allow AIs to offer peace to city states allied with their enemies
.filterNot { it.isCityState() && it.getAllyCiv() != null && civInfo.isAtWarWith(civInfo.gameInfo.getCivilization(it.getAllyCiv()!!)) }
// ignore civs that we have already offered peace this turn as a counteroffer to another civ's peace offer
@ -341,8 +340,8 @@ object DiplomacyAutomation {
val potentialAllies = enemyCiv.threatManager.getNeighboringCivilizations()
.filter {
civInfo.knows(it) && !it.isAtWarWith(enemyCiv)
&& civInfo.getDiplomacyManager(it).isRelationshipLevelGE(RelationshipLevel.Friend)
&& !it.getDiplomacyManager(civInfo).hasFlag(DiplomacyFlags.DeclinedJoinWarOffer) }
&& civInfo.getDiplomacyManager(it)!!.isRelationshipLevelGE(RelationshipLevel.Friend)
&& !it.getDiplomacyManager(civInfo)!!.hasFlag(DiplomacyFlags.DeclinedJoinWarOffer) }
.sortedByDescending { it.getStatForRanking(RankingType.Force) }
val civToAsk = potentialAllies.firstOrNull {
DeclareWarPlanEvaluator.evaluateJoinOurWarPlan(civInfo, enemyCiv, it, null) > 0 } ?: continue

View File

@ -45,7 +45,7 @@ object MotivationToAttackAutomation {
modifiers.add(Pair("Their allies", getDefensivePactAlliesScore(targetCiv, civInfo, baseForce, ourCombatStrength)))
if (civInfo.threatManager.getNeighboringCivilizations().none { it != targetCiv && it.isMajorCiv()
&& civInfo.getDiplomacyManager(it).isRelationshipLevelLT(RelationshipLevel.Friend) })
&& civInfo.getDiplomacyManager(it)!!.isRelationshipLevelLT(RelationshipLevel.Friend) })
modifiers.add(Pair("No other threats", 10))
if (targetCiv.isMajorCiv()) {
@ -70,7 +70,7 @@ object MotivationToAttackAutomation {
}))
if (minTargetCityDistance < 6) modifiers.add(Pair("Close cities", 5))
val diplomacyManager = civInfo.getDiplomacyManager(targetCiv)
val diplomacyManager = civInfo.getDiplomacyManager(targetCiv)!!
if (diplomacyManager.hasFlag(DiplomacyFlags.ResearchAgreement))
modifiers.add(Pair("Research Agreement", -5))
@ -165,12 +165,12 @@ object MotivationToAttackAutomation {
/** If they are at war with our allies, then we should join in */
private fun getAlliedWarMotivation(civInfo: Civilization, otherCiv: Civilization): Int {
var alliedWarMotivation = 0
for (thirdCiv in civInfo.getDiplomacyManager(otherCiv).getCommonKnownCivs()) {
for (thirdCiv in civInfo.getDiplomacyManager(otherCiv)!!.getCommonKnownCivs()) {
val thirdCivDiploManager = civInfo.getDiplomacyManager(thirdCiv)
if (thirdCivDiploManager.isRelationshipLevelGE(RelationshipLevel.Friend)
if (thirdCivDiploManager!!.isRelationshipLevelGE(RelationshipLevel.Friend)
&& thirdCiv.isAtWarWith(otherCiv)
) {
if (thirdCiv.getDiplomacyManager(otherCiv).hasFlag(DiplomacyFlags.Denunciation))
if (thirdCiv.getDiplomacyManager(otherCiv)!!.hasFlag(DiplomacyFlags.Denunciation))
alliedWarMotivation += 2
alliedWarMotivation += if (thirdCivDiploManager.hasFlag(DiplomacyFlags.DefensivePact)) 15
else if (thirdCivDiploManager.isRelationshipLevelGT(RelationshipLevel.Friend)) 5

View File

@ -104,14 +104,14 @@ object NextTurnAutomation {
for (popupAlert in civInfo.popupAlerts.toList()) { // toList because this can trigger other things that give alerts, like Golden Age
if (popupAlert.type == AlertType.DemandToStopSettlingCitiesNear) { // we're called upon to make a decision
val demandingCiv = civInfo.gameInfo.getCivilization(popupAlert.value)
val diploManager = civInfo.getDiplomacyManager(demandingCiv)
val diploManager = civInfo.getDiplomacyManager(demandingCiv)!!
if (Automation.threatAssessment(civInfo, demandingCiv) >= ThreatLevel.High)
diploManager.agreeNotToSettleNear()
else diploManager.refuseDemandNotToSettleNear()
}
if (popupAlert.type == AlertType.DeclarationOfFriendship) {
val requestingCiv = civInfo.gameInfo.getCivilization(popupAlert.value)
val diploManager = civInfo.getDiplomacyManager(requestingCiv)
val diploManager = civInfo.getDiplomacyManager(requestingCiv)!!
if (civInfo.diplomacyFunctions.canSignDeclarationOfFriendshipWith(requestingCiv)
&& DiplomacyAutomation.wantsToSignDeclarationOfFrienship(civInfo,requestingCiv)) {
diploManager.signDeclarationOfFriendship()
@ -179,7 +179,7 @@ object NextTurnAutomation {
// The more we have invested into the city-state the more the alliance is worth
val ourInfluence = if (civInfo.knows(cityState))
cityState.getDiplomacyManager(civInfo).getInfluence().toInt()
cityState.getDiplomacyManager(civInfo)!!.getInfluence().toInt()
else 0
value += ourInfluence / 10
@ -190,7 +190,7 @@ object NextTurnAutomation {
if (cityState.getAllyCiv() != null && cityState.getAllyCiv() != civInfo.civName) {
// easier not to compete if a third civ has this locked down
val thirdCivInfluence = cityState.getDiplomacyManager(cityState.getAllyCiv()!!).getInfluence().toInt()
val thirdCivInfluence = cityState.getDiplomacyManager(cityState.getAllyCiv()!!)!!.getInfluence().toInt()
value -= (thirdCivInfluence - 30) / 10
}
@ -210,7 +210,7 @@ object NextTurnAutomation {
private fun protectCityStates(civInfo: Civilization) {
for (state in civInfo.getKnownCivs().filter { !it.isDefeated() && it.isCityState() }) {
val diplomacyManager = state.getDiplomacyManager(civInfo.civName)
val diplomacyManager = state.getDiplomacyManager(civInfo.civName)!!
val isAtLeastFriend = diplomacyManager.isRelationshipLevelGE(RelationshipLevel.Friend)
if (isAtLeastFriend && state.cityStateFunctions.otherCivCanPledgeProtection(civInfo)) {
state.cityStateFunctions.addProtectorCiv(civInfo)
@ -222,7 +222,7 @@ object NextTurnAutomation {
private fun bullyCityStates(civInfo: Civilization) {
for (state in civInfo.getKnownCivs().filter { !it.isDefeated() && it.isCityState() }.toList()) {
val diplomacyManager = state.getDiplomacyManager(civInfo.civName)
val diplomacyManager = state.getDiplomacyManager(civInfo.civName)!!
if (diplomacyManager.isRelationshipLevelLT(RelationshipLevel.Friend)
&& diplomacyManager.diplomaticStatus == DiplomaticStatus.Peace
&& valueCityStateAlliance(civInfo, state) <= 0
@ -460,6 +460,7 @@ object NextTurnAutomation {
private fun trainSettler(civInfo: Civilization) {
val personality = civInfo.getPersonality()
if (civInfo.isCityState()) return
if (civInfo.isOneCityChallenger()) return
if (civInfo.isAtWar()) return // don't train settlers when you could be training troops.
if (civInfo.wantsToFocusOn(Victory.Focus.Culture) && civInfo.cities.size > 3 &&
civInfo.getPersonality().isNeutralPersonality)
@ -509,14 +510,14 @@ object NextTurnAutomation {
val knownMajorCivs = civ.getKnownCivs().filter { it.isMajorCiv() }
val highestOpinion = knownMajorCivs
.maxOfOrNull {
civ.getDiplomacyManager(it).opinionOfOtherCiv()
civ.getDiplomacyManager(it)!!.opinionOfOtherCiv()
}
if (highestOpinion == null) null // Abstain if we know nobody
else if (highestOpinion < -80 || highestOpinion < -40 && highestOpinion + Random.Default.nextInt(40) < -40)
null // Abstain if we hate everybody (proportional chance in the RelationshipLevel.Enemy range - lesser evil)
else knownMajorCivs
.filter { civ.getDiplomacyManager(it).opinionOfOtherCiv() == highestOpinion }
.filter { civ.getDiplomacyManager(it)!!.opinionOfOtherCiv() == highestOpinion }
.toList().random().civName
} else {
@ -528,14 +529,14 @@ object NextTurnAutomation {
private fun issueRequests(civInfo: Civilization) {
for (otherCiv in civInfo.getKnownCivs().filter { it.isMajorCiv() && !civInfo.isAtWarWith(it) }) {
val diploManager = civInfo.getDiplomacyManager(otherCiv)
val diploManager = civInfo.getDiplomacyManager(otherCiv)!!
if (diploManager.hasFlag(DiplomacyFlags.SettledCitiesNearUs))
onCitySettledNearBorders(civInfo, otherCiv)
}
}
private fun onCitySettledNearBorders(civInfo: Civilization, otherCiv: Civilization) {
val diplomacyManager = civInfo.getDiplomacyManager(otherCiv)
val diplomacyManager = civInfo.getDiplomacyManager(otherCiv)!!
when {
diplomacyManager.hasFlag(DiplomacyFlags.IgnoreThemSettlingNearUs) -> {
}

View File

@ -178,10 +178,10 @@ object TradeAutomation {
for (otherCiv in knownCivs.filter {
it.isMajorCiv() && !it.isAtWarWith(civInfo)
&& !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedLuxExchange)
&& !civInfo.getDiplomacyManager(it)!!.hasFlag(DiplomacyFlags.DeclinedLuxExchange)
}) {
val isEnemy = civInfo.getDiplomacyManager(otherCiv).isRelationshipLevelLE(RelationshipLevel.Enemy)
val isEnemy = civInfo.getDiplomacyManager(otherCiv)!!.isRelationshipLevelLE(RelationshipLevel.Enemy)
if (isEnemy || otherCiv.tradeRequests.any { it.requestingCiv == civInfo.civName })
continue

View File

@ -51,7 +51,7 @@ object UseGoldAutomation {
if (civ.gold < 250) return // skip checks if tryGainInfluence will bail anyway
if (civ.wantsToFocusOn(Victory.Focus.Culture)) {
for (cityState in knownCityStates.filter { it.cityStateFunctions.canProvideStat(Stat.Culture) }) {
val diploManager = cityState.getDiplomacyManager(civ)
val diploManager = cityState.getDiplomacyManager(civ)!!
if (diploManager.getInfluence() < 40) { // we want to gain influence with them
tryGainInfluence(civ, cityState)
}
@ -165,7 +165,7 @@ object UseGoldAutomation {
private fun tryGainInfluence(civInfo: Civilization, cityState: Civilization) {
if (civInfo.gold < 250) return // Save up
if (cityState.getDiplomacyManager(civInfo).getInfluence() >= 20
if (cityState.getDiplomacyManager(civInfo)!!.getInfluence() >= 20
&& civInfo.gold < 500) {
// Only make a small investment if we have a bit of influence already to build off of so we don't waste our money
cityState.cityStateFunctions.receiveGoldGift(civInfo, 250)

View File

@ -66,7 +66,7 @@ object CityLocationTileRanker {
if (distance <= 6 && civ.knows(city.civ)
&& !civ.isAtWarWith(city.civ)
// If the CITY OWNER knows that the UNIT OWNER agreed not to settle near them
&& city.civ.getDiplomacyManager(civ)
&& city.civ.getDiplomacyManager(civ)!!
.hasFlag(DiplomacyFlags.AgreedToNotSettleNearUs))
return false
if (tile.getContinent() == city.getCenterTile().getContinent()) {

View File

@ -68,8 +68,8 @@ class EspionageAutomation(val civInfo: Civilization) {
* Moves the spy to a random city-state
*/
private fun automateSpyRigElection(spy: Spy): Boolean {
val cityToMoveTo = cityStatesToRig.flatMap { it.cities }.filter { !it.isBeingRazed && spy.canMoveTo(it) && (it.civ.getDiplomacyManager(civInfo).getInfluence() < 150 || it.civ.getAllyCiv() != civInfo.civName) }
.maxByOrNull { it.civ.getDiplomacyManager(civInfo).getInfluence() }
val cityToMoveTo = cityStatesToRig.flatMap { it.cities }.filter { !it.isBeingRazed && spy.canMoveTo(it) && (it.civ.getDiplomacyManager(civInfo)!!.getInfluence() < 150 || it.civ.getAllyCiv() != civInfo.civName) }
.maxByOrNull { it.civ.getDiplomacyManager(civInfo)!!.getInfluence() }
spy.moveTo(cityToMoveTo)
return cityToMoveTo != null
}
@ -87,8 +87,7 @@ class EspionageAutomation(val civInfo: Civilization) {
if (spy.getCoupChanceOfSuccess(false) < .7) return
val allyCiv = spy.getCity().civ.getAllyCiv()?.let { civInfo.gameInfo.getCivilization(it) }
// Don't coup city-states whose allies are out friends
if (allyCiv != null && civInfo.knows(allyCiv)
&& civInfo.getDiplomacyManager(allyCiv).isRelationshipLevelGE(RelationshipLevel.Friend)) return
if (allyCiv != null && civInfo.getDiplomacyManager(allyCiv)?.isRelationshipLevelGE(RelationshipLevel.Friend) == true) return
val spies = civInfo.espionageManager.spyList
val randomSeed = spies.size + spies.indexOf(spy) + civInfo.gameInfo.turns
val randomAction = Random(randomSeed).nextInt(100)

View File

@ -33,7 +33,7 @@ object SpecificUnitAutomation {
return false
// try to revenge and capture their tiles
val enemyCities = unit.civ.getKnownCivs()
.filter { unit.civ.getDiplomacyManager(it).hasModifier(DiplomaticModifiers.StealingTerritory) }
.filter { unit.civ.getDiplomacyManager(it)!!.hasModifier(DiplomaticModifiers.StealingTerritory) }
.flatMap { it.cities }
// find the suitable tiles (or their neighbours)
val tileToSteal = enemyCities.flatMap { it.getTiles() } // City tiles
@ -185,7 +185,7 @@ object SpecificUnitAutomation {
val foundCityAction = UnitActionsFromUniques.getFoundCityAction(unit, bestCityLocation)
if (foundCityAction?.action == null) { // this means either currentMove == 0 or city within 3 tiles
if (unit.currentMovement > 0) // therefore, city within 3 tiles
if (unit.currentMovement > 0 && !unit.civ.isOneCityChallenger()) // therefore, city within 3 tiles
throw Exception("City within distance")
return
}

View File

@ -505,7 +505,7 @@ object UnitAutomation {
val civInfo = unit.civ
fun hasPreparationFlag(targetCiv: Civilization): Boolean {
val diploManager = civInfo.getDiplomacyManager(targetCiv)
val diploManager = civInfo.getDiplomacyManager(targetCiv)!!
if (diploManager.hasFlag(DiplomacyFlags.Denunciation)
|| diploManager.otherCivDiplomacy().hasFlag(DiplomacyFlags.Denunciation)) return true
if (diploManager.hasFlag(DiplomacyFlags.WaryOf) && diploManager.getFlag(DiplomacyFlags.WaryOf) < 0) return true

View File

@ -8,7 +8,6 @@ import com.unciv.logic.automation.civilization.NextTurnAutomation
import com.unciv.logic.automation.unit.UnitAutomation.wander
import com.unciv.logic.civilization.Civilization
import com.unciv.logic.civilization.NotificationCategory
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
import com.unciv.logic.map.mapunit.MapUnit
import com.unciv.logic.map.tile.Tile
import com.unciv.logic.map.tile.toStats
@ -489,8 +488,8 @@ class WorkerAutomation(
// except citadel which can be built near-by
(!isCitadel || tile.neighbors.all { it.getOwner() != civInfo }) ||
!isAcceptableTileForFort(tile)) return 0f
val enemyCivs = civInfo.getKnownCivs()
.filter { it != civInfo && it.cities.isNotEmpty() && (civInfo.isAtWarWith(it) || civInfo.getDiplomacyManager(it).isRelationshipLevelLE(RelationshipLevel.Enemy)) }
val enemyCivs = civInfo.getCivsAtWarWith()
// no potential enemies
if (enemyCivs.none()) return 0f

View File

@ -26,7 +26,7 @@ object Nuke {
* - Not if we would need to declare war on someone we can't.
* - Disallow nuking the tile the nuke is in, as per Civ5 (but not nuking your own tiles/units otherwise)
*
* Both [BattleTable.simulateNuke] and [SpecificUnitAutomation.automateNukes] check range, so that check is omitted here.
* Both [BattleTable.simulateNuke] and [AirUnitAutomation.automateNukes] check range, so that check is omitted here.
*/
fun mayUseNuke(nuke: MapUnitCombatant, targetTile: Tile): Boolean {
if (nuke.getTile() == targetTile) return false
@ -43,8 +43,7 @@ object Nuke {
// Gleaned from Civ5 source - this disallows nuking unknown civs even in invisible tiles
// https://github.com/Gedemon/Civ5-DLL/blob/master/CvGameCoreDLL_Expansion1/CvUnit.cpp#L5056
// https://github.com/Gedemon/Civ5-DLL/blob/master/CvGameCoreDLL_Expansion1/CvTeam.cpp#L986
if (attackerCiv.knows(defenderCiv) && attackerCiv.getDiplomacyManager(defenderCiv).canAttack())
return
if (attackerCiv.getDiplomacyManager(defenderCiv)?.canAttack() == true) return
canNuke = false
}
@ -88,7 +87,7 @@ object Nuke {
// It's unclear whether using nukes results in a penalty with all civs, or only affected civs.
// For now I'll make it give a diplomatic penalty to all known civs, but some testing for this would be appreciated
for (civ in attackingCiv.getKnownCivs()) {
civ.getDiplomacyManager(attackingCiv).setModifier(DiplomaticModifiers.UsedNuclearWeapons, -50f)
civ.getDiplomacyManager(attackingCiv)!!.setModifier(DiplomaticModifiers.UsedNuclearWeapons, -50f)
}
if (!attacker.isDefeated()) {
@ -159,9 +158,9 @@ object Nuke {
fun tryDeclareWar(civSuffered: Civilization) {
if (civSuffered != attackingCiv
&& civSuffered.knows(attackingCiv)
&& civSuffered.getDiplomacyManager(attackingCiv).diplomaticStatus != DiplomaticStatus.War
&& civSuffered.getDiplomacyManager(attackingCiv)!!.diplomaticStatus != DiplomaticStatus.War
) {
attackingCiv.getDiplomacyManager(civSuffered).declareWar()
attackingCiv.getDiplomacyManager(civSuffered)!!.declareWar()
if (!notifyDeclaredWarCivs.contains(civSuffered)) notifyDeclaredWarCivs.add(
civSuffered
)

View File

@ -61,7 +61,7 @@ class GreatPersonPointsBreakdown private constructor(private val ruleset: Rulese
// Now add boni for GreatPersonBoostWithFriendship (Sweden UP)
val civ = city.civ
for (otherCiv in civ.getKnownCivs()) {
if (!civ.getDiplomacyManager(otherCiv).hasFlag(DiplomacyFlags.DeclarationOfFriendship))
if (!civ.getDiplomacyManager(otherCiv)!!.hasFlag(DiplomacyFlags.DeclarationOfFriendship))
continue
val boostUniques = civ.getMatchingUniques(UniqueType.GreatPersonBoostWithFriendship) +
otherCiv.getMatchingUniques(UniqueType.GreatPersonBoostWithFriendship)

View File

@ -148,15 +148,15 @@ class CityConquestFunctions(val city: City) {
if (!conqueringCiv.knows(oldCiv))
conqueringCiv.diplomacyFunctions.makeCivilizationsMeet(oldCiv)
oldCiv.getDiplomacyManager(conqueringCiv)
oldCiv.getDiplomacyManager(conqueringCiv)!!
.addModifier(DiplomaticModifiers.CapturedOurCities, -aggroGenerated)
for (thirdPartyCiv in conqueringCiv.getKnownCivs().filter { it.isMajorCiv() }) {
val aggroGeneratedForOtherCivs = (aggroGenerated / 10).roundToInt().toFloat()
if (thirdPartyCiv.isAtWarWith(oldCiv)) // You annoyed our enemy?
thirdPartyCiv.getDiplomacyManager(conqueringCiv)
.addModifier(DiplomaticModifiers.SharedEnemy, aggroGeneratedForOtherCivs) // Cool, keep at at! =D
else thirdPartyCiv.getDiplomacyManager(conqueringCiv)
if (thirdPartyCiv.isAtWarWith(oldCiv)) // Shared Enemies should like us more
thirdPartyCiv.getDiplomacyManager(conqueringCiv)!!
.addModifier(DiplomaticModifiers.SharedEnemy, aggroGeneratedForOtherCivs) // Cool, keep at it! =D
else thirdPartyCiv.getDiplomacyManager(conqueringCiv)!!
.addModifier(DiplomaticModifiers.WarMongerer, -aggroGeneratedForOtherCivs) // Uncool bro.
}
}
@ -216,19 +216,16 @@ class CityConquestFunctions(val city: City) {
100f / (foundingCiv.cities.sumOf { it.population.population } + city.population.population)
val respectForLiberatingOurCity = 10f + percentageOfCivPopulationInThatCity.roundToInt()
// In order to get "plus points" in Diplomacy, you have to establish diplomatic relations if you haven't yet
if (!conqueringCiv.knows(foundingCiv))
conqueringCiv.diplomacyFunctions.makeCivilizationsMeet(foundingCiv)
if (foundingCiv.isMajorCiv()) {
foundingCiv.getDiplomacyManager(conqueringCiv)
// In order to get "plus points" in Diplomacy, you have to establish diplomatic relations if you haven't yet
foundingCiv.getDiplomacyManagerOrMeet(conqueringCiv)
.addModifier(DiplomaticModifiers.CapturedOurCities, respectForLiberatingOurCity)
val openBordersTrade = TradeLogic(foundingCiv, conqueringCiv)
openBordersTrade.currentTrade.ourOffers.add(TradeOffer(Constants.openBorders, TradeType.Agreement))
openBordersTrade.acceptTrade(false)
} else {
//Liberating a city state gives a large amount of influence, and peace
foundingCiv.getDiplomacyManager(conqueringCiv).setInfluence(90f)
foundingCiv.getDiplomacyManagerOrMeet(conqueringCiv).setInfluence(90f)
if (foundingCiv.isAtWarWith(conqueringCiv)) {
val tradeLogic = TradeLogic(foundingCiv, conqueringCiv)
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty))
@ -239,7 +236,7 @@ class CityConquestFunctions(val city: City) {
val otherCivsRespectForLiberating = (respectForLiberatingOurCity / 10).roundToInt().toFloat()
for (thirdPartyCiv in conqueringCiv.getKnownCivs().filter { it.isMajorCiv() && it != conqueredCiv }) {
thirdPartyCiv.getDiplomacyManager(conqueringCiv)
thirdPartyCiv.getDiplomacyManager(conqueringCiv)!!
.addModifier(DiplomaticModifiers.LiberatedCity, otherCivsRespectForLiberating) // Cool, keep at at! =D
}
}

View File

@ -244,6 +244,6 @@ class CityFounder {
.distinct()
.filter { it.knows(city.civ) && it.hasExplored(city.getCenterTile()) }
for (otherCiv in civsWithCloseCities)
otherCiv.getDiplomacyManager(city.civ).setFlag(DiplomacyFlags.SettledCitiesNearUs, 30)
otherCiv.getDiplomacyManager(city.civ)!!.setFlag(DiplomacyFlags.SettledCitiesNearUs, 30)
}
}

View File

@ -320,8 +320,13 @@ class Civilization : IsPartOfGameInfoSerialization {
return gameInfo.ruleset.difficulties.values.first()
}
fun getDiplomacyManager(civInfo: Civilization) = getDiplomacyManager(civInfo.civName)
fun getDiplomacyManager(civName: String) = diplomacy[civName]!!
/** Makes this civilization meet [civInfo] and returns the DiplomacyManager */
fun getDiplomacyManagerOrMeet(civInfo: Civilization): DiplomacyManager {
if (!knows(civInfo)) diplomacyFunctions.makeCivilizationsMeet(civInfo)
return getDiplomacyManager(civInfo.civName)!!
}
fun getDiplomacyManager(civInfo: Civilization): DiplomacyManager? = getDiplomacyManager(civInfo.civName)
fun getDiplomacyManager(civName: String): DiplomacyManager? = diplomacy[civName]
fun getProximity(civInfo: Civilization) = getProximity(civInfo.civName)
@Suppress("MemberVisibilityCanBePrivate") // same visibility for overloads
@ -900,7 +905,7 @@ class Civilization : IsPartOfGameInfoSerialization {
tradeRequests.clear() // if we don't do this then there could be resources taken by "pending" trades forever
for (diplomacyManager in diplomacy.values) {
diplomacyManager.trades.clear()
diplomacyManager.otherCiv().getDiplomacyManager(this).trades.clear()
diplomacyManager.otherCivDiplomacy().trades.clear()
for (tradeRequest in diplomacyManager.otherCiv().tradeRequests.filter { it.requestingCiv == civName })
diplomacyManager.otherCiv().tradeRequests.remove(tradeRequest) // it would be really weird to get a trade request from a dead civ
}

View File

@ -77,7 +77,7 @@ class CityStateFunctions(val civInfo: Civilization) {
fun getVotesFromSpy(spy: Spy?): Float {
if (spy == null) return 20f
var votes = (civInfo.getDiplomacyManager(spy.civInfo).influence / 2)
var votes = (civInfo.getDiplomacyManager(spy.civInfo)!!.influence / 2)
votes += (spy.getSkillModifierPercent() * spy.getEfficiencyModifier()).toFloat() // ranges from 30 to 90
return votes
}
@ -94,7 +94,7 @@ class CityStateFunctions(val civInfo: Civilization) {
// Winning civ gets influence and all others loose influence
for (civ in civInfo.getKnownCivs().toList()) {
val influence = if (civ == winner) 20f else -5f
civInfo.getDiplomacyManager(civ).addInfluence(influence)
civInfo.getDiplomacyManager(civ)!!.addInfluence(influence)
if (civ == winner) {
civ.addNotification("Your spy successfully rigged the election in [${civInfo.civName}]!", capital.location, NotificationCategory.Espionage, NotificationIcon.Spy)
} else if (spies.any { it.civInfo == civ}) {
@ -108,7 +108,7 @@ class CityStateFunctions(val civInfo: Civilization) {
} else {
// No spy won the election, the civs that tried to rig the election loose influence
for (spy in spies) {
civInfo.getDiplomacyManager(spy.civInfo).addInfluence(-5f)
civInfo.getDiplomacyManager(spy.civInfo)!!.addInfluence(-5f)
spy.civInfo.addNotification("Your spy lost the election in [$capital]!", capital.location, NotificationCategory.Espionage, NotificationIcon.Spy)
}
}
@ -201,7 +201,7 @@ class CityStateFunctions(val civInfo: Civilization) {
if (!civInfo.isCityState()) throw Exception("You can only gain influence with City-States!")
donorCiv.addGold(-giftAmount)
civInfo.addGold(giftAmount)
civInfo.getDiplomacyManager(donorCiv).addInfluence(influenceGainedByGift(donorCiv, giftAmount).toFloat())
civInfo.getDiplomacyManager(donorCiv)!!.addInfluence(influenceGainedByGift(donorCiv, giftAmount).toFloat())
civInfo.questManager.receivedGoldGift(donorCiv)
}
@ -216,7 +216,7 @@ class CityStateFunctions(val civInfo: Civilization) {
if(!otherCivCanPledgeProtection(otherCiv))
return
val diplomacy = civInfo.getDiplomacyManager(otherCiv.civName)
val diplomacy = civInfo.getDiplomacyManager(otherCiv.civName)!!
diplomacy.diplomaticStatus = DiplomaticStatus.Protector
diplomacy.setFlag(DiplomacyFlags.RecentlyPledgedProtection, 10) // Can't break for 10 turns
}
@ -225,7 +225,7 @@ class CityStateFunctions(val civInfo: Civilization) {
if(!forced && !otherCivCanWithdrawProtection(otherCiv))
return
val diplomacy = civInfo.getDiplomacyManager(otherCiv)
val diplomacy = civInfo.getDiplomacyManager(otherCiv)!!
diplomacy.diplomaticStatus = DiplomaticStatus.Peace
diplomacy.setFlag(DiplomacyFlags.RecentlyWithdrewProtection, 20) // Can't re-pledge for 20 turns
diplomacy.addInfluence(-20f)
@ -235,7 +235,7 @@ class CityStateFunctions(val civInfo: Civilization) {
// Must be a known city state
if(!civInfo.isCityState() || !otherCiv.isMajorCiv() || otherCiv.isDefeated() || !civInfo.knows(otherCiv))
return false
val diplomacy = civInfo.getDiplomacyManager(otherCiv)
val diplomacy = civInfo.getDiplomacyManager(otherCiv)!!
// Can't pledge too soon after withdrawing
if (diplomacy.hasFlag(DiplomacyFlags.RecentlyWithdrewProtection))
return false
@ -255,7 +255,7 @@ class CityStateFunctions(val civInfo: Civilization) {
// Must be a known city state
if(!civInfo.isCityState() || !otherCiv.isMajorCiv() || otherCiv.isDefeated() || !civInfo.knows(otherCiv))
return false
val diplomacy = civInfo.getDiplomacyManager(otherCiv)
val diplomacy = civInfo.getDiplomacyManager(otherCiv)!!
// Can't withdraw too soon after pledging
if (diplomacy.hasFlag(DiplomacyFlags.RecentlyPledgedProtection))
return false
@ -290,7 +290,7 @@ class CityStateFunctions(val civInfo: Civilization) {
newAllyCiv.cache.updateViewableTiles()
newAllyCiv.cache.updateCivResources()
for (unique in newAllyCiv.getMatchingUniques(UniqueType.CityStateCanBeBoughtForGold))
newAllyCiv.getDiplomacyManager(civInfo.civName).setFlag(DiplomacyFlags.MarriageCooldown, unique.params[0].toInt())
newAllyCiv.getDiplomacyManager(civInfo)!!.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() } ) {
@ -298,7 +298,7 @@ class CityStateFunctions(val civInfo: Civilization) {
if (!civInfo.knows(newEnemy))
// We have to meet first
civInfo.diplomacyFunctions.makeCivilizationsMeet(newEnemy, warOnContact = true)
civInfo.getDiplomacyManager(newEnemy).declareWar(DeclareWarReason(WarType.CityStateAllianceWar, newAllyCiv))
civInfo.getDiplomacyManager(newEnemy)!!.declareWar(DeclareWarReason(WarType.CityStateAllianceWar, newAllyCiv))
}
}
}
@ -349,8 +349,8 @@ class CityStateFunctions(val civInfo: Civilization) {
return (!civInfo.isDefeated()
&& civInfo.isCityState()
&& civInfo.cities.any()
&& civInfo.getDiplomacyManager(otherCiv).isRelationshipLevelEQ(RelationshipLevel.Ally)
&& !otherCiv.getDiplomacyManager(civInfo).hasFlag(DiplomacyFlags.MarriageCooldown)
&& civInfo.getDiplomacyManager(otherCiv)!!.isRelationshipLevelEQ(RelationshipLevel.Ally)
&& !otherCiv.getDiplomacyManager(civInfo)!!.hasFlag(DiplomacyFlags.MarriageCooldown)
&& otherCiv.getMatchingUniques(UniqueType.CityStateCanBeBoughtForGold).any()
&& otherCiv.gold >= getDiplomaticMarriageCost())
@ -422,7 +422,7 @@ class CityStateFunctions(val civInfo: Civilization) {
modifiers["Very recently paid tribute"] = -300
else if (recentBullying != null && recentBullying > 0)
modifiers["Recently paid tribute"] = -40
if (civInfo.getDiplomacyManager(demandingCiv).getInfluence() < -30)
if (civInfo.getDiplomacyManager(demandingCiv)!!.getInfluence() < -30)
modifiers["Influence below -30"] = -300
// Slight optimization, we don't do the expensive stuff if we have no chance of getting a >= 0 result
@ -475,7 +475,7 @@ class CityStateFunctions(val civInfo: Civilization) {
if (!civInfo.isCityState()) throw Exception("You can only demand gold from City-States!")
val goldAmount = goldGainedByTribute()
demandingCiv.addGold(goldAmount)
civInfo.getDiplomacyManager(demandingCiv).addInfluence(-15f)
civInfo.getDiplomacyManager(demandingCiv)!!.addInfluence(-15f)
cityStateBullied(demandingCiv)
civInfo.addFlag(CivFlags.RecentlyBullied.name, 20)
}
@ -490,7 +490,7 @@ class CityStateFunctions(val civInfo: Civilization) {
if (buildableWorkerLikeUnits.isEmpty()) return // Bad luck?
demandingCiv.units.placeUnitNearTile(civInfo.getCapital()!!.location, buildableWorkerLikeUnits.values.random())
civInfo.getDiplomacyManager(demandingCiv).addInfluence(-50f)
civInfo.getDiplomacyManager(demandingCiv)!!.addInfluence(-50f)
cityStateBullied(demandingCiv)
civInfo.addFlag(CivFlags.RecentlyBullied.name, 20)
}
@ -512,7 +512,7 @@ class CityStateFunctions(val civInfo: Civilization) {
for (otherCiv in civInfo.getKnownCivs().filter { it.isMajorCiv() }.toList()) {
if (civInfo.isAtWarWith(otherCiv)) continue
if (otherCiv.hasUnique(UniqueType.CityStateTerritoryAlwaysFriendly)) continue
val diplomacy = civInfo.getDiplomacyManager(otherCiv)
val diplomacy = civInfo.getDiplomacyManager(otherCiv)!!
if (diplomacy.hasFlag(DiplomacyFlags.AngerFreeIntrusion)) continue // They recently helped us
val unitsInBorder = otherCiv.units.getCivUnits().count { !it.isCivilian() && it.getTile().getOwner() == civInfo }
@ -546,7 +546,7 @@ class CityStateFunctions(val civInfo: Civilization) {
}
fun threateningBarbarianKilledBy(otherCiv: Civilization) {
val diplomacy = civInfo.getDiplomacyManager(otherCiv)
val diplomacy = civInfo.getDiplomacyManager(otherCiv)!!
if (diplomacy.diplomaticStatus == DiplomaticStatus.War) return // No reward for enemies
diplomacy.addInfluence(12f)
@ -567,7 +567,7 @@ class CityStateFunctions(val civInfo: Civilization) {
for (protector in civInfo.cityStateFunctions.getProtectorCivs()) {
if (!protector.knows(bully)) // Who?
continue
val protectorDiplomacy = protector.getDiplomacyManager(bully)
val protectorDiplomacy = protector.getDiplomacyManager(bully)!!
if (protectorDiplomacy.hasModifier(DiplomaticModifiers.BulliedProtectedMinor)
&& protectorDiplomacy.getFlag(DiplomacyFlags.RememberBulliedProtectedMinor) > 50)
protectorDiplomacy.addModifier(DiplomaticModifiers.BulliedProtectedMinor, -10f) // Penalty less severe for second offence
@ -587,7 +587,7 @@ class CityStateFunctions(val civInfo: Civilization) {
}
// Set a diplomatic flag so we remember for future quests (and not to give them any)
civInfo.getDiplomacyManager(bully).setFlag(DiplomacyFlags.Bullied, 20)
civInfo.getDiplomacyManager(bully)!!.setFlag(DiplomacyFlags.Bullied, 20)
// Notify all City-States that we were bullied (for quests)
civInfo.gameInfo.getAliveCityStates()
@ -601,11 +601,11 @@ class CityStateFunctions(val civInfo: Civilization) {
// We might become wary!
if (attacker.isMinorCivWarmonger()) { // They've attacked a lot of city-states
civInfo.getDiplomacyManager(attacker).becomeWary()
civInfo.getDiplomacyManager(attacker)!!.becomeWary()
}
else if (attacker.isMinorCivAggressor()) { // They've attacked a few
if (Random.Default.nextBoolean()) { // 50% chance
civInfo.getDiplomacyManager(attacker).becomeWary()
civInfo.getDiplomacyManager(attacker)!!.becomeWary()
}
}
// Others might become wary!
@ -644,15 +644,13 @@ class CityStateFunctions(val civInfo: Civilization) {
probability += 50
if (Random.Default.nextInt(100) <= probability) {
cityState.getDiplomacyManager(attacker).becomeWary()
cityState.getDiplomacyManager(attacker)!!.becomeWary()
}
}
}
for (protector in civInfo.cityStateFunctions.getProtectorCivs()) {
if (!protector.knows(attacker)) // Who?
continue
val protectorDiplomacy = protector.getDiplomacyManager(attacker)
val protectorDiplomacy = protector.getDiplomacyManager(attacker) ?: continue // Who?
if (protectorDiplomacy.hasModifier(DiplomaticModifiers.AttackedProtectedMinor)
&& protectorDiplomacy.getFlag(DiplomacyFlags.RememberAttackedProtectedMinor) > 50)
protectorDiplomacy.addModifier(DiplomaticModifiers.AttackedProtectedMinor, -15f) // Penalty less severe for second offence
@ -673,7 +671,7 @@ class CityStateFunctions(val civInfo: Civilization) {
// Set up war with major pseudo-quest
civInfo.questManager.wasAttackedBy(attacker)
civInfo.getDiplomacyManager(attacker).setFlag(DiplomacyFlags.RecentlyAttacked, 2) // Reminder to ask for unit gifts in 2 turns
civInfo.getDiplomacyManager(attacker)!!.setFlag(DiplomacyFlags.RecentlyAttacked, 2) // Reminder to ask for unit gifts in 2 turns
}
/** A city state was destroyed. Its protectors are going to be upset! */
@ -683,7 +681,7 @@ class CityStateFunctions(val civInfo: Civilization) {
for (protector in civInfo.cityStateFunctions.getProtectorCivs()) {
if (!protector.knows(attacker)) // Who?
continue
val protectorDiplomacy = protector.getDiplomacyManager(attacker)
val protectorDiplomacy = protector.getDiplomacyManager(attacker)!!
if (protectorDiplomacy.hasModifier(DiplomaticModifiers.DestroyedProtectedMinor))
protectorDiplomacy.addModifier(DiplomaticModifiers.DestroyedProtectedMinor, -10f) // Penalty less severe for second offence
else
@ -742,7 +740,7 @@ class CityStateFunctions(val civInfo: Civilization) {
// We don't use DiplomacyManager.getRelationshipLevel for performance reasons - it tries to calculate getTributeWillingness which is heavy
val relationshipLevel =
if (it.getAllyCiv() == civInfo.civName) RelationshipLevel.Ally
else if (it.getDiplomacyManager(civInfo).getInfluence() >= 30) RelationshipLevel.Friend
else if (it.getDiplomacyManager(civInfo)!!.getInfluence() >= 30) RelationshipLevel.Friend
else RelationshipLevel.Neutral
getCityStateBonuses(it.cityStateType, relationshipLevel, uniqueType)
}

View File

@ -58,7 +58,7 @@ object DeclareWar {
otherCiv.cityStateFunctions.updateAllyCivForCityState()
otherCivDiplomacy.setInfluence(-120f)
for (knownCiv in civInfo.getKnownCivs()) {
knownCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.BetrayedDeclarationOfFriendship, -10f)
knownCiv.getDiplomacyManager(civInfo)!!.addModifier(DiplomaticModifiers.BetrayedDeclarationOfFriendship, -10f)
}
}
}
@ -175,7 +175,7 @@ object DeclareWar {
for (thirdCiv in civInfo.getKnownCivs()) {
if (!thirdCiv.isAtWarWith(otherCiv))
// We don't want this modify to stack if there is a defensive pact
thirdCiv.getDiplomacyManager(civInfo)
thirdCiv.getDiplomacyManager(civInfo)!!
.addModifier(DiplomaticModifiers.WarMongerer, -5f)
}
}
@ -184,12 +184,12 @@ object DeclareWar {
for (thirdCiv in diplomacyManager.getCommonKnownCivs()) {
if (thirdCiv.isAtWarWith(otherCiv) && !thirdCiv.isAtWarWith(civInfo)) {
// Improve our relations
if (thirdCiv.isCityState()) thirdCiv.getDiplomacyManager(civInfo).addInfluence(10f)
else thirdCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.SharedEnemy, 5f)
if (thirdCiv.isCityState()) thirdCiv.getDiplomacyManager(civInfo)!!.addInfluence(10f)
else thirdCiv.getDiplomacyManager(civInfo)!!.addModifier(DiplomaticModifiers.SharedEnemy, 5f)
} else if (thirdCiv.isAtWarWith(civInfo)) {
// Improve their relations
if (thirdCiv.isCityState()) thirdCiv.getDiplomacyManager(otherCiv).addInfluence(10f)
else thirdCiv.getDiplomacyManager(otherCiv).addModifier(DiplomaticModifiers.SharedEnemy, 5f)
if (thirdCiv.isCityState()) thirdCiv.getDiplomacyManager(otherCiv)!!.addInfluence(10f)
else thirdCiv.getDiplomacyManager(otherCiv)!!.addModifier(DiplomaticModifiers.SharedEnemy, 5f)
}
}
}
@ -216,7 +216,7 @@ object DeclareWar {
if (betrayedFriendship || betrayedDefensivePact) {
for (knownCiv in diplomacyManager.civInfo.getKnownCivs()) {
val diploManager = knownCiv.getDiplomacyManager(diplomacyManager.civInfo)
val diploManager = knownCiv.getDiplomacyManager(diplomacyManager.civInfo)!!
if (betrayedFriendship) {
val amount = if (knownCiv == otherCiv) -40f else -20f
diploManager.addModifier(DiplomaticModifiers.BetrayedDeclarationOfFriendship, amount)
@ -299,7 +299,7 @@ object DeclareWar {
val ally = ourDefensivePact.otherCiv()
if (!civAtWarWith.knows(ally)) civAtWarWith.diplomacyFunctions.makeCivilizationsMeet(ally, true)
// Have the aggressor declare war on the ally.
civAtWarWith.getDiplomacyManager(ally).declareWar(DeclareWarReason(WarType.DefensivePactWar, diplomacyManager.civInfo))
civAtWarWith.getDiplomacyManager(ally)!!.declareWar(DeclareWarReason(WarType.DefensivePactWar, diplomacyManager.civInfo))
}
}
@ -312,7 +312,7 @@ object DeclareWar {
if (!thirdCiv.knows(civAtWarWith))
// Our city state ally has not met them yet, so they have to meet first
thirdCiv.diplomacyFunctions.makeCivilizationsMeet(civAtWarWith, warOnContact = true)
thirdCiv.getDiplomacyManager(civAtWarWith).declareWar(DeclareWarReason(WarType.CityStateAllianceWar, diplomacyManager.civInfo))
thirdCiv.getDiplomacyManager(civAtWarWith)!!.declareWar(DeclareWarReason(WarType.CityStateAllianceWar, diplomacyManager.civInfo))
}
}
}

View File

@ -89,8 +89,8 @@ class DiplomacyFunctions(val civInfo: Civilization) {
fun canSignDeclarationOfFriendshipWith(otherCiv: Civilization): Boolean {
return otherCiv.isMajorCiv() && !otherCiv.isAtWarWith(civInfo)
&& !civInfo.getDiplomacyManager(otherCiv).hasFlag(DiplomacyFlags.Denunciation)
&& !civInfo.getDiplomacyManager(otherCiv).hasFlag(DiplomacyFlags.DeclarationOfFriendship)
&& !civInfo.getDiplomacyManager(otherCiv)!!.hasFlag(DiplomacyFlags.Denunciation)
&& !civInfo.getDiplomacyManager(otherCiv)!!.hasFlag(DiplomacyFlags.DeclarationOfFriendship)
}
fun canSignResearchAgreement(): Boolean {
@ -102,7 +102,7 @@ class DiplomacyFunctions(val civInfo: Civilization) {
}
fun canSignResearchAgreementNoCostWith (otherCiv: Civilization): Boolean {
val diplomacyManager = civInfo.getDiplomacyManager(otherCiv)
val diplomacyManager = civInfo.getDiplomacyManager(otherCiv)!!
return canSignResearchAgreement() && otherCiv.diplomacyFunctions.canSignResearchAgreement()
&& diplomacyManager.hasFlag(DiplomacyFlags.DeclarationOfFriendship)
&& !diplomacyManager.hasFlag(DiplomacyFlags.ResearchAgreement)
@ -129,7 +129,7 @@ class DiplomacyFunctions(val civInfo: Civilization) {
}
fun canSignDefensivePactWith(otherCiv: Civilization): Boolean {
val diplomacyManager = civInfo.getDiplomacyManager(otherCiv)
val diplomacyManager = civInfo.getDiplomacyManager(otherCiv)!!
return canSignDefensivePact() && otherCiv.diplomacyFunctions.canSignDefensivePact()
&& (diplomacyManager.hasFlag(DiplomacyFlags.DeclarationOfFriendship)
|| diplomacyManager.otherCivDiplomacy().hasFlag(DiplomacyFlags.DeclarationOfFriendship))

View File

@ -172,7 +172,7 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
//region pure functions
fun otherCiv() = civInfo.gameInfo.getCivilization(otherCivName)
fun otherCivDiplomacy() = otherCiv().getDiplomacyManager(civInfo)
fun otherCivDiplomacy() = otherCiv().getDiplomacyManager(civInfo)!!
fun turnsToPeaceTreaty(): Int {
for (trade in trades)
@ -258,7 +258,7 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
return RelationshipLevel.Neutral // People make their own choices.
if (civInfo.isHuman())
return otherCiv().getDiplomacyManager(civInfo).relationshipLevel()
return otherCivDiplomacy().relationshipLevel()
if (civInfo.isCityState()) return when {
getInfluence() <= -30 -> RelationshipLevel.Unforgivable // getInfluence tests isAtWarWith
@ -472,10 +472,10 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
for (thirdCiv in civInfo.getKnownCivs()) {
// Our ally city states make peace with us
if (thirdCiv.getAllyCiv() == civInfo.civName && thirdCiv.isAtWarWith(otherCiv))
thirdCiv.getDiplomacyManager(otherCiv).makePeace()
thirdCiv.getDiplomacyManager(otherCiv)!!.makePeace()
// Other City-States that are not our ally don't like the fact that we made peace with their enemy
if (thirdCiv.getAllyCiv() != civInfo.civName && thirdCiv.isAtWarWith(otherCiv))
thirdCiv.getDiplomacyManager(civInfo).addInfluence(-10f)
thirdCiv.getDiplomacyManager(civInfo)!!.addInfluence(-10f)
}
}
@ -530,9 +530,9 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
for (thirdCiv in getCommonKnownCivsWithSpectators()) {
thirdCiv.addNotification("[${civInfo.civName}] and [$otherCivName] have signed the Declaration of Friendship!",
NotificationCategory.Diplomacy, civInfo.civName, NotificationIcon.Diplomacy, otherCivName)
thirdCiv.getDiplomacyManager(civInfo).setFriendshipBasedModifier()
thirdCiv.getDiplomacyManager(civInfo)!!.setFriendshipBasedModifier()
if (thirdCiv.isSpectator()) return
thirdCiv.getDiplomacyManager(civInfo).setFriendshipBasedModifier()
thirdCiv.getDiplomacyManager(civInfo)!!.setFriendshipBasedModifier()
}
// Ignore contitionals as triggerUnique will check again, and that would break
@ -547,9 +547,9 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
removeModifier(DiplomaticModifiers.DeclaredFriendshipWithOurAllies)
removeModifier(DiplomaticModifiers.DeclaredFriendshipWithOurEnemies)
for (thirdCiv in getCommonKnownCivs()
.filter { it.getDiplomacyManager(civInfo).hasFlag(DiplomacyFlags.DeclarationOfFriendship) }) {
.filter { it.getDiplomacyManager(civInfo)!!.hasFlag(DiplomacyFlags.DeclarationOfFriendship) }) {
val relationshipLevel = otherCiv().getDiplomacyManager(thirdCiv).relationshipIgnoreAfraid()
val relationshipLevel = otherCiv().getDiplomacyManager(thirdCiv)!!.relationshipIgnoreAfraid()
val modifierType = when (relationshipLevel) {
RelationshipLevel.Unforgivable, RelationshipLevel.Enemy -> DiplomaticModifiers.DeclaredFriendshipWithOurEnemies
else -> DiplomaticModifiers.DeclaredFriendshipWithOurAllies
@ -579,7 +579,7 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
thirdCiv.addNotification("[${civInfo.civName}] and [$otherCivName] have signed a Defensive Pact!",
NotificationCategory.Diplomacy, civInfo.civName, NotificationIcon.Diplomacy, otherCivName)
if (thirdCiv.isSpectator()) return
thirdCiv.getDiplomacyManager(civInfo).setDefensivePactBasedModifier()
thirdCiv.getDiplomacyManager(civInfo)!!.setDefensivePactBasedModifier()
}
// Ignore contitionals as triggerUnique will check again, and that would break
@ -594,9 +594,9 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
removeModifier(DiplomaticModifiers.SignedDefensivePactWithOurAllies)
removeModifier(DiplomaticModifiers.SignedDefensivePactWithOurEnemies)
for (thirdCiv in getCommonKnownCivs()
.filter { it.getDiplomacyManager(civInfo).hasFlag(DiplomacyFlags.DefensivePact) }) {
.filter { it.getDiplomacyManager(civInfo)!!.hasFlag(DiplomacyFlags.DefensivePact) }) {
//Note: These modifiers are additive to the friendship modifiers
val relationshipLevel = otherCiv().getDiplomacyManager(thirdCiv).relationshipIgnoreAfraid()
val relationshipLevel = otherCivDiplomacy().relationshipIgnoreAfraid()
val modifierType = when (relationshipLevel) {
RelationshipLevel.Unforgivable, RelationshipLevel.Enemy -> DiplomaticModifiers.SignedDefensivePactWithOurEnemies
else -> DiplomaticModifiers.SignedDefensivePactWithOurAllies
@ -613,7 +613,7 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
}
internal fun setReligionBasedModifier() {
if (civInfo.getDiplomacyManager(otherCiv()).believesSameReligion())
if (otherCivDiplomacy().believesSameReligion())
// they share same majority religion
setModifier(DiplomaticModifiers.BelieveSameReligion, 5f)
else
@ -635,8 +635,8 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
thirdCiv.addNotification("[${civInfo.civName}] has denounced [$otherCivName]!",
NotificationCategory.Diplomacy, civInfo.civName, NotificationIcon.Diplomacy, otherCivName)
if (thirdCiv.isSpectator()) return@forEach
val thirdCivRelationshipWithOtherCiv = thirdCiv.getDiplomacyManager(otherCiv()).relationshipIgnoreAfraid()
val thirdCivDiplomacyManager = thirdCiv.getDiplomacyManager(civInfo)
val thirdCivRelationshipWithOtherCiv = thirdCiv.getDiplomacyManager(otherCiv())!!.relationshipIgnoreAfraid()
val thirdCivDiplomacyManager = thirdCiv.getDiplomacyManager(civInfo)!!
when (thirdCivRelationshipWithOtherCiv) {
RelationshipLevel.Unforgivable -> thirdCivDiplomacyManager.addModifier(DiplomaticModifiers.DenouncedOurEnemies, 15f)
RelationshipLevel.Enemy -> thirdCivDiplomacyManager.addModifier(DiplomaticModifiers.DenouncedOurEnemies, 5f)

View File

@ -39,7 +39,7 @@ object DiplomacyTurnManager {
) {
trades.remove(trade)
val otherCivTrades = otherCiv().getDiplomacyManager(civInfo).trades
val otherCivTrades = otherCiv().getDiplomacyManager(civInfo)!!.trades
otherCivTrades.removeAll { it.equalTrade(trade.reverse()) }
// Can't cut short peace treaties!
@ -70,7 +70,7 @@ object DiplomacyTurnManager {
TradeOffer(Constants.peaceTreaty, TradeType.Treaty, duration = durationLeft)
)
trades.add(treaty)
otherCiv().getDiplomacyManager(civInfo).trades.add(treaty)
otherCiv().getDiplomacyManager(civInfo)!!.trades.add(treaty)
}

View File

@ -378,7 +378,7 @@ class QuestManager : IsPartOfGameInfoSerialization {
return false
if (getAssignedQuestsOfName(quest.questNameInstance).any { it.assignee == challenger.civName })
return false
if (quest.isIndividual() && civ.getDiplomacyManager(challenger).hasFlag(DiplomacyFlags.Bullied))
if (quest.isIndividual() && civ.getDiplomacyManager(challenger)!!.hasFlag(DiplomacyFlags.Bullied))
return false
return when (quest.questNameInstance) {
@ -417,8 +417,8 @@ class QuestManager : IsPartOfGameInfoSerialization {
private fun isDenounceCivQuestValid(challenger: Civilization, mostRecentBully: String?): Boolean {
return mostRecentBully != null
&& challenger.knows(mostRecentBully)
&& !challenger.getDiplomacyManager(mostRecentBully).hasFlag(DiplomacyFlags.Denunciation)
&& challenger.getDiplomacyManager(mostRecentBully).diplomaticStatus != DiplomaticStatus.War
&& !challenger.getDiplomacyManager(mostRecentBully)!!.hasFlag(DiplomacyFlags.Denunciation)
&& challenger.getDiplomacyManager(mostRecentBully)!!.diplomaticStatus != DiplomaticStatus.War
&& !( challenger.playerType == PlayerType.Human
&& civ.gameInfo.getCivilization(mostRecentBully).playerType == PlayerType.Human)
}
@ -434,7 +434,7 @@ class QuestManager : IsPartOfGameInfoSerialization {
QuestName.FindPlayer -> assignee.hasMetCivTerritory(civ.gameInfo.getCivilization(assignedQuest.data1))
QuestName.FindNaturalWonder -> assignee.naturalWonders.contains(assignedQuest.data1)
QuestName.PledgeToProtect -> assignee in civ.cityStateFunctions.getProtectorCivs()
QuestName.DenounceCiv -> assignee.getDiplomacyManager(assignedQuest.data1).hasFlag(DiplomacyFlags.Denunciation)
QuestName.DenounceCiv -> assignee.getDiplomacyManager(assignedQuest.data1)!!.hasFlag(DiplomacyFlags.Denunciation)
QuestName.SpreadReligion -> civ.getCapital()!!.religion.getMajorityReligion() == civ.gameInfo.religions[assignedQuest.data2]
else -> false
}
@ -459,7 +459,7 @@ class QuestManager : IsPartOfGameInfoSerialization {
val rewardInfluence = assignedQuest.getInfluence()
val assignee = civ.gameInfo.getCivilization(assignedQuest.assignee)
civ.getDiplomacyManager(assignedQuest.assignee).addInfluence(rewardInfluence)
civ.getDiplomacyManager(assignedQuest.assignee)!!.addInfluence(rewardInfluence)
if (rewardInfluence > 0)
assignee.addNotification(
"[${civ.civName}] rewarded you with [${rewardInfluence.toInt()}] influence for completing the [${assignedQuest.questName}] quest.",
@ -670,7 +670,7 @@ class QuestManager : IsPartOfGameInfoSerialization {
if (updatedKillCount >= unitsToKillForCiv[killed.civName]!!) {
killer.addNotification("[${civ.civName}] is deeply grateful for your assistance in the war against [${killed.civName}]!",
DiplomacyAction(civ.civName), NotificationCategory.Diplomacy, civ.civName, "OtherIcons/Quest")
civ.getDiplomacyManager(killer).addInfluence(100f) // yikes
civ.getDiplomacyManager(killer)!!.addInfluence(100f) // yikes
endWarWithMajorQuest(killed)
}
}

View File

@ -169,7 +169,7 @@ class CivInfoStatsForNextTurn(val civInfo: Civilization) {
//City-States bonuses
for (otherCiv in civInfo.getKnownCivs()) {
if (!otherCiv.isCityState()) continue
if (!otherCiv.getDiplomacyManager(civInfo.civName).isRelationshipLevelEQ(RelationshipLevel.Ally))
if (!otherCiv.getDiplomacyManager(civInfo.civName)!!.isRelationshipLevelEQ(RelationshipLevel.Ally))
continue
for (unique in civInfo.getMatchingUniques(UniqueType.CityStateStatPercent)) {
statMap.add(

View File

@ -347,7 +347,7 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable {
tileOwner == null -> false
tileOwner == civInfo -> true
!civInfo.knows(tileOwner) -> false
else -> tileOwner.getDiplomacyManager(civInfo).isConsideredFriendlyTerritory()
else -> tileOwner.getDiplomacyManager(civInfo)!!.isConsideredFriendlyTerritory()
}
}

View File

@ -356,8 +356,7 @@ class TileImprovementFunctions(val tile: Tile) {
val otherCiv = tileToTakeOver.getOwner()
if (otherCiv != null) {
// decrease relations for -10 pt/tile
if (!otherCiv.knows(civ)) otherCiv.diplomacyFunctions.makeCivilizationsMeet(civ)
otherCiv.getDiplomacyManager(civ).addModifier(DiplomaticModifiers.StealingTerritory, -10f)
otherCiv.getDiplomacyManagerOrMeet(civ).addModifier(DiplomaticModifiers.StealingTerritory, -10f)
civsToNotify.add(otherCiv)
}
nearestCity.expansion.takeOwnership(tileToTakeOver)

View File

@ -53,7 +53,7 @@ class Trade : IsPartOfGameInfoSerialization {
class TradeRequest : IsPartOfGameInfoSerialization {
fun decline(decliningCiv: Civilization) {
val requestingCivInfo = decliningCiv.gameInfo.getCivilization(requestingCiv)
val requestingCivDiploManager = requestingCivInfo.getDiplomacyManager(decliningCiv)
val requestingCivDiploManager = requestingCivInfo.getDiplomacyManager(decliningCiv)!!
// the numbers of the flags (20,5) are the amount of turns to wait until offering again
if (trade.ourOffers.all { it.type == TradeType.Luxury_Resource }
&& trade.theirOffers.all { it.type == TradeType.Luxury_Resource })

View File

@ -76,7 +76,7 @@ class TradeEvaluation {
var sumOfOurOffers = trade.ourOffers.sumOf { evaluateSellCostWithInflation(it, evaluator, tradePartner, trade) }
val relationshipLevel = evaluator.getDiplomacyManager(tradePartner).relationshipIgnoreAfraid()
val relationshipLevel = evaluator.getDiplomacyManager(tradePartner)!!.relationshipIgnoreAfraid()
// If we're making a peace treaty, don't try to up the bargain for people you don't like.
// Leads to spartan behaviour where you demand more, the more you hate the enemy...unhelpful
if (trade.ourOffers.none { it.name == Constants.peaceTreaty || it.name == Constants.researchAgreement}) {
@ -90,7 +90,7 @@ class TradeEvaluation {
return Int.MIN_VALUE
}
}
val diplomaticGifts: Int = if (includeDiplomaticGifts) evaluator.getDiplomacyManager(tradePartner).getGoldGifts() else 0
val diplomaticGifts: Int = if (includeDiplomaticGifts) evaluator.getDiplomacyManager(tradePartner)!!.getGoldGifts() else 0
return sumOfTheirOffers - sumOfOurOffers + diplomaticGifts
}
@ -119,7 +119,7 @@ class TradeEvaluation {
}
TradeType.Luxury_Resource -> {
if (civInfo.getDiplomacyManager(tradePartner).hasFlag(DiplomacyFlags.ResourceTradesCutShort))
if (civInfo.getDiplomacyManager(tradePartner)!!.hasFlag(DiplomacyFlags.ResourceTradesCutShort))
return 0 // We don't trust you for resources
val weLoveTheKingPotential = civInfo.cities.count { it.demandedResource == offer.name } * 50
@ -133,7 +133,7 @@ class TradeEvaluation {
}
TradeType.Strategic_Resource -> {
if (civInfo.getDiplomacyManager(tradePartner).hasFlag(DiplomacyFlags.ResourceTradesCutShort))
if (civInfo.getDiplomacyManager(tradePartner)!!.hasFlag(DiplomacyFlags.ResourceTradesCutShort))
return 0 // We don't trust you for resources
val amountWillingToBuy = 2 - civInfo.getResourceAmount(offer.name)
@ -303,7 +303,7 @@ class TradeEvaluation {
}
TradeType.Agreement -> {
if (offer.name == Constants.openBorders) {
return when (civInfo.getDiplomacyManager(tradePartner).relationshipIgnoreAfraid()) {
return when (civInfo.getDiplomacyManager(tradePartner)!!.relationshipIgnoreAfraid()) {
RelationshipLevel.Unforgivable -> 10000
RelationshipLevel.Enemy -> 2000
RelationshipLevel.Competitor -> 500

View File

@ -23,7 +23,7 @@ class TradeLogic(val ourCivilization: Civilization, val otherCivilization: Civil
if (civInfo.isAtWarWith(otherCivilization))
offers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty))
if (!otherCivilization.getDiplomacyManager(civInfo).hasOpenBorders
if (!otherCivilization.getDiplomacyManager(civInfo)!!.hasOpenBorders
&& !otherCivilization.isCityState()
&& civInfo.hasUnique(UniqueType.EnablesOpenBorders)
&& otherCivilization.hasUnique(UniqueType.EnablesOpenBorders)) {
@ -70,7 +70,7 @@ class TradeLogic(val ourCivilization: Civilization, val otherCivilization: Civil
val civsWeBothKnow = otherCivsWeKnow
.filter { otherCivilization.diplomacy.containsKey(it.civName) }
val civsWeArentAtWarWith = civsWeBothKnow
.filter { civInfo.getDiplomacyManager(it).canDeclareWar() }
.filter { civInfo.getDiplomacyManager(it)!!.canDeclareWar() }
for (thirdCiv in civsWeArentAtWarWith) {
offers.add(TradeOffer(thirdCiv.civName, TradeType.WarDeclaration))
}
@ -80,8 +80,8 @@ class TradeLogic(val ourCivilization: Civilization, val otherCivilization: Civil
}
fun acceptTrade(applyGifts: Boolean = true) {
val ourDiploManager = ourCivilization.getDiplomacyManager(otherCivilization)
val theirDiploManger = otherCivilization.getDiplomacyManager(ourCivilization)
val ourDiploManager = ourCivilization.getDiplomacyManager(otherCivilization)!!
val theirDiploManger = otherCivilization.getDiplomacyManager(ourCivilization)!!
ourDiploManager.apply {
trades.add(currentTrade)
@ -126,16 +126,16 @@ class TradeLogic(val ourCivilization: Civilization, val otherCivilization: Civil
}
TradeType.Treaty -> {
// Note: Treaties are not transfered from both sides due to notifications and double signing
if (offer.name == Constants.peaceTreaty) to.getDiplomacyManager(from).makePeace()
if (offer.name == Constants.peaceTreaty) to.getDiplomacyManager(from)!!.makePeace()
if (offer.name == Constants.researchAgreement) {
to.addGold(-offer.amount)
from.addGold(-offer.amount)
to.getDiplomacyManager(from)
to.getDiplomacyManager(from)!!
.setFlag(DiplomacyFlags.ResearchAgreement, offer.duration)
from.getDiplomacyManager(to)
from.getDiplomacyManager(to)!!
.setFlag(DiplomacyFlags.ResearchAgreement, offer.duration)
}
if (offer.name == Constants.defensivePact) to.getDiplomacyManager(from).signDefensivePact(offer.duration)
if (offer.name == Constants.defensivePact) to.getDiplomacyManager(from)!!.signDefensivePact(offer.duration)
}
TradeType.Introduction -> to.diplomacyFunctions.makeCivilizationsMeet(to.gameInfo.getCivilization(offer.name))
TradeType.WarDeclaration -> {
@ -145,7 +145,7 @@ class TradeLogic(val ourCivilization: Civilization, val otherCivilization: Civil
WarType.TeamWar
else WarType.JoinWar
from.getDiplomacyManager(nameOfCivToDeclareWarOn).declareWar(DeclareWarReason(warType, to))
from.getDiplomacyManager(nameOfCivToDeclareWarOn)!!.declareWar(DeclareWarReason(warType, to))
}
else -> {}
}

View File

@ -9,7 +9,6 @@ import com.unciv.logic.civilization.Civilization
import com.unciv.logic.civilization.EspionageAction
import com.unciv.logic.civilization.NotificationCategory
import com.unciv.logic.civilization.NotificationIcon
import com.unciv.logic.civilization.diplomacy.DiplomacyFunctions
import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers
import com.unciv.logic.civilization.managers.EspionageManager
import com.unciv.models.ruleset.unique.StateForConditionals
@ -239,7 +238,7 @@ class Spy private constructor() : IsPartOfGameInfoSerialization {
} else startStealingTech() // reset progress
if (spyResult >= 100) {
otherCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.SpiedOnUs, -15f)
otherCiv.getDiplomacyManager(civInfo)?.addModifier(DiplomaticModifiers.SpiedOnUs, -15f)
}
}
@ -259,29 +258,28 @@ class Spy private constructor() : IsPartOfGameInfoSerialization {
}
val cityState = getCity().civ
val allyCiv = cityState.getAllyCiv()?.let { civInfo.gameInfo.getCivilization(it) }
if (allyCiv?.knows(civInfo) == false) civInfo.diplomacyFunctions.makeCivilizationsMeet(allyCiv)
val successChance = getCoupChanceOfSuccess(true)
val randomValue = Random(randomSeed()).nextFloat()
if (randomValue <= successChance) {
// Success
val previousInfluence = if (allyCiv != null) cityState.getDiplomacyManager(allyCiv).getInfluence() else 80f
cityState.getDiplomacyManager(civInfo).setInfluence(previousInfluence)
val previousInfluence = if (allyCiv != null) cityState.getDiplomacyManager(allyCiv)!!.getInfluence() else 80f
cityState.getDiplomacyManager(civInfo)!!.setInfluence(previousInfluence)
civInfo.addNotification("Your spy [$name] successfully staged a coup in [${cityState.civName}]!", getCity().location,
NotificationCategory.Espionage, NotificationIcon.Spy, cityState.civName)
if (allyCiv != null) {
cityState.getDiplomacyManager(allyCiv).reduceInfluence(20f)
cityState.getDiplomacyManagerOrMeet(allyCiv).reduceInfluence(20f)
allyCiv.addNotification("A spy from [${civInfo.civName}] successfully staged a coup in our former ally [${cityState.civName}]!", getCity().location,
NotificationCategory.Espionage, civInfo.civName, NotificationIcon.Spy, cityState.civName)
allyCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.SpiedOnUs, -15f)
allyCiv.getDiplomacyManagerOrMeet(civInfo).addModifier(DiplomaticModifiers.SpiedOnUs, -15f)
}
for (civ in cityState.getKnownCivsWithSpectators()) {
if (civ == allyCiv || civ == civInfo) continue
civ.addNotification("A spy from [${civInfo.civName}] successfully staged a coup in [${cityState.civName}]!", getCity().location,
NotificationCategory.Espionage, civInfo.civName, NotificationIcon.Spy, cityState.civName)
if (civ.isSpectator()) continue
cityState.getDiplomacyManager(civ).reduceInfluence(10f) // Guess
cityState.getDiplomacyManager(civ)!!.reduceInfluence(10f) // Guess
}
setAction(SpyAction.RiggingElections, 10)
cityState.cityStateFunctions.updateAllyCivForCityState()
@ -289,10 +287,10 @@ class Spy private constructor() : IsPartOfGameInfoSerialization {
} else {
// Failure
val spy = allyCiv?.espionageManager?.getSpyAssignedToCity(getCity())
cityState.getDiplomacyManager(civInfo).addInfluence(-20f)
cityState.getDiplomacyManager(civInfo)!!.addInfluence(-20f)
allyCiv?.addNotification("A spy from [${civInfo.civName}] failed to stag a coup in our ally [${cityState.civName}] and was killed!", getCity().location,
NotificationCategory.Espionage, civInfo.civName, NotificationIcon.Spy, cityState.civName)
allyCiv?.getDiplomacyManager(civInfo)?.addModifier(DiplomaticModifiers.SpiedOnUs, -10f)
allyCiv?.getDiplomacyManagerOrMeet(civInfo)?.addModifier(DiplomaticModifiers.SpiedOnUs, -10f)
civInfo.addNotification("Our spy [$name] failed to stag a coup in [${cityState.civName}] and was killed!", getCity().location,
NotificationCategory.Espionage, civInfo.civName, NotificationIcon.Spy, cityState.civName)
@ -311,9 +309,9 @@ class Spy private constructor() : IsPartOfGameInfoSerialization {
// Influence difference should always be a positive value
var influenceDifference: Float = if (cityState.getAllyCiv() != null)
cityState.getDiplomacyManager(cityState.getAllyCiv()!!).getInfluence()
cityState.getDiplomacyManager(cityState.getAllyCiv()!!)!!.getInfluence()
else 60f
influenceDifference -= cityState.getDiplomacyManager(civInfo).getInfluence()
influenceDifference -= cityState.getDiplomacyManager(civInfo)!!.getInfluence()
successPercentage -= influenceDifference / 2f
// If we are viewing the success chance we don't want to reveal that there is a defending spy

View File

@ -432,7 +432,7 @@ class CityButton(val city: City, private val tileGroup: TileGroup) : Table(BaseS
val selectedPlayer = GUI.getSelectedPlayer()
// If city state - add influence bar
if (city.civ.isCityState() && city.civ.knows(selectedPlayer)) {
val diplomacyManager = city.civ.getDiplomacyManager(selectedPlayer)
val diplomacyManager = city.civ.getDiplomacyManager(selectedPlayer)!!
add(InfluenceTable(diplomacyManager.getInfluence(), diplomacyManager.relationshipLevel())).padTop(1f).row()
}

View File

@ -37,7 +37,7 @@ class CityStateDiplomacyTable(private val diplomacyScreen: DiplomacyScreen) {
val viewingCiv = diplomacyScreen.viewingCiv
fun getCityStateDiplomacyTable(otherCiv: Civilization): Table {
val otherCivDiplomacyManager = otherCiv.getDiplomacyManager(viewingCiv)
val otherCivDiplomacyManager = otherCiv.getDiplomacyManager(viewingCiv)!!
val diplomacyTable = getCityStateDiplomacyTableHeader(otherCiv)
@ -67,7 +67,7 @@ class CityStateDiplomacyTable(private val diplomacyScreen: DiplomacyScreen) {
diplomacyTable.add(demandTributeButton).row()
if (diplomacyScreen.isNotPlayersTurn() || viewingCiv.isAtWarWith(otherCiv)) demandTributeButton.disable()
val diplomacyManager = viewingCiv.getDiplomacyManager(otherCiv)
val diplomacyManager = viewingCiv.getDiplomacyManager(otherCiv)!!
if (!viewingCiv.gameInfo.ruleset.modOptions.hasUnique(UniqueType.DiplomaticRelationshipsCannotChange)) {
if (viewingCiv.isAtWarWith(otherCiv))
diplomacyTable.add(getNegotiatePeaceCityStateButton(otherCiv, diplomacyManager)).row()
@ -95,7 +95,7 @@ class CityStateDiplomacyTable(private val diplomacyScreen: DiplomacyScreen) {
private fun getCityStateDiplomacyTableHeader(otherCiv: Civilization): Table {
val otherCivDiplomacyManager = otherCiv.getDiplomacyManager(viewingCiv)
val otherCivDiplomacyManager = otherCiv.getDiplomacyManager(viewingCiv)!!
val diplomacyTable = Table()
diplomacyTable.defaults().pad(2.5f)
@ -130,7 +130,7 @@ class CityStateDiplomacyTable(private val diplomacyScreen: DiplomacyScreen) {
otherCiv.cityStateFunctions.updateAllyCivForCityState()
var ally = otherCiv.getAllyCiv()
if (ally != null) {
val allyInfluence = otherCiv.getDiplomacyManager(ally).getInfluence().toInt()
val allyInfluence = otherCiv.getDiplomacyManager(ally)!!.getInfluence().toInt()
if (!viewingCiv.knows(ally) && ally != viewingCiv.civName)
ally = "Unknown civilization"
diplomacyTable

View File

@ -139,7 +139,7 @@ class DiplomacyScreen(
val civIndicator = ImageGetter.getNationPortrait(civ.nation, nationIconSize)
val relationLevel = civ.getDiplomacyManager(viewingCiv).relationshipLevel()
val relationLevel = civ.getDiplomacyManager(viewingCiv)!!.relationshipLevel()
val relationshipIcon = if (civ.isCityState() && relationLevel == RelationshipLevel.Ally)
ImageGetter.getImage("OtherIcons/Star")
.surroundWithCircle(size = 30f, color = relationLevel.color).apply {

View File

@ -29,7 +29,7 @@ class MajorCivDiplomacyTable(private val diplomacyScreen: DiplomacyScreen) {
val viewingCiv = diplomacyScreen.viewingCiv
fun getMajorCivDiplomacyTable(otherCiv: Civilization): Table {
val otherCivDiplomacyManager = otherCiv.getDiplomacyManager(viewingCiv)
val otherCivDiplomacyManager = otherCiv.getDiplomacyManager(viewingCiv)!!
val diplomacyTable = Table()
diplomacyTable.defaults().pad(10f)
@ -50,7 +50,7 @@ class MajorCivDiplomacyTable(private val diplomacyScreen: DiplomacyScreen) {
val diplomaticRelationshipsCanChange =
!viewingCiv.gameInfo.ruleset.modOptions.hasUnique(UniqueType.DiplomaticRelationshipsCannotChange)
val diplomacyManager = viewingCiv.getDiplomacyManager(otherCiv)
val diplomacyManager = viewingCiv.getDiplomacyManager(otherCiv)!!
if (!viewingCiv.isAtWarWith(otherCiv)) {
diplomacyTable.add(getTradeButton(otherCiv)).row()

View File

@ -125,7 +125,7 @@ class AlertPopup(
val player = viewingCiv
addLeaderName(bullyOrAttacker)
val isAtLeastNeutral = bullyOrAttacker.getDiplomacyManager(player).isRelationshipLevelGE(RelationshipLevel.Neutral)
val isAtLeastNeutral = bullyOrAttacker.getDiplomacyManager(player)!!.isRelationshipLevelGE(RelationshipLevel.Neutral)
val text = when {
popupAlert.type == AlertType.BulliedProtectedMinor && isAtLeastNeutral -> // Nice message
"I've been informed that my armies have taken tribute from [${cityState.civName}], a city-state under your protection.\nI assure you, this was quite unintentional, and I hope that this does not serve to drive us apart."
@ -139,7 +139,7 @@ class AlertPopup(
addGoodSizedLabel(text).row()
addCloseButton("You'll pay for this!", KeyboardBinding.Confirm) {
player.getDiplomacyManager(bullyOrAttacker).sideWithCityState()
player.getDiplomacyManager(bullyOrAttacker)!!.sideWithCityState()
}.row()
addCloseButton("Very well.", KeyboardBinding.Cancel) {
player.addNotification("You have broken your Pledge to Protect [${cityState.civName}]!",
@ -202,7 +202,7 @@ class AlertPopup(
private fun addDeclarationOfFriendship() {
val otherciv = getCiv(popupAlert.value)
val playerDiploManager = viewingCiv.getDiplomacyManager(otherciv)
val playerDiploManager = viewingCiv.getDiplomacyManager(otherciv)!!
addLeaderName(otherciv)
addGoodSizedLabel("My friend, shall we declare our friendship to the world?").row()
addCloseButton("We are not interested.", KeyboardBinding.Cancel) {
@ -224,7 +224,7 @@ class AlertPopup(
private fun addDemandToStopSettlingCitiesNear() {
val otherciv = getCiv(popupAlert.value)
val playerDiploManager = viewingCiv.getDiplomacyManager(otherciv)
val playerDiploManager = viewingCiv.getDiplomacyManager(otherciv)!!
addLeaderName(otherciv)
addGoodSizedLabel("Please don't settle new cities near us.").row()
addCloseButton("Very well, we shall look for new lands to settle.", KeyboardBinding.Confirm) {
@ -306,18 +306,18 @@ class AlertPopup(
// Return it to original owner
val unitName = capturedUnit.baseUnit.name
capturedUnit.destroy()
val closestCity =
originalOwner.cities.minByOrNull { it.getCenterTile().aerialDistanceTo(tile) }
val closestCity = originalOwner.cities.minByOrNull { it.getCenterTile().aerialDistanceTo(tile) }
if (closestCity != null) {
// Attempt to place the unit near their nearest city
originalOwner.units.placeUnitNearTile(closestCity.location, unitName)
}
if (originalOwner.isCityState()) {
originalOwner.getDiplomacyManager(captor).addInfluence(45f)
originalOwner.getDiplomacyManagerOrMeet(captor).addInfluence(45f)
} else if (originalOwner.isMajorCiv()) {
// No extra bonus from doing it several times
originalOwner.getDiplomacyManager(captor)
originalOwner.getDiplomacyManagerOrMeet(captor)
.setModifier(DiplomaticModifiers.ReturnedCapturedUnits, 20f)
}
val notificationSequence = sequence {

View File

@ -341,14 +341,14 @@ object UnitActions {
checkCivInfoUniques = true
)) {
if (unit.matchesFilter(unique.params[1])) {
recipient.getDiplomacyManager(unit.civ)
recipient.getDiplomacyManager(unit.civ)!!
.addInfluence(unique.params[0].toFloat() - 5f)
break
}
}
recipient.getDiplomacyManager(unit.civ).addInfluence(5f)
} else recipient.getDiplomacyManager(unit.civ)
recipient.getDiplomacyManager(unit.civ)!!.addInfluence(5f)
} else recipient.getDiplomacyManager(unit.civ)!!
.addModifier(DiplomaticModifiers.GaveUsUnits, 5f)
if (recipient.isCityState() && unit.isGreatPerson())

View File

@ -106,7 +106,7 @@ object UnitActionsFromUniques {
private fun getLeadersWePromisedNotToSettleNear(civInfo: Civilization, tile: Tile): String? {
val leadersWePromisedNotToSettleNear = HashSet<String>()
for (otherCiv in civInfo.getKnownCivs().filter { it.isMajorCiv() && !civInfo.isAtWarWith(it) }) {
val diplomacyManager = otherCiv.getDiplomacyManager(civInfo)
val diplomacyManager = otherCiv.getDiplomacyManager(civInfo)!!
if (diplomacyManager.hasFlag(DiplomacyFlags.AgreedToNotSettleNearUs)) {
val citiesWithin6Tiles = otherCiv.cities
.filter { it.getCenterTile().aerialDistanceTo(tile) <= 6 }

View File

@ -114,7 +114,7 @@ object UnitActionsGreatPerson {
unit.civ.addGold(goldEarned.toInt())
val tileOwningCiv = tile.owningCity!!.civ
tileOwningCiv.getDiplomacyManager(unit.civ).addInfluence(influenceEarned)
tileOwningCiv.getDiplomacyManager(unit.civ)!!.addInfluence(influenceEarned)
unit.civ.addNotification("Your trade mission to [$tileOwningCiv] has earned you [$goldEarned] gold and [$influenceEarned] influence!",
NotificationCategory.General, tileOwningCiv.civName, NotificationIcon.Gold, NotificationIcon.Culture)
unit.consume()

View File

@ -381,8 +381,8 @@ class BattleTest {
Battle.attackOrNuke(MapUnitCombatant(attackerUnit), AttackableTile(attackerUnit.getTile(), defaultDefenderUnit.currentTile, 0f, null))
// then
assertEquals(-75f, defenderCiv.getDiplomacyManager(attackerCiv).opinionOfOtherCiv()) // 50 for nuke, 25 for war declaration
assertEquals(-55f, thirdCiv.getDiplomacyManager(attackerCiv).opinionOfOtherCiv()) // 50 for nuke, 5 for warmongering
assertEquals(-75f, defenderCiv.getDiplomacyManager(attackerCiv)!!.opinionOfOtherCiv()) // 50 for nuke, 25 for war declaration
assertEquals(-55f, thirdCiv.getDiplomacyManager(attackerCiv)!!.opinionOfOtherCiv()) // 50 for nuke, 5 for warmongering
}
@Test

View File

@ -46,8 +46,8 @@ class CapitalConnectionsFinderTests {
}
private fun meetCivAndSetBorders(civ: Civilization, areBordersOpen: Boolean) {
ourCiv.getDiplomacyManager(civ).makePeace()
ourCiv.getDiplomacyManager(civ).hasOpenBorders = areBordersOpen
ourCiv.getDiplomacyManager(civ)!!.makePeace()
ourCiv.getDiplomacyManager(civ)!!.hasOpenBorders = areBordersOpen
}
@Test
@ -167,12 +167,12 @@ class CapitalConnectionsFinderTests {
val openCiv = testGame.addCiv(cityStateType = "Cultured")
val openCivCapital = testGame.addCity(openCiv, testGame.tileMap[0, 2])
ourCiv.getDiplomacyManager(openCiv).makePeace()
ourCiv.getDiplomacyManager(openCiv)!!.makePeace()
val closedCiv = testGame.addCiv(cityStateType = "Cultured")
val closedCivCapital = testGame.addCity(closedCiv, testGame.tileMap[0, -2])
ourCiv.diplomacyFunctions.makeCivilizationsMeet(closedCiv)
ourCiv.getDiplomacyManager(closedCiv).declareWar()
ourCiv.getDiplomacyManager(closedCiv)!!.declareWar()
createMedium(-4,-2, RoadStatus.Railroad)

View File

@ -31,7 +31,7 @@ class CityMovingTests {
civInfo.tech.addTechnology(tech)
civInfo.diplomacyFunctions.makeCivilizationsMeet(enemy)
civInfo.getDiplomacyManager(enemy).declareWar()
civInfo.getDiplomacyManager(enemy)!!.declareWar()
}
@Test

View File

@ -29,42 +29,42 @@ class DefensivePactTests {
@Test
fun `Civs with Defensive Pacts are called in`() {
meetAll()
a.getDiplomacyManager(b).signDefensivePact(100)
Assert.assertTrue(a.getDiplomacyManager(b).diplomaticStatus == DiplomaticStatus.DefensivePact
&& b.getDiplomacyManager(a).diplomaticStatus == DiplomaticStatus.DefensivePact)
c.getDiplomacyManager(a).declareWar()
a.getDiplomacyManager(b)!!.signDefensivePact(100)
Assert.assertTrue(a.getDiplomacyManager(b)!!.diplomaticStatus == DiplomaticStatus.DefensivePact
&& b.getDiplomacyManager(a)!!.diplomaticStatus == DiplomaticStatus.DefensivePact)
c.getDiplomacyManager(a)!!.declareWar()
Assert.assertTrue(c.isAtWarWith(b) && c.isAtWarWith(a))
Assert.assertTrue(b.isAtWarWith(c) && a.isAtWarWith(c))
Assert.assertTrue(b.getDiplomacyManager(a).diplomaticStatus == DiplomaticStatus.DefensivePact
|| b.getDiplomacyManager(a).diplomaticStatus == DiplomaticStatus.DefensivePact)
Assert.assertTrue(b.getDiplomacyManager(a)!!.diplomaticStatus == DiplomaticStatus.DefensivePact
|| b.getDiplomacyManager(a)!!.diplomaticStatus == DiplomaticStatus.DefensivePact)
}
@Test
fun `Defensive Pact cancel when attacking`() {
meetAll()
a.getDiplomacyManager(b).signDefensivePact(100)
a.getDiplomacyManager(c).declareWar()
a.getDiplomacyManager(b)!!.signDefensivePact(100)
a.getDiplomacyManager(c)!!.declareWar()
Assert.assertFalse(a.getDiplomacyManager(b).diplomaticStatus == DiplomaticStatus.DefensivePact)
Assert.assertFalse(a.getDiplomacyManager(b)!!.diplomaticStatus == DiplomaticStatus.DefensivePact)
}
@Test
fun `Defensive Pact timeout`() {
meetAll()
a.getDiplomacyManager(b).signDefensivePact(1)
Assert.assertTrue(a.getDiplomacyManager(b).diplomaticStatus == DiplomaticStatus.DefensivePact)
a.getDiplomacyManager(b).nextTurn()
b.getDiplomacyManager(a).nextTurn()
a.getDiplomacyManager(b)!!.signDefensivePact(1)
Assert.assertTrue(a.getDiplomacyManager(b)!!.diplomaticStatus == DiplomaticStatus.DefensivePact)
a.getDiplomacyManager(b)!!.nextTurn()
b.getDiplomacyManager(a)!!.nextTurn()
Assert.assertFalse(a.getDiplomacyManager(b).diplomaticStatus == DiplomaticStatus.DefensivePact
|| b.getDiplomacyManager(a).diplomaticStatus == DiplomaticStatus.DefensivePact)
Assert.assertFalse(a.getDiplomacyManager(b)!!.diplomaticStatus == DiplomaticStatus.DefensivePact
|| b.getDiplomacyManager(a)!!.diplomaticStatus == DiplomaticStatus.DefensivePact)
}
@Test
fun `Breaking Defensive Pact`() {
meetAll()
val abDiploManager = a.getDiplomacyManager(b)
val abDiploManager = a.getDiplomacyManager(b)!!
abDiploManager.signDefensivePact(100)
abDiploManager.declareWar()
Assert.assertTrue(abDiploManager.otherCivDiplomacy().hasModifier(DiplomaticModifiers.BetrayedDefensivePact)) // Defender should be extra mad
@ -75,12 +75,12 @@ class DefensivePactTests {
@Test
fun `Breaking Defensive Pact with friends`() {
meetAll()
val abDiploManager = a.getDiplomacyManager(b)
val bcDiploManager = b.getDiplomacyManager(c)
val abDiploManager = a.getDiplomacyManager(b)!!
val bcDiploManager = b.getDiplomacyManager(c)!!
abDiploManager.signDefensivePact(100)
bcDiploManager.signDeclarationOfFriendship()
abDiploManager.declareWar()
Assert.assertTrue(c.getDiplomacyManager(a).hasModifier(DiplomaticModifiers.BetrayedDefensivePact))
Assert.assertTrue(c.getDiplomacyManager(a)!!.hasModifier(DiplomaticModifiers.BetrayedDefensivePact))
}
}

View File

@ -39,7 +39,7 @@ class DiplomacyManagerTests {
@Test
fun `getCommonKnownCivs does not include either DiplomacyManagers's civs`() {
meet(a, b)
val commonKnownCivs = a.getDiplomacyManager(b).getCommonKnownCivs()
val commonKnownCivs = a.getDiplomacyManager(b)!!.getCommonKnownCivs()
assertTrue(a !in commonKnownCivs)
assertTrue(b !in commonKnownCivs)
@ -50,7 +50,7 @@ class DiplomacyManagerTests {
meet(a,b)
meet(b,c)
meet(c,a)
val commonKnownCivs = a.getDiplomacyManager(b).getCommonKnownCivs()
val commonKnownCivs = a.getDiplomacyManager(b)!!.getCommonKnownCivs()
assertTrue(c in commonKnownCivs)
}
@ -59,7 +59,7 @@ class DiplomacyManagerTests {
fun `getCommonKnownCivs does not include civs met by only one civ`() {
meet(a,b)
meet(a,c)
val commonKnownCivs = a.getDiplomacyManager(b).getCommonKnownCivs()
val commonKnownCivs = a.getDiplomacyManager(b)!!.getCommonKnownCivs()
assertTrue(c !in commonKnownCivs)
}
@ -73,8 +73,8 @@ class DiplomacyManagerTests {
meet(b,d)
assertEquals(
a.getDiplomacyManager(b).getCommonKnownCivs(),
b.getDiplomacyManager(a).getCommonKnownCivs()
a.getDiplomacyManager(b)!!.getCommonKnownCivs(),
b.getDiplomacyManager(a)!!.getCommonKnownCivs()
)
}
@ -84,7 +84,7 @@ class DiplomacyManagerTests {
meet(a, b)
// then
val opinionOfOtherCiv = a.getDiplomacyManager(b.civName).opinionOfOtherCiv()
val opinionOfOtherCiv = a.getDiplomacyManager(b.civName)!!.opinionOfOtherCiv()
assertEquals(0f, opinionOfOtherCiv)
}
@ -94,11 +94,11 @@ class DiplomacyManagerTests {
meet(a, b)
// when
a.getDiplomacyManager(b).denounce()
a.getDiplomacyManager(b)!!.denounce()
// then
val aOpinionOfB = a.getDiplomacyManager(b.civName).opinionOfOtherCiv()
val bOpinionOfA = b.getDiplomacyManager(a.civName).opinionOfOtherCiv()
val aOpinionOfB = a.getDiplomacyManager(b.civName)!!.opinionOfOtherCiv()
val bOpinionOfA = b.getDiplomacyManager(a.civName)!!.opinionOfOtherCiv()
assertEquals(-35f, aOpinionOfB)
assertEquals(-35f, bOpinionOfA)
@ -125,10 +125,10 @@ class DiplomacyManagerTests {
bCity.liberateCity(a)
// then
val aOpinionOfB = a.getDiplomacyManager(b.civName).opinionOfOtherCiv()
val bOpinionOfA = b.getDiplomacyManager(a.civName).opinionOfOtherCiv()
val cOpinionOfA = c.getDiplomacyManager(a.civName).opinionOfOtherCiv()
val dOpinionOfA = d.getDiplomacyManager(a.civName).opinionOfOtherCiv()
val aOpinionOfB = a.getDiplomacyManager(b.civName)!!.opinionOfOtherCiv()
val bOpinionOfA = b.getDiplomacyManager(a.civName)!!.opinionOfOtherCiv()
val cOpinionOfA = c.getDiplomacyManager(a.civName)!!.opinionOfOtherCiv()
val dOpinionOfA = d.getDiplomacyManager(a.civName)!!.opinionOfOtherCiv()
assertEquals(0f, aOpinionOfB) // A shouldn't change its opinion of others
assertEquals(121f, bOpinionOfA) // massive boost, liberated their city
@ -153,9 +153,9 @@ class DiplomacyManagerTests {
bCity.puppetCity(a)
// then
val aOpinionOfB = a.getDiplomacyManager(b.civName).opinionOfOtherCiv()
val bOpinionOfA = b.getDiplomacyManager(a.civName).opinionOfOtherCiv()
val cOpinionOfA = c.getDiplomacyManager(a.civName).opinionOfOtherCiv()
val aOpinionOfB = a.getDiplomacyManager(b.civName)!!.opinionOfOtherCiv()
val bOpinionOfA = b.getDiplomacyManager(a.civName)!!.opinionOfOtherCiv()
val cOpinionOfA = c.getDiplomacyManager(a.civName)!!.opinionOfOtherCiv()
assertEquals(0f, aOpinionOfB) // A shouldn't change its opinion of others
assertEquals(-121f, bOpinionOfA) // massive penality, conquered their city
@ -169,10 +169,10 @@ class DiplomacyManagerTests {
meet(a, cityState)
// when
cityState.getDiplomacyManager(a).addInfluence(31f)
cityState.getDiplomacyManager(a)!!.addInfluence(31f)
// then
assertTrue(cityState.getDiplomacyManager(a).isRelationshipLevelEQ(RelationshipLevel.Friend))
assertTrue(cityState.getDiplomacyManager(a)!!.isRelationshipLevelEQ(RelationshipLevel.Friend))
}
@Test
@ -182,10 +182,10 @@ class DiplomacyManagerTests {
meet(a, cityState)
// when
cityState.getDiplomacyManager(a).addInfluence(61f)
cityState.getDiplomacyManager(a)!!.addInfluence(61f)
// then
assertTrue(cityState.getDiplomacyManager(a).isRelationshipLevelEQ(RelationshipLevel.Ally))
assertTrue(cityState.getDiplomacyManager(a)!!.isRelationshipLevelEQ(RelationshipLevel.Ally))
}
@Test
@ -194,14 +194,14 @@ class DiplomacyManagerTests {
val cityState = addCiv(cityStateType = "Militaristic")
meet(a, cityState)
meet(b, cityState)
cityState.getDiplomacyManager(a).addInfluence(70f)
cityState.getDiplomacyManager(a)!!.addInfluence(70f)
// when
cityState.getDiplomacyManager(b).addInfluence(61f)
cityState.getDiplomacyManager(b)!!.addInfluence(61f)
// then
assertTrue(cityState.getDiplomacyManager(a).isRelationshipLevelEQ(RelationshipLevel.Ally))
assertTrue(cityState.getDiplomacyManager(b).isRelationshipLevelEQ(RelationshipLevel.Friend))
assertTrue(cityState.getDiplomacyManager(a)!!.isRelationshipLevelEQ(RelationshipLevel.Ally))
assertTrue(cityState.getDiplomacyManager(b)!!.isRelationshipLevelEQ(RelationshipLevel.Friend))
}
@Test
@ -210,14 +210,14 @@ class DiplomacyManagerTests {
val cityState = addCiv(cityStateType = "Militaristic")
meet(a, cityState)
meet(b, cityState)
cityState.getDiplomacyManager(a).addInfluence(61f)
cityState.getDiplomacyManager(a)!!.addInfluence(61f)
// when
cityState.getDiplomacyManager(b).addInfluence(70f)
cityState.getDiplomacyManager(b)!!.addInfluence(70f)
// then
assertTrue(cityState.getDiplomacyManager(a).isRelationshipLevelEQ(RelationshipLevel.Friend))
assertTrue(cityState.getDiplomacyManager(b).isRelationshipLevelEQ(RelationshipLevel.Ally))
assertTrue(cityState.getDiplomacyManager(a)!!.isRelationshipLevelEQ(RelationshipLevel.Friend))
assertTrue(cityState.getDiplomacyManager(b)!!.isRelationshipLevelEQ(RelationshipLevel.Ally))
}
@Test
@ -225,14 +225,14 @@ class DiplomacyManagerTests {
// given
val cityState = addCiv(cityStateType = "Militaristic")
meet(a, cityState)
cityState.getDiplomacyManager(a).addInfluence(61f)
cityState.getDiplomacyManager(a)!!.addInfluence(61f)
// when
a.getDiplomacyManager(cityState).declareWar()
a.getDiplomacyManager(cityState)!!.declareWar()
// then
assertTrue(cityState.getDiplomacyManager(a).isRelationshipLevelEQ(RelationshipLevel.Unforgivable))
assertEquals(-60f, cityState.getDiplomacyManager(a).getInfluence())
assertTrue(cityState.getDiplomacyManager(a)!!.isRelationshipLevelEQ(RelationshipLevel.Unforgivable))
assertEquals(-60f, cityState.getDiplomacyManager(a)!!.getInfluence())
}
@Test
@ -242,15 +242,15 @@ class DiplomacyManagerTests {
val e = addCiv(defaultUnitTile = testGame.getTile(Vector2.X))
meet(e, cityState)
// we cannot be allied and simoultaneously having a city state declare indirect war on us
cityState.getDiplomacyManager(e).addInfluence(31f)
cityState.getDiplomacyManager(e).declareWar(DeclareWarReason(WarType.DefensivePactWar, a))
cityState.getDiplomacyManager(e)!!.addInfluence(31f)
cityState.getDiplomacyManager(e)!!.declareWar(DeclareWarReason(WarType.DefensivePactWar, a))
// when
e.getDiplomacyManager(cityState).makePeace()
e.getDiplomacyManager(cityState)!!.makePeace()
// then
assertTrue(cityState.getDiplomacyManager(e).isRelationshipLevelEQ(RelationshipLevel.Friend))
assertEquals(31f, cityState.getDiplomacyManager(e).getInfluence())
assertTrue(cityState.getDiplomacyManager(e)!!.isRelationshipLevelEQ(RelationshipLevel.Friend))
assertEquals(31f, cityState.getDiplomacyManager(e)!!.getInfluence())
}
@Test
@ -260,13 +260,13 @@ class DiplomacyManagerTests {
cityState.cityStatePersonality = CityStatePersonality.Neutral
meet(a, cityState)
cityState.getDiplomacyManager(a).addInfluence(30f)
cityState.getDiplomacyManager(a)!!.addInfluence(30f)
// when
cityState.getDiplomacyManager(a).nextTurn()
cityState.getDiplomacyManager(a)!!.nextTurn()
// then
assertEquals(29f, cityState.getDiplomacyManager(a).getInfluence())
assertEquals(29f, cityState.getDiplomacyManager(a)!!.getInfluence())
}
@Test
@ -276,13 +276,13 @@ class DiplomacyManagerTests {
cityState.cityStatePersonality = CityStatePersonality.Hostile
meet(a, cityState)
cityState.getDiplomacyManager(a).addInfluence(30f)
cityState.getDiplomacyManager(a)!!.addInfluence(30f)
// when
cityState.getDiplomacyManager(a).nextTurn()
cityState.getDiplomacyManager(a)!!.nextTurn()
// then
assertEquals(28.5f, cityState.getDiplomacyManager(a).getInfluence())
assertEquals(28.5f, cityState.getDiplomacyManager(a)!!.getInfluence())
}
@Test
@ -302,13 +302,13 @@ class DiplomacyManagerTests {
religion.founderBeliefs.add(belief.name)
cityStateCapital.religion.addPressure(religion.name, 1000)
cityState.getDiplomacyManager(a).addInfluence(30f)
cityState.getDiplomacyManager(a)!!.addInfluence(30f)
// when
cityState.getDiplomacyManager(a).nextTurn()
cityState.getDiplomacyManager(a)!!.nextTurn()
// then
assertEquals(29.25f, cityState.getDiplomacyManager(a).getInfluence())
assertEquals(29.25f, cityState.getDiplomacyManager(a)!!.getInfluence())
}
@Test
@ -318,13 +318,13 @@ class DiplomacyManagerTests {
cityState.cityStatePersonality = CityStatePersonality.Neutral
meet(a, cityState)
cityState.getDiplomacyManager(a).addInfluence(-30f)
cityState.getDiplomacyManager(a)!!.addInfluence(-30f)
// when
cityState.getDiplomacyManager(a).nextTurn()
cityState.getDiplomacyManager(a)!!.nextTurn()
// then
assertEquals(-29f, cityState.getDiplomacyManager(a).getInfluence())
assertEquals(-29f, cityState.getDiplomacyManager(a)!!.getInfluence())
}
@Test
@ -343,13 +343,13 @@ class DiplomacyManagerTests {
religion.founderBeliefs.add(belief.name)
cityStateCapital.religion.addPressure(religion.name, 1000)
cityState.getDiplomacyManager(a).addInfluence(-30f)
cityState.getDiplomacyManager(a)!!.addInfluence(-30f)
// when
cityState.getDiplomacyManager(a).nextTurn()
cityState.getDiplomacyManager(a)!!.nextTurn()
// then
assertEquals(-28.5f, cityState.getDiplomacyManager(a).getInfluence())
assertEquals(-28.5f, cityState.getDiplomacyManager(a)!!.getInfluence())
}
@Test
@ -364,16 +364,16 @@ class DiplomacyManagerTests {
val turns = 10
// when
a.getDiplomacyManager(b).setFlag(DiplomacyFlags.ResearchAgreement, turns)
b.getDiplomacyManager(a).setFlag(DiplomacyFlags.ResearchAgreement, turns)
a.getDiplomacyManager(b)!!.setFlag(DiplomacyFlags.ResearchAgreement, turns)
b.getDiplomacyManager(a)!!.setFlag(DiplomacyFlags.ResearchAgreement, turns)
repeat(turns) {
a.getDiplomacyManager(b).nextTurn()
b.getDiplomacyManager(a).nextTurn()
a.getDiplomacyManager(b)!!.nextTurn()
b.getDiplomacyManager(a)!!.nextTurn()
}
// then
assertFalse(a.getDiplomacyManager(b).hasFlag(DiplomacyFlags.ResearchAgreement))
assertFalse(b.getDiplomacyManager(a).hasFlag(DiplomacyFlags.ResearchAgreement))
assertFalse(a.getDiplomacyManager(b)!!.hasFlag(DiplomacyFlags.ResearchAgreement))
assertFalse(b.getDiplomacyManager(a)!!.hasFlag(DiplomacyFlags.ResearchAgreement))
assertEquals(expectedSciencePerTurnCivA * turns, a.tech.scienceFromResearchAgreements)
assertEquals(expectedSciencePerTurnCivA * turns, b.tech.scienceFromResearchAgreements)
}

View File

@ -27,8 +27,8 @@ class GoldGiftingTests {
@Before
fun setUp() {
a.diplomacyFunctions.makeCivilizationsMeet(b)
aDiplomacy = a.getDiplomacyManager(b)
bDiplomacy = b.getDiplomacyManager(a)
aDiplomacy = a.getDiplomacyManager(b)!!
bDiplomacy = b.getDiplomacyManager(a)!!
}
@Test

View File

@ -26,7 +26,7 @@ class ThreatManangerTests {
testGame.makeHexagonalMap(10)
civ.diplomacyFunctions.makeCivilizationsMeet(enemyCiv)
civ.diplomacyFunctions.makeCivilizationsMeet(neutralCiv)
civ.getDiplomacyManager(enemyCiv).declareWar()
civ.getDiplomacyManager(enemyCiv)!!.declareWar()
}
@After

View File

@ -214,7 +214,7 @@ internal class UnitFormationTests {
setUp(3)
val enemyCiv = testGame.addCiv()
civInfo.diplomacyFunctions.makeCivilizationsMeet(enemyCiv)
civInfo.getDiplomacyManager(enemyCiv).declareWar()
civInfo.getDiplomacyManager(enemyCiv)!!.declareWar()
val centerTile = testGame.getTile(Vector2(0f,0f))
val enemyTile = testGame.getTile(Vector2(2f,2f))
val scout = testGame.addUnit("Warrior", civInfo, centerTile)
@ -240,7 +240,7 @@ internal class UnitFormationTests {
val enemyCiv = testGame.addCiv()
DebugUtils.VISIBLE_MAP = true
civInfo.diplomacyFunctions.makeCivilizationsMeet(enemyCiv)
civInfo.getDiplomacyManager(enemyCiv).declareWar()
civInfo.getDiplomacyManager(enemyCiv)!!.declareWar()
val centerTile = testGame.getTile(Vector2(0f,0f))
val enemyTile = testGame.getTile(Vector2(3f,3f))
val archer = testGame.addUnit("Archer", civInfo, centerTile)
@ -264,7 +264,7 @@ internal class UnitFormationTests {
setUp(3)
val enemyCiv = testGame.addCiv()
civInfo.diplomacyFunctions.makeCivilizationsMeet(enemyCiv)
civInfo.getDiplomacyManager(enemyCiv).declareWar()
civInfo.getDiplomacyManager(enemyCiv)!!.declareWar()
val centerTile = testGame.getTile(Vector2(0f,0f))
val forestTile = testGame.getTile(Vector2(1f,1f))
val enemyTile = testGame.getTile(Vector2(2f,2f))

View File

@ -201,7 +201,7 @@ class UnitMovementTests {
city.hasJustBeenConquered = true
civInfo.diplomacy[otherCiv.civName] = DiplomacyManager(otherCiv, otherCiv.civName)
civInfo.getDiplomacyManager(otherCiv).diplomaticStatus = DiplomaticStatus.War
civInfo.getDiplomacyManager(otherCiv)!!.diplomaticStatus = DiplomaticStatus.War
Assert.assertTrue("Unit can capture other civ city", unit.movement.canPassThrough(tile))
}
@ -271,7 +271,7 @@ class UnitMovementTests {
// Place an enemy civilian unit on that tile
val atWarCiv = testGame.addCiv()
atWarCiv.diplomacyFunctions.makeCivilizationsMeet(civInfo)
atWarCiv.getDiplomacyManager(civInfo).declareWar()
atWarCiv.getDiplomacyManager(civInfo)!!.declareWar()
val enemyWorkerUnit = testGame.addUnit("Worker", atWarCiv, testGame.tileMap[1,2])
val otherCiv = testGame.addCiv()

View File

@ -375,7 +375,7 @@ class GlobalUniquesTests {
@Suppress("UNUSED_VARIABLE")
val cityStateCity = game.addCity(cityState, cityStateTile, true)
civInfo.diplomacyFunctions.makeCivilizationsMeet(cityState)
cityState.getDiplomacyManager(civInfo).addInfluence(100f)
cityState.getDiplomacyManager(civInfo)!!.addInfluence(100f)
city.cityStats.update()
Assert.assertTrue(city.cityStats.finalStatList[Constants.cityStates]!!.food == 3f)