Legalism grants enqueued buildings (#1906)

This commit is contained in:
Federico Luongo 2020-02-11 09:36:58 +01:00 committed by GitHub
parent 942092e33e
commit b9e3ca5fd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -301,14 +301,14 @@ class CityConstructions {
fun hasBuildableCultureBuilding(): Boolean {
return getBasicCultureBuildings()
.map { cityInfo.civInfo.getEquivalentBuilding(it.name) }
.filter { it.isBuildable(this) || it.name == currentConstruction}
.filter { it.isBuildable(this) || isBeingConstructedOrEnqueued(it.name) }
.any()
}
fun addCultureBuilding(): String? {
val buildableCultureBuildings = getBasicCultureBuildings()
.map { cityInfo.civInfo.getEquivalentBuilding(it.name) }
.filter { it.isBuildable(this) || it.name == currentConstruction }
.filter { it.isBuildable(this) || isBeingConstructedOrEnqueued(it.name) }
if (!buildableCultureBuildings.any())
return null
@ -316,8 +316,10 @@ class CityConstructions {
val cultureBuildingToBuild = buildableCultureBuildings.minBy { it.cost }!!.name
constructionComplete(getConstruction(cultureBuildingToBuild))
if (currentConstruction == cultureBuildingToBuild)
if (isBeingConstructed(cultureBuildingToBuild))
cancelCurrentConstruction()
else if (isEnqueued(cultureBuildingToBuild))
removeFromQueue(cultureBuildingToBuild)
return cultureBuildingToBuild
}
@ -353,6 +355,11 @@ class CityConstructions {
}
}
fun removeFromQueue(constructionName: String) {
if (constructionName in constructionQueue)
constructionQueue.remove(constructionName)
}
fun removeFromQueue(constructionQueueIndex: Int) {
// constructionQueueIndex -1 is the current construction
if (constructionQueueIndex < 0) {