## Categories used in this file must have use_for_ai_budget = yes defined in economic_categories ##
## It is possible to have multiple entries with the same category and resource ##

#################
## Expenditure ##
#################
trade_expenditure_buffer = { # Buffer, will not be spent
	resource = trade
	type = expenditure
	category = buffer

	potential = {
		always = yes
	}

	weight = {
		weight = 0.1
	}
}


trade_expenditure_colonies_sponsored = {
	resource = trade
	type = expenditure
	category = colonies

	potential = {
		is_nomadic = no
		is_guided_sapience_empire = no
		OR = {
			has_civic = civic_corporate_dominion
			has_civic = civic_private_prospectors
		}
		ai_colonize_plans > 0
		has_resource = { type = trade amount > 400 }
		has_monthly_income = {
			resource = trade
			value > 0
		}
	}

	weight = {
		weight = 1.5
	}

	desired_min = {
		base = @colony_cost_high # Sponsored colonizer costs 500 trade
	}

	desired_max = {
		base = @colony_cost_high_max
	}
}

trade_expenditure_trade = {
	resource = trade
	type = expenditure
	category = trade

	potential = {
		has_resource = {
			type = trade
			amount > 2500
		}
	}

	weight = {
		weight = 0.5
	}
}

trade_expenditure_trade_deficit = {
	resource = trade
	type = expenditure
	category = trade

	potential = {
		has_resource = {
			type = trade
			amount > 100
		}
		OR = {
			AND = {
				has_monthly_income = {
					resource = energy
					value < -1
				}
				has_resource = {
					type = energy
					amount < 1000
				}
			}
			AND = {
				has_monthly_income = {
					resource = minerals
					value < -1
				}
				has_resource = {
					type = minerals
					amount < 1000
				}
			}
			AND = {
				has_monthly_income = {
					resource = food
					value < -1
				}
				has_resource = {
					type = food
					amount < 500
				}
			}
			AND = {
				has_monthly_income = {
					resource = consumer_goods
					value < -1
				}
				has_resource = {
					type = consumer_goods
					amount < 500
				}
			}
			AND = {
				has_monthly_income = {
					resource = alloys
					value < -1
				}
				has_resource = {
					type = alloys
					amount < 500
				}
			}
		}
	}

	weight = {
		weight = 0.7
	}
}

############
## Upkeep ##
############
trade_upkeep_buffer = {	# Buffer, will not be spent
	resource = trade
	type = upkeep
	category = buffer

	potential = {
		always = yes
	}

	weight = {
		weight = 0.01
	}
}

trade_upkeep_planets = {
	resource = trade
	type = upkeep
	category = planets

	potential = {
		always = yes
	}

	weight = {
		weight = 0.1

		modifier = {
			add = 0.5

			resource_expenses_compare = {
				resource = trade
				category = planet_resource_deficit
				value > 0
			}
		}
	}
}

trade_upkeep_country = { # Covers most other things. Note: each category opts into using this pool via ai_use_parent_for_resources_upkeep in the category
	resource = trade
	type = upkeep
	category = country

	potential = {
		always = yes
	}

	weight = {
		weight = 1
		modifier = {
			factor = 1.25
			resource_income_compare = {
				resource = trade
				value > 1000
			}
		}
		modifier = {
			factor = 1.5
			resource_income_compare = {
				resource = trade
				value > 2000
			}
		}
	}
}

trade_upkeep_ships = {
	resource = trade
	type = upkeep
	category = ships

	potential = {
		always = yes
	}

	weight = {
		weight = 0.5
		modifier = {
			factor = 1.5
			OR = {
				is_at_war = yes
				resource_income_compare = {
					resource = trade
					value > 800
				}
			}
		}
	}
}
