BuildingType
    name = "BLD_CONC_CAMP"
    description = "BLD_CONC_CAMP_DESC"
    buildcost = 5 * [[BUILDING_COST_MULTIPLIER]]
    buildtime = 1
    location = And [
        Planet
        OwnedBy empire = Source.Owner
        Not Contains Building name = "BLD_CONC_CAMP"
        EmpireHasAdoptedPolicy empire = Source.Owner name = "PLC_RACIAL_PURITY"
        Population low = 3
    ]
    enqueuelocation = [[ENQUEUE_BUILD_ONE_PER_PLANET]]
    effectsgroups = [
        [[SPECIES_LIKES_OR_DISLIKES_BUILDING_STABILITY_EFFECTS]]
    
        EffectsGroup
            scope = And [
                Object id = Source.PlanetID
                Planet
            ]
            activation = ContainedBy And [
                Object id = Source.PlanetID
                Planet
                OwnedBy empire = Source.Owner
            ]
            priority = [[TARGET_AFTER_SCALING_PRIORITY]]
            effects = SetTargetIndustry value = Value + Target.Population
                        * (NamedReal name = "BLD_CONC_CAMP_TARGET_INDUSTRY_PERPOP"
                                     value = 3.75 * [[INDUSTRY_PER_POP]])

        EffectsGroup
            scope = And [
                Object id = Source.PlanetID
                Planet
            ]
            activation = Or [
                Not EmpireHasAdoptedPolicy empire = Source.Owner name = "PLC_RACIAL_PURITY"
                ContainedBy And [
                    Object id = Source.PlanetID
                    OwnedBy empire = Source.Owner
                    Population low = 0.0001
                    Not HasSpecial name = "CONC_CAMP_MASTER_SPECIAL"
                ]
            ]
            effects = AddSpecial name = "CONC_CAMP_MASTER_SPECIAL"

        EffectsGroup
            scope = Source
            activation = ContainedBy And [
                Object id = Source.PlanetID
                Population high = 0
            ]
            effects = [
                Destroy
                GenerateSitRepMessage
                    message = "EFFECT_CONC_CAMP_COMLETE"
                    label = "EFFECT_CONC_CAMP_COMLETE_LABEL"
                    icon = "icons/building/concentration-camp.png"
                    parameters = tag = "planet" data = Source.PlanetID
                    empire = Source.Owner
            ]

        EffectsGroup
            scope = And [
                Object id = Source.PlanetID
                Planet
            ]
            activation = ContainedBy And [
                Object id = Source.PlanetID
                OwnedBy empire = Source.Owner
                HasSpecial name = "CONC_CAMP_MASTER_SPECIAL"
            ]
            priority = [[CONCENTRATION_CAMP_PRIORITY]]
            effects = [
                SetSpeciesOpinion
                    species = Target.Species
                    empire = Source.Owner
                    opinion = Value - (NamedReal name = "BLD_CONC_CAMP_TARGET_SPECIES_OPINION_PENALTY" value = 3.0)

                SetPopulation value = min(Value, Target.Population + (NamedReal name = "BLD_CONC_CAMP_POPULATION_FLAT" value = -3))
                SetIndustry value = Target.TargetIndustry
            ]

        EffectsGroup
            scope = Source
            activation = Or [
                Not EmpireHasAdoptedPolicy empire = Source.Owner name = "PLC_RACIAL_PURITY"
                Not ProducedByEmpire empire = Source.Owner
            ]
            effects = Destroy
    ]
    icon = "icons/building/concentration-camp.png"

#include "/scripting/common/*.macros"
#include "/scripting/buildings/buildings.macros"
#include "/scripting/common/priorities.macros"
