Bugfixes from unitTypes so promotions work again (#4744)

This commit is contained in:
Xander Lenstra
2021-08-04 12:55:12 +02:00
committed by GitHub
parent c1382477e0
commit 2c428f8269
5 changed files with 28 additions and 28 deletions

View File

@ -214,20 +214,6 @@ ImprovementIcons/Quarry
orig: 100, 100 orig: 100, 100
offset: 0, 0 offset: 0, 0
index: -1 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 ImprovementIcons/Road
rotate: false rotate: false
xy: 1832, 1400 xy: 1832, 1400
@ -2167,6 +2153,20 @@ TileSets/Default/OasisOverlay
orig: 100, 100 orig: 100, 100
offset: 0, 0 offset: 0, 0
index: -1 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 TileSets/Default/Road
rotate: false rotate: false
xy: 190, 565 xy: 190, 565

View File

@ -118,6 +118,6 @@
}, },
{ {
"name": "AtomicBomber", "name": "AtomicBomber",
"Domain": "Air" "movementType": "Air"
} }
] ]

View File

@ -46,7 +46,7 @@ class UnitPromotions{
fun getAvailablePromotions(): List<Promotion> { fun getAvailablePromotions(): List<Promotion> {
return unit.civInfo.gameInfo.ruleSet.unitPromotions.values 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 } } .filter { it.prerequisites.isEmpty() || it.prerequisites.any { p->p in promotions } }
} }

View File

@ -16,23 +16,24 @@ enum class UnitMovementType { // The types of tiles the unit can by default ente
Air // Only city tiles and carrying units Air // Only city tiles and carrying units
} }
class UnitType( class UnitType() : INamed {
val movementType: String? = null
) : INamed {
override lateinit var name: String 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) } } 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.name = name
this.movementType = domain
} }
fun getMovementType() = if (movementType == null) null else UnitMovementType.valueOf(movementType) fun getMovementType() = unitMovementType
fun isLandUnit() = getMovementType() == UnitMovementType.Land fun isLandUnit() = unitMovementType == UnitMovementType.Land
fun isWaterUnit() = getMovementType() == UnitMovementType.Water fun isWaterUnit() = unitMovementType == UnitMovementType.Water
fun isAirUnit() = getMovementType() == UnitMovementType.Air fun isAirUnit() = unitMovementType == UnitMovementType.Air
fun matchesFilter(filter: String): Boolean { fun matchesFilter(filter: String): Boolean {
return when (filter) { return when (filter) {
@ -40,8 +41,7 @@ class UnitType(
"Water" -> isWaterUnit() "Water" -> isWaterUnit()
"Air" -> isAirUnit() "Air" -> isAirUnit()
else -> { else -> {
if (uniques.contains(filter)) true uniques.contains(filter)
else false
} }
} }
} }

View File

@ -47,7 +47,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
val unitType = unit.type val unitType = unit.type
val promotionsForUnitType = unit.civInfo.gameInfo.ruleSet.unitPromotions.values.filter { 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) } || unit.promotions.promotions.contains(it.name) }
val unitAvailablePromotions = unit.promotions.getAvailablePromotions() val unitAvailablePromotions = unit.promotions.getAvailablePromotions()