﻿namespace = ppr_building_events

# Pilgrims and Preachers - camp building maintenance
# 0001 - Remove Pilgrims-only camp buildings the camp may no longer have.
#        Fired (delayed) from ppr_camp_purpose_pilgrims on_revoke, and from the
#        quarterly safety net in common/on_action/ppr_building_on_actions.txt.
#        Pattern of vanilla ep3_laamps.1021.

ppr_building_events.0001 = {
	hidden = yes

	trigger = {
		exists = domicile
	}

	immediate = {
		if = {
			limit = {
				domicile = {
					OR = {
						has_domicile_building = ppr_baggage_train_reliquary
						has_domicile_construction = ppr_baggage_train_reliquary
					}
				}
				OR = {
					NOT = { has_realm_law_flag = ppr_unlocks_baggage_train_reliquary }
					domicile = {
						NOT = { has_domicile_building_or_higher = baggage_train_01 }
					}
				}
			}
			domicile = { remove_domicile_building = ppr_baggage_train_reliquary }
		}
		if = {
			limit = {
				domicile = {
					OR = {
						has_domicile_building = ppr_barber_tent_hospice
						has_domicile_construction = ppr_barber_tent_hospice
					}
				}
				OR = {
					NOT = { has_realm_law_flag = ppr_unlocks_barber_tent_hospice }
					domicile = {
						NOT = { has_domicile_building_or_higher = barber_tent_01 }
					}
				}
			}
			domicile = { remove_domicile_building = ppr_barber_tent_hospice }
		}
		if = {
			limit = {
				domicile = {
					OR = {
						has_domicile_building = ppr_camp_fire_vespers
						has_domicile_construction = ppr_camp_fire_vespers
					}
				}
				OR = {
					NOT = { has_realm_law_flag = ppr_unlocks_camp_fire_vespers }
					domicile = {
						NOT = { has_domicile_building_or_higher = camp_fire_01 }
					}
				}
			}
			domicile = { remove_domicile_building = ppr_camp_fire_vespers }
		}
		if = {
			limit = {
				domicile = {
					OR = {
						has_domicile_building = ppr_supply_tent_alms_chest
						has_domicile_construction = ppr_supply_tent_alms_chest
					}
				}
				OR = {
					NOT = { has_realm_law_flag = ppr_unlocks_supply_tent_alms_chest }
					domicile = {
						NOT = { has_domicile_building_or_higher = supply_tent_01 }
					}
				}
			}
			domicile = { remove_domicile_building = ppr_supply_tent_alms_chest }
		}
		if = {
			limit = {
				domicile = {
					OR = {
						has_domicile_building = ppr_camp_perimeter_palmers_watch
						has_domicile_construction = ppr_camp_perimeter_palmers_watch
					}
				}
				OR = {
					NOT = { has_realm_law_flag = ppr_unlocks_camp_perimeter_palmers_watch }
					domicile = {
						NOT = { has_domicile_building_or_higher = camp_perimeter_01 }
					}
				}
			}
			domicile = { remove_domicile_building = ppr_camp_perimeter_palmers_watch }
		}
	}
}
