mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-31 07:09:26 +07:00
Chore - typified unit uniques
This commit is contained in:
@ -199,8 +199,8 @@ object BattleDamage {
|
||||
|
||||
if (defender.unit.isEmbarked()) {
|
||||
// embarked units get no defensive modifiers apart from this unique
|
||||
if (defender.unit.hasUnique("Defense bonus when embarked") ||
|
||||
defender.getCivInfo().hasUnique("Embarked units can defend themselves")
|
||||
if (defender.unit.hasUnique(UniqueType.DefenceBonusWhenEmbarked) ||
|
||||
defender.getCivInfo().hasUnique(UniqueType.DefenceBonusWhenEmbarkedCivwide)
|
||||
)
|
||||
modifiers["Embarked"] = 100
|
||||
|
||||
@ -210,8 +210,8 @@ object BattleDamage {
|
||||
modifiers.putAll(getTileSpecificModifiers(defender, tile))
|
||||
|
||||
val tileDefenceBonus = tile.getDefensiveBonus()
|
||||
if (!defender.unit.hasUnique("No defensive terrain bonus") && tileDefenceBonus > 0
|
||||
|| !defender.unit.hasUnique("No defensive terrain penalty") && tileDefenceBonus < 0
|
||||
if (!defender.unit.hasUnique(UniqueType.NoDefensiveTerrainBonus) && tileDefenceBonus > 0
|
||||
|| !defender.unit.hasUnique(UniqueType.NoDefensiveTerrainPenalty) && tileDefenceBonus < 0
|
||||
)
|
||||
modifiers["Tile"] = (tileDefenceBonus * 100).toInt()
|
||||
|
||||
|
@ -458,7 +458,7 @@ class MapUnit {
|
||||
fun getRange(): Int {
|
||||
if (baseUnit.isMelee()) return 1
|
||||
var range = baseUnit().range
|
||||
range += getMatchingUniques("[] Range").sumOf { it.params[0].toInt() }
|
||||
range += getMatchingUniques(UniqueType.Range).sumOf { it.params[0].toInt() }
|
||||
return range
|
||||
}
|
||||
|
||||
@ -472,9 +472,9 @@ class MapUnit {
|
||||
}
|
||||
|
||||
fun isInvisible(to: CivilizationInfo): Boolean {
|
||||
if (hasUnique("Invisible to others"))
|
||||
if (hasUnique(UniqueType.Invisible))
|
||||
return true
|
||||
if (hasUnique("Invisible to non-adjacent units"))
|
||||
if (hasUnique(UniqueType.InvisibleToNonAdjacent))
|
||||
return getTile().getTilesInDistance(1).none {
|
||||
it.getOwner() == to || it.getUnits().any { unit -> unit.owner == to.civName }
|
||||
}
|
||||
@ -533,7 +533,7 @@ class MapUnit {
|
||||
if (isCivilian()) return false
|
||||
if (baseUnit.movesLikeAirUnits()) return false
|
||||
if (isEmbarked()) return false
|
||||
if (hasUnique("No defensive terrain bonus")) return false
|
||||
if (hasUnique(UniqueType.NoDefensiveTerrainBonus)) return false
|
||||
if (isFortified()) return false
|
||||
return true
|
||||
}
|
||||
|
@ -232,16 +232,21 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget, val flags:
|
||||
|
||||
Movement("[amount] Movement", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
Sight("[amount] Sight", UniqueTarget.Unit, UniqueTarget.Global, UniqueTarget.Terrain),
|
||||
Range("[amount] Range", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
SpreadReligionStrength("[amount]% Spread Religion Strength", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
MayFoundReligion("May found a religion", UniqueTarget.Unit),
|
||||
MayEnhanceReligion("May enhance a religion", UniqueTarget.Unit),
|
||||
NormalVisionWhenEmbarked("Normal vision when embarked", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
CannotAttack("Cannot attack", UniqueTarget.Unit),
|
||||
MustSetUp("Must set up to ranged attack", UniqueTarget.Unit),
|
||||
NoDefensiveTerrainBonus("No defensive terrain bonus", UniqueTarget.Unit),
|
||||
NoDefensiveTerrainPenalty("No defensive terrain penalty", UniqueTarget.Unit),
|
||||
|
||||
NormalVisionWhenEmbarked("Normal vision when embarked", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
DefenceBonusWhenEmbarked("Defense bonus when embarked", UniqueTarget.Unit),
|
||||
DefenceBonusWhenEmbarkedCivwide("Embarked units can defend themselves", UniqueTarget.Global),
|
||||
|
||||
SixTilesAlwaysVisible("6 tiles in every direction always visible", UniqueTarget.Unit),
|
||||
|
||||
|
||||
BlastRadius("Blast radius [amount]", UniqueTarget.Unit),
|
||||
|
||||
CarryAirUnits("Can carry [amount] [mapUnitFilter] units", UniqueTarget.Unit),
|
||||
@ -257,7 +262,10 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget, val flags:
|
||||
|
||||
FlatXPGain("[amount] XP gained from combat", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
PercentageXPGain("[amount]% XP gained from combat", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
|
||||
|
||||
Invisible("Invisible to others", UniqueTarget.Unit),
|
||||
InvisibleToNonAdjacent("Invisible to non-adjacent units", UniqueTarget.Unit),
|
||||
|
||||
// The following block gets cached in MapUnit for faster getMovementCostBetweenAdjacentTiles
|
||||
DoubleMovementOnTerrain("Double movement in [terrainFilter]", UniqueTarget.Unit),
|
||||
AllTilesCost1Move("All tiles cost 1 movement", UniqueTarget.Unit),
|
||||
|
Reference in New Issue
Block a user