﻿exigir_independencia = {
    picture = {
        reference = "gfx/interface/illustrations/decisions/decision_legitimacy.dds"
    }

    decision_group_type = admin
    ai_check_interval = 0

    desc = exigir_independencia_interaction_desc

    is_shown = {
        NOT = { is_independent_ruler = yes } # Show only if not independent
    }

    is_valid = {
        # Verify that the character holds at least a Duchy-level title
        highest_held_title_tier >= tier_duchy
        NOT = { is_independent_ruler = yes } # Verify that the character is not independent
        liege = { exists = yes } # Verify that the liege exists
        # Verify that the character is not at war
        NOT = { is_at_war = yes }

        # Verify military strength or weak hook over the liege
        OR = {
            current_military_strength > liege.current_military_strength
            root = {
                has_weak_hook = liege
            }
        }

        # Verify that the primary title has been held for at least 10 years
        primary_title = {
            title_held_years > 10
        }
        # Verify that all counties in the capital are of the same culture and faith
        custom_tooltip = {
            text = exigir_independencia_decision_tt
            capital_county = {
                de_jure_liege = {
                    any_de_jure_county = {
                        count = all
                        culture = root.culture
                        faith = root.faith
                    }
                }
            }
        }
        # Verify that the liege's culture differs from the character's culture
        liege = {
            NOT = { culture = ROOT.culture }
        }
    }
    
    effect = {
        # Visible effects for the player
        custom_tooltip = exigir_independencia_decision_effects.01
        custom_tooltip = exigir_independencia_decision_effects.02
        custom_description_no_bullet = { text = exigir_independencia_warning_effect }

        # Increase legitimacy
        add_legitimacy = 100

        # Increase dynasty prestige
        dynasty = {
            add_dynasty_prestige = 400
        }

        # Trigger independence event
        hidden_effect = {
            trigger_event = independence_event.1
        }
    }

    ai_potential = {
        # The AI will consider the decision only if the game rule is enabled
        has_game_rule = independence_ai_enabled_yes
        NOT = { is_independent_ruler = yes }
        highest_held_title_tier >= tier_duchy
        liege = { exists = yes }
        NOT = { is_at_war = yes }
        OR = {
            current_military_strength > liege.current_military_strength
            liege = {
                has_weak_hook = root
            }
        }
        primary_title = {
            title_held_years > 10
        }
        capital_county = {
            de_jure_liege = {
                any_de_jure_county = {
                    count = all
                    culture = root.culture
                    faith = root.faith
                }
            }
        }
        liege = {
            NOT = { culture = ROOT.culture }
        }
    }

    ai_will_do = {
        base = 1 # Base likelihood for the AI to take the decision
    }
}
