country_decisions = {

	form_great_yuan = {
		major = yes
		potential = {
			normal_or_historical_nations = yes
			was_never_end_game_tag_trigger = yes
			NOT = { has_country_flag = formed_yuan_flag }
			OR = {
				ai = no
				is_playing_custom_nation = no
			}
			OR = {
				is_free_or_tributary_trigger = yes
				ai = no
			}
			NOT = { exists = YUA } 
			NOT = { tag = KHA }
			NOT = { tag = MUG }
			NOT = { tag = QNG }
			NOT = { tag = MNG }
			NOT = { tag = MCH }
			NOT = { tag = LIO }
			culture_group = mongolic
			NOT = { primary_culture = khitan }
			OR = {
				ai = no
				AND = {
					ai = yes
					num_of_cities = 8
				}
			}
			is_colonial_nation = no
			OR = {
				is_former_colonial_nation = no
				AND = {
					is_former_colonial_nation = yes
					ai = no
				}
			}
		}
		provinces_to_highlight = {
			OR = {
				province_id = 688 #Kaifeng
				province_id = 723 #Xilin Gol
				province_id = 1816 #Beijing
				province_id = 2190 #Qaraqorum
				province_id = 2136 #Xuanha
				AND = {
					culture_group = mongolic
					NOT = { culture = khitan }
					is_city = yes
					NOT = { country_or_non_sovereign_subject_holds = ROOT }
				}
			}
			OR = {
				NOT = { owned_by = ROOT }
				NOT = { is_core = ROOT }
			}
		}
		allow = {
			is_free_or_tributary_trigger = yes
			culture_group = mongolic
			NOT = { primary_culture = khitan }
			is_at_war = no
			stability = 2
			owns_core_province = 688 #Kaifeng
			owns_core_province = 723 	#Xilin Gol
			owns_core_province = 2190 	#Qaraqorum
			owns_core_province = 2136 	#Xuanha
			owns_core_province = 1816 	#Beijing
			1816 = {					#Beijing
				is_state = yes
			}
			custom_trigger_tooltip = {
				tooltip = subject_all_mongols
				NOT = {
					any_province = {
						culture_group = mongolic
						NOT = { culture = khitan }
						is_city = yes
						NOT = { country_or_non_sovereign_subject_holds = ROOT }
					}
				}
			}
			if = {
				limit = {
					has_dlc = "Mandate of Heaven"
					any_country = {
						is_emperor_of_china = yes
					}
				}
				is_emperor_of_china = yes
			}
			else_if = {
				limit = {
					has_dlc = "Common Sense"
				}
				government_rank = 3
			}
			else = {
				total_development = 1000
			}
		}
		effect = {
			1816 = {
				add_base_tax = 1
				add_base_production = 1
				add_base_manpower = 1
				rename_capital = Khanbaliq
				move_capital_effect = yes
			}
			723 = {
				rename_capital = Xanadu 
			}
			2136 = {
				rename_capital = Zhongdu 
			}
			change_tag = YUA
			on_change_tag_effect = yes
			remove_non_electors_emperors_from_empire_effect = yes
			if = {		#added MMETR
				limit = {
					NOT = { government_rank = 3 }
				}
				set_government_rank = 3
			}
			china_superregion = {
				limit = {
					NOT = { owned_by = ROOT }
				}
				add_permanent_claim = YUA
			}
			manchuria_region = {
				limit = {
					NOT = { owned_by = ROOT }
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = YUA
			}
			mongolia_region = {
				limit = {
					NOT = { owned_by = ROOT }
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = YUA
			}
			tibet_region = {
				limit = {
					NOT = { owned_by = ROOT }
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = YUA
			}
			add_prestige = 20
			set_country_flag = formed_yuan_flag
			if = {
				limit = { has_custom_ideas = no }
				country_event = { id = ideagroups.1 } #Swap Ideas
			}
			swap_non_generic_missions = yes
		}
		ai_will_do = {
			factor = 1
		}
		ai_importance = 400
	}
	hordes_restore_yuan = {
		potential = {
			has_country_flag = hordes_yuan_restoration
			NOT = { 
				YUA = {
					is_subject_of = ROOT
				}
			}
		}
		allow = {
			NOT = { exists = YUA }
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				OR = {
					region = mongolia_region
					region = north_china_region
					region = manchuria_region
					region = south_china_region
					region = xinan_region
				}
				value = 10
			}
		}
		effect = {
			custom_tooltip = HORDES_RESTORE_YUAN_EFFECT
			hidden_effect = {
				every_owned_province = {
					limit = {
						OR = {
							region = mongolia_region
							region = north_china_region
							region = manchuria_region
							region = south_china_region
							region = xinan_region
						}
					}
					add_core = YUA
					cede_province = YUA
				}
				
				create_subject = {
					subject_type = mongol_brother_realm
					subject = YUA
				}
				custom_tooltip = ""
				custom_tooltip = MONGOL_BROTHER_REALM_EXPLANATION
				
				YUA = {
					set_country_flag = yua_subject_less_liberty_desire_flag
				}
				
				clr_country_flag = hordes_yuan_restoration
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
}
