Simplified rough terrain check

This commit is contained in:
Yair Morgenstern 2021-05-06 12:35:28 +03:00
parent 4cb5a8c912
commit 7686b1ee4a
2 changed files with 4 additions and 5 deletions

View File

@ -74,7 +74,7 @@ open class TileInfo {
var roadStatus = RoadStatus.None
var turnsToImprovement: Int = 0
fun isHill() = terrainFeatures.contains(Constants.hill)
fun isHill() = baseTerrain == Constants.hill || terrainFeatures.contains(Constants.hill)
var hasBottomRightRiver = false
var hasBottomRiver = false
@ -191,6 +191,8 @@ open class TileInfo {
}
fun getTerrainFeatures(): List<Terrain> = terrainFeatures.mapNotNull { ruleset.terrains[it] }
fun getAllTerrains(): Sequence<Terrain> = sequenceOf(baseTerrainObject) +
terrainFeatures.asSequence().mapNotNull { ruleset.terrains[it] }
fun getWorkingCity(): CityInfo? {
val civInfo = getOwner()
@ -437,9 +439,6 @@ open class TileInfo {
return min(distance, wrappedDistance).toInt()
}
fun isRoughTerrain() = getBaseTerrain().rough || getTerrainFeatures().any { it.rough }
|| getBaseTerrain().uniques.contains("Rough") || getTerrainFeatures().any { it.uniques.contains("Rough") }
override fun toString(): String { // for debugging, it helps to see what you're doing
return toString(null)
}

View File

@ -43,7 +43,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
if (civInfo.nation.ignoreHillMovementCost && to.isHill())
return 1f + extraCost // usually hills take 2 movements, so here it is 1
if (unit.roughTerrainPenalty && to.isRoughTerrain())
if (unit.roughTerrainPenalty && to.getAllTerrains().any { it.rough || it.uniques.contains("Rough terrain") })
return 4f + extraCost
if (unit.doubleMovementInCoast && to.baseTerrain == Constants.coast)