﻿
#Literal Activity Cost
imperial_examination_base_cost = {
	value = 0 
	add = standard_activity_base_cost
}

imperial_examination_actual_cost = {
	value = 0
	add = {
		value = imperial_examination_base_cost
		desc = imperial_examination_base_cost
	}
	add = {
		value = imperial_examination_base_cost
		multiply = activity_cost_scale_by_era
		subtract = imperial_examination_base_cost
		desc = activity_cost_scale_by_era_desc
	}
	min = 0
}

imperial_examination_cost_discount_max = {
	value = 0.5
}
imperial_examination_cost_discount_max_value = {
	value = feast_activity_cost_discount_max
	subtract = 1
}

imperial_examination_predicted_cost = {
	value = 0
	add = {
		# Base Cost
		value = {
			value = imperial_examination_base_cost
			desc = imperial_examination_base_cost
		}
		# Scale by Era
		add = { #Unop Should be add, as value overwrites the previous calculation
			value = imperial_examination_base_cost
			multiply = activity_cost_scale_by_era
			subtract = imperial_examination_base_cost
			desc = activity_cost_scale_by_era_desc
		}
		# Kaifeng cost bonus
		if = {
			limit = {
				capital_province = { has_building_or_higher = kaifeng_palace_01 } #Unop root is the activity, we are in a character scope
			}
			multiply = {
				value = {
					value = 1
					subtract = kaifeng_examination_cost_value
				}
				desc = kaifeng_palace_name_desc
			}
		}

		# OPTIONS
		#Focus Option
		add = { # Calculate the average of the 3 option costs  #Unop Should be add, as value overwrites the previous calculation
			value = 0 #Learning Focus
			add = imperial_examination_alternate_focus_cost # Martial Focus
			add = imperial_examination_alternate_focus_cost # Stewardship Focus
			# Divide by total number of option breadth to get an average option cost
			divide = 2
			# Scale Option costs by era
			multiply = activity_cost_scale_by_era
		}
		#Examination Breadth Option
		add = { # Calculate the average of the 3 option costs  #Unop Should be add, as value overwrites the previous calculation
			value = 0 
			add = {
				add = tiny_gold_value_static_max #Palace Exams
				min = imperial_examination_breadth_exclusive_cost
			}
			add = {
				add = minor_gold_value_static_max #Metropolitan Exams
				min = imperial_examination_breadth_restricted_cost
			}
			add = {
				add = medium_gold_value_static_max #Provincial Exams
				min = imperial_examination_breadth_open_cost
			}
			# Divide by total number of option breadth to get an average option cost
			divide = 3
			# Scale Option costs by era
			multiply = activity_cost_scale_by_era
		}
		# Make it a multiple of 5 (rounded up)
		divide = 5
		ceiling = yes 
		multiply = 5
		min = 0
	}
}

#Literal Activity Focus Option Cost
imperial_examination_alternate_focus_value = {
	value = 0
	add = {
		add = {
			value = minor_gold_value_static_max #Remember to also update this in ui_predicted_cost
			min = imperial_examination_alternate_focus_cost
			desc = imperial_examination_focus_martial
		}
		add = {
			value = imperial_examination_base_cost #Unop root is the activity, we are in a character scope
			multiply = activity_cost_scale_by_era
			subtract = imperial_examination_base_cost #Unop root is the activity, we are in a character scope
			desc = activity_cost_scale_by_era_desc 
		}
	}
}

#Literal Activity Breadth Option Cost
imperial_examination_breadth_exclusive_value = {
	value = 0
	add = {
		desc = imperial_examination_breadth_exclusive
		add = {
			value = tiny_gold_value_static_max #Remember to also update this in ui_predicted_cost
			min = imperial_examination_breadth_exclusive_cost
			desc = imperial_examination_breadth_exclusive
		}
		add = {
			value = imperial_examination_base_cost #Unop root is the activity, we are in a character scope
			multiply = activity_cost_scale_by_era
			subtract = imperial_examination_base_cost #Unop root is the activity, we are in a character scope
			desc = activity_cost_scale_by_era_desc 
		}
	}
}

imperial_examination_breadth_restricted_value = {
	value = 0
	add = {
		desc = imperial_examination_breadth_restricted
		add = {
			value = minor_gold_value_static_max #Remember to also update this in ui_predicted_cost
			min = imperial_examination_breadth_restricted_cost
			desc = imperial_examination_breadth_restricted
		}
		add = {
			value = imperial_examination_base_cost #Unop root is the activity, we are in a character scope
			multiply = activity_cost_scale_by_era
			subtract = imperial_examination_base_cost #Unop root is the activity, we are in a character scope
			desc = activity_cost_scale_by_era_desc 
		}
	}
}

imperial_examination_breadth_open_value = {
	value = 0
	add = {
		desc = imperial_examination_breadth_open
		add = {
			value = medium_gold_value_static_max #Remember to also update this in ui_predicted_cost
			min = imperial_examination_breadth_open_cost
			desc = imperial_examination_breadth_open
		}
		add = {
			value = imperial_examination_base_cost #Unop root is the activity, we are in a character scope
			multiply = activity_cost_scale_by_era
			subtract = imperial_examination_base_cost #Unop root is the activity, we are in a character scope
			desc = activity_cost_scale_by_era_desc 
		}
	}
}


imperial_examination_alternate_focus_cost = 25

imperial_examination_breadth_exclusive_cost = 25
imperial_examination_breadth_restricted_cost = 50
imperial_examination_breadth_open_cost = 75

imperial_examination_wait_time_before_start_months = 7

imperial_examination_assembly_days = 15
imperial_examination_prep_days = 30
imperial_examination_exam_days = 30

exclusive_exam_guests_amount = 250
restricted_exam_guests_amount = 500
open_exam_guests_amount = 1000

# Used in triggers to check if the activity guest list is full.
exclusive_exam_guests_full_calc = {
	value = exclusive_exam_guests_amount
	subtract = 1
}

restricted_exam_guests_full_calc = {
	value = restricted_exam_guests_amount
	subtract = 1
}

open_exam_guests_full_calc = {
	value = open_exam_guests_amount
	subtract = 1
}

examiners_amount = 5

# Guest Invite Rules Handling
exam_invited_guests_amount_calc = {
	value = 0
	if = {
		limit = {
			scope:imperial_examination_breadth ?= flag:imperial_examination_breadth_exclusive
		}
		add = exclusive_exam_guests_amount
	}
	else_if = {
		limit = {
			scope:imperial_examination_breadth ?= flag:imperial_examination_breadth_restricted
		}
		add = restricted_exam_guests_amount
	}
	else_if = {
		limit = {
			scope:imperial_examination_breadth ?= flag:imperial_examination_breadth_open
		}
		add = open_exam_guests_amount
	}
	multiply = 0.2
}

exam_invited_entrants_amount_calc = {
	value = 0
	if = {
		limit = {
			scope:imperial_examination_breadth ?= flag:imperial_examination_breadth_exclusive
		}
		add = exclusive_exam_guests_amount
	}
	else_if = {
		limit = {
			scope:imperial_examination_breadth ?= flag:imperial_examination_breadth_restricted
		}
		add = restricted_exam_guests_amount
	}
	else_if = {
		limit = {
			scope:imperial_examination_breadth ?= flag:imperial_examination_breadth_open
		}
		add = open_exam_guests_amount
	}
	multiply = 0.6
}

num_intermediate_exams_value = 3 #Needs to correspond to amount of actual examination EVENTS (i.e. Essay, Classics, Poetry ---)

#All Entrants who took the exams (also failees)
imperial_examination_num_examinees_value = {
	scope:activity = {
		every_attending_character = {
			limit = {
				OR = {
					is_in_guest_subset = { name = entrants }
					is_in_guest_subset = { name = failees }
				}
			}
			add = 1
		}
	}
}

#How poised is our character to be apt at the exams?
imperial_examination_entry_value = {
	value = 0
	if = {
		limit = { is_alive = yes }
		# Merit
		if = {
			limit = { merit_level >= 7 }
			add = 20
		}
		else_if = {
			limit = { merit_level >= 5 }
			add = 15
		}
		else_if = {
			limit = { merit_level >= 3 }
			add = 9
		}
		else_if = {
			limit = { merit_level >= 1 }
			add = 6
		}
		#Confucian Education trait
		if = {
			limit = { has_trait = confucian_education }
			if = {
				limit = {
					has_trait_xp = {
						trait = confucian_education
						#value >= 100 #Max
						value >= trait_max_value
					}
				}
				add = 20
			}
			else_if = {
				limit = {
					has_trait_xp = {
						trait = confucian_education
						#value >= 80 #Fourth level
						value >= trait_fourth_of_five_level_value
					}
				}
				add = 15
			}
			else_if = {
				limit = {
					has_trait_xp = {
						trait = confucian_education
						#value >= 60 #Third level
						value >= trait_third_of_five_level_value
					}
				}
				add = 12
			}
			else_if = {
				limit = {
					has_trait_xp = {
						trait = confucian_education
						#value >= 40 #Second level
						value >= trait_second_of_five_level_value
					}
				}
				add = 9
			}
			else_if = {
				limit = {
					has_trait_xp = {
						trait = confucian_education
						#value >= 20 #First level
						value >= trait_first_of_five_level_value
					}
				}
				add = 6
			}
			else = { add = 3 } #Zero level
		}
		
		if = {
			limit = {
				involved_activity ?= { has_activity_type = activity_imperial_examination }
			}
			#Learning focused exams
			if = {
				limit = { 
					involved_activity ?= { activity_is_learning_focus_trigger = yes }
				}
				add = learning
				if = {
					limit = { has_trait = education_learning_1 }
					add = 3
				}
				if = {
					limit = { has_trait = education_learning_2 }
					add = 6
				}
				if = {
					limit = { has_trait = education_learning_3 }
					add = 9
				}
				if = {
					limit = { has_trait = education_learning_4 }
					add = 12
				}
				if = {
					limit = { has_trait = education_learning_5 }
					add = 15
				}
				if = {
					limit = { has_trait = shrewd }
					add = 3
				}
				if = {
					limit = { has_trait = lifestyle_mystic }
					add = 3
				}
				if = {
					limit = { 
						has_trait_xp = {
							trait = lifestyle_mystic 
							value >= trait_second_level
						}
					}
					add = 3
				}
				if = {
					limit = { 
						has_trait_xp = {
							trait = lifestyle_mystic 
							value >= trait_third_level
						}
					}
					add = 3
				}
				if = {
					limit = { has_trait = lifestyle_physician }
					add = 3
				}
				if = {
					limit = { 
						has_trait_xp = {
							trait = lifestyle_physician 
							value >= trait_second_level
						}
					}
					add = 3
				}
				if = {
					limit = { 
						has_trait_xp = {
							trait = lifestyle_physician 
							value >= trait_third_level
						}
					}
					add = 3
				}
				if = {
					limit = { has_trait = whole_of_body }
					add = 3
				}
				if = {
					limit = { has_trait = theologian }
					add = 3
				}
				if = {
					limit = { has_trait = scholar }
					add = 3
				}
				if = {
					limit = { has_trait = lifestyle_poet }
					add = 3
				}
				if = {
					limit = { has_trait = journaller }
					add = 3
				}
			}
			#Martial focused exams
			if = {
				limit = { 
					involved_activity ?= { activity_is_martial_focus_trigger = yes }
				}
				add = martial
				if = {
					limit = { has_trait = education_martial_1 }
					add = 3
				}
				if = {
					limit = { has_trait = education_martial_2 }
					add = 6
				}
				if = {
					limit = { has_trait = education_martial_3 }
					add = 9
				}
				if = {
					limit = { has_trait = education_martial_4 }
					add = 12
				}
				if = {
					limit = { has_trait = education_martial_5 }
					add = 15
				}
				if = {
					limit = { has_trait = strategist }
					add = 3
				}
				if = {
					limit = { has_trait = overseer }
					add = 3
				}
				if = {
					limit = { has_trait = gallant }
					add = 3
				}
				if = {
					limit = { has_trait = logistician }
					add = 3
				}
				if = {
					limit = { has_trait = military_engineer }
					add = 3
				}
				if = {
					limit = { has_trait = unyielding_defender }
					add = 3
				}
				if = {
					limit = { has_trait = forder }
					add = 3
				}
				if = {
					limit = { has_trait = flexible_leader }
					add = 3
				}
				if = {
					limit = { has_trait = desert_warrior }
					add = 3
				}
				if = {
					limit = { has_trait = reaver }
					add = 3
				}
				if = {
					limit = { has_trait = reckless }
					add = 3
				}
				if = {
					limit = { has_trait = holy_warrior }
					add = 3
				}
				if = {
					limit = { has_trait = open_terrain_expert }
					add = 3
				}
				if = {
					limit = { has_trait = rough_terrain_expert }
					add = 3
				}
				if = {
					limit = { has_trait = forest_fighter }
					add = 3
				}
				if = {
					limit = { has_trait = cautious_leader }
					add = 3
				}
				if = {
					limit = { has_trait = organizer }
					add = 3
				}
				if = {
					limit = { has_trait = winter_soldier }
					add = 3
				}
			}
			#Stewardship focused exams
			if = {
				limit = { 
					involved_activity ?= { activity_is_stewardship_focus_trigger = yes }
				}
				add = stewardship
				if = {
					limit = { has_trait = education_stewardship_1 }
					add = 3
				}
				if = {
					limit = { has_trait = education_stewardship_2 }
					add = 6
				}
				if = {
					limit = { has_trait = education_stewardship_3 }
					add = 9
				}
				if = {
					limit = { has_trait = education_stewardship_4 }
					add = 12
				}
				if = {
					limit = { has_trait = education_stewardship_5 }
					add = 15
				}
				if = {
					limit = { has_trait = architect }
					add = 3
				}
				if = {
					limit = { has_trait = administrator }
					add = 3
				}
				if = {
					limit = { has_trait = avaricious }
					add = 3
				}
				if = {
					limit = { has_trait = lifestyle_gardener }
					add = 3
				}
				if = {
					limit = { has_trait = governor }
					add = 3
				}
			}
		}
		else = {
			add = learning
			add = martial
			add = stewardship
		}
		
		# Bonus from House Aspirations
		if = {
			limit = {
				exists = house
			}
			house = {
				if = {
					limit = { has_house_aspiration_parameter = examination_success_bonus }
					add = 10
				}
			}
		}
		
		# Bonus from domicile buildings
		if = {
			limit = { exists = house.house_head.domicile }
			house.house_head.domicile = {
				# Archive - Multiplier
				if = {
					limit = { has_domicile_parameter = estate_examination_start_score_bonus_4 }
					multiply = {
						value = 1
						add = estate_examination_start_score_bonus_4_value
					}
				}
				else_if = {
					limit = { has_domicile_parameter = estate_examination_start_score_bonus_3 }
					multiply = {
						value = 1
						add = estate_examination_start_score_bonus_3_value
					}
				}
				else_if = {
					limit = { has_domicile_parameter = estate_examination_start_score_bonus_2 }
					multiply = {
						value = 1
						add = estate_examination_start_score_bonus_2_value
					}
				}
				else_if = {
					limit = { has_domicile_parameter = estate_examination_start_score_bonus_1 }
					multiply = {
						value = 1
						add = estate_examination_start_score_bonus_1_value
					}
				}
			}
		}

		#Malus for not taking the Local Exam.
		if = {
			limit = {
				involved_activity ?= { has_activity_type = activity_imperial_examination }
				NOT = { has_character_flag = passed_provincial_exam }
			}
			divide = 3
		}

		#Malus for not knowing the activity language
		if = {
			limit = {
				exists = scope:host.culture
				NOT = { knows_language_of_culture = scope:host.culture }
			}
			divide = 5
		}
	}
	min = 0
	ceiling = yes
}

imperial_examination_score_value = {
	value = 0
	#Is this for the Predicted Excellence?
	if = {
		limit = {
			NOT = { has_variable = imperial_examination_score }
		}
		add = imperial_examination_entry_value
	}
	#Or have you already taken at least one exam
	else = {
		add = var:imperial_examination_score
	}
}

metropolitan_exam_player_passing_grade = {
	value = 0
	add = imperial_examination_great_success_value
	multiply = num_intermediate_exams_value
}

imperial_examination_critical_success_value = {
	value = 0
	add = imperial_examination_great_success_value
	multiply = 2
}
#The arbitrary score we're adding for a successful exam
imperial_examination_great_success_value = 20
imperial_examination_success_value = {
	value = 0
	add = imperial_examination_great_success_value
	divide = 2
}

imperial_examination_cheat_value = {
	value = 0
	add = imperial_examination_great_success_value
	multiply = 1.5
}

imperial_examination_perfect_score_value = {
	value = imperial_examination_critical_success_value #100
	multiply = num_intermediate_exams_value #Essay, Classics, Poetry
}

imperial_examination_great_score_value = {
	value = imperial_examination_great_success_value #50
	multiply = num_intermediate_exams_value #Essay, Classics, Poetry
}

imperial_examination_decent_score_value = {
	value = imperial_examination_success_value #25
	multiply = num_intermediate_exams_value #Essay, Classics, Poetry
}

imperial_examination_intermediate_perfect_score_value = {
	value = imperial_examination_critical_success_value #100
	multiply = num_intermediate_exams_value #Essay, Classics, Poetry
}

imperial_examination_intermediate_great_score_value = {
	value = imperial_examination_great_success_value #50
	multiply = num_intermediate_exams_value #Essay, Classics, Poetry
}

imperial_examination_intermediate_decent_score_value = {
	value = imperial_examination_success_value #25
	multiply = num_intermediate_exams_value #Essay, Classics, Poetry
}

imperial_examination_merit_base_reward = 400

imperial_examination_legitimacy_base_reward_value = medium_legitimacy_gain
imperial_examination_influence_base_reward_value = 50
imperial_examination_prestige_base_reward_value = 50

local_examination_legitimacy_base_reward_value = minor_legitimacy_gain
local_examination_influence_base_reward_value = 30
local_examination_prestige_base_reward_value = 30

imperial_examination_palace_great_success_value = {
	value = duchy_starting_merit_value
	multiply = 3
}

imperial_examination_palace_success_value = {
	value = duchy_starting_merit_value
	multiply = 2
}

imperial_examination_merit_base_reward_value = {
	value = imperial_examination_merit_base_reward
	#High Score
	if = {
		limit = { has_perfect_score_trigger = { SCORE_VAR = imperial_examination_score } }
		multiply = 3
	}
	#Good Score
	else_if = {
		limit = { has_good_score_trigger = { SCORE_VAR = imperial_examination_score } }
		multiply = 2
	}
	#Decent Score
	else_if = {
		limit = { has_decent_score_trigger = { SCORE_VAR = imperial_examination_score } }
		multiply = 1.5
	}
	#Poor Score
	else_if = {
		limit = { has_questionable_score_trigger = { SCORE_VAR = imperial_examination_score } }
		multiply = 0.8
	}
	if = {
		limit = {
			is_in_guest_subset = { name = palace_entrants }
		}
		# Add a lump sum for all who took the Palace Exam.
		add = duchy_starting_merit_value
		if = {
			# Let's give extra to Player Characters who are not roped into OP Emperor Prep Phase Events
			limit = { is_ai = no }
			if = {
				limit = { has_character_flag = palace_critical_success }
				add = kingdom_starting_merit_value
			}
			else_if = {
				limit = { has_character_flag = palace_great_success }
				add = imperial_examination_palace_great_success_value
			}
			else_if = {
				limit = { has_character_flag = palace_success }
				add = imperial_examination_palace_success_value
			}
			else_if = {
				limit = { has_character_flag = safe_start }
				add = county_starting_merit_value
			}
		}
	}
}

local_examination_merit_base_reward_value = {
	value = major_merit_value
	#High Score
	if = {
		limit = { has_perfect_score_trigger = { SCORE_VAR = imperial_examination_score } }
		multiply = 3
	}
	#Good Score
	else_if = {
		limit = { has_good_score_trigger = { SCORE_VAR = imperial_examination_score } }
		multiply = 2.5
	}
	#Decent Score
	else_if = {
		limit = { has_decent_score_trigger = { SCORE_VAR = imperial_examination_score } }
		multiply = 1.5
	}
	#Poor Score
	else_if = {
		limit = { has_questionable_score_trigger = { SCORE_VAR = imperial_examination_score } }
		multiply = 0.8
	}
}

imperial_examination_entrant_influence_reward_value = {
	value = imperial_examination_influence_base_reward_value
	#High Score
	if = {
		limit = { has_perfect_score_trigger = { SCORE_VAR = imperial_examination_score } }
		multiply = 4
	}
	#Good Score
	else_if = {
		limit = { has_good_score_trigger = { SCORE_VAR = imperial_examination_score } }
		multiply = 2
	}
	#Poor Score
	else_if = {
		limit = { has_questionable_score_trigger = { SCORE_VAR = imperial_examination_score } }
		multiply = 0.8
	}
}

local_examination_entrant_influence_reward_value = {
	value = local_examination_influence_base_reward_value
	#High Score
	if = {
		limit = { has_perfect_score_trigger = { SCORE_VAR = imperial_examination_score } }
		multiply = 3.5
	}
	#Good Score
	else_if = {
		limit = { has_good_score_trigger = { SCORE_VAR = imperial_examination_score } }
		multiply = 2.5
	}
	#Decent Score
	else_if = {
		limit = { has_decent_score_trigger = { SCORE_VAR = imperial_examination_score } }
		multiply = 1.5
	}
	#Poor Score
	else_if = {
		limit = { has_questionable_score_trigger = { SCORE_VAR = imperial_examination_score } }
		multiply = 0.8
	}
}

imperial_examination_entrant_merit_reward_value = {
	value = imperial_examination_merit_base_reward_value
	if = {
		limit = {
			is_in_guest_subset = { name = palace_entrants }
		}
		add = {
			value = var:imperial_examination_score
			multiply = 0.1
		}
	}
	#Extreme Grade
	if = {
		limit = { scope:activity = { activity_has_extreme_grade_trigger = yes } }
		multiply = 2
	}
	#High Grade is the default, as it were, so no post for that case
	#Mediocre Grade
	else_if = {
		limit = { scope:activity = { activity_has_mediocre_grade_trigger = yes } }
		multiply = 0.8
	}
	#Low Grade
	else = {
		limit = { scope:activity = { activity_has_low_grade_trigger = yes } }
		multiply = 0.5
	}
	#Grand Secretariat Mandate
	if = {
		limit = {
			scope:activity.activity_host.top_liege.diarch ?= { has_active_mandate = promote_merit }
		}
		multiply = 1.1
	}
}

imperial_examination_failee_influence_reward_value = {
	value = imperial_examination_influence_base_reward_value
	multiply = 0.2
}

imperial_examination_failee_merit_reward_value = {
	value = imperial_examination_merit_base_reward_value
	multiply = 0.1
}

temporary_exam_score_value = {
	value = 0
	if = {
		limit = { has_variable = temporary_exam_score }
		add = var:temporary_exam_score
	}
}

imperial_examination_current_ai_entrants_value = {
	value = 0
	scope:activity = {
		every_guest_subset = {
			name = entrants
			limit = { 
				is_ai = yes
				is_alive = yes
			}
			add = 1
		}
	}
}

imperial_examination_current_failees_value = {
	value = 0
	scope:activity = {
		every_guest_subset = {
			name = failees
			add = 1
		}
	}
}

imperial_examination_failee_quota_value = {
	value = 0
	#If we only have 1 guest, the failee quota needs to be 0
	if = {
		limit = {
			#activity_num_attending_characters_value >= 2
			scope:activity = { activity_has_ai_entrants_trigger = yes }
		}
		add = imperial_examination_current_ai_entrants_value
		#Not the 10th percentile? Too bad.
		if = {
			limit = {
				scope:activity = { activity_has_extreme_grade_trigger = yes }
			}
			multiply = 0.5
		}
		if = {
			limit = {
				scope:activity = { activity_has_high_grade_trigger = yes }
			}
			multiply = 0.3
		}
		if = {
			limit = {
				scope:activity = { activity_has_mediocre_grade_trigger = yes }
			}
			multiply = 0.15
		}
		if = {
			limit = {
				scope:activity = { activity_has_low_grade_trigger = yes }
			}
			multiply = 0.1
		}
		round = yes
		min = 0
	}
}

exam_cheats_count = {
	value = 0
	if = {
		limit = { has_variable = has_bribed_examiner }
		add = 1
	}
	if = {
		limit = { has_variable = has_exam_taker }
		add = 1
	}
	if = {
		limit = { has_variable = has_blackmailed_examiner }
		add = 1
	}
	if = {
		limit = { has_variable = has_planted_answers }
		add = 1
	}
	if = {
		limit = { has_variable = parent_has_bribed_examiner }
		add = 1
	}
}

imperial_examination_cooldown_years = 3

#Example:
# Provincial
# 200 guests * 0.75 = 150 fails
# 75 fails Provincial round = 50%
# 50 fails Metropolitan round = 34%
# 25 fails Palace round = 16% (a.k.a. the original number minus the current failee number, since we sometime lack 1 failee from the final failee count corresponding to var:failee_quota due to rounding down)
