Added the "crudely-drawn map" to ancient ruins outcomes (#1645)

* Added the "crudely-drawn map" to ancient ruins outcomes

Closes #1640

* Extracted the constants for readability

Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>
This commit is contained in:
lyrjie
2020-01-09 21:40:59 +03:00
committed by Yair Morgenstern
parent 0aa2061637
commit ba324c9fad
19 changed files with 53 additions and 1 deletions

View File

@ -15,6 +15,7 @@ import com.unciv.models.ruleset.tile.TerrainType
import com.unciv.models.ruleset.unit.BaseUnit
import com.unciv.models.ruleset.unit.UnitType
import java.text.DecimalFormat
import kotlin.random.Random
class MapUnit {
@ -63,6 +64,12 @@ class MapUnit {
var promotions = UnitPromotions()
var due: Boolean = true
companion object {
private const val ANCIENT_RUIN_MAP_REVEAL_OFFSET = 4
private const val ANCIENT_RUIN_MAP_REVEAL_RANGE = 4
private const val ANCIENT_RUIN_MAP_REVEAL_CHANCE = 0.8f
}
//region pure functions
fun clone(): MapUnit {
val toReturn = MapUnit()
@ -507,6 +514,17 @@ class MapUnit {
civInfo.addNotification("We have found a stash of [$amount] gold in the ruins!",tile.position, Color.GOLD)
}
// Map of the surrounding area
actions.add {
val revealCenter = tile.getTilesAtDistance(ANCIENT_RUIN_MAP_REVEAL_OFFSET).random()
val tilesToReveal = revealCenter
.getTilesInDistance(ANCIENT_RUIN_MAP_REVEAL_RANGE)
.filter { Random.nextFloat() < ANCIENT_RUIN_MAP_REVEAL_CHANCE }
.map { it.position }
civInfo.exploredTiles.addAll(tilesToReveal)
civInfo.addNotification("We have found a crudely-drawn map in the ruins!", tile.position, Color.RED)
}
(actions.random())()
}