mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 05:09:25 +07:00
Fixed wrapped tiles costing way to much gold (#3648)
This commit is contained in:
@ -12,6 +12,7 @@ import com.unciv.models.stats.Stats
|
|||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.utils.Fonts
|
import com.unciv.ui.utils.Fonts
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
import kotlin.math.min
|
||||||
|
|
||||||
open class TileInfo {
|
open class TileInfo {
|
||||||
@Transient
|
@Transient
|
||||||
@ -398,7 +399,14 @@ open class TileInfo {
|
|||||||
fun aerialDistanceTo(otherTile: TileInfo): Int {
|
fun aerialDistanceTo(otherTile: TileInfo): Int {
|
||||||
val xDelta = position.x - otherTile.position.x
|
val xDelta = position.x - otherTile.position.x
|
||||||
val yDelta = position.y - otherTile.position.y
|
val yDelta = position.y - otherTile.position.y
|
||||||
return listOf(abs(xDelta), abs(yDelta), abs(xDelta - yDelta)).max()!!.toInt()
|
val distance = listOf(abs(xDelta), abs(yDelta), abs(xDelta - yDelta)).maxOrNull()!!
|
||||||
|
|
||||||
|
val otherTileUnwrappedPos = tileMap.getUnWrappedPosition(otherTile.position)
|
||||||
|
val xDeltaWrapped = position.x - otherTileUnwrappedPos.x
|
||||||
|
val yDeltaWrapped = position.y - otherTileUnwrappedPos.y
|
||||||
|
val wrappedDistance = listOf(abs(xDeltaWrapped), abs(yDeltaWrapped), abs(xDeltaWrapped - yDeltaWrapped)).maxOrNull()!!
|
||||||
|
|
||||||
|
return min(distance, wrappedDistance).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isRoughTerrain() = getBaseTerrain().rough || getTerrainFeature()?.rough == true
|
fun isRoughTerrain() = getBaseTerrain().rough || getTerrainFeature()?.rough == true
|
||||||
|
Reference in New Issue
Block a user