﻿# CK3 1.20 vanilla minister eligibility, with a transient Palace Coup guard.
# Keep both complete definitions in sync with 10_tgp_triggers.txt on upgrades.

tgp_can_be_a_minister_trigger = {
    # Ministry promotion can retire a governor's territorial titles. During a
    # Palace Coup handoff, retain those governors for their recorded camp and
    # let the native refill recruit only existing landless subjects instead.
    trigger_if = {
        limit = { $COURT_OWNER$ = { has_character_flag = rf_palace_coup_title_handoff } }
        is_landed = no
        NOT = { has_character_flag = rf_palace_coup_title_handoff }
    }

	can_be_councillor_basics_trigger = yes
	# Has to be celestial or a non-ruler
	OR = {
		is_ruler = no
		government_has_flag = government_is_celestial
	}
	# Gender is based on laws of the liege
	OR = {
		has_variable = can_be_councillor_override
		AND = {
			is_female = yes
			$COURT_OWNER$ = {
				NOR = {
					has_realm_law = male_only_law
					has_realm_law = male_preference_law
				}
			}
		}
		AND = {
			is_male = yes
			$COURT_OWNER$ = {
				NOR = {
					has_realm_law = female_only_law
					has_realm_law = female_preference_law
				}
			}
		}
	}
	# Players are only allowed if they have enough merit or is a councillor already, unless they are friends or disciples/elders
	# We do this to prevent the AI from "randomly" requesting the player to be on their council
	trigger_if = {
		limit = {
			is_ai = no
			$COURT_OWNER$ = { is_ai = yes }
			NOT = { is_councillor_of = $COURT_OWNER$ }
		}
		OR = {
			merit_level >= merit_level_expected_empire_value
			has_relation_friend = $COURT_OWNER$
			has_relation_disciple = $COURT_OWNER$
			has_relation_elder = $COURT_OWNER$
		}
	}
}

tgp_can_be_grand_marshal_trigger = {
    # Ministry promotion can retire a governor's territorial titles. During a
    # Palace Coup handoff, retain those governors for their recorded camp and
    # let the native refill recruit only existing landless subjects instead.
    trigger_if = {
        limit = { $COURT_OWNER$ = { has_character_flag = rf_palace_coup_title_handoff } }
        is_landed = no
        NOT = { has_character_flag = rf_palace_coup_title_handoff }
    }

	can_be_councillor_basics_trigger = yes
	# Has to be celestial or a non-ruler
	OR = {
		is_ruler = no
		government_has_flag = government_is_celestial
	}
	# Has to be able to lead armies
	can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = $COURT_OWNER$ }
}

