mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 23:40:01 +07:00
Some of the last remaining simple uniques, from now on it's more complicated ones
This commit is contained in:
@ -110,7 +110,7 @@ class BarbarianManager {
|
||||
val viableTiles = fogTiles.filter {
|
||||
!it.isImpassible()
|
||||
&& it.resource == null
|
||||
&& it.terrainFeatureObjects.none { feature -> feature.hasUnique("Only [] improvements may be built on this tile") }
|
||||
&& it.terrainFeatureObjects.none { feature -> feature.hasUnique(UniqueType.RestrictedBuildableImprovements) }
|
||||
&& it.neighbors.any { neighbor -> neighbor.isLand }
|
||||
&& it !in tooCloseToCapitals
|
||||
&& it !in tooCloseToCamps
|
||||
|
@ -265,7 +265,7 @@ class CityInfo {
|
||||
fun capitalCityIndicator(): String {
|
||||
val indicatorBuildings = getRuleset().buildings.values
|
||||
.asSequence()
|
||||
.filter { it.uniques.contains("Indicates the capital city") }
|
||||
.filter { it.hasUnique(UniqueType.IndicatesCapital) }
|
||||
|
||||
val civSpecificBuilding = indicatorBuildings.firstOrNull { it.uniqueTo == civInfo.civName }
|
||||
return civSpecificBuilding?.name ?: indicatorBuildings.first().name
|
||||
@ -372,7 +372,7 @@ class CityInfo {
|
||||
var amountToAdd = if (resource.resourceType == ResourceType.Strategic) tileInfo.resourceAmount
|
||||
else 1
|
||||
if (resource.resourceType == ResourceType.Luxury
|
||||
&& containsBuildingUnique("Provides 1 extra copy of each improved luxury resource near this City")
|
||||
&& containsBuildingUnique(UniqueType.ProvidesExtraLuxuryFromCityResources)
|
||||
)
|
||||
amountToAdd += 1
|
||||
|
||||
@ -402,9 +402,6 @@ class CityInfo {
|
||||
return population.foodStored / -foodForNextTurn() + 1
|
||||
}
|
||||
|
||||
fun containsBuildingUnique(unique: String) =
|
||||
cityConstructions.getBuiltBuildings().any { it.uniques.contains(unique) }
|
||||
|
||||
fun containsBuildingUnique(uniqueType: UniqueType) =
|
||||
cityConstructions.getBuiltBuildings().flatMap { it.uniqueObjects }.any { it.isOfType(uniqueType) }
|
||||
|
||||
|
@ -25,7 +25,7 @@ class CityInfoConquestFunctions(val city: CityInfo){
|
||||
private fun getGoldForCapturingCity(conqueringCiv: CivilizationInfo): Int {
|
||||
val baseGold = 20 + 10 * city.population.population + tileBasedRandom.nextInt(40)
|
||||
val turnModifier = max(0, min(50, city.civInfo.gameInfo.turns - city.turnAcquired)) / 50f
|
||||
val cityModifier = if (city.containsBuildingUnique("Doubles Gold given to enemy if city is captured")) 2f else 1f
|
||||
val cityModifier = if (city.containsBuildingUnique(UniqueType.DoublesGoldFromCapturingCity)) 2f else 1f
|
||||
val conqueringCivModifier = if (conqueringCiv.hasUnique(UniqueType.TripleGoldFromEncampmentsAndCities)) 3f else 1f
|
||||
|
||||
val goldPlundered = baseGold * turnModifier * cityModifier * conqueringCivModifier
|
||||
@ -37,9 +37,9 @@ class CityInfoConquestFunctions(val city: CityInfo){
|
||||
// Possibly remove other buildings
|
||||
for (building in cityConstructions.getBuiltBuildings()) {
|
||||
when {
|
||||
building.hasUnique("Never destroyed when the city is captured") || building.isWonder -> continue
|
||||
building.hasUnique("Indicates the capital city") -> continue // Palace needs to stay a just a bit longer so moveToCiv isn't confused
|
||||
building.hasUnique("Destroyed when the city is captured") ->
|
||||
building.hasUnique(UniqueType.NotDestroyedWhenCityCaptured) || building.isWonder -> continue
|
||||
building.hasUnique(UniqueType.IndicatesCapital) -> continue // Palace needs to stay a just a bit longer so moveToCiv isn't confused
|
||||
building.hasUnique(UniqueType.DestroyedWhenCityCaptured) ->
|
||||
cityConstructions.removeBuilding(building.name)
|
||||
else -> {
|
||||
if (tileBasedRandom.nextInt(100) < 34) {
|
||||
@ -70,7 +70,7 @@ class CityInfoConquestFunctions(val city: CityInfo){
|
||||
|
||||
for (building in cityConstructions.getBuiltBuildings()) {
|
||||
// Remove national wonders
|
||||
if (building.isNationalWonder && !building.hasUnique("Never destroyed when the city is captured"))
|
||||
if (building.isNationalWonder && !building.hasUnique(UniqueType.NotDestroyedWhenCityCaptured))
|
||||
cityConstructions.removeBuilding(building.name)
|
||||
|
||||
// Check if we exceed MaxNumberBuildable for any buildings
|
||||
|
@ -516,7 +516,7 @@ open class TileInfo {
|
||||
} -> false
|
||||
// Road improvements can change on tiles with irremovable improvements - nothing else can, though.
|
||||
RoadStatus.values().none { it.name == improvement.name || it.removeAction == improvement.name }
|
||||
&& getTileImprovement().let { it != null && it.hasUnique("Irremovable") } -> false
|
||||
&& getTileImprovement().let { it != null && it.hasUnique( UniqueType.Irremovable) } -> false
|
||||
|
||||
// Terrain blocks BUILDING improvements - removing things (such as fallout) is fine
|
||||
!improvement.name.startsWith(Constants.remove) &&
|
||||
|
@ -346,6 +346,12 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
|
||||
Unsellable("Unsellable", UniqueTarget.Building),
|
||||
ObsoleteWith("Obsolete with [tech]", UniqueTarget.Building, UniqueTarget.Resource, UniqueTarget.Improvement),
|
||||
IndicatesCapital("Indicates the capital city", UniqueTarget.Building),
|
||||
ProvidesExtraLuxuryFromCityResources("Provides 1 extra copy of each improved luxury resource near this City", UniqueTarget.Building),
|
||||
|
||||
DestroyedWhenCityCaptured("Destroyed when the city is captured", UniqueTarget.Building),
|
||||
NotDestroyedWhenCityCaptured("Never destroyed when the city is captured", UniqueTarget.Building),
|
||||
DoublesGoldFromCapturingCity("Doubles Gold given to enemy if city is captured", UniqueTarget.Building),
|
||||
|
||||
RemoveAnnexUnhappiness("Remove extra unhappiness from annexed cities", UniqueTarget.Building),
|
||||
|
||||
@ -546,8 +552,8 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
IsAncientRuinsEquivalent("Provides a random bonus when entered", UniqueTarget.Improvement),
|
||||
|
||||
Unpillagable("Unpillagable", UniqueTarget.Improvement),
|
||||
|
||||
Indestructible("Indestructible", UniqueTarget.Improvement),
|
||||
Irremovable("Irremovable", UniqueTarget.Improvement),
|
||||
//endregion
|
||||
|
||||
///////////////////////////////////////// region CONDITIONALS /////////////////////////////////////////
|
||||
|
@ -89,7 +89,7 @@ class GlobalUniquesTests {
|
||||
|
||||
if (replacePalace && civInfo.cities.size == 1) {
|
||||
// Add a capital indicator without any other stats
|
||||
val palaceWithoutStats = createBuildingWithUnique("Indicates the capital city")
|
||||
val palaceWithoutStats = createBuildingWithUnique(UniqueType.IndicatesCapital.text)
|
||||
cityInfo.cityConstructions.removeBuilding("Palace")
|
||||
cityInfo.cityConstructions.addBuilding(palaceWithoutStats.name)
|
||||
}
|
||||
|
Reference in New Issue
Block a user