mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 23:39:40 +07:00
Better Religion info and some moddability (#8807)
* Make maximum number of religions moddable * Explain remaining religion count in Empire Overview
This commit is contained in:
@ -186,20 +186,24 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
}
|
||||
|
||||
private fun maxNumberOfReligions() = min(
|
||||
civInfo.gameInfo.ruleset.religions.size,
|
||||
civInfo.gameInfo.civilizations.count { it.isMajorCiv() } / 2 + 1
|
||||
)
|
||||
private fun maxNumberOfReligions(): Int {
|
||||
val gameInfo = civInfo.gameInfo
|
||||
val ruleset = gameInfo.ruleset
|
||||
val multiplier = ruleset.modOptions.constants.religionLimitMultiplier
|
||||
val base = ruleset.modOptions.constants.religionLimitBase
|
||||
val civCount = gameInfo.civilizations.count { it.isMajorCiv() }
|
||||
return min(ruleset.religions.size, base + (civCount * multiplier).toInt())
|
||||
}
|
||||
|
||||
/** Calculates the number of religions that are already founded */
|
||||
private fun foundedReligionsCount() = civInfo.gameInfo.civilizations.count {
|
||||
it.religionManager.religion != null && it.religionManager.religionState >= ReligionState.Religion
|
||||
}
|
||||
|
||||
/** Calculates the amount of religions that can still be founded */
|
||||
fun remainingFoundableReligions(): Int {
|
||||
val gameInfo = civInfo.gameInfo
|
||||
val foundedReligionsCount = gameInfo.civilizations.count {
|
||||
it.religionManager.religion != null && it.religionManager.religionState >= ReligionState.Religion
|
||||
}
|
||||
|
||||
// count the number of foundable religions left given defined ruleset religions and number of civs in game
|
||||
val maxNumberOfAdditionalReligions = maxNumberOfReligions() - foundedReligionsCount
|
||||
val maxNumberOfAdditionalReligions = maxNumberOfReligions() - foundedReligionsCount()
|
||||
|
||||
val availableBeliefsToFound = min(
|
||||
numberOfBeliefsAvailable(BeliefType.Follower),
|
||||
@ -209,6 +213,20 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
return min(maxNumberOfAdditionalReligions, availableBeliefsToFound)
|
||||
}
|
||||
|
||||
/** Get info breaking down the reasons behind the result of [remainingFoundableReligions] */
|
||||
fun remainingFoundableReligionsBreakdown() = sequence {
|
||||
val gameInfo = civInfo.gameInfo
|
||||
val ruleset = gameInfo.ruleset
|
||||
val multiplier = ruleset.modOptions.constants.religionLimitMultiplier
|
||||
val base = ruleset.modOptions.constants.religionLimitBase
|
||||
val civCount = gameInfo.civilizations.count { it.isMajorCiv() }
|
||||
yield("Available religion symbols" to ruleset.religions.size)
|
||||
yield("Number of civilizations * [$multiplier] + [$base]" to base + (civCount * multiplier).toInt())
|
||||
yield("Religions already founded" to foundedReligionsCount())
|
||||
yield("Available founder beliefs" to numberOfBeliefsAvailable(BeliefType.Founder))
|
||||
yield("Available follower beliefs" to numberOfBeliefsAvailable(BeliefType.Follower))
|
||||
}
|
||||
|
||||
fun numberOfBeliefsAvailable(type: BeliefType): Int {
|
||||
val gameInfo = civInfo.gameInfo
|
||||
val numberOfBeliefs = if (type == BeliefType.Any) gameInfo.ruleset.beliefs.values.count()
|
||||
|
@ -62,6 +62,10 @@ class ModConstants {
|
||||
var minRiverLength = 5
|
||||
var maxRiverLength = 666 // Do not set to less than the maximal map radius
|
||||
|
||||
// Factors in formula for Maximum Number of foundable Religions
|
||||
var religionLimitBase = 1
|
||||
var religionLimitMultiplier = 0.5f
|
||||
|
||||
fun merge(other: ModConstants) {
|
||||
if (other.maxXPfromBarbarians != defaults.maxXPfromBarbarians) maxXPfromBarbarians = other.maxXPfromBarbarians
|
||||
if (other.cityStrengthBase != defaults.cityStrengthBase) cityStrengthBase = other.cityStrengthBase
|
||||
@ -82,6 +86,8 @@ class ModConstants {
|
||||
if (other.riverCountMultiplier != defaults.riverCountMultiplier) riverCountMultiplier = other.riverCountMultiplier
|
||||
if (other.minRiverLength != defaults.minRiverLength) minRiverLength = other.minRiverLength
|
||||
if (other.maxRiverLength != defaults.maxRiverLength) maxRiverLength = other.maxRiverLength
|
||||
if (other.religionLimitBase != defaults.religionLimitBase) religionLimitBase = other.religionLimitBase
|
||||
if (other.religionLimitMultiplier != defaults.religionLimitMultiplier) religionLimitMultiplier = other.religionLimitMultiplier
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -12,6 +12,7 @@ import com.unciv.models.Religion
|
||||
import com.unciv.models.ruleset.Belief
|
||||
import com.unciv.models.translations.fillPlaceholders
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.components.ExpanderTab
|
||||
import com.unciv.ui.screens.civilopediascreen.CivilopediaScreen
|
||||
import com.unciv.ui.screens.civilopediascreen.MarkupRenderer
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
@ -66,6 +67,22 @@ class ReligionOverviewTab(
|
||||
}
|
||||
|
||||
private fun Table.addCivSpecificStats() {
|
||||
// This is not Civ-specific, but -oh well- still fits
|
||||
val remaining = viewingPlayer.religionManager.remainingFoundableReligions()
|
||||
val minWidth = max(religionButtonLabel.prefWidth, overviewScreen.stage.width / 3)
|
||||
val headerText = "Religions to be founded: [$remaining]"
|
||||
val religionCountExpander = ExpanderTab(
|
||||
headerText, fontSize = 18, headerPad = 5f,
|
||||
startsOutOpened = false, defaultPad = 0f, expanderWidth = minWidth
|
||||
) {
|
||||
it.defaults().padTop(10f)
|
||||
for ((text, num) in viewingPlayer.religionManager.remainingFoundableReligionsBreakdown()) {
|
||||
it.add(text.toLabel())
|
||||
it.add(num.toString().toLabel(alignment = Align.right)).right().row()
|
||||
}
|
||||
}
|
||||
add(religionCountExpander).colspan(2).growX().row()
|
||||
|
||||
if (viewingPlayer.religionManager.canGenerateProphet()) {
|
||||
add("Minimal Faith required for\nthe next [great prophet equivalent]:"
|
||||
.fillPlaceholders(viewingPlayer.religionManager.getGreatProphetEquivalent()!!)
|
||||
@ -77,9 +94,6 @@ class ReligionOverviewTab(
|
||||
).right().row()
|
||||
}
|
||||
|
||||
add("Religions to be founded:".toLabel())
|
||||
add((viewingPlayer.religionManager.remainingFoundableReligions()).toLabel()).right().row()
|
||||
|
||||
add("Religious status:".toLabel()).left()
|
||||
add(viewingPlayer.religionManager.religionState.toString().toLabel()).right().row()
|
||||
}
|
||||
|
Reference in New Issue
Block a user