Policy
    name = "PLC_ISOLATION"
    description = "PLC_ISOLATION_DESC"
    short_description = "PLC_ISOLATION_SHORT_DESC"
    category = "SOCIAL_CATEGORY"
    adoptioncost = floor(5.0 * [[PLANETS_OWNED_BY_EMPIRE]]^0.5)
    exclusions = [ "PLC_BOOTSTRAPPING" "PLC_CENTRALIZATION" "PLC_COLONIALISM" "PLC_EXPLORATION" "PLC_FEUDALISM" "PLC_VASSALIZATION" ]
    effectsgroups = [
        [[SPECIES_LIKES_OR_DISLIKES_POLICY_STABILITY_EFFECTS]]

        // apply stability bonus dependent on distance to other known populated planets. Above the threshold distance, a bonus is given. Closer than that, a penalty is applied.
        EffectsGroup
            scope = And [
                Planet
                Species
                OwnedBy empire = Source.Owner
            ]
            activation = Number low = 2 condition = And [
                Planet
                Species
                VisibleToEmpire empire = Source.Owner
            ]
            effects =
                SetTargetHappiness value = Value + min(
                    10.0, 
                    (Statistic Min
                        value = DirectDistanceBetween object = Target.SystemID object = LocalCandidate.SystemID
                        condition = And [
                            Planet
                            Species
                            VisibleToEmpire empire = Source.Owner
                            Not Target
                        ]
                    ) / (NamedReal name = "PLC_ISOLATION_THRESHOLD_DISTANCE" value = 150.0) * 10.0 - 10.0)

        // fallback for case when only a single populated planet is known to an empire...
        EffectsGroup
            scope = And [
                Planet
                Species
                OwnedBy empire = Source.Owner
            ]
            activation = Number high = 1 condition = And [
                Planet
                Species
                VisibleToEmpire empire = Source.Owner
            ]
            effects = SetTargetHappiness value = Value + 10.0
        
        // stealth boost
        EffectsGroup
            scope = And [
                Planet
                Species
                OwnedBy empire = Source.Owner
            ]
            effects = SetStealth value = Value + (NamedReal name = "PLC_ISOLATION_STEALTH" value = 5.0)
    ]
    graphic = "icons/policies/social_isolation.png"

#include "/scripting/policies/policies.macros"
