mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 03:23:17 -04:00
More generic-ing for demands
This commit is contained in:
parent
daceb87f7f
commit
dee883340d
@ -107,30 +107,16 @@ object NextTurnAutomation {
|
|||||||
}
|
}
|
||||||
private fun respondToPopupAlerts(civInfo: Civilization) {
|
private fun respondToPopupAlerts(civInfo: Civilization) {
|
||||||
for (popupAlert in civInfo.popupAlerts.toList()) { // toList because this can trigger other things that give alerts, like Golden Age
|
for (popupAlert in civInfo.popupAlerts.toList()) { // toList because this can trigger other things that give alerts, like Golden Age
|
||||||
if (popupAlert.type == AlertType.DemandToStopSettlingCitiesNear) { // we're called upon to make a decision
|
|
||||||
val demandingCiv = civInfo.gameInfo.getCivilization(popupAlert.value)
|
|
||||||
val diploManager = civInfo.getDiplomacyManager(demandingCiv)!!
|
|
||||||
if (Automation.threatAssessment(civInfo, demandingCiv) >= ThreatLevel.High)
|
|
||||||
diploManager.agreeNotToSettleNear()
|
|
||||||
else diploManager.refuseDemandNotToSettleNear()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (popupAlert.type == AlertType.DemandToStopSpreadingReligion) {
|
for (demand in Demand.entries){
|
||||||
|
if (popupAlert.type == demand.demandAlert) {
|
||||||
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
|
||||||
|| diploManager.isRelationshipLevelGT(RelationshipLevel.Ally))
|
|| diploManager.isRelationshipLevelGT(RelationshipLevel.Ally))
|
||||||
diploManager.agreeNotToSpreadReligionTo()
|
diploManager.agreeToDemand(demand)
|
||||||
else diploManager.refuseNotToSpreadReligionTo()
|
else diploManager.refuseDemand(demand)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (popupAlert.type == AlertType.DemandToStopSpyingOnUs) {
|
|
||||||
val demandingCiv = civInfo.gameInfo.getCivilization(popupAlert.value)
|
|
||||||
val diploManager = civInfo.getDiplomacyManager(demandingCiv)!!
|
|
||||||
if (Automation.threatAssessment(civInfo, demandingCiv) >= ThreatLevel.High
|
|
||||||
|| diploManager.isRelationshipLevelGT(RelationshipLevel.Ally))
|
|
||||||
diploManager.agreeNotToSpreadSpiesTo()
|
|
||||||
else diploManager.refuseNotToSpreadSpiesTo()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (popupAlert.type == AlertType.DeclarationOfFriendship) {
|
if (popupAlert.type == AlertType.DeclarationOfFriendship) {
|
||||||
|
@ -9,7 +9,9 @@ enum class Demand(
|
|||||||
val refusedDiplomaticModifier: DiplomaticModifiers,
|
val refusedDiplomaticModifier: DiplomaticModifiers,
|
||||||
val betrayedPromiseDiplomacyMpodifier: DiplomaticModifiers,
|
val betrayedPromiseDiplomacyMpodifier: DiplomaticModifiers,
|
||||||
val demandAlert: AlertType,
|
val demandAlert: AlertType,
|
||||||
val violationDiscoveredAlert: AlertType) {
|
val violationDiscoveredAlert: AlertType,
|
||||||
|
val agreedToDemandText: String,
|
||||||
|
val refusedDemandText: String) {
|
||||||
DontSpyOnUs(
|
DontSpyOnUs(
|
||||||
agreedToDemand = DiplomacyFlags.AgreedToNotSendSpies,
|
agreedToDemand = DiplomacyFlags.AgreedToNotSendSpies,
|
||||||
violationOccurred = DiplomacyFlags.DiscoveredSpiesInOurCities,
|
violationOccurred = DiplomacyFlags.DiscoveredSpiesInOurCities,
|
||||||
@ -17,7 +19,9 @@ enum class Demand(
|
|||||||
refusedDiplomaticModifier = DiplomaticModifiers.RefusedToNotSendingSpiesToUs,
|
refusedDiplomaticModifier = DiplomaticModifiers.RefusedToNotSendingSpiesToUs,
|
||||||
betrayedPromiseDiplomacyMpodifier = DiplomaticModifiers.BetrayedPromiseToNotSendingSpiesToUs,
|
betrayedPromiseDiplomacyMpodifier = DiplomaticModifiers.BetrayedPromiseToNotSendingSpiesToUs,
|
||||||
demandAlert = AlertType.DemandToStopSpyingOnUs,
|
demandAlert = AlertType.DemandToStopSpyingOnUs,
|
||||||
violationDiscoveredAlert = AlertType.SpyingOnUsDespiteOurPromise
|
violationDiscoveredAlert = AlertType.SpyingOnUsDespiteOurPromise,
|
||||||
|
agreedToDemandText = "[civName] agreed to stop spying on us!",
|
||||||
|
refusedDemandText = "[civName] refused to stop spying on us!"
|
||||||
),
|
),
|
||||||
DoNotSpreadReligion(
|
DoNotSpreadReligion(
|
||||||
agreedToDemand = DiplomacyFlags.AgreedToNotSpreadReligion,
|
agreedToDemand = DiplomacyFlags.AgreedToNotSpreadReligion,
|
||||||
@ -26,7 +30,9 @@ enum class Demand(
|
|||||||
refusedDiplomaticModifier = DiplomaticModifiers.RefusedToNotSpreadReligionToUs,
|
refusedDiplomaticModifier = DiplomaticModifiers.RefusedToNotSpreadReligionToUs,
|
||||||
betrayedPromiseDiplomacyMpodifier = DiplomaticModifiers.BetrayedPromiseToNotSpreadReligionToUs,
|
betrayedPromiseDiplomacyMpodifier = DiplomaticModifiers.BetrayedPromiseToNotSpreadReligionToUs,
|
||||||
demandAlert = AlertType.DemandToStopSpreadingReligion,
|
demandAlert = AlertType.DemandToStopSpreadingReligion,
|
||||||
violationDiscoveredAlert = AlertType.ReligionSpreadDespiteOurPromise
|
violationDiscoveredAlert = AlertType.ReligionSpreadDespiteOurPromise,
|
||||||
|
agreedToDemandText = "[civName] agreed to stop spreading religion to us!",
|
||||||
|
refusedDemandText = "[civName] refused to stop spreading religion to us!",
|
||||||
),
|
),
|
||||||
DoNotSettleNearUs(
|
DoNotSettleNearUs(
|
||||||
agreedToDemand = DiplomacyFlags.AgreedToNotSettleNearUs,
|
agreedToDemand = DiplomacyFlags.AgreedToNotSettleNearUs,
|
||||||
@ -35,7 +41,9 @@ enum class Demand(
|
|||||||
refusedDiplomaticModifier = DiplomaticModifiers.RefusedToNotSettleCitiesNearUs,
|
refusedDiplomaticModifier = DiplomaticModifiers.RefusedToNotSettleCitiesNearUs,
|
||||||
betrayedPromiseDiplomacyMpodifier = DiplomaticModifiers.BetrayedPromiseToNotSettleCitiesNearUs,
|
betrayedPromiseDiplomacyMpodifier = DiplomaticModifiers.BetrayedPromiseToNotSettleCitiesNearUs,
|
||||||
demandAlert = AlertType.DemandToStopSettlingCitiesNear,
|
demandAlert = AlertType.DemandToStopSettlingCitiesNear,
|
||||||
violationDiscoveredAlert = AlertType.CitySettledNearOtherCivDespiteOurPromise
|
violationDiscoveredAlert = AlertType.CitySettledNearOtherCivDespiteOurPromise,
|
||||||
|
agreedToDemandText = "[civName] agreed to stop settling cities near us!",
|
||||||
|
refusedDemandText = "[civName] refused to stop settling cities near us!"
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
}
|
}
|
@ -15,6 +15,7 @@ import com.unciv.models.ruleset.tile.ResourceSupplyList
|
|||||||
import com.unciv.models.ruleset.unique.StateForConditionals
|
import com.unciv.models.ruleset.unique.StateForConditionals
|
||||||
import com.unciv.models.ruleset.unique.UniqueTriggerActivation
|
import com.unciv.models.ruleset.unique.UniqueTriggerActivation
|
||||||
import com.unciv.models.ruleset.unique.UniqueType
|
import com.unciv.models.ruleset.unique.UniqueType
|
||||||
|
import com.unciv.models.translations.fillPlaceholders
|
||||||
import com.unciv.ui.components.extensions.toPercent
|
import com.unciv.ui.components.extensions.toPercent
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
@ -684,49 +685,19 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun agreeNotToSettleNear() {
|
fun agreeToDemand(demand: Demand){
|
||||||
otherCivDiplomacy().setFlag(DiplomacyFlags.AgreedToNotSettleNearUs, 100)
|
otherCivDiplomacy().setFlag(demand.agreedToDemand, 100)
|
||||||
addModifier(DiplomaticModifiers.UnacceptableDemands, -10f)
|
addModifier(DiplomaticModifiers.UnacceptableDemands, -10f)
|
||||||
otherCiv().addNotification("[${civInfo.civName}] agreed to stop settling cities near us!",
|
val text = demand.agreedToDemandText.fillPlaceholders(civInfo.civName)
|
||||||
NotificationCategory.Diplomacy, NotificationIcon.Diplomacy, civInfo.civName)
|
otherCiv().addNotification(text, NotificationCategory.Diplomacy, NotificationIcon.Diplomacy, civInfo.civName)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refuseDemandNotToSettleNear() {
|
fun refuseDemand(demand: Demand) {
|
||||||
addModifier(DiplomaticModifiers.UnacceptableDemands, -20f)
|
addModifier(DiplomaticModifiers.UnacceptableDemands, -20f)
|
||||||
otherCivDiplomacy().setFlag(DiplomacyFlags.IgnoreThemSettlingNearUs, 100)
|
otherCivDiplomacy().setFlag(demand.willIgnoreViolation, 100)
|
||||||
otherCivDiplomacy().addModifier(DiplomaticModifiers.RefusedToNotSettleCitiesNearUs, -15f)
|
otherCivDiplomacy().addModifier(demand.refusedDiplomaticModifier, -15f)
|
||||||
otherCiv().addNotification("[${civInfo.civName}] refused to stop settling cities near us!",
|
val text = demand.refusedDemandText.fillPlaceholders(civInfo.civName)
|
||||||
NotificationCategory.Diplomacy, NotificationIcon.Diplomacy, civInfo.civName)
|
otherCiv().addNotification(text, NotificationCategory.Diplomacy, NotificationIcon.Diplomacy, civInfo.civName)
|
||||||
}
|
|
||||||
|
|
||||||
fun agreeNotToSpreadReligionTo() {
|
|
||||||
otherCivDiplomacy().setFlag(DiplomacyFlags.AgreedToNotSpreadReligion, 100)
|
|
||||||
addModifier(DiplomaticModifiers.UnacceptableDemands, -10f)
|
|
||||||
otherCiv().addNotification("[${civInfo.civName}] agreed to stop spreading religion to us!",
|
|
||||||
NotificationCategory.Diplomacy, NotificationIcon.Diplomacy, civInfo.civName)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun refuseNotToSpreadReligionTo() {
|
|
||||||
addModifier(DiplomaticModifiers.UnacceptableDemands, -20f)
|
|
||||||
otherCivDiplomacy().setFlag(DiplomacyFlags.IgnoreThemSpreadingReligion, 100)
|
|
||||||
otherCivDiplomacy().addModifier(DiplomaticModifiers.RefusedToNotSpreadReligionToUs, -15f)
|
|
||||||
otherCiv().addNotification("[${civInfo.civName}] refused to stop spreading religion to us!",
|
|
||||||
NotificationCategory.Diplomacy, NotificationIcon.Diplomacy, civInfo.civName)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun agreeNotToSpreadSpiesTo() {
|
|
||||||
otherCivDiplomacy().setFlag(DiplomacyFlags.AgreedToNotSendSpies, 100)
|
|
||||||
addModifier(DiplomaticModifiers.UnacceptableDemands, -10f)
|
|
||||||
otherCiv().addNotification("[${civInfo.civName}] agreed to stop spying on us!",
|
|
||||||
NotificationCategory.Diplomacy, NotificationIcon.Diplomacy, civInfo.civName)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun refuseNotToSpreadSpiesTo() {
|
|
||||||
addModifier(DiplomaticModifiers.UnacceptableDemands, -20f)
|
|
||||||
otherCivDiplomacy().setFlag(DiplomacyFlags.IgnoreThemSendingSpies, 100)
|
|
||||||
otherCivDiplomacy().addModifier(DiplomaticModifiers.RefusedToNotSendingSpiesToUs, -15f)
|
|
||||||
otherCiv().addNotification("[${civInfo.civName}] refused to stop spying on us!",
|
|
||||||
NotificationCategory.Diplomacy, NotificationIcon.Diplomacy, civInfo.civName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sideWithCityState() {
|
fun sideWithCityState() {
|
||||||
|
@ -269,10 +269,10 @@ class AlertPopup(
|
|||||||
addLeaderName(otherciv)
|
addLeaderName(otherciv)
|
||||||
addGoodSizedLabel("Please don't settle new cities near us.").row()
|
addGoodSizedLabel("Please don't settle new cities near us.").row()
|
||||||
addCloseButton("Very well, we shall look for new lands to settle.", KeyboardBinding.Confirm) {
|
addCloseButton("Very well, we shall look for new lands to settle.", KeyboardBinding.Confirm) {
|
||||||
playerDiploManager.agreeNotToSettleNear()
|
playerDiploManager.agreeToDemand(Demand.DoNotSettleNearUs)
|
||||||
}.row()
|
}.row()
|
||||||
addCloseButton("We shall do as we please.", KeyboardBinding.Cancel) {
|
addCloseButton("We shall do as we please.", KeyboardBinding.Cancel) {
|
||||||
playerDiploManager.refuseDemandNotToSettleNear()
|
playerDiploManager.refuseDemand(Demand.DoNotSettleNearUs)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -284,10 +284,10 @@ class AlertPopup(
|
|||||||
addLeaderName(otherciv)
|
addLeaderName(otherciv)
|
||||||
addGoodSizedLabel("Please don't spread religion to us.").row()
|
addGoodSizedLabel("Please don't spread religion to us.").row()
|
||||||
addCloseButton("Very well, we shall spread our faith elsewhere.", KeyboardBinding.Confirm) {
|
addCloseButton("Very well, we shall spread our faith elsewhere.", KeyboardBinding.Confirm) {
|
||||||
playerDiploManager.agreeNotToSpreadReligionTo()
|
playerDiploManager.agreeToDemand(Demand.DoNotSpreadReligion)
|
||||||
}.row()
|
}.row()
|
||||||
addCloseButton("We shall do as we please.", KeyboardBinding.Cancel) {
|
addCloseButton("We shall do as we please.", KeyboardBinding.Cancel) {
|
||||||
playerDiploManager.refuseNotToSpreadReligionTo()
|
playerDiploManager.refuseDemand(Demand.DoNotSpreadReligion)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -307,10 +307,10 @@ class AlertPopup(
|
|||||||
addLeaderName(otherciv)
|
addLeaderName(otherciv)
|
||||||
addGoodSizedLabel("Stop spying on us.").row()
|
addGoodSizedLabel("Stop spying on us.").row()
|
||||||
addCloseButton("We see our people are not welcome in your lands... we will take our attention elsewhere.", KeyboardBinding.Confirm) {
|
addCloseButton("We see our people are not welcome in your lands... we will take our attention elsewhere.", KeyboardBinding.Confirm) {
|
||||||
playerDiploManager.agreeNotToSpreadSpiesTo()
|
playerDiploManager.agreeToDemand(Demand.DontSpyOnUs)
|
||||||
}.row()
|
}.row()
|
||||||
addCloseButton("I'll do what's necessary for my empire to survive.", KeyboardBinding.Cancel) {
|
addCloseButton("I'll do what's necessary for my empire to survive.", KeyboardBinding.Cancel) {
|
||||||
playerDiploManager.refuseNotToSpreadSpiesTo()
|
playerDiploManager.refuseDemand(Demand.DontSpyOnUs)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user