mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 15:27: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)
|
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 =
|
placedUnit.religion =
|
||||||
when {
|
when {
|
||||||
placedUnit.hasUnique("Takes your religion over the one in their birth city")
|
placedUnit.hasUnique("Takes your religion over the one in their birth city")
|
||||||
|
@ -255,7 +255,7 @@ class ReligionManager {
|
|||||||
shouldChoosePantheonBelief = false
|
shouldChoosePantheonBelief = false
|
||||||
|
|
||||||
for (unit in civInfo.getCivUnits())
|
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
|
unit.religion = newReligion.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,8 +288,8 @@ class MapUnit {
|
|||||||
|
|
||||||
hasUniqueToBuildImprovements = hasUnique(UniqueType.BuildImprovements)
|
hasUniqueToBuildImprovements = hasUnique(UniqueType.BuildImprovements)
|
||||||
canEnterForeignTerrain =
|
canEnterForeignTerrain =
|
||||||
hasUnique("May enter foreign tiles without open borders, but loses [] religious strength each turn it ends there")
|
hasUnique(UniqueType.CanEnterForeignTilesButLosesReligiousStrength)
|
||||||
|| hasUnique("May enter foreign tiles without open borders")
|
|| hasUnique(UniqueType.CanEnterForeignTiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun copyStatisticsTo(newUnit: MapUnit) {
|
fun copyStatisticsTo(newUnit: MapUnit) {
|
||||||
@ -340,11 +340,6 @@ class MapUnit {
|
|||||||
visibilityRange += getMatchingUniques(UniqueType.Sight, checkCivInfoUniques = true)
|
visibilityRange += getMatchingUniques(UniqueType.Sight, checkCivInfoUniques = true)
|
||||||
.sumOf { it.params[0].toInt() }
|
.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
|
if (visibilityRange < 1) visibilityRange = 1
|
||||||
|
|
||||||
return visibilityRange
|
return visibilityRange
|
||||||
@ -355,7 +350,7 @@ class MapUnit {
|
|||||||
*/
|
*/
|
||||||
fun updateVisibleTiles() {
|
fun updateVisibleTiles() {
|
||||||
if (baseUnit.isAirUnit()) {
|
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
|
getTile().getTilesInDistance(6).toList() // it's that simple
|
||||||
else listOf() // bomber units don't do recon
|
else listOf() // bomber units don't do recon
|
||||||
civInfo.updateViewableTiles() // for the civ
|
civInfo.updateViewableTiles() // for the civ
|
||||||
@ -722,13 +717,13 @@ class MapUnit {
|
|||||||
if (isPreparingParadrop())
|
if (isPreparingParadrop())
|
||||||
action = null
|
action = null
|
||||||
|
|
||||||
if (hasUnique("Religious Unit")
|
if (hasUnique(UniqueType.ReligiousUnit)
|
||||||
&& getTile().getOwner() != null
|
&& getTile().getOwner() != null
|
||||||
&& !getTile().getOwner()!!.isCityState()
|
&& !getTile().getOwner()!!.isCityState()
|
||||||
&& !civInfo.canPassThroughTiles(getTile().getOwner()!!)
|
&& !civInfo.canPassThroughTiles(getTile().getOwner()!!)
|
||||||
) {
|
) {
|
||||||
val lostReligiousStrength =
|
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() }
|
.map { it.params[0].toInt() }
|
||||||
.minOrNull()
|
.minOrNull()
|
||||||
if (lostReligiousStrength != null)
|
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)
|
@Deprecated("As of 3.17.5 - removed 3.18.5", ReplaceWith("[-1] Sight"), DeprecationLevel.ERROR)
|
||||||
LimitedVisibility("Limited Visibility", UniqueTarget.Unit),
|
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)
|
@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),
|
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),
|
CannotEnterOcean("Cannot enter ocean tiles", UniqueTarget.Unit),
|
||||||
CannotEnterOceanUntilAstronomy("Cannot enter ocean tiles until Astronomy", UniqueTarget.Unit),
|
CannotEnterOceanUntilAstronomy("Cannot enter ocean tiles until Astronomy", UniqueTarget.Unit),
|
||||||
CannotBeBarbarian("Never appears as a Barbarian unit", UniqueTarget.Unit, flags = listOf(UniqueFlag.HideInCivilopedia)),
|
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 /////////////////////////////////////////
|
///////////////////////////////////////// TILE UNIQUES /////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -471,7 +471,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
|||||||
unit.currentMovement = 0f
|
unit.currentMovement = 0f
|
||||||
|
|
||||||
// If this unit has special abilities that need to be kept track of, start doing so here
|
// 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 =
|
unit.religion =
|
||||||
if (unit.hasUnique("Takes your religion over the one in their birth city"))
|
if (unit.hasUnique("Takes your religion over the one in their birth city"))
|
||||||
civInfo.religionManager.religion?.name
|
civInfo.religionManager.religion?.name
|
||||||
@ -555,7 +555,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
|||||||
"Nuclear Weapon" -> isNuclearWeapon()
|
"Nuclear Weapon" -> isNuclearWeapon()
|
||||||
// "Great" should be deprecated, replaced by "Great Person".
|
// "Great" should be deprecated, replaced by "Great Person".
|
||||||
"Great Person", "Great" -> isGreatPerson()
|
"Great Person", "Great" -> isGreatPerson()
|
||||||
"Religious" -> uniques.contains("Religious Unit")
|
"Religious" -> hasUnique(UniqueType.ReligiousUnit)
|
||||||
else -> {
|
else -> {
|
||||||
if (getType().matchesFilter(filter)) return true
|
if (getType().matchesFilter(filter)) return true
|
||||||
if (
|
if (
|
||||||
|
Reference in New Issue
Block a user