mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-30 15:30:43 -04:00
River adjacency functions and gold bonus for tiles adjacent to rivers
This commit is contained in:
parent
8a43d5c5d6
commit
3032ba9c73
@ -242,6 +242,8 @@ open class TileInfo {
|
|||||||
if (stats.gold != 0f && observingCiv.goldenAges.isGoldenAge())
|
if (stats.gold != 0f && observingCiv.goldenAges.isGoldenAge())
|
||||||
stats.gold++
|
stats.gold++
|
||||||
|
|
||||||
|
if (isAdjacentToRiver()) stats.gold++
|
||||||
|
|
||||||
if (stats.production < 0) stats.production = 0f
|
if (stats.production < 0) stats.production = 0f
|
||||||
|
|
||||||
return stats
|
return stats
|
||||||
@ -336,6 +338,21 @@ open class TileInfo {
|
|||||||
return toString(null)
|
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 {
|
fun toString(viewingCiv: CivilizationInfo?): String {
|
||||||
val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case
|
val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case
|
||||||
val isViewableToPlayer = viewingCiv == null || UncivGame.Current.viewEntireMapForDebug
|
val isViewableToPlayer = viewingCiv == null || UncivGame.Current.viewEntireMapForDebug
|
||||||
@ -412,6 +429,7 @@ open class TileInfo {
|
|||||||
improvementInProgress = improvement.name
|
improvementInProgress = improvement.name
|
||||||
turnsToImprovement = improvement.getTurnsToBuild(civInfo)
|
turnsToImprovement = improvement.getTurnsToBuild(civInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stopWorkingOnImprovement() {
|
fun stopWorkingOnImprovement() {
|
||||||
improvementInProgress = null
|
improvementInProgress = null
|
||||||
turnsToImprovement = 0
|
turnsToImprovement = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user