mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-25 22:59:12 +07:00
Getting used to multi-param placeholders ;)
This commit is contained in:
parent
362ca7c1e3
commit
0eaad31ce1
@ -174,7 +174,7 @@
|
||||
{
|
||||
"name": "Theocracy",
|
||||
"effect": "Temples give +10% gold",
|
||||
"uniques": ["Temples give +10% gold"],
|
||||
"uniques": ["+[10]% [Gold] from every [Temple]"],
|
||||
"requires": ["Organized Religion"],
|
||||
"row": 2,
|
||||
"column": 1
|
||||
@ -303,22 +303,27 @@
|
||||
"name": "Rationalism",
|
||||
"era": "Renaissance era",
|
||||
"effect": "Production to science conversion in cities increased by 33%",
|
||||
"uniques": ["Production to science conversion in cities increased by 33%"]
|
||||
"policies": [
|
||||
{
|
||||
"name": "Secularism",
|
||||
"effect": "+2 science from every specialist",
|
||||
"uniques": ["[+2 Science] from every specialist"],
|
||||
"row": 1,
|
||||
"column": 2
|
||||
},
|
||||
{
|
||||
"name": "Humanism",
|
||||
"effect": "+1 happiness from every university, observatory and public school",
|
||||
"uniques": ["[+1 Happiness] from every [University]","[+1 Happiness] from every [Observatory]",
|
||||
"[+1 Happiness] from every [Public School]"]
|
||||
"row": 1,
|
||||
"column": 5
|
||||
},
|
||||
{
|
||||
"name": "Free Thought",
|
||||
"effect": "+1 science from every trading post, +17% science from universities",
|
||||
"uniques": ["[+1 Gold] from every [Trading post]", "+[17]% [Science] from every [University]"]
|
||||
"requires": ["Secularism"],
|
||||
"row": 2,
|
||||
"column": 1
|
||||
|
@ -4,6 +4,7 @@ import com.unciv.Constants
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.UniqueAbility
|
||||
import com.unciv.logic.civilization.CityStateType
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.PolicyManager
|
||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||
import com.unciv.logic.map.RoadStatus
|
||||
@ -65,15 +66,18 @@ class CityStats {
|
||||
|
||||
when (cityInfo.cityConstructions.currentConstructionFromQueue) {
|
||||
"Gold" -> stats.gold += production / 4
|
||||
"Science" -> {
|
||||
var scienceProduced = production / 4
|
||||
if (cityInfo.civInfo.policies.hasEffect(Constants.scienceConversionEffect)) scienceProduced *= 1.33f
|
||||
stats.science += scienceProduced
|
||||
}
|
||||
"Science" -> stats.science += production * getScienceConversionRate()
|
||||
}
|
||||
return stats
|
||||
}
|
||||
|
||||
fun getScienceConversionRate(): Float {
|
||||
var conversionRate = 1/4f
|
||||
if (cityInfo.civInfo.hasUnique("Production to science conversion in cities increased by 33%"))
|
||||
conversionRate *= 1.33f
|
||||
return conversionRate
|
||||
}
|
||||
|
||||
private fun getStatPercentBonusesFromRailroad(): Stats {
|
||||
val stats = Stats()
|
||||
val railroadImprovement = cityInfo.getRuleset().tileImprovements["Railroad"]
|
||||
@ -250,7 +254,8 @@ class CityStats {
|
||||
if (stat == Stat.Culture || stat == Stat.Science) stats.add(stat, 3f)
|
||||
else stats.add(stat, 2f) // science and gold specialists
|
||||
|
||||
if (policies.contains("Secularism")) stats.science += 2
|
||||
for(unique in cityInfo.civInfo.getMatchingUniques("[] from every specialist"))
|
||||
stats.add(Stats.parse(unique.getPlaceholderParameters()[0]))
|
||||
if (cityInfo.civInfo.hasUnique("+1 Production from specialists"))
|
||||
stats.production += 1
|
||||
if(cityInfo.civInfo.nation.unique == UniqueAbility.SCHOLARS_OF_THE_JADE_HALL)
|
||||
|
@ -29,7 +29,6 @@ open class PerpetualConstruction(override var name: String, val description: Str
|
||||
|
||||
companion object {
|
||||
const val CONVERSION_RATE: Int = 4
|
||||
const val CONVERSION_RATE_WITH_POLICY = CONVERSION_RATE * 3 / 4
|
||||
val science = object : PerpetualConstruction("Science", "Convert production to science at a rate of [rate] to 1") {
|
||||
override fun isBuildable(cityConstructions: CityConstructions): Boolean {
|
||||
return cityConstructions.cityInfo.civInfo.tech.getTechUniques().contains("Enables conversion of city production to science")
|
||||
@ -37,8 +36,7 @@ open class PerpetualConstruction(override var name: String, val description: Str
|
||||
override fun getProductionTooltip(cityInfo: CityInfo): String {
|
||||
return "\r\n${(cityInfo.cityStats.currentCityStats.production / getConversionRate(cityInfo)).roundToInt()}/${"{turn}".tr()}"
|
||||
}
|
||||
override fun getConversionRate(cityInfo: CityInfo): Int
|
||||
= if (cityInfo.civInfo.policies.hasEffect(Constants.scienceConversionEffect)) CONVERSION_RATE_WITH_POLICY else CONVERSION_RATE
|
||||
override fun getConversionRate(cityInfo: CityInfo) = (1/cityInfo.cityStats.getScienceConversionRate()).roundToInt()
|
||||
}
|
||||
val gold = object : PerpetualConstruction("Gold", "Convert production to gold at a rate of $CONVERSION_RATE to 1") {
|
||||
override fun isBuildable(cityConstructions: CityConstructions): Boolean {
|
||||
|
@ -260,8 +260,6 @@ open class TileInfo {
|
||||
}
|
||||
|
||||
|
||||
if (improvement.name == Constants.tradingPost && city != null
|
||||
&& city.civInfo.policies.hasEffect("+1 science from every trading post, +17% science from universities"))
|
||||
stats.science += 1f
|
||||
if (containsGreatImprovement()
|
||||
&& observingCiv.policies.hasEffect("Tile yield from great improvement +100%, golden ages increase by 50%"))
|
||||
|
@ -160,20 +160,19 @@ class Building : NamedStats(), IConstruction{
|
||||
}
|
||||
|
||||
fun getStatPercentageBonuses(civInfo: CivilizationInfo?): Stats {
|
||||
val stats = if(percentStatBonus==null) Stats() else percentStatBonus!!.clone()
|
||||
if(civInfo==null) return stats // initial stats
|
||||
val stats = if (percentStatBonus == null) Stats() else percentStatBonus!!.clone()
|
||||
if (civInfo == null) return stats // initial stats
|
||||
|
||||
val adoptedPolicies = civInfo.policies.adoptedPolicies
|
||||
val baseBuildingName = getBaseBuilding(civInfo.gameInfo.ruleSet).name
|
||||
|
||||
if (baseBuildingName == "Temple" && civInfo.hasUnique("Temples give +10% gold"))
|
||||
stats.gold = 10f
|
||||
for (unique in civInfo.getMatchingUniques("+[]% [] from every []")) {
|
||||
val placeholderParams = unique.getPlaceholderParameters()
|
||||
if (placeholderParams[2] == baseBuildingName)
|
||||
stats.add(Stat.valueOf(placeholderParams[1]), placeholderParams[0].toFloat())
|
||||
}
|
||||
|
||||
if (baseBuildingName == "University" && adoptedPolicies.contains("Free Thought"))
|
||||
stats.science = 50f
|
||||
|
||||
if(uniques.contains("+5% Production for every Trade Route with a City-State in the empire"))
|
||||
stats.production += 5*civInfo.citiesConnectedToCapitalToMediums.count { it.key.civInfo.isCityState() }
|
||||
if (uniques.contains("+5% Production for every Trade Route with a City-State in the empire"))
|
||||
stats.production += 5 * civInfo.citiesConnectedToCapitalToMediums.count { it.key.civInfo.isCityState() }
|
||||
|
||||
return stats
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user