﻿
#####################################################################
# EFFECT LIST
#####################################################################

increase_crown_authority_effect = {
	if = {
		limit = { has_realm_law_flag = uses_crown_authority }
		#Laws
		if = {
			limit = { has_realm_law = crown_authority_0 }
			add_realm_law = crown_authority_1
		}
		else_if = {
			limit = { has_realm_law = crown_authority_1 }
			add_realm_law = crown_authority_2
		}
		else_if = {
			limit = { has_realm_law = crown_authority_2 }
			add_realm_law = crown_authority_3
		}
	}
}

decrease_crown_authority_effect = {
	if = {
		limit = { has_realm_law_flag = uses_crown_authority }
		#Laws
		if = {
			limit = { has_realm_law = crown_authority_3 }
			add_realm_law = crown_authority_2
		}
		else_if = {
			limit = { has_realm_law = crown_authority_2 }
			add_realm_law = crown_authority_1
		}
		else_if = {
			limit = { has_realm_law = crown_authority_1 }
			add_realm_law = crown_authority_0
		}
	}
}

increase_tribal_authority_effect = {
	if = {
		limit = { has_realm_law_flag = uses_tribal_authority }
		#Laws
		if = {
			limit = { has_realm_law = tribal_authority_0 }
			add_realm_law = tribal_authority_1
		}
		else_if = {
			limit = { has_realm_law = tribal_authority_1 }
			add_realm_law = tribal_authority_2
		}
		else_if = {
			limit = { has_realm_law = tribal_authority_2 }
			add_realm_law = tribal_authority_3
		}
	}
}

decrease_tribal_authority_effect = {
	if = {
		limit = { has_realm_law_flag = uses_tribal_authority }
		#Laws
		if = {
			limit = { has_realm_law = tribal_authority_3 }
			add_realm_law = tribal_authority_2
		}
		else_if = {
			limit = { has_realm_law = tribal_authority_2 }
			add_realm_law = tribal_authority_1
		}
		else_if = {
			limit = { has_realm_law = tribal_authority_1 }
			add_realm_law = tribal_authority_0
		}
	}
}

increase_imperial_bureaucracy_effect = {
	if = {
		limit = { has_realm_law_flag = uses_imperial_bureaucracy }
		#Laws
		if = {
			limit = { has_realm_law = imperial_bureaucracy_0 }
			add_realm_law = imperial_bureaucracy_1
		}
		else_if = {
			limit = { has_realm_law = imperial_bureaucracy_1 }
			add_realm_law = imperial_bureaucracy_2
		}
		else_if = {
			limit = { has_realm_law = imperial_bureaucracy_2 }
			add_realm_law = imperial_bureaucracy_3
		}
	}
}

decrease_imperial_bureaucracy_effect = {
	if = {
		limit = { has_realm_law_flag = uses_imperial_bureaucracy }
		#Laws
		if = {
			limit = { has_realm_law = imperial_bureaucracy_3 }
			add_realm_law = imperial_bureaucracy_2
		}
		else_if = {
			limit = { has_realm_law = imperial_bureaucracy_2 }
			add_realm_law = imperial_bureaucracy_1
		}
		else_if = {
			limit = { has_realm_law = imperial_bureaucracy_1 }
			add_realm_law = imperial_bureaucracy_0
		}
	}
}

# We use this rather than doing it straight in the effect block for better mod compatibility, since this can be overridden without adjusting the rest of the laws file.
remove_law_related_modifiers_effect = {
	# We call out some modifiers because we want the player to see what they're losing, but it's fine to hide future modifiers ye may add in a hidden_effect if they're minor.
	if = {
		limit = { has_character_modifier = liege_authority_boost_has_scapegoat_modifier }
		remove_character_modifier = liege_authority_boost_has_scapegoat_modifier
	}
}

remove_vassal_directives = {
	remove_character_flag = vassal_directive_improve_development
	remove_character_flag = vassal_directive_train_commanders
	remove_character_flag = vassal_directive_build_maa
	remove_character_flag = vassal_directive_convert_faith
	remove_character_flag = vassal_directive_convert_culture
	remove_character_flag = vassal_directive_improve_cultural_acceptance
	remove_character_flag = vassal_directive_building_focus_fortification
	remove_character_flag = vassal_directive_building_focus_military
	remove_character_flag = vassal_directive_building_focus_economy
	remove_character_flag = vassal_directive_manage_fertility
	remove_character_flag = vassal_directive_explore_cultures
	remove_character_flag = vassal_directive_raid_innovation_intent
	remove_character_flag = vassal_directive_raid_herd_intent
}

increase_nomadic_authority_effect = {
	if = {
		limit = { has_realm_law_flag = uses_nomadic_authority }
		#Laws
		if = {
			limit = { has_realm_law = nomadic_authority_1 }
			add_realm_law = nomadic_authority_2
		}
		else_if = {
			limit = { has_realm_law = nomadic_authority_2 }
			add_realm_law = nomadic_authority_3
		}
		else_if = {
			limit = { has_realm_law = nomadic_authority_3 }
			add_realm_law = nomadic_authority_4
		}
	}
}

decrease_nomadic_authority_effect = {
	if = {
		limit = { has_realm_law_flag = uses_nomadic_authority }
		#Laws
		if = {
			limit = { has_realm_law = nomadic_authority_4 }
			add_realm_law = nomadic_authority_3
		}
		else_if = {
			limit = { has_realm_law = nomadic_authority_3 }
			add_realm_law = nomadic_authority_2
		}
		else_if = {
			limit = { has_realm_law = nomadic_authority_2 }
			add_realm_law = nomadic_authority_1
		}
	}
}

# Should be used in the county title scope
add_law_of_the_land_title_succession_law_if_appropriate_effect = {
	save_scope_as = county_title
	if = {
		limit = {
			#tier = tier_county # Commented out for performance reasons, comment back in if this effect is used outside of on_title_gained
			NOT = { has_title_law = law_of_the_land_succession_law }
			is_noble_family_title = no
			title_province ?= {
				holding_type = {
					has_required_heir_governments = yes
					NOT = {
						any_required_heir_government_type = {
							this = scope:county_title.holder.government_type
						}
					}
				}
			}
		}
		holder = {
			send_interface_toast = {
				title = succession_law_changed
				left_icon = scope:county_title

				scope:county_title = { add_title_law = law_of_the_land_succession_law }
			}
		}
	}
}
