mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 10:54:19 -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) {
|
||||
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 diploManager = civInfo.getDiplomacyManager(demandingCiv)!!
|
||||
if (Automation.threatAssessment(civInfo, demandingCiv) >= ThreatLevel.High
|
||||
|| diploManager.isRelationshipLevelGT(RelationshipLevel.Ally))
|
||||
diploManager.agreeNotToSpreadReligionTo()
|
||||
else diploManager.refuseNotToSpreadReligionTo()
|
||||
diploManager.agreeToDemand(demand)
|
||||
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) {
|
||||
|
@ -9,7 +9,9 @@ enum class Demand(
|
||||
val refusedDiplomaticModifier: DiplomaticModifiers,
|
||||
val betrayedPromiseDiplomacyMpodifier: DiplomaticModifiers,
|
||||
val demandAlert: AlertType,
|
||||
val violationDiscoveredAlert: AlertType) {
|
||||
val violationDiscoveredAlert: AlertType,
|
||||
val agreedToDemandText: String,
|
||||
val refusedDemandText: String) {
|
||||
DontSpyOnUs(
|
||||
agreedToDemand = DiplomacyFlags.AgreedToNotSendSpies,
|
||||
violationOccurred = DiplomacyFlags.DiscoveredSpiesInOurCities,
|
||||
@ -17,7 +19,9 @@ enum class Demand(
|
||||
refusedDiplomaticModifier = DiplomaticModifiers.RefusedToNotSendingSpiesToUs,
|
||||
betrayedPromiseDiplomacyMpodifier = DiplomaticModifiers.BetrayedPromiseToNotSendingSpiesToUs,
|
||||
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(
|
||||
agreedToDemand = DiplomacyFlags.AgreedToNotSpreadReligion,
|
||||
@ -26,7 +30,9 @@ enum class Demand(
|
||||
refusedDiplomaticModifier = DiplomaticModifiers.RefusedToNotSpreadReligionToUs,
|
||||
betrayedPromiseDiplomacyMpodifier = DiplomaticModifiers.BetrayedPromiseToNotSpreadReligionToUs,
|
||||
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(
|
||||
agreedToDemand = DiplomacyFlags.AgreedToNotSettleNearUs,
|
||||
@ -35,7 +41,9 @@ enum class Demand(
|
||||
refusedDiplomaticModifier = DiplomaticModifiers.RefusedToNotSettleCitiesNearUs,
|
||||
betrayedPromiseDiplomacyMpodifier = DiplomaticModifiers.BetrayedPromiseToNotSettleCitiesNearUs,
|
||||
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.UniqueTriggerActivation
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.translations.fillPlaceholders
|
||||
import com.unciv.ui.components.extensions.toPercent
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.max
|
||||
@ -684,49 +685,19 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
}
|
||||
|
||||
fun agreeNotToSettleNear() {
|
||||
otherCivDiplomacy().setFlag(DiplomacyFlags.AgreedToNotSettleNearUs, 100)
|
||||
fun agreeToDemand(demand: Demand){
|
||||
otherCivDiplomacy().setFlag(demand.agreedToDemand, 100)
|
||||
addModifier(DiplomaticModifiers.UnacceptableDemands, -10f)
|
||||
otherCiv().addNotification("[${civInfo.civName}] agreed to stop settling cities near us!",
|
||||
NotificationCategory.Diplomacy, NotificationIcon.Diplomacy, civInfo.civName)
|
||||
val text = demand.agreedToDemandText.fillPlaceholders(civInfo.civName)
|
||||
otherCiv().addNotification(text, NotificationCategory.Diplomacy, NotificationIcon.Diplomacy, civInfo.civName)
|
||||
}
|
||||
|
||||
fun refuseDemandNotToSettleNear() {
|
||||
fun refuseDemand(demand: Demand) {
|
||||
addModifier(DiplomaticModifiers.UnacceptableDemands, -20f)
|
||||
otherCivDiplomacy().setFlag(DiplomacyFlags.IgnoreThemSettlingNearUs, 100)
|
||||
otherCivDiplomacy().addModifier(DiplomaticModifiers.RefusedToNotSettleCitiesNearUs, -15f)
|
||||
otherCiv().addNotification("[${civInfo.civName}] refused to stop settling cities near us!",
|
||||
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)
|
||||
otherCivDiplomacy().setFlag(demand.willIgnoreViolation, 100)
|
||||
otherCivDiplomacy().addModifier(demand.refusedDiplomaticModifier, -15f)
|
||||
val text = demand.refusedDemandText.fillPlaceholders(civInfo.civName)
|
||||
otherCiv().addNotification(text, NotificationCategory.Diplomacy, NotificationIcon.Diplomacy, civInfo.civName)
|
||||
}
|
||||
|
||||
fun sideWithCityState() {
|
||||
|
@ -269,10 +269,10 @@ class AlertPopup(
|
||||
addLeaderName(otherciv)
|
||||
addGoodSizedLabel("Please don't settle new cities near us.").row()
|
||||
addCloseButton("Very well, we shall look for new lands to settle.", KeyboardBinding.Confirm) {
|
||||
playerDiploManager.agreeNotToSettleNear()
|
||||
playerDiploManager.agreeToDemand(Demand.DoNotSettleNearUs)
|
||||
}.row()
|
||||
addCloseButton("We shall do as we please.", KeyboardBinding.Cancel) {
|
||||
playerDiploManager.refuseDemandNotToSettleNear()
|
||||
playerDiploManager.refuseDemand(Demand.DoNotSettleNearUs)
|
||||
}
|
||||
return true
|
||||
}
|
||||
@ -284,10 +284,10 @@ class AlertPopup(
|
||||
addLeaderName(otherciv)
|
||||
addGoodSizedLabel("Please don't spread religion to us.").row()
|
||||
addCloseButton("Very well, we shall spread our faith elsewhere.", KeyboardBinding.Confirm) {
|
||||
playerDiploManager.agreeNotToSpreadReligionTo()
|
||||
playerDiploManager.agreeToDemand(Demand.DoNotSpreadReligion)
|
||||
}.row()
|
||||
addCloseButton("We shall do as we please.", KeyboardBinding.Cancel) {
|
||||
playerDiploManager.refuseNotToSpreadReligionTo()
|
||||
playerDiploManager.refuseDemand(Demand.DoNotSpreadReligion)
|
||||
}
|
||||
return true
|
||||
}
|
||||
@ -307,10 +307,10 @@ class AlertPopup(
|
||||
addLeaderName(otherciv)
|
||||
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) {
|
||||
playerDiploManager.agreeNotToSpreadSpiesTo()
|
||||
playerDiploManager.agreeToDemand(Demand.DontSpyOnUs)
|
||||
}.row()
|
||||
addCloseButton("I'll do what's necessary for my empire to survive.", KeyboardBinding.Cancel) {
|
||||
playerDiploManager.refuseNotToSpreadSpiesTo()
|
||||
playerDiploManager.refuseDemand(Demand.DontSpyOnUs)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user