# Representing the Byzantine monarchy, or monarchic theocracy, as it is referred to by historians, is a bit of a mess. What we do know is the following:
# -The Empire had no formal imperial succession because it was by law, still a republic. Emperors were elected practically by the military.
# -This highly militarised Empire essentially means that "bigger army diplomacy" (CGP Grey) rules.
# -Emperors managed to secure succession using honorary titles as co-emperors for their children.


# This government will not generate heirs automatically - the "Introduce heir" button must be used in order to name someone co-emperor, and this button will generate a heir
# of your dynasty.

#Clearly I never used the above. Oh well. Maybe one of these days I'll properly represent the ridiculous succession of the Byzantines. Or maybe I'll never do it. It's not exactly easy to model in EU4 mechanics.

byzantine_pronoia_mechanic = {
	alert_icon_gfx = GFX_alerticons_government_mechanics_byzantium
	alert_icon_index = 1
	available = {
		has_country_flag = byz_restored_pronoia_mechanic
	}
	
	powers = {
		byzantine_pronoia_power = {
			gui = byzantine_pronoia_gov_mech_power
			max = 150
			base_monthly_growth = 1 #Countered by -2 at 80% nobility estate influence
			monarch_power = ADM
			is_good = yes
		}
	}
	
	interactions = {
		demand_state_tax = {
			gui = byzantine_pronoia_gov_mech_button
			icon = GFX_pronoia_demand_state_tax_button
			cost_type = byzantine_pronoia_power
			cost = 100
			trigger = {
			}
			effect = {
				add_years_of_income = 1
			}
			ai_chance = {
				factor = 20
				modifier = {
					factor = 0
					NOT = { num_of_loans = 1 }
				}
				modifier = {
					factor = 0.5
					is_in_deficit = no
				}
				modifier = {
					factor = 1.25
					has_any_disaster = yes
				}
				modifier = {
					factor = 1.5
					num_of_loans = 2
					is_in_deficit = yes
				}
				modifier = {
					factor = 20
					num_of_loans = 1
				}
				modifier = {
					factor = 100
					num_of_loans = 3
				}
				modifier = {
					factor = 100
					num_of_loans = 5
				}
				modifier = {
					factor = 100
					num_of_loans = 7
				}

			}
		}
		raise_tagmata = {
			gui = byzantine_pronoia_gov_mech_button
			icon = GFX_pronoia_raise_tagmata_button
			cost_type = byzantine_pronoia_power
			cost = 100
			trigger = { 
			}
			effect = { 
				add_yearly_manpower = 2
				add_yearly_sailors = 2
			}
			ai_chance = {
				factor = 2
				modifier = {
					factor = 0
					is_at_war = no
					OR = {
						NOT = {
							any_neighbor_country = {
								NOT = { truce_with = ROOT }
							}
						}
						manpower_percentage = 0.9
					}
				}
				modifier = {
					factor = 1.5
					not = { manpower_percentage = 0.3 }
				}
				modifier = {
					factor = 1.5
					not = { manpower_percentage = 0.2 }
				}
				modifier = {
					factor = 1.5
					not = { manpower_percentage = 0.1 }
				}
				modifier = {
					factor = 10
					is_in_important_war = yes
				}
				modifier = {
					factor = 3
					is_at_war = yes
					is_in_deficit = no
				}
			}
		}
		lenient_state_tax = {
			gui = byzantine_pronoia_gov_mech_button
			icon = GFX_pronoia_lenient_state_tax_button
			cost_type = byzantine_pronoia_power
			cost = 100
			trigger = {
			}
			effect = { 
				add_country_modifier = {
					name = lenient_state_tax_mod
					duration = 9125 #In theory, this power grows by an average of 4/year, or a click every 25 years.
				}
			}
			ai_chance = {
				factor = 5
				modifier = {
					factor = 0
					NOT = {
						any_subject_country = {
							liberty_desire = 40
						}
					}
				}
				modifier = {
					factor = 2
					any_subject_country = {
						liberty_desire = 45
					}
				}
				modifier = {
					factor = 5
					any_subject_country = {
						liberty_desire = 50
					}
				}
				modifier = {
					factor = 10
					any_subject_country = {
						liberty_desire = 60
					}
				}
			}
		}
	}
	
}

byzantine_bureaucracy_mechanic = {
	alert_icon_gfx = GFX_alerticons_government_mechanics_byzantium
	alert_icon_index = 3
	available = {
		has_country_flag = byz_restored_bureaucracy_mechanic
	}
	#There's six Logothetes:
	#Genikou: General (Taxation)
	#Dromou: Postal (Diplomacy)
	#Stratiotikou: Military (Land)
	#Praitoriou: Praetorium (Law & Order)
	#Eidikou: Special Affairs (Production & Trade)
	#Hydaton: Waters (Naval)
	#The idea of the mechanic is the following:
	#All of these have a powerbase between 0 to 100.
	#Between 0 to 100, they provide nice bonuses to the Empire.
	#However, if any individual power goes above 50, it starts decreasing all others' powers as it grows, at -0.5 monthly at 100 power. If a power reaches above 75, you also get +0.2 yearly corruption for mismanaging your administration.
	#All Logothete grow by 0.01 monthly for one click of expand administration.
	#The base growth of all Logothete is 0 monthly otherwise.
	#Their power grows dynamically based on a variety of factors.
	#Each power can be paid down by 5 points for 5 monarch points of their respective category.
	
	#Genikou:
	#The Logothetes tou Genikou, or General Logothete, manages the taxation of the Imperial provinces.
	#
	#The Logothetes tou Genikou's power changes by the following:
	#+0.05 monthly per point of stability
	#-0.05 monthly per point of negative stability
	#+0.1 monthly if at peace
	
	#Dromou:
	#The Logothetes tou Dromou, or Postal Logothete, manages the Empire's foreign affairs.
	#
	#The Logothetes tou Dromou's power changes by the following:
	#+0.05 monthly per point of diplomatic reputation
	
	#Stratiotikou:
	#The Logothetes tou Stratiotikou, or Military Logothete, manages the pay and provision of the Imperial Army. 
	#
	#The Logothetes tou Stratiotikou's power changes by the following:
	#+0.1 monthly per 100 army tradition
	#+0.1 monthly per 100 army professionalism
	#+0.1 monthly during war taxes
	#-0.1 monthly during slackening recruitment
	#-0.1 monthly if at peace
	
	#Praitoriou:
	#The Logothetes tou Praitoriou, or Praetorium Logothete, manages the Empire's law and order. 
	#
	#The Logothetes tou Praitoriou's power changes by the following:
	#+0.2 monthly at 0% average global autonomy
	#-0.2 monthly at 100% average global autonomy
	
	#Eidikou:
	#The Logothetes tou Eidikou, or Special Affairs Logothete, manages the Empire's manufacturing and storehouses for war and trade alike.
	#
	#The Logothetes tou Eidikou's power changes by the following:
	#+0.2 monthly per 100 mercantilism
	#+0.01 monthly per "trading in"-modifier
	
	#Hydaton:
	#The Logothetes ton Hydaton, or Waters Logothete, manages the supplies for the Imperial Navy.
	#
	#The Logothetes ton Hydaton's power changes by the following:
	#+0.2 monthly per 100 naval tradition
	
	#Boni at 100 power:
	#Genikou: +50% national tax modifier
	#Dromou: +50% improve relations modifier
	#Stratiotikou: +50% manpower recovery speed
	#Praitoriou -50% Expand administration cost modifier
	#Eidikou: +50% trade efficiency
	#Hydaton: +10% ship durability & +50% sailor recovery speed
	
	powers = { #Revamp to above
		logothete_general_power = {
			gui = byzantine_bureaucracy_gov_mech_button_with_power
			max = 100
			base_monthly_growth = 0
			scaled_modifier = {
				modifier = {
					global_tax_modifier = 0.5
					monthly_logothete_general_power = -0.25
				}
			}
			scaled_modifier = {
				start_value = 50
				modifier = {
					yearly_corruption = 0.1
					monthly_logothete_postal_power = -0.1
					monthly_logothete_military_power = -0.1
					monthly_logothete_praetorium_power = -0.1
					monthly_logothete_special_affairs_power = -0.1
					monthly_logothete_waters_power = -0.1
				}
			}
		}
		logothete_postal_power = {
			gui = byzantine_bureaucracy_gov_mech_button_with_power
			max = 100
			base_monthly_growth = 0
			scaled_modifier = {
				modifier = {
					improve_relation_modifier = 0.5
					monthly_logothete_postal_power = -0.25
				}
			}
			scaled_modifier = {
				start_value = 50
				modifier = {
					yearly_corruption = 0.1
					monthly_logothete_general_power = -0.1
					monthly_logothete_military_power = -0.1
					monthly_logothete_praetorium_power = -0.1
					monthly_logothete_special_affairs_power = -0.1
					monthly_logothete_waters_power = -0.1
				}
			}
		}
		logothete_military_power = {
			gui = byzantine_bureaucracy_gov_mech_button_with_power
			max = 100
			base_monthly_growth = 0
			scaled_modifier = {
				modifier = {
					manpower_recovery_speed = 0.5
					monthly_logothete_military_power = -0.25
				}
			}
			scaled_modifier = {
				start_value = 50
				modifier = {
					yearly_corruption = 0.1
					monthly_logothete_general_power = -0.1
					monthly_logothete_postal_power = -0.1
					monthly_logothete_praetorium_power = -0.1
					monthly_logothete_special_affairs_power = -0.1
					monthly_logothete_waters_power = -0.1
				}
			}
		}
		logothete_praetorium_power = {
			gui = byzantine_bureaucracy_gov_mech_button_with_power
			max = 100
			base_monthly_growth = 0
			scaled_modifier = {
				modifier = {
					expand_administration_cost = -0.5
					monthly_logothete_praetorium_power = -0.25
				}
			}
			scaled_modifier = {
				start_value = 50
				modifier = {
					yearly_corruption = 0.1
					monthly_logothete_general_power = -0.1
					monthly_logothete_postal_power = -0.1
					monthly_logothete_military_power = -0.1
					monthly_logothete_special_affairs_power = -0.1
					monthly_logothete_waters_power = -0.1
				}
			}
		}
		logothete_special_affairs_power = {
			gui = byzantine_bureaucracy_gov_mech_button_with_power
			max = 100
			base_monthly_growth = 0
			scaled_modifier = {
				modifier = {
					trade_efficiency = 0.5
					monthly_logothete_special_affairs_power = -0.25
				}
			}
			scaled_modifier = {
				start_value = 50
				modifier = {
					yearly_corruption = 0.1
					monthly_logothete_general_power = -0.1
					monthly_logothete_postal_power = -0.1
					monthly_logothete_military_power = -0.1
					monthly_logothete_praetorium_power = -0.1
					monthly_logothete_waters_power = -0.1
				}
			}
		}
		logothete_waters_power = {
			gui = byzantine_bureaucracy_gov_mech_button_with_power
			max = 100
			base_monthly_growth = 0
			scaled_modifier = {
				modifier = {
					sailors_recovery_speed = 0.5
					ship_durability = 0.1
					monthly_logothete_waters_power = -0.25
				}
			}
			scaled_modifier = {
				start_value = 50
				modifier = {
					yearly_corruption = 0.1
					monthly_logothete_general_power = -0.1
					monthly_logothete_postal_power = -0.1
					monthly_logothete_military_power = -0.1
					monthly_logothete_praetorium_power = -0.1
					monthly_logothete_special_affairs_power = -0.1
				}
			}
		}
	}
	
	interactions = {
		logothete_general_interaction = {
			gui = byzantine_bureaucracy_gov_mech_button_with_power
			icon = GFX_logothete_general_button
			cost_type = logothete_general_power
			cost = 5
			trigger = {
				adm_power = 5
				has_government_power = { 
					mechanic_type = byzantine_bureaucracy_mechanic 
					power_type = logothete_general_power
					value = 50 
				}
			}
			
			effect = {
				add_adm_power = -5
			}
		}
		logothete_postal_interaction = {
			gui = byzantine_bureaucracy_gov_mech_button_with_power
			icon = GFX_logothete_postal_button
			cost_type = logothete_postal_power
			cost = 5
			trigger = {
				dip_power = 5
				has_government_power = { 
					mechanic_type = byzantine_bureaucracy_mechanic 
					power_type = logothete_postal_power
					value = 50 
				}
			}
			
			effect = {
				add_dip_power = -5
			}
		}
		logothete_military_interaction = {
			gui = byzantine_bureaucracy_gov_mech_button_with_power
			icon = GFX_logothete_military_button
			cost_type = logothete_military_power
			cost = 5
			trigger = {
				mil_power = 5
				has_government_power = { 
					mechanic_type = byzantine_bureaucracy_mechanic 
					power_type = logothete_military_power
					value = 50 
				}
			}
			
			effect = {
				add_mil_power = -5
			}
		}
		logothete_praetorium_interaction = {
			gui = byzantine_bureaucracy_gov_mech_button_with_power
			icon = GFX_logothete_praetorium_button
			cost_type = logothete_praetorium_power
			cost = 5
			trigger = {
				adm_power = 5
				has_government_power = { 
					mechanic_type = byzantine_bureaucracy_mechanic 
					power_type = logothete_praetorium_power
					value = 50 
				}
			}
			
			effect = {
				add_adm_power = -5
			}
		}
		logothete_special_affairs_interaction = {
			gui = byzantine_bureaucracy_gov_mech_button_with_power
			icon = GFX_logothete_special_affairs_button
			cost_type = logothete_special_affairs_power
			cost = 5
			trigger = {
				dip_power = 5
				has_government_power = { 
					mechanic_type = byzantine_bureaucracy_mechanic 
					power_type = logothete_special_affairs_power
					value = 50 
				}
			}
			
			effect = {
				add_dip_power = -5
			}
		}
		logothete_waters_interaction = {
			gui = byzantine_bureaucracy_gov_mech_button_with_power
			icon = GFX_logothete_waters_button
			cost_type = logothete_waters_power
			cost = 5
			trigger = {
				mil_power = 5
				has_government_power = { 
					mechanic_type = byzantine_bureaucracy_mechanic 
					power_type = logothete_waters_power
					value = 50 
				}
			}
			
			effect = {
				add_mil_power = -5
			}
		}
	}
}

byzantine_militarization_mechanic = {
	alert_icon_gfx = GFX_alerticons_government_mechanics_byzantium
	alert_icon_index = 2
	available = {
		has_country_flag = byz_restored_militarization_mechanic
	}
	
	powers = {
		byzantine_militarization = {
			gui = byzantine_militarization_gov_mech_power
			max = 200 #Scales to 200 because monarch power is hardcoded to +1/year/skill
			monarch_power = MIL
			reset_on_new_ruler = yes
			scaled_modifier = {
				end_value = 200
				modifier = {
					generals_loyalty_modifier = 0.4
					drill_decay_modifier = -1.0
					drill_gain_modifier = 2.0
				}
			}
			range_modifier = {
				modifier = {
					monarch_military_power = 1
				}
				start_value = 50
				end_value = 200
			}
			range_modifier = {
				modifier = {
					monarch_military_power = 1
				}
				start_value = 100
				end_value = 200
			}
			range_modifier = {
				modifier = {
					monarch_military_power = 1
				}
				start_value = 150
				end_value = 200
			}
			range_modifier = {
				modifier = {
					monarch_military_power = 1
				}
				start_value = 200
				end_value = 200
			}
			is_good = yes
		}
	}
	
	interactions = {
		#None
	}
}

latin_imperial_authority_mechanic = {
	alert_icon_gfx = GFX_alerticons_government_mechanics_byzantium
	alert_icon_index = 4
	
	powers = {
		latin_imperial_authority = {
			gui = latin_imperial_authority_gov_mech_power
			min = -100
			max = 100
			base_monthly_growth = 0
			is_good = yes
			scaled_modifier = {
				#start_value = 50
				#extend_beyond_value = no
				modifier = { 	
					vassal_forcelimit_bonus = 1 
					vassal_naval_forcelimit_bonus = 1
					vassal_manpower_bonus = 1
					vassal_sailors_bonus = 1
					vassal_income = 1
				}
			}
			scaled_modifier = {
				start_value = 0
				end_value = -100
				extend_beyond_value = no
				modifier = { 	
					reduced_liberty_desire = -50
				}
			}
		}
	}
}



























