Added "Can only start games from the starting era" conditional, "if [buildingFilter] is not constructed" unique

This commit is contained in:
yairm210 2024-07-11 16:34:03 +03:00
parent 2b752866bf
commit b58b73a790
5 changed files with 17 additions and 2 deletions

View File

@ -26,7 +26,6 @@ object DeclareWar {
internal fun declareWar(diplomacyManager: DiplomacyManager, declareWarReason: DeclareWarReason) {
val civInfo = diplomacyManager.civInfo
val otherCiv = diplomacyManager.otherCiv()
if (otherCiv.isDefeated()) throw Exception("Tried to declare war on a defeated civ!")
val otherCivDiplomacy = diplomacyManager.otherCivDiplomacy()
if (otherCiv.isCityState && declareWarReason.warType == WarType.DirectWar)

View File

@ -171,6 +171,8 @@ object Conditionals {
UniqueType.ConditionalBuildingBuilt ->
checkOnCiv { cities.any { it.cityConstructions.containsBuildingOrEquivalent(conditional.params[0]) } }
UniqueType.ConditionalBuildingNotBuilt ->
checkOnCiv { cities.none { it.cityConstructions.containsBuildingOrEquivalent(conditional.params[0]) } }
UniqueType.ConditionalBuildingBuiltAll ->
checkOnCiv { cities.filter { it.matchesFilter(conditional.params[1]) }.all {
it.cityConstructions.containsBuildingOrEquivalent(conditional.params[0]) } }

View File

@ -706,6 +706,7 @@ enum class UniqueType(
ConditionalAfterGeneratingGreatProphet("after generating a Great Prophet", UniqueTarget.Conditional),
ConditionalBuildingBuilt("if [buildingFilter] is constructed", UniqueTarget.Conditional),
ConditionalBuildingNotBuilt("if [buildingFilter] is not constructed", UniqueTarget.Conditional),
ConditionalBuildingBuiltAll("if [buildingFilter] is constructed in all [cityFilter] cities", UniqueTarget.Conditional),
ConditionalBuildingBuiltAmount("if [buildingFilter] is constructed in at least [positiveAmount] of [cityFilter] cities", UniqueTarget.Conditional),
ConditionalBuildingBuiltByAnybody("if [buildingFilter] is constructed by anybody", UniqueTarget.Conditional),
@ -911,6 +912,7 @@ enum class UniqueType(
AllowCityStatesSpawnUnits("Allow City States to spawn with additional units", UniqueTarget.ModOptions, flags = UniqueFlag.setOfNoConditionals),
TradeCivIntroductions("Can trade civilization introductions for [positiveAmount] Gold", UniqueTarget.ModOptions, flags = UniqueFlag.setOfNoConditionals),
DisableReligion("Disable religion", UniqueTarget.ModOptions, flags = UniqueFlag.setOfNoConditionals),
CanOnlyStartFromStartingEra("Can only start games from the starting era", UniqueTarget.ModOptions, flags = UniqueFlag.setOfNoConditionals),
AllowRazeCapital("Allow raze capital", UniqueTarget.ModOptions, flags = UniqueFlag.setOfNoConditionals),
AllowRazeHolyCity("Allow raze holy city", UniqueTarget.ModOptions, flags = UniqueFlag.setOfNoConditionals),
@ -1385,6 +1387,6 @@ enum class UniqueType(
targetTypes.any { uniqueTarget.canAcceptUniqueTarget(it) }
companion object {
val uniqueTypeMap: Map<String, UniqueType> = UniqueType.values().associateBy { it.placeholderText }
val uniqueTypeMap: Map<String, UniqueType> = entries.associateBy { it.placeholderText }
}
}

View File

@ -408,6 +408,10 @@ class GameOptionsTable(
private fun Table.addEraSelectBox() {
if (ruleset.eras.isEmpty()) return // mod with no techs
if (ruleset.modOptions.hasUnique(UniqueType.CanOnlyStartFromStartingEra)){
gameParameters.startingEra = ruleset.eras.keys.first()
return
}
val eras = ruleset.eras.keys
addSelectBox("{Starting Era}:", eras, gameParameters.startingEra)
{ gameParameters.startingEra = it; null }

View File

@ -2622,6 +2622,9 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
??? example "Disable religion"
Applicable to: ModOptions
??? example "Can only start games from the default era"
Applicable to: ModOptions
??? example "Allow raze capital"
Applicable to: ModOptions
@ -2842,6 +2845,11 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Applicable to: Conditional
??? example "&lt;if [buildingFilter] is not constructed&gt;"
Example: "&lt;if [Culture] is not constructed&gt;"
Applicable to: Conditional
??? example "&lt;if [buildingFilter] is constructed in all [cityFilter] cities&gt;"
Example: "&lt;if [Culture] is constructed in all [in all cities] cities&gt;"