# Scripted triggers for the Naval College.
#
# nc_can_pay_current_phase = checks the player can pay for the *next*
# Advance click, given the current nc_training_id + nc_training_phase.
#
# Cost model (exercise simulation):
#   - Convoys are CONSUMED (sunk in exercise) by add_equipment_to_stockpile
#     in the advance effects. Convoy is a normal equipment archetype, so
#     has_equipment = { convoy > N } gates the stockpile check.
#   - The relevant ship type (subs / screens / carriers / battleships)
#     must be PRESENT in the active fleet but is NOT consumed - the navy
#     practices using its own ships, which return to port intact.
#     has_navy_size = { unit = <archetype> size > N } is the correct
#     trigger for ship-count gating (post-NSB the ship equipment
#     archetypes were renamed to ship_hull_*; has_equipment no longer
#     accepts plain unit names like "battleship").
#
# Thresholds use "> N-1" (e.g. > 4 = "at least 5") because both
# has_equipment and has_navy_size are strictly-greater-than. Keep
# these in lockstep with the amounts in nc_advance_effects.txt and
# the NC_COST_* loc strings.

nc_can_pay_current_phase = {
	OR = {
		# Submarine Studies (id = 1) - subs sink convoys in exercise.
		# Convoys consumed: 5/10/15. Subs required (not consumed): 3/5/8.
		AND = {
			check_variable = { nc_training_id = 1 }
			OR = {
				AND = {
					check_variable = { nc_training_phase = 0 }
					has_equipment = { convoy > 4 }
					has_navy_size = { unit = submarine size > 2 }
				}
				AND = {
					check_variable = { nc_training_phase = 1 }
					has_equipment = { convoy > 9 }
					has_navy_size = { unit = submarine size > 4 }
				}
				AND = {
					check_variable = { nc_training_phase = 2 }
					has_equipment = { convoy > 14 }
					has_navy_size = { unit = submarine size > 7 }
				}
			}
		}
		# Screen Studies (id = 2) - destroyers OR light cruisers screen exercise convoys.
		# Convoys consumed: 5/10/15. Screens required (not consumed): 3/5/8 of either type.
		AND = {
			check_variable = { nc_training_id = 2 }
			OR = {
				AND = {
					check_variable = { nc_training_phase = 0 }
					has_equipment = { convoy > 4 }
					OR = {
						has_navy_size = { unit = destroyer size > 2 }
						has_navy_size = { unit = light_cruiser size > 2 }
					}
				}
				AND = {
					check_variable = { nc_training_phase = 1 }
					has_equipment = { convoy > 9 }
					OR = {
						has_navy_size = { unit = destroyer size > 4 }
						has_navy_size = { unit = light_cruiser size > 4 }
					}
				}
				AND = {
					check_variable = { nc_training_phase = 2 }
					has_equipment = { convoy > 14 }
					OR = {
						has_navy_size = { unit = destroyer size > 7 }
						has_navy_size = { unit = light_cruiser size > 7 }
					}
				}
			}
		}
		# Carrier Studies (id = 3) - carrier strike exercises against convoys.
		# Convoys consumed: 5/10/15. Carriers required (not consumed): 1/2/3.
		AND = {
			check_variable = { nc_training_id = 3 }
			OR = {
				AND = {
					check_variable = { nc_training_phase = 0 }
					has_equipment = { convoy > 4 }
					has_navy_size = { unit = carrier size > 0 }
				}
				AND = {
					check_variable = { nc_training_phase = 1 }
					has_equipment = { convoy > 9 }
					has_navy_size = { unit = carrier size > 1 }
				}
				AND = {
					check_variable = { nc_training_phase = 2 }
					has_equipment = { convoy > 14 }
					has_navy_size = { unit = carrier size > 2 }
				}
			}
		}
		# Battleship Studies (id = 4) - capital-ship gunnery exercises on convoys.
		# Convoys consumed: 5/10/15. Battleships required (not consumed): 1/2/3.
		AND = {
			check_variable = { nc_training_id = 4 }
			OR = {
				AND = {
					check_variable = { nc_training_phase = 0 }
					has_equipment = { convoy > 4 }
					has_navy_size = { unit = battleship size > 0 }
				}
				AND = {
					check_variable = { nc_training_phase = 1 }
					has_equipment = { convoy > 9 }
					has_navy_size = { unit = battleship size > 1 }
				}
				AND = {
					check_variable = { nc_training_phase = 2 }
					has_equipment = { convoy > 14 }
					has_navy_size = { unit = battleship size > 2 }
				}
			}
		}
	}
}
