﻿theomonarchy_elective = { # Combination of tribal elective and confederation elective
	elector_vote_strength = {
		base = 0
		modifier = { #Each voter is the "representative" of all the free men living in his domain. The larger the domain, the more voting power he has.
			desc = tooltip_tribal_elective_development
			is_landed_or_landless_administrative = yes
			domain_size >= 1
			any_held_title = {
				title_tier = county
				development_level > 0
				target_is_de_jure_liege_or_above = scope:title
			}
			add = {
				every_held_title = {
					title_tier = county
					limit = {
						development_level > 0
						target_is_de_jure_liege_or_above = scope:title
					}
					add = {
						value = this.development_level
						if = {
							limit = {
								this.faith != root.faith
							}
							divide = 2
						}
						min = 1
					}
				}
			}
		}
		modifier = { #Additional sway from piety level
			desc = tooltip_confederation_elective_piety_levels
			add = {
				value = piety_level
			}
		}
        #Lets see how this looks without
		#modifier = { #Further boost/reduction is given depending on capital county's opinion.
		#	desc = tooltip_tribal_elective_capital_opinion
		#	is_landed_or_landless_administrative = yes
		#	exists = capital_county
		#	OR = {
		#		capital_county.county_opinion <= -5
		#		capital_county.county_opinion >= 5
		#	}
		#	add = {
		#		value = capital_county.county_opinion
		#		multiply = 0.2
		#	}
		#}
		#min = 1
	}
	
	electors = {  
		add = holder
		add = {
			type = holder_direct_vassals
			limit = {
				OR = { #Is either a vassal, or a somewhat respected elder
					AND = {
						is_adult = yes
						piety_level >= 2
					}
                    AND = {
				        highest_held_title_tier >= scope:title.holder.highest_held_title_tier_minus_two_landed
				        target_is_de_facto_liege_or_above = scope:character
                    }
				}
                faith = scope:title.holder.faith
				NOT = { has_trait = incapable }
			}
		}
	}

	candidate_score = {
		base = 0
		######################	Elector self-voting pattern	##########################
		elector_self_voting_pattern_feudal_elective_modifier = yes

		##########################	Holder voting pattern	##########################
		holder_voting_pattern_feudal_elective_modifier = yes

		##########################	Elector voting patterns (circumstances)	##########################
		elector_voting_pattern_circumstances_feudal_elective_modifier = yes

		##########################	Elector voting patterns (prestige/piety)	##########################
		elector_voting_pattern_piety_theomonarchy = yes

		##########################	Elector voting patterns (traits)	##########################
		elector_voting_pattern_traits_theomonarchy = yes

		##########################	Elector voting patterns (opinion)	##########################
		elector_voting_pattern_opinion_feudal_elective_modifier = yes

		##########################	Elector voting patterns (misc)	##########################
		elector_voting_pattern_circumstances_misc_elective_modifier = yes
	}
	
	#scope:candidate = Candidate, scope:title = Title, scope:holder_candidate = Candidate currently selected by ruler.
	candidates = {
		add = {
			type = title_claimants
			limit = {
				feudal_elective_potential_landless_claimant_candidate_trigger = yes
                faith = scope:title.holder.faith
			}
		}
		add = {
			type = holder_direct_vassals	
			limit = {
				feudal_elective_potential_landed_candidate_trigger = yes
				highest_held_title_tier >= tier_county
                faith = scope:title.holder.faith
			}
		}
		add = {
			type = holder_dynasty
			limit = {
				feudal_elective_potential_landless_dynastic_candidate_trigger = yes
                faith = scope:title.holder.faith
			}
		}
	}
}
