namespace = esap_combination_t1

# The Art of War, add special trait to Admirals and Generals.
country_event = {
	id = esap_combination_t1.1
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		has_ascension_perk = ap_esap_ct1_war
		from = {
			Not = { has_leader_flag = flag_esap_ct1_war_trait_added }
			has_skill > 2
		}
	}
	
	immediate = {
		from = {
			set_leader_flag = flag_esap_ct1_war_trait_added
			if = {
				limit = { leader_class = commander }
				random_list = {
					1 = { add_trait = leader_trait_admiral_esap_ct1_war_deceptive }
					1 = { add_trait = leader_trait_admiral_esap_ct1_war_decisive }
					1 = { add_trait = leader_trait_admiral_esap_ct1_war_moderate }
					1 = { add_trait = leader_trait_admiral_esap_ct1_war_observant }
					1 = { add_trait = leader_trait_admiral_esap_ct1_war_opportunist }
					1 = { add_trait = leader_trait_admiral_esap_ct1_war_prudent }
					1 = { add_trait = leader_trait_admiral_esap_ct1_war_wise }
				}
			}
			if = {
				limit = { leader_class = commander }
				random_list = {
					1 = { add_trait = leader_trait_general_esap_ct1_war_ambusher }
					1 = { add_trait = leader_trait_general_esap_ct1_war_demoralizer }
					1 = { add_trait = leader_trait_general_esap_ct1_war_enigma }
					1 = { add_trait = leader_trait_general_esap_ct1_war_inspirational }
					1 = { add_trait = leader_trait_general_esap_ct1_war_preservative }
				}
			}
		}		
	}
}

# Whispers of Profit, generate Energy Credits.
planet_event = {
	id = esap_combination_t1.3
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		owner = {
			has_ascension_perk = ap_esap_ct1_finance
		}
	}

	immediate = {
		if = {
			limit = { last_district_changed = district_city }
			owner = {
				owner = { add_resource = { energy = 200 } }
			}
		}
	}
}

# Builders of Nations, Bonus while there are new free district slots.
country_event = {
	id = esap_combination_t1.4
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		has_ascension_perk = ap_esap_ct1_infrastructure
	}
	
	immediate = {
		every_owned_planet = {
			if = {
				limit = {
					num_free_districts = { 
						type = any
						value < 1
					} 
				}
				if = {
					limit = {
						Not = { has_modifier = mod_esap_ct1_infrastructure }
					}
					add_modifier = {
						modifier = "mod_esap_ct1_infrastructure"
						days = -1
					}
				}
			}
			else = {
				if = {
					limit = { has_modifier = mod_esap_ct1_infrastructure }
					remove_modifier = "mod_esap_ct1_infrastructure"
				}
			}
		}
	}
}