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

	group = je_group_usa_manifest_destiny

	is_shown_when_inactive = {
		exists = c:USA
		exists = c:GBR
		c:USA = ROOT
		s:STATE_WASHINGTON = {
			any_scope_state = {
				owner = {
					OR = {
						c:GBR = THIS
						is_subject_of = c:GBR
					}
				}
			}
		}
		s:STATE_OREGON = {
			any_scope_state = {
				owner = {
					OR = {
						c:GBR = THIS
						is_subject_of = c:GBR
					}
				}
			}
		}
		s:STATE_IDAHO = {
			any_scope_state = {
				owner = {
					OR = {
						c:GBR = THIS
						is_subject_of = c:GBR
					}
				}
			}
		}
	}

	possible = {
		OR = {
			has_interest_marker_in_region = region_pacific_coast
			custom_tooltip = {
				text = oregon_tt
				has_global_variable = oregon_trail_mapped
			}
			owns_entire_state_region = STATE_MONTANA
			owns_entire_state_region = STATE_WYOMING
		}
		s:STATE_TEXAS = {
			any_scope_state = {
				owner = {
					OR = {
						c:USA = THIS
						is_subject_of = c:USA
					}
				}
			}
		}
	}

	complete = {

		AND = {
			has_interest_marker_in_region = region_pacific_coast
			custom_tooltip = {
				text = oregon_tt
				has_global_variable = oregon_trail_mapped
			}
			OR = {
				AND = {
					owns_entire_state_region = STATE_MONTANA
					owns_entire_state_region = STATE_WYOMING
					c:GBR = {
						relations:ROOT >= relations_threshold:cordial
					}
				}
				AND = {
					has_war_with = c:MEX
					NOT = {
						has_war_with = c:GBR
					}
				}
			}
		}
	}

	on_complete = {
		if = {
			limit = {
				s:STATE_WASHINGTON = {
					any_scope_state = {
						owner = {
							OR = {
								c:GBR = THIS
								is_subject_of = c:GBR
							}
						}
					}
				}
				s:STATE_OREGON = {
					any_scope_state = {
						owner = {
							OR = {
								c:GBR = THIS
								is_subject_of = c:GBR
							}
						}
					}
				}
				s:STATE_IDAHO = {
					any_scope_state = {
						owner = {
							OR = {
								c:GBR = THIS
								is_subject_of = c:GBR
							}
						}
					}
				}
			}
			c:GBR = { trigger_event = { id = oregon.2 } }
		}
		else = {
			s:STATE_IDAHO = {
				add_homeland = cu:yankee
			}
			s:STATE_WASHINGTON = {
				add_homeland = cu:yankee
			}
			s:STATE_OREGON = {
				add_homeland = cu:yankee
			}
			add_modifier = {
				name = oregon_resolved
				days = normal_modifier_time
			}
		}
	}

	fail = {
		c:GBR = {
			relations:ROOT <= relations_threshold:poor
   	 	}
	}
	
	on_fail = {
			add_journal_entry = {
				type = je_conquer_oregon
			}
			s:STATE_OREGON = {
				add_claim = ROOT
			}
			s:STATE_IDAHO = {
				add_claim = ROOT
			}
			s:STATE_WASHINGTON = {
				add_claim = ROOT
			}
	}

	should_be_pinned_by_default = yes
	weight = 100
}

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

	group = je_group_usa_manifest_destiny

	complete = {
		c:USA ?= {
			owns_entire_state_region = STATE_WASHINGTON
			owns_entire_state_region = STATE_IDAHO
			owns_entire_state_region = STATE_OREGON
		}
	}

	on_complete = {
		s:STATE_OREGON = {
			add_homeland = cu:yankee
		}
		s:STATE_IDAHO = {
			add_homeland = cu:yankee
		}
		s:STATE_WASHINGTON = {
			add_homeland = cu:yankee
		}
	}

	weight = 100

	transferable = no
	should_be_pinned_by_default = yes
}
