###################################
#
# CHARLEMAGNE
# - Councillor decisions
#
###################################

# Written by Henrik "Groogy" Hansson

decisions = {
	
	help_liege_manage_titles = {
	 	is_high_prio = yes
	 	ai = no

		potential = {
			
			is_councillor = yes
			
			liege = {
				NOT = { character = ROOT }
				is_nomadic = no
			}

			OR = {
				has_job_title = job_chancellor
				has_job_title = job_treasurer
				has_job_title = job_spiritual
			}
			NOT = { trait = slothful }
			NOT = { had_character_flag = { flag = proposed_to_help_liege_with_titles days = 730 } } 
		}
		allow = {
			liege = {
				over_max_demesne_size = 4
				custom_tooltip = { 
					text = NOT_PROPOSED_TITLE_HELP_RECENTLY_TOOLTIP
					hidden_tooltip = {
						OR = {
							NOT = { has_character_flag = has_been_proposed_about_titles }
							had_character_flag = { flag = has_been_proposed_about_titles days = 14 }
						}
					}
  				}
  				custom_tooltip = {
  					text = NOT_REFUSED_ANY_HELP_WITH_TITLES_TOOLTIP
  					hidden_tooltip = {
  						OR = {
  							NOT = { has_character_flag = refused_any_help_with_titles }
							had_character_flag = { flag = refused_any_help_with_titles days = 712 }
						}
  					}
  				}
  				custom_tooltip = {
  					text = NOT_GETTING_HELP_WITH_TITLES_TOOLTIP
  					hidden_tooltip = {
  						OR = {
  							NOT = { has_character_flag = getting_help_with_titles }
							had_character_flag = { flag = getting_help_with_titles days = 800 }
						}
  					}
  				}
			}
		}
		effect = {
			set_character_flag = proposed_to_help_liege_with_titles
			liege = {
				set_character_flag = has_been_proposed_about_titles
			}
			if = {
				limit = {
					has_job_title = job_chancellor
				}
				character_event = { id = 108050 }
			}
			if = {
				limit = {
					has_job_title = job_treasurer
				}
				character_event = { id = 108051 }
			}
			if = {
				limit = {
					has_job_title = job_spiritual
				}
				character_event = { id = 108052 }
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	ask_help_to_manage_titles = {
		only_playable = yes
	 	is_high_prio = yes
		ai_check_interval = 12

		potential = {
			is_ruler = yes
			is_nomadic = no
			
			OR = {
				job_chancellor = {
					ai = no
				}
				ai = no
			}
			
			over_max_demesne_size = 4
			OR = {
				NOT = { has_character_flag = has_been_proposed_about_titles }
				had_character_flag = { flag = has_been_proposed_about_titles days = 14 }
			}
			OR = {
				NOT = { has_character_flag = refused_any_help_with_titles }
				had_character_flag = { flag = refused_any_help_with_titles days = 712 }
			}
		}
		allow = {
			over_max_demesne_size = 4
			custom_tooltip = {
				text = HAS_CHANCELLOR
				hidden_tooltip = {
					job_chancellor = {
						is_alive = yes
					}
				}
			}
  			custom_tooltip = {
  				text = TOOLTIP_RECENTLY_ASKED_HELP_WITH_TITLES
  				OR = {
  					NOT = { has_character_flag = getting_help_with_titles }
					had_character_flag = { flag = getting_help_with_titles days = 800 }
				}
			}
		}
		effect = {
			set_character_flag = getting_help_with_titles
			job_chancellor = {
				character_event = { id = 108010 }
				character_event = { id = 108005 }
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
		}
	}
}
