# Scope: leader. Gives the leader its class's version of a leader trait while its species has
# SPECIES_TRAIT, and takes it away when the species loses it.
# Leader traits are named leader_trait_<class>_<SUFFIX>; 4.x classes are commander, official and
# scientist (rulers keep their class; the ruler bonus is a triggered_councilor_modifier).
apb_sync_leader_trait = {
	if = {
		limit = {
			species = { has_trait = $SPECIES_TRAIT$ }
		}
		if = {
			limit = {
				leader_class = commander
				NOT = { has_trait = leader_trait_commander_$SUFFIX$ }
			}
			add_trait = { trait = leader_trait_commander_$SUFFIX$ show_message = no }
		}
		else_if = {
			limit = {
				leader_class = official
				NOT = { has_trait = leader_trait_official_$SUFFIX$ }
			}
			add_trait = { trait = leader_trait_official_$SUFFIX$ show_message = no }
		}
		else_if = {
			limit = {
				leader_class = scientist
				NOT = { has_trait = leader_trait_scientist_$SUFFIX$ }
			}
			add_trait = { trait = leader_trait_scientist_$SUFFIX$ show_message = no }
		}
	}
	else = {
		if = {
			limit = { has_trait = leader_trait_commander_$SUFFIX$ }
			remove_trait = leader_trait_commander_$SUFFIX$
		}
		if = {
			limit = { has_trait = leader_trait_official_$SUFFIX$ }
			remove_trait = leader_trait_official_$SUFFIX$
		}
		if = {
			limit = { has_trait = leader_trait_scientist_$SUFFIX$ }
			remove_trait = leader_trait_scientist_$SUFFIX$
		}
	}
}

# Scope: leader. Forever Young (trait_youth) and Perpetually Maintained (Perpetual Maintenance).
apb_sync_all_leader_traits = {
	apb_sync_leader_trait = { SPECIES_TRAIT = trait_youth SUFFIX = youth }
	apb_sync_leader_trait = { SPECIES_TRAIT = trait_apb_perpetual_maintenance SUFFIX = apb_maintained }
}
