﻿construction_center = {
	audio_tier = 2

	is_foreign = no
	max_levels = construction_center_max_level 
	pop_type = bureaucrats
	forbidden_for_estates = yes

	employment_size = construction_employment

	category = infrastructure_category

	town = yes
	city = yes
	megalopolis = yes

	
	increase_per_level_cost = 1.0

	build_time = government_build_time


	unique_production_methods = {
		construction_center_maintenance = {
			icon_type = goods
			icon = masonry
			masonry = 0.2
			tools = 0.25
			category = building_maintenance
		}
	}


	construction_demand = town_building_construction


	modifier = {
		max_constructions_at_same_time = 1
	}

}

minting_office = {
	audio_tier = 1
	is_foreign = no
	max_levels = 1
	pop_type = bureaucrats
	forbidden_for_estates = yes


	category = government_category
	employment_size = generic_burgher_employment

	town = yes
	city = yes
	megalopolis = yes

	expensive = yes

	build_time = government_build_time

	possible_production_methods = {
		mint_maintenance
	}

	construction_demand = minting_office_construction


	modifier = {
		local_crown_estate_power = 0.25	
		local_bureaucrats_desired_pop_scaled = 0.001
	}

}

granary = {
	audio_tier = 2
	is_foreign = no
	max_levels = guild_max_level

	pop_type = laborers

	employment_size = granary_employment
	AI_ignore_available_worker_flag = yes # we want this for pop growth so build it anyway

	category = infrastructure_category

	rural_settlement = no
	town = yes
	city = yes
	megalopolis = yes


	build_time = government_build_time


	unique_production_methods = {
		granary_maintenance = {
			icon_type = goods
			icon = masonry
			masonry = 0.2
			category = building_maintenance
		}
	}


	construction_demand = granary_construction



	modifier = {
		local_food_capacity = 500
		local_food_decay_modifier = -0.05
	}

	ai_forbid_shutdown = yes
}

fortress_granary = { #https://en.wikipedia.org/wiki/Agadir_(granary)
	audio_tier = 2
	is_special = yes
	is_foreign = no
	max_levels = 1
	pop_type = peasants

	rural_settlement = no
	town = yes
	city = yes
	megalopolis = yes

	employment_size = granary_employment
	category = defense_category

	build_time = medium_fort_building

	country_potential = {
		culture ?= { has_culture_group = culture_group:maghrebi_group }
	}

	location_potential = {
	}

	expensive = yes

	construction_demand = fortress_granary_construction

	modifier = {
		local_garrison_size = 0.1
		local_food_capacity = 500
		local_defensive = 0.25
	}

	unique_production_methods = {
		fortress_granary_maintenance = {
			icon_type = goods
			icon = wheat
			wheat = 0.1
			masonry = 0.2
			weaponry = 0.05
			cloth = 0.05
			copper = 0.025
			tin = 0.01
			potential = {
				any_market_present_in_country = {
					is_produced_in_market = goods:wheat
				}
			}
			allow = {
				scope:target ?= { market ?= {  is_produced_in_market = goods:wheat } }
			}
			category = building_maintenance
		}

		fortress_millet_granary_maintenance = {
			icon_type = goods
			icon = millet
			millet = 0.1
			masonry = 0.2
			weaponry = 0.05
			cloth = 0.05
			copper = 0.025
			tin = 0.01
			potential = {
				any_market_present_in_country = {
					is_produced_in_market = goods:millet
				}
			}
			allow = {
				scope:target ?= {  market ?= { is_produced_in_market = goods:millet } }
			}
			category = building_maintenance
		}

		fortress_rice_granary_maintenance = {
			icon_type = goods
			icon = rice
			rice = 0.1
			masonry = 0.2
			weaponry = 0.05
			cloth = 0.05
			copper = 0.025
			tin = 0.01
			potential = {
				any_market_present_in_country = {
					is_produced_in_market = goods:rice
				}
			}
			allow = {
				scope:target ?= { market ?= {  is_produced_in_market = goods:rice } }
			}
			category = building_maintenance
		}

		fortress_maize_granary_maintenance = {
			icon_type = goods
			icon = maize
			maize = 0.1
			masonry = 0.2
			weaponry = 0.05
			cloth = 0.05
			copper = 0.025
			tin = 0.01
			potential = {
				any_market_present_in_country = {
					is_produced_in_market = goods:maize
				}
			}
			allow = {
				scope:target ?= {market ?= { is_produced_in_market = goods:maize } }
			}
			category = building_maintenance
		}

		fortress_qullqa_maintenance = {
			icon_type = goods
			icon = potato
			potato = 0.08
			maize = 0.02
			masonry = 0.2
			weaponry = 0.05
			cloth = 0.05
			copper = 0.025
			tin = 0.01
			potential = {
				any_market_present_in_country = {
					is_produced_in_market = goods:potato
					is_produced_in_market = goods:maize
				}
			}
			allow = {
				scope:target ?= { market ?= {
						is_produced_in_market = goods:potato
						is_produced_in_market = goods:maize
					}
				}
			}
			category = building_maintenance
		}
	}
}

grain_house = {
	audio_tier = 1
	is_foreign = no
	max_levels = guild_max_level

	pop_type = laborers

	employment_size = granary_employment

	category = infrastructure_category

	rural_settlement = no
	town = yes
	city = yes
	megalopolis = yes

	build_time = government_build_time

	country_potential = {
		has_reform = government_reform:everyone_serves_reform
	}

	possible_production_methods = {
		granary_maintenance
	}

	construction_demand = granary_construction

	modifier = {
		local_food_capacity = 100
		local_supply_limit_modifier = 0.01
	}
}

medical_school = {
	audio_tier = 2
	is_foreign = no
	pop_type = bureaucrats

	max_levels = 1
	employment_size = burghers_medical_employment

	category = infrastructure_category

	rural_settlement = no
	town = yes
	city = yes
	megalopolis = yes


	build_time = huge_unique_build_time
	graphical_tags = { medium_religious }

	expensive = yes

	modifier = {
		local_life_expectancy = 3
		local_disease_resistance = 0.33
	}

	possible_production_methods = {
		temple_maintenance
	}


	construction_demand = town_building_construction
}

lazaretto = {
	audio_tier = 1
	is_foreign = no
	pop_type = bureaucrats
	max_levels = 1
	employment_size = clergy_medical_employment
	category = infrastructure_category
	town = yes
	city = yes
	megalopolis = yes
	location_potential = {
		is_coastal = yes
	}
	expensive = yes
	build_time = generic_town_build_time

	unique_production_methods = {
		lazaretto_maintenance = {
			icon_type = goods
			icon = fiber_crops
			fiber_crops = 0.15
			books = 0.05
			medicaments = 0.03
			category = building_maintenance
		}
	}
	construction_demand = town_building_construction
	modifier = {
		local_disease_resistance = 0.25
	}
}

pest_house = {
	audio_tier = 1
	is_foreign = no
	pop_type = clergy
	max_levels = 1
	employment_size = clergy_medical_employment
	category = infrastructure_category

	rural_settlement = yes
	town = yes
	city = yes
	megalopolis = yes

	build_time = super_fast_temporary_house

	country_potential = {
		is_situation_active = situation:black_death
		custom_tooltip = {
				text = pest_house_tt
				modifier:enable_pest_house = yes
			}
	}
	
	remove_if = {
		OR = {
			NOT = { is_situation_active = situation:black_death }
			owner = {
				AND = {
					modifier:enable_pest_house = no
					trigger_if = {
						limit = {
							is_subject = yes
						}
						overlord = { modifier:enable_pest_house = no }
					}
				}
			}
		}
	}

	unique_production_methods = {
		pest_house_maintenance = {
			icon_type = goods
			icon = fiber_crops
			fiber_crops = 0.10
			incense = 0.10
			category = building_maintenance
		}
	}
	construction_demand = town_building_construction
	modifier = {
		local_disease_resistance = 0.3
		local_unrest = 0.1
	}
}

hospital = {
	audio_tier = 2
	is_foreign = no
	pop_type = bureaucrats
	max_levels = 1
	employment_size = clergy_medical_employment

	category = infrastructure_category

	town = yes
	city = yes
	megalopolis = yes

	location_potential = {
		development >= 20
	}

	expensive = yes

	build_time = generic_town_build_time


	possible_production_methods = {
		hospital_maintenance
	}
	graphical_tags = { medium_religious }


	construction_demand = town_building_construction

	modifier = {
		local_disease_resistance = 0.1
		local_life_expectancy = 5
	}
}

slave_market = {
	audio_tier = 2
	is_foreign = no
	max_levels = slave_market_max_level
	startup_ramp_target = rural_startup_ramp_target
	pop_type = burghers

	category = government_category


	employment_size = trade_employment


	rural_settlement = no
	town = yes
	city = yes
	megalopolis = yes


	country_potential = {
		religion ?= {
			group != religion_group:christian
		}
	}


	allow = {
		scope:actor = {
			has_slavery = yes
		}
	}

	remove_if = {
		scope:actor = {
			has_slavery = no
		}
	}

	

	build_time = generic_town_build_time

	unique_production_methods = {

		slave_market_maintenance = {
			icon_type = goods
			icon = leather
			leather = 0.526
			tools = 0.478
			weaponry = 0.421
			paper = 0.363

			produced = slaves_goods
			output = 2.0

			debug_max_profit = rural_profit_margin
			category = building_maintenance
		}


	}

	modifier = {
		building_enslavement_power = 0.10
		local_slave_pop_satisfaction = -0.025
	}



	construction_demand = town_building_construction

}


#Aqueducts

aqueduct_system = {
	audio_tier = 5
	content_priority = 100
	is_foreign = no
	max_levels = aqueduct_system_max_level 
	pop_type = laborers
	forbidden_for_estates = yes

	employment_size = aqueduct_system_employment
	price = expand_aqueduct_system

	category = infrastructure_category

	town = yes
	city = yes
	megalopolis = yes

	build_time = infrastructure_build_time

	country_potential = {
		OR = {
			tag = BYZ
			tag = ROM

			owns = location:constantinople
			owns = location:rome
			owns = location:avignon
			owns = location:segovia
		}
	}

	location_potential = {
		OR = {
			this = location:constantinople
			this = location:rome
			this = location:avignon
			this = location:segovia
		}
	}

	possible_production_methods = { aqueduct_system_maintenance }

	construction_demand = aqueduct_system_construction

	modifier = {
		local_disease_resistance = 0.1
		local_monthly_food_modifier = 0.15
		local_monthly_prosperity = 0.001
		local_monthly_development_modifier = 0.1
	}

	capital_country_modifier = {
		monthly_legitimacy = 0.1
		monthly_republican_tradition = 0.1
		monthly_devotion = 0.1
	}
}

provincial_chancery = {
	audio_tier = 1
	is_foreign = no
	pop_type = burghers
	max_levels = chancery_max_level
	
	category = government_category
	
	employment_size = generic_burgher_employment
	
	town = yes
	city = yes
	megalopolis = yes
	
	expensive = yes
	build_time = generic_town_build_time


	country_potential = {
		has_reform = government_reform:provincial_consulates_reform
	}
	
	remove_if = {
		location.owner = {
			NOT = {
				has_reform = government_reform:provincial_consulates_reform
			}
		}
	}

	modifier = {
		local_burghers_max_literacy = 2.5
		local_nobles_max_literacy = 2.5
		local_pop_join_rebel_threshold = -0.05
	}
	
	
	possible_production_methods = { chancery_maintenance }

	
	construction_demand = town_building_construction
}