﻿# Test whether or not the scoped character is a `crypto regula`, meaning they
# have a regula secret faith.
#
# scope = character being tested
is_crypto_regula_trigger = {
	secret_faith ?= {
		is_regula_faith_trigger = yes
	}
}

# Returns whether or not the scoped character is situated such that they might
# benefit from hiding regula faith association.
#
# Note: We perform no tests for the character's current religion or secret
# religion here. We are purely testing whether the character would have reason
# to hide being regula.
#
# scope = the character being tested
has_reason_to_hide_regula_faith_trigger = {
	OR = {
		# If no magister => Probably best to stay hidden.
		magister_alive_trigger = no

		# If magister is hiding faith => who am I to say otherwise?
		# Note: Magister being crypto-regula not yet supported.
		global_var:magister_character ?= {
			is_crypto_regula_trigger = yes
		}

		# Otherwise, considerations for my current situation.
		AND = {
			NOT = {
				# Magister is alive, not hiding faith, and we are in their
				# realm. Reveal should be safe.
				target_is_liege_or_above = global_var:magister_character
			}
			OR = {
				# If liege is hostile to magister faith it might be risky to out
				# yourself.
				liege ?= {
					faith = {
						faith_hostility_level = {
							target = global_var:magister_character.faith
							value >= faith_hostile_level
						}
					}
				}

				# If spouse is hostile to magister faith, again, might be risky to
				# be public about it.
				primary_spouse ?= {
					faith = {
						faith_hostility_level = {
							target = global_var:magister_character.faith
							value >= faith_hostile_level
						}
					}
				}
			}
		}
	}
}
