# Reduce Mosley's pacifism
ENG_mosley_pacifism_level_down = {
	if = {
		limit = {
			has_country_leader_with_trait = champion_of_peace_5
		}
		remove_country_leader_trait = champion_of_peace_5
	}
	else_if = {
		limit = {
			has_country_leader_with_trait = champion_of_peace_4
		}
		swap_ruler_traits = { remove = champion_of_peace_4 add = champion_of_peace_5 }
	}
	else_if = {
		limit = {
			has_country_leader_with_trait = champion_of_peace_3
		}
		swap_ruler_traits = { remove = champion_of_peace_3 add = champion_of_peace_4 }
	}
	else_if = {
		limit = {
			has_country_leader_with_trait = champion_of_peace_2
		}
		swap_ruler_traits = { remove = champion_of_peace_2 add = champion_of_peace_3 }
	}
	else_if = {
		limit = {
			has_country_leader_with_trait = champion_of_peace_1
		}
		swap_ruler_traits = { remove = champion_of_peace_1 add = champion_of_peace_2 }
	}
}

# Increase Imperial Defense spirit
ENG_imperial_conference_defense_level_up = {
	if = {
		limit = {
			has_idea = ENG_imperial_conference_defense_4
		}
		swap_ideas = {
			remove_idea = ENG_imperial_conference_defense_4
			add_idea = ENG_imperial_conference_defense_5
		}
	}
	else_if = {
		limit = {
			has_idea = ENG_imperial_conference_defense_3
		}
		swap_ideas = {
			remove_idea = ENG_imperial_conference_defense_3
			add_idea = ENG_imperial_conference_defense_4
		}
	}
	else_if = {
		limit = {
			has_idea = ENG_imperial_conference_defense_2
		}
		swap_ideas = {
			remove_idea = ENG_imperial_conference_defense_2
			add_idea = ENG_imperial_conference_defense_3
		}
	}
	else_if = {
		limit = {
			has_idea = ENG_imperial_conference_defense_1
		}
		swap_ideas = {
			remove_idea = ENG_imperial_conference_defense_1
			add_idea = ENG_imperial_conference_defense_2
		}
	}
	else_if = {
		limit = {
			NOT = { has_idea = ENG_imperial_conference_defense_1 }
			NOT = { has_idea = ENG_imperial_conference_defense_2 }
			NOT = { has_idea = ENG_imperial_conference_defense_3 }
			NOT = { has_idea = ENG_imperial_conference_defense_4 }
			NOT = { has_idea = ENG_imperial_conference_defense_5 }
		}
		add_timed_idea = { idea = ENG_imperial_conference_defense_1 days = 365 }
	}
}

# Increase Imperial Economy spirit
ENG_imperial_conference_economy_level_up = {
	if = {
		limit = {
			has_idea = ENG_imperial_conference_economy_4
		}
		swap_ideas = {
			remove_idea = ENG_imperial_conference_economy_4
			add_idea = ENG_imperial_conference_economy_5
		}
	}
	else_if = {
		limit = {
			has_idea = ENG_imperial_conference_economy_3
		}
		swap_ideas = {
			remove_idea = ENG_imperial_conference_economy_3
			add_idea = ENG_imperial_conference_economy_4
		}
	}
	else_if = {
		limit = {
			has_idea = ENG_imperial_conference_economy_2
		}
		swap_ideas = {
			remove_idea = ENG_imperial_conference_economy_2
			add_idea = ENG_imperial_conference_economy_3
		}
	}
	else_if = {
		limit = {
			has_idea = ENG_imperial_conference_economy_1
		}
		swap_ideas = {
			remove_idea = ENG_imperial_conference_economy_1
			add_idea = ENG_imperial_conference_economy_2
		}
	}
	else_if = {
		limit = {
			NOT = { has_idea = ENG_imperial_conference_economy_1 }
			NOT = { has_idea = ENG_imperial_conference_economy_2 }
			NOT = { has_idea = ENG_imperial_conference_economy_3 }
			NOT = { has_idea = ENG_imperial_conference_economy_4 }
			NOT = { has_idea = ENG_imperial_conference_economy_5 }
		}
		add_timed_idea = { idea = ENG_imperial_conference_economy_1 days = 365 }
	}
}

# Set amount of subjects in variable
ENG_imperial_conference_set_subject_counter = {
	set_variable = {
		var = ENG_imperial_conference_number_of_subjects
		value = 0
	}
	if = {
		limit = {
			CAN = {
				exists = yes
				is_subject_of = ROOT
			}
		}
		add_to_variable = {
			var = ENG_imperial_conference_number_of_subjects
			value = 1
		}
	}
	if = {
		limit = {
			SAF = {
				exists = yes
				is_subject_of = ROOT
			}
		}
		add_to_variable = {
			var = ENG_imperial_conference_number_of_subjects
			value = 1
		}
	}
	if = {
		limit = {
			RAJ = {
				exists = yes
				is_subject_of = ROOT
			}
		}
		add_to_variable = {
			var = ENG_imperial_conference_number_of_subjects
			value = 1
		}
	}
	if = {
		limit = {
			AST = {
				exists = yes
				is_subject_of = ROOT
			}
		}
		add_to_variable = {
			var = ENG_imperial_conference_number_of_subjects
			value = 1
		}
	}
	if = {
		limit = {
			NZL = {
				exists = yes
				is_subject_of = ROOT
			}
		}
		add_to_variable = {
			var = ENG_imperial_conference_number_of_subjects
			value = 1
		}
	}
}

# Clear Imperial Conference flags
ENG_imperial_conference_clear_in_progress_flags = {
	if = {
		limit = {
			has_country_flag = ENG_imperial_defense_flag
			check_variable = { var = ENG_imperial_conference_defense_answers value = ENG_imperial_conference_number_of_subjects compare = equals }
		}
		clr_country_flag = ENG_imperial_conference_discussion_in_progress
		clr_country_flag = ENG_diplomatic_pressure_flag
		clr_country_flag = ENG_extensive_diplomatic_pressure_flag
		clr_country_flag = ENG_imperial_defense_flag
	}
	if = {
		limit = {
			has_country_flag = ENG_imperial_trade_flag
			check_variable = { var = ENG_imperial_conference_trade_answers value = ENG_imperial_conference_number_of_subjects compare = equals }
		}
		clr_country_flag = ENG_imperial_conference_discussion_in_progress
		clr_country_flag = ENG_diplomatic_pressure_flag
		clr_country_flag = ENG_extensive_diplomatic_pressure_flag
		clr_country_flag = ENG_imperial_trade_flag
	}
	if = {
		limit = {
			has_country_flag = ENG_imperial_economy_flag
			check_variable = { var = ENG_imperial_conference_economy_answers value = ENG_imperial_conference_number_of_subjects compare = equals }
		}
		clr_country_flag = ENG_imperial_conference_discussion_in_progress
		clr_country_flag = ENG_diplomatic_pressure_flag
		clr_country_flag = ENG_extensive_diplomatic_pressure_flag
		clr_country_flag = ENG_imperial_economy_flag
	}
	if = {
		limit = {
			has_country_flag = ENG_imperial_appeasement_flag
			check_variable = { var = ENG_imperial_conference_appeasement_answers value = ENG_imperial_conference_number_of_subjects compare = equals }
		}
		clr_country_flag = ENG_imperial_conference_discussion_in_progress
		clr_country_flag = ENG_diplomatic_pressure_flag
		clr_country_flag = ENG_extensive_diplomatic_pressure_flag
		clr_country_flag = ENG_imperial_appeasement_flag
	}
	if = {
		limit = {
			has_country_flag = ENG_imperial_federation_flag
			check_variable = { var = ENG_imperial_conference_federation_answers value = ENG_imperial_conference_number_of_subjects compare = equals }
		}
		clr_country_flag = ENG_imperial_conference_discussion_in_progress
		clr_country_flag = ENG_diplomatic_pressure_flag
		clr_country_flag = ENG_extensive_diplomatic_pressure_flag
		clr_country_flag = ENG_imperial_federation_flag
	}
}

# Increase Trade Union Support costs
ENG_request_trade_union_support_cost_level_up = {
	if = {
		limit = {
			NOT = { check_variable = { ENG_trade_unions_support_shared > 0 } }
			NOT = { check_variable = { ENG_trade_unions_support_shared < 0 } }
		}
		set_variable = { var = ENG_trade_unions_support_shared value = 0 }
	}
	add_to_variable = { var = ENG_trade_unions_support_shared value = 10 }
	set_variable = { var = ENG_trade_unions_support_50_cost value = 50 }
	add_to_variable = { var = ENG_trade_unions_support_50_cost value = ENG_trade_unions_support_shared }
	set_variable = { var = ENG_trade_unions_support_75_cost value = 75 }
	add_to_variable = { var = ENG_trade_unions_support_75_cost value = ENG_trade_unions_support_shared }
	custom_effect_tooltip = ENG_request_trade_union_support_cost_level_up_tt
}

# Decrease Trade Union Support costs
ENG_request_trade_union_support_cost_level_down = {
	if = {
		limit = {
			NOT = { check_variable = { ENG_trade_unions_support_shared > 0 } }
			NOT = { check_variable = { ENG_trade_unions_support_shared < 0 } }
		}
		set_variable = { var = ENG_trade_unions_support_shared value = 0 }
	}
	add_to_variable = { var = ENG_trade_unions_support_shared value = -10 }
	if = {
		limit = {
			check_variable = { ENG_trade_unions_support_shared < -40 }
		}
		set_variable = { var = ENG_trade_unions_support_shared value = -40 }
	}
	set_variable = { var = ENG_trade_unions_support_50_cost value = 50 }
	add_to_variable = { var = ENG_trade_unions_support_50_cost value = ENG_trade_unions_support_shared }
	set_variable = { var = ENG_trade_unions_support_75_cost value = 75 }
	add_to_variable = { var = ENG_trade_unions_support_75_cost value = ENG_trade_unions_support_shared }
	custom_effect_tooltip = ENG_request_trade_union_support_cost_level_down_tt
}

CAN_enforce_loyalty = {
	set_country_flag = britain_enforced_our_loyalty
	if = {
		complete_national_focus = CAN_strengthen_the_commonwealth_ties
	}
	if = {
		limit = {
			has_idea = CAN_swastika_clubs
		}
		remove_ideas = CAN_swastika_clubs
	}
	if = {
		limit = {
			has_idea = CAN_swastika_clubs_2
		}
		remove_ideas = CAN_swastika_clubs_2
	}
	if = {
		limit = {
			has_idea = CAN_swastika_clubs_skewer
		}
		remove_ideas = CAN_swastika_clubs_skewer
	}
	if = {
		limit = {
			is_in_tech_sharing_group = us_research
		}
		remove_from_tech_sharing_group = us_research
	}
	if = {
		limit = {
			has_idea = CAN_communist_ideals
		}
		remove_ideas = CAN_communist_ideals
	}
	if = {
		limit = {
			has_idea = CAN_communist_ideals_2
		}
		remove_ideas = CAN_communist_ideals_2
	}
	if = {
		limit = {
			has_idea = CAN_communist_ideals_3
		}
		remove_ideas = CAN_communist_ideals_3
	}
	
}

SAF_enforce_loyalty = {
	set_country_flag = britain_enforced_our_loyalty
	if = {
		complete_national_focus = SAF_support_the_policy_of_appeasement
	}
	if = {
		limit = {
			has_idea = SAF_abandon_westminster
		}
		remove_ideas = SAF_abandon_westminster
	}
	if = {
		limit = {
			has_idea = SAF_abandon_westminster_fascism
		}
		remove_ideas = SAF_abandon_westminster_fascism
	}
	if = {
		limit = {
			has_idea = SAF_ossewabrandwag_fascism
		}
		swap_ideas = {
			remove_idea = SAF_ossewabrandwag_fascism
			add_idea = SAF_ossewabrandwag
		}
	}
	if = {
		limit = {
			has_idea = SAF_voortrekker_monument_2
		}
		swap_ideas = {
			remove_idea = SAF_voortrekker_monument_2
			add_idea = SAF_voortrekker_monument
		}
	}
	if = {
		limit = {
			has_idea = SAF_king_edward
		}
		remove_ideas = SAF_king_edward
	}
	if = {
		limit = {
			is_in_tech_sharing_group = axis_research
		}
		remove_from_tech_sharing_group = axis_research
	}
	if = {
		limit = {
			is_in_tech_sharing_group = comintern_research
		}
		remove_from_tech_sharing_group = comintern_research
	}
	if = {
		limit = {
			has_idea = SAF_abandon_westminster_communism
		}
		remove_ideas = SAF_abandon_westminster_communism
	}
	if = {
		limit = {
			has_idea = SAF_black_volunteers
		}
		remove_ideas = SAF_black_volunteers
	}
	if = {
		limit = {
			has_idea = SAF_voortrekker_monument_2
		}
		swap_ideas = {
			remove_idea = SAF_ossewabrandwag_2
			add_idea = SAF_ossewabrandwag
		}
	}
	if = {
		limit = {
			has_idea = SAF_equal_opportunities
		}
		remove_ideas = SAF_equal_opportunities
		add_ideas = SAF_ossewabrandwag
	}
	if = {
		limit = {
			has_idea = SAF_support_the_world_revolution
		}
		remove_ideas = SAF_support_the_world_revolution
	}
	if = {
		limit = {
			has_idea = SAF_soviet_advisers
		}
		remove_ideas = SAF_soviet_advisers
	}
	
}

RAJ_enforce_loyalty = {
	set_country_flag = britain_enforced_our_loyalty
	if = {
		complete_national_focus = RAJ_indian_national_congress
	}
	if = {
		limit = {
			has_idea = RAJ_all_india_forward_bloc
		}
		remove_ideas = RAJ_all_india_forward_bloc
	}
	if = {
		limit = {
			has_idea = RAJ_all_india_forward_bloc_fascism
		}
		remove_ideas = RAJ_all_india_forward_bloc_fascism
	}
	if = {
		limit = {
			has_idea = RAJ_all_india_forward_bloc_communism
		}
		remove_ideas = RAJ_all_india_forward_bloc_communism
	}
	if = {
		limit = {
			is_in_tech_sharing_group = comintern_research
		}
		remove_from_tech_sharing_group = comintern_research
	}
	if = {
		limit = {
			is_in_tech_sharing_group = axis_research
		}
		remove_from_tech_sharing_group = axis_research
	}
	if = {
		limit = {
			has_idea = CAN_communist_ideals
		}
		remove_ideas = CAN_communist_ideals
	}
	if = {
		limit = {
			has_idea = CAN_communist_ideals_2
		}
		remove_ideas = CAN_communist_ideals_2
	}
	if = {
		limit = {
			has_idea = CAN_communist_ideals_3
		}
		remove_ideas = CAN_communist_ideals_3
	}
	
}

AST_enforce_loyalty = {
	set_country_flag = britain_enforced_our_loyalty
	if = {
		complete_national_focus = AST_support_the_policy_of_appeasement
	}
	if = {
		limit = {
			has_idea = AST_abandon_the_westminster_system
		}
		remove_ideas = AST_abandon_the_westminster_system
	}
	if = {
		limit = {
			has_idea = AST_abandon_the_westminster_system_fascism
		}
		remove_ideas = AST_abandon_the_westminster_system_fascism
	}
	if = {
		limit = {
			is_in_tech_sharing_group = us_research
		}
		remove_from_tech_sharing_group = us_research
	}
	if = {
		limit = {
			is_in_tech_sharing_group = japanese_research
		}
		remove_from_tech_sharing_group = japanese_research
	}
	if = {
		limit = {
			is_in_tech_sharing_group = swpi_research
		}
		remove_from_tech_sharing_group = swpi_research
	}
	if = {
		limit = {
			is_in_tech_sharing_group = comintern_research
		}
		remove_from_tech_sharing_group = comintern_research
	}
	if = {
		limit = {
			has_idea = AST_abandon_the_westminster_system_communism
		}
		remove_ideas = AST_abandon_the_westminster_system_communism
	}
	if = {
		limit = {
			has_idea = AST_arms_for_the_revolution
		}
		remove_ideas = AST_arms_for_the_revolution
	}
	if = {
		limit = {
			has_idea = AST_direct_support
		}
		remove_ideas = AST_direct_support
	}
	
}

NZL_enforce_loyalty = {
	set_country_flag = britain_enforced_our_loyalty
	if = {
		limit = {
			has_completed_focus = NZL_statute_of_westminster
		}
		complete_national_focus = NZL_strengthen_the_commonwealth
	}
	if = {
		limit = {
			has_idea = NZL_in_the_darkness
		}
		swap_ideas = {
			remove_idea = NZL_in_the_darkness
			add_idea = NZL_first_labor_government
		}
	}
	if = {
		limit = {
			has_idea = AST_abandon_the_westminster_system_fascism
		}
		remove_ideas = AST_abandon_the_westminster_system_fascism
	}
	if = {
		limit = {
			is_in_tech_sharing_group = japanese_research
		}
		remove_from_tech_sharing_group = japanese_research
	}
	if = {
		limit = {
			is_in_tech_sharing_group = comintern_research
		}
		remove_from_tech_sharing_group = comintern_research
	}
	if = {
		limit = {
			has_idea = NZL_the_workers_party_1
		}
		swap_ideas = {
			remove_idea = NZL_the_workers_party_1
			add_idea = NZL_first_labor_government
		}
	}
	if = {
		limit = {
			has_idea = NZL_the_workers_party_2
		}
		remove_ideas = NZL_the_workers_party_2
	}	
}

ENG_viceroy_reduce_autonomy_effect = {
	if = {
		limit = {
			ROOT = { has_country_leader_with_trait = viceroy_emeritus }
		}
		add_autonomy_ratio = {
			value = -0.10
			localization = uk_india_focus
		}
	}
	else = {
		add_autonomy_ratio = {
			value = -0.05
			localization = uk_india_focus
		}
	}
}
