# Crown level (de jure) laws
# Laws ending with 0 will be default laws at game start

de_jure_laws = {

	# CROWN AUTHORITY

	crown_authority_0 = {
		group = crown_authority
		default = yes

		feudal_opinion = 5
		city_opinion = 5
		temple_opinion = 5

		city_vassal_min_levy = 0.00
		castle_vassal_min_levy = 0.00
		temple_vassal_min_levy = 0.00

		potential = {
			NOT = { has_dlc = "Conclave" }

			holder_scope = {
				is_tribal = no
				is_nomadic = no
			}
		}

		allow = {
			trigger_if = {
				limit = {
					OR = {
						has_law = crown_authority_0
						has_law = crown_authority_1
						has_law = crown_authority_2
						has_law = crown_authority_3
						has_law = crown_authority_4
					}
				}
				has_law = crown_authority_1
			}
		}

		pass_effect = {
			log = "crown_authority_0 pass ([This.GetFullBaseName])"
			revoke_law = crown_authority_1
			revoke_law = crown_authority_2
			revoke_law = crown_authority_3
			revoke_law = crown_authority_4
			decreased_crown_authority_effect = yes
		}

		effect = {
			log = "crown_authority_0 ([This.GetFullBaseName])"
			set_the_kings_peace = no
			set_the_kings_full_peace = no
			set_protected_inheritance = no
			set_allow_title_revokation = no
			set_allow_free_infidel_revokation = no
			# set_allow_free_revokation = no
			# set_appoint_generals = no
			# set_appoint_regents = no
		}

		ai_will_do = {
			factor = 0
		}
	}

	crown_authority_1 = {
		group = crown_authority

		feudal_opinion = -5
		city_opinion = -5
		temple_opinion = -5

		city_vassal_min_levy = 0.20
		castle_vassal_min_levy = 0.20
		temple_vassal_min_levy = 0.20

		potential = {
			is_law_potential = crown_authority_0
		}

		allow = {
			OR = {
				has_law = crown_authority_0
				has_law = crown_authority_2
			}
		}

		pass_effect = {
			log = "crown_authority_1 pass ([This.GetFullBaseName])"
			revoke_law = crown_authority_0
			revoke_law = crown_authority_2
			revoke_law = crown_authority_3
			revoke_law = crown_authority_4

			if = {
				limit = { has_law = crown_authority_0 }
				increased_crown_authority_effect = yes
			}
			else = {
				decreased_crown_authority_effect = yes
			}
		}

		effect = {
			log = "crown_authority_1 ([This.GetFullBaseName])"
			set_the_kings_peace = no
			set_the_kings_full_peace = no
			set_protected_inheritance = no
			set_allow_title_revokation = yes
			set_allow_free_infidel_revokation = no
			# set_allow_free_revokation = no
			# set_appoint_generals = yes
			# set_appoint_regents = no
		}

		ai_will_do = {
			factor = 1

			trigger = {
				has_law = crown_authority_0
			}
		}
	}

	crown_authority_2 = {
		group = crown_authority

		feudal_opinion = -10
		city_opinion = -10
		temple_opinion = -10

		city_vassal_min_levy = 0.40
		castle_vassal_min_levy = 0.40
		temple_vassal_min_levy = 0.40

		potential = {
			is_law_potential = crown_authority_0
		}

		allow = {
			OR = {
				has_law = crown_authority_1
				has_law = crown_authority_3
			}

			holder_scope = {
				show_scope_change = no

				is_republic = no

				custom_tooltip = {
					text = TT_NOT_UNREFORMED_PAGAN

					OR = {
						is_unreformed_pagan_trigger = no
						religion_openly_bon_or_reformed_trigger = yes
					}
				}
			}
		}

		pass_effect = {
			log = "crown_authority_2 pass ([This.GetFullBaseName])"
			revoke_law = crown_authority_0
			revoke_law = crown_authority_1
			revoke_law = crown_authority_3
			revoke_law = crown_authority_4

			if = {
				limit = { has_law = crown_authority_1 }
				increased_crown_authority_effect = yes
			}
			else = {
				decreased_crown_authority_effect = yes
			}
		}

		effect = {
			log = "crown_authority_2 ([This.GetFullBaseName])"
			set_the_kings_peace = yes
			set_the_kings_full_peace = no
			set_protected_inheritance = no
			set_allow_title_revokation = yes
			set_allow_free_infidel_revokation = yes
			# set_allow_free_revokation = no
			# set_appoint_generals = yes
			# set_appoint_regents = no
		}

		ai_will_do = {
			factor = 0.01

			trigger = {
				has_law = crown_authority_1
			}
		}
	}

	crown_authority_3 = {
		group = crown_authority

		feudal_opinion = -20
		city_opinion = -20
		temple_opinion = -20

		city_vassal_min_levy = 0.60
		castle_vassal_min_levy = 0.60
		temple_vassal_min_levy = 0.60

		potential = {
			is_law_potential = crown_authority_0
		}

		allow = {
			OR = {
				has_law = crown_authority_2
				has_law = crown_authority_4
			}

			holder_scope = {
				show_scope_change = no

				is_republic = no

				custom_tooltip = {
					text = TT_NOT_UNREFORMED_PAGAN

					OR = {
						is_unreformed_pagan_trigger = no
						religion_openly_bon_or_reformed_trigger = yes
					}
				}
			}
		}

		pass_effect = {
			log = "crown_authority_3 pass ([This.GetFullBaseName])"
			revoke_law = crown_authority_0
			revoke_law = crown_authority_1
			revoke_law = crown_authority_2
			revoke_law = crown_authority_4

			if = {
				limit = { has_law = crown_authority_2 }
				increased_crown_authority_effect = yes
			}
			else = {
				decreased_crown_authority_effect = yes
			}
		}

		effect = {
			log = "crown_authority_3 ([This.GetFullBaseName])"
			set_the_kings_peace = yes
			set_the_kings_full_peace = no
			set_protected_inheritance = yes
			set_allow_title_revokation = yes
			set_allow_free_infidel_revokation = yes
			# set_allow_free_revokation = no
			# set_appoint_generals = yes
			# set_appoint_regents = yes
		}

		ai_will_do = {
			factor = 0.005

			trigger = {
				has_law = crown_authority_2
				ruled_years >= 20
			}
		}
	}

	crown_authority_4 = {
		group = crown_authority

		feudal_opinion = -30
		city_opinion = -30
		temple_opinion = -30

		city_vassal_min_levy = 0.80
		castle_vassal_min_levy = 0.80
		temple_vassal_min_levy = 0.80

		potential = {
			is_law_potential = crown_authority_0
		}

		allow = {
			has_law = crown_authority_3

			holder_scope = {
				show_scope_change = no

				is_republic = no

				custom_tooltip = {
					text = TT_NOT_UNREFORMED_PAGAN

					OR = {
						is_unreformed_pagan_trigger = no
						religion_openly_bon_or_reformed_trigger = yes
					}
				}
			}
		}

		pass_effect = {
			log = "crown_authority_4 pass ([This.GetFullBaseName])"
			revoke_law = crown_authority_0
			revoke_law = crown_authority_1
			revoke_law = crown_authority_2
			revoke_law = crown_authority_3
			increased_crown_authority_effect = yes
		}

		effect = {
			log = "crown_authority_4 ([This.GetFullBaseName])"
			set_the_kings_peace = yes
			set_the_kings_full_peace = yes
			set_protected_inheritance = yes
			set_allow_title_revokation = yes
			set_allow_free_infidel_revokation = yes
			# set_allow_free_revokation = yes
			# set_appoint_generals = yes
			# set_appoint_regents = yes
		}

		ai_will_do = {
			factor = 0.001

			trigger = {
				has_law = crown_authority_3
				ruled_years >= 20
			}
		}
	}

	# INVESTITURE

	# Papal Investiture
	investiture_law_0 = {
		group = investiture_law

		potential = {
			holder_scope = {
				show_scope_change = no

				OR = {
					religion = catholic
					religion = fraticelli
				}

				is_tribal = no
				is_nomadic = no
				NOT = { rightful_religious_head = THIS }
			}
		}

		allow = {
			year >= 1000
		}

		pass_effect = {
			log = "investiture_law_0 ([This.GetFullBaseName])"
			revoke_law = investiture_law_1
		}

		effect = {
			log = "investiture_law_0 pass ([This.GetFullBaseName])"
			set_investiture = head
		}

		ai_will_do = {
			factor = 0
		}

		default_selection = {
			factor = 1
		}
	}

	# Free Investiture
	investiture_law_1 = {
		group = investiture_law

		rel_head_opinion = -30
		free_invest_vassal_opinion = 10 # vassals with bishops will appreciate this law
		temple_all_opinion = 10 # Bishops will tend to be more loyal to the Crown

		potential = {
			is_law_potential = investiture_law_0
		}

		allow = {
			holy_order = no
		}

		pass_effect = {
			log = "investiture_law_1 ([This.GetFullBaseName])"
			revoke_law = investiture_law_0
		}

		effect = {
			log = "investiture_law_1 pass ([This.GetFullBaseName])"
			set_investiture = any
		}

		ai_will_do = {
			factor = 0.002 # Rare to do this

			trigger = {
				holder_scope = {
					trait = cynical
				}
			}
		}

		default_selection = {
			factor = 1
		}
	}
}