﻿je_francocracia = {
    icon = "gfx/interface/icons/event_icons/event_portrait.dds"

	group = je_group_historical_content

    immediate = {
        ruler = {
            save_scope_as = francia_character_scope
            set_character_immortal = no
        }
    }

    complete = {
        custom_tooltip = {
            text = je_francocracia_tt
            NOT = {
                ruler = {
                    has_template = PRG_jose_gaspar_rodriguez_de_francia
                }
            }
        }
    }

    on_complete = {
        trigger_event = { id = paraguay.1 popup = yes }
        remove_modifier = hairy_feet_modifier
        set_variable = death_of_francia_var
    }

    weight = 1000
    should_be_pinned_by_default = yes
}

je_modernizing_paraguay = {
    icon = "gfx/interface/icons/event_icons/event_industry.dds"

	group = je_group_historical_content

    immediate = {
        g:iron = {
            save_scope_as = iron_scope
        }
        g:wood = {
            save_scope_as = wood_scope
        }
    }

    scripted_button = humanita_fortress_button
    scripted_button = ybycui_iron_works_button
    scripted_button = good_health_prg_button
    scripted_button = army_git_good_button

    complete = {
        scope:journal_entry = {
            is_goal_complete = yes
        }
        custom_tooltip = {
            text = je_modernizing_paraguay.tt_1
            has_global_variable = humanita_fortress_global_var
        }
        custom_tooltip = {
            text = je_modernizing_paraguay.tt_2
            has_global_variable = ybycui_iron_works_global_var
        }
        custom_tooltip = {
            text = je_modernizing_paraguay.tt_3
            has_global_variable = paraguay_army_reform_global_var
        }
        custom_tooltip = {
            text = je_modernizing_paraguay.tt_4
            has_global_variable = improve_living_conditions_global_var
        }
    }

    on_monthly_pulse = {
        random_events = {
            100 = 0
            10 = paraguay.2 # Napoleon of South America
        }
    }

    current_value = {
        value = root.gdp
    }

    goal_add_value = {
        value = root.gdp
    }

    progressbar = yes

    on_complete = {
        trigger_event = { id = paraguay.12 popup = yes }
        show_as_tooltip = {
            add_journal_entry = { type = je_expanding_paraguay }
        }
    }

    weight = 1000
    should_be_pinned_by_default = yes
}

je_expanding_paraguay = {
    icon = "gfx/interface/icons/event_icons/event_military.dds"

	group = je_group_historical_content

    immediate = {

    }

    complete = {
        owns_entire_state_region = STATE_CORRIENTES
        OR = {
            country_or_subject_owns_entire_state_region = STATE_URUGUAY
            country_or_subject_owns_entire_state_region = STATE_SANTA_FE
            country_or_subject_owns_entire_state_region = STATE_PARANA
            country_or_subject_owns_entire_state_region = STATE_RIO_GRANDE_DO_SUL
        }
    }

    fail = {
        custom_tooltip = {
            text = lost_war_tt
            OR = {
                has_variable = recently_lost_war
                AND = {
                    has_variable = recently_had_war
                    NOT = {
                        has_variable = recently_won_war
                    }
                }
            }
        }
    }

    on_fail = {
        trigger_event = { id = paraguay.8 popup = yes }
        show_as_tooltip = {
            if = {
                limit = {
                    any_scope_state = {
                        has_modifier = ybycui_iron_works_modifier
                    }
                }
                random_scope_state = {
                    limit = {
                        has_modifier = ybycui_iron_works_modifier
                    }
                    remove_modifier = ybycui_iron_works_modifier
                }
            }
            if = {
                limit = {
                    any_scope_state = {
                        has_modifier = ybycui_prisoner_workforce_modifier
                    }
                }
                random_scope_state = {
                    limit = {
                        has_modifier = ybycui_prisoner_workforce_modifier
                    }
                    remove_modifier = ybycui_prisoner_workforce_modifier
                }
            }
            if = {
                limit = {
                    any_scope_state = {
                        has_modifier = ybycui_steelworks
                    }
                }
                random_scope_state = {
                    limit = {
                        has_modifier = ybycui_steelworks
                    }
                    remove_modifier = ybycui_steelworks
                }
            }
            if = {
                limit = {
                    any_scope_state = {
                        has_modifier = humanita_fortress_modifier
                    }
                }
                random_scope_state = {
                    limit = {
                        has_modifier = humanita_fortress_modifier
                    }
                    remove_modifier = humanita_fortress_modifier
                }
            }
            if = {
                limit = {
                    any_scope_state = {
                        has_modifier = vaccinations_prg_modifier
                    }
                }
                random_scope_state = {
                    limit = {
                        has_modifier = vaccinations_prg_modifier
                    }
                    remove_modifier = vaccinations_prg_modifier
                }
            }
            if = {
                limit = {
                    any_scope_state = {
                        has_modifier = barracks_boost_paraguay_quantity_modifier
                    }
                }
                random_scope_state = {
                    limit = {
                        has_modifier = barracks_boost_paraguay_quantity_modifier
                    }
                    remove_modifier = barracks_boost_paraguay_quantity_modifier
                }
            }
            if = {
                limit = {
                    has_modifier = barracks_boost_paraguay_quality_modifier
                }
                remove_modifier = barracks_boost_paraguay_quality_modifier
            }
            if = {
                limit = {
                    any_scope_character = {
                        has_modifier = napoleon_of_the_americas_modifier
                    }
                }
                random_character = {
                    limit = {
                        has_modifier = napoleon_of_the_americas_modifier
                    }
                    kill_character = yes
                }
            }
            if = {
                limit = {
                    any_scope_character = {
                        has_modifier = el_excelentisimo_modifier
                    }
                }
                random_character = {
                    limit = {
                        has_modifier = el_excelentisimo_modifier
                    }
                    kill_character = yes
                }
            }
            if = {
                limit = {
                    ruler = {
                        NOR = {
                            has_modifier = el_excelentisimo_modifier
                            has_modifier = napoleon_of_the_americas_modifier
                        }
                    }
                }
                ruler = {
                    kill_character = yes
                }
            }
            if = {
                limit = {
                    any_scope_state = {
                        state_region = s:STATE_BAJO_PARAGUAY
                    }
                }
                s:STATE_BAJO_PARAGUAY.region_state:PRG = {
                    add_modifier = {
                        name = thus_unto_tyrants_modifier
                        months = long_modifier_time
                    }
                }
            }
            add_modifier = {
                name = a_broken_land_modifier
                months = long_modifier_time
            }
        }
    }

    on_complete = {
        trigger_event = { id = paraguay.9 popup = yes }
        set_variable = paraguay_war_victory_achievement
    }

    invalid = {
        is_subject = yes
    }

    weight = 1000
    should_be_pinned_by_default = yes
}

je_paraguayan_war = {
    icon = "gfx/interface/icons/event_icons/event_military.dds"

	group = je_group_historical_content

    immediate = {
        c:PRG ?= {
            save_scope_as = paraguay_scope
        }
    }

    complete = {
        OR = {
            AND = {
                custom_tooltip = {
                    text = je_paraguayan_war_tt_1
                    OR = {
                        c:PRG ?= {
                            has_variable = recently_lost_war
                        }
                    }
                    has_variable = recently_won_war
                }
                c:PRG = {
                    NOT = {
                        has_state_in_state_region = STATE_MATO_GROSSO
                        has_state_in_state_region = STATE_CORRIENTES
                        has_state_in_state_region = STATE_CHACO
                    }
                }
            }
            AND = {
                custom_tooltip = {
                    text = je_paraguayan_war_tt_1
                    has_variable = recently_won_war
                }
                NOT = { 
                    c:PRG = { 
                        is_country_alive = yes 
                    } 
                }
            }
        }
    }
    
    fail = {
        custom_tooltip = {
            text = je_paraguayan_war_tt_2
            c:PRG ?= {
                has_variable = recently_won_war
            }
            has_variable = recently_lost_war
        }
        c:PRG ?= {
            has_state_in_state_region = STATE_CORRIENTES
            OR = {
                country_or_subject_owns_entire_state_region = STATE_URUGUAY
                country_or_subject_owns_entire_state_region = STATE_SANTA_FE
                country_or_subject_owns_entire_state_region = STATE_PARANA
                country_or_subject_owns_entire_state_region = STATE_RIO_GRANDE_DO_SUL
            }
        }
    }

    on_fail = {
        trigger_event = { id = paraguay.10 popup = yes }
    }

    on_complete = {
        trigger_event = { id = paraguay.7 popup = yes }
    }

    invalid = {
        c:PRG ?= {
            has_journal_entry = je_expanding_paraguay
            NOT = {
                has_war_with = root
            }
            any_diplomatic_play = {
                is_war = yes
                initiator = prev
                target = {
                    any_scope_state = {
                        OR = {
                            state_region = s:STATE_CORRIENTES
                            state_region = s:STATE_URUGUAY
                            state_region = s:STATE_SANTA_FE
                            state_region = s:STATE_PARANA
                            state_region = s:STATE_RIO_GRANDE_DO_SUL
                        }
                    }
                    root = {
                        has_interest_marker_in_region = prev.capital.region
                    }
                }
                OR = {
                    has_play_goal = conquer_state
                    has_play_goal = return_state
                    has_play_goal = make_tributary
                    has_play_goal = make_dominion
                    has_play_goal = make_protectorate
                }
            }
        }
    }

    weight = 1000
    should_be_pinned_by_default = yes
}
