Converted policies up to Collective Rule
This commit is contained in:
parent
a5f7aee1ea
commit
627283b10b
5 changed files with 58 additions and 36 deletions
|
@ -2,10 +2,12 @@
|
||||||
{
|
{
|
||||||
"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"],
|
"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"],
|
"uniques": ["+15% production when constructing wonders", "+1 happiness for every 10 citizens in a city"],
|
||||||
"row": 1,
|
"row": 1,
|
||||||
"column": 1
|
"column": 1
|
||||||
|
@ -13,18 +15,21 @@
|
||||||
{
|
{
|
||||||
"name": "Legalism",
|
"name": "Legalism",
|
||||||
"effect": "Immediately creates a cheapest available cultural building in each of your first 4 cities for free",
|
"effect": "Immediately creates a cheapest available cultural building in each of your first 4 cities for free",
|
||||||
|
"uniques":["Immediately creates a cheapest available cultural building in each of your first 4 cities for free"],
|
||||||
"row": 1,
|
"row": 1,
|
||||||
"column": 3
|
"column": 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Oligarchy",
|
"name": "Oligarchy",
|
||||||
"effect": "Units in cities cost no Maintenance, garrisoned city +50% attacking strength",
|
"effect": "Units in cities cost no Maintenance, garrisoned city +50% attacking strength",
|
||||||
|
"uniques": ["Units in cities cost no Maintenance"]
|
||||||
"row": 1,
|
"row": 1,
|
||||||
"column": 5
|
"column": 5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Landed Elite",
|
"name": "Landed Elite",
|
||||||
"effect": "+10% food growth and +2 food in capital",
|
"effect": "+10% food growth and +2 food in capital",
|
||||||
|
"uniques": ["+10% food growth in capital", "[+2 Food] in capital"],
|
||||||
"requires": ["Legalism"],
|
"requires": ["Legalism"],
|
||||||
"row": 2,
|
"row": 2,
|
||||||
"column": 2
|
"column": 2
|
||||||
|
@ -32,13 +37,15 @@
|
||||||
{
|
{
|
||||||
"name": "Monarchy",
|
"name": "Monarchy",
|
||||||
"effect": "+1 gold and -1 unhappiness for every 2 citizens in capital",
|
"effect": "+1 gold and -1 unhappiness for every 2 citizens in capital",
|
||||||
|
"uniques": ["+1 gold and -1 unhappiness for every 2 citizens in capital"],
|
||||||
"requires": ["Legalism"],
|
"requires": ["Legalism"],
|
||||||
"row": 2,
|
"row": 2,
|
||||||
"column": 4
|
"column": 4
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Tradition Complete",
|
"name": "Tradition Complete",
|
||||||
"effect": "+15% growth and +2 food in all cities"
|
"effect": "+15% growth and +2 food in all cities",
|
||||||
|
"uniques": ["+15% growth in all cities","[+2 Food] in all cities"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -46,10 +53,12 @@
|
||||||
"name": "Liberty",
|
"name": "Liberty",
|
||||||
"era": "Ancient era",
|
"era": "Ancient era",
|
||||||
"effect": "+1 culture in every city",
|
"effect": "+1 culture in every city",
|
||||||
|
"uniques": ["[+1 Culture] in all cities"],
|
||||||
"policies": [
|
"policies": [
|
||||||
{
|
{
|
||||||
"name": "Collective Rule",
|
"name": "Collective Rule",
|
||||||
"effect": "Training of settlers increased +50% in capital, receive a new settler near the capital",
|
"effect": "Training of settlers increased +50% in capital, receive a new settler near the capital",
|
||||||
|
"uniques": ["Training of settlers increased +50% in capital", "Free [Settler] appears"]
|
||||||
"row": 1,
|
"row": 1,
|
||||||
"column": 1
|
"column": 1
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,6 +12,8 @@ import com.unciv.models.ruleset.unit.BaseUnit
|
||||||
import com.unciv.models.ruleset.unit.UnitType
|
import com.unciv.models.ruleset.unit.UnitType
|
||||||
import com.unciv.models.stats.Stat
|
import com.unciv.models.stats.Stat
|
||||||
import com.unciv.models.stats.Stats
|
import com.unciv.models.stats.Stats
|
||||||
|
import com.unciv.models.translations.equalsPlaceholderText
|
||||||
|
import com.unciv.models.translations.getPlaceholderParameters
|
||||||
|
|
||||||
|
|
||||||
class CityStats {
|
class CityStats {
|
||||||
|
@ -164,9 +166,9 @@ class CityStats {
|
||||||
|
|
||||||
fun getGrowthBonusFromPolicies(): Float {
|
fun getGrowthBonusFromPolicies(): Float {
|
||||||
var bonus = 0f
|
var bonus = 0f
|
||||||
if (cityInfo.civInfo.policies.hasEffect("+10% food growth and +2 food in capital") && cityInfo.isCapital())
|
if (cityInfo.civInfo.hasUnique("+10% food growth in capital") && cityInfo.isCapital())
|
||||||
bonus += 0.1f
|
bonus += 0.1f
|
||||||
if (cityInfo.civInfo.policies.hasEffect("+15% growth and +2 food in all cities"))
|
if (cityInfo.civInfo.hasUnique("+15% growth in all cities"))
|
||||||
bonus += 0.15f
|
bonus += 0.15f
|
||||||
return bonus
|
return bonus
|
||||||
}
|
}
|
||||||
|
@ -264,10 +266,12 @@ class CityStats {
|
||||||
val stats = Stats()
|
val stats = Stats()
|
||||||
if (adoptedPolicies.hasEffect("+3 culture in capital") && 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())
|
for(effect in adoptedPolicies.policyEffects) {
|
||||||
stats.food += 2f
|
if (effect.equalsPlaceholderText("[] in capital") && cityInfo.isCapital())
|
||||||
if (adoptedPolicies.hasEffect("+15% growth and +2 food in all cities"))
|
stats.add(Stats.parse(effect.getPlaceholderParameters()[0]))
|
||||||
stats.food += 2f
|
else if(effect.equalsPlaceholderText("[] in all cities"))
|
||||||
|
stats.add(Stats.parse(effect.getPlaceholderParameters()[0]))
|
||||||
|
}
|
||||||
if (adoptedPolicies.hasEffect("+1 gold and -1 unhappiness for every 2 citizens in capital") && cityInfo.isCapital())
|
if (adoptedPolicies.hasEffect("+1 gold and -1 unhappiness for every 2 citizens in capital") && cityInfo.isCapital())
|
||||||
stats.gold += (cityInfo.population.population / 2).toFloat()
|
stats.gold += (cityInfo.population.population / 2).toFloat()
|
||||||
if (adoptedPolicies.hasEffect("+1 culture in every city"))
|
if (adoptedPolicies.hasEffect("+1 culture in every city"))
|
||||||
|
|
|
@ -20,11 +20,10 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
||||||
val baseUnitCost = 0.5f
|
val baseUnitCost = 0.5f
|
||||||
val freeUnits = 3
|
val freeUnits = 3
|
||||||
var unitsToPayFor = civInfo.getCivUnits()
|
var unitsToPayFor = civInfo.getCivUnits()
|
||||||
if(civInfo.policies.hasEffect("Units in cities cost no Maintenance, garrisoned city +50% attacking strength"))
|
if(civInfo.hasUnique("Units in cities cost no Maintenance"))
|
||||||
// Only land military units can truly "garrison"
|
// Only land military units can truly "garrison"
|
||||||
unitsToPayFor = unitsToPayFor.filterNot {
|
unitsToPayFor = unitsToPayFor.filterNot {
|
||||||
it.getTile().isCityCenter()
|
it.getTile().isCityCenter() && it.canGarrison()
|
||||||
&& it.canGarrison()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var numberOfUnitsToPayFor = max(0f, unitsToPayFor.count().toFloat() - freeUnits)
|
var numberOfUnitsToPayFor = max(0f, unitsToPayFor.count().toFloat() - freeUnits)
|
||||||
|
|
|
@ -3,6 +3,10 @@ package com.unciv.logic.civilization
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
import com.unciv.models.ruleset.Policy
|
import com.unciv.models.ruleset.Policy
|
||||||
import com.unciv.models.ruleset.VictoryType
|
import com.unciv.models.ruleset.VictoryType
|
||||||
|
import com.unciv.models.translations.equalsPlaceholderText
|
||||||
|
import com.unciv.models.translations.getPlaceholderParameters
|
||||||
|
import com.unciv.models.translations.getPlaceholderText
|
||||||
|
import com.unciv.ui.utils.withItem
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
@ -126,32 +130,36 @@ class PolicyManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
val hasCapital = civInfo.cities.any { it.isCapital() }
|
val hasCapital = civInfo.cities.any { it.isCapital() }
|
||||||
when (policy.effect) {
|
|
||||||
"Training of settlers increased +50% in capital, receive a new settler near the capital" ->
|
for(effect in policy.uniques.withItem(policy.effect))
|
||||||
if (hasCapital && !civInfo.isOneCityChallenger())
|
when (effect.getPlaceholderText()) {
|
||||||
civInfo.placeUnitNearTile(civInfo.getCapital().location, Constants.settler)
|
"Free [] appears" -> {
|
||||||
"Tile improvement speed +25%, receive a free worker near the capital" ->
|
val unitName = effect.getPlaceholderParameters()[0]
|
||||||
if (hasCapital) civInfo.placeUnitNearTile(civInfo.getCapital().location, Constants.worker)
|
if (hasCapital && (unitName != Constants.settler || !civInfo.isOneCityChallenger()))
|
||||||
"+1 culture for each monument, temple and monastery. Gain a free policy." -> freePolicies++
|
civInfo.placeUnitNearTile(civInfo.getCapital().location, unitName)
|
||||||
"Each city founded increases culture cost of policies 33% less than normal. Starts a golden age.",
|
|
||||||
"+33% culture in all cities with a world wonder, immediately enter a golden age" ->
|
|
||||||
civInfo.goldenAges.enterGoldenAge()
|
|
||||||
"Free Great Person of choice near capital" -> {
|
|
||||||
if (civInfo.isPlayerCivilization()) civInfo.greatPeople.freeGreatPeople++
|
|
||||||
else {
|
|
||||||
val preferredVictoryType = civInfo.victoryType()
|
|
||||||
val greatPerson = when (preferredVictoryType) {
|
|
||||||
VictoryType.Cultural -> "Great Artist"
|
|
||||||
VictoryType.Scientific -> "Great Scientist"
|
|
||||||
VictoryType.Domination, VictoryType.Neutral ->
|
|
||||||
civInfo.gameInfo.ruleSet.units.keys.filter { it.startsWith("Great") }.random()
|
|
||||||
}
|
|
||||||
civInfo.addGreatPerson(greatPerson)
|
|
||||||
}
|
}
|
||||||
|
"Tile improvement speed +25%, receive a free worker near the capital" ->
|
||||||
|
if (hasCapital) civInfo.placeUnitNearTile(civInfo.getCapital().location, Constants.worker)
|
||||||
|
"+1 culture for each monument, temple and monastery. Gain a free policy." -> freePolicies++
|
||||||
|
"Each city founded increases culture cost of policies 33% less than normal. Starts a golden age.",
|
||||||
|
"+33% culture in all cities with a world wonder, immediately enter a golden age" ->
|
||||||
|
civInfo.goldenAges.enterGoldenAge()
|
||||||
|
"Free Great Person of choice near capital" -> {
|
||||||
|
if (civInfo.isPlayerCivilization()) civInfo.greatPeople.freeGreatPeople++
|
||||||
|
else {
|
||||||
|
val preferredVictoryType = civInfo.victoryType()
|
||||||
|
val greatPerson = when (preferredVictoryType) {
|
||||||
|
VictoryType.Cultural -> "Great Artist"
|
||||||
|
VictoryType.Scientific -> "Great Scientist"
|
||||||
|
VictoryType.Domination, VictoryType.Neutral ->
|
||||||
|
civInfo.gameInfo.ruleSet.units.keys.filter { it.startsWith("Great") }.random()
|
||||||
|
}
|
||||||
|
civInfo.addGreatPerson(greatPerson)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"Quantity of strategic resources produced by the empire increased by 100%" -> civInfo.updateDetailedCivResources()
|
||||||
|
"+20% attack bonus to all Military Units for 30 turns" -> autocracyCompletedTurns = 30
|
||||||
}
|
}
|
||||||
"Quantity of strategic resources produced by the empire increased by 100%" -> civInfo.updateDetailedCivResources()
|
|
||||||
"+20% attack bonus to all Military Units for 30 turns" -> autocracyCompletedTurns = 30
|
|
||||||
}
|
|
||||||
tryAddLegalismBuildings()
|
tryAddLegalismBuildings()
|
||||||
|
|
||||||
// This ALSO has the side-effect of updating the CivInfo statForNextTurn so we don't need to call it explicitly
|
// This ALSO has the side-effect of updating the CivInfo statForNextTurn so we don't need to call it explicitly
|
||||||
|
@ -162,7 +170,7 @@ class PolicyManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun tryAddLegalismBuildings() {
|
fun tryAddLegalismBuildings() {
|
||||||
if(!civInfo.policies.hasEffect("Immediately creates a cheapest available cultural building in each of your first 4 cities for free"))
|
if(!civInfo.hasUnique("Immediately creates a cheapest available cultural building in each of your first 4 cities for free"))
|
||||||
return
|
return
|
||||||
if(legalismState.size >= 4) return
|
if(legalismState.size >= 4) return
|
||||||
|
|
||||||
|
|
|
@ -275,9 +275,11 @@ fun String.tr(): String {
|
||||||
return UncivGame.Current.translations.getText(this, UncivGame.Current.settings.language, activeMods)
|
return UncivGame.Current.translations.getText(this, UncivGame.Current.settings.language, activeMods)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun String.getPlaceholderText() = this.replace(squareBraceRegex, "[]")
|
||||||
|
|
||||||
fun String.equalsPlaceholderText(str:String): Boolean {
|
fun String.equalsPlaceholderText(str:String): Boolean {
|
||||||
if (first() != str.first()) return false // for quick negative return 95% of the time
|
if (first() != str.first()) return false // for quick negative return 95% of the time
|
||||||
return this.replace(squareBraceRegex, "[]") == str
|
return this.getPlaceholderText() == str
|
||||||
}
|
}
|
||||||
|
|
||||||
fun String.getPlaceholderParameters() = squareBraceRegex.findAll(this).map { it.groups[1]!!.value }.toList()
|
fun String.getPlaceholderParameters() = squareBraceRegex.findAll(this).map { it.groups[1]!!.value }.toList()
|
Loading…
Reference in a new issue