##################################################
#	Train for a Tournament

##################################################



#############################################
# Train for a Tournament 					#
# by Veronica Pazos							#
#############################################

### Train For Tournament Decision ###
train_for_tournament_decision = {
	title = train_for_tournament_decision_name
	picture = {
		trigger = {
			OR = {
				culture = { has_graphical_east_asia_culture_group_trigger = yes }
				culture = { has_graphical_india_culture_group_trigger = yes }
			}
		}
		reference = "gfx/interface/illustrations/event_scenes/tgp_camp_asia.dds"
	}
	picture = {
		reference = "gfx/interface/illustrations/activity_header_backgrounds/activity_tournament.dds"
	}
	desc = train_for_tournament_decision_desc
	selection_tooltip = train_for_tournament_decision_tooltip
	cooldown = { years = 10 }
	sort_order = 80

	is_shown = {
		has_dlc_feature = tours_and_tournaments
		activity_is_valid_tournament_contestant_training_decision = yes
		OR = {
			exists = cp:councillor_marshal
			AND = {
				government_has_flag = government_is_landless_adventurer
				employs_court_position = master_of_arms_camp_officer
			}
			any_councillor = {
				is_kurultai_trigger = yes
				is_available_ai = yes
				martial > high_skill_rating
			}
		}
		
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		custom_tooltip = {
			text = grand_tournament_active
			any_open_invite_activity = {
				has_activity_type = activity_tournament
				root = { can_join_activity = prev }
			}
		}
	}

	effect = {
		custom_tooltip = train_tournament_decision.tt
		save_scope_as = training_ruler
		cp:councillor_marshal ?= { save_scope_as = marshal }
		if = {
			limit = {
				NOT = { exists = scope:marshal }
			}
			if = {
				limit = {
					government_has_flag = government_is_landless_adventurer
				}
				random_court_position_holder = {
					type = master_of_arms_camp_officer
					save_scope_as = marshal
				}
			}
			else = {
				random_councillor = {
					limit = {
						is_kurultai_trigger = yes
						is_available_ai = yes
						martial > high_skill_rating
					}
					save_scope_as = marshal
				}
			}
		}
		trigger_event = ep2_decision_events.0001
		stress_impact = {
			craven = major_stress_impact_gain
		}
	}

	cost = {
		prestige = {
			value = { 
				value = medium_prestige_value
				max = 150
			}
			if = { # Cheaper to convert to a hybrid culture made from your culture
				limit = {
					culture = { has_cultural_parameter = can_use_sparring_duel }
				}
				multiply = 0
			}
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}
	
	ai_potential = {
		# Has enough prestige.
		prestige >= medium_prestige_value
		NOR = {
			has_trait = lazy
			has_trait = humble
			has_trait = craven
		}
		ai_energy > 0
	}

	ai_will_do = {
		base = 0
		modifier = {
			add = ai_boldness
		}
		modifier = {
			add = 50
			has_trait = arrogant
		}
		modifier = {
			add = 100
			culture = {
				OR = {
					has_cultural_tradition = tradition_chivalry
					has_cultural_tradition = tradition_warrior_culture
					has_cultural_tradition = tradition_martial_admiration
					has_cultural_tradition = tradition_chanson_de_geste
				}
			}
		}
		modifier = {
			add = 200
			has_focus_or_focus_trait_trigger = { FOCUS = martial_chivalry_focus }
		}
	}
}
