mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 14:24:43 -04:00
Typed "Unbuildable"
This commit is contained in:
parent
8b2bb8e59b
commit
d4205cb405
@ -205,7 +205,7 @@ class CityConstructions {
|
||||
val turnsToConstruction = turnsToConstruction(constructionName, useStoredProduction)
|
||||
val currentProgress = if (useStoredProduction) getWorkDone(constructionName) else 0
|
||||
val lines = ArrayList<String>()
|
||||
val buildable = construction.uniques.none{ it == "Unbuildable" }
|
||||
val buildable = construction.uniqueObjects.none{ it.isOfType(UniqueType.Unbuildable) }
|
||||
if (buildable)
|
||||
lines += (if (currentProgress == 0) "" else "$currentProgress/") +
|
||||
"$cost${Fonts.production} $turnsToConstruction${Fonts.turn}"
|
||||
|
@ -2,6 +2,7 @@ package com.unciv.logic.city
|
||||
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.ruleset.IHasUniques
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.stats.INamed
|
||||
import com.unciv.models.stats.Stat
|
||||
import com.unciv.ui.utils.Fonts
|
||||
@ -27,7 +28,7 @@ interface INonPerpetualConstruction : IConstruction, INamed, IHasUniques {
|
||||
fun canBePurchasedWithStat(cityInfo: CityInfo?, stat: Stat): Boolean {
|
||||
if (stat in listOf(Stat.Production, Stat.Happiness)) return false
|
||||
if ("Cannot be purchased" in uniques) return false
|
||||
if (stat == Stat.Gold) return !uniques.contains("Unbuildable")
|
||||
if (stat == Stat.Gold) return !hasUnique(UniqueType.Unbuildable)
|
||||
// Can be purchased with [Stat] [cityFilter]
|
||||
if (getMatchingUniques("Can be purchased with [] []")
|
||||
.any { it.params[0] == stat.name && (cityInfo != null && cityInfo.matchesFilter(it.params[1])) }
|
||||
|
@ -107,7 +107,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
private fun getUniquesStringsWithoutDisablers() = getUniquesStrings()
|
||||
.filterNot {
|
||||
it.startsWith("Hidden ") && it.endsWith(" disabled") ||
|
||||
it == "Unbuildable" ||
|
||||
it == UniqueType.Unbuildable.text ||
|
||||
it == Constants.hideFromCivilopediaUnique
|
||||
}
|
||||
|
||||
@ -403,7 +403,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
rejectionReasons.add(RejectionReason.AlreadyBuilt)
|
||||
// for buildings that are created as side effects of other things, and not directly built,
|
||||
// or for buildings that can only be bought
|
||||
if (uniques.contains("Unbuildable"))
|
||||
if (hasUnique(UniqueType.Unbuildable))
|
||||
rejectionReasons.add(RejectionReason.Unbuildable)
|
||||
|
||||
for (unique in uniqueObjects) {
|
||||
@ -467,7 +467,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
if (civInfo.tech.isResearched(unique.params[0]))
|
||||
rejectionReasons.add(RejectionReason.Obsoleted.apply { errorMessage = unique.text })
|
||||
|
||||
"Hidden when religion is disabled" ->
|
||||
UniqueType.HiddenWithoutReligion.text ->
|
||||
if (!civInfo.gameInfo.isReligionEnabled())
|
||||
rejectionReasons.add(RejectionReason.DisabledBySetting)
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ class Ruleset {
|
||||
* */
|
||||
fun updateBuildingCosts() {
|
||||
for (building in buildings.values) {
|
||||
if (building.cost == 0 && !building.uniques.contains("Unbuildable")) {
|
||||
if (building.cost == 0 && !building.hasUnique(UniqueType.Unbuildable)) {
|
||||
val column = technologies[building.requiredTech]?.column
|
||||
?: throw UncivShowableException("Building (${building.name}) is buildable and therefore must either have an explicit cost or reference an existing tech")
|
||||
building.cost = if (building.isAnyWonder()) column.wonderCost else column.buildingCost
|
||||
@ -393,7 +393,7 @@ class Ruleset {
|
||||
}
|
||||
|
||||
for (building in buildings.values) {
|
||||
if (building.requiredTech == null && building.cost == 0 && !building.uniques.contains("Unbuildable"))
|
||||
if (building.requiredTech == null && building.cost == 0 && !building.hasUnique(UniqueType.Unbuildable))
|
||||
lines += "${building.name} is buildable and therefore must either have an explicit cost or reference an existing tech!"
|
||||
|
||||
checkUniques(building, lines, UniqueType.UniqueComplianceErrorSeverity.RulesetInvariant)
|
||||
|
@ -138,6 +138,12 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
|
||||
MayanGainGreatPerson("Receive a free Great Person at the end of every [comment] (every 394 years), after researching [tech]. Each bonus person can only be chosen once.", UniqueTarget.Nation),
|
||||
MayanCalendarDisplay("Once The Long Count activates, the year on the world screen displays as the traditional Mayan Long Count.", UniqueTarget.Nation),
|
||||
|
||||
///////////////////////////////////////// BUILDING UNIQUES /////////////////////////////////////////
|
||||
|
||||
Unbuildable("Unbuildable", UniqueTarget.Building),
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////// UNIT UNIQUES /////////////////////////////////////////
|
||||
|
||||
FoundCity("Founds a new city", UniqueTarget.Unit),
|
||||
|
@ -90,7 +90,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
|
||||
if (replacementTextForUniques != "") lines += replacementTextForUniques
|
||||
else for (unique in uniques.filterNot {
|
||||
it.startsWith("Hidden ") && it.endsWith(" disabled") || it == "Unbuildable"
|
||||
it.startsWith("Hidden ") && it.endsWith(" disabled") || it == UniqueType.Unbuildable.text
|
||||
})
|
||||
lines += unique.tr()
|
||||
|
||||
@ -382,7 +382,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
val rejectionReasons = RejectionReasons()
|
||||
val ruleSet = civInfo.gameInfo.ruleSet
|
||||
|
||||
if (uniques.contains("Unbuildable"))
|
||||
if (hasUnique(UniqueType.Unbuildable))
|
||||
rejectionReasons.add(RejectionReason.Unbuildable)
|
||||
|
||||
if (requiredTech != null && !civInfo.tech.isResearched(requiredTech!!))
|
||||
|
Loading…
x
Reference in New Issue
Block a user