mirror of
https://github.com/yairm210/Unciv.git
synced 2025-08-03 16:49:15 +07:00
River adjacency functions and gold bonus for tiles adjacent to rivers
This commit is contained in:
@ -242,6 +242,8 @@ open class TileInfo {
|
||||
if (stats.gold != 0f && observingCiv.goldenAges.isGoldenAge())
|
||||
stats.gold++
|
||||
|
||||
if (isAdjacentToRiver()) stats.gold++
|
||||
|
||||
if (stats.production < 0) stats.production = 0f
|
||||
|
||||
return stats
|
||||
@ -336,6 +338,21 @@ open class TileInfo {
|
||||
return toString(null)
|
||||
}
|
||||
|
||||
fun isConnectedByRiver(otherTile:TileInfo): Boolean {
|
||||
if(otherTile !in neighbors) throw Exception("Should never call this function on a non-neighbor!")
|
||||
val xDifference = this.position.x - otherTile.position.x
|
||||
val yDifference = this.position.y - otherTile.position.y
|
||||
|
||||
return when {
|
||||
xDifference == 1f && yDifference == 1f -> hasBottomRiver // we're directly above it
|
||||
xDifference == 1f -> hasBottomRightRiver // we're to the top-left of it
|
||||
yDifference == 1f -> hasBottomLeftRiver // we're to the top-right of it
|
||||
else -> otherTile.isConnectedByRiver(this) // we're below it, check the other tile
|
||||
}
|
||||
}
|
||||
|
||||
fun isAdjacentToRiver() = neighbors.any { isConnectedByRiver(it) }
|
||||
|
||||
fun toString(viewingCiv: CivilizationInfo?): String {
|
||||
val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case
|
||||
val isViewableToPlayer = viewingCiv == null || UncivGame.Current.viewEntireMapForDebug
|
||||
@ -412,6 +429,7 @@ open class TileInfo {
|
||||
improvementInProgress = improvement.name
|
||||
turnsToImprovement = improvement.getTurnsToBuild(civInfo)
|
||||
}
|
||||
|
||||
fun stopWorkingOnImprovement() {
|
||||
improvementInProgress = null
|
||||
turnsToImprovement = 0
|
||||
|
Reference in New Issue
Block a user