mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-23 05:00:43 +07:00
Potpourri of RekMod-inspired little updates (#10390)
* RekMod-inspired: StatPercentFromReligionFollowers does work on FounderBelief target * RekMod-inspired: Make StatPercentFromReligionFollowers check correct Religion * RekMod-inspired: Prep: flags on ImprovementBuildingProblem * RekMod-inspired: Don't offer e.g. Kampong Ayer to non-Brunei Workboats * Update "filtering Uniques" documentation
This commit is contained in:
parent
c9d10cd8e1
commit
652b3c9159
@ -295,7 +295,7 @@ class CityStats(val city: City) {
|
||||
for (unique in city.getMatchingUniques(UniqueType.StatPercentFromReligionFollowers))
|
||||
addUniqueStats(unique, Stat.valueOf(unique.params[1]),
|
||||
min(
|
||||
unique.params[0].toFloat() * city.religion.getFollowersOfMajorityReligion(),
|
||||
unique.params[0].toFloat() * city.religion.getFollowersOfOurReligion(),
|
||||
unique.params[2].toFloat()
|
||||
))
|
||||
|
||||
|
@ -199,6 +199,11 @@ class CityReligionManager : IsPartOfGameInfoSerialization {
|
||||
return followers[majorityReligion]
|
||||
}
|
||||
|
||||
fun getFollowersOfOurReligion(): Int {
|
||||
val ourReligion = city.civ.religionManager.religion ?: return 0
|
||||
return followers[ourReligion.name]
|
||||
}
|
||||
|
||||
fun getFollowersOfOtherReligionsThan(religion: String): Int {
|
||||
return followers.filterNot { it.key == religion }.values.sum()
|
||||
}
|
||||
|
@ -11,8 +11,23 @@ import com.unciv.models.ruleset.unique.StateForConditionals
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
|
||||
|
||||
enum class ImprovementBuildingProblem {
|
||||
WrongCiv, MissingTech, Unbuildable, NotJustOutsideBorders, OutsideBorders, UnmetConditional, Obsolete, MissingResources, Other
|
||||
/** Reason why an Improvement cannot be built by a given civ */
|
||||
enum class ImprovementBuildingProblem(
|
||||
/** `true` if this cannot change on the future of this game */
|
||||
val permanent: Boolean = false,
|
||||
/** `true` if the ImprovementPicker should report this problem */
|
||||
val reportable: Boolean = false
|
||||
) {
|
||||
WrongCiv(permanent = true),
|
||||
MissingTech(reportable = true),
|
||||
Unbuildable(permanent = true),
|
||||
ConditionallyUnbuildable,
|
||||
NotJustOutsideBorders(reportable = true),
|
||||
OutsideBorders(reportable = true),
|
||||
UnmetConditional,
|
||||
Obsolete(permanent = true),
|
||||
MissingResources(reportable = true),
|
||||
Other
|
||||
}
|
||||
|
||||
class TileInfoImprovementFunctions(val tile: Tile) {
|
||||
@ -30,8 +45,11 @@ class TileInfoImprovementFunctions(val tile: Tile) {
|
||||
yield(ImprovementBuildingProblem.WrongCiv)
|
||||
if (improvement.techRequired != null && !civInfo.tech.isResearched(improvement.techRequired!!))
|
||||
yield(ImprovementBuildingProblem.MissingTech)
|
||||
if (improvement.hasUnique(UniqueType.Unbuildable, stateForConditionals))
|
||||
if (improvement.getMatchingUniques(UniqueType.Unbuildable, StateForConditionals.IgnoreConditionals)
|
||||
.any { it.conditionals.isEmpty() })
|
||||
yield(ImprovementBuildingProblem.Unbuildable)
|
||||
else if (improvement.hasUnique(UniqueType.Unbuildable, stateForConditionals))
|
||||
yield(ImprovementBuildingProblem.ConditionallyUnbuildable)
|
||||
|
||||
if (tile.getOwner() != civInfo && !improvement.hasUnique(UniqueType.CanBuildOutsideBorders, stateForConditionals)) {
|
||||
if (!improvement.hasUnique(UniqueType.CanBuildJustOutsideBorders, stateForConditionals))
|
||||
|
@ -40,7 +40,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
StatPercentBonusCities("[relativeAmount]% [stat] [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
StatPercentFromObject("[relativeAmount]% [stat] from every [tileFilter/buildingFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
AllStatsPercentFromObject("[relativeAmount]% Yield from every [tileFilter/buildingFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
StatPercentFromReligionFollowers("[relativeAmount]% [stat] from every follower, up to [relativeAmount]%", UniqueTarget.FollowerBelief),
|
||||
StatPercentFromReligionFollowers("[relativeAmount]% [stat] from every follower, up to [relativeAmount]%", UniqueTarget.FollowerBelief, UniqueTarget.FounderBelief),
|
||||
BonusStatsFromCityStates("[relativeAmount]% [stat] from City-States", UniqueTarget.Global),
|
||||
StatPercentFromTradeRoutes("[relativeAmount]% [stat] from Trade Routes", UniqueTarget.Global),
|
||||
|
||||
|
@ -216,7 +216,7 @@ class UniqueValidator(val ruleset: Ruleset) {
|
||||
|
||||
private fun isFilteringUniqueAllowed(unique: Unique): Boolean {
|
||||
// Isolate this decision, to allow easy change of approach
|
||||
// This says: Must have no conditionals or parameters, and is contained in GlobalUniques
|
||||
// This says: Must have no conditionals or parameters, and is used in any "filtering" parameter of another Unique
|
||||
if (unique.conditionals.isNotEmpty() || unique.params.isNotEmpty()) return false
|
||||
return unique.text in allUniqueParameters // referenced at least once from elsewhere
|
||||
}
|
||||
|
@ -31,16 +31,8 @@ class ImprovementPickerScreen(
|
||||
) : PickerScreen() {
|
||||
|
||||
companion object {
|
||||
/** Set of resolvable improvement building problems that this class knows how to report. */
|
||||
private val reportableProblems = setOf(
|
||||
ImprovementBuildingProblem.MissingTech,
|
||||
ImprovementBuildingProblem.NotJustOutsideBorders,
|
||||
ImprovementBuildingProblem.OutsideBorders,
|
||||
ImprovementBuildingProblem.MissingResources
|
||||
)
|
||||
|
||||
/** Return true if we can report improvements associated with the [problems] (or there are no problems for it at all). */
|
||||
fun canReport(problems: Collection<ImprovementBuildingProblem>) = problems.all { it in reportableProblems }
|
||||
fun canReport(problems: Collection<ImprovementBuildingProblem>) = problems.all { it.reportable }
|
||||
}
|
||||
|
||||
private var selectedImprovement: TileImprovement? = null
|
||||
|
@ -236,6 +236,11 @@ object UnitActionsFromUniques {
|
||||
val improvement = tile.ruleset.tileImprovements[improvementName]
|
||||
?: continue
|
||||
|
||||
// Try to skip Improvements we can never build
|
||||
// (getImprovementBuildingProblems catches those so the button is always disabled, but it nevertheless looks nicer)
|
||||
if (tile.improvementFunctions.getImprovementBuildingProblems(improvement, unit.civ).any { it.permanent })
|
||||
continue
|
||||
|
||||
val resourcesAvailable = improvement.uniqueObjects.none {
|
||||
improvementUnique ->
|
||||
improvementUnique.isOfType(UniqueType.ConsumesResources) &&
|
||||
|
@ -95,7 +95,10 @@ Example: `"uniques":["[+1 Gold] <with a garrison>"]` on a building - does almost
|
||||
|
||||
All Unique "types" that have an implementation in Unciv are automatically documented in [uniques](../uniques.md). Note that file is entirely machine-generated from source code structures. Also kindly note the separate sections for [conditionals](../uniques.md#conditional-uniques) and [trigger conditions](../uniques.md#triggercondition-uniques).
|
||||
Uniques that do not correspond to any of those entries (verbatim including upper/lower case!) are called "untyped", will have no _direct_ effect, and may result in the "Ruleset Validator" showing warnings (see the Options Tab "Locate mod errors", it also runs when starting new games).
|
||||
A legitimate use of "untyped" Uniques is their use as markers that can be recognized elsewhere in filters (example: "Aircraft" in the vanilla rulesets used as [Unit filter](../Unique-parameters.md#baseunitfilter)). To allow "Ruleset Validator" to warn about mistakes leading to untyped uniques, but still allow the "filtering Unique" use, those should be "declared" by including each in [GlobalUniques](5-Miscellaneous-JSON-files.md#globaluniquesjson), too.
|
||||
A legitimate use of "untyped" Uniques is their use as markers that can be recognized elsewhere in **filters** (example: "Aircraft" in the vanilla rulesets used as [Unit filter](../Unique-parameters.md#baseunitfilter)).
|
||||
This use is recognized by the "Ruleset Validator" and not flagged as invalid - but a filtering Unique must also use _no placeholders or conditionals_ to pass the test.
|
||||
If you get the "not found in Unciv's unique types" warning, but are sure you are using a correct filtering Unique, please look for exactly identical spelling in all places, including upper/lower case.
|
||||
Note: Currently some mods use untyped Uniques not for filtering purposes, but as purely informational tool. The team will try to think of an approach for that use that won't trigger validation warnings without reducing validation quality, but as of now, those are unavoidable.
|
||||
|
||||
## Information on JSON files used in the game
|
||||
|
||||
|
@ -214,9 +214,6 @@ Defines uniques that apply globally. e.g. Vanilla rulesets define the effects of
|
||||
Only the `uniques` field is used, but a name must still be set (the Ruleset validator might display it).
|
||||
When extension rulesets define GlobalUniques, all uniques are merged. At the moment there is no way to change/remove uniques set by a base mod.
|
||||
|
||||
Note: Mods can use "arbitrary" Uniques as purely filtering uniques. They are not "Typed" by Unciv code and thus have no actual effect implementation - except by being filterable elsewhere.
|
||||
In the near future, the ruleset validator will show warnings for all these, unless they are also included here, as validation that they are intentional (and - they **must** have **no** placeholders or conditionals).
|
||||
|
||||
## Tutorials.json
|
||||
|
||||
[link to original](https://github.com/yairm210/Unciv/tree/master/android/assets/jsons/Tutorials.json)
|
||||
|
@ -934,16 +934,16 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
|
||||
|
||||
Applicable to: FounderBelief
|
||||
|
||||
??? example "[relativeAmount]% [stat] from every follower, up to [relativeAmount]%"
|
||||
Example: "[+20]% [Culture] from every follower, up to [+20]%"
|
||||
|
||||
Applicable to: FounderBelief, FollowerBelief
|
||||
|
||||
## FollowerBelief uniques
|
||||
!!! note ""
|
||||
|
||||
Uniques for Pantheon and Follower type beliefs, that will apply to each city where the religion is the majority religion
|
||||
|
||||
??? example "[relativeAmount]% [stat] from every follower, up to [relativeAmount]%"
|
||||
Example: "[+20]% [Culture] from every follower, up to [+20]%"
|
||||
|
||||
Applicable to: FollowerBelief
|
||||
|
||||
??? example "Earn [amount]% of [mapUnitFilter] unit's [costOrStrength] as [civWideStat] when killed within 4 tiles of a city following this religion"
|
||||
Example: "Earn [3]% of [Wounded] unit's [Cost] as [Gold] when killed within 4 tiles of a city following this religion"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user