From a3889a549e12aa6a58173607df69772641629e76 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 20 Sep 2019 10:26:15 +0300 Subject: [PATCH] Iroquis can now use Forest and Jungles to connect cities Persian +1 movement only activaes when in golden age --- android/assets/jsons/Nations/Nations.json | 2 +- .../Translations/Diplomacy,Trade,Nations.json | 4 +-- android/build.gradle | 4 +-- .../civilization/CivInfoTransientUpdater.kt | 27 ++++++++++--------- core/src/com/unciv/logic/map/MapUnit.kt | 3 ++- core/src/com/unciv/logic/map/TileInfo.kt | 7 +++++ .../unciv/logic/map/UnitMovementAlgorithms.kt | 9 +------ 7 files changed, 30 insertions(+), 26 deletions(-) diff --git a/android/assets/jsons/Nations/Nations.json b/android/assets/jsons/Nations/Nations.json index 47d99886..b51cb4c8 100644 --- a/android/assets/jsons/Nations/Nations.json +++ b/android/assets/jsons/Nations/Nations.json @@ -573,7 +573,7 @@ outerColor:[54,72,72], innerColor:[246,205,137], uniqueName:"The Great Warpath" - unique:"All units move through Forest and Jungle tiles in friendly territory as if it is Road. These tiles can be used to establish City Connections upon researching the Wheel.", + unique: "All units move through Forest and Jungle Tiles in friendly territory as if they have roads. These tiles can be used to establish City Connections upon researching the Wheel.", cities:["Onoondaga","Osininka","Grand River","Akwesasme","Buffalo Creek","Brantford","Montreal","Genesse River", "Canandaigua Lake","Lake Simcoe","Salamanca","Gowanda","Cuba","Akron","Kanesatake","Ganienkeh","Cayuga Castle", "Chondote","Canajoharie","Nedrow","Oneida Lake","Kanonwalohale","Green Bay","Southwold","Mohawk Valley", diff --git a/android/assets/jsons/Translations/Diplomacy,Trade,Nations.json b/android/assets/jsons/Translations/Diplomacy,Trade,Nations.json index ae98768d..9bae7d79 100644 --- a/android/assets/jsons/Translations/Diplomacy,Trade,Nations.json +++ b/android/assets/jsons/Translations/Diplomacy,Trade,Nations.json @@ -1229,7 +1229,7 @@ Italian:"Hiawatha"//Same as in Italian } - "All units move through Forest and Jungle Tiles in friendly territory as if it is Road. These tiles can be used to establish City Connections upon researching the Wheel.":{ + "All units move through Forest and Jungle Tiles in friendly territory as if they have roads. These tiles can be used to establish City Connections upon researching the Wheel.":{ Italian:"Le caselle di Foreste e Giungle in territorio amico agiscono come strade, e sono usate per stabilire Rotte Commerciali quando scopri la Ruota." Portuguese:"Mova-se por florestas e selvas em território amigo como se fossem estradas. Estas terras podem ser usadas para estabelecer rotas de comércio após pesquisar a roda." French:"Les Forêt et les Jungles en territoire alliés ont les mêmes attributs que les routes. A la découverte de la Roue, elles peuvent établir des routes commerciales." @@ -1246,7 +1246,7 @@ Italian:"Dario I" } - "Golden Ages last 50% longer. During a Golden Age, units receive +1 Movement and +10% Strenght.":{ + "Golden Ages last 50% longer. During a Golden Age, units receive +1 Movement and +10% Strength":{ Italian:"+50% durata delle Età dell'Oro, durante le quali le unità ricevono +1 Movimento e +10% Forza." Portuguese:"Idades douradas duram 50% mais, unidades recebem 1 movimento a mais e um bonus de +10% em força de combate." French:"Les Ages d'Or durent 50% plus longtemps. Durant les Ages d'Or, les unités gagnent +1 mouvement et +10% de force de Combat." diff --git a/android/build.gradle b/android/build.gradle index 83946f5c..16e93a0a 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,8 +21,8 @@ android { applicationId "com.unciv.app" minSdkVersion 14 targetSdkVersion 29 - versionCode 299 - versionName "3.0.6" + versionCode 300 + versionName "3.0.7" } // Had to add this crap for Travis to build, it wanted to sign the app diff --git a/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt b/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt index 6750707b..3642f112 100644 --- a/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt +++ b/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt @@ -3,11 +3,9 @@ package com.unciv.logic.civilization import com.badlogic.gdx.graphics.Color import com.unciv.logic.city.CityInfo import com.unciv.logic.map.BFS -import com.unciv.logic.map.RoadStatus import com.unciv.logic.map.TileInfo import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.tile.ResourceSupplyList -import com.unciv.models.gamebasics.tr import java.util.* import kotlin.collections.HashMap import kotlin.collections.set @@ -78,15 +76,20 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo){ citiesReachedToMediums[civInfo.getCapital()] = arrayListOf("Start") val allCivCities = civInfo.gameInfo.civilizations.flatMap { it.cities } + val theWheelIsResearched = civInfo.tech.isResearched("The Wheel") + + val road = "Road" + val harbor = "Harbor" + while(citiesToCheck.isNotEmpty() && citiesReachedToMediums.size() for(cityToConnectFrom in citiesToCheck){ val reachedMediums = citiesReachedToMediums[cityToConnectFrom]!! // This is copypasta and can be cleaned up - if(!reachedMediums.contains("Road")){ + if(theWheelIsResearched && !reachedMediums.contains(road)){ - val roadBfs = BFS(cityToConnectFrom.getCenterTile()) { it.roadStatus != RoadStatus.None } + val roadBfs = BFS(cityToConnectFrom.getCenterTile()) { it.hasRoad(civInfo) } roadBfs.stepToEnd() val reachedCities = allCivCities.filter { roadBfs.tilesReached.containsKey(it.getCenterTile())} for(reachedCity in reachedCities){ @@ -95,14 +98,14 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo){ citiesReachedToMediums[reachedCity] = arrayListOf() } val cityReachedByMediums = citiesReachedToMediums[reachedCity]!! - if(!cityReachedByMediums.contains("Road")) - cityReachedByMediums.add("Road") + if(!cityReachedByMediums.contains(road)) + cityReachedByMediums.add(road) } - citiesReachedToMediums[cityToConnectFrom]!!.add("Road") + citiesReachedToMediums[cityToConnectFrom]!!.add(road) } - if(!reachedMediums.contains("Harbor") - && cityToConnectFrom.cityConstructions.containsBuildingOrEquivalent("Harbor")){ + if(!reachedMediums.contains(harbor) + && cityToConnectFrom.cityConstructions.containsBuildingOrEquivalent(harbor)){ val seaBfs = BFS(cityToConnectFrom.getCenterTile()) { it.isWater || it.isCityCenter() } seaBfs.stepToEnd() val reachedCities = allCivCities.filter { seaBfs.tilesReached.containsKey(it.getCenterTile())} @@ -112,10 +115,10 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo){ citiesReachedToMediums[reachedCity] = arrayListOf() } val cityReachedByMediums = citiesReachedToMediums[reachedCity]!! - if(!cityReachedByMediums.contains("Harbor")) - cityReachedByMediums.add("Harbor") + if(!cityReachedByMediums.contains(harbor)) + cityReachedByMediums.add(harbor) } - citiesReachedToMediums[cityToConnectFrom]!!.add("Harbor") + citiesReachedToMediums[cityToConnectFrom]!!.add(harbor) } } citiesToCheck = newCitiesToCheck diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 3940dc65..f4cef024 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -94,7 +94,8 @@ class MapUnit { if (type.isWaterUnit() && civInfo.nation.unique == "+2 movement for all naval units") movement += 2 - if(civInfo.nation.unique=="Golden Ages last 50% longer. During a Golden Age, units receive +1 Movement and +10% Strength") + if(civInfo.goldenAges.isGoldenAge() && + civInfo.nation.unique=="Golden Ages last 50% longer. During a Golden Age, units receive +1 Movement and +10% Strength") movement+=1 return movement diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index eac838d6..1874b408 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -324,5 +324,12 @@ open class TileInfo { } return false } + + fun hasRoad(civInfo: CivilizationInfo): Boolean { + if(roadStatus != RoadStatus.None) return true + if(civInfo.nation.forestsAndJunglesAreRoads && (terrainFeature==Constants.jungle || terrainFeature==Constants.forest)) + return true + return false + } //endregion } \ No newline at end of file diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index 258a427a..c0571212 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -21,7 +21,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) { if (from.roadStatus === RoadStatus.Railroad && to.roadStatus === RoadStatus.Railroad) return 1 / 10f + extraCost - if (hasRoad(from,civInfo) && hasRoad(to,civInfo)) + if (from.hasRoad(civInfo) && to.hasRoad(civInfo)) { if (unit.civInfo.tech.movementSpeedOnRoadsImproved) return 1 / 3f + extraCost else return 1 / 2f + extraCost @@ -40,13 +40,6 @@ class UnitMovementAlgorithms(val unit:MapUnit) { return to.getLastTerrain().movementCost.toFloat() + extraCost // no road } - fun hasRoad(tileInfo:TileInfo, civInfo: CivilizationInfo): Boolean { - if(tileInfo.roadStatus!==RoadStatus.None) return true - if(civInfo.nation.forestsAndJunglesAreRoads && tileInfo.terrainFeature!=null - && (tileInfo.terrainFeature==Constants.jungle || tileInfo.terrainFeature==Constants.forest)) return true - return false - } - class ParentTileAndTotalDistance(val parentTile:TileInfo, val totalDistance: Float) fun getDistanceToTilesWithinTurn(origin: Vector2, unitMovement: Float): PathsToTilesWithinTurn {