Fix Fountain of Youth (#5355)

* fix fountain of youth

* fix test fail

* reviews

* reviews
This commit is contained in:
SimonCeder 2021-10-01 14:51:30 +02:00 committed by GitHub
parent 03f374b058
commit 344c96319b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 17 deletions

View File

@ -233,6 +233,7 @@
"name": "El Dorado",
"type": "NaturalWonder",
"culture": 5,
"overrideStats": true,
"occursOn": ["Plains"],
"turnsInto": "Plains",
"impassable": true,
@ -246,12 +247,14 @@
"name": "Fountain of Youth",
"type": "NaturalWonder",
"happiness": 10,
"overrideStats": true,
"occursOn": ["Plains"],
"turnsInto": "Plains",
"impassable": true,
"unbuildable": true,
"uniques": ["Must be adjacent to [0] [Coast] tiles",
"Grants [Rejuvenation] ([all healing effects doubled]) to adjacent [{Military} {Land}] units for the rest of the game"],
"Grants [Rejuvenation] ([all healing effects doubled]) to adjacent [{Military} {Land}] units for the rest of the game",
"Tile provides yield without assigned population"],
"weight": 1
},
{
@ -411,6 +414,7 @@
"name": "King Solomon's Mines",
"type": "NaturalWonder",
"production": 6,
"overrideStats": true,
"occursOn": ["Plains","Desert"],
"uniques": ["Must be adjacent to [0] [Coast] tiles",
"Must be adjacent to [0] to [2] [Mountain] tiles"],

View File

@ -45,7 +45,9 @@ class CityStats(val cityInfo: CityInfo) {
val stats = Stats()
for (cell in cityInfo.tilesInRange
.filter { cityInfo.location == it.position || cityInfo.isWorked(it) ||
it.getTileImprovement()?.hasUnique(UniqueType.TileProvidesYieldWithoutPopulation)==true && it.owningCity == cityInfo })
it.owningCity == cityInfo && (it.getTileImprovement()?.hasUnique(UniqueType.TileProvidesYieldWithoutPopulation) == true ||
it.hasUnique(UniqueType.TileProvidesYieldWithoutPopulation))
})
stats.add(cell.getTileStats(cityInfo, cityInfo.civInfo))
return stats
}

View File

@ -648,13 +648,15 @@ class MapUnit {
.flatMap { it.getUnits().asSequence() }.map { it.adjacentHealingBonus() }.maxOrNull()
if (maxAdjacentHealingBonus != null)
amountToHealBy += maxAdjacentHealingBonus
if (hasUnique("All healing effects doubled"))
amountToHealBy *= 2
healBy(amountToHealBy)
}
fun healBy(amount: Int) {
health += amount
health += if (hasUnique("All healing effects doubled"))
amount * 2
else
amount
if (health > 100) health = 100
}

View File

@ -194,7 +194,8 @@ open class TileInfo {
fun isRoughTerrain() = getAllTerrains().any{ it.isRough() }
fun hasUnique(unique: String) = getAllTerrains().any { it.uniques.contains(unique) }
fun hasUnique(unique: String) = getAllTerrains().any { it.hasUnique(unique) }
fun hasUnique(uniqueType: UniqueType) = getAllTerrains().any { it.hasUnique(uniqueType) }
fun getWorkingCity(): CityInfo? {
val civInfo = getOwner() ?: return null
@ -203,7 +204,8 @@ open class TileInfo {
fun isWorked(): Boolean = getWorkingCity() != null
fun providesYield() = getCity() != null && (isCityCenter() || isWorked()
|| getTileImprovement()?.hasUnique(UniqueType.TileProvidesYieldWithoutPopulation) == true)
|| getTileImprovement()?.hasUnique(UniqueType.TileProvidesYieldWithoutPopulation) == true
|| hasUnique(UniqueType.TileProvidesYieldWithoutPopulation))
fun isLocked(): Boolean {
val workingCity = getWorkingCity()
@ -222,6 +224,20 @@ open class TileInfo {
stats.add(terrainFeatureBase)
}
if (naturalWonder != null) {
val wonder = getNaturalWonder().clone()
// Spain doubles tile yield
if (city != null && city.civInfo.hasUnique("Tile yields from Natural Wonders doubled")) {
wonder.timesInPlace(2f)
}
if (getNaturalWonder().overrideStats)
stats = wonder
else
stats.add(wonder)
}
if (city != null) {
var tileUniques = city.getMatchingUniques("[] from [] tiles []")
.filter { city.matchesFilter(it.params[2]) }
@ -245,15 +261,6 @@ open class TileInfo {
stats.add(unique.stats)
}
if (naturalWonder != null) {
val wonder = getNaturalWonder()
stats.add(wonder)
// Spain doubles tile yield
if (city != null && city.civInfo.hasUnique("Tile yields from Natural Wonders doubled")) {
stats.add(wonder)
}
}
// resource base
if (hasViewableResource(observingCiv)) stats.add(getTileResource())

View File

@ -78,7 +78,7 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
@Deprecated("As of 3.16.14", ReplaceWith("[amount]% growth [cityFilter] <when not at war>"), DeprecationLevel.WARNING)
GrowthPercentBonusWhenNotAtWar("+[amount]% growth [cityFilter] when not at war", UniqueTarget.Global),
TileProvidesYieldWithoutPopulation("Tile provides yield without assigned population", UniqueTarget.Improvement),
TileProvidesYieldWithoutPopulation("Tile provides yield without assigned population", UniqueTarget.Terrain, UniqueTarget.Improvement),
@Deprecated("As of 3.16.16", ReplaceWith("[amount]% maintenance costs for [mapUnitFilter] units"), DeprecationLevel.WARNING)
DecreasedUnitMaintenanceCostsByFilter("-[amount]% [mapUnitFilter] unit maintenance costs"), // No conditional support