﻿##################################################
# REGENCIES
## Power sharing arrangements where the diarch is expected to hold authority temporarily in order to assist their liege.

# Temporary Regencies
## Regencies that are expected to be over shortly, and where the liege can take authority back without issue.
## Referenced in code - this is the default diarchy type, it must always exist and be available to any ruler
temporary_regency = {
	# Handled via content - this is only for power sharing arrangements we want to start automatically.
	start = { always = yes }

	# Handled via content - this is only for power sharing arrangements we want to end automatically.
	end = { always = no }

	# Mandates
	## Just the standard suite
	mandate = fill_coffers
	mandate = swell_armies
	mandate = promote_authority
	## Aptitudes.
	aptitude_score = {
		add = mandate_type_qualification:fill_coffers
		add = mandate_type_qualification:swell_armies
		add = mandate_type_qualification:promote_authority
	}

	# 000
	## Diarch unlocks Syphon Treasury interaction.
	power_level = {
		swing = 0
		parameter = can_be_instantly_dismissed
		parameter = unlock_syphon_treasury_interaction
	}
	# 033
	## Diarch unlocks Diarch Imprison interaction.
	power_level = {
		swing = 33
		parameter = unlock_diarch_imprison_interaction
	}
	# 066
	## Diarch unlocks Legal Meddling interaction.
	power_level = {
		swing = 66
		parameter = unlock_legal_meddling_interaction
	}

	### dr Adjusted the swing requirement to prevent instant downgrading after a month
	# 100
	## Diarch unlocks Entrench Regency interaction.
	power_level = {
		swing = 95
		parameter = unlock_entrench_regency_interaction
		parameter = diarch_gets_a_free_change_on_vassal_contract
	}
	### dr/

	# The longer a temporary regency goes on, the more likely it is to become entrenched.
	### dr
	swing_balance = { value = 0 } #No longer neccesary. Handled in story
	### dr/

	succession = yes
	# Candidate scoring for succession.
	candidate_score = { add = diarchy_regent_succession_score_value }

	# Container for hidden parameters.
	power_level = {
		swing = 0
		hidden_parameter = diarchy_is_regency
		hidden_parameter = diarchy_type_is_temporary_regency
		hidden_parameter = mandate_tempo_fast
	}

	loyalty_score = { add = diarch_loyalty_score_type_regency_value }

	end_interaction = liege_dismiss_temporary_regency_interaction

	liege_modifier = {
		name = from_diarch_stress_loss
		stress_loss_mult = 0.1
	}

	diarch_modifier = {
		name = to_diarch_stress_gain
		stress_gain_mult = 0.15
	}
}

# Entrenched Regencies
## Regencies that have matured or had time to become severe, making them more of a pain to remove.
## Referenced in code - this is the diarchy type used for long-term diarchies, it must always exist and be available to any ruler
regency = {
	# Handled via content - this is only for power sharing arrangements we want to start automatically.
	start = { always = yes }

	# Handled via content - this is only for power sharing arrangements we want to end automatically.
	end = { always = no }

	# Mandates
	## Just the standard suite
	mandate = fill_coffers
	mandate = swell_armies
	mandate = promote_authority
	## Aptitudes.
	aptitude_score = {
		add = mandate_type_qualification:fill_coffers
		add = mandate_type_qualification:swell_armies
		add = mandate_type_qualification:promote_authority
	}
	
	# Scales of Power
	## 000
	power_level = {
		swing = 0
		parameter = dismissal_requires_gift
		parameter = unlock_syphon_treasury_interaction
		parameter = diarch_can_subsidise_liege_authority
	}
	## 020
	power_level = {
		swing = 20
		parameter = unlock_shift_privileges_interaction
		parameter = diarch_gets_a_free_change_on_vassal_contract
		parameter = regency_free_end_below_this_point
	}
	## 040
	power_level = {
		swing = 40
		parameter = unlock_legal_meddling_interaction
		parameter = unlock_diarch_revoke_title_interaction
		parameter = liege_pays_currency_surcharge_for_mundane_interactions_mild
	}
	## 60
	power_level = {
		swing = 60
		parameter = unlock_diarch_retract_vassal_interaction
		parameter = unlock_diarch_imprison_interaction
		parameter = liege_pays_currency_surcharge_for_mundane_interactions_medium
	}
	## 080
	power_level = {
		swing = 80
		parameter = liege_pays_currency_surcharge_for_mundane_interactions_major
		parameter = diarch_can_appoint_self_co_emperor
		parameter = regency_cant_be_ended_above_this_point
	}
	## 95
	power_level = {
		swing = 95
		parameter = liege_pays_currency_surcharge_for_mundane_interactions_massive
		parameter = regents_can_try_to_overthrow_present_lieges
		parameter = regents_can_try_to_overthrow_present_lieges_help
	}

	# Trend towards an even balance of power.

	### dr
	swing_balance = { value = 0 }
	### dr/

	succession = yes
	# Candidate scoring for succession.
	candidate_score = { add = diarchy_regent_succession_score_value }

	# Container for hidden parameters.
	power_level = {
		swing = 0
		hidden_parameter = diarchy_is_regency
		hidden_parameter = diarchy_type_is_entrenched_regency
		hidden_parameter = mandate_tempo_fast
	}

	loyalty_score = { add = diarch_loyalty_score_type_regency_value }

	end_interaction = liege_dismiss_entrenched_regency_interaction

	liege_modifier = {
		name = from_diarch_domain_limit_bonus
		domain_limit = 1
		scale = {
			add = stewardship
			divide = 6
		}
	}

	diarch_modifier = {
		name = to_diarch_stress_gain
		stress_gain_mult = 0.3
	}
}

##################################################
# CO-RULERSHIPS
## Power sharing arrangements where the diarch is expected to hold authority permanently, either as a lifelong assistant or as an heir invested with power early.

# Junior Emperors.
## Co-rule for children, going a long ways towards securing their succession but depriving the realm of leadership during a regency.
## Mostly a political tool, so not something with a lot of its own content, but _gains_ content when the child reaches their majority.
junior_emperorship = {
	# Handled via content - this is only for power sharing arrangements we want to start automatically.
	start = { always = yes }

	end = {
		liege = {
			NOT = { has_realm_law = acclamation_succession_law }
		}
	}

	# Mandates
	## Just the standard suite
	mandate = fill_coffers
	mandate = swell_armies
	mandate = promote_authority
	## Aptitudes.
	aptitude_score = {
		add = mandate_type_qualification:fill_coffers
		add = mandate_type_qualification:swell_armies
		add = mandate_type_qualification:promote_authority
	}
	
	# Scales of Power
	## 000
	power_level = {
		swing = 0
		parameter = diarch_is_preferred_liege_heir
		parameter = diarchy_transition_into_co_emperorship_on_majority
		parameter = half_sop_swing_transfer_over_on_majority
		parameter = liege_may_voluntarily_cede_authority
	}
	## 020
	power_level = {
		swing = 20
		parameter = diarch_gain_skill_on_majority_t1
		parameter = diarch_more_efficient_administrative_emperor_promotion_candidate_mild
	}
	## 040
	power_level = {
		swing = 40
		parameter = diarch_gain_skill_on_majority_t2
		parameter = diarch_more_efficient_administrative_emperor_promotion_candidate_medium
	}
	## 060
	power_level = {
		swing = 60
		parameter = diarch_gain_skill_on_majority_t3
		parameter = diarch_more_efficient_administrative_emperor_promotion_candidate_major
	}
	## 080
	power_level = {
		swing = 80
		parameter = diarch_gain_skill_on_majority_t4
		parameter = diarch_more_efficient_administrative_emperor_promotion_candidate_massive
	}

	# Trend towards an even balance of power.
	### dr
	swing_balance = { value = 0 }
	### dr/

	# No succession here.
	succession = no

	# Container for hidden parameters.
	power_level = {
		swing = 0
		hidden_parameter = diarchy_is_co_rulership
		hidden_parameter = diarchy_type_is_junior_emperorship
		hidden_parameter = mandate_tempo_slow
	}

	loyalty_score = { add = diarch_loyalty_score_type_co_emperorship_value }

	end_interaction = systematically_maim_character_interaction

	liege_modifier = {
		name = from_diarch_monthly_influence_bonus
		monthly_influence_mult = 0.05
		scale = {
			add = diarch.years_as_diarch
			divide = co_emperor_scale_years_in_job_value
			round = yes
			# Add 1 so that we get incomplete 5 years rather than making you wait for the first 5.
			add = 1
		}
	}

	diarch_modifier = {
		#name = to_diarch_monthly_influence_add_bonus
		name = "[co_emperor|E]"
		monthly_influence = 1
		scale = {
			add = diarch.years_as_diarch
			divide = co_emperor_scale_years_in_job_value
			round = yes
			# Add 1 so that we get incomplete 5 years rather than making you wait for the first 5.
			add = 1
		}
	}
}

# Co-Emperors.
## Specific to anyone with Byzantine elective.
## Permanent, powerful, and scales benefits to both parties with SoP.
co_emperorship = {
	# Handled via content - this is only for power sharing arrangements we want to start automatically.
	start = { always = yes }

	end = {
		liege = {
			NOT = { has_realm_law = acclamation_succession_law }
		}
	}

	# Mandates
	## Just the standard suite
	mandate = fill_coffers
	mandate = swell_armies
	mandate = promote_authority
	## Aptitudes.
	aptitude_score = {
		add = mandate_type_qualification:fill_coffers
		add = mandate_type_qualification:swell_armies
		add = mandate_type_qualification:promote_authority
	}
	
	# Scales of Power
	## 000
	power_level = {
		swing = 0
		parameter = unlock_syphon_treasury_interaction
		parameter = unlock_shift_privileges_interaction
		parameter = unlock_diarch_imprison_interaction
		parameter = diarch_more_efficient_administrative_emperor_promotion_candidate_mild
		parameter = diarch_children_born_in_purple_if_culturally_appropriate
	}
	## 020
	power_level = {
		swing = 20
		parameter = unlock_diarch_revoke_title_interaction
		parameter = unlock_diarch_retract_vassal_interaction
		parameter = unlock_adjust_imperial_bureaucracy_interaction
		parameter = diarch_more_efficient_administrative_emperor_promotion_candidate_medium
	}
	## 040
	power_level = {
		swing = 40
		parameter = unlock_diarch_demand_kingdom_interaction
		parameter = unlock_scapegoat_counterpart_interaction
		parameter = liege_pays_currency_surcharge_for_mundane_interactions_mild
		parameter = diarch_more_efficient_administrative_emperor_promotion_candidate_major
	}
	## 60
	power_level = {
		swing = 60
		parameter = unlock_diarch_requests_military_expedition_interaction
		parameter = liege_pays_currency_surcharge_for_mundane_interactions_medium
		parameter = diarch_more_efficient_administrative_emperor_promotion_candidate_massive
	}
	## 080
	power_level = {
		swing = 80
		parameter = liege_pays_currency_surcharge_for_mundane_interactions_major
		parameter = regents_can_try_to_overthrow_present_lieges
		parameter = regents_can_try_to_overthrow_present_lieges_help
	}

	# Trend towards an even balance of power — most of the time.
	### dr
	swing_balance = { value = 0 }
	### dr/

	# No succession here.
	succession = no

	# Container for hidden parameters.
	power_level = {
		swing = 0
		hidden_parameter = diarchy_is_co_rulership
		hidden_parameter = diarchy_type_is_co_emperorship
		hidden_parameter = mandate_tempo_slow
	}

	loyalty_score = { add = diarch_loyalty_score_type_co_emperorship_value }

	end_interaction = systematically_maim_character_interaction

	liege_modifier = {
		name = from_diarch_monthly_influence_bonus
		monthly_influence_mult = 0.2
		scale = {
			add = diarch.years_as_diarch
			divide = co_emperor_scale_years_in_job_value
			round = yes
			# Add 1 so that we get incomplete 5 years rather than making you wait for the first 5.
			add = 1
		}
	}

	diarch_modifier = {
		#name = to_diarch_monthly_influence_add_bonus
		name = "[co_emperor|E]"
		monthly_influence = 1
		scale = {
			add = diarch.years_as_diarch
			divide = co_emperor_scale_years_in_job_value
			round = yes
			# Add 1 so that we get incomplete 5 years rather than making you wait for the first 5.
			add = 1
		}
	}
}

# Co-Monarchs.
## Trimmed down version of co-emperors used outside of the ERE.
## Permanent and powerful, allows a degree of heir control but will cause controversy with other heirs.
co_monarchy = {
	# Handled via content - this is only for power sharing arrangements we want to start automatically.
	start = { always = yes }

	end = {
		liege = { may_appoint_co_monarchs_trigger = no }
	}

	# Mandates
	## Just the standard suite
	mandate = fill_coffers
	mandate = swell_armies
	mandate = promote_authority
	## Aptitudes.
	aptitude_score = {
		add = mandate_type_qualification:fill_coffers
		add = mandate_type_qualification:swell_armies
		add = mandate_type_qualification:promote_authority
	}
	
	# Scales of Power
	## 000
	power_level = {
		swing = 0
		parameter = unlock_syphon_treasury_interaction
		parameter = diarch_can_subsidise_liege_authority
	}
	## 020
	power_level = {
		swing = 20
		parameter = unlock_shift_privileges_interaction
		parameter = diarch_gets_a_free_change_on_vassal_contract
		parameter = liege_pays_currency_surcharge_for_mundane_interactions_mild
	}
	## 040
	power_level = {
		swing = 40
		parameter = unlock_diarch_revoke_title_interaction
		parameter = unlock_legal_meddling_interaction
	}
	## 60
	power_level = {
		swing = 60
		parameter = unlock_diarch_retract_vassal_interaction
		parameter = unlock_diarch_imprison_interaction
		parameter = liege_pays_currency_surcharge_for_mundane_interactions_medium
	}
	## 080
	power_level = {
		swing = 80
		parameter = liege_pays_currency_surcharge_for_mundane_interactions_major
	}
	## 95
	power_level = {
		swing = 95
		parameter = liege_pays_currency_surcharge_for_mundane_interactions_massive
		parameter = regents_can_try_to_overthrow_present_lieges
		parameter = regents_can_try_to_overthrow_present_lieges_help
	}

	# Trend towards an even balance of power — most of the time.
	### dr
	swing_balance = { value = 0 }
	### dr/

	# No succession here.
	succession = no

	# Container for hidden parameters.
	power_level = {
		swing = 0
		hidden_parameter = diarchy_is_co_rulership
		hidden_parameter = diarchy_type_is_co_monarchy
		hidden_parameter = mandate_tempo_slow
	}

	loyalty_score = { add = diarch_loyalty_score_type_co_emperorship_value }

	end_interaction = execute_prisoner_interaction

	liege_modifier = {
		name = from_co_monarch_diplomacy_vassal_opinion

		vassal_opinion = 1
		scale = {
			add = diplomacy
			max = 40
		}
	}

	diarch_modifier = {
		name = to_co_monarch_monthly_prestige_add_bonus

		monthly_prestige = 0.5
		scale = { add = liege.highest_held_title_tier }
	}
}

##################################################
# PRIMEMINISTERSHIPS
## Power sharing arrangements where the diarch is expected to hold authority semi-permanently in order to assist their liege, but still derives that authority from their liege rather than themselves.

# Vizierates
## A type of diarchy accessible to clans, where the chief minister exercises huge amounts of discretion on behalf of their ruler. This frees the ruler up to better perform at many tasks, but poses greater long-term risks.
## Generally intended to be lower tempo than regencies.
vizierate = {
	# Handled via content - this is only for power sharing arrangements we want to start automatically.
	start = { always = yes }

	end = {
		liege = {
			NOT = { government_has_flag = may_appoint_viziers }
		}
	}

	# Mandates
	## Just the standard suite
	mandate = fill_coffers
	mandate = swell_armies
	mandate = promote_authority
	## Aptitudes.
	aptitude_score = {
		add = mandate_type_qualification:fill_coffers
		add = mandate_type_qualification:swell_armies
		add = mandate_type_qualification:promote_authority
	}
	
	# Scales of Power
	## 000
	power_level = {
		swing = 0
		parameter = unlock_syphon_treasury_interaction
		parameter = unlock_shift_privileges_interaction
		parameter = unlock_mulct_vizier_interaction
		parameter = lieges_swing_more_against_diarchs
		# We put a toggle on here so we can early out of diarchy checks for tax collectors a little faster + explicitly list the diarch bonus.
		parameter = diarch_aptitude_helps_tax_collectors_toggle
	}
	## 020
	power_level = {
		swing = 20
		parameter = primeminister_dismissal_will_upset_administration
		parameter = primeminister_requires_county
		parameter = diarch_aptitude_helps_tax_collectors_t1
	}
	## 040
	power_level = {
		swing = 40
		parameter = diarch_aptitude_helps_tax_collectors_t2
	}
	## 60
	power_level = {
		swing = 60
		parameter = primeminister_requires_duchy
		parameter = diarch_aptitude_helps_tax_collectors_t3
		parameter = liege_pays_currency_surcharge_for_mundane_interactions_mild
	}
	power_level = {
		swing = 60
		hidden_parameter = vizier_cannot_be_snaked
	}
	## 70
	power_level = {
		swing = 70
		parameter = liege_pays_currency_surcharge_for_mundane_interactions_medium
	}
	## 080
	power_level = {
		swing = 80
		parameter = diarch_aptitude_helps_tax_collectors_t4
		parameter = liege_pays_currency_surcharge_for_mundane_interactions_major
	}
	## 90
	power_level = {
		swing = 90
		parameter = liege_pays_currency_surcharge_for_mundane_interactions_massive
		parameter = regents_can_try_to_overthrow_present_lieges
	}

	# Trend towards an even balance of power.
	### dr
	swing_balance = { value = 0 }
	### dr/	

	succession = yes
	# Candidate scoring for succession.
	candidate_score = { add = diarchy_vizier_succession_score_value }

	# Container for hidden parameters.
	power_level = {
		swing = 0
		hidden_parameter = diarchy_is_vizierate
		hidden_parameter = vizier_sits_in_the_council_instead_of_spouse
		# This one isn't hooked up to anything yet - just here to establish a parameter standard for mods & potential... _future_ diarchies.
		hidden_parameter = diarchy_is_primeministership
		hidden_parameter = mandate_tempo_slow
	}

	loyalty_score = { add = diarch_loyalty_score_type_vizierate_value }

	end_interaction = liege_dismiss_vizier_interaction

	liege_modifier = {
		name = from_diarch_domain_limit_bonus
		tax_slot_add = 1
		scale = { add = vizier_bonus_tax_jurisdictions_value }
	}

	diarch_modifier = {
		name = family_member_is_civil_servant
		stress_gain_mult = 0.3
		monthly_dynasty_prestige = -0.25
	}
	diarch_modifier = {
		name = civil_servant_salary_and_corruption
		monthly_income = 1
		scale = {
			add = liege.monthly_character_balance
			multiply = {
				add = stewardship
				# Get nearest complete 5.
				divide = 5
				round = yes
				min = 1
				# And fractalise.
				divide = 20
				# So we should be getting something like 5% of our liege's income per 5 stewardship, with rounding errors.
				## Plus, y'know, Paradox maths.
			}
		}
	}
}

