mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 22:37:02 -04:00
Separated City-state and Major civ diplomacy tables, because they're more different than similar at this point
Centralized nation leader name
This commit is contained in:
parent
75bdced3c6
commit
f8a4f15f33
@ -169,7 +169,7 @@ class NextTurnAutomation{
|
|||||||
&& !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedLuxExchange)}) {
|
&& !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedLuxExchange)}) {
|
||||||
|
|
||||||
val relationshipLevel = civInfo.getDiplomacyManager(otherCiv).relationshipLevel()
|
val relationshipLevel = civInfo.getDiplomacyManager(otherCiv).relationshipLevel()
|
||||||
if(relationshipLevel==RelationshipLevel.Enemy || relationshipLevel == RelationshipLevel.Unforgivable)
|
if(relationshipLevel <= RelationshipLevel.Enemy)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
val trades = potentialLuxuryTrades(civInfo,otherCiv)
|
val trades = potentialLuxuryTrades(civInfo,otherCiv)
|
||||||
|
@ -52,7 +52,7 @@ class DiplomacyManager() {
|
|||||||
/** Contains various flags (declared war, promised to not settle, declined luxury trade) and the number of turns in which they will expire.
|
/** Contains various flags (declared war, promised to not settle, declined luxury trade) and the number of turns in which they will expire.
|
||||||
* The JSON serialize/deserialize REFUSES to deserialize hashmap keys as Enums, so I'm forced to use strings instead =(
|
* The JSON serialize/deserialize REFUSES to deserialize hashmap keys as Enums, so I'm forced to use strings instead =(
|
||||||
* This is so sad Alexa play Despacito */
|
* This is so sad Alexa play Despacito */
|
||||||
var flagsCountdown = HashMap<String,Int>()
|
private var flagsCountdown = HashMap<String,Int>()
|
||||||
|
|
||||||
/** For AI. Positive is good relations, negative is bad.
|
/** For AI. Positive is good relations, negative is bad.
|
||||||
* Baseline is 1 point for each turn of peace - so declaring a war upends 40 years of peace, and e.g. capturing a city can be another 30 or 40.
|
* Baseline is 1 point for each turn of peace - so declaring a war upends 40 years of peace, and e.g. capturing a city can be another 30 or 40.
|
||||||
|
@ -25,7 +25,7 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
|
|||||||
&& otherCivilization.tech.getTechUniques().contains("Enables Open Borders agreements")) {
|
&& otherCivilization.tech.getTechUniques().contains("Enables Open Borders agreements")) {
|
||||||
val relationshipLevel = otherCivilization.getDiplomacyManager(civInfo).relationshipLevel()
|
val relationshipLevel = otherCivilization.getDiplomacyManager(civInfo).relationshipLevel()
|
||||||
|
|
||||||
if(relationshipLevel!=RelationshipLevel.Enemy && relationshipLevel!=RelationshipLevel.Unforgivable)
|
if(relationshipLevel >= RelationshipLevel.Neutral)
|
||||||
offers.add(TradeOffer("Open Borders", TradeType.Agreement, 30))
|
offers.add(TradeOffer("Open Borders", TradeType.Agreement, 30))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,9 @@ class Nation : INamed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var leaderName=""
|
var leaderName=""
|
||||||
|
fun getLeaderDisplayName() = if(isCityState()) "City-state [${getNameTranslation()}]".tr()
|
||||||
|
else "[$leaderName] of [${getNameTranslation()}]"
|
||||||
|
|
||||||
var cityStateType: CityStateType?=null
|
var cityStateType: CityStateType?=null
|
||||||
var declaringWar=""
|
var declaringWar=""
|
||||||
var attacked=""
|
var attacked=""
|
||||||
|
@ -8,6 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
|||||||
import com.unciv.UnCivGame
|
import com.unciv.UnCivGame
|
||||||
import com.unciv.logic.civilization.CityStateType
|
import com.unciv.logic.civilization.CityStateType
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
|
import com.unciv.logic.civilization.diplomacy.DiplomacyManager
|
||||||
import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers.*
|
import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers.*
|
||||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||||
import com.unciv.logic.trade.TradeLogic
|
import com.unciv.logic.trade.TradeLogic
|
||||||
@ -60,7 +61,8 @@ class DiplomacyScreen:CameraStageBaseScreen() {
|
|||||||
|
|
||||||
civIndicator.onClick {
|
civIndicator.onClick {
|
||||||
rightSideTable.clear()
|
rightSideTable.clear()
|
||||||
rightSideTable.add(getDiplomacyTable(civ))
|
if(civ.isCityState()) rightSideTable.add(getCityStateDiplomacyTable(civ))
|
||||||
|
else rightSideTable.add(getMajorCivDiplomacyTable(civ))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,17 +79,16 @@ class DiplomacyScreen:CameraStageBaseScreen() {
|
|||||||
currentPlayerCiv.gold -= 100
|
currentPlayerCiv.gold -= 100
|
||||||
otherCiv.getDiplomacyManager(currentPlayerCiv).influence += 10
|
otherCiv.getDiplomacyManager(currentPlayerCiv).influence += 10
|
||||||
rightSideTable.clear()
|
rightSideTable.clear()
|
||||||
rightSideTable.add(getDiplomacyTable(otherCiv))
|
rightSideTable.add(getCityStateDiplomacyTable(otherCiv))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDiplomacyTable(otherCiv: CivilizationInfo): Table {
|
|
||||||
|
private fun getCityStateDiplomacyTable(otherCiv: CivilizationInfo): Table {
|
||||||
val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
|
val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
|
||||||
val diplomacyTable = Table()
|
val diplomacyTable = Table()
|
||||||
diplomacyTable.defaults().pad(10f)
|
diplomacyTable.defaults().pad(10f)
|
||||||
val leaderName: String
|
|
||||||
if (otherCiv.isCityState()) {
|
if (otherCiv.isCityState()) {
|
||||||
leaderName = "City-state of [" + otherCiv.civName + "]"
|
diplomacyTable.add(otherCiv.getNation().getLeaderDisplayName().toLabel())
|
||||||
diplomacyTable.add(leaderName.toLabel()).row()
|
|
||||||
diplomacyTable.add(("Type : " + otherCiv.getCityStateType().toString()).toLabel()).row()
|
diplomacyTable.add(("Type : " + otherCiv.getCityStateType().toString()).toLabel()).row()
|
||||||
diplomacyTable.add(("Influence : " + otherCiv.getDiplomacyManager(currentPlayerCiv).influence.toInt().toString()).toLabel()).row()
|
diplomacyTable.add(("Influence : " + otherCiv.getDiplomacyManager(currentPlayerCiv).influence.toInt().toString()).toLabel()).row()
|
||||||
if (otherCiv.getDiplomacyManager(currentPlayerCiv).influence > 60) {
|
if (otherCiv.getDiplomacyManager(currentPlayerCiv).influence > 60) {
|
||||||
@ -96,27 +97,19 @@ class DiplomacyScreen:CameraStageBaseScreen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
leaderName = "[" + otherCiv.getNation().leaderName + "] of [" + otherCiv.civName + "]"
|
diplomacyTable.add(otherCiv.getNation().getLeaderDisplayName().toLabel())
|
||||||
diplomacyTable.add(leaderName.toLabel())
|
|
||||||
}
|
}
|
||||||
diplomacyTable.addSeparator()
|
diplomacyTable.addSeparator()
|
||||||
|
|
||||||
if(otherCiv.isCityState()) {
|
|
||||||
val giftButton = TextButton("Give 100 gold".tr(), skin)
|
val giftButton = TextButton("Give 100 gold".tr(), skin)
|
||||||
giftButton.onClick{ giveGoldGift(otherCiv) }
|
giftButton.onClick{ giveGoldGift(otherCiv) }
|
||||||
diplomacyTable.add(giftButton).row()
|
diplomacyTable.add(giftButton).row()
|
||||||
if (currentPlayerCiv.gold < 1) giftButton.disable()
|
if (currentPlayerCiv.gold < 1) giftButton.disable()
|
||||||
} else {
|
|
||||||
val tradeButton = TextButton("Trade".tr(), skin)
|
|
||||||
tradeButton.onClick { setTrade(otherCiv) }
|
|
||||||
diplomacyTable.add(tradeButton).row()
|
|
||||||
}
|
|
||||||
|
|
||||||
val diplomacyManager = currentPlayerCiv.getDiplomacyManager(otherCiv)
|
val diplomacyManager = currentPlayerCiv.getDiplomacyManager(otherCiv)
|
||||||
|
|
||||||
if (currentPlayerCiv.isAtWarWith(otherCiv)) {
|
if (currentPlayerCiv.isAtWarWith(otherCiv)) {
|
||||||
if (otherCiv.isCityState()) {
|
val PeaceButton = TextButton("Negotiate Peace".tr(), skin)
|
||||||
val PeaceButton = TextButton("Negociate Peace".tr(), skin)
|
|
||||||
PeaceButton.onClick {
|
PeaceButton.onClick {
|
||||||
YesNoPopupTable("Peace with [${otherCiv.civName}]?".tr(), {
|
YesNoPopupTable("Peace with [${otherCiv.civName}]?".tr(), {
|
||||||
val tradeLogic = TradeLogic(currentPlayerCiv, otherCiv)
|
val tradeLogic = TradeLogic(currentPlayerCiv, otherCiv)
|
||||||
@ -127,8 +120,15 @@ class DiplomacyScreen:CameraStageBaseScreen() {
|
|||||||
}, this)
|
}, this)
|
||||||
}
|
}
|
||||||
diplomacyTable.add(PeaceButton).row()
|
diplomacyTable.add(PeaceButton).row()
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
val declareWarButton = getDeclareWarButton(diplomacyManager, otherCiv)
|
||||||
|
diplomacyTable.add(declareWarButton).row()
|
||||||
|
}
|
||||||
|
|
||||||
|
return diplomacyTable
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getDeclareWarButton(diplomacyManager: DiplomacyManager, otherCiv: CivilizationInfo): TextButton {
|
||||||
val declareWarButton = TextButton("Declare war".tr(), skin)
|
val declareWarButton = TextButton("Declare war".tr(), skin)
|
||||||
declareWarButton.color = Color.RED
|
declareWarButton.color = Color.RED
|
||||||
val turnsToPeaceTreaty = diplomacyManager.turnsToPeaceTreaty()
|
val turnsToPeaceTreaty = diplomacyManager.turnsToPeaceTreaty()
|
||||||
@ -141,13 +141,7 @@ class DiplomacyScreen:CameraStageBaseScreen() {
|
|||||||
diplomacyManager.declareWar()
|
diplomacyManager.declareWar()
|
||||||
|
|
||||||
val responsePopup = PopupTable(this)
|
val responsePopup = PopupTable(this)
|
||||||
val otherCivLeaderName: String
|
responsePopup.add(otherCiv.getTranslatedNation().getLeaderDisplayName().toLabel())
|
||||||
if (otherCiv.isCityState()) {
|
|
||||||
otherCivLeaderName = "City-state [" + otherCiv.civName + "]"
|
|
||||||
} else {
|
|
||||||
otherCivLeaderName = "[" + otherCiv.getNation().leaderName + "] of [" + otherCiv.civName + "]"
|
|
||||||
}
|
|
||||||
responsePopup.add(otherCivLeaderName.toLabel())
|
|
||||||
responsePopup.addSeparator()
|
responsePopup.addSeparator()
|
||||||
responsePopup.addGoodSizedLabel(otherCiv.getNation().attacked).row()
|
responsePopup.addGoodSizedLabel(otherCiv.getNation().attacked).row()
|
||||||
responsePopup.addButton("Very well.".tr()) { responsePopup.remove() }
|
responsePopup.addButton("Very well.".tr()) { responsePopup.remove() }
|
||||||
@ -156,28 +150,46 @@ class DiplomacyScreen:CameraStageBaseScreen() {
|
|||||||
updateLeftSideTable()
|
updateLeftSideTable()
|
||||||
}, this)
|
}, this)
|
||||||
}
|
}
|
||||||
|
return declareWarButton
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getMajorCivDiplomacyTable(otherCiv: CivilizationInfo): Table {
|
||||||
|
val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
|
||||||
|
val diplomacyTable = Table()
|
||||||
|
diplomacyTable.defaults().pad(10f)
|
||||||
|
diplomacyTable.add(otherCiv.getNation().getLeaderDisplayName().toLabel())
|
||||||
|
diplomacyTable.addSeparator()
|
||||||
|
|
||||||
|
val tradeButton = TextButton("Trade".tr(), skin)
|
||||||
|
tradeButton.onClick { setTrade(otherCiv) }
|
||||||
|
diplomacyTable.add(tradeButton).row()
|
||||||
|
|
||||||
|
val diplomacyManager = currentPlayerCiv.getDiplomacyManager(otherCiv)
|
||||||
|
|
||||||
|
if (!currentPlayerCiv.isAtWarWith(otherCiv)) {
|
||||||
|
val declareWarButton = getDeclareWarButton(diplomacyManager, otherCiv)
|
||||||
diplomacyTable.add(declareWarButton).row()
|
diplomacyTable.add(declareWarButton).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!otherCiv.isCityState()){
|
|
||||||
val diplomacyModifiersTable = Table()
|
val diplomacyModifiersTable = Table()
|
||||||
val otherCivDiplomacyManager = otherCiv.getDiplomacyManager(currentPlayerCiv)
|
val otherCivDiplomacyManager = otherCiv.getDiplomacyManager(currentPlayerCiv)
|
||||||
|
|
||||||
val relationshipTable = Table()
|
val relationshipTable = Table()
|
||||||
relationshipTable.add("Our relationship: ".toLabel())
|
relationshipTable.add("Our relationship: ".toLabel())
|
||||||
val relationshipLevel = otherCivDiplomacyManager.relationshipLevel()
|
val relationshipLevel = otherCivDiplomacyManager.relationshipLevel()
|
||||||
val relationshipText = otherCivDiplomacyManager.relationshipLevel().toString().tr()+" ("+otherCivDiplomacyManager.opinionOfOtherCiv().toInt()+")"
|
val relationshipText = otherCivDiplomacyManager.relationshipLevel().toString().tr() + " (" + otherCivDiplomacyManager.opinionOfOtherCiv().toInt() + ")"
|
||||||
val relationshipColor = when{
|
val relationshipColor = when {
|
||||||
relationshipLevel==RelationshipLevel.Neutral -> Color.WHITE
|
relationshipLevel == RelationshipLevel.Neutral -> Color.WHITE
|
||||||
relationshipLevel==RelationshipLevel.Favorable || relationshipLevel==RelationshipLevel.Friend
|
relationshipLevel == RelationshipLevel.Favorable || relationshipLevel == RelationshipLevel.Friend
|
||||||
|| relationshipLevel==RelationshipLevel.Ally -> Color.GREEN
|
|| relationshipLevel == RelationshipLevel.Ally -> Color.GREEN
|
||||||
else -> Color.RED
|
else -> Color.RED
|
||||||
}
|
}
|
||||||
relationshipTable.add(relationshipText.toLabel().setFontColor(relationshipColor))
|
relationshipTable.add(relationshipText.toLabel().setFontColor(relationshipColor))
|
||||||
diplomacyModifiersTable.add(relationshipText.toLabel()).row()
|
diplomacyModifiersTable.add(relationshipText.toLabel()).row()
|
||||||
|
|
||||||
for(modifier in otherCivDiplomacyManager.diplomaticModifiers){
|
for (modifier in otherCivDiplomacyManager.diplomaticModifiers) {
|
||||||
var text = when(valueOf(modifier.key)){
|
var text = when (valueOf(modifier.key)) {
|
||||||
DeclaredWarOnUs -> "You declared war on us!"
|
DeclaredWarOnUs -> "You declared war on us!"
|
||||||
WarMongerer -> "Your warmongering ways are unacceptable to us."
|
WarMongerer -> "Your warmongering ways are unacceptable to us."
|
||||||
CapturedOurCities -> "You have captured our cities!"
|
CapturedOurCities -> "You have captured our cities!"
|
||||||
@ -187,15 +199,15 @@ 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"
|
||||||
}
|
}
|
||||||
text = text.tr()+" "
|
text = text.tr() + " "
|
||||||
if(modifier.value>0) text += "+"
|
if (modifier.value > 0) text += "+"
|
||||||
text += modifier.value.toInt()
|
text += modifier.value.toInt()
|
||||||
val color = if(modifier.value<0) Color.RED else Color.GREEN
|
val color = if (modifier.value < 0) Color.RED else Color.GREEN
|
||||||
diplomacyModifiersTable.add(text.toLabel().setFontColor(color)).row()
|
diplomacyModifiersTable.add(text.toLabel().setFontColor(color)).row()
|
||||||
}
|
}
|
||||||
diplomacyTable.add(diplomacyModifiersTable).row()
|
diplomacyTable.add(diplomacyModifiersTable).row()
|
||||||
}
|
|
||||||
|
|
||||||
return diplomacyTable
|
return diplomacyTable
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -19,13 +19,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun addLeaderName(translatedNation: Nation){
|
fun addLeaderName(translatedNation: Nation){
|
||||||
val otherCivLeaderName: String
|
val otherCivLeaderName = translatedNation.getLeaderDisplayName()
|
||||||
if (translatedNation.isCityState()) {
|
|
||||||
otherCivLeaderName = "City-state [${translatedNation.getNameTranslation()}]".tr()
|
|
||||||
} else {
|
|
||||||
otherCivLeaderName = "[${translatedNation.leaderName}] of [${translatedNation.getNameTranslation()}]".tr()
|
|
||||||
}
|
|
||||||
|
|
||||||
add(otherCivLeaderName.toLabel())
|
add(otherCivLeaderName.toLabel())
|
||||||
addSeparator()
|
addSeparator()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user