﻿is_character_allowed_to_be_player = {
	trigger_if = {
		limit = { scope:will_override_government = no }
		OR = {
			has_game_rule = allow_unplayables
			AND = {
				custom_description = {
					text = "GAME_OVER_CANNOT_PLAY_REPUBLIC"
					NOT = { government_has_flag = government_is_republic }
				}

				custom_description = {
					text = "GAME_OVER_CANNOT_PLAY_MERCENARY"
					NOT = { government_has_flag = government_is_mercenary }
				}

				custom_description = {
					text = "GAME_OVER_CANNOT_PLAY_HOLY_ORDER"
					NOT = { government_has_flag = government_is_holy_order }
				}

				trigger_if = {
					limit = {
						NOT = { has_dlc_feature = admin_gov }
					}
					custom_description = {
						text = "GAME_OVER_CANNOT_PLAY_ADMIN"
						NOT = { government_has_flag = government_is_administrative }
					}
				}

				trigger_if = {
					limit = {
						NOT = { has_dlc_feature = by_god_alone }
					}
					trigger_if = {
						limit = { government_has_flag = government_is_ecclesiastical }
						custom_description = {
							text = "GAME_OVER_CANNOT_PLAY_ECCLESIASTICAL"
							NOT = { government_has_flag = government_is_ecclesiastical }
						}
					}
					trigger_else = {
						custom_description = {
							text = "GAME_OVER_CANNOT_PLAY_THEOCRACY"
							NOT = { government_has_flag = government_is_theocracy }
						}
					}
				}
				
				# We cannot become landless adventurers
				trigger_if = {
					limit = {
						NOT = { has_dlc_feature = roads_to_power }
					}
					custom_description = {
						text = "GAME_OVER_CANNOT_PLAY_ADVENTURER"
						NOT = { government_has_flag = government_is_landless_adventurer }
					}
					custom_description = {
						text = "GAME_OVER_CANNOT_PLAY_BARON"
						NOT = { highest_held_title_tier = tier_barony }
					}

					# This is a generic "catch all", we should have caught it before this
					is_playable_character = yes
				}

				# This character is not playable
				trigger_if = {
					limit = {
						OR = {
							government_is_japanese_trigger = yes
							government_has_flag = government_is_theocracy
						}
						is_landed = no
						not = { exists = clerical_elector_title }
					}

					custom_tooltip = {
						text = GAME_OVER_CANNOT_PLAY_ESTATELESS
						has_domicile = yes
					}
				}
				# We can become landless adventurers
				trigger_else = {
					# This is a generic "catch all", we should have caught it before this
					OR = {
						AND = {
							is_ruler = no # We're not a ruler, but we can become a landless adventurer
							is_valid_for_laampdom = yes
						}
						is_playable_character = yes # General catch-all, we can continue playing
					}
					NOT = { has_character_flag = declined_become_laamp }
					
				}
			}
		}
	}
}