mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-23 14:19:15 +07:00
Unify all those (isWonder || isNationalWonder) cases (#4574)
This commit is contained in:
@ -21,9 +21,9 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||||||
val civInfo = cityInfo.civInfo
|
val civInfo = cityInfo.civInfo
|
||||||
|
|
||||||
val buildableNotWonders = cityConstructions.getBuildableBuildings()
|
val buildableNotWonders = cityConstructions.getBuildableBuildings()
|
||||||
.filterNot { it.isWonder || it.isNationalWonder }
|
.filterNot { it.isAnyWonder() }
|
||||||
private val buildableWonders = cityConstructions.getBuildableBuildings()
|
private val buildableWonders = cityConstructions.getBuildableBuildings()
|
||||||
.filter { it.isWonder || it.isNationalWonder }
|
.filter { it.isAnyWonder() }
|
||||||
|
|
||||||
val civUnits = civInfo.getCivUnits()
|
val civUnits = civInfo.getCivUnits()
|
||||||
val militaryUnits = civUnits.count { !it.type.isCivilian() }
|
val militaryUnits = civUnits.count { !it.type.isCivilian() }
|
||||||
|
@ -70,7 +70,7 @@ class CityConstructions {
|
|||||||
.asSequence().filter { it.isBuildable(this) }
|
.asSequence().filter { it.isBuildable(this) }
|
||||||
|
|
||||||
fun getBasicCultureBuildings() = cityInfo.getRuleset().buildings.values
|
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
|
* @return [Stats] provided by all built buildings in city plus the bonus from Library
|
||||||
@ -179,8 +179,7 @@ class CityConstructions {
|
|||||||
val currentConstructionSnapshot = currentConstructionFromQueue
|
val currentConstructionSnapshot = currentConstructionFromQueue
|
||||||
if (currentConstructionSnapshot.isEmpty()) return FormattedLine()
|
if (currentConstructionSnapshot.isEmpty()) return FormattedLine()
|
||||||
val category = when {
|
val category = when {
|
||||||
ruleset.buildings[currentConstructionSnapshot]
|
ruleset.buildings[currentConstructionSnapshot]?.isAnyWonder() == true ->
|
||||||
?.let{ it.isWonder || it.isNationalWonder } == true ->
|
|
||||||
CivilopediaCategories.Wonder.name
|
CivilopediaCategories.Wonder.name
|
||||||
currentConstructionSnapshot in ruleset.buildings ->
|
currentConstructionSnapshot in ruleset.buildings ->
|
||||||
CivilopediaCategories.Building.name
|
CivilopediaCategories.Building.name
|
||||||
|
@ -306,7 +306,7 @@ class CityStats {
|
|||||||
// Since this is sometimes run from a different thread (getConstructionButtonDTOs),
|
// Since this is sometimes run from a different thread (getConstructionButtonDTOs),
|
||||||
// this helps mitigate concurrency problems.
|
// 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" }) {
|
for (unique in uniques.filter { it.placeholderText == "+[]% Production when constructing [] buildings" }) {
|
||||||
val stat = Stat.valueOf(unique.params[1])
|
val stat = Stat.valueOf(unique.params[1])
|
||||||
if (currentConstruction.isStatRelated(stat))
|
if (currentConstruction.isStatRelated(stat))
|
||||||
|
@ -48,6 +48,7 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
|
|||||||
private var hurryCostModifier = 0
|
private var hurryCostModifier = 0
|
||||||
var isWonder = false
|
var isWonder = false
|
||||||
var isNationalWonder = false
|
var isNationalWonder = false
|
||||||
|
fun isAnyWonder() = isWonder || isNationalWonder
|
||||||
var requiredBuilding: String? = null
|
var requiredBuilding: String? = null
|
||||||
var requiredBuildingInAllCities: String? = null
|
var requiredBuildingInAllCities: String? = null
|
||||||
|
|
||||||
@ -195,7 +196,7 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
|
|||||||
return stats
|
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 getCivilopediaTextHeader() = FormattedLine(name, header=2, icon=makeLink())
|
||||||
override fun hasCivilopediaTextLines() = true
|
override fun hasCivilopediaTextLines() = true
|
||||||
override fun replacesCivilopediaDescription() = true
|
override fun replacesCivilopediaDescription() = true
|
||||||
@ -204,7 +205,7 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
|
|||||||
|
|
||||||
val textList = ArrayList<FormattedLine>()
|
val textList = ArrayList<FormattedLine>()
|
||||||
|
|
||||||
if (isWonder || isNationalWonder) {
|
if (isAnyWonder()) {
|
||||||
textList += FormattedLine( if (isWonder) "Wonder" else "National Wonder", color="#CA4", header=3 )
|
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 {
|
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) {
|
return when (filter) {
|
||||||
"All" -> true
|
"All" -> true
|
||||||
name -> true
|
name -> true
|
||||||
"Building", "Buildings" -> !(isWonder || isNationalWonder)
|
"Building", "Buildings" -> !isAnyWonder()
|
||||||
"Wonder", "Wonders" -> isWonder || isNationalWonder
|
"Wonder", "Wonders" -> isAnyWonder()
|
||||||
replaces -> true
|
replaces -> true
|
||||||
else -> {
|
else -> {
|
||||||
if (uniques.contains(filter)) return true
|
if (uniques.contains(filter)) return true
|
||||||
@ -609,7 +610,7 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
|
|||||||
return ruleset.tileImprovements[improvementUnique.params[0]]
|
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> {
|
override fun getResourceRequirements(): HashMap<String, Int> {
|
||||||
val resourceRequirements = HashMap<String, Int>()
|
val resourceRequirements = HashMap<String, Int>()
|
||||||
|
@ -221,7 +221,7 @@ class Ruleset {
|
|||||||
if (building.cost == 0) {
|
if (building.cost == 0) {
|
||||||
val column = technologies[building.requiredTech]?.column
|
val column = technologies[building.requiredTech]?.column
|
||||||
?: throw UncivShowableException("Building (${building.name}) must either have an explicit cost or reference an existing tech")
|
?: 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ class Technology {
|
|||||||
val enabledBuildings = getEnabledBuildings(viewingCiv)
|
val enabledBuildings = getEnabledBuildings(viewingCiv)
|
||||||
|
|
||||||
val regularBuildings = enabledBuildings.filter {
|
val regularBuildings = enabledBuildings.filter {
|
||||||
!it.isWonder && !it.isNationalWonder
|
!it.isAnyWonder()
|
||||||
&& "Will not be displayed in Civilopedia" !in it.uniques
|
&& "Will not be displayed in Civilopedia" !in it.uniques
|
||||||
&& !(!viewingCiv.gameInfo.hasReligionEnabled() && it.uniques.contains("Hidden when religion is disabled"))
|
&& !(!viewingCiv.gameInfo.hasReligionEnabled() && it.uniques.contains("Hidden when religion is disabled"))
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ class Technology {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val wonders = enabledBuildings.filter {
|
val wonders = enabledBuildings.filter {
|
||||||
(it.isWonder || it.isNationalWonder)
|
it.isAnyWonder()
|
||||||
&& "Will not be displayed in Civilopedia" !in it.uniques
|
&& "Will not be displayed in Civilopedia" !in it.uniques
|
||||||
}
|
}
|
||||||
if (wonders.isNotEmpty()) {
|
if (wonders.isNotEmpty()) {
|
||||||
|
@ -103,7 +103,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
|
|||||||
|
|
||||||
for (building in cityInfo.cityConstructions.getBuiltBuildings()) {
|
for (building in cityInfo.cityConstructions.getBuiltBuildings()) {
|
||||||
when {
|
when {
|
||||||
building.isWonder || building.isNationalWonder -> wonders.add(building)
|
building.isAnyWonder() -> wonders.add(building)
|
||||||
!building.newSpecialists().isEmpty() -> specialistBuildings.add(building)
|
!building.newSpecialists().isEmpty() -> specialistBuildings.add(building)
|
||||||
else -> otherBuildings.add(building)
|
else -> otherBuildings.add(building)
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ class CivilopediaScreen(
|
|||||||
.filter { "Will not be displayed in Civilopedia" !in it.uniques
|
.filter { "Will not be displayed in Civilopedia" !in it.uniques
|
||||||
&& !(hideReligionItems && "Hidden when religion is disabled" in it.uniques)
|
&& !(hideReligionItems && "Hidden when religion is disabled" in it.uniques)
|
||||||
&& !(noCulturalVictory && "Hidden when cultural victory is disabled" in it.uniques)
|
&& !(noCulturalVictory && "Hidden when cultural victory is disabled" in it.uniques)
|
||||||
&& !(it.isWonder || it.isNationalWonder) }
|
&& !it.isAnyWonder() }
|
||||||
.map {
|
.map {
|
||||||
CivilopediaEntry(
|
CivilopediaEntry(
|
||||||
it.name,
|
it.name,
|
||||||
@ -187,7 +187,7 @@ class CivilopediaScreen(
|
|||||||
.filter { "Will not be displayed in Civilopedia" !in it.uniques
|
.filter { "Will not be displayed in Civilopedia" !in it.uniques
|
||||||
&& !(hideReligionItems && "Hidden when religion is disabled" in it.uniques)
|
&& !(hideReligionItems && "Hidden when religion is disabled" in it.uniques)
|
||||||
&& !(noCulturalVictory && "Hidden when cultural victory is disabled" in it.uniques)
|
&& !(noCulturalVictory && "Hidden when cultural victory is disabled" in it.uniques)
|
||||||
&& (it.isWonder || it.isNationalWonder) }
|
&& it.isAnyWonder() }
|
||||||
.map {
|
.map {
|
||||||
CivilopediaEntry(
|
CivilopediaEntry(
|
||||||
it.name,
|
it.name,
|
||||||
|
@ -377,7 +377,7 @@ object UnitActions {
|
|||||||
else {
|
else {
|
||||||
val currentConstruction = tile.getCity()!!.cityConstructions.getCurrentConstruction()
|
val currentConstruction = tile.getCity()!!.cityConstructions.getCurrentConstruction()
|
||||||
if (currentConstruction !is Building) false
|
if (currentConstruction !is Building) false
|
||||||
else currentConstruction.isWonder || currentConstruction.isNationalWonder
|
else currentConstruction.isAnyWonder()
|
||||||
}
|
}
|
||||||
actionList += UnitAction(UnitActionType.HurryWonder,
|
actionList += UnitAction(UnitActionType.HurryWonder,
|
||||||
uncivSound = UncivSound.Chimes,
|
uncivSound = UncivSound.Chimes,
|
||||||
|
Reference in New Issue
Block a user