Resolved #752 - Added big friendship penalty for betraying declaration of friendship

This commit is contained in:
Yair Morgenstern
2019-05-17 15:00:24 +03:00
parent 0e54a1b91c
commit 054b3b000d
3 changed files with 36 additions and 22 deletions

View File

@ -2673,6 +2673,9 @@
Simplified_Chinese:"开放的边界促进了彼此的了解,让我们的人民心心相通!" Simplified_Chinese:"开放的边界促进了彼此的了解,让我们的人民心心相通!"
} }
"Your so-called 'friendship' is worth nothing.":{ // When we have a decleration of friendship to someone and we declare war on them
}
////// Overview screen ////// Overview screen
"Overview":{ "Overview":{

View File

@ -35,6 +35,7 @@ enum class DiplomaticModifiers{
WarMongerer, WarMongerer,
CapturedOurCities, CapturedOurCities,
DeclaredFriendshipWithOurEnemies, DeclaredFriendshipWithOurEnemies,
BetrayedDeclarationOfFriendship,
YearsOfPeace, YearsOfPeace,
SharedEnemy, SharedEnemy,
@ -213,15 +214,17 @@ class DiplomacyManager() {
var openBorders = 0 var openBorders = 0
if(hasOpenBorders) openBorders+=1 if(hasOpenBorders) openBorders+=1
if(otherCivDiplomacy().hasOpenBorders) openBorders+=1 if(otherCivDiplomacy().hasOpenBorders) openBorders+=1
if(openBorders>0) addModifier(DiplomaticModifiers.OpenBorders,openBorders/8f) // so if we both have open borders it'll grow by 0.25 per turn if(openBorders>0) addModifier(DiplomaticModifiers.OpenBorders,openBorders/8f) // so if we both have open borders it'll grow by 0.25 per turn
else revertToZero(DiplomaticModifiers.OpenBorders, 1/8f) else revertToZero(DiplomaticModifiers.OpenBorders, 1/8f)
revertToZero(DiplomaticModifiers.DeclaredWarOnUs,1/8f) // this disappears real slow - it'll take 160 turns to really forget, this is war declaration we're talking about revertToZero(DiplomaticModifiers.DeclaredWarOnUs,1/8f) // this disappears real slow - it'll take 160 turns to really forget, this is war declaration we're talking about
revertToZero(DiplomaticModifiers.WarMongerer,0.5f) // warmongering gives a big negative boost when it happens but they're forgotten relatively quickly, like WWII amirite revertToZero(DiplomaticModifiers.WarMongerer,1/2f) // warmongering gives a big negative boost when it happens but they're forgotten relatively quickly, like WWII amirite
revertToZero(DiplomaticModifiers.CapturedOurCities,1/4f) // if you captured our cities, though, that's harder to forget revertToZero(DiplomaticModifiers.CapturedOurCities,1/4f) // if you captured our cities, though, that's harder to forget
revertToZero(DiplomaticModifiers.BetrayedDeclarationOfFriendship,1/2f) // if you captured our cities, though, that's harder to forget
if(!hasFlag(DiplomacyFlags.DeclarationOfFriendship)) if(!hasFlag(DiplomacyFlags.DeclarationOfFriendship))
revertToZero(DiplomaticModifiers.DeclarationOfFriendship, 0.5f) //decreases slowly and will revert to full if it is declared later revertToZero(DiplomaticModifiers.DeclarationOfFriendship, 1/2f) //decreases slowly and will revert to full if it is declared later
for(flag in flagsCountdown.keys.toList()) { for(flag in flagsCountdown.keys.toList()) {
flagsCountdown[flag] = flagsCountdown[flag]!! - 1 flagsCountdown[flag] = flagsCountdown[flag]!! - 1
@ -238,10 +241,9 @@ class DiplomacyManager() {
} }
fun declareWar(){ /** Everything that happens to both sides equally when war is delcared by one side on the other */
private fun onWarDeclared(){
diplomaticStatus = DiplomaticStatus.War diplomaticStatus = DiplomaticStatus.War
val otherCiv = otherCiv()
val otherCivDiplomacy = otherCiv.getDiplomacyManager(civInfo)
// Cancel all trades. // Cancel all trades.
for(trade in trades) for(trade in trades)
@ -250,35 +252,40 @@ class DiplomacyManager() {
trades.clear() trades.clear()
updateHasOpenBorders() updateHasOpenBorders()
for(trade in otherCivDiplomacy.trades) setFlag(DiplomacyFlags.DeclinedPeace,10)/// AI won't propose peace for 10 turns
for(offer in trade.theirOffers.filter { it.duration>0 }) setFlag(DiplomacyFlags.DeclaredWar,10) // AI won't agree to trade for 10 turns
otherCiv.addNotification("["+offer.name+"] from [$otherCivName] has ended",null, Color.GOLD) removeFlag(DiplomacyFlags.BorderConflict)
otherCivDiplomacy.trades.clear() }
otherCivDiplomacy.updateHasOpenBorders()
fun declareWar(){
val otherCiv = otherCiv()
val otherCivDiplomacy = otherCivDiplomacy()
onWarDeclared()
otherCivDiplomacy.onWarDeclared()
otherCiv.getDiplomacyManager(civInfo).diplomaticStatus = DiplomaticStatus.War
otherCiv.addNotification("[${civInfo.civName}] has declared war on us!",null, Color.RED) otherCiv.addNotification("[${civInfo.civName}] has declared war on us!",null, Color.RED)
otherCiv.popupAlerts.add(PopupAlert(AlertType.WarDeclaration,civInfo.civName)) otherCiv.popupAlerts.add(PopupAlert(AlertType.WarDeclaration,civInfo.civName))
/// AI won't propose peace for 10 turns
setFlag(DiplomacyFlags.DeclinedPeace,10)
otherCiv.getDiplomacyManager(civInfo).setFlag(DiplomacyFlags.DeclinedPeace,10)
// AI won't agree to trade for 10 turns
setFlag(DiplomacyFlags.DeclaredWar,10)
otherCiv.getDiplomacyManager(civInfo).setFlag(DiplomacyFlags.DeclaredWar,10)
otherCivDiplomacy.setModifier(DiplomaticModifiers.DeclaredWarOnUs,-20f) otherCivDiplomacy.setModifier(DiplomaticModifiers.DeclaredWarOnUs,-20f)
removeFlag(DiplomacyFlags.BorderConflict)
otherCivDiplomacy.removeFlag(DiplomacyFlags.BorderConflict)
for(thirdCiv in civInfo.getKnownCivs()){ for(thirdCiv in civInfo.getKnownCivs()){
if(thirdCiv.isAtWarWith(otherCiv)) if(thirdCiv.isAtWarWith(otherCiv))
thirdCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.WarMongerer,5f) thirdCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.WarMongerer,5f)
else thirdCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.WarMongerer,-5f) else thirdCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.WarMongerer,-5f)
} }
if(hasFlag(DiplomacyFlags.DeclarationOfFriendship)){
removeFlag(DiplomacyFlags.DeclarationOfFriendship)
otherCivDiplomacy.removeModifier(DiplomaticModifiers.DeclarationOfFriendship)
for(knownCiv in civInfo.getKnownCivs()){
val amount = if(knownCiv==otherCiv) -40f else -20f
val diploManager = knownCiv.getDiplomacyManager(civInfo)
diploManager.addModifier(DiplomaticModifiers.BetrayedDeclarationOfFriendship, amount)
diploManager.removeModifier(DiplomaticModifiers.DeclaredFriendshipWithOurAllies) // obviously this guy's declarations of friendship aren't worth much.
}
}
otherCivDiplomacy.removeFlag(DiplomacyFlags.DeclarationOfFriendship)
} }
fun makePeace(){ fun makePeace(){
@ -309,6 +316,9 @@ class DiplomacyManager() {
diplomaticModifiers[modifierString] = amount diplomaticModifiers[modifierString] = amount
} }
fun removeModifier(modifier: DiplomaticModifiers) =
diplomaticModifiers.remove(modifier.toString())
fun hasModifier(modifier: DiplomaticModifiers) = diplomaticModifiers.containsKey(modifier.toString()) fun hasModifier(modifier: DiplomaticModifiers) = diplomaticModifiers.containsKey(modifier.toString())
/** @param amount always positive, so you don't need to think about it */ /** @param amount always positive, so you don't need to think about it */

View File

@ -220,6 +220,7 @@ class DiplomacyScreen:CameraStageBaseScreen() {
DeclaredFriendshipWithOurEnemies -> "You have declared friendship with our enemies!" DeclaredFriendshipWithOurEnemies -> "You have declared friendship with our enemies!"
DeclaredFriendshipWithOurAllies -> "You have declared friendship with our allies" DeclaredFriendshipWithOurAllies -> "You have declared friendship with our allies"
OpenBorders -> "Our open borders have brought us closer together." OpenBorders -> "Our open borders have brought us closer together."
BetrayedDeclarationOfFriendship -> "Your so-called 'friendship' is worth nothing."
} }
text = text.tr() + " " text = text.tr() + " "
if (modifier.value > 0) text += "+" if (modifier.value > 0) text += "+"