# Written by:
# Linna Thimrn

decisions = {

	court_exodus = {
		ai_check_interval = 12

		is_high_prio = yes

		only_playable = yes

		potential = {
			has_full_court = yes

			has_game_rule = {
				name = court_limit_rule
				value = on
			}
		}

		allow = {
			prisoner = no

			custom_tooltip = {
				text = exodus_court_allow_tooltip

				any_courtier = {
					count >= 3

					courtier_is_mass_expellable = yes

					trigger_if = {
						limit = { is_married = yes }

						NOT = {
							any_spouse = {
								courtier_is_mass_expellable = no
							}
						}
					}

					trigger_if = {
						limit = { has_living_children = yes }

						NOT = {
							any_child = {
								OR = {
									is_child_of = ROOT
									dynasty = ROOT
									important_character_to_root_trigger = yes
								}
							}
						}
					}
				}
			}

			custom_tooltip = {
				text = already_exodus_tooltip

				NOT = { has_character_flag = started_court_exodus }
			}
		}

		effect = {
			set_character_flag = started_court_exodus
			character_event = { id = LT.61008 }

			tooltip = {
				scaled_wealth = {
					value = -0.02
					min = -5
					max = -45
				}
			}
		}

		ai_will_do = {
			factor = 0.75

			mult_modifier = {
				factor = 1.12
				court_is_min_crowded_trigger = yes
			}

			mult_modifier = {
				factor = 1.5
				court_is_mid_crowded_trigger = yes
			}

			mult_modifier = {
				factor = 1.75
				court_is_max_crowded_trigger = yes
			}
		}
	}

}