mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-20 12:48:56 +07:00
Added the culture-refunding remove policy unique (#11538)
This commit is contained in:
@ -139,6 +139,23 @@ class PolicyManager : IsPartOfGameInfoSerialization {
|
||||
// from https://forums.civfanatics.com/threads/the-number-crunching-thread.389702/
|
||||
// round down to nearest 5
|
||||
fun getCultureNeededForNextPolicy(): Int {
|
||||
return getPolicyCultureCost(numberOfAdoptedPolicies)
|
||||
}
|
||||
|
||||
fun getCultureRefundMap(policiesToRemove: List<Policy>, refundPercentage: Int): Map<Policy, Int> {
|
||||
var policyCostInput = numberOfAdoptedPolicies
|
||||
|
||||
val policyMap = mutableMapOf<Policy, Int>()
|
||||
|
||||
for (policy in policiesToRemove) {
|
||||
policyCostInput--
|
||||
policyMap.put(policy, getPolicyCultureCost(policyCostInput))
|
||||
}
|
||||
|
||||
return policyMap.toMap()
|
||||
}
|
||||
|
||||
fun getPolicyCultureCost(numberOfAdoptedPolicies: Int): Int {
|
||||
var policyCultureCost = 25 + (numberOfAdoptedPolicies * 6).toDouble().pow(1.7)
|
||||
// https://civilization.fandom.com/wiki/Map_(Civ5)
|
||||
val worldSizeModifier = with(civInfo.gameInfo.tileMap.mapParameters.mapSize) {
|
||||
|
@ -316,6 +316,33 @@ object UniqueTriggerActivation {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
UniqueType.OneTimeRemovePolicyRefund -> {
|
||||
val policyFilter = unique.params[0]
|
||||
val refundPercentage = unique.params[1].toInt()
|
||||
val policiesToRemove = civInfo.policies.adoptedPolicies
|
||||
.mapNotNull { civInfo.gameInfo.ruleset.policies[it] }
|
||||
.filter { it.matchesFilter(policyFilter) }
|
||||
if (policiesToRemove.isEmpty()) return null
|
||||
|
||||
val policiesToRemoveMap = civInfo.policies.getCultureRefundMap(policiesToRemove, refundPercentage)
|
||||
|
||||
return {
|
||||
for (policy in policiesToRemoveMap){
|
||||
civInfo.policies.removePolicy(policy.key)
|
||||
civInfo.policies.addCulture(policy.value)
|
||||
|
||||
val notificationText = getNotificationText(
|
||||
notification, triggerNotificationText,
|
||||
"You lose the [${policy.key.name}] Policy. [${policy.value}] Culture has been refunded"
|
||||
)
|
||||
if (notificationText != null)
|
||||
civInfo.addNotification(notificationText, PolicyAction(policy.key.name), NotificationCategory.General, NotificationIcon.Culture)
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
UniqueType.OneTimeEnterGoldenAge, UniqueType.OneTimeEnterGoldenAgeTurns -> {
|
||||
return {
|
||||
if (unique.type == UniqueType.OneTimeEnterGoldenAgeTurns) civInfo.goldenAges.enterGoldenAge(unique.params[0].toInt())
|
||||
|
@ -773,6 +773,7 @@ enum class UniqueType(
|
||||
OneTimeDiscoverTech("Discover [tech]", UniqueTarget.Triggerable),
|
||||
OneTimeAdoptPolicy("Adopt [policy]", UniqueTarget.Triggerable),
|
||||
OneTimeRemovePolicy("Remove [policy]", UniqueTarget.Triggerable),
|
||||
OneTimeRemovePolicyRefund("Remove [policy] and refund [amount]% of its cost", UniqueTarget.Triggerable),
|
||||
OneTimeFreeTech("Free Technology", UniqueTarget.Triggerable), // used in Buildings
|
||||
OneTimeAmountFreeTechs("[positiveAmount] Free Technologies", UniqueTarget.Triggerable), // used in Policy
|
||||
OneTimeFreeTechRuins("[positiveAmount] free random researchable Tech(s) from the [era]", UniqueTarget.Triggerable),
|
||||
|
Reference in New Issue
Block a user