Added a check to see if a policy effect was active - this is an important step towards "different effects for the same policy name", as happens between Vanilla and G&K/BNW

This commit is contained in:
Yair Morgenstern
2020-04-16 11:05:49 +03:00
parent 68af30acf0
commit c1f0084fb0
9 changed files with 104 additions and 88 deletions

View File

@ -2,435 +2,435 @@
{
"name": "Tradition",
"era": "Ancient",
"description": "+3 culture in capital and increased rate of border expansion",
"effect": "+3 culture in capital and increased rate of border expansion",
"policies": [
{
"name": "Aristocracy",
"description": "+15% production when constructing wonders, +1 happiness for every 10 citizens in a city",
"effect": "+15% production when constructing wonders, +1 happiness for every 10 citizens in a city",
"row": 1,
"column": 1
},
{
"name": "Legalism",
"description": "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",
"row": 1,
"column": 3
},
{
"name": "Oligarchy",
"description": "Units in cities cost no Maintenance, garrisoned city +50% attacking strength",
"effect": "Units in cities cost no Maintenance, garrisoned city +50% attacking strength",
"row": 1,
"column": 5
},
{
"name": "Landed Elite",
"description": "+10% food growth and +2 food in capital",
"effect": "+10% food growth and +2 food in capital",
"requires": ["Legalism"],
"row": 2,
"column": 2
},
{
"name": "Monarchy",
"description": "+1 gold and -1 unhappiness for every 2 citizens in capital",
"effect": "+1 gold and -1 unhappiness for every 2 citizens in capital",
"requires": ["Legalism"],
"row": 2,
"column": 4
},
{
"name": "Tradition Complete",
"description": "+15% growth and +2 food in all cities"
"effect": "+15% growth and +2 food in all cities"
}
]
},
{
"name": "Liberty",
"era": "Ancient",
"description": "+1 culture in every city",
"effect": "+1 culture in every city",
"policies": [
{
"name": "Collective Rule",
"description": "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",
"row": 1,
"column": 1
},
{
"name": "Citizenship",
"description": "Tile improvement speed +25%, receive a free worker near the capital",
"effect": "Tile improvement speed +25%, receive a free worker near the capital",
"row": 1,
"column": 4
},
{
"name": "Republic",
"description": "+1 production in every city, +5% production when constructing buildings",
"effect": "+1 production in every city, +5% production when constructing buildings",
"requires": ["Collective Rule"],
"row": 2,
"column": 1
},
{
"name": "Representation",
"description": "Each city founded increases culture cost of policies 33% less than normal. Starts a golden age.",
"effect": "Each city founded increases culture cost of policies 33% less than normal. Starts a golden age.",
"requires": ["Citizenship"],
"row": 2,
"column": 3
},
{
"name": "Meritocracy",
"description": "+1 happiness for every city connected to capital, -5% unhappiness from citizens",
"effect": "+1 happiness for every city connected to capital, -5% unhappiness from citizens",
"requires": ["Citizenship"],
"row": 2,
"column": 5
},
{
"name": "Liberty Complete",
"description": "Free Great Person of choice near capital"
"effect": "Free Great Person of choice near capital"
}
]
},
{
"name": "Honor",
"era": "Ancient",
"description": "+25% bonus vs Barbarians; gain Culture when you kill a barbarian unit",
"effect": "+25% bonus vs Barbarians; gain Culture when you kill a barbarian unit",
"policies": [
{
"name": "Warrior Code",
"description": "+20% production when training melee units",
"effect": "+20% production when training melee units",
"row": 1,
"column": 2
},
{
"name": "Discipline",
"description": "+15% combat strength for melee units which have another military unit in an adjacent tile",
"effect": "+15% combat strength for melee units which have another military unit in an adjacent tile",
"row": 1,
"column": 4
},
{
"name": "Military Tradition",
"description": "Military units gain 50% more Experience from combat",
"effect": "Military units gain 50% more Experience from combat",
"requires": ["Warrior Code"],
"row": 2,
"column": 2
},
{
"name": "Military Caste",
"description": "Each city with a garrison increases happiness by 1 and culture by 2",
"effect": "Each city with a garrison increases happiness by 1 and culture by 2",
"requires": ["Discipline"],
"row": 2,
"column": 4
},
{
"name": "Professional Army",
"description": "Gold cost of upgrading military units reduced by 33%",
"effect": "Gold cost of upgrading military units reduced by 33%",
"requires": ["Military Caste"],
"row": 3,
"column": 4
},
{
"name": "Honor Complete",
"description": "Gain gold for each unit killed"
"effect": "Gain gold for each unit killed"
}
]
},{
"name": "Piety",
"era": "Classical",
"description": "Building time of culture buildings reduced by 15%",
"effect": "Building time of culture buildings reduced by 15%",
"policies": [
{
"name": "Organized Religion",
"description": "+1 happiness for each monument, temple and monastery",
"effect": "+1 happiness for each monument, temple and monastery",
"row": 1,
"column": 2
},
{
"name": "Mandate Of Heaven",
"description": "50% of excess happiness added to culture towards policies",
"effect": "50% of excess happiness added to culture towards policies",
"row": 1,
"column": 5
},
{
"name": "Theocracy",
"description": "Temples give +10% gold",
"effect": "Temples give +10% gold",
"requires": ["Organized Religion"],
"row": 2,
"column": 1
},
{
"name": "Reformation",
"description": "+33% culture in all cities with a world wonder, immediately enter a golden age",
"effect": "+33% culture in all cities with a world wonder, immediately enter a golden age",
"requires": ["Organized Religion"],
"row": 2,
"column": 3
},
{
"name": "Free Religion",
"description": "+1 culture for each monument, temple and monastery. Gain a free policy.",
"effect": "+1 culture for each monument, temple and monastery. Gain a free policy.",
"requires": ["Mandate Of Heaven","Reformation"],
"row": 3,
"column": 4
},
{
"name": "Piety Complete",
"description": "Reduce culture cost of future policies by 10%"
"effect": "Reduce culture cost of future policies by 10%"
}
]
},/*{
"name": "Patronage",
"era": "Classical",
"description": "Influence with City-States degrades 25% slower than normal",
"effect": "Influence with City-States degrades 25% slower than normal",
"policies": [
{
"name": "Philantropy",
"description": "Gifting Gold to a City-State generates 25% more Influence",
"effect": "Gifting Gold to a City-State generates 25% more Influence",
"row": 1,
"column": 2
},
{
"name": "Aesthetics",
"description": "Resting point for Influence level with all City-States is increased by 20",
"effect": "Resting point for Influence level with all City-States is increased by 20",
"row": 1,
"column": 4
},
{
"name": "Scholasticism",
"description": "All Allied City-States provide a Science bonus equal to 25% of what they produce for themselves",
"effect": "All Allied City-States provide a Science bonus equal to 25% of what they produce for themselves",
"requires": ["Philantropy"],
"row": 2,
"column": 2
},
{
"name": "Cultural Diplomacy",
"description": "Happiness from gifted Luxuries increased by 50%",
"effect": "Happiness from gifted Luxuries increased by 50%",
"requires": ["Scholasticism"],
"row": 3,
"column": 2
},
{
"name": "Educated Elite",
"description": "Allied City-States will occasionally gift you Great People",
"effect": "Allied City-States will occasionally gift you Great People",
"requires": ["Scholasticism","Aesthetics"],
"row": 3,
"column": 4
},
{
"name": "Patronage Complete",
"description": "Influence with City-States degrades 25% slower than normal"
"effect": "Influence with City-States degrades 25% slower than normal"
}
]
},*/
{
"name": "Commerce",
"description": "+25% gold in capital",
"effect": "+25% gold in capital",
"era": "Medieval",
"policies": [
{
"name": "Trade Unions",
"description": "Maintenance on roads & railroads reduced by 33%, +2 gold from all trade routes",
"effect": "Maintenance on roads & railroads reduced by 33%, +2 gold from all trade routes",
"row": 1,
"column": 2
},
{
"name": "Mercantilism",
"description": "-25% to purchasing items in cities",
"effect": "-25% to purchasing items in cities",
"row": 1,
"column": 5
},
{
"name": "Entrepreneurship",
"description": "Great Merchants are earned 25% faster, +1 Science from every Mint, Market, Bank and Stock Exchange.",
"effect": "Great Merchants are earned 25% faster, +1 Science from every Mint, Market, Bank and Stock Exchange.",
"requires": ["Trade Unions"],
"row": 2,
"column": 2
},
{
"name": "Patronage",
"description": "Cost of purchasing culture buildings reduced by 50%",
"effect": "Cost of purchasing culture buildings reduced by 50%",
"requires": ["Mercantilism"],
"row": 2,
"column": 5
},
{
"name": "Protectionism",
"description": "+1 happiness from each luxury resource",
"effect": "+1 happiness from each luxury resource",
"requires": ["Entrepreneurship","Patronage"],
"row": 3,
"column": 3
},
{
"name": "Commerce Complete",
"description": "+1 gold from every trading post, double gold from Great Merchant trade missions"
"effect": "+1 gold from every trading post, double gold from Great Merchant trade missions"
}
]
},
{
"name": "Rationalism",
"era": "Renaissance",
"description": "Production to science conversion in cities increased by 33%",
"effect": "Production to science conversion in cities increased by 33%",
"policies": [
{
"name": "Secularism",
"description": "+2 science from every specialist",
"effect": "+2 science from every specialist",
"row": 1,
"column": 2
},
{
"name": "Humanism",
"description": "+1 happiness from every university, observatory and public school",
"effect": "+1 happiness from every university, observatory and public school",
"row": 1,
"column": 5
},
{
"name": "Free Thought",
"description": "+1 science from every trading post, +17% science from universities",
"effect": "+1 science from every trading post, +17% science from universities",
"requires": ["Secularism"],
"row": 2,
"column": 1
},
{
"name": "Sovereignty",
"description": "+15% science while empire is happy",
"effect": "+15% science while empire is happy",
"requires": ["Humanism"],
"row": 2,
"column": 5
},
{
"name": "Scientific Revolution",
"description": "Science gained from research agreements +50%",
"effect": "Science gained from research agreements +50%",
"requires": ["Free Thought"],
"row": 3,
"column": 1
},
{
"name": "Rationalism Complete",
"description": "+1 gold from all science buildings"
"effect": "+1 gold from all science buildings"
}
]
},
/*{
"name": "Order",
"era": "Industrial",
"description": "+1 Happiness per City",
"effect": "+1 Happiness per City",
"policies": [
{
"name": "Nationalism",
"description": "25% Attack bonus when fighting in friendly territory",
"effect": "25% Attack bonus when fighting in friendly territory",
"row": 1,
"column": 1
},
{
"name": "United Front",
"description": "Militaristic City-States grant units twice as often when you are at war with a common foe",
"effect": "Militaristic City-States grant units twice as often when you are at war with a common foe",
"row": 1,
"column": 3
},
{
"name": "Planned Economy",
"description": "Factories increase a cities Science output by 25%",
"effect": "Factories increase a cities Science output by 25%",
"row": 2,
"column": 5
},
{
"name": "Socialism",
"description": "Gold maintenance costs of Buildings reduced by 15%",
"effect": "Gold maintenance costs of Buildings reduced by 15%",
"requires": ["Planned Economy"],
"row": 2,
"column": 3
},
{
"name": "Communism",
"description": "+2 Production per City and +10% Production when constructing buildings",
"effect": "+2 Production per City and +10% Production when constructing buildings",
"requires": ["Socialism"],
"row": 3,
"column": 3
},
{
"name": "Order Complete",
"description": "+1 Food, Production, Science, Gold and Culture per city"
"effect": "+1 Food, Production, Science, Gold and Culture per city"
}
]
},*/
{
"name": "Freedom",
"era": "Renaissance",
"description": "+25% great people rate",
"effect": "+25% great people rate",
"policies": [
{
"name": "Constitution",
"description": "+2 culture from each wonder",
"effect": "+2 culture from each wonder",
"row": 1,
"column": 1
},
{
"name": "Universal Suffrage",
"description": "+1 production per 5 population",
"effect": "+1 production per 5 population",
"row": 1,
"column": 3
},
{
"name": "Civil Society",
"description": "-50% food consumption by specialists",
"effect": "-50% food consumption by specialists",
"row": 1,
"column": 5
},
{
"name": "Free Speech",
"description": "+1 culture for every 2 citizens",
"effect": "+1 culture for every 2 citizens",
"requires": ["Constitution"],
"row": 2,
"column": 1
},
{
"name": "Democracy",
"description": "Specialists produce half normal unhappiness",
"effect": "Specialists produce half normal unhappiness",
"requires": ["Civil Society"],
"row": 2,
"column": 5
},
{
"name": "Freedom Complete",
"description": "Tile yield from great improvement +100%, golden ages increase by 50%"
"effect": "Tile yield from great improvement +100%, golden ages increase by 50%"
}
]
},
{
"name": "Autocracy",
"era": "Industrial",
"description": "-33% unit upkeep costs",
"effect": "-33% unit upkeep costs",
"policies": [
{
"name": "Populism",
"description": "Wounded military units deal +25% damage",
"effect": "Wounded military units deal +25% damage",
"row": 1,
"column": 1
},
{
"name": "Militarism",
"description": "Gold cost of purchasing units -33%",
"effect": "Gold cost of purchasing units -33%",
"row": 1,
"column": 5
},
{
"name": "Fascism",
"description": "Quantity of strategic resources produced by the empire increased by 100%",
"effect": "Quantity of strategic resources produced by the empire increased by 100%",
"requires": ["Populism","Militarism"],
"row": 2,
"column": 3
},
{
"name": "Police State",
"description": "+3 Happiness from every Courthouse. Build Courthouses in half the usual time.",
"effect": "+3 Happiness from every Courthouse. Build Courthouses in half the usual time.",
"requires": ["Militarism"],
"row": 2,
"column": 5
},
{
"name": "Total War",
"description": "+15% production when building military units and new military units start with 15 Experience",
"effect": "+15% production when building military units and new military units start with 15 Experience",
"requires": ["Police State","Fascism"],
"row": 3,
"column": 4
},
{
"name": "Autocracy Complete",
"description": "+20% attack bonus to all Military Units for 30 turns"
"effect": "+20% attack bonus to all Military Units for 30 turns"
}
]
}

View File

@ -33,7 +33,7 @@ allprojects {
version = '1.0.1'
ext {
appName = "Unciv"
appCodeNumber = 409
appCodeNumber = 410
appVersion = "3.7.4"
gdxVersion = '1.9.10'

View File

@ -17,7 +17,7 @@ Added city expansion tutorial - #2322
Reveal all civs when won/lost - #2407
Carious exploration-related improvements - #2278
Various exploration-related improvements - #2278
Unit placement improvements - #2406

View File

@ -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.PolicyManager
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
import com.unciv.logic.map.RoadStatus
import com.unciv.models.ruleset.Building
@ -254,25 +255,25 @@ class CityStats {
return stats
}
private fun getStatsFromPolicies(adoptedPolicies: HashSet<String>): Stats {
private fun getStatsFromPolicies(adoptedPolicies: PolicyManager): Stats {
val stats = Stats()
if (adoptedPolicies.contains("Tradition") && cityInfo.isCapital())
if (adoptedPolicies.isAdopted("Tradition") && cityInfo.isCapital())
stats.culture += 3f
if (adoptedPolicies.contains("Landed Elite") && cityInfo.isCapital())
if (adoptedPolicies.isAdopted("Landed Elite") && cityInfo.isCapital())
stats.food += 2f
if (adoptedPolicies.contains("Tradition Complete"))
if (adoptedPolicies.isAdopted("Tradition Complete"))
stats.food += 2f
if (adoptedPolicies.contains("Monarchy") && cityInfo.isCapital())
if (adoptedPolicies.isAdopted("Monarchy") && cityInfo.isCapital())
stats.gold += (cityInfo.population.population / 2).toFloat()
if (adoptedPolicies.contains("Liberty"))
if (adoptedPolicies.hasEffect("+1 culture in every city"))
stats.culture += 1f
if (adoptedPolicies.contains("Republic"))
if (adoptedPolicies.isAdopted("Republic"))
stats.production += 1f
if (adoptedPolicies.contains("Military Caste") && cityInfo.getCenterTile().militaryUnit != null)
if (adoptedPolicies.isAdopted("Military Caste") && cityInfo.getCenterTile().militaryUnit != null)
stats.culture += 2
if (adoptedPolicies.contains("Universal Suffrage"))
if (adoptedPolicies.isAdopted("Universal Suffrage"))
stats.production += (cityInfo.population.population / 5).toFloat()
if (adoptedPolicies.contains("Free Speech"))
if (adoptedPolicies.isAdopted("Free Speech"))
stats.culture += (cityInfo.population.population / 2).toFloat()
return stats
@ -367,7 +368,7 @@ class CityStats {
newBaseStatList["Specialists"] = getStatsFromSpecialists(cityInfo.population.specialists, civInfo.policies.adoptedPolicies)
newBaseStatList["Trade routes"] = getStatsFromTradeRoute()
newBaseStatList["Buildings"] = cityInfo.cityConstructions.getStats()
newBaseStatList["Policies"] = getStatsFromPolicies(civInfo.policies.adoptedPolicies)
newBaseStatList["Policies"] = getStatsFromPolicies(civInfo.policies)
newBaseStatList["National ability"] = getStatsFromNationUnique()
newBaseStatList["City States"] = getStatsFromCityStates()

View File

@ -347,6 +347,7 @@ class CivilizationInfo {
policies.civInfo = this
if(policies.adoptedPolicies.size>0 && policies.numberOfAdoptedPolicies == 0)
policies.numberOfAdoptedPolicies = policies.adoptedPolicies.count { !it.endsWith("Complete") }
policies.setTransients()
if(citiesCreated==0 && cities.any())
citiesCreated = cities.filter { it.name in nation.cities }.count()

View File

@ -11,6 +11,9 @@ import kotlin.math.roundToInt
class PolicyManager {
@Transient lateinit var civInfo: CivilizationInfo
// Needs to be separate from the actual adopted policies, so that
// in different game versions, policies can have different effects
@Transient internal val policyEffects = HashSet<String>()
var freePolicies = 0
var storedCulture = 0
@ -33,6 +36,15 @@ class PolicyManager {
return toReturn
}
fun setTransients(){
val allPolicies = getAllPolicies()
val effectsOfCurrentPolicies = adoptedPolicies.map { adoptedPolicy -> allPolicies.first { it.name==adoptedPolicy }.effect }
policyEffects.addAll(effectsOfCurrentPolicies)
}
private fun getAllPolicies() = civInfo.gameInfo.ruleSet.policyBranches.values.asSequence()
.flatMap { it.policies.asSequence()+sequenceOf(it) }
fun startTurn() {
if (isAdopted("Legalism") && legalismState.size < 4)
tryAddLegalismBuildings()
@ -68,6 +80,8 @@ class PolicyManager {
fun isAdopted(policyName: String): Boolean = adoptedPolicies.contains(policyName)
fun hasEffect(effectName:String) = policyEffects.contains(effectName)
fun isAdoptable(policy: Policy): Boolean {
if(isAdopted(policy.name)) return false
if (policy.name.endsWith("Complete")) return false
@ -80,8 +94,7 @@ class PolicyManager {
if (freePolicies == 0 && storedCulture < getCultureNeededForNextPolicy())
return false
val hasAdoptablePolicies = civInfo.gameInfo.ruleSet.policyBranches.values
.flatMap { it.policies.union(listOf(it)) }
val hasAdoptablePolicies = getAllPolicies()
.any { civInfo.policies.isAdoptable(it) }
return hasAdoptablePolicies
}
@ -100,6 +113,7 @@ class PolicyManager {
}
adoptedPolicies.add(policy.name)
policyEffects.add(policy.effect)
if (!branchCompletion) {
val branch = policy.branch

View File

@ -6,7 +6,7 @@ open class Policy : INamed {
lateinit var branch: PolicyBranch // not in json - added in gameBasics
override lateinit var name: String
lateinit var description: String
lateinit var effect: String
var row: Int = 0
var column: Int = 0
var requires: ArrayList<String>? = null

View File

@ -9,7 +9,7 @@ class Promotion : INamed{
override lateinit var name: String
var prerequisites = listOf<String>()
lateinit var effect:String
var unitTypes = listOf<String>() // The json parser woulddn't agree to deserialize this as a list of UnitTypes. =(
var unitTypes = listOf<String>() // The json parser wouldn't agree to deserialize this as a list of UnitTypes. =(
fun getDescription(promotionsForUnitType: Collection<Promotion>, forCivilopedia:Boolean=false, ruleSet:Ruleset? = null):String {
// we translate it before it goes in to get uniques like "vs units in rough terrain" and after to get "vs city

View File

@ -93,7 +93,7 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo
rightSideButton.enable()
}
pickedPolicy = policy
var policyText = policy.name.tr() + "\r\n" + policy.description.tr() + "\r\n"
var policyText = policy.name.tr() + "\r\n" + policy.effect.tr() + "\r\n"
if (!policy.name.endsWith("Complete")){
if(policy.requires!!.isNotEmpty())
policyText += "{Requires} ".tr() + policy.requires!!.joinToString { it.tr() }