// sets stability (happiness) on planets in empire that has adopted the policy this macro effect is added to, if those planets' species like or dislike the policy

STABILITY_PER_LIKED_POLICY
'''2.0'''

// Policy Liberty doubles the dislike effect, policy Conformance halves it, macro is in macros/opinion.macros
STABILITY_PER_DISLIKED_POLICY
'''2.0 * [[POLICY_DISLIKE_SCALING]]'''

// Species like empires more or less and are more or less stable on planets for each liked or disliked policy it adopts
SPECIES_LIKES_OR_DISLIKES_POLICY_STABILITY_EFFECTS
'''
        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
                Population low = 0.001
                SpeciesLikes name = ThisPolicy
            ]
            accountinglabel = "LIKES_POLICY_LABEL"
            effects =
                SetTargetHappiness value = Value + [[STABILITY_PER_LIKED_POLICY]]

        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
                Population low = 0.001
                SpeciesDislikes name = ThisPolicy
            ]
            accountinglabel = "DISLIKES_POLICY_LABEL"
            effects =
                SetTargetHappiness value = Value - [[STABILITY_PER_DISLIKED_POLICY]]

        EffectsGroup
            scope =
                Unique      // pick one object per species
                    sortkey = LocalCandidate.Species
                    condition = And [
                        Or [
                            Planet
                            Ship
                        ]
                        SpeciesLikes name = ThisPolicy
                    ]
            effects = [
                SetSpeciesTargetOpinion
                    species = Target.Species
                    empire = Source.Owner
                    opinion = Value + [[STABILITY_PER_LIKED_POLICY]]
            ]

        EffectsGroup
            scope =
                Unique
                    sortkey = LocalCandidate.Species
                    condition = And [
                        Or [
                            Planet
                            Ship
                        ]
                        SpeciesDislikes name = ThisPolicy
                    ]
            effects =
                SetSpeciesTargetOpinion
                    species = Target.Species
                    empire = Source.Owner
                    opinion = Value - [[STABILITY_PER_DISLIKED_POLICY]]
'''

// A particular species (@1@) likes an empire (@2@) by @3@ more in ref named @4@
ONE_SPECIES_EMIPRE_OPINION_ADJUST
'''
        EffectsGroup
            scope =
                NumberOf
                    number = 1
                    condition = Species name = @1@
            effects =
                SetSpeciesTargetOpinion
                    species = @1@
                    empire = @2@
                    opinion = Value + (NamedReal name = "@4@" value = @3@)
'''

// Species other than (@1@) likes an empire (@2@) by (@3@) more in ref named @4@
OTHER_SPECIES_EMIPRE_OPINION_ADJUST
'''
        EffectsGroup
            scope =
                Unique
                    sortkey = LocalCandidate.Species
                    condition = Not Species name = @1@
            effects =
                SetSpeciesTargetOpinion
                    species = Target.Species
                    empire = @2@
                    opinion = Value + (NamedReal name = "@4@" value = @3@)
'''

POPULATION_OWNED_BY_EMPIRE
'''(Statistic Sum value = LocalCandidate.Population condition = And [ Planet OwnedBy empire = Source.Owner ])'''

PLANETS_OWNED_BY_EMPIRE
'''(Statistic Count condition = And [ Planet Species OwnedBy empire = Source.Owner ])'''

SHIPS_OWNED_BY_EMPIRE
'''(Statistic Count condition = And [Ship OwnedBy empire = Source.Owner])'''

#include "/scripting/macros/opinion.macros"
