﻿je_sale_of_alaska = {
	icon = "gfx/interface/icons/event_icons/event_map.dds"

	group = je_group_foreign_affairs

	is_shown_when_inactive = {
		c:ALK ?= {
			is_player = no
		}
		OR = {
			country_is_in_east_asia = yes
			country_is_in_europe = yes
		}
		OR = {
			has_state_in_state_region = STATE_ALASKA
			any_subject_or_below = {
				has_state_in_state_region = STATE_ALASKA
			}
		}
	}
	
	scripted_button = je_sell_alaska_button

	possible = {
		is_subject = no
		OR = {
			any_scope_state = {
				state_region = s:STATE_ALASKA
			}
			any_subject_or_below = {
				any_scope_state = {
					state_region = s:STATE_ALASKA
				}
			}
		}
		custom_tooltip = {
			text = unfriendly_nation_with_interest_in_alaska_tt
			any_country = {
				country_rank >= root.country_rank
				has_interest_marker_in_region = sr:region_pacific_coast
				relations:root < 0
			}
		}
		custom_tooltip = {
			text = friendly_nation_with_interest_in_alaska_tt
			any_country = {
				NOT = {
					is_subject = yes
				}
				country_is_in_north_america = yes
				relations:root >= 0
				country_rank >= rank_value:great_power
				any_scope_state = {
					region = sr:region_pacific_coast
					is_incorporated = yes
				}
			}
		}
	}

	immediate = {
		random_state = {
			limit = {
				state_region = s:STATE_ALASKA
				OR = {
					owner = ROOT
					owner = {
						is_subject_of = ROOT
					}
				}
			}
			save_scope_as = alaska_scope
			owner = {
				save_scope_as = alaska_owner_scope
			}
		}
		ruler = {
			save_scope_as = ruler_scope
		}
	}

	complete = {
		custom_tooltip = {
			text = sold_alaska_tt
			has_variable = successful_sale_of_alaska
		}
	}

	fail = {
		NOT = {
			OR = {
				has_state_in_state_region = STATE_ALASKA
				any_subject_or_below = {
					has_state_in_state_region = STATE_ALASKA
				}
			}
			custom_tooltip = {
				text = not_sold_alaska_tt
				has_variable = successful_sale_of_alaska
			}
		}
	}

	on_complete = {
		custom_tooltip = {
			text = selling_alaska_tt
		}
	}

	weight = 200

	transferable = no

	should_be_pinned_by_default = yes
}

je_alaska = {
	icon = "gfx/interface/icons/event_icons/event_map.dds"

	group = je_group_foreign_affairs

	is_shown_when_inactive = {
		has_interest_marker_in_region = region_pacific_coast
		has_technology_researched = nationalism
	}

	scripted_button = je_buy_alaska_button

	possible = {
		is_subject = no
		any_scope_state = {
			is_incorporated = yes
			region = sr:region_pacific_coast
			is_homeland_of_country_cultures = ROOT
		}
		NOT = {
			owns_entire_state_region = STATE_ALASKA
		}
		country_rank >= rank_value:great_power
	}

	immediate = {
		random_state = {
			limit = {
				state_region = s:STATE_ALASKA
				owner = {
					NOT = {
						is_country_type = decentralized
					}
				}
			}
			save_scope_as = alaska_state
		}
	}

	complete = {
		s:STATE_ALASKA = {
			any_scope_state = {
				owner = root
			}
			any_scope_state = {
				OR = {
					owner = root
					owner = {
						is_country_type = decentralized
					}
				}
				count = all
			}
		}
	}

	on_complete = {
		add_modifier = {
			name = conquest_of_alaska
			months = normal_modifier_time
		}
	}

	timeout = 7300

	weight = 200

	transferable = no

	should_be_pinned_by_default = yes
}
