﻿# AUTO-GENERATED by DI Updater Tool - do not edit by hand
# Set or create holding types discovered from effective game sources

DI_set_holding_type_sgui = {
    scope = character # Player Character

    saved_scopes = {
        holding_type # Holding type flag
    }

    effect = {
        save_scope_as = player

        if = {
            limit = {
                scope:holding_type = flag:castle_holding
            }

            every_in_list = {
                variable = DI_action_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = {
                            province_has_no_holding_trigger = yes
                        }
                        begin_create_holding = castle_holding
                    }
                    set_holding_type = castle_holding
                }
            }
        }
        else_if = {
            limit = {
                scope:holding_type = flag:city_holding
            }

            every_in_list = {
                variable = DI_action_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = {
                            province_has_no_holding_trigger = yes
                        }
                        begin_create_holding = city_holding
                    }
                    set_holding_type = city_holding
                }
            }
        }
        else_if = {
            limit = {
                scope:holding_type = flag:church_holding
            }

            every_in_list = {
                variable = DI_action_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = {
                            province_has_no_holding_trigger = yes
                        }
                        begin_create_holding = church_holding
                    }
                    set_holding_type = church_holding
                }
            }
        }
        else_if = {
            limit = {
                scope:holding_type = flag:tribal_holding
            }

            every_in_list = {
                variable = DI_action_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = {
                            province_has_no_holding_trigger = yes
                        }
                        begin_create_holding = tribal_holding
                    }
                    set_holding_type = tribal_holding
                }
            }
        }
        else_if = {
            limit = {
                scope:holding_type = flag:herder_holding
            }

            every_in_list = {
                variable = DI_action_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = {
                            province_has_no_holding_trigger = yes
                        }
                        begin_create_holding = herder_holding
                    }
                    set_holding_type = herder_holding
                }
            }
        }
        else_if = {
            limit = {
                scope:holding_type = flag:nomad_holding
            }

            every_in_list = {
                variable = DI_action_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = {
                            province_has_no_holding_trigger = yes
                        }
                        begin_create_holding = nomad_holding
                    }
                    set_holding_type = nomad_holding
                }
            }
        }
        else_if = {
            limit = {
                scope:holding_type = flag:temple_citadel_holding
            }

            every_in_list = {
                variable = DI_action_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = {
                            province_has_no_holding_trigger = yes
                        }
                        begin_create_holding = temple_citadel_holding
                    }
                    set_holding_type = temple_citadel_holding
                }
            }
        }
    }
}

DI_load_province_dropdown = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_global_variable_list = DI_province_filter_choices }
            NOT = { has_global_variable = DI_province_filters_1d1f2c245368_loaded }
        }
    }

    effect = {
        save_scope_as = player

        clear_global_variable_list = DI_province_filter_choices
        set_global_variable = DI_province_filters_1d1f2c245368_loaded

        add_to_global_variable_list = { name = DI_province_filter_choices target = flag:DI_province_filter_all }
        add_to_global_variable_list = { name = DI_province_filter_choices target = flag:DI_province_filter_hide }
        add_to_global_variable_list = { name = DI_province_filter_choices target = flag:DI_province_filter_capital }
        add_to_global_variable_list = { name = DI_province_filter_choices target = flag:DI_holding_filter_castle_holding }
        add_to_global_variable_list = { name = DI_province_filter_choices target = flag:DI_holding_filter_city_holding }
        add_to_global_variable_list = { name = DI_province_filter_choices target = flag:DI_holding_filter_church_holding }
        add_to_global_variable_list = { name = DI_province_filter_choices target = flag:DI_holding_filter_tribal_holding }
        add_to_global_variable_list = { name = DI_province_filter_choices target = flag:DI_holding_filter_herder_holding }
        add_to_global_variable_list = { name = DI_province_filter_choices target = flag:DI_holding_filter_nomad_holding }
        add_to_global_variable_list = { name = DI_province_filter_choices target = flag:DI_holding_filter_temple_citadel_holding }
        add_to_global_variable_list = { name = DI_province_filter_choices target = flag:DI_province_filter_empty }
    }
}

DI_apply_province_filter_choice = {
    scope = character # Player Character

    saved_scopes = {
        filter_choice # Filter choice to apply
    }

    effect = {
        save_scope_as = player

        if = {
            limit = { scope:filter_choice = flag:DI_province_filter_all }

            if = {
                limit = { has_variable_list = DI_action_provinces }
                clear_variable_list = DI_action_provinces
            }
            else = {
                every_in_list = {
                    variable = DI_selected_titles_provinces
                    save_scope_as = province
                    scope:player = {
                        add_to_variable_list = {
                            name = DI_action_provinces
                            target = scope:province
                        }
                    }
                }

                if = {
                    limit = { has_variable = DI_provinces_hide }
                    clear_variable_list = DI_shown_provinces
                    every_in_list = {
                        variable = DI_selected_titles_provinces
                        save_scope_as = province
                        scope:player = {
                            add_to_variable_list = {
                                name = DI_shown_provinces
                                target = scope:province
                            }
                        }
                    }
                }
            }
        }
        else_if = {
            limit = { scope:filter_choice = flag:DI_province_filter_hide }

            if = {
                limit = { has_variable_list = DI_action_provinces }
                clear_variable_list = DI_shown_provinces

                if = {
                    limit = { has_variable = DI_provinces_hide }
                    remove_variable = DI_provinces_hide
                    every_in_list = {
                        variable = DI_selected_titles_provinces
                        save_scope_as = province
                        scope:player = {
                            add_to_variable_list = {
                                name = DI_shown_provinces
                                target = scope:province
                            }
                        }
                    }
                }
                else = {
                    set_variable = DI_provinces_hide
                    every_in_list = {
                        variable = DI_action_provinces
                        save_scope_as = province
                        scope:player = {
                            add_to_variable_list = {
                                name = DI_shown_provinces
                                target = scope:province
                            }
                        }
                    }
                }
            }
            else = {
                if = {
                    limit = { has_variable = DI_provinces_hide }
                    remove_variable = DI_provinces_hide
                    clear_variable_list = DI_shown_provinces
                    every_in_list = {
                        variable = DI_selected_titles_provinces
                        save_scope_as = province
                        scope:player = {
                            add_to_variable_list = {
                                name = DI_shown_provinces
                                target = scope:province
                            }
                        }
                    }
                }
                else = {
                    every_in_list = {
                        variable = DI_selected_titles_provinces
                        save_scope_as = province
                        scope:player = {
                            add_to_variable_list = {
                                name = DI_shown_provinces
                                target = scope:province
                            }
                        }
                    }
                }
            }
        }
        else_if = {
            limit = { scope:filter_choice = flag:DI_province_filter_capital }
            clear_variable_list = DI_action_provinces
            if = {
                limit = { has_variable = DI_provinces_hide }
                clear_variable_list = DI_shown_provinces
            }

            every_in_list = {
                variable = DI_selected_titles_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = { is_county_capital = yes }
                        scope:player = {
                            add_to_variable_list = {
                                name = DI_action_provinces
                                target = scope:province
                            }
                            if = {
                                limit = { has_variable = DI_provinces_hide }
                                add_to_variable_list = {
                                    name = DI_shown_provinces
                                    target = scope:province
                                }
                            }
                        }
                    }
                }
            }
        }
        else_if = {
            limit = { scope:filter_choice = flag:DI_holding_filter_castle_holding }
            clear_variable_list = DI_action_provinces
            if = {
                limit = { has_variable = DI_provinces_hide }
                clear_variable_list = DI_shown_provinces
            }

            every_in_list = {
                variable = DI_selected_titles_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = { has_holding_type = castle_holding }
                        scope:player = {
                            add_to_variable_list = {
                                name = DI_action_provinces
                                target = scope:province
                            }
                            if = {
                                limit = { has_variable = DI_provinces_hide }
                                add_to_variable_list = {
                                    name = DI_shown_provinces
                                    target = scope:province
                                }
                            }
                        }
                    }
                }
            }
        }
        else_if = {
            limit = { scope:filter_choice = flag:DI_holding_filter_city_holding }
            clear_variable_list = DI_action_provinces
            if = {
                limit = { has_variable = DI_provinces_hide }
                clear_variable_list = DI_shown_provinces
            }

            every_in_list = {
                variable = DI_selected_titles_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = { has_holding_type = city_holding }
                        scope:player = {
                            add_to_variable_list = {
                                name = DI_action_provinces
                                target = scope:province
                            }
                            if = {
                                limit = { has_variable = DI_provinces_hide }
                                add_to_variable_list = {
                                    name = DI_shown_provinces
                                    target = scope:province
                                }
                            }
                        }
                    }
                }
            }
        }
        else_if = {
            limit = { scope:filter_choice = flag:DI_holding_filter_church_holding }
            clear_variable_list = DI_action_provinces
            if = {
                limit = { has_variable = DI_provinces_hide }
                clear_variable_list = DI_shown_provinces
            }

            every_in_list = {
                variable = DI_selected_titles_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = { has_holding_type = church_holding }
                        scope:player = {
                            add_to_variable_list = {
                                name = DI_action_provinces
                                target = scope:province
                            }
                            if = {
                                limit = { has_variable = DI_provinces_hide }
                                add_to_variable_list = {
                                    name = DI_shown_provinces
                                    target = scope:province
                                }
                            }
                        }
                    }
                }
            }
        }
        else_if = {
            limit = { scope:filter_choice = flag:DI_holding_filter_tribal_holding }
            clear_variable_list = DI_action_provinces
            if = {
                limit = { has_variable = DI_provinces_hide }
                clear_variable_list = DI_shown_provinces
            }

            every_in_list = {
                variable = DI_selected_titles_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = { has_holding_type = tribal_holding }
                        scope:player = {
                            add_to_variable_list = {
                                name = DI_action_provinces
                                target = scope:province
                            }
                            if = {
                                limit = { has_variable = DI_provinces_hide }
                                add_to_variable_list = {
                                    name = DI_shown_provinces
                                    target = scope:province
                                }
                            }
                        }
                    }
                }
            }
        }
        else_if = {
            limit = { scope:filter_choice = flag:DI_holding_filter_herder_holding }
            clear_variable_list = DI_action_provinces
            if = {
                limit = { has_variable = DI_provinces_hide }
                clear_variable_list = DI_shown_provinces
            }

            every_in_list = {
                variable = DI_selected_titles_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = { has_holding_type = herder_holding }
                        scope:player = {
                            add_to_variable_list = {
                                name = DI_action_provinces
                                target = scope:province
                            }
                            if = {
                                limit = { has_variable = DI_provinces_hide }
                                add_to_variable_list = {
                                    name = DI_shown_provinces
                                    target = scope:province
                                }
                            }
                        }
                    }
                }
            }
        }
        else_if = {
            limit = { scope:filter_choice = flag:DI_holding_filter_nomad_holding }
            clear_variable_list = DI_action_provinces
            if = {
                limit = { has_variable = DI_provinces_hide }
                clear_variable_list = DI_shown_provinces
            }

            every_in_list = {
                variable = DI_selected_titles_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = { has_holding_type = nomad_holding }
                        scope:player = {
                            add_to_variable_list = {
                                name = DI_action_provinces
                                target = scope:province
                            }
                            if = {
                                limit = { has_variable = DI_provinces_hide }
                                add_to_variable_list = {
                                    name = DI_shown_provinces
                                    target = scope:province
                                }
                            }
                        }
                    }
                }
            }
        }
        else_if = {
            limit = { scope:filter_choice = flag:DI_holding_filter_temple_citadel_holding }
            clear_variable_list = DI_action_provinces
            if = {
                limit = { has_variable = DI_provinces_hide }
                clear_variable_list = DI_shown_provinces
            }

            every_in_list = {
                variable = DI_selected_titles_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = { has_holding_type = temple_citadel_holding }
                        scope:player = {
                            add_to_variable_list = {
                                name = DI_action_provinces
                                target = scope:province
                            }
                            if = {
                                limit = { has_variable = DI_provinces_hide }
                                add_to_variable_list = {
                                    name = DI_shown_provinces
                                    target = scope:province
                                }
                            }
                        }
                    }
                }
            }
        }
        else_if = {
            limit = { scope:filter_choice = flag:DI_province_filter_empty }
            clear_variable_list = DI_action_provinces
            if = {
                limit = { has_variable = DI_provinces_hide }
                clear_variable_list = DI_shown_provinces
            }

            every_in_list = {
                variable = DI_selected_titles_provinces
                save_scope_as = province

                scope:province = {
                    if = {
                        limit = { has_holding = no }
                        scope:player = {
                            add_to_variable_list = {
                                name = DI_action_provinces
                                target = scope:province
                            }
                            if = {
                                limit = { has_variable = DI_provinces_hide }
                                add_to_variable_list = {
                                    name = DI_shown_provinces
                                    target = scope:province
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
