mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 07:17:50 +07:00
Typing for unit uniques
This commit is contained in:
@ -1008,7 +1008,7 @@ class CivilizationInfo {
|
||||
addNotification("A [${unit.name}] has been born in [${cityToAddTo.name}]!", placedUnit.getTile().position, unit.name)
|
||||
}
|
||||
|
||||
if (placedUnit.hasUnique("Religious Unit") && gameInfo.isReligionEnabled()) {
|
||||
if (placedUnit.hasUnique(UniqueType.ReligiousUnit) && gameInfo.isReligionEnabled()) {
|
||||
placedUnit.religion =
|
||||
when {
|
||||
placedUnit.hasUnique("Takes your religion over the one in their birth city")
|
||||
|
@ -255,7 +255,7 @@ class ReligionManager {
|
||||
shouldChoosePantheonBelief = false
|
||||
|
||||
for (unit in civInfo.getCivUnits())
|
||||
if (unit.hasUnique("Religious Unit") && unit.hasUnique("Takes your religion over the one in their birth city"))
|
||||
if (unit.hasUnique(UniqueType.ReligiousUnit) && unit.hasUnique("Takes your religion over the one in their birth city"))
|
||||
unit.religion = newReligion.name
|
||||
}
|
||||
|
||||
|
@ -288,8 +288,8 @@ class MapUnit {
|
||||
|
||||
hasUniqueToBuildImprovements = hasUnique(UniqueType.BuildImprovements)
|
||||
canEnterForeignTerrain =
|
||||
hasUnique("May enter foreign tiles without open borders, but loses [] religious strength each turn it ends there")
|
||||
|| hasUnique("May enter foreign tiles without open borders")
|
||||
hasUnique(UniqueType.CanEnterForeignTilesButLosesReligiousStrength)
|
||||
|| hasUnique(UniqueType.CanEnterForeignTiles)
|
||||
}
|
||||
|
||||
fun copyStatisticsTo(newUnit: MapUnit) {
|
||||
@ -340,11 +340,6 @@ class MapUnit {
|
||||
visibilityRange += getMatchingUniques(UniqueType.Sight, checkCivInfoUniques = true)
|
||||
.sumOf { it.params[0].toInt() }
|
||||
|
||||
// Maybe add the uniques of the tile a unit is standing on to the tempUniques of the unit?
|
||||
for (unique in getTile().getAllTerrains().flatMap { it.uniqueObjects })
|
||||
if (unique.placeholderText == "[] Sight for [] units" && matchesFilter(unique.params[1]))
|
||||
visibilityRange += unique.params[0].toInt()
|
||||
|
||||
if (visibilityRange < 1) visibilityRange = 1
|
||||
|
||||
return visibilityRange
|
||||
@ -355,7 +350,7 @@ class MapUnit {
|
||||
*/
|
||||
fun updateVisibleTiles() {
|
||||
if (baseUnit.isAirUnit()) {
|
||||
viewableTiles = if (hasUnique("6 tiles in every direction always visible"))
|
||||
viewableTiles = if (hasUnique(UniqueType.SixTilesAlwaysVisible))
|
||||
getTile().getTilesInDistance(6).toList() // it's that simple
|
||||
else listOf() // bomber units don't do recon
|
||||
civInfo.updateViewableTiles() // for the civ
|
||||
@ -722,13 +717,13 @@ class MapUnit {
|
||||
if (isPreparingParadrop())
|
||||
action = null
|
||||
|
||||
if (hasUnique("Religious Unit")
|
||||
if (hasUnique(UniqueType.ReligiousUnit)
|
||||
&& getTile().getOwner() != null
|
||||
&& !getTile().getOwner()!!.isCityState()
|
||||
&& !civInfo.canPassThroughTiles(getTile().getOwner()!!)
|
||||
) {
|
||||
val lostReligiousStrength =
|
||||
getMatchingUniques("May enter foreign tiles without open borders, but loses [] religious strength each turn it ends there")
|
||||
getMatchingUniques(UniqueType.CanEnterForeignTilesButLosesReligiousStrength)
|
||||
.map { it.params[0].toInt() }
|
||||
.minOrNull()
|
||||
if (lostReligiousStrength != null)
|
||||
|
@ -287,6 +287,8 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget, val flags:
|
||||
@Deprecated("As of 3.17.5 - removed 3.18.5", ReplaceWith("[-1] Sight"), DeprecationLevel.ERROR)
|
||||
LimitedVisibility("Limited Visibility", UniqueTarget.Unit),
|
||||
|
||||
SixTilesAlwaysVisible("6 tiles in every direction always visible", UniqueTarget.Unit),
|
||||
|
||||
@Deprecated("As of 3.17.5 - removed 3.18.5", ReplaceWith("[amount]% Spread Religion Strength <for [mapUnitFilter] units>"), DeprecationLevel.ERROR)
|
||||
SpreadReligionStrengthUnits("[amount]% Spread Religion Strength for [mapUnitFilter] units", UniqueTarget.Global),
|
||||
|
||||
@ -315,6 +317,10 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget, val flags:
|
||||
CannotEnterOcean("Cannot enter ocean tiles", UniqueTarget.Unit),
|
||||
CannotEnterOceanUntilAstronomy("Cannot enter ocean tiles until Astronomy", UniqueTarget.Unit),
|
||||
CannotBeBarbarian("Never appears as a Barbarian unit", UniqueTarget.Unit, flags = listOf(UniqueFlag.HideInCivilopedia)),
|
||||
CanEnterForeignTiles("May enter foreign tiles without open borders", UniqueTarget.Unit),
|
||||
CanEnterForeignTilesButLosesReligiousStrength("May enter foreign tiles without open borders, but loses [amount] religious strength each turn it ends there", UniqueTarget.Unit),
|
||||
|
||||
ReligiousUnit("Religious Unit", UniqueTarget.Unit),
|
||||
|
||||
///////////////////////////////////////// TILE UNIQUES /////////////////////////////////////////
|
||||
|
||||
|
@ -471,7 +471,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
unit.currentMovement = 0f
|
||||
|
||||
// If this unit has special abilities that need to be kept track of, start doing so here
|
||||
if (unit.hasUnique("Religious Unit") && civInfo.gameInfo.isReligionEnabled()) {
|
||||
if (unit.hasUnique(UniqueType.ReligiousUnit) && civInfo.gameInfo.isReligionEnabled()) {
|
||||
unit.religion =
|
||||
if (unit.hasUnique("Takes your religion over the one in their birth city"))
|
||||
civInfo.religionManager.religion?.name
|
||||
@ -555,7 +555,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
"Nuclear Weapon" -> isNuclearWeapon()
|
||||
// "Great" should be deprecated, replaced by "Great Person".
|
||||
"Great Person", "Great" -> isGreatPerson()
|
||||
"Religious" -> uniques.contains("Religious Unit")
|
||||
"Religious" -> hasUnique(UniqueType.ReligiousUnit)
|
||||
else -> {
|
||||
if (getType().matchesFilter(filter)) return true
|
||||
if (
|
||||
|
Reference in New Issue
Block a user