add_namespace = Vote

# Настройка даты войны // все
country_event = {
	id = Vote.1
	title = Vote.1.t
	desc = Vote.1.desc
	picture = GFX_report_event_generic_rally_3
	is_triggered_only = yes
	
	immediate = { log = "[GetDateText]: [Root.GetName] ([Root.GetTag]): event Vote.1" }
	immediate = {
		#Все становятся врагами и получают эмбарго и санкции
		hidden_effect = {
			every_other_country = {
				limit = {
					NOT = {
						original_tag = VER
						original_tag = SVE
						original_tag = SVD
					}
				}
				add_opinion_modifier = { target = ROOT modifier = embargo }
				add_opinion_modifier = { target = ROOT modifier = embargo_2 }
				add_opinion_modifier = { target = ROOT modifier = sanctions }
				add_opinion_modifier = { target = ROOT modifier = hostile_status }
				ROOT = {
					add_opinion_modifier = { target = PREV modifier = embargo }
					add_opinion_modifier = { target = PREV modifier = embargo_2 }
					add_opinion_modifier = { target = PREV modifier = sanctions }
					add_opinion_modifier = { target = PREV modifier = hostile_status }
				}
			}
		}
	}
	
	option = {
		name = Vote.1.a
		trigger = {
			if = {
				limit = { is_ai = yes }
				NOT = {
					any_other_country = {
						NOT = {
							original_tag = VER
							original_tag = SVE
							original_tag = SVD
						}
						is_ai = no
					}
				}
			}
		}
		ai_chance = {
			factor = 100
		}
		add_to_variable = { global.vote_1 = 1 }
		country_event = { id = Vote.2 }
		check_final_vote = yes
		army_experience = 200
		navy_experience = 100
	}
	
	option = {
		name = Vote.1.b
		trigger = {
			if = {
				limit = { is_ai = yes }
				NOT = {
					any_other_country = {
						NOT = {
							original_tag = VER
							original_tag = SVE
							original_tag = SVD
						}
						is_ai = no
					}
				}
			}
		}
		ai_chance = {
			factor = 50
		}
		add_to_variable = { global.vote_2 = 1 }
		country_event = { id = Vote.2 }
		check_final_vote = yes
		army_experience = 200
		navy_experience = 100
	}
	
	option = {
		name = Vote.1.c
		trigger = {
			if = {
				limit = { is_ai = yes }
				NOT = {
					any_other_country = {
						NOT = {
							original_tag = VER
							original_tag = SVE
							original_tag = SVD
						}
						is_ai = no
					}
				}
			}
		}
		ai_chance = {
			factor = 50
		}
		add_to_variable = { global.vote_3 = 1 }
		country_event = { id = Vote.2 }
		check_final_vote = yes
		army_experience = 200
		navy_experience = 100
	}
	
	option = {
		name = Vote.1.d
		trigger = {
			if = {
				limit = { is_ai = yes }
				NOT = {
					any_other_country = {
						NOT = {
							original_tag = VER
							original_tag = SVE
							original_tag = SVD
						}
						is_ai = no
					}
				}
			}
		}
		ai_chance = {
			factor = 50
		}
		add_to_variable = { global.vote_4 = 1 }
		country_event = { id = Vote.2 }
		check_final_vote = yes
		army_experience = 200
		navy_experience = 100
	}
	
	option = {
		name = Vote.1.e
		trigger = { is_ai = yes }
		ai_chance = {
			factor = 1
			modifier = {
				factor = 0
				NOT = {
					any_other_country = {
						NOT = {
							original_tag = VER
							original_tag = SVE
							original_tag = SVD
						}
						is_ai = no
					}
				}
			}
		}
		add_to_variable = { global.vote_5 = 1 }
		country_event = { id = Vote.2 }
		check_final_vote = yes
		army_experience = 200
		navy_experience = 100
	}
}

# Итог
country_event = {
	id = Vote.2
	hidden = yes
	is_triggered_only = yes
	
	immediate = { log = "[GetDateText]: [Root.GetName] ([Root.GetTag]): event Vote.2" }
	immediate = {
		log = "Vote.1: [?global.vote_1]"
		log = "Vote.2: [?global.vote_2]"
		log = "Vote.3: [?global.vote_3]"
		log = "Vote.4: [?global.vote_4]"
		log = "Vote.5: [?global.vote_5]"
		set_temp_variable = { num_player = global.vote_1 }
		add_to_temp_variable = { num_player = global.vote_2 }
		add_to_temp_variable = { num_player = global.vote_3 }
		add_to_temp_variable = { num_player = global.vote_4 }
		set_temp_variable = { min_level_votes = num_player }
		multiply_temp_variable = { min_level_votes = 0.5 }
		round_temp_variable = min_level_votes
		log = "min_level_votes = [?min_level_votes]"
		set_temp_variable = { one_third_level_votes = num_player }
		multiply_temp_variable = { one_third_level_votes = 0.333 }
		round_temp_variable = one_third_level_votes
		log = "one_third_level_votes = [?one_third_level_votes]"
		if = {
			limit = { check_variable = { var = global.vote_1 value = min_level_votes compare = greater_than_or_equals } }
			
			every_country = { set_variable = { var_game_loadings = 365 }}	
		}
		else_if = {
			limit = { check_variable = { var = global.vote_2 value = min_level_votes compare = greater_than_or_equals } }
			
			every_country = { set_variable = { var_game_loadings = 548 }}
			
		}
		else_if = {
			limit = { check_variable = { var = global.vote_3 value = min_level_votes compare = greater_than_or_equals } }
			
			every_country = { set_variable = { var_game_loadings = 730 }}
		}
		else_if = {
			limit = { check_variable = { var = global.vote_4 value = min_level_votes compare = greater_than_or_equals } }
			
			every_country = { set_variable = { var_game_loadings = 1095 }}
		}
		else_if = {	#50*50
			limit = {
				count_triggers = {
					amount = 2
					check_variable = { global.vote_1 = min_level_votes }
					check_variable = { global.vote_2 = min_level_votes }
					check_variable = { global.vote_3 = min_level_votes }
					check_variable = { global.vote_4 = min_level_votes }
				}
			}
			random_list = {
				50 = {
					modifier = {
						factor = 0
						NOT = { check_variable = { global.vote_1 = min_level_votes } }
					}
					
					every_country = { set_variable = { var_game_loadings = 365 }}
				}
				50 = {
					modifier = {
						factor = 0
						NOT = { check_variable = { global.vote_2 = min_level_votes } }
					}
					
					every_country = { set_variable = { var_game_loadings = 548 }}
				}
				50 = {
					modifier = {
						factor = 0
						NOT = { check_variable = { global.vote_3 = min_level_votes } }
					}
					
					every_country = { set_variable = { var_game_loadings = 730 }}
				}
				50 = {
					modifier = {
						factor = 0
						NOT = { check_variable = { global.vote_4 = min_level_votes } }
					}
					
					every_country = { set_variable = { var_game_loadings = 1095 }}
				}
			}
		}
		else_if = {
			limit = {
				count_triggers = {
					amount = 3
					check_variable = { global.vote_1 = one_third_level_votes }
					check_variable = { global.vote_2 = one_third_level_votes }
					check_variable = { global.vote_3 = one_third_level_votes }
					check_variable = { global.vote_4 = one_third_level_votes }
				}
			}
			random_list = {
				50 = {
					modifier = {
						factor = 0
						NOT = { check_variable = { global.vote_1 = one_third_level_votes } }
					}
					
					every_country = { set_variable = { var_game_loadings = 365 }}
				}
				50 = {
					modifier = {
						factor = 0
						NOT = { check_variable = { global.vote_2 = one_third_level_votes } }
					}
					
					every_country = { set_variable = { var_game_loadings = 548 }}
				}
				50 = {
					modifier = {
						factor = 0
						NOT = { check_variable = { global.vote_3 = one_third_level_votes } }
					}
					
					every_country = { set_variable = { var_game_loadings = 730 }}
				}
				50 = {
					modifier = {
						factor = 0
						NOT = { check_variable = { global.vote_4 = one_third_level_votes } }
					}
					
					every_country = { set_variable = { var_game_loadings = 1095 }}
				}
			}
		}
		else = {
			random_list = {
				1 = {
					modifier = {
						factor = var:global.vote_1
					}
					
					every_country = { set_variable = { var_game_loadings = 365 }}
				}
				1 = {
					modifier = {
						factor = var:global.vote_2
					}
					
					every_country = { set_variable = { var_game_loadings = 548 }}
				}
				1 = {
					modifier = {
						factor = var:global.vote_3
					}
					
					every_country = { set_variable = { var_game_loadings = 730 }}
				}
				1 = {
					modifier = {
						factor = var:global.vote_4
					}
					
					every_country = { set_variable = { var_game_loadings = 1095 }}
				}
			}
		}
	}
}