#Written by:
#Linnéa Thimrén

decisions = {

	court_exodus = {
		is_high_prio = yes
		ai_check_interval = 12 #check only once every 12 months.
		only_playable = yes

		potential = {
			has_game_rule = {
	            name = court_limit_rule
	            value = on
	        }
			has_full_court = yes
	        is_ruler = yes
	    	any_courtier = {
	    		prisoner = no
		    	is_adult = yes
		    	is_landed = no
		    	important_character_to_root_trigger = no
		    	trigger_if = {
		    		limit = { is_married = yes }
	    			any_spouse = { is_landed = no }
		    	}
		    	trigger_if = {
		    		limit = { any_child = { always = yes } }
		    		any_child = { 
		    			NOR = {
		    				is_child_of = root
		    				important_character_to_root_trigger = yes
		    			}
		    		}
		    	}
		    	count = 3
	    	}
		}
		allow = {
			prisoner = no
			custom_tooltip = {
				text = exodus_court_allow_tooltip
				hidden_tooltip = {
					has_full_court = yes
					any_courtier = {
			    		prisoner = no
				    	is_adult = yes
				    	is_landed = no
				    	important_character_to_root_trigger = no
				    	trigger_if = {
				    		limit = { is_married = yes }
			    			any_spouse = { is_landed = no }
				    	}
				    	trigger_if = {
				    		limit = { any_child = { always = yes } }
				    		any_child = { 
				    			NOR = {
				    				is_child_of = root
				    				important_character_to_root_trigger = yes
				    			}
				    		}
				    	}
				    	count = 3
			    	}
				}
			}
			custom_tooltip = {
				NOT = { has_character_flag = started_court_exodus }
				text = already_exodus_tooltip
			}
		}
		effect = {
			set_character_flag = started_court_exodus
			character_event = { id = LT.61008 }
			tooltip = {
				scaled_wealth = {
	    		    value = -0.02
	    		    min = -5
	    		    max = -45
	    		}
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0.75
			modifier = {
				factor = 1.12
				court_is_min_crowded_trigger = yes
			}
			modifier = {
				factor = 1.5
				court_is_mid_crowded_trigger = yes
			}
			modifier = {
				factor = 1.75
				court_is_max_crowded_trigger = yes
			}
		}
	}
}