From f5a8211574e50b315cd564b578d9491d4fe0e0dc Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 13 Apr 2020 23:51:27 +0300 Subject: [PATCH] Resolved #2322 - added city expansion tutorial --- android/assets/jsons/Tutorials.json | 8 +++++--- core/src/com/unciv/logic/city/CityExpansionManager.kt | 11 ++++++----- core/src/com/unciv/models/Tutorial.kt | 2 +- core/src/com/unciv/ui/cityscreen/CityScreen.kt | 2 -- core/src/com/unciv/ui/worldscreen/WorldScreen.kt | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/android/assets/jsons/Tutorials.json b/android/assets/jsons/Tutorials.json index ff9bb0bb66..60bf2796ee 100644 --- a/android/assets/jsons/Tutorials.json +++ b/android/assets/jsons/Tutorials.json @@ -22,6 +22,11 @@ "The policies are organized into branches, with each\n branch providing a bonus ability when all policies \n in the branch have been adopted." , "With each policy adopted, and with each city built,\n the cost of adopting another policy rises - so choose wisely!" ], + City_Expansion: [ + "Once a city has gathered enough Culture, it will expand into a neighboring tile.\nyou have no control over the tile it will expand into, but tiles with resources and higher yields are prioritized.", + "Each additional tile will require more culture, but generally your first cities will eventually expand to a wide tile range." + "Although your city will keep expanding forever, your citizens can only work 3 tiles away from city center.\nThis should be taken into account when placing new cities." + ] Happiness: [ "As cities grow in size and influence, you have to deal with a happiness mechanic that is no longer tied to each individual city.\nInstead, your entire empire shares the same level of satisfaction.\nAs your cities grow in population you’ll find that it is more and more difficult to keep your empire happy." , "In addition, you can’t even build any city improvements that increase happiness until you’ve done the appropriate research.\nIf your empire’s happiness ever goes below zero the growth rate of your cities will be hurt.\nIf your empire becomes severely unhappy (as indicated by the smiley-face icon at the top of the interface)\n your armies will have a big penalty slapped on to their overall combat effectiveness." , @@ -81,9 +86,6 @@ Embarking: [ "Once a certain tech is researched, your land units can embark, allowing them to traverse water tiles.\nEntering or leaving water takes the entire turn.\nUnits are defenseless while embarked, so be careful!" ], - City_Range: [ - "Your citizens can work 3 tiles away from city center.\nThe city border will keep expanding,\n but citizens cannot be assigned to faraway tiles." - ], Idle_Units: [ "If you don't want to move a unit this turn, you can skip it by clicking 'Next unit' again.\nIf you won't be moving it for a while, you can have the unit enter Fortify or Sleep mode - \n units in Fortify or Sleep are not considered idle units.\nIf you want to disable the 'Next unit' feature entirely, you can toggle it in Menu -> Check for idle units" ], diff --git a/core/src/com/unciv/logic/city/CityExpansionManager.kt b/core/src/com/unciv/logic/city/CityExpansionManager.kt index 68b276b31b..75904c41ae 100644 --- a/core/src/com/unciv/logic/city/CityExpansionManager.kt +++ b/core/src/com/unciv/logic/city/CityExpansionManager.kt @@ -6,6 +6,8 @@ import com.unciv.logic.automation.Automation import com.unciv.logic.map.TileInfo import com.unciv.ui.utils.withItem import com.unciv.ui.utils.withoutItem +import kotlin.math.pow +import kotlin.math.roundToInt class CityExpansionManager { @Transient @@ -18,6 +20,7 @@ class CityExpansionManager { return toReturn } + fun tilesClaimed() = cityInfo.tiles.size - 7 // This one has conflicting sources - // http://civilization.wikia.com/wiki/Mathematics_of_Civilization_V says it's 20+(10(t-1))^1.1 // https://www.reddit.com/r/civ/comments/58rxkk/how_in_gods_name_do_borders_expand_in_civ_vi/ has it @@ -25,14 +28,13 @@ class CityExpansionManager { // The second seems to be more based, so I'll go with that fun getCultureToNextTile(): Int { - val numTilesClaimed = cityInfo.tiles.size - 7 - var cultureToNextTile = 6 * Math.pow(numTilesClaimed + 1.4813, 1.3) + var cultureToNextTile = 6 * (tilesClaimed() + 1.4813).pow(1.3) if (cityInfo.civInfo.containsBuildingUnique("Cost of acquiring new tiles reduced by 25%")) cultureToNextTile *= 0.75 //Speciality of Angkor Wat if(cityInfo.containsBuildingUnique("Culture and Gold costs of acquiring new tiles reduced by 25% in this city")) cultureToNextTile *= 0.75 // Specialty of Krepost if (cityInfo.civInfo.policies.isAdopted("Tradition")) cultureToNextTile *= 0.75 - return Math.round(cultureToNextTile).toInt() + return cultureToNextTile.roundToInt() } fun buyTile(tileInfo: TileInfo){ @@ -45,9 +47,8 @@ class CityExpansionManager { fun getGoldCostOfTile(tileInfo: TileInfo): Int { val baseCost = 50 - val numTilesClaimed= cityInfo.tiles.size - 7 val distanceFromCenter = tileInfo.aerialDistanceTo(cityInfo.getCenterTile()) - var cost = baseCost * (distanceFromCenter-1) + numTilesClaimed*5.0 + var cost = baseCost * (distanceFromCenter-1) + tilesClaimed()*5.0 if (cityInfo.civInfo.containsBuildingUnique("Cost of acquiring new tiles reduced by 25%")) cost *= 0.75 //Speciality of Angkor Wat diff --git a/core/src/com/unciv/models/Tutorial.kt b/core/src/com/unciv/models/Tutorial.kt index 517c89a8c4..ce8aad9cb8 100644 --- a/core/src/com/unciv/models/Tutorial.kt +++ b/core/src/com/unciv/models/Tutorial.kt @@ -23,7 +23,6 @@ enum class Tutorial(val value: String, val isCivilopedia: Boolean = !value.start Workers("Workers"), SiegeUnits("Siege_Units"), Embarking("Embarking"), - CityRange("City_Range"), IdleUnits("Idle_Units"), ContactMe("Contact_Me"), Pillaging("Pillaging"), @@ -32,6 +31,7 @@ enum class Tutorial(val value: String, val isCivilopedia: Boolean = !value.start ResearchAgreements("Research_Agreements"), CityStates("City-States"), NaturalWonders("Natural_Wonders"), + CityExpansion("City_Expansion"), ; companion object { diff --git a/core/src/com/unciv/ui/cityscreen/CityScreen.kt b/core/src/com/unciv/ui/cityscreen/CityScreen.kt index 73bd5e1f08..b3a97f2337 100644 --- a/core/src/com/unciv/ui/cityscreen/CityScreen.kt +++ b/core/src/com/unciv/ui/cityscreen/CityScreen.kt @@ -97,8 +97,6 @@ class CityScreen(internal val city: CityInfo): CameraStageBaseScreen() { updateAnnexAndRazeCityButton() updateTileGroups() - - displayTutorial(Tutorial.CityRange) { city.getCenterTile().getTilesAtDistance(4).any() } } private fun updateTileGroups() { diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index dcdba6eb4f..6124b11881 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -30,7 +30,6 @@ import com.unciv.ui.pickerscreens.PolicyPickerScreen import com.unciv.ui.pickerscreens.TechButton import com.unciv.ui.pickerscreens.TechPickerScreen import com.unciv.ui.trade.DiplomacyScreen -import com.unciv.ui.tutorials.TutorialController import com.unciv.ui.utils.* import com.unciv.ui.worldscreen.bottombar.BattleTable import com.unciv.ui.worldscreen.bottombar.TileInfoTable @@ -576,6 +575,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { private fun showTutorialsOnNextTurn(){ if (!UncivGame.Current.settings.showTutorials) return displayTutorial(Tutorial.SlowStart) + displayTutorial(Tutorial.CityExpansion){ viewingCiv.cities.any { it.expansion.tilesClaimed()>0 } } displayTutorial(Tutorial.BarbarianEncountered) { viewingCiv.viewableTiles.any { it.getUnits().any { unit -> unit.civInfo.isBarbarian() } } } displayTutorial(Tutorial.RoadsAndRailroads) { viewingCiv.cities.size > 2 } displayTutorial(Tutorial.Happiness) { viewingCiv.getHappiness() < 5 }