# Allows you to create your own dynamic keys
# to be called in localization.
# defined_text -> this is it, we're defining the text
# text -> a discrete entry that can be picked to display in loc.
# trigger -> determines if a text entry will be picked or not.
# (The triggers need to be valid for the scope the key is called in
# (eg Root or From.From).)
# localization_key -> points to the localization key
# that'll be used if trigger passes
defined_text = {
	name = GetSenateElectionOutcome
	text = {
		trigger = {
			check_variable = { senators_for_reelection < 0 }
		}
		localization_key = SenateElectionLost
	}
	text = {
		trigger = {
			check_variable = { var = senators_for_reelection value = 0 compare = greater_than_or_equals }
		}
		localization_key = SenateElectionGained
	}
}
defined_text = {
	name = GetHouseElectionOutcome
	text = {
		trigger = {
			check_variable = { representatives_for_reelection < 0 }
		}
		localization_key = HouseElectionLost
	}
	text = {
		trigger = {
			check_variable = { var = representatives_for_reelection value = 0 compare = greater_than_or_equals }
		}
		localization_key = HouseElectionGained
	}
}

defined_text = { # Country
	name = GetCandidatesFascism
	text = {
		trigger = {
			has_global_flag = MTG_flag_955
		}
		localization_key = USA_hilt_candidate
	}
	text = {
		localization_key = ""
	}
}
defined_text = {
	name = GetStrengthRatioBritain
	text = {
		trigger = { 
			if = { 
				limit = { U73 = { has_naval_treaty_trigger = yes } }
				naval_strength_comparison = { 
					other = U73
					ratio < 1
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
				naval_strength_comparison = { 
					other = U73
					ratio > 0.9
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
			}
			else_if = { 
				limit = { ITA = { has_naval_treaty_trigger = yes } }
				naval_strength_comparison = { 
					other = ITA
					ratio < 1
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
				naval_strength_comparison = { 
					other = ITA
					ratio > 0.9
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
			}
		}
		localization_key = Naval_treaty_90
	}
	text = {
		trigger = { 
			if = { 
				limit = { U73 = { has_naval_treaty_trigger = yes } }
				naval_strength_comparison = { 
					other = U73
					ratio < 0.9
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
				naval_strength_comparison = { 
					other = U73
					ratio > 0.75
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
			}
			else_if = { 
				limit = { ITA = { has_naval_treaty_trigger = yes } }
				naval_strength_comparison = { 
					other = ITA
					ratio < 0.9
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
				naval_strength_comparison = { 
					other = ITA
					ratio > 0.75
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
			}
		}
		localization_key = Naval_treaty_75
	}
	text = {
		trigger = { 
			if = { 
				limit = { U73 = { has_naval_treaty_trigger = yes } }
				naval_strength_comparison = { 
					other = U73
					ratio < 0.75
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
				naval_strength_comparison = { 
					other = U73
					ratio > 0.5
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
			}
			else_if = { 
				limit = { ITA = { has_naval_treaty_trigger = yes } }
				naval_strength_comparison = { 
					other = ITA
					ratio < 0.75
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
				naval_strength_comparison = { 
					other = ITA
					ratio > 0.5
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
			}
		}
		localization_key = Naval_treaty_50
	}
	text = {
		trigger = { 
			if = { 
				limit = { U73 = { has_naval_treaty_trigger = yes } }
				naval_strength_comparison = { 
					other = U73
					ratio < 0.5
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
			}
			else_if = { 
				limit = { ITA = { has_naval_treaty_trigger = yes } }
				naval_strength_comparison = { 
					other = ITA
					ratio < 0.5
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
			}
		}
		localization_key = Naval_treaty_lower_than_50
	}
	text = {
		trigger = { 
			if = { 
				limit = { U73 = { has_naval_treaty_trigger = yes } }
				naval_strength_comparison = { 
					other = U73
					ratio > 1
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
			}
			else_if = { 
				limit = { ITA = { has_naval_treaty_trigger = yes } }
				naval_strength_comparison = { 
					other = ITA
					ratio > 1
					sub_unit_def_weights = { 
						carrier = 0.5
						battleship = 1
						battle_cruiser = 0.8
						heavy_cruiser = 0.5
					}
				}
			}
		}
		localization_key = Naval_treaty_over_100
	}
}
defined_text = {
	name = GetRelevantNavalTreatyNation
	text = {
		trigger = { 
			U73 = { 
				has_naval_treaty_trigger = yes
			}
		}
		localization_key = U73_Naval_treaty_nation
	}
	text = {
		trigger = { 
			U73 = { 
				not = { has_naval_treaty_trigger = yes }
			}
			ITA = { 
				has_naval_treaty_trigger = yes
			}
		}
		localization_key = ITA_Naval_treaty_nation
	}
}
