mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-04 16:11:46 +07:00
Typed denmarks unique and generalized it (#6463)
* Typed denmarks unique and generalized it * Added support for deprecated unique
This commit is contained in:
parent
90a172ab02
commit
72b4d2069e
@ -689,7 +689,7 @@
|
||||
"innerColor": [255,255,102],
|
||||
"favoredReligion": "Christianity",
|
||||
"uniqueName": "Viking Fury",
|
||||
"uniques": ["[+1] Movement <for [Embarked] units>", "Units pay only 1 movement point to disembark",
|
||||
"uniques": ["[+1] Movement <for [Embarked] units>", "[1] Movement point cost to disembark <for [All] units>",
|
||||
"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",
|
||||
|
@ -662,7 +662,7 @@
|
||||
"outerColor": [51,25,0],
|
||||
"innerColor": [255,255,102],
|
||||
"uniqueName": "Viking Fury",
|
||||
"uniques": ["[+1] Movement <for [Embarked] units>", "Units pay only 1 movement point to disembark",
|
||||
"uniques": ["[+1] Movement <for [Embarked] units>", "[1] Movement point cost to disembark <for [All] units>",
|
||||
"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",
|
||||
|
@ -107,6 +107,12 @@ class MapUnit {
|
||||
|
||||
@Transient
|
||||
var canEnterForeignTerrain: Boolean = false
|
||||
|
||||
@Transient
|
||||
var costToDisembark: Float? = null
|
||||
|
||||
@Transient
|
||||
var costToEmbark: Float? = null
|
||||
|
||||
@Transient
|
||||
var paradropRange = 0
|
||||
@ -261,7 +267,7 @@ class MapUnit {
|
||||
fun getMatchingUniques(
|
||||
uniqueType: UniqueType,
|
||||
stateForConditionals: StateForConditionals = StateForConditionals(civInfo, unit=this),
|
||||
checkCivInfoUniques:Boolean = false
|
||||
checkCivInfoUniques: Boolean = false
|
||||
) = sequence {
|
||||
val tempUniques = tempUniquesMap[uniqueType]
|
||||
if (tempUniques != null)
|
||||
@ -326,6 +332,13 @@ class MapUnit {
|
||||
.none { it.value != DoubleMovementTerrainTarget.Feature }
|
||||
noFilteredDoubleMovementUniques = doubleMovementInTerrain
|
||||
.none { it.value == DoubleMovementTerrainTarget.Filter }
|
||||
costToDisembark = (getMatchingUniques(UniqueType.ReducedDisembarkCost, checkCivInfoUniques = true)
|
||||
// Deprecated as of 4.0.3
|
||||
+ getMatchingUniques(UniqueType.DisembarkCostDeprecated, checkCivInfoUniques = true)
|
||||
//
|
||||
).minOfOrNull { it.params[0].toFloat() }
|
||||
costToEmbark = getMatchingUniques(UniqueType.ReducedEmbarkCost, checkCivInfoUniques = true)
|
||||
.minOfOrNull { it.params[0].toFloat() }
|
||||
|
||||
//todo: consider parameterizing [terrainFilter] in some of the following:
|
||||
canEnterIceTiles = hasUnique(UniqueType.CanEnterIceTiles)
|
||||
|
@ -7,7 +7,7 @@ import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.helpers.UnitMovementMemoryType
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
|
||||
class UnitMovementAlgorithms(val unit:MapUnit) {
|
||||
class UnitMovementAlgorithms(val unit: MapUnit) {
|
||||
|
||||
// This function is called ALL THE TIME and should be as time-optimal as possible!
|
||||
private fun getMovementCostBetweenAdjacentTiles(
|
||||
@ -18,8 +18,8 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
||||
): Float {
|
||||
|
||||
if (from.isLand != to.isLand && unit.baseUnit.isLandUnit())
|
||||
return if (unit.civInfo.nation.disembarkCosts1 && from.isWater && to.isLand) 1f
|
||||
else 100f // this is embarkment or disembarkment, and will take the entire turn
|
||||
return if (from.isWater && to.isLand) unit.costToDisembark ?: 100f
|
||||
else unit.costToEmbark ?: 100f
|
||||
|
||||
// If the movement is affected by a Zone of Control, all movement points are expended
|
||||
if (considerZoneOfControl && isMovementAffectedByZoneOfControl(from, to, civInfo))
|
||||
@ -40,7 +40,10 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
||||
if (from.roadStatus == RoadStatus.Railroad && to.roadStatus == RoadStatus.Railroad)
|
||||
return RoadStatus.Railroad.movement + extraCost
|
||||
|
||||
// Each of these two function calls `hasUnique(UniqueType.CityStateTerritoryAlwaysFriendly)`
|
||||
// when entering territory of a city state
|
||||
val areConnectedByRoad = from.hasConnection(civInfo) && to.hasConnection(civInfo)
|
||||
|
||||
val areConnectedByRiver = from.isAdjacentToRiver() && to.isAdjacentToRiver() && from.isConnectedByRiver(to)
|
||||
|
||||
if (areConnectedByRoad && (!areConnectedByRiver || civInfo.tech.roadsConnectAcrossRivers))
|
||||
|
@ -78,9 +78,6 @@ class Nation : RulesetObject() {
|
||||
@Transient
|
||||
var ignoreHillMovementCost = false
|
||||
|
||||
@Transient
|
||||
var disembarkCosts1 = false
|
||||
|
||||
fun setTransients() {
|
||||
outerColorObject = colorFromRGB(outerColor)
|
||||
|
||||
@ -89,7 +86,6 @@ class Nation : RulesetObject() {
|
||||
|
||||
forestsAndJunglesAreRoads = uniques.contains("All units move through Forest and Jungle Tiles in friendly territory as if they have roads. These tiles can be used to establish City Connections upon researching the Wheel.")
|
||||
ignoreHillMovementCost = uniques.contains("Units ignore terrain costs when moving into any tile with Hills")
|
||||
disembarkCosts1 = uniques.contains("Units pay only 1 movement point to disembark")
|
||||
}
|
||||
|
||||
var cities: ArrayList<String> = arrayListOf()
|
||||
|
@ -488,6 +488,10 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
CannotEnterOcean("Cannot enter ocean tiles", UniqueTarget.Unit),
|
||||
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),
|
||||
ReducedDisembarkCost("[amount] Movement point cost to disembark", UniqueTarget.Global, UniqueTarget.Unit),
|
||||
ReducedEmbarkCost("[amount] Movement point cost to embark", UniqueTarget.Global, UniqueTarget.Unit),
|
||||
@Deprecated("as of 4.0.3", ReplaceWith("[1] Movement point cost to disembark <for [All] units>"))
|
||||
DisembarkCostDeprecated("Units pay only 1 movement point to disembark", UniqueTarget.Global),
|
||||
|
||||
CannotBeBarbarian("Never appears as a Barbarian unit", UniqueTarget.Unit, flags = UniqueFlag.setOfHiddenToUsers),
|
||||
|
||||
|
@ -751,6 +751,16 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
|
||||
|
||||
Applicable to: Global, Unit
|
||||
|
||||
??? example "[amount] Movement point cost to disembark"
|
||||
Example: "[20] Movement point cost to disembark"
|
||||
|
||||
Applicable to: Global, Unit
|
||||
|
||||
??? example "[amount] Movement point cost to embark"
|
||||
Example: "[20] Movement point cost to embark"
|
||||
|
||||
Applicable to: Global, Unit
|
||||
|
||||
??? example "This Unit upgrades for free"
|
||||
Applicable to: Global
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user