More unit unique typing (#5952)

* There are so many of these my gosh

* Fixed, good thing we have tests :)

* Fixed
This commit is contained in:
Yair Morgenstern 2022-01-14 10:43:13 +02:00 committed by GitHub
parent aaeb4f36d8
commit 6e95a07572
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 9 deletions

View File

@ -689,7 +689,7 @@
"favoredReligion": "Christianity",
"uniqueName": "Viking Fury",
"uniques": ["[+1] Movement <for [Embarked] units>", "Units pay only 1 movement point to disembark",
"Melee units pay no movement cost to pillage"],
"No movement cost to pillage <for [Melee] units>"],
"cities": ["Copenhagen","Aarhus","Kaupang","Ribe","Viborg","Tunsberg","Roskilde","Hedeby","Oslo","Jelling","Truso",
"Bergen","Faeroerne","Reykjavik","Trondheim","Godthab","Helluland","Lillehammer","Markland","Elsinore",
"Sarpsborg","Odense","Aalborg","Stavanger","Vorbasse","Schleswig","Kristiansand","Halogaland","Randers",

View File

@ -662,7 +662,7 @@
"innerColor": [255,255,102],
"uniqueName": "Viking Fury",
"uniques": ["[+1] Movement <for [Embarked] units>", "Units pay only 1 movement point to disembark",
"Melee units pay no movement cost to pillage"],
"No movement cost to pillage <for [Melee] units>"],
"cities": ["Copenhagen","Aarhus","Kaupang","Ribe","Viborg","Tunsberg","Roskilde","Hedeby","Oslo","Jelling","Truso",
"Bergen","Faeroerne","Reykjavik","Trondheim","Godthab","Helluland","Lillehammer","Markland","Elsinore",
"Sarpsborg","Odense","Aalborg","Stavanger","Vorbasse","Schleswig","Kristiansand","Halogaland","Randers",

View File

@ -243,7 +243,7 @@ object UnitAutomation {
}
private fun tryHealUnit(unit: MapUnit): Boolean {
if (unit.baseUnit.isRanged() && unit.hasUnique("Unit will heal every turn, even if it performs an action"))
if (unit.baseUnit.isRanged() && unit.hasUnique(UniqueType.HealsEvenAfterAction))
return false // will heal anyway, and attacks don't hurt
val unitDistanceToTiles = unit.movement.getDistanceToTiles()

View File

@ -399,7 +399,7 @@ object Battle {
if (attacker is MapUnitCombatant) {
val unit = attacker.unit
unit.attacksThisTurn += 1
if (unit.hasUnique("Can move after attacking") || unit.maxAttacksPerTurn() > unit.attacksThisTurn) {
if (unit.hasUnique(UniqueType.CanMoveAfterAttacking) || unit.maxAttacksPerTurn() > unit.attacksThisTurn) {
// if it was a melee attack and we won, then the unit ALREADY got movement points deducted,
// for the movement to the enemy's tile!
// and if it's an air unit, it only has 1 movement anyway, so...

View File

@ -760,7 +760,7 @@ class MapUnit {
currentTile.neighbors.flatMap { it.getUnits() }.forEach { it.healBy(15) }
if (currentMovement == getMaxMovement().toFloat() // didn't move this turn
|| hasUnique("Unit will heal every turn, even if it performs an action")
|| hasUnique(UniqueType.HealsEvenAfterAction)
) heal()
if (action != null && health > 99)

View File

@ -310,6 +310,12 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget, val flags:
NoDefensiveTerrainPenalty("No defensive terrain penalty", UniqueTarget.Unit, UniqueTarget.Global),
Uncapturable("Uncapturable", UniqueTarget.Unit),
SelfDestructs("Self-destructs when attacking", UniqueTarget.Unit),
HealsEvenAfterAction("Unit will heal every turn, even if it performs an action", UniqueTarget.Unit),
NoMovementToPillage("No movement cost to pillage", UniqueTarget.Unit, UniqueTarget.Global),
@Deprecated("As of 3.18.17", ReplaceWith("No movement cost to pillage <for [Melee] units>"), DeprecationLevel.WARNING)
NoMovementToPillageMelee("Melee units pay no movement cost to pillage", UniqueTarget.Unit, UniqueTarget.Global),
CanMoveAfterAttacking("Can move after attacking", UniqueTarget.Unit),
MoveImmediatelyOnceBought("Can move immediately once bought", UniqueTarget.Unit),
BlastRadius("Blast radius [amount]", UniqueTarget.Unit),
HealsOutsideFriendlyTerritory("May heal outside of friendly territory", UniqueTarget.Unit, UniqueTarget.Global),

View File

@ -471,7 +471,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
?: return false // couldn't place the unit, so there's actually no unit =(
//movement penalty
if (boughtWith != null && !civInfo.gameInfo.gameParameters.godMode && !unit.hasUnique("Can move immediately once bought"))
if (boughtWith != null && !civInfo.gameInfo.gameParameters.godMode && !unit.hasUnique(UniqueType.MoveImmediatelyOnceBought))
unit.currentMovement = 0f
// If this unit has special abilities that need to be kept track of, start doing so here

View File

@ -285,9 +285,10 @@ object UnitActions {
tile.improvement = null
if (tile.resource != null) tile.getOwner()?.updateDetailedCivResources() // this might take away a resource
val freePillage = unit.hasUnique("No movement cost to pillage")
|| unit.civInfo.hasUnique("No movement cost to pillage")
|| (unit.baseUnit.isMelee() && unit.civInfo.hasUnique("Melee units pay no movement cost to pillage"))
val freePillage = unit.hasUnique(UniqueType.NoMovementToPillage)
|| unit.civInfo.hasUnique(UniqueType.NoMovementToPillage)
// Deprecated 3.18.17
|| (unit.baseUnit.isMelee() && unit.civInfo.hasUnique(UniqueType.NoMovementToPillageMelee))
if (!freePillage) unit.useMovementPoints(1f)
unit.healBy(25)