mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-16 10:49:17 +07:00
More unique typing isn't this fun
This commit is contained in:
@ -391,7 +391,7 @@ class CityConstructions {
|
||||
|
||||
private fun constructionBegun(construction: IConstruction) {
|
||||
if (construction !is Building) return
|
||||
if (!construction.hasUnique("Triggers a global alert upon build start")) return
|
||||
if (!construction.hasUnique(UniqueType.TriggersAlertOnStart)) return
|
||||
val buildingIcon = "BuildingIcons/${construction.name}"
|
||||
for (otherCiv in cityInfo.civInfo.gameInfo.civilizations) {
|
||||
if (otherCiv == cityInfo.civInfo) continue
|
||||
@ -433,7 +433,7 @@ class CityConstructions {
|
||||
cityInfo.location, NotificationIcon.Construction, icon)
|
||||
}
|
||||
|
||||
if (construction is Building && construction.hasUnique("Triggers a global alert upon completion",
|
||||
if (construction is Building && construction.hasUnique(UniqueType.TriggersAlertOnCompletion,
|
||||
StateForConditionals(cityInfo.civInfo, cityInfo)
|
||||
)) {
|
||||
for (otherCiv in cityInfo.civInfo.gameInfo.civilizations) {
|
||||
|
@ -610,7 +610,7 @@ class CityInfo {
|
||||
expansion.nextTurn(stats.culture)
|
||||
if (isBeingRazed) {
|
||||
val removedPopulation =
|
||||
1 + civInfo.getMatchingUniques("Cities are razed [] times as fast")
|
||||
1 + civInfo.getMatchingUniques(UniqueType.CitiesAreRazedXTimesFaster)
|
||||
.sumOf { it.params[0].toInt() - 1 }
|
||||
population.addPopulation(-1 * removedPopulation)
|
||||
if (population.population <= 0) {
|
||||
|
@ -249,7 +249,6 @@ open class TileInfo {
|
||||
|
||||
fun isRoughTerrain() = getAllTerrains().any{ it.isRough() }
|
||||
|
||||
fun hasUnique(unique: String) = getAllTerrains().any { it.hasUnique(unique) }
|
||||
fun hasUnique(uniqueType: UniqueType) = getAllTerrains().any { it.hasUnique(uniqueType) }
|
||||
|
||||
fun getWorkingCity(): CityInfo? {
|
||||
@ -539,7 +538,7 @@ open class TileInfo {
|
||||
improvement.hasUnique(UniqueType.ImprovementBuildableByFreshWater) && isAdjacentToFreshwater -> true
|
||||
|
||||
// If an unique of this type exists, we want all to match (e.g. Hill _and_ Forest would be meaningful).
|
||||
improvement.getMatchingUniques("Can only be built on [] tiles").let {
|
||||
improvement.getMatchingUniques(UniqueType.CanOnlyBeBuiltOnTile).let {
|
||||
it.any() && it.all { unique -> matchesTerrainFilter(unique.params[0]) }
|
||||
} -> true
|
||||
|
||||
@ -578,7 +577,7 @@ open class TileInfo {
|
||||
"Fresh Water" -> isAdjacentToFreshwater
|
||||
else -> {
|
||||
if (terrainFeatures.contains(filter)) return true
|
||||
if (hasUnique(filter)) return true
|
||||
if (getAllTerrains().any { it.hasUnique(filter) }) return true
|
||||
// Resource type check is last - cannot succeed if no resource here
|
||||
if (resource == null) return false
|
||||
// Checks 'luxury resource', 'strategic resource' and 'bonus resource' - only those that are visible of course
|
||||
|
@ -138,7 +138,7 @@ class Technology: RulesetObject() {
|
||||
.filter {
|
||||
it.requiredTech == name
|
||||
&& (it.uniqueTo == civInfo.civName || it.uniqueTo==null && civInfo.getEquivalentUnit(it) == it)
|
||||
&& (nuclearWeaponsEnabled || !it.hasUnique("Nuclear weapon of Strength []"))
|
||||
&& (nuclearWeaponsEnabled || !it.isNuclearWeapon())
|
||||
&& (religionEnabled || !it.hasUnique(UniqueType.HiddenWithoutReligion))
|
||||
&& !it.hasUnique(UniqueType.HiddenFromCivilopedia)
|
||||
}
|
||||
|
@ -241,6 +241,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
ChanceToRecruitBarbarianFromEncampment("67% chance to earn 25 Gold and recruit a Barbarian unit from a conquered encampment", UniqueTarget.Global),
|
||||
ChanceToRecruitNavalBarbarian("50% chance of capturing defeated Barbarian naval units and earning 25 Gold", UniqueTarget.Global),
|
||||
TripleGoldFromEncampmentsAndCities("Receive triple Gold from Barbarian encampments and pillaging Cities", UniqueTarget.Global),
|
||||
CitiesAreRazedXTimesFaster("Cities are razed [amount] times as fast", UniqueTarget.Global),
|
||||
|
||||
EnablesOpenBorders("Enables Open Borders agreements", UniqueTarget.Global),
|
||||
// Should the 'R' in 'Research agreements' be capitalized?
|
||||
@ -333,7 +334,9 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
|
||||
ConvertFoodToProductionWhenConstructed("Excess Food converted to Production when under construction", UniqueTarget.Building, UniqueTarget.Unit),
|
||||
RequiresPopulation("Requires at least [amount] population", UniqueTarget.Building, UniqueTarget.Unit),
|
||||
|
||||
|
||||
TriggersAlertOnStart("Triggers a global alert upon build start", UniqueTarget.Building, UniqueTarget.Unit),
|
||||
TriggersAlertOnCompletion("Triggers a global alert upon completion", UniqueTarget.Building, UniqueTarget.Unit),
|
||||
//endregion
|
||||
|
||||
|
||||
@ -366,6 +369,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
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),
|
||||
|
||||
@ -553,6 +557,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
|
||||
CanBuildOutsideBorders("Can be built outside your borders", UniqueTarget.Improvement),
|
||||
CanBuildJustOutsideBorders("Can be built just outside your borders", UniqueTarget.Improvement),
|
||||
CanOnlyBeBuiltOnTile("Can only be built on [tileFilter] tiles", UniqueTarget.Improvement),
|
||||
CannotBuildOnTile("Cannot be built on [tileFilter] tiles", UniqueTarget.Improvement),
|
||||
NoFeatureRemovalNeeded("Does not need removal of [tileFilter]", UniqueTarget.Improvement),
|
||||
|
||||
|
@ -101,7 +101,7 @@ class Promotion : RulesetObject() {
|
||||
}
|
||||
|
||||
val grantors = ruleset.buildings.values.filter {
|
||||
building -> building.getMatchingUniques("All newly-trained [] units [] receive the [] promotion")
|
||||
building -> building.getMatchingUniques(UniqueType.UnitStartingPromotions)
|
||||
.any { it.params[2] == name }
|
||||
} + ruleset.terrains.values.filter {
|
||||
terrain -> terrain.getMatchingUniques(UniqueType.TerrainGrantsPromotion).any {
|
||||
|
Reference in New Issue
Block a user