mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-11 18:39:43 +07:00
More unique typing
This commit is contained in:
parent
7f539aa4fa
commit
bb8c9d3175
@ -391,6 +391,9 @@ class CityInfo {
|
||||
fun containsBuildingUnique(unique: String) =
|
||||
cityConstructions.getBuiltBuildings().any { it.uniques.contains(unique) }
|
||||
|
||||
fun containsBuildingUnique(uniqueType: UniqueType) =
|
||||
cityConstructions.getBuiltBuildings().flatMap { it.uniqueObjects }.any { it.isOfType(uniqueType) }
|
||||
|
||||
fun getGreatPersonPointsForNextTurn(): HashMap<String, Counter<String>> {
|
||||
val sourceToGPP = HashMap<String, Counter<String>>()
|
||||
|
||||
|
@ -44,7 +44,7 @@ class CityStats(val cityInfo: CityInfo) {
|
||||
val stats = Stats()
|
||||
for (cell in cityInfo.tilesInRange
|
||||
.filter { cityInfo.location == it.position || cityInfo.isWorked(it) ||
|
||||
it.getTileImprovement()?.hasUnique("Tile provides yield without assigned population")==true && it.owningCity == cityInfo })
|
||||
it.getTileImprovement()?.hasUnique(UniqueType.TileProvidesYieldWithoutPopulation)==true && it.owningCity == cityInfo })
|
||||
stats.add(cell.getTileStats(cityInfo, cityInfo.civInfo))
|
||||
return stats
|
||||
}
|
||||
@ -127,13 +127,11 @@ class CityStats(val cityInfo: CityInfo) {
|
||||
if (bonus.isOfType(UniqueType.CityStateStatsPerCity)
|
||||
&& cityInfo.matchesFilter(bonus.params[1])
|
||||
&& bonus.conditionalsApply(otherCiv, cityInfo)
|
||||
) {
|
||||
stats.add(bonus.stats)
|
||||
}
|
||||
) stats.add(bonus.stats)
|
||||
}
|
||||
}
|
||||
|
||||
for (unique in cityInfo.civInfo.getMatchingUniques("[]% [] from City-States")) {
|
||||
for (unique in cityInfo.civInfo.getMatchingUniques(UniqueType.BonusStatsFromCityStates)) {
|
||||
stats[Stat.valueOf(unique.params[1])] *= unique.params[0].toPercent()
|
||||
}
|
||||
}
|
||||
@ -170,17 +168,17 @@ class CityStats(val cityInfo: CityInfo) {
|
||||
private fun getGrowthBonusFromPoliciesAndWonders(): Float {
|
||||
var bonus = 0f
|
||||
// "[amount]% growth [cityFilter]"
|
||||
for (unique in cityInfo.getMatchingUniques("[]% growth []")) {
|
||||
for (unique in cityInfo.getMatchingUniques(UniqueType.GrowthPercentBonus)) {
|
||||
if (!unique.conditionalsApply(cityInfo.civInfo, cityInfo)) continue
|
||||
if (cityInfo.matchesFilter(unique.params[1]))
|
||||
bonus += unique.params[0].toFloat()
|
||||
}
|
||||
// Deprecated since 3.16.14
|
||||
for (unique in cityInfo.getMatchingUniques("+[]% growth []")) {
|
||||
for (unique in cityInfo.getMatchingUniques(UniqueType.GrowthPercentBonusPositive)) {
|
||||
if (cityInfo.matchesFilter(unique.params[1]))
|
||||
bonus += unique.params[0].toFloat()
|
||||
}
|
||||
for (unique in cityInfo.getMatchingUniques("+[]% growth [] when not at war"))
|
||||
for (unique in cityInfo.getMatchingUniques(UniqueType.GrowthPercentBonusWhenNotAtWar))
|
||||
if (cityInfo.matchesFilter(unique.params[1]) && !cityInfo.civInfo.isAtWar())
|
||||
bonus += unique.params[0].toFloat()
|
||||
//
|
||||
@ -189,7 +187,7 @@ class CityStats(val cityInfo: CityInfo) {
|
||||
|
||||
fun hasExtraAnnexUnhappiness(): Boolean {
|
||||
if (cityInfo.civInfo.civName == cityInfo.foundingCiv || cityInfo.isPuppet) return false
|
||||
return !cityInfo.containsBuildingUnique("Remove extra unhappiness from annexed cities")
|
||||
return !cityInfo.containsBuildingUnique(UniqueType.RemoveAnnexUnhappiness)
|
||||
}
|
||||
|
||||
fun getStatsOfSpecialist(specialistName: String): Stats {
|
||||
|
@ -203,7 +203,7 @@ open class TileInfo {
|
||||
|
||||
fun isWorked(): Boolean = getWorkingCity() != null
|
||||
fun providesYield() = getCity() != null && (isCityCenter() || isWorked()
|
||||
|| getTileImprovement()?.hasUnique("Tile provides yield without assigned population") == true)
|
||||
|| getTileImprovement()?.hasUnique(UniqueType.TileProvidesYieldWithoutPopulation) == true)
|
||||
|
||||
fun isLocked(): Boolean {
|
||||
val workingCity = getWorkingCity()
|
||||
|
@ -456,7 +456,6 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
||||
unit.currentMovement -= distanceToTiles[lastReachedEnterableTile]!!.totalDistance
|
||||
if (unit.currentMovement < Constants.minimumMovementEpsilon)
|
||||
unit.currentMovement = 0f // silly floats which are "almost zero"
|
||||
// const Epsilon, anyone?
|
||||
}
|
||||
|
||||
// The .toList() here is because we have a sequence that's running on the units in the tile,
|
||||
|
@ -3,6 +3,7 @@ package com.unciv.models.ruleset.unique
|
||||
import com.unciv.models.ruleset.Ruleset
|
||||
import com.unciv.models.ruleset.tile.ResourceType
|
||||
import com.unciv.models.ruleset.tile.TerrainType
|
||||
import com.unciv.models.stats.Stat
|
||||
|
||||
// parameterName values should be compliant with autogenerated values in TranslationFileWriter.generateStringsFromJSONs
|
||||
// Eventually we'll merge the translation generation to take this as the source of that
|
||||
@ -51,6 +52,13 @@ enum class UniqueParameterType(val parameterName:String) {
|
||||
return null
|
||||
}
|
||||
},
|
||||
StatName("stat"){
|
||||
override fun getErrorSeverity(parameterText: String, ruleset: Ruleset):
|
||||
UniqueType.UniqueComplianceErrorSeverity? {
|
||||
if (Stat.values().any { it.name == parameterText }) return null
|
||||
return UniqueType.UniqueComplianceErrorSeverity.RulesetInvariant
|
||||
}
|
||||
},
|
||||
CityFilter("cityFilter"){
|
||||
override fun getErrorSeverity(parameterText: String, ruleset: Ruleset):
|
||||
UniqueType.UniqueComplianceErrorSeverity? {
|
||||
|
@ -69,6 +69,17 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
|
||||
|
||||
FreeUnits("[amount] units cost no maintenance", UniqueTarget.Global),
|
||||
UnitMaintenanceDiscount("[amount]% maintenance costs for [mapUnitFilter] units", UniqueTarget.Global),
|
||||
BonusStatsFromCityStates("[amount]% [stat] from City-States", UniqueTarget.Global),
|
||||
RemoveAnnexUnhappiness("Remove extra unhappiness from annexed cities", UniqueTarget.Building),
|
||||
|
||||
GrowthPercentBonus("[amount]% growth [cityFilter]", UniqueTarget.Global),
|
||||
@Deprecated("As of 3.16.14", ReplaceWith("[amount]% growth [cityFilter]"), DeprecationLevel.WARNING)
|
||||
GrowthPercentBonusPositive("+[amount]% growth [cityFilter]", UniqueTarget.Global),
|
||||
@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),
|
||||
|
||||
|
||||
@Deprecated("As of 3.16.16", ReplaceWith("[amount]% maintenance costs for [mapUnitFilter] units"), DeprecationLevel.WARNING)
|
||||
DecreasedUnitMaintenanceCostsByFilter("-[amount]% [mapUnitFilter] unit maintenance costs"), // No conditional support
|
||||
|
Loading…
Reference in New Issue
Block a user