From f41d30e0cc8111428034709dbae7ca5b93084da0 Mon Sep 17 00:00:00 2001 From: SimonCeder <63475501+SimonCeder@users.noreply.github.com> Date: Thu, 22 Jul 2021 23:20:20 +0200 Subject: [PATCH] City states adjustments (#4597) * city-state AI * City-state spawns * City-state border expansion * City-state border expansion adjustment * Food and production multipliers for city states * 6 CS as default --- core/src/com/unciv/logic/GameStarter.kt | 8 ++++---- .../com/unciv/logic/automation/SpecificUnitAutomation.kt | 3 ++- core/src/com/unciv/logic/automation/UnitAutomation.kt | 1 + core/src/com/unciv/logic/city/CityExpansionManager.kt | 5 +++++ core/src/com/unciv/logic/city/PopulationManager.kt | 2 ++ core/src/com/unciv/models/metadata/GameParameters.kt | 2 +- core/src/com/unciv/models/ruleset/Building.kt | 2 ++ core/src/com/unciv/models/ruleset/unit/BaseUnit.kt | 2 ++ 8 files changed, 19 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/logic/GameStarter.kt b/core/src/com/unciv/logic/GameStarter.kt index 9f7882992b8fc..5b18aa720812d 100644 --- a/core/src/com/unciv/logic/GameStarter.kt +++ b/core/src/com/unciv/logic/GameStarter.kt @@ -290,11 +290,11 @@ object GameStarter { if (civ.isCityState()) { + // City states should spawn with one settler only irregardless of era and difficulty val startingSettlers = startingUnits.filter { settlerLikeUnits.contains(it) } - if (startingSettlers.count() > 1) { - startingUnits = startingUnits.filter { !settlerLikeUnits.contains(it) }.toMutableList() - startingUnits.add(startingSettlers.random()) - } + + startingUnits.clear() + startingUnits.add( startingSettlers.random() ) } for (unit in startingUnits) { diff --git a/core/src/com/unciv/logic/automation/SpecificUnitAutomation.kt b/core/src/com/unciv/logic/automation/SpecificUnitAutomation.kt index 5e2fa8bb74239..c6b180089cedd 100644 --- a/core/src/com/unciv/logic/automation/SpecificUnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/SpecificUnitAutomation.kt @@ -154,7 +154,8 @@ object SpecificUnitAutomation { } } - if (unit.getTile().militaryUnit == null) return // Don't move until you're accompanied by a military unit + if (unit.getTile().militaryUnit == null // Don't move until you're accompanied by a military unit + && !unit.civInfo.isCityState()) return // ..unless you're a city state that was unable to settle its city on turn 1 val tilesNearCities = unit.civInfo.gameInfo.getCities().asSequence() .flatMap { diff --git a/core/src/com/unciv/logic/automation/UnitAutomation.kt b/core/src/com/unciv/logic/automation/UnitAutomation.kt index 8418d5c88459e..019fdf52cc4bd 100644 --- a/core/src/com/unciv/logic/automation/UnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/UnitAutomation.kt @@ -19,6 +19,7 @@ object UnitAutomation { && (tile.getOwner() == null || !tile.getOwner()!!.isCityState()) && tile.neighbors.any { it.position !in unit.civInfo.exploredTiles } && unit.movement.canReach(tile) + && (!unit.civInfo.isCityState() || tile.neighbors.any { it.getOwner() == unit.civInfo }) // Don't want city-states exploring far outside their borders } internal fun tryExplore(unit: MapUnit): Boolean { diff --git a/core/src/com/unciv/logic/city/CityExpansionManager.kt b/core/src/com/unciv/logic/city/CityExpansionManager.kt index 574708b56b0c5..fb33610b8f1db 100644 --- a/core/src/com/unciv/logic/city/CityExpansionManager.kt +++ b/core/src/com/unciv/logic/city/CityExpansionManager.kt @@ -8,6 +8,7 @@ import com.unciv.logic.map.TileInfo import com.unciv.ui.utils.withItem import com.unciv.ui.utils.withoutItem import kotlin.math.max +import kotlin.math.min import kotlin.math.pow import kotlin.math.roundToInt @@ -35,6 +36,10 @@ class CityExpansionManager { // The second seems to be more based, so I'll go with that fun getCultureToNextTile(): Int { var cultureToNextTile = 6 * (max(0, tilesClaimed()) + 1.4813).pow(1.3) + + if (cityInfo.civInfo.isCityState()) + cultureToNextTile *= 1.5f // City states grow slower, perhaps 150% cost? + for (unique in cityInfo.civInfo.getMatchingUniques("-[]% Culture cost of acquiring tiles []")) { if (cityInfo.matchesFilter(unique.params[1])) cultureToNextTile *= (100 - unique.params[0].toFloat()) / 100 diff --git a/core/src/com/unciv/logic/city/PopulationManager.kt b/core/src/com/unciv/logic/city/PopulationManager.kt index 4bf6ee7aa23ac..7e5861e2b1c06 100644 --- a/core/src/com/unciv/logic/city/PopulationManager.kt +++ b/core/src/com/unciv/logic/city/PopulationManager.kt @@ -42,6 +42,8 @@ class PopulationManager { fun getFoodToNextPopulation(): Int { // civ v math, civilization.wikia var foodRequired = 15 + 6 * (population - 1) + floor((population - 1).toDouble().pow(1.8)) + if (cityInfo.civInfo.isCityState()) + foodRequired *= 1.5f if (!cityInfo.civInfo.isPlayerCivilization()) foodRequired *= cityInfo.civInfo.gameInfo.getDifficulty().aiCityGrowthModifier return foodRequired.toInt() diff --git a/core/src/com/unciv/models/metadata/GameParameters.kt b/core/src/com/unciv/models/metadata/GameParameters.kt index 11fe5fa7ca4ef..4d3448f0b6a7a 100644 --- a/core/src/com/unciv/models/metadata/GameParameters.kt +++ b/core/src/com/unciv/models/metadata/GameParameters.kt @@ -15,7 +15,7 @@ class GameParameters { // Default values are the default new game add(Player().apply { playerType = PlayerType.Human }) for (i in 1..3) add(Player()) } - var numberOfCityStates = 2 + var numberOfCityStates = 6 var noBarbarians = false var oneCityChallenge = false diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index d9cb51832b976..5955ed61aca00 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -338,6 +338,8 @@ class Building : NamedStats(), IConstruction, ICivilopediaText { for (unique in uniqueObjects.filter { it.placeholderText == "Cost increases by [] per owned city" }) productionCost += civInfo.cities.count() * unique.params[0].toInt() + if (civInfo.isCityState()) + productionCost *= 1.5f if (civInfo.isPlayerCivilization()) { if (!isWonder) productionCost *= civInfo.getDifficulty().buildingCostModifier diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index 686371be910d8..303176b834584 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -172,6 +172,8 @@ class BaseUnit : INamed, IConstruction, CivilopediaText() { override fun getProductionCost(civInfo: CivilizationInfo): Int { var productionCost = cost.toFloat() + if (civInfo.isCityState()) + productionCost *= 1.5f if (civInfo.isPlayerCivilization()) productionCost *= civInfo.getDifficulty().unitCostModifier else