### Brief: feudal_government
#
# This is referenced in code
#
feudal_government = {
	government_rules = {
		create_cadet_branches = yes
		rulers_should_have_dynasty = yes
		dynasty_named_realms = yes
		royal_court = yes
		legitimacy = yes
	}

	fallback = 1

	primary_holding = castle_holding
	required_county_holdings = { castle_holding city_holding church_holding }

	vassal_contract = {
		feudal_government_taxes
		feudal_government_levies
		special_contract
		religious_rights
		fortification_rights
		coinage_rights
		succession_rights
		war_declaration_rights
		council_rights
		title_revocation_rights
		jizya_special_rights
	}

	ai = {
		use_legends = yes
	}

	flag = may_elevate_co_monarch
	# Use flags instead of has_government for moddability if possible (i.e., wherever not visible to the player).
	flag = government_is_feudal
	color = hsv{ 0.67 1.00 0.78 }
}

republic_government = {
	primary_holding = city_holding
	valid_holdings = { castle_holding }
	required_county_holdings = { city_holding castle_holding church_holding }

	government_rules = {
		create_cadet_branches = yes
		rulers_should_have_dynasty = yes
		legitimacy = yes
		inherit_from_dynastic_government = no
		landless_playable = yes
	}
	domicile_type = estate
	ai = {
		use_legends = yes
	}
	
	vassal_contract = { republic_government_obligations }

	# Use flags instead of has_government for moddability if possible (i.e., wherever not visible to the player).
	flag = government_is_special_republic
	color = hsv{ 0.00 1.00 0.98 }
}

### Brief: theocracy_government
# Head of faith will always get this if possible
#
# This is referenced in code
#
theocracy_government = {
	government_rules = {
		religious = yes
		inherit_from_dynastic_government = no
	}

	primary_holding = church_holding
	valid_holdings = { castle_holding }
	required_county_holdings = { church_holding castle_holding city_holding }

	ai = {
		use_legends = no
	}

	can_get_government = {
		NOT = {
			faith = {
				has_doctrine = doctrine_theocracy_lay_clergy
			}
		}
	}

	vassal_contract = { theocracy_government_obligations }

	# Use flags instead of has_government for moddability if possible (i.e., wherever not visible to the player).
	flag = government_is_theocracy
	color = hsv{ 0.00 0.00 0.78 }
}

### Brief: clan_government
# This is referenced in code
#
clan_government = {
	government_rules = {
		create_cadet_branches = yes
		rulers_should_have_dynasty = yes
		royal_court = yes
		legitimacy = yes
		dynasty_named_realms = yes
	}

	primary_holding = castle_holding
	primary_heritages = { heritage_arabic heritage_iranian heritage_turkic }

	fallback = 2

	preferred_religions = { islam_religion }

	valid_holdings = { castle_holding }
	required_county_holdings = { castle_holding city_holding church_holding }
	always_use_patronym = yes

	house_unity = clan_house_unity
	tax_slot_type = clan_tax_slot

	vassal_contract = {
		clan_tax_collector_obligations
		special_contract
		religious_rights
		war_declaration_rights
		council_rights
		title_revocation_rights
		marriage_favor_rights
	}

	ai = {
		use_legends = yes
	}

	opinion_of_liege = {
		scope:vassal = {
			if = {
				limit = {
					NOT = {
						is_allied_to = scope:liege
					}
				}
				if = {
					limit = {
						is_powerful_vassal = yes
					}
					value = clan_powerful_vassal_no_alliance_opinion_penalty_value
				}
				else = {
					value = clan_vassal_no_alliance_opinion_penalty_value
				}
			}
		}
	}
	opinion_of_liege_desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:vassal = {
						NOT = {
							is_allied_to = scope:liege
						}
						is_powerful_vassal = yes
					}
				}
				desc = "GOVERNMENT_CLAN_NOT_ALLIED_POWERFUL"
			}
			triggered_desc = {
				trigger = {
					scope:vassal = {
						NOT = {
							is_allied_to = scope:liege
						}
						is_powerful_vassal = no
					}
				}
				desc = "GOVERNMENT_CLAN_NOT_ALLIED"
			}
		}
	}

	# Use flags instead of has_government for moddability if possible (i.e., wherever not visible to the player).
	flag = government_is_clan
	flag = may_appoint_viziers
	color = hsv{ 0.39 0.93 0.54 }
}

tribal_government = {
	government_rules = {
		rulers_should_have_dynasty = yes
		regiments_prestige_as_gold = yes
		royal_court = yes
		legitimacy = yes
	}

	supply_limit_mult_for_others = -0.5
	primary_holding = tribal_holding
	required_county_holdings = { tribal_holding }

	valid_holdings = { castle_holding }

	prestige_opinion_override = { -10 0 3 5 10 20 }
	always_use_patronym = yes
	affected_by_development = no

	vassal_contract = { tribal_government_obligations }

	ai = {
		use_legends = yes
	}

	character_modifier = {
		title_creation_cost_mult = -0.5
		army_maintenance_mult = -0.5

		feudal_government_vassal_opinion = -20
		clan_government_vassal_opinion = -20
		republic_government_vassal_opinion = -20

		character_travel_safety = 10

		ai_war_chance = 0.25
		monthly_prestige = 0.2
	}

	flag = government_can_raid_rule
	flag = may_elevate_co_monarch
	# Use flags instead of has_government for moddability if possible (i.e., wherever not visible to the player).
	flag = government_is_tribal
	color = hsv{ 0.02 0.75 0.36 }
}

### Brief: mercenary_government
# Mercenary will always get this
#
# This is referenced in code
#
mercenary_government = {
	government_rules = {
		court_generate_spouses = no
		council = no
		inherit_from_dynastic_government = no
	}

	court_generate_commanders = 5

	ai = {
		arrange_marriage = no
		use_goals = no
		use_scripted_guis = no
		perform_religious_reformation = no
		use_legends = no
	}

	flag = cannot_be_vassal_or_liege
	# Use flags instead of has_government for moddability if possible (i.e., wherever not visible to the player).
	flag = government_is_mercenary
	color = hsv{ 0.00 0.00 0.66 }
}

### Brief: holy_order_government
# Holy order will always get this
#
# This is referenced in code
#
holy_order_government = {
	government_rules = {
		council = no
		court_generate_spouses = no
		inherit_from_dynastic_government = no
	}

	court_generate_commanders = 5

	ai = {
		arrange_marriage = no
		use_goals = no
		use_scripted_guis = no
		perform_religious_reformation = no
		use_legends = no
	}

	valid_holdings = { castle_holding city_holding }

	flag = cannot_be_vassal_or_liege
	# Use flags instead of has_government for moddability if possible (i.e., wherever not visible to the player).
	flag = government_is_holy_order
	color = hsv{ 0.00 0.00 0.66 }
}

administrative_government = {
	government_rules = {
		create_cadet_branches = yes
		rulers_should_have_dynasty = yes
		dynasty_named_realms = no
		royal_court = yes
		#administrative = yes
		landless_playable = yes
		legitimacy = yes
		#state_faith = yes
		use_as_base_on_landed = yes
		use_as_base_on_rank_up = yes
		#inherit_from_dynastic_government = no
	}

	domicile_type = estate

	fallback = 3

	primary_holding = castle_holding
	valid_holdings = { city_holding }
	required_county_holdings = { castle_holding city_holding church_holding }

	vassal_contract = {
		administrative_obligations
		administrative_themes
	}

	character_modifier = {
		#levy_size = -0.2
		#feudal_government_tax_contribution_mult = -0.2
		#feudal_government_levy_contribution_mult = -0.2
		#clan_government_tax_contribution_mult = -0.2
		#clan_government_levy_contribution_mult = -0.2
		#men_at_arms_cap = -1
		#men_at_arms_limit = -1
		#knight_limit = -3
		#vassal_limit = 100
		#active_accolades = -1
		#title_creation_cost_mult = -0.5
	}

	# Use flags instead of has_government = administrative_government for moddability if possible (i.e., wherever not visible to the player).
	flag = government_is_administrative

	# These flags only exist for loc and in-game descriptions
	flag = government_has_influence
	flag = government_has_title_men_at_arms
	flag = government_has_powerful_families
	color = { 72 6 92 }
}

landless_adventurer_government = {
	government_rules = {
		court_generate_spouses = no
		council = no
		create_cadet_branches = yes
		rulers_should_have_dynasty = yes
		landless_playable = yes
		conditional_maa_refill = yes
		use_title_tier_modifiers = no
		mercenary = yes
		allow_out_of_realm_inheritance = yes
		use_as_base_on_landed = yes
	}

	domicile_type = camp
	court_generate_commanders = no

	can_get_government = {
		any_held_title = {
			tier = tier_duchy
			is_landless_type_title = yes
		}
	}

	valid_holdings = { tribal_holding church_holding castle_holding city_holding }

	character_modifier = {
		active_accolades = -100
		knight_limit = 2
		men_at_arms_cap = -3
		men_at_arms_limit = -2
		character_travel_speed = 20
		siege_weapon_siege_value_mult = -0.5
		mercenary_hire_cost_mult = 1
		short_reign_duration_mult = -5
		long_reign_bonus_mult = -1
		domicile_travel_speed = -0.75
		monthly_wanderer_lifestyle_xp_gain_mult = 0.15
	}

	ai = {
		use_goals = no
		use_scripted_guis = no
		perform_religious_reformation = no
		use_legends = no
	}

	# Use flags instead of has_government for moddability if possible (i.e., wherever not visible to the player).
	flag = cannot_be_vassal_or_liege
	flag = adult_rulers_only
	flag = government_is_landless_adventurer
	color = hsv{ 0.00 0.00 0.66 }
}
