﻿# you can appoint an accolade successor RIGHT NOW
action_accolade_successor_available = {
	combine_into_one = yes
	priority = 500

	check_create_action = {
		if = {
			limit = {
				has_dlc_feature = accolades
				any_active_accolade = {
					NOT = { exists = accolade_successor }
					save_temporary_scope_as = accolade_temp
					root = {
						any_knight = {
							is_acclaimed = no
							is_valid_successor_for_accolade = scope:accolade_temp
							highest_held_title_tier <= tier_county
						}
					}
				}
			}
			every_active_accolade = {
				limit = {
					NOT = { exists = accolade_successor }
					save_temporary_scope_as = accolade_temp
					root = {
						any_knight = {
							is_acclaimed = no
							is_valid_successor_for_accolade = scope:accolade_temp
							highest_held_title_tier <= tier_county
						}
					}
				}
				try_create_important_action = {
					important_action_type = action_accolade_successor_available
					actor = root
					recipient = this
				}
			}
		}
	}

	effect = {
		open_view_data = military
		open_view = knights
	}
}

# you have an accolade that's missing a successor
action_find_accolade_successor = {
	priority = 500
	combine_into_one = yes

	check_create_action = {
		if = {
			limit = {
				has_dlc_feature = accolades
				any_active_accolade = {
					NOT = { exists = accolade_successor }
					save_temporary_scope_as = accolade_temp
					NOT = {
						root = {
							any_knight = {
								is_acclaimed = no
								is_valid_successor_for_accolade = scope:accolade_temp
								highest_held_title_tier <= tier_county
							}
						}
					}
				}
			}
			every_active_accolade = {
				limit = {
					NOT = { exists = accolade_successor }
					save_temporary_scope_as = accolade_temp
					NOT = {
						root = {
							any_knight = {
								is_acclaimed = no
								is_valid_successor_for_accolade = scope:accolade_temp
								highest_held_title_tier <= tier_county
							}
						}
					}
				}
				try_create_important_action = {
					important_action_type = action_find_accolade_successor
					actor = root
					recipient = this
				}
			}
		}
	}
	unimportant = {
		NOT = {
			any_active_accolade = {
				NOT = { exists = accolade_successor }
				has_potential_accolade_successors = no
				NOT = {
					primary_type = {
						this = accolade_type:house_knight_attribute 
					}
				}
				acclaimed_knight = {
					save_temporary_scope_as = potential_recipient
					root = {
						is_character_interaction_valid = { 
							recipient = scope:potential_recipient
							interaction = find_suitable_accolade_successor_interaction
						}
					}
				}
			}
		}
    }

	effect = {
		open_view_data = military
		open_view = knights
	}
}

# you have an empty accolade slot and a knight who could fill it
action_empty_accolade_slot = {
    priority = 500

    check_create_action = {
    	if = {
    		limit = {
    			is_landed = yes
				max_number_of_knights > 0
    			max_active_accolades > 0
				num_active_accolades < max_active_accolades
    			has_dlc_feature = accolades
				NOT = { has_global_variable = tutorial_current_situation_gradual_reveal_3 }
    		}
    		try_create_important_action = {
           		important_action_type = action_empty_accolade_slot
                actor = root
      		}
    	}
    }
    unimportant = {
      	any_active_accolade = {
			save_temporary_scope_as = accolade_temp
			root = {
				any_knight = {
					is_acclaimed = no
					is_valid_successor_for_accolade = scope:accolade_temp
					highest_held_title_tier <= tier_county
					can_be_acclaimed = yes
				}
			}
		}
    }
    effect = {
		open_view_data = military
		open_view = knights
        start_tutorial_lesson = reactive_advice_create_accolade
    }
}

# you have an inactive accolade that can be reinstated
action_inactive_accolade = {
    combine_into_one = yes
    priority = 500

    check_create_action = {
    	if = {
    		limit = {
    			has_dlc_feature = accolades
    			max_active_accolades > num_active_accolades
    			any_accolade = {
    				is_accolade_active = no
    				exists = acclaimed_knight
    			}
    		}
    		every_accolade = {
    			limit = {
    				is_accolade_active = no
    				exists = acclaimed_knight
    			}
    			try_create_important_action = {
           			important_action_type = action_inactive_accolade
            	    actor = root
            	    recipient = this
      			}
      		}
    	}
    	else_if = {
    		limit = {
    			has_dlc_feature = accolades
    			max_active_accolades > num_active_accolades
    			any_accolade = {
    				is_accolade_active = no
    				NOT = { exists = acclaimed_knight }
    				save_temporary_scope_as = accolade_temp
    				root = {
    					any_knight = {
    						is_acclaimed = no
    						is_valid_successor_for_accolade = scope:accolade_temp
    						highest_held_title_tier <= tier_county
    					}
    				}
    			}
    		}
    		every_accolade = {
    			limit = {
    				is_accolade_active = no
    				NOT = { exists = acclaimed_knight }
    				save_temporary_scope_as = accolade_temp
    				root = {
    					any_knight = {
    						is_acclaimed = no
    						is_valid_successor_for_accolade = scope:accolade_temp
    						highest_held_title_tier <= tier_county
    					}
    				}
    			}
    			try_create_important_action = {
           			important_action_type = action_inactive_accolade
            	    actor = root
            	    recipient = this
      			}
    		}
    	}
    }
    effect = {
		open_view_data = military
		open_view = knights
    }
}

#you should use the "restore accolade" decision
# you have an inactive accolade that can be reinstated
action_restore_accolade = {
   priority = 1000

    check_create_action = {
    	if = {
    		limit = {
    			has_dlc_feature = accolades
    			can_execute_decision = call_for_acclaimed_knight_candidates_decision
    		}
    		try_create_important_action = {
        	   important_action_type = action_restore_accolade
        	   actor = root
      		}
      	}
    }
    effect = {
        open_view = decisions
    }
}
