mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 15:01:09 -04:00
Implemented holy warriors follower belief (#5411)
* Implemented holy warriors follower belief * Minor fixes * Likely fixed the tests * Made someTroglodyte happy :) * Removed stray println's * Implemented requested changes
This commit is contained in:
parent
de0c1161f6
commit
551e6e1d54
@ -151,7 +151,11 @@
|
||||
"type": "Follower",
|
||||
"uniques": ["[+2 Production] <if this city has at least [1] specialists>"]
|
||||
},
|
||||
// ToDo: Holy Warriors (I have to look up the faith costs for these sometime)
|
||||
{
|
||||
"name": "Holy Warriors",
|
||||
"type": "Follower",
|
||||
"uniques": ["May buy [{Military} {Land}] units with [Faith] for [2] times their normal Production cost <before the [Industrial era]>"]
|
||||
},
|
||||
{
|
||||
"name": "Liturgical Drama",
|
||||
"type": "Follower",
|
||||
|
@ -267,7 +267,7 @@
|
||||
{
|
||||
"name": "Commerce Complete",
|
||||
"uniques": ["[+1 Gold] from every [Trading post]", "Double gold from Great Merchant trade missions",
|
||||
"May buy [Great Merchant] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] starting from the [Industrial era] at an increasing price ([500])"
|
||||
"May buy [Great Merchant] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
|
||||
]
|
||||
}
|
||||
]
|
||||
@ -314,7 +314,7 @@
|
||||
{
|
||||
"name": "Rationalism Complete",
|
||||
"uniques": ["[2] Free Technologies",
|
||||
"May buy [Great Scientist] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] starting from the [Industrial era] at an increasing price ([500])"
|
||||
"May buy [Great Scientist] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
|
||||
]
|
||||
}
|
||||
]
|
||||
@ -359,7 +359,7 @@
|
||||
{
|
||||
"name": "Freedom Complete",
|
||||
"uniques": ["+[100]% yield from every [Great Improvement]", "Golden Age length increased by [50]%",
|
||||
"May buy [Great Artist] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] starting from the [Industrial era] at an increasing price ([500])"
|
||||
"May buy [Great Artist] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
|
||||
]
|
||||
}
|
||||
]
|
||||
@ -407,8 +407,8 @@
|
||||
{
|
||||
"name": "Autocracy Complete",
|
||||
"uniques": ["+[25]% attack strength to all [Military] units for [50] turns",
|
||||
"May buy [Great General] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] starting from the [Industrial era] at an increasing price ([500])",
|
||||
"May buy [Great Admiral] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] starting from the [Industrial era] at an increasing price ([500])"
|
||||
"May buy [Great General] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>",
|
||||
"May buy [Great Admiral] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
|
||||
]
|
||||
}
|
||||
]
|
||||
@ -453,7 +453,7 @@
|
||||
{
|
||||
"name": "Order Complete",
|
||||
"uniques": ["[+2 Food, +2 Production, +2 Science, +2 Gold, +2 Culture] [in all cities]",
|
||||
"May buy [Great Engineer] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] starting from the [Industrial era] at an increasing price ([500])"
|
||||
"May buy [Great Engineer] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -507,7 +507,6 @@ Check extension mods based on vanilla =
|
||||
Checking mods for errors... =
|
||||
Show experimental world wrap for maps =
|
||||
HIGHLY EXPERIMENTAL - YOU HAVE BEEN WARNED! =
|
||||
HIGHLY EXPERIMENTAL - UPDATES WILL BREAK SAVES! =
|
||||
Enable portrait orientation =
|
||||
Generate translation files =
|
||||
Translation files are generated successfully. =
|
||||
|
@ -150,6 +150,8 @@ object ChooseBeliefsAutomation {
|
||||
// This is something completely different from the original, but I have no idea
|
||||
// what happens over there
|
||||
else civInfo.statsForNextTurn[Stat.valueOf(unique.params[1])] * 10f / civInfo.getEra().baseUnitBuyCost
|
||||
UniqueType.BuyUnitsByProductionCost.placeholderText ->
|
||||
15f * if (civInfo.victoryType() == VictoryType.Domination) 2f else 1f
|
||||
"when a city adopts this religion for the first time (modified by game speed)" -> // Modified by personality
|
||||
unique.stats.values.sum() * 10f
|
||||
"When spreading religion to a city, gain [] times the amount of followers of other religions as []" ->
|
||||
@ -160,7 +162,7 @@ object ChooseBeliefsAutomation {
|
||||
unique.params[0].toInt() / 7f
|
||||
"[] for each global city following this religion" ->
|
||||
50f / unique.stats.values.sum()
|
||||
"whenever a Great Person is expended" ->
|
||||
UniqueType.StatsSpendingGreatPeople.placeholderText ->
|
||||
unique.stats.values.sum() / 2f
|
||||
"[]% Natural religion spread to []" ->
|
||||
unique.params[0].toFloat() / 4f
|
||||
|
@ -716,18 +716,10 @@ class CityInfo {
|
||||
// Finds matching uniques provided from both local and non-local sources.
|
||||
fun getMatchingUniques(
|
||||
uniqueType: UniqueType,
|
||||
// We might have this cached to avoid concurrency problems. If we don't, just get it directly
|
||||
localUniques: Sequence<Unique> = getLocalMatchingUniques(uniqueType),
|
||||
stateForConditionals: StateForConditionals? = null,
|
||||
): Sequence<Unique> {
|
||||
// The localUniques might not be filtered when passed as a parameter, so we filter it anyway
|
||||
// The time loss shouldn't be that large I don't think
|
||||
return civInfo.getMatchingUniques(uniqueType, stateForConditionals, this) +
|
||||
localUniques.filter {
|
||||
it.isOfType(uniqueType)
|
||||
&& it.conditionalsApply(stateForConditionals)
|
||||
&& it.params.none { param -> param == "in other cities" }
|
||||
}
|
||||
getLocalMatchingUniques(uniqueType, stateForConditionals)
|
||||
}
|
||||
|
||||
// Matching uniques provided by sources in the city itself
|
||||
|
@ -1051,6 +1051,7 @@ class MapUnit {
|
||||
if (filter.contains('{')) // multiple types at once - AND logic. Looks like:"{Military} {Land}"
|
||||
return filter.removePrefix("{").removeSuffix("}").split("} {")
|
||||
.all { matchesFilter(it) }
|
||||
|
||||
return when (filter) {
|
||||
// todo: unit filters should be adjectives, fitting "[filterType] units"
|
||||
// This means converting "wounded units" to "Wounded", "Barbarians" to "Barbarian"
|
||||
|
@ -564,7 +564,10 @@ class Ruleset {
|
||||
}
|
||||
for (nation in nations.values) {
|
||||
checkUniques(nation, lines, UniqueType.UniqueComplianceErrorSeverity.RulesetSpecific)
|
||||
if (nation.favoredReligion != null && nation.favoredReligion !in religions)
|
||||
lines += "${nation.name} has ${nation.favoredReligion} as their favored religion, which does not exist!"
|
||||
}
|
||||
|
||||
for (policy in policies.values) {
|
||||
if (policy.requires != null)
|
||||
for (prereq in policy.requires!!)
|
||||
|
@ -51,6 +51,12 @@ class Unique(val text: String, val sourceObjectType: UniqueTarget? = null, val s
|
||||
state.civInfo != null && state.civInfo.statsForNextTurn.happiness >= 0
|
||||
UniqueType.ConditionalGoldenAge ->
|
||||
state.civInfo != null && state.civInfo.goldenAges.isGoldenAge()
|
||||
UniqueType.ConditionalBeforeEra ->
|
||||
state.civInfo != null && state.civInfo.getEraNumber() < state.civInfo.gameInfo.ruleSet.eras[condition.params[0]]!!.eraNumber
|
||||
UniqueType.ConditionalStartingFromEra ->
|
||||
state.civInfo != null && state.civInfo.getEraNumber() >= state.civInfo.gameInfo.ruleSet.eras[condition.params[0]]!!.eraNumber
|
||||
UniqueType.ConditionalDuringEra ->
|
||||
state.civInfo != null && state.civInfo.getEraNumber() == state.civInfo.gameInfo.ruleSet.eras[condition.params[0]]!!.eraNumber
|
||||
|
||||
UniqueType.ConditionalSpecialistCount ->
|
||||
state.cityInfo != null && state.cityInfo.population.getNumberOfSpecialists() >= condition.params[0].toInt()
|
||||
|
@ -78,6 +78,8 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
|
||||
|
||||
StatsPerPopulation("[stats] per [amount] population [cityFilter]", UniqueTarget.Global),
|
||||
|
||||
StatsSpendingGreatPeople("[stats] whenever a Great Person is expended", UniqueTarget.Global),
|
||||
|
||||
/////// City-State related uniques
|
||||
|
||||
// I don't like the fact that currently "city state bonuses" are separate from the "global bonuses",
|
||||
@ -104,10 +106,8 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
|
||||
@Deprecated("As of 3.16.16", ReplaceWith("[amount]% maintenance costs for [mapUnitFilter] units"), DeprecationLevel.WARNING)
|
||||
DecreasedUnitMaintenanceCostsGlobally("-[amount]% unit upkeep costs", UniqueTarget.Global),
|
||||
|
||||
ConsumesResources("Consumes [amount] [resource]",
|
||||
UniqueTarget.Improvement, UniqueTarget.Building, UniqueTarget.Unit),
|
||||
ProvidesResources("Provides [amount] [resource]",
|
||||
UniqueTarget.Improvement, UniqueTarget.Building),
|
||||
ConsumesResources("Consumes [amount] [resource]", UniqueTarget.Improvement, UniqueTarget.Building, UniqueTarget.Unit),
|
||||
ProvidesResources("Provides [amount] [resource]", UniqueTarget.Improvement, UniqueTarget.Building),
|
||||
|
||||
GrowthPercentBonus("[amount]% growth [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
@Deprecated("As of 3.16.14", ReplaceWith("[amount]% growth [cityFilter]"), DeprecationLevel.WARNING)
|
||||
@ -122,6 +122,11 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
|
||||
FreeExtraBeliefs("May choose [amount] additional [beliefType] beliefs when [foundingOrEnhancing] a religion", UniqueTarget.Global),
|
||||
FreeExtraAnyBeliefs("May choose [amount] additional belief(s) of any type when [foundingOrEnhancing] a religion", UniqueTarget.Global),
|
||||
|
||||
BuyUnitsIncreasingCost("May buy [baseUnitFilter] units for [amount] [stat] [cityFilter] at an increasing price ([amount])", UniqueTarget.Global),
|
||||
@Deprecated("As of 3.17.9", ReplaceWith ("May buy [baseUnitFilter] units for [amount] [stat] [cityFilter] at an increasing price ([amount]) <starting from the [era]>"))
|
||||
BuyUnitsIncreasingCostEra("May buy [baseUnitFilter] units for [amount] [stat] [cityFilter] starting from the [era] at an increasing price ([amount])", UniqueTarget.Global),
|
||||
BuyUnitsByProductionCost("May buy [baseUnitFilter] units with [stat] for [amount] times their normal Production cost", UniqueTarget.FollowerBelief, UniqueTarget.Global),
|
||||
|
||||
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),
|
||||
|
||||
@ -213,7 +218,7 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
|
||||
|
||||
HiddenWithoutReligion("Hidden when religion is disabled", UniqueTarget.Unit, UniqueTarget.Building, UniqueTarget.Ruins),
|
||||
|
||||
//////////////////////////////////////// TERRAIN UNIQUES ////////////////////////////////////////
|
||||
///////////////////////////////////////// TILE UNIQUES /////////////////////////////////////////
|
||||
|
||||
|
||||
NaturalWonderNeighborCount("Must be adjacent to [amount] [simpleTerrain] tiles", UniqueTarget.Terrain),
|
||||
@ -246,6 +251,10 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
|
||||
ConditionalHappy("while the empire is happy", UniqueTarget.Conditional),
|
||||
ConditionalGoldenAge("during a Golden Age", UniqueTarget.Conditional),
|
||||
|
||||
ConditionalDuringEra("during the [era]", UniqueTarget.Conditional),
|
||||
ConditionalBeforeEra("before the [era]", UniqueTarget.Conditional),
|
||||
ConditionalStartingFromEra("starting from the [era]", UniqueTarget.Conditional),
|
||||
|
||||
// city conditionals
|
||||
ConditionalSpecialistCount("if this city has at least [amount] specialists", UniqueTarget.Conditional),
|
||||
|
||||
@ -265,6 +274,7 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
|
||||
|
||||
///////////////////////////////////////// TRIGGERED ONE-TIME /////////////////////////////////////////
|
||||
|
||||
|
||||
OneTimeFreeUnit("Free [baseUnitFilter] appears", UniqueTarget.Global), // used in Policies, Buildings
|
||||
OneTimeAmountFreeUnits("[amount] free [baseUnitFilter] units appear", UniqueTarget.Global), // used in Buildings
|
||||
OneTimeFreeUnitRuins("Free [baseUnitFilter] found in the ruins", UniqueTarget.Ruins), // Differs from "Free [] appears" in that it spawns near the ruins instead of in a city
|
||||
|
@ -6,6 +6,7 @@ import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.models.ruleset.Ruleset
|
||||
import com.unciv.models.ruleset.RulesetObject
|
||||
import com.unciv.models.ruleset.unique.StateForConditionals
|
||||
import com.unciv.models.ruleset.unique.UniqueTarget
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.stats.Stat
|
||||
@ -250,7 +251,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
|
||||
override fun canBePurchasedWithStat(cityInfo: CityInfo?, stat: Stat): Boolean {
|
||||
// May buy [unitFilter] units for [amount] [Stat] [cityFilter] starting from the [eraName] at an increasing price ([amount])
|
||||
if (cityInfo != null && cityInfo.civInfo.getMatchingUniques("May buy [] units for [] [] [] starting from the [] at an increasing price ([])")
|
||||
if (cityInfo != null && cityInfo.getMatchingUniques("May buy [] units for [] [] [] starting from the [] at an increasing price ([])")
|
||||
.any {
|
||||
matchesFilter(it.params[0])
|
||||
&& cityInfo.matchesFilter(it.params[3])
|
||||
@ -260,7 +261,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
) return true
|
||||
|
||||
// May buy [unitFilter] units for [amount] [Stat] [cityFilter] at an increasing price ([amount])
|
||||
if (cityInfo != null && cityInfo.civInfo.getMatchingUniques("May buy [] units for [] [] [] at an increasing price ([])")
|
||||
if (cityInfo != null && cityInfo.getMatchingUniques("May buy [] units for [] [] [] at an increasing price ([])")
|
||||
.any {
|
||||
matchesFilter(it.params[0])
|
||||
&& cityInfo.matchesFilter(it.params[3])
|
||||
@ -268,6 +269,15 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
}
|
||||
) return true
|
||||
|
||||
if (cityInfo != null && cityInfo.getMatchingUniques(
|
||||
UniqueType.BuyUnitsByProductionCost,
|
||||
stateForConditionals = StateForConditionals(civInfo = cityInfo.civInfo, cityInfo = cityInfo)
|
||||
).any {
|
||||
matchesFilter(it.params[0])
|
||||
&& it.params[1] == stat.name
|
||||
}
|
||||
) return true
|
||||
|
||||
return super.canBePurchasedWithStat(cityInfo, stat)
|
||||
}
|
||||
|
||||
@ -277,10 +287,11 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
|
||||
override fun getBaseBuyCost(cityInfo: CityInfo, stat: Stat): Int? {
|
||||
if (stat == Stat.Gold) return getBaseGoldCost(cityInfo.civInfo).toInt()
|
||||
val conditionalState = StateForConditionals(civInfo = cityInfo.civInfo, cityInfo = cityInfo)
|
||||
return (
|
||||
sequenceOf(super.getBaseBuyCost(cityInfo, stat)).filterNotNull()
|
||||
// May buy [unitFilter] units for [amount] [Stat] starting from the [eraName] at an increasing price ([amount])
|
||||
+ (cityInfo.civInfo.getMatchingUniques("May buy [] units for [] [] [] starting from the [] at an increasing price ([])")
|
||||
// Deprecated since 3.17.9
|
||||
+ (cityInfo.getMatchingUniques(UniqueType.BuyUnitsIncreasingCostEra, conditionalState)
|
||||
.filter {
|
||||
matchesFilter(it.params[0])
|
||||
&& cityInfo.matchesFilter(it.params[3])
|
||||
@ -294,7 +305,8 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
)
|
||||
}
|
||||
)
|
||||
+ (cityInfo.civInfo.getMatchingUniques("May buy [] units for [] [] [] at an increasing price ([])")
|
||||
//
|
||||
+ (cityInfo.getMatchingUniques(UniqueType.BuyUnitsIncreasingCost, conditionalState)
|
||||
.filter {
|
||||
matchesFilter(it.params[0])
|
||||
&& cityInfo.matchesFilter(it.params[3])
|
||||
@ -307,6 +319,15 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
)
|
||||
}
|
||||
)
|
||||
+ (cityInfo.getMatchingUniques(
|
||||
UniqueType.BuyUnitsByProductionCost, conditionalState
|
||||
).filter {
|
||||
it.params[1] == stat.name
|
||||
&& matchesFilter(it.params[0])
|
||||
}.map {
|
||||
getProductionCost(cityInfo.civInfo) * it.params[2].toInt()
|
||||
}
|
||||
)
|
||||
).minOrNull()
|
||||
}
|
||||
|
||||
@ -493,6 +514,9 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
}
|
||||
|
||||
fun matchesFilter(filter: String): Boolean {
|
||||
if (filter.contains('{')) // multiple types at once - AND logic. Looks like:"{Military} {Land}"
|
||||
return filter.removePrefix("{").removeSuffix("}").split("} {")
|
||||
.all { matchesFilter(it) }
|
||||
|
||||
return when (filter) {
|
||||
unitType -> true
|
||||
|
@ -213,7 +213,7 @@ class Translations : LinkedHashMap<String, TranslationEntry>(){
|
||||
// Whenever this string is changed, it should also be changed in the translation files!
|
||||
// It is mostly used as the template for translating the order of conditionals
|
||||
const val englishConditionalOrderingString =
|
||||
"<for [mapUnitFilter] units> <vs cities> <vs [mapUnitFilter] units> <when fighting in [tileFilter] tiles> <when attacking> <when defending> <if this city has at least [amount] specialists> <when at war> <when not at war> <while the empire is happy> <during a Golden Age>"
|
||||
"<for [mapUnitFilter] units> <vs cities> <vs [mapUnitFilter] units> <when fighting in [tileFilter] tiles> <when attacking> <when defending> <if this city has at least [amount] specialists> <when at war> <when not at war> <while the empire is happy> <during a Golden Age> <during the [era]> <before the [era]> <starting from the [era]>"
|
||||
const val conditionalUniqueOrderString = "ConditionalsPlacement"
|
||||
const val shouldCapitalizeString = "StartWithCapitalLetter"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user