Unify all those (isWonder || isNationalWonder) cases (#4574)

This commit is contained in:
SomeTroglodyte
2021-07-20 08:26:06 +02:00
committed by GitHub
parent 05adc04a71
commit 1b397f0583
9 changed files with 19 additions and 19 deletions

View File

@ -21,9 +21,9 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
val civInfo = cityInfo.civInfo
val buildableNotWonders = cityConstructions.getBuildableBuildings()
.filterNot { it.isWonder || it.isNationalWonder }
.filterNot { it.isAnyWonder() }
private val buildableWonders = cityConstructions.getBuildableBuildings()
.filter { it.isWonder || it.isNationalWonder }
.filter { it.isAnyWonder() }
val civUnits = civInfo.getCivUnits()
val militaryUnits = civUnits.count { !it.type.isCivilian() }

View File

@ -70,7 +70,7 @@ class CityConstructions {
.asSequence().filter { it.isBuildable(this) }
fun getBasicCultureBuildings() = cityInfo.getRuleset().buildings.values
.asSequence().filter { it.culture > 0f && !it.isWonder && !it.isNationalWonder && it.replaces == null }
.asSequence().filter { it.culture > 0f && !it.isAnyWonder() && it.replaces == null }
/**
* @return [Stats] provided by all built buildings in city plus the bonus from Library
@ -179,8 +179,7 @@ class CityConstructions {
val currentConstructionSnapshot = currentConstructionFromQueue
if (currentConstructionSnapshot.isEmpty()) return FormattedLine()
val category = when {
ruleset.buildings[currentConstructionSnapshot]
?.let{ it.isWonder || it.isNationalWonder } == true ->
ruleset.buildings[currentConstructionSnapshot]?.isAnyWonder() == true ->
CivilopediaCategories.Wonder.name
currentConstructionSnapshot in ruleset.buildings ->
CivilopediaCategories.Building.name

View File

@ -306,7 +306,7 @@ class CityStats {
// Since this is sometimes run from a different thread (getConstructionButtonDTOs),
// this helps mitigate concurrency problems.
if (currentConstruction is Building && !currentConstruction.isWonder && !currentConstruction.isNationalWonder)
if (currentConstruction is Building && !currentConstruction.isAnyWonder())
for (unique in uniques.filter { it.placeholderText == "+[]% Production when constructing [] buildings" }) {
val stat = Stat.valueOf(unique.params[1])
if (currentConstruction.isStatRelated(stat))

View File

@ -48,6 +48,7 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
private var hurryCostModifier = 0
var isWonder = false
var isNationalWonder = false
fun isAnyWonder() = isWonder || isNationalWonder
var requiredBuilding: String? = null
var requiredBuildingInAllCities: String? = null
@ -195,7 +196,7 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
return stats
}
fun makeLink() = if (isWonder || isNationalWonder) "Wonder/$name" else "Building/$name"
fun makeLink() = if (isAnyWonder()) "Wonder/$name" else "Building/$name"
override fun getCivilopediaTextHeader() = FormattedLine(name, header=2, icon=makeLink())
override fun hasCivilopediaTextLines() = true
override fun replacesCivilopediaDescription() = true
@ -204,7 +205,7 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
val textList = ArrayList<FormattedLine>()
if (isWonder || isNationalWonder) {
if (isAnyWonder()) {
textList += FormattedLine( if (isWonder) "Wonder" else "National Wonder", color="#CA4", header=3 )
}
@ -321,7 +322,7 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
override fun canBePurchased(): Boolean {
return !isWonder && !isNationalWonder && "Cannot be purchased" !in uniques
return !isAnyWonder() && "Cannot be purchased" !in uniques
}
@ -580,8 +581,8 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
return when (filter) {
"All" -> true
name -> true
"Building", "Buildings" -> !(isWonder || isNationalWonder)
"Wonder", "Wonders" -> isWonder || isNationalWonder
"Building", "Buildings" -> !isAnyWonder()
"Wonder", "Wonders" -> isAnyWonder()
replaces -> true
else -> {
if (uniques.contains(filter)) return true
@ -609,7 +610,7 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
return ruleset.tileImprovements[improvementUnique.params[0]]
}
fun isSellable() = !isWonder && !isNationalWonder && !uniques.contains("Unsellable")
fun isSellable() = !isAnyWonder() && !uniques.contains("Unsellable")
override fun getResourceRequirements(): HashMap<String, Int> {
val resourceRequirements = HashMap<String, Int>()

View File

@ -221,7 +221,7 @@ class Ruleset {
if (building.cost == 0) {
val column = technologies[building.requiredTech]?.column
?: throw UncivShowableException("Building (${building.name}) must either have an explicit cost or reference an existing tech")
building.cost = if (building.isWonder || building.isNationalWonder) column.wonderCost else column.buildingCost
building.cost = if (building.isAnyWonder()) column.wonderCost else column.buildingCost
}
}
}

View File

@ -45,7 +45,7 @@ class Technology {
val enabledBuildings = getEnabledBuildings(viewingCiv)
val regularBuildings = enabledBuildings.filter {
!it.isWonder && !it.isNationalWonder
!it.isAnyWonder()
&& "Will not be displayed in Civilopedia" !in it.uniques
&& !(!viewingCiv.gameInfo.hasReligionEnabled() && it.uniques.contains("Hidden when religion is disabled"))
}
@ -56,7 +56,7 @@ class Technology {
}
val wonders = enabledBuildings.filter {
(it.isWonder || it.isNationalWonder)
it.isAnyWonder()
&& "Will not be displayed in Civilopedia" !in it.uniques
}
if (wonders.isNotEmpty()) {

View File

@ -103,7 +103,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
for (building in cityInfo.cityConstructions.getBuiltBuildings()) {
when {
building.isWonder || building.isNationalWonder -> wonders.add(building)
building.isAnyWonder() -> wonders.add(building)
!building.newSpecialists().isEmpty() -> specialistBuildings.add(building)
else -> otherBuildings.add(building)
}

View File

@ -174,7 +174,7 @@ class CivilopediaScreen(
.filter { "Will not be displayed in Civilopedia" !in it.uniques
&& !(hideReligionItems && "Hidden when religion is disabled" in it.uniques)
&& !(noCulturalVictory && "Hidden when cultural victory is disabled" in it.uniques)
&& !(it.isWonder || it.isNationalWonder) }
&& !it.isAnyWonder() }
.map {
CivilopediaEntry(
it.name,
@ -187,7 +187,7 @@ class CivilopediaScreen(
.filter { "Will not be displayed in Civilopedia" !in it.uniques
&& !(hideReligionItems && "Hidden when religion is disabled" in it.uniques)
&& !(noCulturalVictory && "Hidden when cultural victory is disabled" in it.uniques)
&& (it.isWonder || it.isNationalWonder) }
&& it.isAnyWonder() }
.map {
CivilopediaEntry(
it.name,

View File

@ -377,7 +377,7 @@ object UnitActions {
else {
val currentConstruction = tile.getCity()!!.cityConstructions.getCurrentConstruction()
if (currentConstruction !is Building) false
else currentConstruction.isWonder || currentConstruction.isNationalWonder
else currentConstruction.isAnyWonder()
}
actionList += UnitAction(UnitActionType.HurryWonder,
uncivSound = UncivSound.Chimes,