mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-30 14:48:56 +07:00
Some religion stuff (#10242)
* Enable HiddenWithoutReligion to work directly on a Tutorial * Remove religious units from Vanilla * Fix limited uses of Missionary and Prophet
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package com.unciv.models.ruleset
|
||||
|
||||
import com.unciv.models.ruleset.unique.UniqueTarget
|
||||
import com.unciv.ui.screens.civilopediascreen.FormattedLine
|
||||
|
||||
/**
|
||||
* Container for json-read "Tutorial" text, potentially decorated.
|
||||
@ -13,11 +14,12 @@ import com.unciv.models.ruleset.unique.UniqueTarget
|
||||
* @see com.unciv.models.TutorialTrigger
|
||||
*/
|
||||
class Tutorial : RulesetObject() {
|
||||
// Why does this override RulesetObject()? The only unique it overrides is `Will not be displayed in Civilopedia`,
|
||||
// so allowing it access to the full power of uniques is completely unnecessary.
|
||||
// (Also, what even would it mean for this to have uniques like "[+10]% Production"? When should it even apply.)
|
||||
// imo just having a flag for this (and maybe one if religion is disabled, but even then, that should be a ruleset choice) should suffice.
|
||||
// -xlenstra
|
||||
// Has access to the full power of uniques for:
|
||||
// * Easier integration into Civilopedia
|
||||
// * HiddenWithoutReligion, HiddenFromCivilopedia work _directly_
|
||||
// * Future expansion - other meta tests to display or not are thinkable,
|
||||
// e.g. modders may want to hide instructions until you discover the game element?
|
||||
// -SomeTrog
|
||||
override var name = "" // overridden only to have the name seen first by TranslationFileWriter
|
||||
|
||||
/** These lines will be displayed (when the Tutorial is _triggered_) one after another,
|
||||
@ -27,4 +29,10 @@ class Tutorial : RulesetObject() {
|
||||
|
||||
override fun getUniqueTarget() = UniqueTarget.Tutorial
|
||||
override fun makeLink() = "Tutorial/$name"
|
||||
|
||||
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
||||
val imageLine = FormattedLine(extraImage = name.replace(' ', '_'))
|
||||
if (steps == null) return listOf(imageLine)
|
||||
return (sequenceOf(imageLine) + steps.asSequence().map { FormattedLine(it) }).toList()
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
package com.unciv.models.ruleset.unique
|
||||
|
||||
import com.unciv.Constants
|
||||
import com.unciv.models.ruleset.Ruleset
|
||||
import com.unciv.models.ruleset.validation.RulesetErrorSeverity
|
||||
import com.unciv.models.ruleset.validation.RulesetValidator // Kdoc only
|
||||
import com.unciv.models.ruleset.validation.RulesetValidator
|
||||
import com.unciv.models.translations.getPlaceholderParameters
|
||||
import com.unciv.models.translations.getPlaceholderText
|
||||
|
||||
@ -761,12 +760,15 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
//endregion
|
||||
|
||||
///////////////////////////////////////////// region 90 META /////////////////////////////////////////////
|
||||
HiddenWithoutReligion("Hidden when religion is disabled", UniqueTarget.Unit, UniqueTarget.Building, UniqueTarget.Ruins, flags = UniqueFlag.setOfHiddenToUsers),
|
||||
HiddenWithoutReligion("Hidden when religion is disabled",
|
||||
UniqueTarget.Unit, UniqueTarget.Building, UniqueTarget.Ruins, UniqueTarget.Tutorial,
|
||||
flags = UniqueFlag.setOfHiddenToUsers),
|
||||
|
||||
HiddenAfterGreatProphet("Hidden after generating a Great Prophet", UniqueTarget.Ruins),
|
||||
HiddenWithoutVictoryType("Hidden when [victoryType] Victory is disabled", UniqueTarget.Building, UniqueTarget.Unit, flags = UniqueFlag.setOfHiddenToUsers),
|
||||
HiddenFromCivilopedia("Will not be displayed in Civilopedia", UniqueTarget.Building, UniqueTarget.Unit, UniqueTarget.UnitType, UniqueTarget.Improvement,
|
||||
UniqueTarget.Tech, UniqueTarget.Terrain, UniqueTarget.Resource, UniqueTarget.Policy, UniqueTarget.Promotion,
|
||||
HiddenFromCivilopedia("Will not be displayed in Civilopedia", UniqueTarget.Building,
|
||||
UniqueTarget.Unit, UniqueTarget.UnitType, UniqueTarget.Improvement, UniqueTarget.Tech,
|
||||
UniqueTarget.Terrain, UniqueTarget.Resource, UniqueTarget.Policy, UniqueTarget.Promotion,
|
||||
UniqueTarget.Nation, UniqueTarget.Ruins, flags = UniqueFlag.setOfHiddenToUsers),
|
||||
|
||||
// Declarative Mod compatibility (so far rudimentary):
|
||||
|
@ -7,13 +7,10 @@ import com.unciv.json.fromJsonFile
|
||||
import com.unciv.json.json
|
||||
import com.unciv.models.TutorialTrigger
|
||||
import com.unciv.models.ruleset.Tutorial
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.stats.INamed
|
||||
import com.unciv.ui.components.input.KeyCharAndCode
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
import com.unciv.ui.popups.Popup
|
||||
import com.unciv.ui.screens.civilopediascreen.FormattedLine
|
||||
import com.unciv.ui.screens.civilopediascreen.SimpleCivilopediaText
|
||||
import com.unciv.ui.screens.civilopediascreen.ICivilopediaText
|
||||
|
||||
|
||||
class TutorialController(screen: BaseScreen) {
|
||||
@ -80,32 +77,12 @@ class TutorialController(screen: BaseScreen) {
|
||||
return tutorials[name]?.steps ?: emptyList()
|
||||
}
|
||||
|
||||
/** Wrapper for a Tutorial, supports INamed and ICivilopediaText,
|
||||
* and already provisions for the display of an ExtraImage on top.
|
||||
* @param name from Tutorial.name, also used for ExtraImage (with spaces replaced by underscores)
|
||||
* @param tutorial provides [Tutorial.civilopediaText] and [Tutorial.steps] for display
|
||||
*/
|
||||
//todo Replace - Civilopedia should display Tutorials directly as the RulesetObjects they are
|
||||
class CivilopediaTutorial(
|
||||
override var name: String,
|
||||
tutorial: Tutorial
|
||||
) : INamed, SimpleCivilopediaText(
|
||||
sequenceOf(FormattedLine(extraImage = name.replace(' ', '_'))) + tutorial.civilopediaText.asSequence(),
|
||||
tutorial.steps?.asSequence() ?: emptySequence()
|
||||
) {
|
||||
override fun makeLink() = "Tutorial/$name"
|
||||
}
|
||||
|
||||
/** Get all Tutorials intended to be displayed in the Civilopedia
|
||||
* as a List of wrappers supporting INamed and ICivilopediaText
|
||||
*/
|
||||
fun getCivilopediaTutorials(): List<CivilopediaTutorial> {
|
||||
val civilopediaTutorials = tutorials.filter {
|
||||
!it.value.hasUnique(UniqueType.HiddenFromCivilopedia)
|
||||
}.map {
|
||||
tutorial -> CivilopediaTutorial(tutorial.key, tutorial.value)
|
||||
}
|
||||
return civilopediaTutorials
|
||||
/** Get all Tutorials to be displayed in the Civilopedia */
|
||||
fun getCivilopediaTutorials(): Collection<ICivilopediaText> {
|
||||
// Todo This is essentially an 'un-private' kludge and the accessor
|
||||
// in CivilopediaCategories desperately needs independence from TutorialController:
|
||||
// Move storage to RuleSet someday?
|
||||
return tutorials.values
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user