﻿je_british_dictate_plantations = {
	should_be_pinned_by_default = yes
	icon = "gfx/interface/icons/company_icons/historical_company_icons/gb_eic.dds"

	group = je_group_crises

	timeout = 1825

	immediate = {
		set_variable = { name = count_relevant_plantations value = 0 }
		top_overlord = {
			save_scope_as = overlord_scope
		}
		every_scope_building = {
			limit = {
				OR = {
					AND = {
						ROOT = { var:dictate_plantation_type = 1 }
						is_building_type = building_opium_plantation
					}
					AND = {
						ROOT = { var:dictate_plantation_type = 2 }
						is_building_type = building_tea_plantation
					}
					AND = {
						ROOT = { var:dictate_plantation_type = 3 }
						is_building_type = building_dye_plantation
					}
					AND = {
						ROOT = { var:dictate_plantation_type = 4 }
						is_building_type = building_cotton_plantation
					}
					AND = {
						ROOT = { var:dictate_plantation_type = 5 }
						is_building_type = building_tobacco_plantation
					}
				}
			}
			ROOT = {
				change_variable = { name = count_relevant_plantations add = PREV.level }
			}
		}
		set_variable = { name = count_relevant_plantations_increase_percent value = var:count_relevant_plantations }
		change_variable = { name = count_relevant_plantations_increase_percent multiply = 0.25 }
		clamp_variable = { name = count_relevant_plantations_increase_percent max = 50 min = 10 }
		change_variable = { name = count_relevant_plantations_increase_percent divide = var:count_relevant_plantations }
	}

	on_weekly_pulse = {
		effect = {
			set_variable = { name = count_relevant_plantations value = 0 }
			every_scope_building = {
				limit = {
					OR = {
						AND = {
							ROOT = { var:dictate_plantation_type = 1 }
							is_building_type = building_opium_plantation
						}
						AND = {
							ROOT = { var:dictate_plantation_type = 2 }
							is_building_type = building_tea_plantation
						}
						AND = {
							ROOT = { var:dictate_plantation_type = 3 }
							is_building_type = building_dye_plantation
						}
						AND = {
							ROOT = { var:dictate_plantation_type = 4 }
							is_building_type = building_cotton_plantation
						}
						AND = {
							ROOT = { var:dictate_plantation_type = 5 }
							is_building_type = building_tobacco_plantation
						}
					}
				}
				ROOT = {
					change_variable = { name = count_relevant_plantations add = PREV.level }
				}
			}
		}
	}

	complete = {
		scope:journal_entry = {
			is_goal_complete = yes
		}
	}

	invalid = {
		NOT = {
			is_subject_of = scope:overlord_scope
		}
	}

	on_complete = {
		change_relations = {
			country = top_overlord
			value = 20
		}
		random_political_lobby = {
			limit = {
				is_political_lobby_type = lobby_pro_overlord
			}
			change_appeasement = {
				amount = 3
				factor = appeasement_british_dictate_succeeded
			}
		}
	}

	on_timeout = {
		change_relations = {
			country = top_overlord
			value = -15
		}
		random_political_lobby = {
			limit = {
				is_political_lobby_type = lobby_pro_overlord
			}
			change_appeasement = {
				amount = -5
				factor = appeasement_british_dictate_failed
			}
		}
	}

	current_value = {
		value = root.var:count_relevant_plantations
	}

	goal_add_value = {
		value = root.var:count_relevant_plantations
		multiply = 0.25
		max = 50
		min = 10
		round = 1
	}

	progressbar = yes

	weight = 1000
}

je_british_dictate_military = {
	should_be_pinned_by_default = yes
	icon = "gfx/interface/icons/invention_icons/mandatory_service.dds"

	group = je_group_crises

	timeout = 1825

	immediate = {
		top_overlord = {
			save_scope_as = overlord_scope
		}
	}

	complete = {
		scope:journal_entry = {
			is_goal_complete = yes
		}
	}

	invalid = {
		NOT = {
			is_subject_of = scope:overlord_scope
		}
	}

	on_complete = {
		change_relations = {
			country = top_overlord
			value = 20
		}
		random_political_lobby = {
			limit = {
				is_political_lobby_type = lobby_pro_overlord
			}
			change_appeasement = {
				amount = 3
				factor = appeasement_british_dictate_succeeded
			}
		}
	}

	on_timeout = {
		change_relations = {
			country = top_overlord
			value = -15
		}
		random_political_lobby = {
			limit = {
				is_political_lobby_type = lobby_pro_overlord
			}
			change_appeasement = {
				amount = -5
				factor = appeasement_british_dictate_failed
			}
		}
	}

	current_value = {
		value = root.army_power_projection
	}

	goal_add_value = {
		value = root.army_power_projection
		multiply = 0.25
	}

	progressbar = yes

	weight = 1000
}

je_british_dictate_law = {
    icon = "gfx/interface/icons/event_icons/event_scales.dds"

	group = je_group_crises

	timeout = 1825
    
    immediate = {
		top_overlord = {
			save_scope_as = overlord_scope
		}
		save_scope_as = country_imposed_upon
		imposed_law = {
			save_scope_as = foreign_imposition_law
		}
		imposer_of_law = {
			save_scope_as = foreign_imposition_country
		}
		remove_modifier = impose_law_cooldown 			# the cooldown variable is replicated in this journal entry
		scope:journal_entry = {
			add_modifier = foreign_legislative_interference
		}
	}
	
	modifiers_while_active = { 
		impose_law_cooldown
	}
	
	scripted_button = button_implement_law_imposition
	scripted_button = button_refuse_law_imposition
	
    status_desc = {
		first_valid = {
			triggered_desc = {
				desc = je_law_imposition_status_enacting
				trigger = { currently_enacting_law = scope:foreign_imposition_law }
			}
			triggered_desc = {
				desc = je_law_imposition_status_not_yet_enacting
			}
		}
	}

	on_weekly_pulse = {
		effect = {
			if = {
				limit = { 
					scope:journal_entry = { NOT = { has_variable = notification_sent_var } } 
					currently_enacting_law = scope:foreign_imposition_law
				}
				imposer_of_law = { post_notification = imposition_started }
				scope:journal_entry = { set_variable = notification_sent_var }
			}
		}
	}

    complete = {
        has_law = scope:foreign_imposition_law.type
    }

    on_complete = {
		change_relations = {
			country = scope:foreign_imposition_country
			value = 20
		}
		
		every_political_lobby = {
			limit = { pro_foreign_imposition_country = yes }
			change_appeasement = { amount = 3 factor = appeasement_imposed_law_enacted }
		}
		every_political_lobby = {
			limit = { anti_foreign_imposition_country = yes }
			change_appeasement = { amount = -3 factor = appeasement_imposed_law_enacted }
		}
        add_modifier = {
            name = successfully_met_foreign_imposition_legitimacy
            months = normal_modifier_time
            is_decaying = yes
        }
    }

    invalid = {
		OR = {
			scope:journal_entry = {
				has_variable = has_been_abandoned
			}
			scope:foreign_imposition_country ?= {
				NOT = {
					has_law_imposition_rights = {
						target_country = root
						law_type = scope:foreign_imposition_law.type
					}
				}
			}
		}
    }
	
	on_invalid = {
		if = { 
			limit = { currently_enacting_law = scope:foreign_imposition_law }
			cancel_enactment = yes
		}
	}

	on_timeout = {
		change_relations = {
			country = top_overlord
			value = -15
		}
		random_political_lobby = {
			limit = {
				is_political_lobby_type = lobby_pro_overlord
			}
			change_appeasement = {
				amount = -5
				factor = appeasement_british_dictate_failed
			}
		}
	}

    weight = 1000

    should_be_pinned_by_default = yes
}

je_british_dictate_universities = {
	should_be_pinned_by_default = yes
	icon = "gfx/interface/icons/invention_icons/academia.dds"

	group = je_group_crises

	timeout = 1825

	immediate = {
		top_overlord = {
			save_scope_as = overlord_scope
		}
	}

	complete = {
		any_scope_state = {
			state_region = s:STATE_BOMBAY
			any_scope_building = {
				is_building_type = building_university
				level >= 3
			}
		}
		any_scope_state = {
			state_region = s:STATE_WEST_BENGAL
			any_scope_building = {
				is_building_type = building_university
				level >= 3
			}
		}
		any_scope_state = {
			state_region = s:STATE_MADRAS
			any_scope_building = {
				is_building_type = building_university
				level >= 3
			}
		}
	}

	invalid = {
		NOT = {
			is_subject_of = scope:overlord_scope
		}
	}

	on_complete = {
		change_relations = {
			country = top_overlord
			value = 20
		}
		random_political_lobby = {
			limit = {
				is_political_lobby_type = lobby_pro_overlord
			}
			change_appeasement = {
				amount = 3
				factor = appeasement_british_dictate_succeeded
			}
		}
	}

	on_timeout = {
		change_relations = {
			country = top_overlord
			value = -15
		}
		random_political_lobby = {
			limit = {
				is_political_lobby_type = lobby_pro_overlord
			}
			change_appeasement = {
				amount = -5
				factor = appeasement_british_dictate_failed
			}
		}
	}

	weight = 1000
}