BuildingType
    name = "BLD_MILITARY_COMMAND"
    description = "BLD_MILITARY_COMMAND_DESC"
    captureresult = Destroy
    buildcost = 60 * [[BUILDING_COST_MULTIPLIER]]
    buildtime = 5
    location = And [
        Planet
        OwnedBy empire = Source.Owner
        Not Contains Building name = "BLD_MILITARY_COMMAND"
        TargetPopulation low = 1
        Number low = 0 high = 0 condition = And [
            Building name = "BLD_MILITARY_COMMAND"
            OwnedBy empire = Source.Owner
        ]
    ]
    enqueuelocation = [[ENQUEUE_BUILD_ONE_PER_PLANET]]
    effectsgroups = [
        [[SPECIES_LIKES_OR_DISLIKES_BUILDING_STABILITY_EFFECTS]]
    
        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
                Capital
            ]
            activation = ContainedBy And [
                Object id = Source.PlanetID
                OwnedBy empire = Source.Owner
            ]
            stackinggroup = "MILITARY_COMMAND_SLOT_METER_EFFECT1"
            effects = SetEmpireMeter empire = Source.Owner meter = "MILITARY_CATEGORY_NUM_POLICY_SLOTS" value = Value + 1

        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
                Capital                
            ]
            activation = (5 <= SpeciesShipsDestroyed empire = Source.Owner)
            stackinggroup = "MILITARY_COMMAND_SLOT_METER_EFFECT2"
            effects =
                SetEmpireMeter empire = Source.Owner meter = "MILITARY_CATEGORY_NUM_POLICY_SLOTS" value = Value + 1

        EffectsGroup
            scope = And [
                Object id = Source.PlanetID
                Planet
                OwnedBy empire = Source.ProducedByEmpireID
            ]
            accountinglabel = "BLD_MILITARY_COMMAND"
            priority = [[TARGET_EARLY_BEFORE_SCALING_PRIORITY]]
            effects = [
                SetMaxDefense value = Value + 5 * [[PLANET_DEFENSE_FACTOR]]
                SetMaxTroops value = Value + 6
            ]
    ]
    icon = "icons/building/palace.png"

#include "/scripting/macros/enqueue.macros"
#include "/scripting/macros/priorities.macros"
#include "/scripting/macros/base_prod.macros"
#include "/scripting/buildings/buildings.macros"
#include "/scripting/macros/misc.macros"
