court_brewmaster_court_position = {
	sort_order = 210
	max_available_positions = 1
	minimum_rank = county
	skill = learning
	
	court_position_asset = {
		animation = wedding_drunk
		background = "gfx/interface/illustrations/event_scenes/bp1_wine_cellar.dds"
	}
	
	opinion = {
		value = regular_court_position_opinion
	}
	
	# How high the aptitude has to be to reach the 5 different modifier levels
	aptitude_level_breakpoints = { 20 40 60 80 }
	
	# How good is this character in this position? root scope is the holder of the court position
	aptitude = {
		value = 25
		add = court_position_aptitude_boon_voyager_trait
		add = {
			value = learning
			multiply = 2.5
			max = 50
			desc = court_position_skill_learning
		}
		
		# Positive Traits
		if = {
			limit = {
				has_trait = diligent
			}
			add = {
				value = 15
				desc = court_position_diligent_trait
			}
		}
		if = {
			limit = {
				has_trait = patient
			}
			add = {
				value = 15
				desc = court_position_patient_trait
			}
		}
		if = {
			limit = {
				has_trait = humble
			}
			add = {
				value = 15
				desc = court_position_humble_trait
			}
		}
		if = {
			limit = {
				has_trait = lifestyle_reveler
			}
			add = {
				value = 15
				desc = court_position_reveler_trait
			}
		}
		# Negative Traits
		if = {
			limit = {
				has_trait = impatient
			}
			add = {
				value = -10
				desc = court_position_impatient_trait
			}
		}
		if = {
			limit = {
				has_trait = lazy
			}
			add = {
				value = -10
				desc = court_position_lazy_trait
			}
		}
		
		add = court_position_aptitude_traveling_friends_value
		add = court_position_aptitude_eunuch_tradition_value
		add = court_position_aptitude_family_business_value
		add = court_position_aptitude_high_penalty_value
		# Bonus from court.8311
		if = {
			limit = { var:bonus_aptitude_role ?= flag:court_brewmaster }
			add = {
				value = cp_bonus_aptitude_value
				desc = cp_bonus_aptitude
			}
		}
		# Seneschal
		if = {
			limit = {
				liege.court_position:seneschal_court_position ?= {
					has_variable = performing_improve_court
				}
			}
			add = {
				value = liege.court_position:seneschal_court_position.seneschal_improve_court_value
				desc = seneschal_improve_court_aptitude_desc
			}
		}
	}
	
	is_shown = {
		is_landed_or_landless_administrative = yes
		trigger_if = {
			limit = {
				is_ai = yes
				highest_held_title_tier <= tier_county
			}
			always = no
		}
	}
	
	# Is this an available position for this court? (root is court owner)
	valid_position = {
		is_landed_or_landless_administrative = yes
		OR = {
			custom_tooltip = {
				text = court_brewmaster_requirement_tt
				any_sub_realm_barony = {
					county.holder = root
					title_province = { has_building_or_higher = breweries_01 }
				}
			}
			AND = { #Greek Architecture
				religion = religion:hellenism_religion
				has_title = title:b_athens
				title:b_athens = {
					religion = religion:hellenism_religion
					title_province = { has_building_or_higher = theatre_of_dionysus_01 }
				}
			}
		}
	}
	
	is_shown_character = {
		scope:employee = {
			is_imprisoned = no
		}
	}
	
	valid_character = {
		scope:employee = {
			liege = scope:liege # To ensure invalidation if they leave court
			court_brewmaster_validity_trigger = { EMPLOYER = scope:liege }
		}
	}
	
	revoke_cost = { # root is the liege, no other scopes are passed here!
		prestige =  {
			value = major_court_position_prestige_revoke_cost
			# Set to 0 via obligation hook
			if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = court_brewmaster
						LIEGE = root
					}
				}
				multiply = 0
			}
			# Avoid AI prestige issues
			if = {
				limit = {
					exists = this
					is_ai = yes
				}
				multiply = 0
			}
			# Special case for events
			if = {
				limit = {
					exists = this
					has_character_flag = free_revoke_cost
				}
				multiply = 0
			}
			#Lowering for LAAMPS, to match Camp Officer revoke cost
			if = {
				limit = {
					exists = this
					government_has_flag = government_is_landless_adventurer
				}
				value = minor_court_position_prestige_revoke_cost
			}
		}
	}
	
	salary = {
		round = no
		gold = {
			value = minor_court_position_salary # Update X_salary_tooltip if script_value is changed
			# Set to 0 with Dynasty Perk Inner Circle
			if = {
				limit = { court_position_inner_circle_salary_trigger = { POS = court_brewmaster } }
				multiply = {
					value = 0
					desc = inner_circle_salary_mod
					format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
			}
			# Halved via obligation hook
			else_if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = court_brewmaster
						LIEGE = scope:liege
					}
				}
				multiply = {
					value = 0.5
					desc = obligation_hook_salary
					format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
			}
			# Halved salary
			if = {
				limit = {
					court_position_halved_salary_trigger = { POS = court_brewmaster }
				}
				multiply = {
					value = 0.5
					desc = court_position_halved_salary
					format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
			}
			# Increased salary
			if = {
				limit = {
					court_position_increased_salary_trigger = { POS = court_brewmaster }
				}
				multiply = {
					value = 1.5
					desc = court_position_increased_salary
					format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
			}
			#You're working with LAAMPS now
			if = {
				limit = {
					scope:liege ?= { government_has_flag = government_is_landless_adventurer }
				}
				multiply = 0
			}
		}
		prestige = {
			value = minor_court_position_prestige_salary # Update X_salary_tooltip if script_value is changed
			# Set to 0 with Dynasty Perk Inner Circle
			if = {
				limit = { court_position_inner_circle_salary_trigger = { POS = court_brewmaster } }
				multiply = {
					value = 0
					desc = inner_circle_salary_mod
					format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
			}
			# Halved via obligation hook
			else_if = {
				limit = {
					court_position_obligation_hook_salary_trigger = {
						POS = court_brewmaster
						LIEGE = scope:liege
					}
				}
				multiply = {
					value = 0.5
					desc = obligation_hook_salary
					format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
			}
			# Halved salary
			if = {
				limit = {
					court_position_halved_salary_trigger = { POS = court_brewmaster }
				}
				multiply = {
					value = 0.5
					desc = court_position_halved_salary
					format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
			}
			# Increased salary
			if = {
				limit = {
					court_position_increased_salary_trigger = { POS = court_brewmaster }
				}
				multiply = {
					value = 1.5
					desc = court_position_increased_salary
					format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
			}
			#You're working with LAAMPS now
			if = {
				limit = {
					scope:liege ?= { government_has_flag = government_is_landless_adventurer }
				}
				multiply = {
					value = 0
					desc = court_position_laamps_free
					format = "BASE_VALUE_FORMAT_DECIMALS_MINUS_POSITIVE"
				}
			}
		}
	}
	
	# These modifiers are employed based on what level the aptitude reaches (levels are defined as breakpoints)
	scaling_employer_modifiers = {
		terrible = {
			county_opinion_add = 1
		}
		poor = {
			county_opinion_add = 2
		}
		average = {
			county_opinion_add = 3
		}
		good = {
			county_opinion_add = 6
		}
		excellent = {
			county_opinion_add = 10
		}
	}
	
	custom_employer_modifier_description = court_brewmaster_employer_custom_effect_description
	
	modifier = {
		general_opinion = 5
		monthly_prestige = 0.25
		learning = 1
	}
	
	on_court_position_received = {
		court_brewmaster_title_accepted_effect = yes
	}
	on_court_position_revoked = {
		court_brewmaster_title_revoked_effect = yes
	}
	on_court_position_invalidated = {
		court_brewmaster_title_invalidated_effect = yes
	}
	on_court_position_vacated = {
		court_position_vacated_event_effect = {
			COURT_POSITION_TYPE = court_brewmaster_court_position
		}
	}
	
	# Scripted value to determine whether an AI will hire/fire a position or not. Hires over 0, fires under -50. Look in _court_positions.info for more extensive documentation!
	candidate_score = {
		value = 50
		add = scope:base_value
		add = court_position_candidate_score_base_value
		add = court_position_candidate_aptitude_value
		if = { # To stop petitioned positions immediately being fired by the AI
			limit = {
				court_position_petition_ai_weight_trigger = { ROLE = court_brewmaster }
			}
			add = 1000
		}
		add = court_position_debt_considerations_value
	}
}