mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -04:00
Conditional that tests if a mod is enabled - by @SomeTroglodyte
This commit is contained in:
parent
bcf50497ab
commit
2b81172d20
@ -6,6 +6,7 @@ import com.unciv.logic.battle.CombatAction
|
||||
import com.unciv.logic.city.City
|
||||
import com.unciv.logic.civilization.Civilization
|
||||
import com.unciv.logic.civilization.managers.ReligionState
|
||||
import com.unciv.models.ruleset.validation.ModCompatibility
|
||||
import com.unciv.models.stats.Stat
|
||||
import kotlin.random.Random
|
||||
|
||||
@ -303,6 +304,11 @@ object Conditionals {
|
||||
first in second..third
|
||||
}
|
||||
|
||||
UniqueType.ConditionalModEnabled -> checkOnGameInfo {
|
||||
val filter = conditional.params[0]
|
||||
(gameParameters.mods.asSequence() + gameParameters.baseRuleset).any { ModCompatibility.modNameFilter(it, filter) }
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
@ -937,6 +937,7 @@ enum class UniqueType(
|
||||
ModIsNotAudioVisual("Cannot be used as permanent audiovisual mod", UniqueTarget.ModOptions, flags = UniqueFlag.setOfNoConditionals),
|
||||
ModMapPreselection("Mod preselects map [comment]", UniqueTarget.ModOptions, flags = UniqueFlag.setOfNoConditionals,
|
||||
docDescription = "Only meaningful for Mods containing several maps. When this mod is selected on the new game screen's custom maps mod dropdown, the named map will be selected on the map dropdown. Also disables selection by recently modified. Case insensitive."),
|
||||
ConditionalModEnabled("if [modFilter] is enabled", UniqueTarget.Conditional),
|
||||
|
||||
// endregion
|
||||
|
||||
|
@ -56,7 +56,7 @@ object ModCompatibility {
|
||||
&& mod.name.isNotBlank()
|
||||
&& !mod.modOptions.hasUnique(UniqueType.ModIsAudioVisualOnly)
|
||||
|
||||
private fun modNameFilter(modName: String, filter: String): Boolean {
|
||||
fun modNameFilter(modName: String, filter: String): Boolean {
|
||||
if (modName == filter) return true
|
||||
if (filter.length < 3 || !filter.startsWith('*') || !filter.endsWith('*')) return false
|
||||
val partialName = filter.substring(1, filter.length - 1).lowercase()
|
||||
|
Loading…
x
Reference in New Issue
Block a user