mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -04:00
TileInfo.hasUnique()
This commit is contained in:
parent
b7383bb959
commit
59a419c1c9
@ -96,7 +96,7 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) {
|
||||
var goldGained = 0
|
||||
val discoveredNaturalWonders = civInfo.gameInfo.civilizations.filter { it != civInfo && it.isMajorCiv() }
|
||||
.flatMap { it.naturalWonders }
|
||||
if (tile.containsUnique("Grants 500 Gold to the first civilization to discover it")
|
||||
if (tile.hasUnique("Grants 500 Gold to the first civilization to discover it")
|
||||
&& !discoveredNaturalWonders.contains(tile.naturalWonder!!)) {
|
||||
goldGained += 500
|
||||
}
|
||||
|
@ -360,15 +360,15 @@ class DiplomacyManager() {
|
||||
|
||||
if (!civInfo.isDefeated()) { // don't display city state relationship notifications when the city state is currently defeated
|
||||
val civCapitalLocation = if (civInfo.cities.isNotEmpty()) civInfo.getCapital().location else null
|
||||
if (getTurnsToRelationshipChange() == 1){
|
||||
if (getTurnsToRelationshipChange() == 1) {
|
||||
val text = "Your relationship with [${civInfo.civName}] is about to degrade"
|
||||
if(civCapitalLocation!=null) otherCiv().addNotification(text, civCapitalLocation, civInfo.civName, NotificationIcon.Diplomacy)
|
||||
if (civCapitalLocation != null) otherCiv().addNotification(text, civCapitalLocation, civInfo.civName, NotificationIcon.Diplomacy)
|
||||
else otherCiv().addNotification(text, civInfo.civName, NotificationIcon.Diplomacy)
|
||||
}
|
||||
|
||||
if (initialRelationshipLevel >= RelationshipLevel.Friend && initialRelationshipLevel != relationshipLevel()){
|
||||
if (initialRelationshipLevel >= RelationshipLevel.Friend && initialRelationshipLevel != relationshipLevel()) {
|
||||
val text = "Your relationship with [${civInfo.civName}] degraded"
|
||||
if(civCapitalLocation!=null) otherCiv().addNotification(text, civCapitalLocation, civInfo.civName, NotificationIcon.Diplomacy)
|
||||
if (civCapitalLocation != null) otherCiv().addNotification(text, civCapitalLocation, civInfo.civName, NotificationIcon.Diplomacy)
|
||||
else otherCiv().addNotification(text, civInfo.civName, NotificationIcon.Diplomacy)
|
||||
}
|
||||
}
|
||||
|
@ -559,7 +559,7 @@ class MapUnit {
|
||||
|
||||
if (!hasUnique("All healing effects doubled") && type.isLandUnit() && type.isMilitary()) {
|
||||
val gainDoubleHealPromotion = tile.neighbors
|
||||
.any { it.containsUnique("Grants Rejuvenation (all healing effects doubled) to adjacent military land units for the rest of the game") }
|
||||
.any { it.hasUnique("Grants Rejuvenation (all healing effects doubled) to adjacent military land units for the rest of the game") }
|
||||
if (gainDoubleHealPromotion && civInfo.gameInfo.ruleSet.unitPromotions.containsKey("Rejuvenation"))
|
||||
promotions.addPromotion("Rejuvenation", true)
|
||||
}
|
||||
|
@ -114,9 +114,6 @@ open class TileInfo {
|
||||
if (improvementInProgress == null) return false
|
||||
return ruleset.tileImprovements[improvementInProgress!!]!!.isGreatImprovement()
|
||||
}
|
||||
|
||||
fun containsUnique(unique: String): Boolean =
|
||||
isNaturalWonder() && getNaturalWonder().uniques.contains(unique)
|
||||
//region pure functions
|
||||
|
||||
/** Returns military, civilian and air units in tile */
|
||||
@ -191,8 +188,12 @@ 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 getAllTerrains(): Sequence<Terrain> = sequence {
|
||||
yield(baseTerrainObject)
|
||||
if (naturalWonder != null) yield(getNaturalWonder())
|
||||
yieldAll(terrainFeatures.asSequence().mapNotNull { ruleset.terrains[it] })
|
||||
}
|
||||
fun hasUnique(unique:String) = getAllTerrains().any { it.uniques.contains(unique) }
|
||||
|
||||
fun getWorkingCity(): CityInfo? {
|
||||
val civInfo = getOwner()
|
||||
|
Loading…
x
Reference in New Issue
Block a user