mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-27 16:10:55 +07:00
Fixed natural wonders not being considered 'impassible' for certain things (e.g. ancient ruins spawn)
This commit is contained in:
parent
3a42be7b77
commit
cba9995f99
@ -183,9 +183,8 @@ class GameInfo {
|
|||||||
val tilesWithin3ofExistingEncampment = existingEncampments.asSequence()
|
val tilesWithin3ofExistingEncampment = existingEncampments.asSequence()
|
||||||
.flatMap { it.getTilesInDistance(3) }.toSet()
|
.flatMap { it.getTilesInDistance(3) }.toSet()
|
||||||
val viableTiles = tileMap.values.filter {
|
val viableTiles = tileMap.values.filter {
|
||||||
!it.getBaseTerrain().impassable && it.isLand
|
it.isLand && it.terrainFeature == null
|
||||||
&& it.terrainFeature == null
|
&& !it.isImpassible()
|
||||||
&& it.naturalWonder == null
|
|
||||||
&& it !in tilesWithin3ofExistingEncampment
|
&& it !in tilesWithin3ofExistingEncampment
|
||||||
&& it !in allViewableTiles
|
&& it !in allViewableTiles
|
||||||
}
|
}
|
||||||
|
@ -156,11 +156,11 @@ object GameStarter {
|
|||||||
private fun getStartingLocations(civs: List<CivilizationInfo>, tileMap: TileMap): HashMap<CivilizationInfo, TileInfo> {
|
private fun getStartingLocations(civs: List<CivilizationInfo>, tileMap: TileMap): HashMap<CivilizationInfo, TileInfo> {
|
||||||
var landTiles = tileMap.values
|
var landTiles = tileMap.values
|
||||||
// Games starting on snow might as well start over...
|
// Games starting on snow might as well start over...
|
||||||
.filter { it.isLand && !it.getBaseTerrain().impassable && it.baseTerrain!=Constants.snow }
|
.filter { it.isLand && !it.isImpassible() && it.baseTerrain!=Constants.snow }
|
||||||
|
|
||||||
val landTilesInBigEnoughGroup = ArrayList<TileInfo>()
|
val landTilesInBigEnoughGroup = ArrayList<TileInfo>()
|
||||||
while (landTiles.any()) {
|
while (landTiles.any()) {
|
||||||
val bfs = BFS(landTiles.random()) { it.isLand && !it.getBaseTerrain().impassable }
|
val bfs = BFS(landTiles.random()) { it.isLand && !it.isImpassible() }
|
||||||
bfs.stepToEnd()
|
bfs.stepToEnd()
|
||||||
val tilesInGroup = bfs.tilesReached.keys
|
val tilesInGroup = bfs.tilesReached.keys
|
||||||
landTiles = landTiles.filter { it !in tilesInGroup }
|
landTiles = landTiles.filter { it !in tilesInGroup }
|
||||||
|
@ -429,7 +429,7 @@ object NextTurnAutomation{
|
|||||||
|
|
||||||
val landPathBFS = BFS(ourCity.getCenterTile()) {
|
val landPathBFS = BFS(ourCity.getCenterTile()) {
|
||||||
val owner = it.getOwner();
|
val owner = it.getOwner();
|
||||||
it.isLand && !it.getBaseTerrain().impassable
|
it.isLand && !it.isImpassible()
|
||||||
&& (owner == otherCiv || owner == null || civInfo.canEnterTiles(owner))
|
&& (owner == otherCiv || owner == null || civInfo.canEnterTiles(owner))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ class WorkerAutomation(val unit: MapUnit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun tileCanBeImproved(tile: TileInfo, civInfo: CivilizationInfo): Boolean {
|
private fun tileCanBeImproved(tile: TileInfo, civInfo: CivilizationInfo): Boolean {
|
||||||
if (!tile.isLand || tile.getBaseTerrain().impassable || tile.isCityCenter())
|
if (!tile.isLand || tile.isImpassible() || tile.isCityCenter())
|
||||||
return false
|
return false
|
||||||
val city=tile.getCity()
|
val city=tile.getCity()
|
||||||
if (city == null || city.civInfo != civInfo)
|
if (city == null || city.civInfo != civInfo)
|
||||||
|
@ -111,6 +111,7 @@ open class TileInfo {
|
|||||||
|
|
||||||
fun isCityCenter(): Boolean = getCity()?.location == position
|
fun isCityCenter(): Boolean = getCity()?.location == position
|
||||||
fun isNaturalWonder(): Boolean = naturalWonder != null
|
fun isNaturalWonder(): Boolean = naturalWonder != null
|
||||||
|
fun isImpassible() = getLastTerrain().impassable
|
||||||
|
|
||||||
fun getTileImprovement(): TileImprovement? = if (improvement == null) null else ruleset.tileImprovements[improvement!!]
|
fun getTileImprovement(): TileImprovement? = if (improvement == null) null else ruleset.tileImprovements[improvement!!]
|
||||||
|
|
||||||
@ -400,7 +401,7 @@ open class TileInfo {
|
|||||||
if (!defencePercentString.startsWith("-")) defencePercentString = "+$defencePercentString"
|
if (!defencePercentString.startsWith("-")) defencePercentString = "+$defencePercentString"
|
||||||
lineList += "[$defencePercentString] to unit defence".tr()
|
lineList += "[$defencePercentString] to unit defence".tr()
|
||||||
}
|
}
|
||||||
if (getBaseTerrain().impassable) lineList += Constants.impassable.tr()
|
if (isImpassible()) lineList += Constants.impassable.tr()
|
||||||
|
|
||||||
return lineList.joinToString("\n")
|
return lineList.joinToString("\n")
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
|||||||
// so multiple callees of this function have been optimized,
|
// so multiple callees of this function have been optimized,
|
||||||
// because optimization on this function results in massive benefits!
|
// because optimization on this function results in massive benefits!
|
||||||
fun canPassThrough(tile: TileInfo): Boolean {
|
fun canPassThrough(tile: TileInfo): Boolean {
|
||||||
if (tile.getBaseTerrain().impassable) return false
|
if (tile.isImpassible()) return false
|
||||||
if (tile.isLand
|
if (tile.isLand
|
||||||
&& unit.type.isWaterUnit()
|
&& unit.type.isWaterUnit()
|
||||||
// Check that the tile is not a coastal city's center
|
// Check that the tile is not a coastal city's center
|
||||||
|
@ -104,7 +104,7 @@ class MapGenerator(val ruleset: Ruleset) {
|
|||||||
private fun spreadAncientRuins(map: TileMap) {
|
private fun spreadAncientRuins(map: TileMap) {
|
||||||
if(map.mapParameters.noRuins)
|
if(map.mapParameters.noRuins)
|
||||||
return
|
return
|
||||||
val suitableTiles = map.values.filter { it.isLand && !it.getBaseTerrain().impassable }
|
val suitableTiles = map.values.filter { it.isLand && !it.isImpassible() }
|
||||||
val locations = randomness.chooseSpreadOutLocations(suitableTiles.size/100,
|
val locations = randomness.chooseSpreadOutLocations(suitableTiles.size/100,
|
||||||
suitableTiles, 10)
|
suitableTiles, 10)
|
||||||
for(tile in locations)
|
for(tile in locations)
|
||||||
@ -126,7 +126,7 @@ class MapGenerator(val ruleset: Ruleset) {
|
|||||||
private fun spreadStrategicResources(tileMap: TileMap, distance: Int) {
|
private fun spreadStrategicResources(tileMap: TileMap, distance: Int) {
|
||||||
val strategicResources = ruleset.tileResources.values.filter { it.resourceType == ResourceType.Strategic }
|
val strategicResources = ruleset.tileResources.values.filter { it.resourceType == ResourceType.Strategic }
|
||||||
// passable land tiles (no mountains, no wonders) without resources yet
|
// passable land tiles (no mountains, no wonders) without resources yet
|
||||||
val candidateTiles = tileMap.values.filter { it.resource == null && !it.getLastTerrain().impassable }
|
val candidateTiles = tileMap.values.filter { it.resource == null && !it.isImpassible() }
|
||||||
val totalNumberOfResources = candidateTiles.size * tileMap.mapParameters.resourceRichness
|
val totalNumberOfResources = candidateTiles.size * tileMap.mapParameters.resourceRichness
|
||||||
val resourcesPerType = (totalNumberOfResources/strategicResources.size).toInt()
|
val resourcesPerType = (totalNumberOfResources/strategicResources.size).toInt()
|
||||||
for (resource in strategicResources) {
|
for (resource in strategicResources) {
|
||||||
@ -150,7 +150,7 @@ class MapGenerator(val ruleset: Ruleset) {
|
|||||||
|
|
||||||
val suitableTiles = tileMap.values
|
val suitableTiles = tileMap.values
|
||||||
.filter { it.resource == null && resourcesOfType.any { r -> r.terrainsCanBeFoundOn.contains(it.getLastTerrain().name) } }
|
.filter { it.resource == null && resourcesOfType.any { r -> r.terrainsCanBeFoundOn.contains(it.getLastTerrain().name) } }
|
||||||
val numberOfResources = tileMap.values.count { it.isLand && !it.getBaseTerrain().impassable } *
|
val numberOfResources = tileMap.values.count { it.isLand && !it.isImpassible() } *
|
||||||
tileMap.mapParameters.resourceRichness
|
tileMap.mapParameters.resourceRichness
|
||||||
val locations = randomness.chooseSpreadOutLocations(numberOfResources.toInt(), suitableTiles, distance)
|
val locations = randomness.chooseSpreadOutLocations(numberOfResources.toInt(), suitableTiles, distance)
|
||||||
|
|
||||||
|
@ -503,18 +503,18 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
if (tileInfo.improvement!=null) {
|
if (tileInfo.improvement!=null) {
|
||||||
normalizeTileImprovement(tileInfo)
|
normalizeTileImprovement(tileInfo)
|
||||||
}
|
}
|
||||||
if (tileInfo.getBaseTerrain().impassable || tileInfo.isWater)
|
if (tileInfo.isWater || tileInfo.isImpassible())
|
||||||
tileInfo.roadStatus= RoadStatus.None
|
tileInfo.roadStatus= RoadStatus.None
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun normalizeTileImprovement(tileInfo: TileInfo) {
|
private fun normalizeTileImprovement(tileInfo: TileInfo) {
|
||||||
|
val topTerrain = tileInfo.getLastTerrain()
|
||||||
if (tileInfo.improvement!!.startsWith("StartingLocation")) {
|
if (tileInfo.improvement!!.startsWith("StartingLocation")) {
|
||||||
if (!tileInfo.isLand || tileInfo.getBaseTerrain().impassable)
|
if (!tileInfo.isLand || topTerrain.impassable)
|
||||||
tileInfo.improvement = null
|
tileInfo.improvement = null
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val improvement = tileInfo.getTileImprovement()!!
|
val improvement = tileInfo.getTileImprovement()!!
|
||||||
val topTerrain = tileInfo.getLastTerrain()
|
|
||||||
val resource = if (tileInfo.resource!=null) tileInfo.getTileResource() else null
|
val resource = if (tileInfo.resource!=null) tileInfo.getTileResource() else null
|
||||||
when {
|
when {
|
||||||
// Precedence, simplified: terrainsCanBeBuiltOn, then improves-resource, then 'everywhere', default to false
|
// Precedence, simplified: terrainsCanBeBuiltOn, then improves-resource, then 'everywhere', default to false
|
||||||
|
@ -376,7 +376,7 @@ object UnitActions {
|
|||||||
addGoldPerGreatPersonUsage(unit.civInfo)
|
addGoldPerGreatPersonUsage(unit.civInfo)
|
||||||
unit.destroy()
|
unit.destroy()
|
||||||
}.takeIf { unit.currentMovement > 0f && !tile.isWater &&
|
}.takeIf { unit.currentMovement > 0f && !tile.isWater &&
|
||||||
!tile.isCityCenter() && !tile.getLastTerrain().impassable &&
|
!tile.isCityCenter() && !tile.isImpassible() &&
|
||||||
tile.improvement != improvementName &&
|
tile.improvement != improvementName &&
|
||||||
// citadel can be built only next to or within own borders
|
// citadel can be built only next to or within own borders
|
||||||
(improvementName != Constants.citadel ||
|
(improvementName != Constants.citadel ||
|
||||||
|
Loading…
Reference in New Issue
Block a user