# #
# Era
# #

# SCOPE: GLOBAL
ET_set_new_era = {
    custom_effect_tooltip = ET_set_new_era_tt
    hidden_effect = {
        set_global_flag = ET_flag_global_newera
    }
}
# SCOPE: GLOBAL
ET_remove_new_era = {
    custom_effect_tooltip = ET_remove_new_era_tt
    hidden_effect = {
        clr_global_flag = ET_flag_global_newera
    }
}

# SCOPE: TARGET
ET_set_new_era_country = {
    custom_effect_tooltip = ET_set_new_era_country_tt
    hidden_effect = {
        set_country_flag = ET_flag_country_newera
    }
}
# SCOPE: TARGET
ET_remove_new_era_country = {
    custom_effect_tooltip = ET_remove_new_era_country_tt
    hidden_effect = {
        clr_country_flag = ET_flag_country_newera
    }
}

# #
# Scenario
# #

# SCOPE: TARGET
ET_set_scenario = {
    if = {      # Cold War                [ET_flag_global_scenario_1]
        limit = {
            NOT = { has_global_flag = ET_flag_global_allies_surrender_to_ger }
            NOT = { has_global_flag = ET_flag_global_eng_abandon_pasific }
            NOT = { has_global_flag = ET_flag_global_usa_surrender_to_jap }
            
            has_global_flag = had_yalta_conference

            # Focuses
            USA = { NOT = { has_completed_focus = USA_america_first } }
            ENG = { has_completed_focus = uk_empire_focus }
            ENG = { has_completed_focus = ENG_steady_as_she_goes }
            GER = { has_completed_focus = GER_rhineland }
            SOV = { has_completed_focus = SOV_the_centre }

            # Nations
            country_exists = USA
            country_exists = ENG
            country_exists = FRA
            country_exists = SOV
            USA = { has_government = democratic }
            ENG = { has_government = democratic }
            FRA = { has_government = democratic }
            SOV = { has_government = communism }


        }
        set_global_flag = ET_flag_global_scenario_1
        ET_scenario_allow_decolonization = yes

        every_country = {
            limit = { always = yes }
            news_event = {
                id = ET_Scenario_1.0
                days = 3
            }
            # Disabled needs updating and rework
            #country_event = {
            #    id = ET_S1_Division_Init.0
            #    days = 3
            #}
        }
    }
    else_if = { # A Eagle World           [ET_flag_global_scenario_2]
        limit = {
            NOT = { has_global_flag = ET_flag_global_usa_surrender_to_jap }
            has_global_flag = ET_flag_global_allies_surrender_to_ger
            
            # Focuses
            GER = { has_completed_focus = GER_rhineland }

            # Nations
            OR = { # ENG
                NOT = { country_exists = ENG }
                ENG = { NOT = { has_government = democratic } }
            }

            OR = { # SOV
                NOT = { country_exists = SOV }
                SOV = { NOT = { has_government = communism } }
            }

            country_exists = GER
            GER = { has_government = fascism }

            country_exists = USA
            USA = { has_government = democratic }
        }
        set_global_flag = ET_flag_global_scenario_2

        every_country = {
            limit = { always = yes }
            news_event = {
                id = ET_Scenario_2.0
                days = 3
            }
        }
    }
    else_if = { # A Dragon Empire         [ET_flag_global_scenario_3]
        limit = {
            NOT = { has_global_flag = ET_flag_global_allies_surrender_to_ger }

            has_global_flag = ET_flag_global_usa_surrender_to_jap
            has_global_flag = ET_flag_global_eng_abandon_pasific
            #has_global_flag = ET_flag_global_fra_abandon_pasific

            # Focuses
            GER = { has_completed_focus = GER_rhineland }

            # Nations
            OR = {
                NOT = { country_exists = GER }
                GER = { NOT = { has_government = fascism } }
            }

            country_exists = USA
            USA = { has_government = democratic }

            country_exists = ENG
            ENG = { has_government = democratic }
        }
        
        set_global_flag = ET_flag_global_scenario_3
        #every_country = {
        #    limit = { always = yes }
        #    news_event = {
        #        id = ET_Scenario_3.0
        #        days = 3
        #    }
        #}
    }
    else_if = { # Unused                  [ET_flag_global_scenario_4]
        limit = { always = no }
        set_global_flag = ET_flag_global_scenario_4
    }
    else_if = { # Unused                  [ET_flag_global_scenario_5]
        limit = { always = no }
        set_global_flag = ET_flag_global_scenario_5
    }
    else_if = { # Unused                  [ET_flag_global_scenario_6]
        limit = { always = no }
        set_global_flag = ET_flag_global_scenario_6
    }
    else_if = { # Unused                  [ET_flag_global_scenario_7]
        limit = { always = no }
        set_global_flag = ET_flag_global_scenario_7
    }
    else_if = { # Unused                  [ET_flag_global_scenario_8]
        limit = { always = no }
        set_global_flag = ET_flag_global_scenario_8
    }
    else_if = { # Unused                  [ET_flag_global_scenario_9]
        limit = { always = no }
        set_global_flag = ET_flag_global_scenario_9
    }
    else_if = { # Unused                  [ET_flag_global_scenario_10]
        limit = { always = no }
        set_global_flag = ET_flag_global_scenario_10
    }
    else_if = { # Unused                  [ET_flag_global_scenario_11]
        limit = { always = no }
        set_global_flag = ET_flag_global_scenario_11
    }
    else_if = { # Unused                  [ET_flag_global_scenario_12]
        limit = { always = no }
        set_global_flag = ET_flag_global_scenario_12
    }
    else = {    # Unknown World           [ET_flag_global_scenario_0]
        set_global_flag = ET_flag_global_scenario_0
        ET_scenario_allow_decolonization = yes
        #every_country = {
        #    limit = { always = yes }
        #    news_event = {
        #        id = ET_Scenario_0.0
        #        days = 3
        #    }
        #}
    }
}

# SCOPE: TARGET
ET_set_new_era_effect = {
    if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] Applying new era effects" }
    hidden_effect = {
        # Set new focustree
        ET_set_new_focus_tree_effect = yes
        ET_clr_modifiers_effect = yes
        
        if = {
            limit = { has_idea = civilian_economy }
            set_country_flag = ET_flag_country_HasDemobalizedEconomy
        }
        
        ET_set_new_era_country = yes
    }
}
# SCOPE: TARGET
ET_clr_modifiers_effect = {
    if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] Clearing National Focus Modifiers" }
}
# SCOPE: TARGET
ET_set_new_focus_tree_effect = {
    custom_effect_tooltip = ET_set_new_focus_tree_effect_tt
    hidden_effect = {
        if = {      # Scenario_1
            limit = { ET_has_scenario_1 = yes }
            if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] Applying scenario 1 focus tree" }

            if = {      # ENG
                limit = { original_tag = ENG }   
                if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] have changed focus tree to ENG" }
                load_focus_tree = { tree = ET_S1_ENG keep_completed = yes }
            }
            else_if = { # FRA
                limit = { original_tag = FRA }   
                if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] have changed focus tree to FRA" }
                load_focus_tree = { tree = ET_S1_FRA keep_completed = yes }
            }
            else_if = { # SOV
                limit = { original_tag = SOV }   
                if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] have changed focus tree to SOV" }
                load_focus_tree = { tree = ET_S1_SOV keep_completed = yes }
            }
            else_if = { # USA
                limit = { original_tag = USA }
                if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] have changed focus tree to USA" }
                load_focus_tree = { tree = ET_S1_USA keep_completed = yes }
            }
            else = {    # Generic
                if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] have changed focus tree to GENERIC" }
                load_focus_tree = { tree = ET_Generic keep_completed = yes }
            }
        }
        else_if = { # Scenario_2
            limit = { ET_has_scenario_2 = yes }
            if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] Applying scenario 2 focus tree" }

            if = {      # ENG
                limit = { original_tag = ENG }
                if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] have changed focus tree to ENG" }
                load_focus_tree = { tree = ET_S2_ENG keep_completed = yes }
            }
            else_if = { # GER
                limit = { original_tag = GER }   
                if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] have changed focus tree to GER" }
                load_focus_tree = { tree = ET_S2_GER keep_completed = yes }
            }
            else_if = { # USA
                limit = { original_tag = USA }   
                if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] have changed focus tree to USA" }
                load_focus_tree = { tree = ET_S2_USA keep_completed = yes }
            }
            else = {    # GENERIC
                if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] have changed focus tree to GENERIC" }
                load_focus_tree = { tree = ET_Generic keep_completed = yes }
            }
        }
        else_if = { # Scenario_3
            limit = { ET_has_scenario_3 = yes }
            if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] Applying scenario 3 focus tree" }
            
            if = {      # JAP
                limit = { original_tag = JAP }
                load_focus_tree = { tree = ET_S3_JAP keep_completed = yes }
            }
            else = {    # GENREIC
                if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] have changed focus tree to GENERIC" }
                load_focus_tree = { tree = ET_Generic keep_completed = yes }
            }
        }
        #else_if = { # Scenario_4
        #}
        #else_if = { # Scenario_5
        #}
        #else_if = { # Scenario_6
        #}
        #else_if = { # Scenario_7
        #}
        #else_if = { # Scenario_8
        #}
        #else_if = { # Scenario_9
        #}
        #else_if = { # Scenario_10
        #}
        #else_if = { # Scenario_11
        #}
        #else_if = { # Scenario_12
        #}
        else = {    # Scenario_0
            if = { limit = { is_debug = yes } log = "[GetDateText]: [This.Owner.GetTag] have changed focus tree to GENERIC" }
            load_focus_tree = { tree = ET_Generic keep_completed = yes }
        }
    }
}

# Checks

# SCOPE: GLOBAL
ET_scenario_allow_decolonization = {
    set_global_flag = ET_flag_global_allow_decolonization
}