Demands now work between human players!

This commit is contained in:
Yair Morgenstern 2019-07-29 17:03:24 +03:00
parent 6dc471850e
commit 2799205884
8 changed files with 22 additions and 23 deletions

View File

@ -491,6 +491,9 @@
French:"[civName] nous offre un(e) [untiName] prêt de [cityName]!" French:"[civName] nous offre un(e) [untiName] prêt de [cityName]!"
} }
"[civName] has denounced us!":{
}
// Trade // Trade
"[civName] has accepted your trade request":{ "[civName] has accepted your trade request":{
} }

View File

@ -60,7 +60,7 @@ class NextTurnAutomation{
private fun respondToDemands(civInfo: CivilizationInfo) { private fun respondToDemands(civInfo: CivilizationInfo) {
for(popupAlert in civInfo.popupAlerts){ for(popupAlert in civInfo.popupAlerts){
if(popupAlert.type==AlertType.CitySettledNearOtherCiv){ // we're called upon to make a decision if(popupAlert.type==AlertType.DemandToStopSettlingCitiesNear){ // we're called upon to make a decision
val demandingCiv = civInfo.gameInfo.getCivilization(popupAlert.value) val demandingCiv = civInfo.gameInfo.getCivilization(popupAlert.value)
val diploManager = civInfo.getDiplomacyManager(demandingCiv) val diploManager = civInfo.getDiplomacyManager(demandingCiv)
if(Automation().threatAssessment(civInfo,demandingCiv) >= ThreatLevel.High) if(Automation().threatAssessment(civInfo,demandingCiv) >= ThreatLevel.High)
@ -472,7 +472,7 @@ class NextTurnAutomation{
else -> { else -> {
val threatLevel = Automation().threatAssessment(civInfo,otherCiv) val threatLevel = Automation().threatAssessment(civInfo,otherCiv)
if(threatLevel<ThreatLevel.High) // don't piss them off for no reason please. if(threatLevel<ThreatLevel.High) // don't piss them off for no reason please.
otherCiv.popupAlerts.add(PopupAlert(AlertType.CitySettledNearOtherCiv, civInfo.civName)) otherCiv.popupAlerts.add(PopupAlert(AlertType.DemandToStopSettlingCitiesNear, civInfo.civName))
} }
} }
diplomacyManager.removeFlag(DiplomacyFlags.SettledCitiesNearUs) diplomacyManager.removeFlag(DiplomacyFlags.SettledCitiesNearUs)

View File

@ -316,7 +316,7 @@ class CityInfo {
When someone settles a city within 6 tiles of another civ, When someone settles a city within 6 tiles of another civ,
this makes the AI unhappy and it starts a rolling event. this makes the AI unhappy and it starts a rolling event.
The SettledCitiesNearUs flag gets added to the AI so it knows this happened, The SettledCitiesNearUs flag gets added to the AI so it knows this happened,
and on its turn it asks the player to stop (with a CitySettledNearOtherCiv alert type) and on its turn it asks the player to stop (with a DemandToStopSettlingCitiesNear alert type)
If the player says "whatever, I'm not promising to stop", they get a -10 modifier which gradually disappears in 40 turns If the player says "whatever, I'm not promising to stop", they get a -10 modifier which gradually disappears in 40 turns
If they DO agree, then if they keep their promise for ~100 turns they get a +10 modifier for keeping the promise, If they DO agree, then if they keep their promise for ~100 turns they get a +10 modifier for keeping the promise,
But if they don't keep their promise they get a -20 that will only fully disappear in 160 turns. But if they don't keep their promise they get a -20 that will only fully disappear in 160 turns.

View File

@ -6,7 +6,9 @@ enum class AlertType{
FirstContact, FirstContact,
CityConquered, CityConquered,
BorderConflict, BorderConflict,
CitySettledNearOtherCiv, @Deprecated("As of 2.19.0 - replaced with DemandToStopSettlingCitiesNear")
CitiesSettledNearOtherCiv,
DemandToStopSettlingCitiesNear,
CitySettledNearOtherCivDespiteOurPromise, CitySettledNearOtherCivDespiteOurPromise,
} }

View File

@ -415,18 +415,20 @@ class DiplomacyManager() {
RelationshipLevel.Ally -> addModifier(DiplomaticModifiers.DenouncedOurAllies,-15f) RelationshipLevel.Ally -> addModifier(DiplomaticModifiers.DenouncedOurAllies,-15f)
} }
} }
otherCiv().addNotification("[${civInfo.civName}] has denounced us!", Color.RED) // todo translation otherCiv().addNotification("[${civInfo.civName}] has denounced us!", Color.RED)
} }
fun agreeNotToSettleNear(){ fun agreeNotToSettleNear(){
otherCivDiplomacy().setFlag(DiplomacyFlags.AgreedToNotSettleNearUs,100) otherCivDiplomacy().setFlag(DiplomacyFlags.AgreedToNotSettleNearUs,100)
addModifier(DiplomaticModifiers.UnacceptableDemands,-10f) addModifier(DiplomaticModifiers.UnacceptableDemands,-10f)
otherCiv().addNotification("[${civInfo.civName}] agreed to stop settling cities near us!", Color.MAROON)
} }
fun refuseDemandNotToSettleNear(){ fun refuseDemandNotToSettleNear(){
addModifier(DiplomaticModifiers.UnacceptableDemands,-20f) addModifier(DiplomaticModifiers.UnacceptableDemands,-20f)
otherCivDiplomacy().setFlag(DiplomacyFlags.IgnoreThemSettlingNearUs,100) otherCivDiplomacy().setFlag(DiplomacyFlags.IgnoreThemSettlingNearUs,100)
otherCivDiplomacy().addModifier(DiplomaticModifiers.RefusedToNotSettleCitiesNearUs,-15f) otherCivDiplomacy().addModifier(DiplomaticModifiers.RefusedToNotSettleCitiesNearUs,-15f)
otherCiv().addNotification("[${civInfo.civName}] refused to stop settling cities near us!", Color.MAROON)
} }
//endregion //endregion

View File

@ -7,10 +7,10 @@ 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.Constants
import com.unciv.UnCivGame import com.unciv.UnCivGame
import com.unciv.logic.automation.Automation import com.unciv.logic.civilization.AlertType
import com.unciv.logic.automation.ThreatLevel
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.PopupAlert
import com.unciv.logic.civilization.diplomacy.DiplomacyFlags import com.unciv.logic.civilization.diplomacy.DiplomacyFlags
import com.unciv.logic.civilization.diplomacy.DiplomacyManager import com.unciv.logic.civilization.diplomacy.DiplomacyManager
import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers.* import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers.*
@ -268,19 +268,16 @@ class DiplomacyScreen:CameraStageBaseScreen() {
private fun getDemandsTable(currentPlayerCiv: CivilizationInfo, otherCiv: CivilizationInfo): Table { private fun getDemandsTable(currentPlayerCiv: CivilizationInfo, otherCiv: CivilizationInfo): Table {
val demandsTable = Table() val demandsTable = Table()
demandsTable.defaults().pad(10f) demandsTable.defaults().pad(10f)
val dontSettleCitiesButton = TextButton("Please don't settle new cities near us.".tr(),skin) val dontSettleCitiesButton = TextButton("Please don't settle new cities near us.".tr(),skin)
if(otherCiv.popupAlerts.any { it.type==AlertType.DemandToStopSettlingCitiesNear && it.value==currentPlayerCiv.civName })
dontSettleCitiesButton.disable()
dontSettleCitiesButton.onClick { dontSettleCitiesButton.onClick {
val threatLevel = Automation().threatAssessment(otherCiv,currentPlayerCiv) otherCiv.popupAlerts.add(PopupAlert(AlertType.DemandToStopSettlingCitiesNear, currentPlayerCiv.civName))
if(threatLevel>ThreatLevel.Medium){ dontSettleCitiesButton.disable()
otherCiv.getDiplomacyManager(currentPlayerCiv).agreeNotToSettleNear()
setRightSideFlavorText(otherCiv,"Very well, we shall look for new lands to settle.","Excellent!")
}
else {
otherCiv.getDiplomacyManager(currentPlayerCiv).refuseDemandNotToSettleNear()
setRightSideFlavorText(otherCiv,"We shall do as we please.","Very well.")
}
} }
demandsTable.add(dontSettleCitiesButton).row() demandsTable.add(dontSettleCitiesButton).row()
demandsTable.add(TextButton("Close".tr(),skin).onClick { updateRightSide(otherCiv) }) demandsTable.add(TextButton("Close".tr(),skin).onClick { updateRightSide(otherCiv) })
return demandsTable return demandsTable
} }

View File

@ -77,7 +77,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
responseTable.add(getCloseButton("Never!")) responseTable.add(getCloseButton("Never!"))
add(responseTable) add(responseTable)
} }
AlertType.CitySettledNearOtherCiv -> { AlertType.DemandToStopSettlingCitiesNear -> {
val otherciv= worldScreen.gameInfo.getCivilization(popupAlert.value) val otherciv= worldScreen.gameInfo.getCivilization(popupAlert.value)
val playerDiploManager = worldScreen.currentPlayerCiv.getDiplomacyManager(otherciv) val playerDiploManager = worldScreen.currentPlayerCiv.getDiplomacyManager(otherciv)
val translatedNation = otherciv.getTranslatedNation() val translatedNation = otherciv.getTranslatedNation()

View File

@ -95,12 +95,7 @@ class WorldScreen : CameraStageBaseScreen() {
} }
tileMapHolder.setCenterPosition(tileToCenterOn,true) tileMapHolder.setCenterPosition(tileToCenterOn,true)
update()
// On the one hand, all updates to e.g. TileGroups need to happen on the main rendering thread.
// On the other hand, the initial setup requires setting up a lot of items on the map,
// and we would sometimes get an "Input dispatching timed out" ANR when doing so.
// Putting it in a postRunnnable is our way of attempting to avoid this.
Gdx.app.postRunnable { render(0f) }
} }
// This is private so that we will set the shouldUpdate to true instead. // This is private so that we will set the shouldUpdate to true instead.