#######################
# written by Aetherum #
#######################

############################################################
# some parts are written by Ruben and modified by Aetherum #
############################################################

############################################################
# some parts are written by Imerator Orbis Terrarum Primus #
############################################################

#############################################################
# the creation of some parts was inspired by truelove101992 #
#############################################################

country_decisions = {

    form_hre_1 = {
	    major = yes
		potential = {
		OR = {
		religion = catholic
		religion = anglican
		religion = protestant
		religion = reformed
		religion = orthodox
		religion = coptic
		}
		
		NOT = { exists = HLR }
		NOT = { tag = PAP }
		NOT = { tag = ROM }
		NOT = { tag = ROW }
		NOT = { tag = BYZ }
		NOT = { tag = HRE }
		
        OR = {
		owns = 118 
		owns = 134
		owns = 266
		owns = 50
		owns = 85
		owns = 1876
		owns = 104
		}
		}
		allow = {
        owns = 118 
		owns = 134
		owns = 266
		owns = 50
		owns = 85
		owns = 1876
		owns = 104
		}
		effect = {
		change_tag = HLR
		if = {
				limit = {
					NOT = { government_rank = 3 }
				}
				set_government_rank = 3
			}
	    }
		ai_will_do = {
			factor = 1
		}
    }
	
	hre_emperor = {
	    major = yes
		potential = {
		OR = {
		tag = HLR
	    AND = {
		owns = 118 
		owns = 134
		owns = 266
		owns = 50
		owns = 85
		owns = 1876
		owns = 104
		}
		}
		NOT = { has_country_modifier = HRE }
		}
		allow = {
		OR = {
        tag = HLR
		AND = {
		owns = 118 
		owns = 134
		owns = 50
		}
		}
		}
		effect = {
		add_country_modifier = {
				name = "HRE"
				duration = -1
			} 
	    }
		ai_will_do = {
			factor = 1
		}
    }
	
	curia_controller = {
	    major = yes
		potential = {
		tag = PAP
		NOT = { has_country_modifier = THE_PAP }
		}
		allow = {
		papacy_active = no
        NOT = { has_country_modifier = THE_PAP }
		}
		effect = {
		add_country_modifier = {
				name = "THE_PAP"
				duration = -1
			} 
	    }
		ai_will_do = {
			factor = 1
		}
		
    }
	
	ge_empire_of_china = {
	    major = yes
		potential = {
		is_emperor_of_china = no
		OR = {
		owns = 1816
		owns = 1821
		}
		NOT = { has_country_modifier = mandate_of_heaven1 }
		}
		allow = {
        owns = 1816
		owns = 1821
		}
		effect = {
		add_country_modifier = {
				name = "mandate_of_heaven1"
				duration = -1
			} 
	    }
		ai_will_do = {
			factor = 1
		}
    }
	
	join_hre = {
		major = yes
		
		potential = {
			ai = no
			is_part_of_hre = no
			any_known_country = {
				is_part_of_hre = yes
			}
			NOT = { tag = HRE }
			religion_group = christian
			OR = {
				capital_scope = { superregion = europe_superregion
				}
				capital_scope = { superregion = eastern_europe_superregion
				}
			}
		}
		
		allow = {
			OR = {
				is_emperor = yes
				overlord = { 
				is_part_of_hre = yes
				}
				any_neighbor_country = {
				is_part_of_hre = yes
			    }
			}
		}
		
		effect = {
			every_owned_province = {
				limit = { superregion = europe_superregion
				religion_group = christian
				}
				set_in_empire = yes
			}
			every_owned_province = {
				limit = { superregion = eastern_europe_superregion
				religion_group = christian
				}
				set_in_empire = yes
			}
		}
		
		ai_will_do = {
			factor = 1
		}
		
	}
	
	you_become_elector = {
		major = yes
		potential = {
			is_emperor = yes
			NOT = {
				calc_true_if = {
					all_country = {
						is_elector = yes
					}
				amount = 7
				}
				}
			is_elector  = no
		}

		allow = {
			is_emperor = yes
			is_at_war = no
		}

		effect = {
			elector = yes
			add_prestige = -25
			if = {
				limit = {
					NOT = { government_rank = 2 }
				}
				set_government_rank = 2
			}
		}

		ai_will_do = {

			factor = 1
			modifier = {
				factor = 0
				calc_true_if = {
						all_country = {
							is_elector = yes
						}
					amount = 6
					}
			}
		}
	}
	
}