mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-11 11:28:03 +07:00
Bugfixes from unitTypes so promotions work again (#4744)
This commit is contained in:
parent
c1382477e0
commit
2c428f8269
@ -214,20 +214,6 @@ ImprovementIcons/Quarry
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
ImprovementIcons/Railroad
|
||||
rotate: false
|
||||
xy: 1508, 1184
|
||||
size: 100, 100
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/Default/Railroad
|
||||
rotate: false
|
||||
xy: 1508, 1184
|
||||
size: 100, 100
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
ImprovementIcons/Road
|
||||
rotate: false
|
||||
xy: 1832, 1400
|
||||
@ -2167,6 +2153,20 @@ TileSets/Default/OasisOverlay
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/Default/Railroad
|
||||
rotate: false
|
||||
xy: 1508, 1184
|
||||
size: 100, 100
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
ImprovementIcons/Railroad
|
||||
rotate: false
|
||||
xy: 1508, 1184
|
||||
size: 100, 100
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/Default/Road
|
||||
rotate: false
|
||||
xy: 190, 565
|
||||
|
@ -118,6 +118,6 @@
|
||||
},
|
||||
{
|
||||
"name": "AtomicBomber",
|
||||
"Domain": "Air"
|
||||
"movementType": "Air"
|
||||
}
|
||||
]
|
||||
|
@ -46,7 +46,7 @@ class UnitPromotions{
|
||||
|
||||
fun getAvailablePromotions(): List<Promotion> {
|
||||
return unit.civInfo.gameInfo.ruleSet.unitPromotions.values
|
||||
.filter { unit.type.toString() in it.unitTypes && it.name !in promotions }
|
||||
.filter { unit.type.name in it.unitTypes && it.name !in promotions }
|
||||
.filter { it.prerequisites.isEmpty() || it.prerequisites.any { p->p in promotions } }
|
||||
}
|
||||
|
||||
|
@ -16,23 +16,24 @@ enum class UnitMovementType { // The types of tiles the unit can by default ente
|
||||
Air // Only city tiles and carrying units
|
||||
}
|
||||
|
||||
class UnitType(
|
||||
val movementType: String? = null
|
||||
) : INamed {
|
||||
class UnitType() : INamed {
|
||||
override lateinit var name: String
|
||||
val uniques: ArrayList<String> = ArrayList()
|
||||
private var movementType: String? = null
|
||||
private val unitMovementType: UnitMovementType? by lazy { if (movementType == null) null else UnitMovementType.valueOf(movementType!!) }
|
||||
|
||||
val uniques: ArrayList<String> = ArrayList()
|
||||
val uniqueObjects: List<Unique> by lazy { uniques.map { Unique(it) } }
|
||||
|
||||
constructor(name: String, domain: String? = null) : this(domain) {
|
||||
constructor(name: String, domain: String? = null) : this() {
|
||||
this.name = name
|
||||
this.movementType = domain
|
||||
}
|
||||
|
||||
fun getMovementType() = if (movementType == null) null else UnitMovementType.valueOf(movementType)
|
||||
fun getMovementType() = unitMovementType
|
||||
|
||||
fun isLandUnit() = getMovementType() == UnitMovementType.Land
|
||||
fun isWaterUnit() = getMovementType() == UnitMovementType.Water
|
||||
fun isAirUnit() = getMovementType() == UnitMovementType.Air
|
||||
fun isLandUnit() = unitMovementType == UnitMovementType.Land
|
||||
fun isWaterUnit() = unitMovementType == UnitMovementType.Water
|
||||
fun isAirUnit() = unitMovementType == UnitMovementType.Air
|
||||
|
||||
fun matchesFilter(filter: String): Boolean {
|
||||
return when (filter) {
|
||||
@ -40,8 +41,7 @@ class UnitType(
|
||||
"Water" -> isWaterUnit()
|
||||
"Air" -> isAirUnit()
|
||||
else -> {
|
||||
if (uniques.contains(filter)) true
|
||||
else false
|
||||
uniques.contains(filter)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
||||
|
||||
val unitType = unit.type
|
||||
val promotionsForUnitType = unit.civInfo.gameInfo.ruleSet.unitPromotions.values.filter {
|
||||
it.unitTypes.contains(unitType.toString())
|
||||
it.unitTypes.contains(unitType.name)
|
||||
|| unit.promotions.promotions.contains(it.name) }
|
||||
val unitAvailablePromotions = unit.promotions.getAvailablePromotions()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user