# ============================================================
# RELIGIOUS & CULTURAL STRATEGY EFFECTS
# ============================================================

# Holy Site Control
qyv_ai_seize_holy_sites = {
    if = {
        limit = {
            any_holy_site = {
                faith = root.faith
                controller = { NOT = { is_ruler = root } }
            }
        }
        any_holy_site = {
            limit = {
                faith = root.faith
                controller = { NOT = { is_ruler = root } }
            }
            declare_war = { target = scope:controller cb = holy_site }
        }
    }
}

qyv_ai_create_head_of_faith = {
    create_head_of_faith = {
        faith = root.faith
        title = "head_of_faith_[faith.GetName]"
    }
    root = { add_piety = -1000 }
}

# Faith Reform
qyv_ai_reform_faith = {
    reform_faith = {
        name = "[faith.GetName] Reformed"
        tenet_1 = communion
        tenet_2 = lay_clergy
        tenet_3 = religious_head
        doctrine_1 = gender_equality
        doctrine_2 = female_temple
        doctrine_3 = clergy_marriage
    }
    root = { add_piety = -1500 }
}

qyv_ai_choose_tenets = {
    if = { limit = { qyv_ai_should_choose_tenet_communion = root } add_tenet = communion }
    if = { limit = { qyv_ai_should_choose_tenet_lay_clergy = root } add_tenet = lay_clergy }
    if = { limit = { qyv_ai_should_choose_tenet_religious_head = root } add_tenet = religious_head }
    if = { limit = { qyv_ai_should_choose_doctrine_gender_equality = root } add_doctrine = gender_equality }
    if = { limit = { qyv_ai_should_choose_doctrine_female_temple = root } add_doctrine = female_temple }
    if = { limit = { qyv_ai_should_choose_doctrine_female_temple = root } add_doctrine = clergy_marriage }
}

# Holy War
qyv_ai_launch_holy_war = {
    if = {
        limit = { qyv_ai_should_launch_holy_war = root }
        declare_war = { target = scope:holy_war_target cb = holy_war }
    }
}

qyv_ai_launch_great_holy_war = {
    if = {
        limit = { qyv_ai_should_launch_great_holy_war = root }
        declare_war = { target = scope:holy_site_target cb = great_holy_war }
    }
}

# Conversion
qyv_ai_convert_population = {
    if = {
        limit = { qyv_ai_should_convert_population = root }
        any_owned_province = {
            limit = { faith != root.faith }
            random_list = {
                50 = { convert_faith = { faith = root.faith } }
                50 = { }
            }
        }
    }
}

qyv_ai_use_learning_scenario = {
    if = {
        limit = { qyv_ai_should_use_learning_scenario = root }
        any_owned_province = {
            limit = { faith != root.faith }
            random_list = {
                30 = { convert_faith = { faith = root.faith } }
                70 = { }
            }
        }
    }
}

qyv_ai_use_theologian = {
    if = {
        limit = { qyv_ai_should_use_theologian = root }
        scope:theologian = {
            start_scheme = { scheme = scheme_convert_faith target = scope:province }
        }
    }
}

# Culture Conversion
qyv_ai_convert_culture = {
    if = {
        limit = { qyv_ai_should_convert_culture = root }
        random_owned_province = {
            limit = { culture != root.culture development >= 20 }
            convert_culture = { culture = root.culture }
        }
        root = { add_prestige = -1000 }
    }
}

qyv_rel_qyv_ai_promote_culture = {
    if = {
        limit = { qyv_rel_qyv_ai_promote_culture = root }
        any_owned_province = {
            limit = { culture = root.culture development < 15 }
            promote_culture = yes
        }
    }
}

qyv_ai_create_hybrid_culture = {
    if = {
        limit = { qyv_ai_should_create_hybrid_culture = root }
        create_hybrid_culture = {
            name = "[root.culture.GetName]-[target_culture.GetName]"
            language = root.culture.language
            tradition_1 = root.culture.tradition_1
            tradition_2 = root.culture.tradition_2
        }
    }
}

qyv_ai_promote_hybridization = {
    if = {
        limit = { qyv_ai_should_promote_culture_hybridization = root }
        any_owned_province = {
            limit = { culture != root.culture culture = { NOT = { is_hybrid = yes } } development >= 10 }
            promote_culture = yes
        }
    }
}

# Cultural Head
qyv_ai_become_cultural_head = {
    if = {
        limit = { qyv_ai_should_become_cultural_head = root }
        become_cultural_head = { culture = root.culture }
    }
}

# Pilgrimages
qyv_ai_go_on_pilgrimage = {
    if = {
        limit = { qyv_ai_should_go_on_pilgrimage = root }
        random_holy_site = {
            limit = { faith = root.faith controller = { is_ruler = root } }
            go_on_pilgrimage = { destination = scope:holy_site }
        }
        root = { set_character_flag = on_pilgrimage }
    }
}

# Religious Head Interactions
qyv_ai_request_claim = {
    if = {
        limit = { qyv_ai_should_request_claim = root }
        scope:faith_head = {
            character_interaction = { interaction = request_claim target = root }
        }
    }
}

qyv_ai_request_gold = {
    if = {
        limit = { qyv_ai_should_request_gold = root }
        scope:faith_head = {
            character_interaction = { interaction = request_gold target = root }
        }
    }
}

# Faith Head Decisions
qyv_ai_endorse_ruler = {
    if = {
        limit = { qyv_ai_should_endorse_ruler = root }
        scope:endorsed_ruler = {
            add_character_flag = endorsed_by_faith
            add_opinion = { target = root modifier = faith_endorsement years = 10 }
        }
    }
}

qyv_ai_excommunicate = {
    if = {
        limit = { qyv_ai_should_excommunicate = root }
        scope:target = {
            add_trait = excommunicated
        }
    }
}

# Cultural Head Decisions
qyv_ai_use_cultural_head = {
    if = {
        limit = { qyv_ai_should_use_cultural_head = root }
        scope:cultural_ruler = {
            add_character_flag = endorsed_by_culture
            add_opinion = { target = root modifier = cultural_endorsement years = 10 }
        }
    }
}

# Faith Tenets & Doctrines
qyv_ai_choose_tenets_and_doctrines = {
    if = { limit = { qyv_ai_should_choose_tenet_communion = root } add_tenet = communion }
    if = { limit = { qyv_ai_should_choose_tenet_lay_clergy = root } add_tenet = lay_clergy }
    if = { limit = { qyv_ai_should_choose_tenet_religious_head = root } add_tenet = religious_head }
    if = { limit = { qyv_ai_should_choose_doctrine_gender_equality = root } add_doctrine = gender_equality }
    if = { limit = { qyv_ai_should_choose_doctrine_female_temple = root } add_doctrine = female_temple }
    if = { limit = { qyv_ai_should_choose_doctrine_female_temple = root } add_doctrine = clergy_marriage }
}