# Scripted triggers for the War College.
#
# wc_can_pay_current_phase = checks the player has enough equipment in
# stockpile to pay for the *next* Advance click, given the current
# wc_training_id + wc_training_phase. Used to grey out the Advance button
# when the player can't afford the next phase. The has_equipment check is
# the same archetype-family check vanilla decisions use.
#
# Thresholds use "> N-1" (e.g. > 249 = "at least 250") because has_equipment
# is strictly-greater-than. Keep these in lockstep with the amounts in
# wc_advance_effects.txt and the WC_COST_* loc strings.

wc_can_pay_current_phase = {
	OR = {
		# T1 Infantry Studies (id = 1) - 250/350/400 inf
		AND = {
			check_variable = { wc_training_id = 1 }
			OR = {
				AND = { check_variable = { wc_training_phase = 0 } has_equipment = { infantry_equipment > 249 } }
				AND = { check_variable = { wc_training_phase = 1 } has_equipment = { infantry_equipment > 349 } }
				AND = { check_variable = { wc_training_phase = 2 } has_equipment = { infantry_equipment > 399 } }
			}
		}
		# T1 Artillery Support Studies (id = 2) - 30/50/70 art
		AND = {
			check_variable = { wc_training_id = 2 }
			OR = {
				AND = { check_variable = { wc_training_phase = 0 } has_equipment = { artillery_equipment > 29 } }
				AND = { check_variable = { wc_training_phase = 1 } has_equipment = { artillery_equipment > 49 } }
				AND = { check_variable = { wc_training_phase = 2 } has_equipment = { artillery_equipment > 69 } }
			}
		}
		# T1 Armor Studies (id = 3) - 20/30/50 ltc. light_tank_chassis is the
		# modern tank-designer family root used by post-NSB tank equipment.
		AND = {
			check_variable = { wc_training_id = 3 }
			OR = {
				AND = { check_variable = { wc_training_phase = 0 } has_equipment = { light_tank_chassis > 19 } }
				AND = { check_variable = { wc_training_phase = 1 } has_equipment = { light_tank_chassis > 29 } }
				AND = { check_variable = { wc_training_phase = 2 } has_equipment = { light_tank_chassis > 49 } }
			}
		}
		# T1 Operational Studies (id = 4) - needs BOTH infantry and support.
		# 250+25 / 350+35 / 400+40
		AND = {
			check_variable = { wc_training_id = 4 }
			OR = {
				AND = {
					check_variable = { wc_training_phase = 0 }
					has_equipment = { infantry_equipment > 249 }
					has_equipment = { support_equipment > 24 }
				}
				AND = {
					check_variable = { wc_training_phase = 1 }
					has_equipment = { infantry_equipment > 349 }
					has_equipment = { support_equipment > 34 }
				}
				AND = {
					check_variable = { wc_training_phase = 2 }
					has_equipment = { infantry_equipment > 399 }
					has_equipment = { support_equipment > 39 }
				}
			}
		}
	}
}
