More policy names to effects

This commit is contained in:
Yair Morgenstern 2020-04-16 17:06:47 +03:00
parent 038e1cadbf
commit 248d7b5aa6
4 changed files with 37 additions and 31 deletions

View file

@ -91,8 +91,7 @@ class CityInfo {
cityConstructions.currentConstructionFromQueue = Constants.worker // Default for first city only!
}
if (civInfo.policies.isAdopted("Legalism"))
civInfo.policies.tryAddLegalismBuildings()
civInfo.policies.tryAddLegalismBuildings()
expansion.reset()
@ -195,12 +194,13 @@ class CityInfo {
// Per https://gaming.stackexchange.com/questions/53155/do-manufactories-and-customs-houses-sacrifice-the-strategic-or-luxury-resources
|| (resource.resourceType==ResourceType.Strategic && tileInfo.containsGreatImprovement())){
var amountToAdd = 1
if(resource.resourceType == ResourceType.Strategic){
if(resource.resourceType == ResourceType.Strategic) {
amountToAdd = 2
if(civInfo.policies.isAdopted("Fascism")) amountToAdd*=2
if(civInfo.nation.unique == UniqueAbility.SIBERIAN_RICHES && resource.name in listOf("Horses","Iron","Uranium"))
if (civInfo.policies.hasEffect("Quantity of strategic resources produced by the empire increased by 100%"))
amountToAdd *= 2
if(resource.name=="Oil" && civInfo.nation.unique == UniqueAbility.TRADE_CARAVANS)
if (civInfo.nation.unique == UniqueAbility.SIBERIAN_RICHES && resource.name in listOf("Horses", "Iron", "Uranium"))
amountToAdd *= 2
if (resource.name == "Oil" && civInfo.nation.unique == UniqueAbility.TRADE_CARAVANS)
amountToAdd *= 2
}
if(resource.resourceType == ResourceType.Luxury
@ -260,12 +260,12 @@ class CityInfo {
for(entry in stats){
if(civInfo.nation.unique == UniqueAbility.INGENUITY)
entry.value.science *= 1.5f
if (civInfo.policies.isAdopted("Entrepreneurship"))
if (civInfo.policies.hasEffect("Great Merchants are earned 25% faster, +1 Science from every Mint, Market, Bank and Stock Exchange."))
entry.value.gold *= 1.25f
if (civInfo.containsBuildingUnique("+33% great person generation in all cities"))
stats[entry.key] = stats[entry.key]!!.times(1.33f)
if (civInfo.policies.isAdopted("Freedom"))
if (civInfo.policies.hasEffect("+25% great people rate"))
stats[entry.key] = stats[entry.key]!!.times(1.25f)
}

View file

@ -46,8 +46,7 @@ class PolicyManager {
.flatMap { it.policies.asSequence()+sequenceOf(it) }
fun startTurn() {
if (isAdopted("Legalism") && legalismState.size < 4)
tryAddLegalismBuildings()
tryAddLegalismBuildings()
}
fun endTurn(culture: Int) {
@ -63,9 +62,10 @@ class PolicyManager {
// round down to nearest 5
fun getCultureNeededForNextPolicy(): Int {
var policyCultureCost = 25 + (numberOfAdoptedPolicies * 6).toDouble().pow(1.7)
var cityModifier = 0.3 * (civInfo.cities.count { !it.isPuppet } - 1)
var cityModifier = 0.3f * (civInfo.cities.count { !it.isPuppet } - 1)
if (isAdopted("Representation")) cityModifier *= (2 / 3f).toDouble()
if (hasEffect("Each city founded increases culture cost of policies 33% less than normal. Starts a golden age."))
cityModifier *= (2 / 3f)
if (isAdopted("Piety Complete")) policyCultureCost *= 0.9
if (civInfo.containsBuildingUnique("Culture cost of adopting new Policies reduced by 10%"))
policyCultureCost *= 0.9
@ -101,11 +101,11 @@ class PolicyManager {
fun adopt(policy: Policy, branchCompletion: Boolean = false) {
if(!branchCompletion) {
if (!branchCompletion) {
if (freePolicies > 0) freePolicies--
else {
else {
val cultureNeededForNextPolicy = getCultureNeededForNextPolicy()
if(cultureNeededForNextPolicy > storedCulture)
if (cultureNeededForNextPolicy > storedCulture)
throw Exception("How is this possible??????")
storedCulture -= cultureNeededForNextPolicy
numberOfAdoptedPolicies++
@ -122,22 +122,21 @@ class PolicyManager {
}
}
val hasCapital = civInfo.cities.any{it.isCapital()}
val hasCapital = civInfo.cities.any { it.isCapital() }
when (policy.name) {
"Collective Rule" -> if(hasCapital && !civInfo.isOneCityChallenger())
"Collective Rule" -> if (hasCapital && !civInfo.isOneCityChallenger())
civInfo.placeUnitNearTile(civInfo.getCapital().location, Constants.settler)
"Citizenship" -> if(hasCapital) civInfo.placeUnitNearTile(civInfo.getCapital().location, Constants.worker)
"Citizenship" -> if (hasCapital) civInfo.placeUnitNearTile(civInfo.getCapital().location, Constants.worker)
"Representation", "Reformation" -> civInfo.goldenAges.enterGoldenAge()
"Legalism" -> tryAddLegalismBuildings()
"Free Religion" -> freePolicies++
"Liberty Complete" -> {
if (civInfo.isPlayerCivilization()) civInfo.greatPeople.freeGreatPeople++
else {
val preferredVictoryType = civInfo.victoryType()
val greatPerson = when(preferredVictoryType) {
val greatPerson = when (preferredVictoryType) {
VictoryType.Cultural -> "Great Artist"
VictoryType.Scientific -> "Great Scientist"
VictoryType.Domination,VictoryType.Neutral ->
VictoryType.Domination, VictoryType.Neutral ->
civInfo.gameInfo.ruleSet.units.keys.filter { it.startsWith("Great") }.random()
}
civInfo.addGreatPerson(greatPerson)
@ -145,15 +144,20 @@ class PolicyManager {
}
"Autocracy Complete" -> autocracyCompletedTurns = 30
}
tryAddLegalismBuildings()
// This ALSO has the side-effect of updating the CivInfo statForNextTurn so we don't need to call it explicitly
for (cityInfo in civInfo.cities)
cityInfo.cityStats.update()
if(!canAdoptPolicy()) shouldOpenPolicyPicker=false
if (!canAdoptPolicy()) shouldOpenPolicyPicker = false
}
fun tryAddLegalismBuildings() {
if(!civInfo.policies.hasEffect("Immediately creates a cheapest available cultural building in each of your first 4 cities for free"))
return
if(legalismState.size >= 4) return
val candidateCities = civInfo.cities
.sortedBy { it.turnAcquired }
.subList(0, min(4, civInfo.cities.size))

View file

@ -249,11 +249,14 @@ open class TileInfo {
improvement.clone() // basic improvement
if (improvement.improvingTech != null && observingCiv.tech.isResearched(improvement.improvingTech!!)) stats.add(improvement.improvingTechStats!!) // eg Chemistry for mines
if (improvement.name == "Trading post" && city != null && city.civInfo.policies.isAdopted("Free Thought"))
if (improvement.name == "Trading post" && city != null
&& city.civInfo.policies.hasEffect("+1 science from every trading post, +17% science from universities"))
stats.science += 1f
if (improvement.name == "Trading post" && city != null && city.civInfo.policies.isAdopted("Commerce Complete"))
if (improvement.name == "Trading post" && city != null
&& city.civInfo.policies.hasEffect("+1 gold from every trading post, double gold from Great Merchant trade missions"))
stats.gold += 1f
if (containsGreatImprovement() && observingCiv.policies.isAdopted("Freedom Complete"))
if (containsGreatImprovement()
&& observingCiv.policies.hasEffect("Tile yield from great improvement +100%, golden ages increase by 50%"))
stats.add(improvement) // again, for the double effect
if (containsGreatImprovement() && city != null && city.civInfo.nation.unique == UniqueAbility.SCHOLARS_OF_THE_JADE_HALL)
stats.science += 2

View file

@ -194,10 +194,10 @@ class Building : NamedStats(), IConstruction{
override fun getProductionCost(civInfo: CivilizationInfo): Int {
var productionCost = cost.toFloat()
if (!isWonder && culture != 0f && civInfo.policies.isAdopted("Piety"))
if (!isWonder && culture != 0f && civInfo.policies.hasEffect("Building time of culture buildings reduced by 15%"))
productionCost *= 0.85f
if (name == "Courthouse" && civInfo.policies.isAdopted("Police State"))
if (name == "Courthouse" && civInfo.policies.hasEffect("+3 Happiness from every Courthouse. Build Courthouses in half the usual time."))
productionCost *= 0.5f
if (civInfo.isPlayerCivilization()) {
@ -217,11 +217,10 @@ class Building : NamedStats(), IConstruction{
override fun getGoldCost(civInfo: CivilizationInfo): Int {
// https://forums.civfanatics.com/threads/rush-buying-formula.393892/
var cost = (30 * getProductionCost(civInfo)).toDouble().pow(0.75) * (1 + hurryCostModifier / 100)
if (civInfo.policies.isAdopted("Mercantilism")) cost *= 0.75
if (civInfo.policies.hasEffect("-25% to purchasing items in cities")) cost *= 0.75
if (civInfo.containsBuildingUnique("-15% to purchasing items in cities")) cost *= 0.85
if (civInfo.policies.isAdopted("Patronage")
&& listOf("Monument", "Temple", "Opera House", "Museum", "Broadcast Tower")
.map{civInfo.getEquivalentBuilding(it).name}.contains(name))
if (civInfo.policies.hasEffect( "Cost of purchasing culture buildings reduced by 50%")
&& culture !=0f && !isWonder)
cost *= 0.5
return (cost / 10).toInt() * 10