from focs._effects import ( Abs, CurrentTurn, EffectsGroup, Focus, IsSource, LocalCandidate, MaxOf, MinOf, Planet, Population, SetConstruction, SetIndustry, SetInfluence, SetResearch, SetStockpile, SetTargetConstruction, SetTargetIndustry, SetTargetInfluence, SetTargetResearch, Ship, Target, TargetPopulation, Value, ) from macros.misc import DESCRIPTION_EFFECTSGROUP_MACRO from macros.priorities import ( AFTER_ALL_TARGET_MAX_METERS_PRIORITY, END_CLEANUP_PRIORITY, FOCUS_CHANGE_PENALTY_PRIORITY, LATE_AFTER_ALL_TARGET_MAX_METERS_PRIORITY, ) STANDARD_METER_GROWTH = [ # increase or decrease towards target meter of planets, when not recently conquered EffectsGroup( scope=IsSource, activation=Planet() & (LocalCandidate.LastTurnConquered < CurrentTurn), priority=AFTER_ALL_TARGET_MAX_METERS_PRIORITY, effects=[ SetResearch( value=Value + MinOf( float, 1.0, # increase by (at most) 1 / turn up towards target MaxOf(float, 0.0, Value(Target.Happiness)) / 5.0, # limit rate of increase, dependent on Stability MaxOf( float, MinOf( float, -1.0, # decrease by 1 / turn down towards target, or: (Value(Target.TargetResearch) - Value) / 5.0, # when (target>=value), this is larger than -1.0. when (target<=value), this is larger than -1.0. when (target<