mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-11 03:18:18 +07:00
Step 2 - started POC breakdown of policy effects to constituent uniques
This will allow mix&matching of policy effects, AND allow them to be used as building uniques as well!
This commit is contained in:
parent
937a832b2c
commit
e7639c93c4
@ -2,11 +2,11 @@
|
|||||||
{
|
{
|
||||||
"name": "Tradition",
|
"name": "Tradition",
|
||||||
"era": "Ancient era",
|
"era": "Ancient era",
|
||||||
"effect": "+3 culture in capital and increased rate of border expansion",
|
"uniques": ["+3 culture in capital", "Increased rate of border expansion"],
|
||||||
"policies": [
|
"policies": [
|
||||||
{
|
{
|
||||||
"name": "Aristocracy",
|
"name": "Aristocracy",
|
||||||
"effect": "+15% production when constructing wonders, +1 happiness for every 10 citizens in a city",
|
"uniques": ["+15% production when constructing wonders", "+1 happiness for every 10 citizens in a city"],
|
||||||
"row": 1,
|
"row": 1,
|
||||||
"column": 1
|
"column": 1
|
||||||
},
|
},
|
||||||
|
@ -38,7 +38,7 @@ class CityExpansionManager {
|
|||||||
cultureToNextTile *= 0.75 //Speciality of Angkor Wat
|
cultureToNextTile *= 0.75 //Speciality of Angkor Wat
|
||||||
if (cityInfo.containsBuildingUnique("Culture and Gold costs of acquiring new tiles reduced by 25% in this city"))
|
if (cityInfo.containsBuildingUnique("Culture and Gold costs of acquiring new tiles reduced by 25% in this city"))
|
||||||
cultureToNextTile *= 0.75 // Specialty of Krepost
|
cultureToNextTile *= 0.75 // Specialty of Krepost
|
||||||
if (cityInfo.civInfo.policies.isAdopted("Tradition")) cultureToNextTile *= 0.75
|
if (cityInfo.civInfo.hasUnique("Increased rate of border expansion")) cultureToNextTile *= 0.75
|
||||||
return cultureToNextTile.roundToInt()
|
return cultureToNextTile.roundToInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ class CityStats {
|
|||||||
newHappinessList["Population"] = -unhappinessFromCitizens * unhappinessModifier
|
newHappinessList["Population"] = -unhappinessFromCitizens * unhappinessModifier
|
||||||
|
|
||||||
var happinessFromPolicies = 0f
|
var happinessFromPolicies = 0f
|
||||||
if (civInfo.policies.hasEffect("+15% production when constructing wonders, +1 happiness for every 10 citizens in a city"))
|
if (civInfo.hasUnique("+1 happiness for every 10 citizens in a city"))
|
||||||
happinessFromPolicies += (cityInfo.population.population / 10).toFloat()
|
happinessFromPolicies += (cityInfo.population.population / 10).toFloat()
|
||||||
if (civInfo.policies.hasEffect("+1 gold and -1 unhappiness for every 2 citizens in capital")
|
if (civInfo.policies.hasEffect("+1 gold and -1 unhappiness for every 2 citizens in capital")
|
||||||
&& cityInfo.isCapital())
|
&& cityInfo.isCapital())
|
||||||
@ -262,7 +262,7 @@ class CityStats {
|
|||||||
|
|
||||||
private fun getStatsFromPolicies(adoptedPolicies: PolicyManager): Stats {
|
private fun getStatsFromPolicies(adoptedPolicies: PolicyManager): Stats {
|
||||||
val stats = Stats()
|
val stats = Stats()
|
||||||
if (adoptedPolicies.hasEffect("+3 culture in capital and increased rate of border expansion") && cityInfo.isCapital())
|
if (adoptedPolicies.hasEffect("+3 culture in capital") && cityInfo.isCapital())
|
||||||
stats.culture += 3f
|
stats.culture += 3f
|
||||||
if (adoptedPolicies.hasEffect("+10% food growth and +2 food in capital") && cityInfo.isCapital())
|
if (adoptedPolicies.hasEffect("+10% food growth and +2 food in capital") && cityInfo.isCapital())
|
||||||
stats.food += 2f
|
stats.food += 2f
|
||||||
@ -346,7 +346,7 @@ class CityStats {
|
|||||||
stats.science += 15f
|
stats.science += 15f
|
||||||
if (policies.contains("Total War") && currentConstruction is BaseUnit && !currentConstruction.unitType.isCivilian())
|
if (policies.contains("Total War") && currentConstruction is BaseUnit && !currentConstruction.unitType.isCivilian())
|
||||||
stats.production += 15f
|
stats.production += 15f
|
||||||
if (policies.contains("Aristocracy")
|
if (cityInfo.civInfo.hasUnique("+15% production when constructing wonders")
|
||||||
&& currentConstruction is Building
|
&& currentConstruction is Building
|
||||||
&& currentConstruction.isWonder)
|
&& currentConstruction.isWonder)
|
||||||
stats.production += 15f
|
stats.production += 15f
|
||||||
|
@ -36,10 +36,12 @@ class PolicyManager {
|
|||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getPolicyByName(name:String): Policy = getAllPolicies().first { it.name==name }
|
||||||
|
|
||||||
fun setTransients(){
|
fun setTransients(){
|
||||||
val allPolicies = getAllPolicies()
|
val effectsOfCurrentPolicies = adoptedPolicies.map { getPolicyByName(it).effect }
|
||||||
val effectsOfCurrentPolicies = adoptedPolicies.map { adoptedPolicy -> allPolicies.first { it.name==adoptedPolicy }.effect }
|
|
||||||
policyEffects.addAll(effectsOfCurrentPolicies)
|
policyEffects.addAll(effectsOfCurrentPolicies)
|
||||||
|
adoptedPolicies.map { getPolicyByName(it).uniques }.forEach { policyEffects.addAll(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAllPolicies() = civInfo.gameInfo.ruleSet.policyBranches.values.asSequence()
|
private fun getAllPolicies() = civInfo.gameInfo.ruleSet.policyBranches.values.asSequence()
|
||||||
@ -114,6 +116,7 @@ class PolicyManager {
|
|||||||
|
|
||||||
adoptedPolicies.add(policy.name)
|
adoptedPolicies.add(policy.name)
|
||||||
policyEffects.add(policy.effect)
|
policyEffects.add(policy.effect)
|
||||||
|
policyEffects.addAll(policy.uniques)
|
||||||
|
|
||||||
if (!branchCompletion) {
|
if (!branchCompletion) {
|
||||||
val branch = policy.branch
|
val branch = policy.branch
|
||||||
|
@ -7,6 +7,7 @@ open class Policy : INamed {
|
|||||||
|
|
||||||
override lateinit var name: String
|
override lateinit var name: String
|
||||||
lateinit var effect: String
|
lateinit var effect: String
|
||||||
|
var uniques: ArrayList<String> = ArrayList()
|
||||||
var row: Int = 0
|
var row: Int = 0
|
||||||
var column: Int = 0
|
var column: Int = 0
|
||||||
var requires: ArrayList<String>? = null
|
var requires: ArrayList<String>? = null
|
||||||
|
Loading…
Reference in New Issue
Block a user