## 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 ##
#################

rare_crystals_expenditure_planets = {
	resource = rare_crystals
	type = expenditure
	category = planets

	potential = {
		always = yes
	}

	weight = {
		weight = 0.2
		modifier = {
			factor = 3
			is_nomadic = yes
		}
	}
	desired_min = {
		base = 0
		modifier = {
			add = @ai_nomad_strategic_planet_desired_min
			is_nomadic = yes
			owns_arkship_fleets_at_least = {
				COUNT = 1
			}
		}
		modifier = {
			add = @ai_nomad_strategic_planet_desired_min
			is_nomadic = yes
			owns_arkship_fleets_at_least = {
				COUNT = 2
			}
		}
		modifier = {
			add = @ai_nomad_strategic_planet_desired_min
			is_nomadic = yes
			owns_arkship_fleets_at_least = {
				COUNT = 3
			}
		}
	}
	desired_max = {
		base = 0
		modifier = {
			add = @ai_nomad_strategic_planet_desired_max
			is_nomadic = yes
			owns_arkship_fleets_at_least = {
				COUNT = 1
			}
		}
		modifier = {
			add = @ai_nomad_strategic_planet_desired_max
			is_nomadic = yes
			owns_arkship_fleets_at_least = {
				COUNT = 2
			}
		}
		modifier = {
			add = @ai_nomad_strategic_planet_desired_max
			is_nomadic = yes
			owns_arkship_fleets_at_least = {
				COUNT = 3
			}
		}
	}
}

rare_crystals_expenditure_ships = {
	resource = rare_crystals
	type = expenditure
	category = ships

	potential = {
		always = yes
	}

	weight = {
		weight = 0.1
		modifier = {
			factor = 5
			is_dragon_breeder_country = yes
		}
	}
}

rare_crystals_expenditure_upgrade = {
	resource = rare_crystals
	type = expenditure
	category = ship_upgrades

	potential = {
		always = yes
	}

	weight = {
		base = 0.1
	}
}

rare_crystals_expenditure_trade = {
	resource = rare_crystals
	type = expenditure
	category = trade

	potential = {
		always = yes
	}

	weight = {
		weight = 0.1
	}
}

rare_crystals_expenditure_hyper_relays = {
	resource = rare_crystals
	type = expenditure
	category = megastructures_hyper_relay

	potential = {
		has_technology = tech_hyper_relays
		if = {
			limit = {
				is_nomadic = no
			}
			any_system_within_border = {
				has_hyper_relay = no
				OR = {
					is_capital_system = yes
					any_neighbor_system = {
						has_hyper_relay = yes
					}
				}
			}
		}
		else = {
			any_owned_nonprimary_starbase = {
				has_starbase_size >= starbase_waystation_2
				solar_system = {
					has_hyper_relay = no
					OR = {
						any_neighbor_system = {
							has_hyper_relay = yes
						}
						prev = {
							has_starbase_size >= starbase_waystation_3
						}
						prev = {
							has_starbase_size >= starbase_waystation_2
							has_starbase_module = waystation_logistics_hub
						}
					}
				}
			}
		}
	}

	weight = {
		weight = 0.5
	}
	desired_min = {
		base = 100
	}
	desired_max = {
		base = 100
	}
}

rare_crystals_expenditure_starbases = {
	resource = rare_crystals
	type = expenditure
	category = starbases

	potential = {
		OR = {
			is_nomadic = yes
			any_owned_nonprimary_starbase = {
				has_starbase_size >= orbital_ring_tier_2
				exists = planet
			}
		}
	}

	weight = {
		weight = 0.2

		modifier = {
			factor = 0
			is_nomadic = no
			NOT = { has_orbital_ring_with_empty_building_slots = yes }
		}
		modifier = {
			factor = 3
			is_nomadic = yes
		}
	}
	desired_min = {
		base = 0
		modifier = {
			add = @ai_nomad_strategic_starbase_desired_min
			is_nomadic = yes
			owns_arkship_fleets_at_least = {
				COUNT = 1
			}
		}
		modifier = {
			add = @ai_nomad_strategic_starbase_desired_min
			is_nomadic = yes
			owns_arkship_fleets_at_least = {
				COUNT = 2
			}
		}
		modifier = {
			add = @ai_nomad_strategic_starbase_desired_min
			is_nomadic = yes
			owns_arkship_fleets_at_least = {
				COUNT = 3
			}
		}
	}
	desired_max = {
		base = 0
		modifier = {
			add = @ai_nomad_strategic_starbase_desired_max
			is_nomadic = yes
			owns_arkship_fleets_at_least = {
				COUNT = 1
			}
		}
		modifier = {
			add = @ai_nomad_strategic_starbase_desired_max
			is_nomadic = yes
			owns_arkship_fleets_at_least = {
				COUNT = 2
			}
		}
		modifier = {
			add = @ai_nomad_strategic_starbase_desired_max
			is_nomadic = yes
			owns_arkship_fleets_at_least = {
				COUNT = 3
			}
		}
	}
}

rare_crystals_expenditure_starbases_standard = {
	resource = rare_crystals
	type = expenditure
	category = starbases

	potential = {
		is_nomadic = no
		OR = {
			has_technology = tech_storm_manipulation
			has_origin = origin_shroudwalker_apprentice
			has_country_flag = shroudwalker_enclave_bought_shroud_beacon
		}
	}

	weight = {
		weight = 0.1
	}
}

rare_crystals_upkeep_starbases_standard = {
	resource = rare_crystals
	type = upkeep
	category = starbases

	potential = {
		is_nomadic = no
		has_technology = tech_storm_manipulation
	}

	weight = {
		weight = 0.1
	}
}

# Upkeep ---------------------------------------------------------------

rare_crystals_upkeep_planets = {
	resource = rare_crystals
	type = upkeep
	category = planets

	potential = {
		always = yes
	}

	weight = {
		weight = 0.9
	}
}

rare_crystals_upkeep_ships = {
	resource = rare_crystals
	type = upkeep
	category = ships

	potential = {
		always = yes
	}

	weight = {
		weight = 0.1
	}
}

rare_crystals_upkeep_edicts = {
	resource = rare_crystals
	type = upkeep
	category = edicts

	potential = {
		always = yes
	}

	weight = {
		base = 0.25
	}
}

rare_crystals_upkeep_hyper_relays = {
	resource = rare_crystals
	type = upkeep
	category = megastructures_hyper_relay

	potential = {
		has_technology = tech_hyper_relays
	}

	weight = {
		weight = 0.1
	}
}

rare_crystals_upkeep_starbases = {
	resource = rare_crystals
	type = upkeep
	category = starbases

	potential = {
		OR = {
			is_nomadic = yes
			any_owned_nonprimary_starbase = {
				has_starbase_size >= orbital_ring_tier_2
				exists = planet
			}
		}
	}

	weight = {
		weight = 0.1
		modifier = {
			factor = 3
			is_nomadic = yes
		}
	}
}
