######## Events leading to the Stalin taking over the monarchy ##########


add_namespace = rt56rp_SOV_white_russia_civil_war
add_namespace = rt56rp_SOV_monarch_stalin

country_event = { # Event after civil war starts to select goal
	id = rt56rp_SOV_white_russia_civil_war.1
	title = rt56rp_SOV_white_russia_civil_war.1.t
	desc = rt56rp_SOV_white_russia_civil_war.1.desc
	picture = GFX_report_event_SOV_mongolia_fortify_border

	fire_only_once = yes

	mean_time_to_happen = {
		days = 1
	}

	trigger = {
		tag = SOV
		ROOT = {
			has_country_flag = rt56rp_SOV_the_march_towards_moscow_flag
			NOT = {
				has_global_flag = SOV_soviet_civil_war_over
			}
		}
	}

	option = { #March towards Moscow, it must be taken
		name = rt56rp_SOV_white_russia_civil_war.1.a
		set_country_flag = rt56rp_SOV_capture_moscow_flag
		custom_effect_tooltip = rt56rp_SOV_the_capture_moscow_tt
		add_timed_idea = {
			idea = rt56rp_SOV_start_the_march_towards_moscow
			days = 90
		}
	}

	option = { #consolidate our attacks on the red menace
		name = rt56rp_SOV_white_russia_civil_war.1.b
		set_country_flag = rt56rp_SOV_defeat_the_red_menace_flag
		custom_effect_tooltip = rt56rp_SOV_focus_on_the_red_menace_tt
		add_timed_idea = {
			idea = rt56rp_SOV_defeat_the_red_menace_forever
			days = 150
		}
	}

	option = { #we don't want to lose our morale if we fail
		name = rt56rp_SOV_white_russia_civil_war.1.c
		custom_effect_tooltip = rt56rp_SOV_no_goal_to_risk_morarility_tt
	}
}

country_event = { #Stalin's Trial event
	id = rt56rp_SOV_white_russia_civil_war.2
	title = rt56rp_SOV_white_russia_civil_war.2.t
	desc = rt56rp_SOV_white_russia_civil_war.2.desc
	picture = GFX_report_event_soviet_purge_trial

	fire_only_once = yes

	mean_time_to_happen = {
		days = 2
	}

	trigger = {
		tag = SOV
		ROOT = {
			has_global_flag = SOV_soviet_civil_war_over
			NOT = {
				has_country_flag = rt56rp_SOV_stalin_escapes_flag
			}
		}
	}

	option = { #Execute Stalin
		name = rt56rp_SOV_white_russia_civil_war.2.a
		add_stability = 0.10
		add_war_support = -0.10
		add_political_power = -50
	}

	option = { #Sent Stalin to Prison, can later recruit him
		name = rt56rp_SOV_white_russia_civil_war.2.b
		set_country_flag = rt56rp_SOV_stalin_is_in_prison_flag
	}

	option = { #secret option, if you select to hunt Stalin after he escapes but you still don't care about him
		name = rt56rp_SOV_white_russia_civil_war.2.c
		custom_effect_tooltip = rt56rp_SOV_we_will_leave_stalin_alone_tt

		set_country_flag = rt56rp_SOV_stalin_coup_awaiting_flag

		if = {
			limit = {
				OR = {
					has_stability < 0.40
					has_war_support < 0.50
				}
			}
			custom_effect_tooltip = generic_skip_one_line_tt

			custom_effect_tooltip = rt56rp_SOV_stalin_danger_tt
		}

		trigger = {
			ROOT = {
				has_country_flag = rt56rp_SOV_hunt_stalin_flag
			}
		}
	}
}

country_event = { #Stalin escapes
	id = rt56rp_SOV_white_russia_civil_war.3
	title = rt56rp_SOV_white_russia_civil_war.3.t
	desc = rt56rp_SOV_white_russia_civil_war.3.desc
	picture = GFX_report_event_generic_research_lab

	fire_only_once = yes

	mean_time_to_happen = {
		days = 2
	}

	trigger = {
		tag = SOV
		ROOT = {
			has_global_flag = SOV_soviet_civil_war_over
			has_country_flag = rt56rp_SOV_stalin_escapes_flag
		}
	}

	option = { #hunt Stalin
		name = rt56rp_SOV_white_russia_civil_war.3.a
		set_country_flag = rt56rp_SOV_hunt_stalin_flag
		country_event = {
			id = rt56rp_SOV_white_russia_civil_war.2
			days = 15
		}
	}

	option = { #don't bother with him
		name = rt56rp_SOV_white_russia_civil_war.3.b
		custom_effect_tooltip = rt56rp_SOV_stalin_is_not_our_problem_anymore_tt
		set_country_flag = rt56rp_SOV_stalin_coup_awaiting_flag

		if = {
			limit = {
				OR = {
					has_stability < 0.40
					has_war_support < 0.50
				}
			}
			custom_effect_tooltip = generic_skip_one_line_tt

			custom_effect_tooltip = rt56rp_SOV_stalin_danger_tt
		}
	}
}

country_event = { #Stalin's proposal
	id = rt56rp_SOV_white_russia_civil_war.4
	title = rt56rp_SOV_white_russia_civil_war.4.t
	desc = rt56rp_SOV_white_russia_civil_war.4.desc
	picture = GFX_report_event_stalin_propaganda

	fire_only_once = yes

	mean_time_to_happen = {
		days = 5
	}

	trigger = {
		tag = SOV
		ROOT = {
			OR = {
				AND = {
					has_country_flag = rt56rp_SOV_stalin_is_in_prison_flag
					has_war = yes
					war_length_with = {
						tag = FROM
						months > 3
					}
				}
				AND = {
					has_country_flag = rt56rp_SOV_stalin_is_in_prison_flag
					has_war_with_major = yes
				}
			}
		}
	}

	option = { #Recruit him as a general
		name = rt56rp_SOV_white_russia_civil_war.4.a
		add_field_marshal_role = {
			character = "SOV_iosif_stalin"
			traits = { harsh_leader }
			skill = 3
			attack_skill = 1
			defense_skill = 3
			planning_skill = 3
			logistics_skill = 3
			legacy_id = 0
		}

		set_country_flag = rt56rp_SOV_stalin_coup_awaiting_flag

		if = {
			limit = {
				OR = {
					has_stability < 0.40
					has_war_support < 0.50
				}
			}
			custom_effect_tooltip = generic_skip_one_line_tt

			custom_effect_tooltip = rt56rp_SOV_stalin_danger_tt
		}
	}

	option = { #refuse him
		name = rt56rp_SOV_white_russia_civil_war.4.b
		custom_effect_tooltip = rt56rp_SOV_reject_stalin_proposal_tt
	}
}

country_event = { #Raid of the tsar villa
	id = rt56rp_SOV_white_russia_civil_war.5
	title = rt56rp_SOV_white_russia_civil_war.5.t
	desc = rt56rp_SOV_white_russia_civil_war.5.desc
	picture = GFX_report_event_bunker_01

	fire_only_once = yes

	mean_time_to_happen = {
		days = 24
	}

	trigger = {
		tag = SOV
		has_country_flag = rt56rp_SOV_stalin_coup_awaiting_flag
		OR = {
			AND = {
				NOT = {
					has_completed_focus = SOV_reconvene_the_zemsky_sobor
					has_completed_focus = SOV_solidify_the_provisional_government
				}
				has_completed_focus = SOV_rebuild_the_savior_cathedral
				has_stability < 0.50
				has_war_support < 0.50
			}

			AND = {
				NOT = {
					has_completed_focus = SOV_dismantle_the_zemsky_sobor
					has_completed_focus = SOV_solidify_the_provisional_government
					has_completed_focus = SOV_the_rightful_heir_to_the_empire
				}
				has_completed_focus = SOV_reconvene_the_zemsky_sobor
				has_stability < 0.65
				OR = {
					has_war = yes
					has_war_support < 0.50
				}
			}
		}
	}

	option = { #The Death of the Tsar
		name = rt56rp_SOV_white_russia_civil_war.5.a
		if = {
			limit = {
				NOT = {
					has_completed_focus = SOV_reconvene_the_zemsky_sobor
				} 
			}
			custom_effect_tooltip = rt56rp_SOV_the_tsar_is_dead_tt
			retire_character = SOV_tsar_vladimir_kirillovich
			set_country_flag = rt56rp_SOV_stalin_coup_succeded_flag
		}

		else_if = {
			limit = { 
				NOT = {
					has_completed_focus = SOV_dismantle_the_zemsky_sobor
					has_completed_focus = SOV_solidify_the_provisional_government
				}
			}
			custom_effect_tooltip = rt56rp_SOV_the_tsar_is_dead_tt
			retire_character = SOV_tsar_vladimir_kirillovich
			set_country_flag = rt56rp_SOV_stalin_coup_succeded_flag
			set_cosmetic_tag = rt56rp_SOV_monarchist_stalin_coronation_flag
			uncomplete_national_focus = {
				focus = SOV_westward_bound
			}
			uncomplete_national_focus = {
				focus = SOV_the_old_enemy
			}
			uncomplete_national_focus = {
				focus = SOV_secure_finland
			}
			uncomplete_national_focus = {
				focus = SOV_secure_the_baltics
			}
			uncomplete_national_focus = {
				focus = SOV_panslavic_nationalism
			}
			uncomplete_national_focus = {
				focus = SOV_church_candidates
			}
			complete_national_focus = rt56rp_SOV_a_new_tsar_dynasty
		}
	}
}

country_event = { #Event to elect a new tsar, as the old one is dead, searching for a perfect candidate
	id = rt56rp_SOV_white_russia_civil_war.6
	title = rt56rp_SOV_white_russia_civil_war.6.t
	desc = rt56rp_SOV_white_russia_civil_war.6.desc
	picture = GFX_report_event_communist_leader

	is_triggered_only = yes
	fire_only_once = yes

	option = { #Get Stalin as tsar
		name = rt56rp_SOV_white_russia_civil_war.6.a
		set_country_flag = rt56rp_SOV_monarchist_stalin_coronation_flag
		custom_effect_tooltip = rt56rp_SOV_the_only_remaining_choice_tt
		custom_effect_tooltip = generic_skip_one_line_tt
		custom_effect_tooltip = rt56rp_SOV_warning_refresh_tree_via_ht_tt
	}
}

country_event = { #Alternative event to coronate Tsarist Stalin, if Vladimir died before being coronated
	id = rt56rp_SOV_white_russia_civil_war.7
	title = rt56rp_SOV_white_russia_civil_war.7.t
	desc = rt56rp_SOV_white_russia_civil_war.7.desc
	picture = GFX_report_event_generic_military_parade

	is_triggered_only = yes

	# Glorious!
	option = {
		name = rt56rp_SOV_white_russia_civil_war.7.a
		promote_character = rt56rp_SOV_tsar_iosif_stalin
		#news_event = { id = nsb_news.400 hours = 12 } #rework this next update
		hidden_effect = {
			ROOT = { drop_cosmetic_tag = yes }
			set_cosmetic_tag = russian_empire
		}

	}
}

country_event = { #Event to ask France to join SOV faction
	id = rt56rp_SOV_monarch_stalin.1
	title = rt56rp_SOV_monarch_stalin.1.t
	desc = rt56rp_SOV_monarch_stalin.1.desc
	picture = GFX_report_event_gre_allied_diplomacy_military

	is_triggered_only = yes
	fire_only_once = yes

	option = { #Accept
		name = rt56rp_SOV_monarch_stalin.1.a
		custom_effect_tooltip = rt56rp_SOV_accept_alliance_with_sov_tt
		FRA = {
			dismantle_faction = yes
		}
		SOV = {
			add_to_faction = FRA
		}
	}

	option = { #Reject
		name = rt56rp_SOV_monarch_stalin.1.b
		custom_effect_tooltip = rt56rp_SOV_reject_alliance_with_sov_tt
	}
}