mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-20 09:17:47 +07:00
Diplomacy is ready to be unleashed upon the unsuspecting public!
This commit is contained in:
parent
b4fc129a9b
commit
e8f27c4ef4
@ -4869,6 +4869,23 @@
|
||||
Simplified_Chinese:"很高兴见到你."
|
||||
}
|
||||
|
||||
"Our relationship: ":{}
|
||||
|
||||
"Unforgivable":{}
|
||||
"Enemy":{}
|
||||
"Competitor":{}
|
||||
"Neutral":{}
|
||||
"Favorable":{}
|
||||
"Friend":{}
|
||||
"Ally":{}
|
||||
|
||||
// Diplomatic modifiers
|
||||
"You declared war on us!":{}
|
||||
"Your warmongering ways are unacceptable to us.":{}
|
||||
"You have captured our cities!":{}
|
||||
"Years of peace have strengthened our relations.":{}
|
||||
"Our mutual military struggle brings us closer together.":{}
|
||||
|
||||
// Overview screen
|
||||
"Overview":{
|
||||
Italian:"Panoramica"
|
||||
@ -8830,7 +8847,7 @@
|
||||
"Provides a free [buildingName] in the city":{
|
||||
Italian:"Dona l'edificio gratuito [buildingName] nella città"
|
||||
French:"Construit un(e) [buildingName] gratuit(e) dans la ville"
|
||||
Simplified_Chinese:"城市获得一座免费的建筑:[buildingName]"
|
||||
Simplified_Chinese:"城市获得一座免费的建筑:[buildingName]"
|
||||
}
|
||||
"Requires worked [resource] near city":{
|
||||
Italian:"Richiede che la città sfrutti [resource]"
|
||||
@ -8840,7 +8857,7 @@
|
||||
"Required tech: [requiredTech]":{
|
||||
Italian:"Tecnologie propedeutiche: [requiredTech]"
|
||||
French:"Nécessite la technologie: [requiredTech]"
|
||||
Simplified_Chinese:"需要科技:[requiredTech]"
|
||||
Simplified_Chinese:"需要科技:[requiredTech]"
|
||||
}
|
||||
"Upgrades to [upgradedUnit]":{
|
||||
Italian:"Aggiorna a [upgradedUnit]"
|
||||
|
@ -21,8 +21,8 @@ android {
|
||||
applicationId "com.unciv.app"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 28
|
||||
versionCode 233
|
||||
versionName "2.15.0-patch2"
|
||||
versionCode 234
|
||||
versionName "2.16.0"
|
||||
}
|
||||
|
||||
// Had to add this crap for Travis to build, it wanted to sign the app
|
||||
|
@ -5,6 +5,7 @@ import com.unciv.logic.civilization.PlayerType
|
||||
import com.unciv.logic.civilization.TradeRequest
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomacyFlags
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||
import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.logic.trade.*
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
@ -166,6 +167,11 @@ class NextTurnAutomation{
|
||||
|
||||
for (otherCiv in knownCivs.filter { it.isPlayerCivilization() && !it.isAtWarWith(civInfo)
|
||||
&& !civInfo.getDiplomacyManager(it).flagsCountdown.containsKey(DiplomacyFlags.DeclinedLuxExchange.toString())}) {
|
||||
|
||||
val relationshipLevel = civInfo.getDiplomacyManager(otherCiv).relationshipLevel()
|
||||
if(relationshipLevel==RelationshipLevel.Enemy || relationshipLevel == RelationshipLevel.Unforgivable)
|
||||
continue
|
||||
|
||||
val trades = potentialLuxuryTrades(civInfo,otherCiv)
|
||||
for(trade in trades){
|
||||
val tradeRequest = TradeRequest(civInfo.civName, trade.reverse())
|
||||
|
@ -188,7 +188,7 @@ class Battle(val gameInfo:GameInfo) {
|
||||
val aggroGeneratedForOtherCivs = (aggroGenerated/10).roundToInt().toFloat()
|
||||
if(thirdPartyCiv.isAtWarWith(cityCiv)) // You annoyed our enemy?
|
||||
thirdPartyCiv.getDiplomacyManager(attackerCiv)
|
||||
.addModifier(DiplomaticModifiers.CapturedOurEnemiesCities,aggroGeneratedForOtherCivs) // Cool, keep at at! =D
|
||||
.addModifier(DiplomaticModifiers.SharedEnemy, aggroGeneratedForOtherCivs) // Cool, keep at at! =D
|
||||
else thirdPartyCiv.getDiplomacyManager(attackerCiv)
|
||||
.addModifier(DiplomaticModifiers.WarMongerer, -aggroGeneratedForOtherCivs) // Uncool bro.
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ enum class DiplomaticModifiers{
|
||||
WarMongerer,
|
||||
CapturedOurCities,
|
||||
YearsOfPeace,
|
||||
CapturedOurEnemiesCities
|
||||
SharedEnemy
|
||||
}
|
||||
|
||||
class DiplomacyManager() {
|
||||
@ -86,6 +86,15 @@ class DiplomacyManager() {
|
||||
fun opinionOfOtherCiv() = diplomaticModifiers.values.sum()
|
||||
|
||||
fun relationshipLevel(): RelationshipLevel {
|
||||
if(civInfo.isPlayerCivilization() && otherCiv().isPlayerCivilization())
|
||||
return RelationshipLevel.Neutral // People make their own choices.
|
||||
|
||||
if(civInfo.isPlayerCivilization())
|
||||
return otherCiv().getDiplomacyManager(civInfo).relationshipLevel()
|
||||
|
||||
// not entirely sure what to do between AI civs, because they probably have different views of each other,
|
||||
// maybe we need to average their views of each other? That makes sense to me.
|
||||
|
||||
val opinion = opinionOfOtherCiv()
|
||||
if(opinion>80) return RelationshipLevel.Ally
|
||||
if(opinion>40) return RelationshipLevel.Friend
|
||||
@ -227,7 +236,9 @@ class DiplomacyManager() {
|
||||
|
||||
otherCivDiplomacy.diplomaticModifiers[DiplomaticModifiers.DeclaredWarOnUs.toString()] = -20f
|
||||
for(thirdCiv in civInfo.getKnownCivs()){
|
||||
thirdCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.WarMongerer,-5f)
|
||||
if(thirdCiv.isAtWarWith(otherCiv))
|
||||
thirdCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.WarMongerer,5f)
|
||||
else thirdCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.WarMongerer,-5f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import com.unciv.logic.automation.Automation
|
||||
import com.unciv.logic.automation.ThreatLevel
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tile.ResourceType
|
||||
import kotlin.math.min
|
||||
@ -11,9 +12,14 @@ import kotlin.math.sqrt
|
||||
|
||||
class TradeEvaluation{
|
||||
fun isTradeAcceptable(trade: Trade, evaluator: CivilizationInfo, tradePartner: CivilizationInfo): Boolean {
|
||||
val sumOfTheirOffers = trade.theirOffers.asSequence()
|
||||
var sumOfTheirOffers = trade.theirOffers.asSequence()
|
||||
.filter { it.type!= TradeType.Treaty } // since treaties should only be evaluated once for 2 sides
|
||||
.map { evaluateBuyCost(it,evaluator,tradePartner) }.sum()
|
||||
|
||||
val relationshipLevel = evaluator.getDiplomacyManager(tradePartner).relationshipLevel()
|
||||
if(relationshipLevel==RelationshipLevel.Enemy) sumOfTheirOffers = (sumOfTheirOffers*1.5).toInt()
|
||||
else if(relationshipLevel==RelationshipLevel.Unforgivable) sumOfTheirOffers *= 2
|
||||
|
||||
val sumOfOurOffers = trade.ourOffers.map { evaluateSellCost(it, evaluator, tradePartner)}.sum()
|
||||
return sumOfOurOffers <= sumOfTheirOffers
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.unciv.logic.trade
|
||||
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||
import com.unciv.models.gamebasics.tile.ResourceType
|
||||
import com.unciv.models.gamebasics.tr
|
||||
|
||||
@ -21,8 +22,12 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
|
||||
if(!otherCivilization.getDiplomacyManager(civInfo).hasOpenBorders
|
||||
&& !otherCivilization.isCityState()
|
||||
&& civInfo.tech.getTechUniques().contains("Enables Open Borders agreements")
|
||||
&& otherCivilization.tech.getTechUniques().contains("Enables Open Borders agreements"))
|
||||
offers.add(TradeOffer("Open Borders", TradeType.Agreement, 30))
|
||||
&& otherCivilization.tech.getTechUniques().contains("Enables Open Borders agreements")) {
|
||||
val relationshipLevel = otherCivilization.getDiplomacyManager(civInfo).relationshipLevel()
|
||||
|
||||
if(relationshipLevel!=RelationshipLevel.Enemy && relationshipLevel!=RelationshipLevel.Unforgivable)
|
||||
offers.add(TradeOffer("Open Borders", TradeType.Agreement, 30))
|
||||
}
|
||||
|
||||
for(entry in civInfo.getCivResources().filterNot { it.key.resourceType == ResourceType.Bonus }) {
|
||||
val resourceTradeType = if(entry.key.resourceType== ResourceType.Luxury) TradeType.Luxury_Resource
|
||||
|
@ -7,6 +7,8 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers
|
||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.utils.*
|
||||
import com.unciv.ui.worldscreen.optionstable.PopupTable
|
||||
@ -116,10 +118,34 @@ class DiplomacyScreen:CameraStageBaseScreen() {
|
||||
if(!otherCiv.isCityState()){
|
||||
val diplomacyModifiersTable = Table()
|
||||
val otherCivDiplomacyManager = otherCiv.getDiplomacyManager(currentPlayerCiv)
|
||||
val relationshipText = "Our relationship: "+otherCivDiplomacyManager.relationshipLevel()+" ("+otherCivDiplomacyManager.opinionOfOtherCiv()+")"
|
||||
|
||||
val relationshipTable = Table()
|
||||
relationshipTable.add("Our relationship: ".toLabel())
|
||||
val relationshipLevel = otherCivDiplomacyManager.relationshipLevel()
|
||||
val relationshipText = otherCivDiplomacyManager.relationshipLevel().toString().tr()+" ("+otherCivDiplomacyManager.opinionOfOtherCiv().toInt()+")"
|
||||
val relationshipColor = when{
|
||||
relationshipLevel==RelationshipLevel.Neutral -> Color.WHITE
|
||||
relationshipLevel==RelationshipLevel.Favorable || relationshipLevel==RelationshipLevel.Friend
|
||||
|| relationshipLevel==RelationshipLevel.Ally -> Color.GREEN
|
||||
else -> Color.RED
|
||||
}
|
||||
relationshipTable.add(relationshipText.toLabel().setFontColor(relationshipColor))
|
||||
diplomacyModifiersTable.add(relationshipText.toLabel()).row()
|
||||
|
||||
for(modifier in otherCivDiplomacyManager.diplomaticModifiers){
|
||||
diplomacyModifiersTable.add((modifier.key+" "+modifier.value).toLabel()).row()
|
||||
var text = when(DiplomaticModifiers.valueOf(modifier.key)){
|
||||
DiplomaticModifiers.DeclaredWarOnUs -> "You declared war on us!"
|
||||
DiplomaticModifiers.WarMongerer -> "Your warmongering ways are unacceptable to us."
|
||||
DiplomaticModifiers.CapturedOurCities -> "You have captured our cities!"
|
||||
DiplomaticModifiers.YearsOfPeace -> "Years of peace have strengthened our relations."
|
||||
DiplomaticModifiers.SharedEnemy -> "Our mutual military struggle brings us closer together."
|
||||
}
|
||||
text = text.tr()
|
||||
text += " "
|
||||
if(modifier.value>0) text += "+"
|
||||
text += modifier.value.toInt()
|
||||
val color = if(modifier.value<0) Color.RED else Color.GREEN
|
||||
diplomacyModifiersTable.add(text.toLabel().setFontColor(color)).row()
|
||||
}
|
||||
diplomacyTable.add(diplomacyModifiersTable).row()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user