Civs respond according to neutral/hate and respond properly after peace

This commit is contained in:
Yair Morgenstern
2019-05-26 18:32:19 +03:00
parent f78f9c2fad
commit 1bb62ad681
7 changed files with 515 additions and 479 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 988 KiB

After

Width:  |  Height:  |  Size: 991 KiB

View File

@ -2640,10 +2640,13 @@
Portuguese:"Aliado" Portuguese:"Aliado"
} }
// City State bonuses // City States
"Provides [amountOfCulture] culture at 30 Influence":{} "Provides [amountOfCulture] culture at 30 Influence":{}
"Provides 3 food in capital and 1 food in other cities at 30 Influence":{} "Provides 3 food in capital and 1 food in other cities at 30 Influence":{}
"Provides 3 happiness at 30 Influence":{} "Provides 3 happiness at 30 Influence":{}
"Gift [goldAmount] gold":{}
////// Diplomatic modifiers ////// Diplomatic modifiers

View File

@ -24,10 +24,19 @@ class Nation : INamed {
var introduction="" var introduction=""
var tradeRequest="" var tradeRequest=""
var neutralHello=""
var hateHello=""
var neutralLetsHearIt = ArrayList<String>() var neutralLetsHearIt = ArrayList<String>()
var neutralYes = ArrayList<String>() var neutralYes = ArrayList<String>()
var neutralNo = ArrayList<String>() var neutralNo = ArrayList<String>()
var hateLetsHearIt = ArrayList<String>()
var hateYes = ArrayList<String>()
var hateNo = ArrayList<String>()
var afterPeace=""
lateinit var mainColor: List<Int> lateinit var mainColor: List<Int>
var unique:String?=null var unique:String?=null
var secondaryColor: List<Int>?=null var secondaryColor: List<Int>?=null

View File

@ -125,7 +125,8 @@ class DiplomacyScreen:CameraStageBaseScreen() {
diplomacyTable.addSeparator() diplomacyTable.addSeparator()
val giftAmount = 100 val giftAmount = 100
val giftButton = TextButton("Give [$giftAmount] gold".tr(), skin) val influenceAmount = giftAmount/10
val giftButton = TextButton("Gift [$giftAmount] gold (+[$influenceAmount] influence)".tr(), skin)
giftButton.onClick{ giveGoldGift(otherCiv,giftAmount ) } giftButton.onClick{ giveGoldGift(otherCiv,giftAmount ) }
diplomacyTable.add(giftButton).row() diplomacyTable.add(giftButton).row()
if (currentPlayerCiv.gold < giftAmount ) giftButton.disable() if (currentPlayerCiv.gold < giftAmount ) giftButton.disable()
@ -154,9 +155,17 @@ class DiplomacyScreen:CameraStageBaseScreen() {
private fun getMajorCivDiplomacyTable(otherCiv: CivilizationInfo): Table { private fun getMajorCivDiplomacyTable(otherCiv: CivilizationInfo): Table {
val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization() val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
val otherCivDiplomacyManager = otherCiv.getDiplomacyManager(currentPlayerCiv)
val diplomacyTable = Table() val diplomacyTable = Table()
diplomacyTable.defaults().pad(10f) diplomacyTable.defaults().pad(10f)
diplomacyTable.add(otherCiv.getNation().getLeaderDisplayName().toLabel())
val translatedNation = otherCiv.getTranslatedNation()
diplomacyTable.add(translatedNation.getLeaderDisplayName().toLabel().setFontSize(24)).row()
if(otherCivDiplomacyManager.relationshipLevel()<=RelationshipLevel.Enemy)
diplomacyTable.add(translatedNation.hateHello.toLabel()).row()
else
diplomacyTable.add(translatedNation.neutralHello.toLabel()).row()
diplomacyTable.addSeparator() diplomacyTable.addSeparator()
if(!currentPlayerCiv.isAtWarWith(otherCiv)) { if(!currentPlayerCiv.isAtWarWith(otherCiv)) {
@ -173,7 +182,7 @@ class DiplomacyScreen:CameraStageBaseScreen() {
tradeTable.tradeLogic.currentTrade.ourOffers.add(peaceTreaty) tradeTable.tradeLogic.currentTrade.ourOffers.add(peaceTreaty)
tradeTable.offerColumnsTable.update() tradeTable.offerColumnsTable.update()
} }
if (otherCiv.getDiplomacyManager(currentPlayerCiv).hasFlag(DiplomacyFlags.DeclaredWar)) if (otherCivDiplomacyManager.hasFlag(DiplomacyFlags.DeclaredWar))
negotiatePeaceButton.disable() // Can't trade for 10 turns after war was declared negotiatePeaceButton.disable() // Can't trade for 10 turns after war was declared
diplomacyTable.add(negotiatePeaceButton).row() diplomacyTable.add(negotiatePeaceButton).row()
@ -184,7 +193,7 @@ class DiplomacyScreen:CameraStageBaseScreen() {
if (!currentPlayerCiv.isAtWarWith(otherCiv)) { if (!currentPlayerCiv.isAtWarWith(otherCiv)) {
if(otherCiv.getDiplomacyManager(currentPlayerCiv).relationshipLevel() > RelationshipLevel.Neutral if(otherCivDiplomacyManager.relationshipLevel() > RelationshipLevel.Neutral
&& !diplomacyManager.hasFlag(DiplomacyFlags.DeclarationOfFriendship)){ && !diplomacyManager.hasFlag(DiplomacyFlags.DeclarationOfFriendship)){
val declareFriendshipButton = TextButton("Declare Friendship ([30] turns)".tr(),skin) val declareFriendshipButton = TextButton("Declare Friendship ([30] turns)".tr(),skin)
declareFriendshipButton.onClick { declareFriendshipButton.onClick {
@ -199,8 +208,6 @@ class DiplomacyScreen:CameraStageBaseScreen() {
} }
val otherCivDiplomacyManager = otherCiv.getDiplomacyManager(currentPlayerCiv)
diplomacyTable.add(getRelationshipTable(otherCivDiplomacyManager)).row() diplomacyTable.add(getRelationshipTable(otherCivDiplomacyManager)).row()
val diplomacyModifiersTable = Table() val diplomacyModifiersTable = Table()

View File

@ -4,7 +4,9 @@ import com.badlogic.gdx.scenes.scene2d.Stage
import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.Label
import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.ui.TextButton import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.unciv.Constants
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
import com.unciv.logic.trade.TradeEvaluation import com.unciv.logic.trade.TradeEvaluation
import com.unciv.logic.trade.TradeLogic import com.unciv.logic.trade.TradeLogic
import com.unciv.models.gamebasics.tr import com.unciv.models.gamebasics.tr
@ -16,11 +18,18 @@ class TradeTable(val otherCivilization: CivilizationInfo, stage: Stage, onTradeC
var tradeLogic = TradeLogic(currentPlayerCiv,otherCivilization) var tradeLogic = TradeLogic(currentPlayerCiv,otherCivilization)
var offerColumnsTable = OfferColumnsTable(tradeLogic, stage) { onChange() } var offerColumnsTable = OfferColumnsTable(tradeLogic, stage) { onChange() }
var offerColumnsTableWrapper = Table() // This is so that after a trade has been traded, we can switch out the offersToDisplay to start anew - this is the easiest way var offerColumnsTableWrapper = Table() // This is so that after a trade has been traded, we can switch out the offersToDisplay to start anew - this is the easiest way
val tradeText = Label(otherCivilization.getTranslatedNation().neutralLetsHearIt.random().tr(), CameraStageBaseScreen.skin) val tradeText = Label("", CameraStageBaseScreen.skin)
val offerButton = TextButton("Offer trade".tr(), CameraStageBaseScreen.skin) val offerButton = TextButton("Offer trade".tr(), CameraStageBaseScreen.skin)
fun letsHearIt(){
val relationshipLevel = otherCivilization.getDiplomacyManager(currentPlayerCiv).relationshipLevel()
if(relationshipLevel <= RelationshipLevel.Enemy)
tradeText.setText(otherCivilization.getTranslatedNation().hateLetsHearIt.random().tr())
else tradeText.setText(otherCivilization.getTranslatedNation().neutralLetsHearIt.random().tr())
}
init{ init{
letsHearIt()
offerColumnsTableWrapper.add(offerColumnsTable) offerColumnsTableWrapper.add(offerColumnsTable)
add(offerColumnsTableWrapper).row() add(offerColumnsTableWrapper).row()
@ -29,26 +38,34 @@ class TradeTable(val otherCivilization: CivilizationInfo, stage: Stage, onTradeC
lowerTable.add(tradeText).colspan(2).row() lowerTable.add(tradeText).colspan(2).row()
offerButton.onClick { offerButton.onClick {
val relationshipLevel = otherCivilization.getDiplomacyManager(currentPlayerCiv).relationshipLevel()
if(offerButton.text.toString() == "Offer trade".tr()) { if(offerButton.text.toString() == "Offer trade".tr()) {
if(tradeLogic.currentTrade.theirOffers.size==0 && tradeLogic.currentTrade.ourOffers.size==0){ if(tradeLogic.currentTrade.theirOffers.size==0 && tradeLogic.currentTrade.ourOffers.size==0){
tradeText.setText(otherCivilization.getTranslatedNation().neutralLetsHearIt.random().tr()) letsHearIt()
} }
else if (TradeEvaluation().isTradeAcceptable(tradeLogic.currentTrade.reverse(),otherCivilization,currentPlayerCiv)){ else if (TradeEvaluation().isTradeAcceptable(tradeLogic.currentTrade.reverse(),otherCivilization,currentPlayerCiv)){
tradeText.setText(otherCivilization.getTranslatedNation().neutralYes.random().tr()) if(relationshipLevel<=RelationshipLevel.Enemy)
tradeText.setText(otherCivilization.getTranslatedNation().hateYes.random().tr())
else tradeText.setText(otherCivilization.getTranslatedNation().neutralYes.random().tr())
offerButton.setText("Accept".tr()) offerButton.setText("Accept".tr())
} }
else{ else{
if(relationshipLevel<=RelationshipLevel.Enemy)
tradeText.setText(otherCivilization.getTranslatedNation().hateNo.random().tr())
tradeText.setText(otherCivilization.getTranslatedNation().neutralNo.random().tr()) tradeText.setText(otherCivilization.getTranslatedNation().neutralNo.random().tr())
} }
} }
else if(offerButton.text.toString() == "Accept".tr()){ else if(offerButton.text.toString() == "Accept".tr()){
tradeLogic.acceptTrade() tradeLogic.acceptTrade()
tradeLogic = TradeLogic(currentPlayerCiv,otherCivilization)
offerColumnsTable = OfferColumnsTable(tradeLogic, stage) { onChange() } offerColumnsTable = OfferColumnsTable(tradeLogic, stage) { onChange() }
offerColumnsTableWrapper.clear() offerColumnsTableWrapper.clear()
offerColumnsTableWrapper.add(offerColumnsTable) offerColumnsTableWrapper.add(offerColumnsTable)
tradeText.setText("Pleasure doing business with you!".tr()) if(tradeLogic.currentTrade.ourOffers.any { it.name== Constants.peaceTreaty })
tradeText.setText(otherCivilization.getTranslatedNation().afterPeace)
else tradeText.setText("Pleasure doing business with you!".tr())
onTradeComplete() onTradeComplete()
tradeLogic = TradeLogic(currentPlayerCiv,otherCivilization)
offerButton.setText("Offer trade".tr()) offerButton.setText("Offer trade".tr())
} }
} }
@ -64,7 +81,7 @@ class TradeTable(val otherCivilization: CivilizationInfo, stage: Stage, onTradeC
private fun onChange(){ private fun onChange(){
offerColumnsTable.update() offerColumnsTable.update()
offerButton.setText("Offer trade".tr()) offerButton.setText("Offer trade".tr())
tradeText.setText(otherCivilization.getTranslatedNation().neutralLetsHearIt.random().tr()) letsHearIt()
} }
} }