mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-11 03:18:18 +07:00
A Civilopedia category for Religion (#4609)
* A Civilopedia category for Religion * Civilopedia for Religion - rename cat, template and EOF linting * Civilopedia for Religion - oversight
This commit is contained in:
parent
e514df5b82
commit
e41ba0da91
BIN
android/Images/ReligionIcons/Follower.png
Normal file
BIN
android/Images/ReligionIcons/Follower.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
android/Images/ReligionIcons/Religion.png
Normal file
BIN
android/Images/ReligionIcons/Religion.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
@ -945,6 +945,7 @@ Choose a pantheon =
|
|||||||
Found Religion =
|
Found Religion =
|
||||||
Found Pantheon =
|
Found Pantheon =
|
||||||
Follow [belief] =
|
Follow [belief] =
|
||||||
|
Religions and Beliefs =
|
||||||
|
|
||||||
# Terrains
|
# Terrains
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.unciv.logic.civilization
|
|||||||
import com.unciv.logic.map.MapUnit
|
import com.unciv.logic.map.MapUnit
|
||||||
import com.unciv.models.Religion
|
import com.unciv.models.Religion
|
||||||
import com.unciv.models.ruleset.Belief
|
import com.unciv.models.ruleset.Belief
|
||||||
|
import com.unciv.models.ruleset.BeliefType
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
class ReligionManager {
|
class ReligionManager {
|
||||||
@ -73,7 +74,7 @@ class ReligionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun isPickablePantheonBelief(belief: Belief): Boolean {
|
fun isPickablePantheonBelief(belief: Belief): Boolean {
|
||||||
if (belief.type != "Pantheon") return false
|
if (belief.type != BeliefType.Pantheon) return false
|
||||||
if (civInfo.gameInfo.civilizations.any { it.religionManager.religion != null && it.religionManager.religion!!.followerBeliefs.contains(belief.name)})
|
if (civInfo.gameInfo.civilizations.any { it.religionManager.religion != null && it.religionManager.religion!!.followerBeliefs.contains(belief.name)})
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
@ -179,4 +180,4 @@ enum class ReligionState {
|
|||||||
Religion,
|
Religion,
|
||||||
EnhancingReligion, // Great prophet used, but religion has not yet been enhanced
|
EnhancingReligion, // Great prophet used, but religion has not yet been enhanced
|
||||||
EnhancedReligion
|
EnhancedReligion
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.unciv.models
|
|||||||
|
|
||||||
import com.unciv.logic.GameInfo
|
import com.unciv.logic.GameInfo
|
||||||
import com.unciv.models.ruleset.Belief
|
import com.unciv.models.ruleset.Belief
|
||||||
|
import com.unciv.models.ruleset.BeliefType
|
||||||
import com.unciv.models.ruleset.Unique
|
import com.unciv.models.ruleset.Unique
|
||||||
import com.unciv.models.stats.INamed
|
import com.unciv.models.stats.INamed
|
||||||
|
|
||||||
@ -49,13 +50,13 @@ class Religion() : INamed {
|
|||||||
|
|
||||||
fun getPantheonBeliefs(): Sequence<Belief> {
|
fun getPantheonBeliefs(): Sequence<Belief> {
|
||||||
return mapToExistingBeliefs(followerBeliefs)
|
return mapToExistingBeliefs(followerBeliefs)
|
||||||
.filter { it.type == "Pantheon" }
|
.filter { it.type == BeliefType.Pantheon }
|
||||||
.asSequence()
|
.asSequence()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getFollowerBeliefs(): Sequence<Belief> {
|
fun getFollowerBeliefs(): Sequence<Belief> {
|
||||||
return mapToExistingBeliefs(followerBeliefs)
|
return mapToExistingBeliefs(followerBeliefs)
|
||||||
.filter { it.type == "Follower" }
|
.filter { it.type == BeliefType.Follower }
|
||||||
.asSequence()
|
.asSequence()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,15 +81,16 @@ class Religion() : INamed {
|
|||||||
|
|
||||||
fun isMajorReligion(): Boolean {
|
fun isMajorReligion(): Boolean {
|
||||||
if ("" in followerBeliefs) return true // Temporary as a result of follower beliefs not yet being implemented
|
if ("" in followerBeliefs) return true // Temporary as a result of follower beliefs not yet being implemented
|
||||||
return founderBeliefs.isNotEmpty() && followerBeliefs.any { gameInfo.ruleSet.beliefs[it]!!.type == "Follower"}
|
return founderBeliefs.isNotEmpty() && followerBeliefs
|
||||||
|
.any { gameInfo.ruleSet.beliefs[it]!!.type == BeliefType.Follower}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hasPantheon(): Boolean { // Currently unused
|
fun hasPantheon(): Boolean { // Currently unused
|
||||||
// Temporary as a result of follower beliefs not yet being implemented
|
// Temporary as a result of follower beliefs not yet being implemented
|
||||||
return followerBeliefs.any { it != "" && gameInfo.ruleSet.beliefs[it]!!.type == "Pantheon" }
|
return followerBeliefs.any { it != "" && gameInfo.ruleSet.beliefs[it]!!.type == BeliefType.Pantheon }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hasBelief(belief: String): Boolean {
|
fun hasBelief(belief: String): Boolean {
|
||||||
return followerBeliefs.contains(belief) || founderBeliefs.contains(belief)
|
return followerBeliefs.contains(belief) || founderBeliefs.contains(belief)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,33 @@
|
|||||||
package com.unciv.models.ruleset
|
package com.unciv.models.ruleset
|
||||||
|
|
||||||
import com.unciv.models.stats.INamed
|
import com.unciv.models.stats.INamed
|
||||||
|
import com.unciv.ui.civilopedia.CivilopediaText
|
||||||
|
import com.unciv.ui.civilopedia.FormattedLine
|
||||||
|
import java.awt.Color
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
|
||||||
class Belief: INamed {
|
class Belief: INamed, CivilopediaText() {
|
||||||
override var name: String = ""
|
override var name: String = ""
|
||||||
var type: String = ""
|
var type: BeliefType = BeliefType.None
|
||||||
var uniques = ArrayList<String>()
|
var uniques = ArrayList<String>()
|
||||||
val uniqueObjects: List<Unique> by lazy { uniques.map { Unique(it) } }
|
val uniqueObjects: List<Unique> by lazy { uniques.map { Unique(it) } }
|
||||||
|
|
||||||
|
override fun getCivilopediaTextHeader() = FormattedLine(name, icon="Belief/$name", header=2)
|
||||||
|
override fun replacesCivilopediaDescription() = true
|
||||||
|
override fun hasCivilopediaTextLines() = true
|
||||||
|
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
||||||
|
val textList = ArrayList<FormattedLine>()
|
||||||
|
textList += FormattedLine("{Type}: $type", color=type.color )
|
||||||
|
uniqueObjects.forEach {
|
||||||
|
textList += FormattedLine(it)
|
||||||
|
}
|
||||||
|
return textList
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class BeliefType(val color: String) {
|
||||||
|
None(""),
|
||||||
|
Pantheon("#44c6cc"),
|
||||||
|
Follower("#ccaa44"),
|
||||||
|
Founder("#c00000")
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,13 @@ object CivilopediaImageGetters {
|
|||||||
if (terrain == null) null
|
if (terrain == null) null
|
||||||
else terrainImage(terrain, ImageGetter.ruleset, size)
|
else terrainImage(terrain, ImageGetter.ruleset, size)
|
||||||
}
|
}
|
||||||
|
val belief = { name: String, size: Float ->
|
||||||
|
// Kludge until we decide how exactly to show Religions
|
||||||
|
if (ImageGetter.imageExists("ReligionIcons/$name")) {
|
||||||
|
ImageGetter.getReligionIcon(name).surroundWithCircle(size, color = Color.BLACK)
|
||||||
|
}
|
||||||
|
else null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Enum used as keys for Civilopedia "pages" (categories).
|
/** Enum used as keys for Civilopedia "pages" (categories).
|
||||||
@ -100,6 +107,7 @@ enum class CivilopediaCategories (
|
|||||||
Policy ("Policies", true, CivilopediaImageGetters.policy ),
|
Policy ("Policies", true, CivilopediaImageGetters.policy ),
|
||||||
Tutorial ("Tutorials", false, null ),
|
Tutorial ("Tutorials", false, null ),
|
||||||
Difficulty ("Difficulty levels", false, null ),
|
Difficulty ("Difficulty levels", false, null ),
|
||||||
|
Belief("Religions and Beliefs", false, CivilopediaImageGetters.belief)
|
||||||
;
|
;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -40,9 +40,10 @@ class CivilopediaScreen(
|
|||||||
val image: Actor? = null,
|
val image: Actor? = null,
|
||||||
val flavour: ICivilopediaText? = null,
|
val flavour: ICivilopediaText? = null,
|
||||||
val y: Float = 0f, // coordinates of button cell used to scroll to entry
|
val y: Float = 0f, // coordinates of button cell used to scroll to entry
|
||||||
val height: Float = 0f
|
val height: Float = 0f,
|
||||||
|
val sortBy: Int = 0 // optional, enabling overriding alphabetical order
|
||||||
) {
|
) {
|
||||||
fun withCoordinates(y: Float, height: Float) = CivilopediaEntry(name, description, image, flavour, y, height)
|
fun withCoordinates(y: Float, height: Float) = CivilopediaEntry(name, description, image, flavour, y, height, sortBy)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val categoryToEntries = LinkedHashMap<CivilopediaCategories, Collection<CivilopediaEntry>>()
|
private val categoryToEntries = LinkedHashMap<CivilopediaCategories, Collection<CivilopediaEntry>>()
|
||||||
@ -99,7 +100,10 @@ class CivilopediaScreen(
|
|||||||
var entries = categoryToEntries[category]!!
|
var entries = categoryToEntries[category]!!
|
||||||
if (category != CivilopediaCategories.Difficulty) // this is the only case where we need them in order
|
if (category != CivilopediaCategories.Difficulty) // this is the only case where we need them in order
|
||||||
// Alphabetical order of localized names, using system default locale
|
// Alphabetical order of localized names, using system default locale
|
||||||
entries = entries.sortedWith(compareBy(Collator.getInstance(), { it.name.tr() }))
|
entries = entries.sortedWith(
|
||||||
|
compareBy<CivilopediaEntry>{ it.sortBy }
|
||||||
|
.thenBy (Collator.getInstance(), { it.name.tr() })
|
||||||
|
)
|
||||||
|
|
||||||
var currentY = -1f
|
var currentY = -1f
|
||||||
|
|
||||||
@ -283,6 +287,26 @@ class CivilopediaScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!hideReligionItems)
|
||||||
|
categoryToEntries[CivilopediaCategories.Belief] = (
|
||||||
|
ruleset.beliefs.values.asSequence()
|
||||||
|
.map {
|
||||||
|
CivilopediaEntry(
|
||||||
|
it.name,
|
||||||
|
"",
|
||||||
|
CivilopediaCategories.Belief.getImage?.invoke(it.type.name, imageSize),
|
||||||
|
(it as? ICivilopediaText).takeUnless { ct -> ct==null || ct.isCivilopediaTextEmpty() },
|
||||||
|
sortBy = it.type.ordinal
|
||||||
|
)
|
||||||
|
} + CivilopediaEntry(
|
||||||
|
"Religions",
|
||||||
|
"",
|
||||||
|
CivilopediaCategories.Belief.getImage?.invoke("Religion", imageSize),
|
||||||
|
getReligionText(),
|
||||||
|
sortBy = -1
|
||||||
|
)
|
||||||
|
).toList()
|
||||||
|
|
||||||
val buttonTable = Table()
|
val buttonTable = Table()
|
||||||
buttonTable.pad(15f)
|
buttonTable.pad(15f)
|
||||||
buttonTable.defaults().pad(10f)
|
buttonTable.defaults().pad(10f)
|
||||||
@ -341,6 +365,16 @@ class CivilopediaScreen(
|
|||||||
selectEntry(link, noScrollAnimation = true)
|
selectEntry(link, noScrollAnimation = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getReligionText(): ICivilopediaText {
|
||||||
|
val lines = ArrayList<FormattedLine>()
|
||||||
|
lines += FormattedLine("Religions", header=2, color="#e34a2b")
|
||||||
|
lines += FormattedLine(separator=true)
|
||||||
|
ruleset.religions.sortedWith(compareBy(Collator.getInstance(), { it.tr() })).forEach {
|
||||||
|
lines += FormattedLine(it, icon="Belief/$it")
|
||||||
|
}
|
||||||
|
return SimpleCivilopediaText(lines, true)
|
||||||
|
}
|
||||||
|
|
||||||
override fun resize(width: Int, height: Int) {
|
override fun resize(width: Int, height: Int) {
|
||||||
if (stage.viewport.screenWidth != width || stage.viewport.screenHeight != height) {
|
if (stage.viewport.screenWidth != width || stage.viewport.screenHeight != height) {
|
||||||
game.setScreen(CivilopediaScreen(game.worldScreen.gameInfo.ruleSet, currentCategory, currentEntry))
|
game.setScreen(CivilopediaScreen(game.worldScreen.gameInfo.ruleSet, currentCategory, currentEntry))
|
||||||
|
@ -153,6 +153,7 @@ class FormattedLine (
|
|||||||
val ruleSet = UncivGame.Current.gameInfo.ruleSet
|
val ruleSet = UncivGame.Current.gameInfo.ruleSet
|
||||||
// order these with the categories that should take precedence in case of name conflicts (e.g. Railroad) _last_
|
// order these with the categories that should take precedence in case of name conflicts (e.g. Railroad) _last_
|
||||||
val allObjectMapsSequence = sequence {
|
val allObjectMapsSequence = sequence {
|
||||||
|
yield(CivilopediaCategories.Belief to ruleSet.beliefs)
|
||||||
yield(CivilopediaCategories.Difficulty to ruleSet.difficulties)
|
yield(CivilopediaCategories.Difficulty to ruleSet.difficulties)
|
||||||
yield(CivilopediaCategories.Promotion to ruleSet.unitPromotions)
|
yield(CivilopediaCategories.Promotion to ruleSet.unitPromotions)
|
||||||
yield(CivilopediaCategories.Policy to ruleSet.policies)
|
yield(CivilopediaCategories.Policy to ruleSet.policies)
|
||||||
|
@ -9,6 +9,7 @@ import com.unciv.logic.civilization.CivilizationInfo
|
|||||||
import com.unciv.models.Religion
|
import com.unciv.models.Religion
|
||||||
import com.unciv.models.UncivSound
|
import com.unciv.models.UncivSound
|
||||||
import com.unciv.models.ruleset.Belief
|
import com.unciv.models.ruleset.Belief
|
||||||
|
import com.unciv.models.ruleset.BeliefType
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
|
|
||||||
@ -126,7 +127,7 @@ class FoundReligionPickerScreen (
|
|||||||
rightBeliefsToChoose.clear()
|
rightBeliefsToChoose.clear()
|
||||||
val availableBeliefs = gameInfo.ruleSet.beliefs.values
|
val availableBeliefs = gameInfo.ruleSet.beliefs.values
|
||||||
.filter {
|
.filter {
|
||||||
it.type == beliefType
|
it.type.name == beliefType
|
||||||
&& gameInfo.religions.values.none {
|
&& gameInfo.religions.values.none {
|
||||||
religion -> religion.hasBelief(it.name)
|
religion -> religion.hasBelief(it.name)
|
||||||
}
|
}
|
||||||
@ -135,8 +136,8 @@ class FoundReligionPickerScreen (
|
|||||||
for (belief in availableBeliefs) {
|
for (belief in availableBeliefs) {
|
||||||
val beliefButton = convertBeliefToButton(belief)
|
val beliefButton = convertBeliefToButton(belief)
|
||||||
beliefButton.onClick {
|
beliefButton.onClick {
|
||||||
if (beliefType == "Follower") chosenFollowerBeliefs[leftButtonIndex] = belief
|
if (beliefType == BeliefType.Follower.name) chosenFollowerBeliefs[leftButtonIndex] = belief
|
||||||
else if (beliefType == "Founder") chosenFounderBeliefs[leftButtonIndex] = belief
|
else if (beliefType == BeliefType.Founder.name) chosenFounderBeliefs[leftButtonIndex] = belief
|
||||||
updateLeftTable()
|
updateLeftTable()
|
||||||
checkAndEnableRightSideButton()
|
checkAndEnableRightSideButton()
|
||||||
}
|
}
|
||||||
@ -146,7 +147,7 @@ class FoundReligionPickerScreen (
|
|||||||
|
|
||||||
private fun convertBeliefToButton(belief: Belief): Button {
|
private fun convertBeliefToButton(belief: Belief): Button {
|
||||||
val contentsTable = Table()
|
val contentsTable = Table()
|
||||||
contentsTable.add(belief.type.toLabel()).row()
|
contentsTable.add(belief.type.name.toLabel()).row()
|
||||||
contentsTable.add(belief.name.toLabel(fontSize = 24)).row()
|
contentsTable.add(belief.name.toLabel(fontSize = 24)).row()
|
||||||
contentsTable.add(belief.uniques.joinToString().toLabel())
|
contentsTable.add(belief.uniques.joinToString().toLabel())
|
||||||
return Button(contentsTable, skin)
|
return Button(contentsTable, skin)
|
||||||
@ -157,4 +158,4 @@ class FoundReligionPickerScreen (
|
|||||||
contentsTable.add("Choose a [$beliefType] belief!".toLabel())
|
contentsTable.add("Choose a [$beliefType] belief!".toLabel())
|
||||||
return Button(contentsTable, skin)
|
return Button(contentsTable, skin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -562,6 +562,8 @@ Unless otherwise specified, all the following are from [the Noun Project](https:
|
|||||||
* [taoism](https://thenounproject.com/search/?q=Taoism&i=740812) by parkjisun for Taosim
|
* [taoism](https://thenounproject.com/search/?q=Taoism&i=740812) by parkjisun for Taosim
|
||||||
* [Buddhism](https://thenounproject.com/search/?q=buddhism&i=38764) by Julio Yanes for Buddhism
|
* [Buddhism](https://thenounproject.com/search/?q=buddhism&i=38764) by Julio Yanes for Buddhism
|
||||||
* [Hinduism](https://thenounproject.com/search/?q=hinduism&i=20383) by Mugda Damle for Hinduism
|
* [Hinduism](https://thenounproject.com/search/?q=hinduism&i=20383) by Mugda Damle for Hinduism
|
||||||
|
* [praying](https://thenounproject.com/term/praying/740809/) by parkjisun for Religion (Civilopedia concept entry)
|
||||||
|
* [praying](https://thenounproject.com/term/praying/886367/) by Gan Khoon Lay for Follower
|
||||||
|
|
||||||
## Others
|
## Others
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user