Debian Codegraph @

default/scripting/species/species_macros/planet_shields.py

raw
1 from focs._effects import (
2 CurrentTurn,
3 EffectsGroup,
4 Focus,
5 IsSource,
6 LocalCandidate,
7 MinOf,
8 Planet,
9 SetMaxShield,
10 SetShield,
11 Target,
12 Unowned,
13 Value,
14 )
15 from macros.misc import PLANET_SHIELD_FACTOR
16 from macros.priorities import (
17 AFTER_ALL_TARGET_MAX_METERS_PRIORITY,
18 TARGET_AFTER_2ND_SCALING_PRIORITY,
19 )
20
21
22 def _native_planetary_shields(strength: float):
23 return EffectsGroup(
24 scope=IsSource,
25 activation=Planet() & Unowned,
26 accountinglabel="NATIVE_PLANETARY_SHIELDS_LABEL",
27 effects=(SetMaxShield(value=Value + strength)),
28 )
29
30
31 AVERAGE_PLANETARY_SHIELDS = [
32 EffectsGroup(
33 scope=IsSource,
34 activation=Planet() & Focus(type=["FOCUS_PROTECTION"]),
35 stackinggroup="FOCUS_PROTECTION_SHIELDS_STACK",
36 accountinglabel="FOCUS_PROTECTION_LABEL",
37 priority=TARGET_AFTER_2ND_SCALING_PRIORITY,
38 effects=SetMaxShield(value=Value * 2),
39 ),
40 EffectsGroup( # increase 1 per turn, up to max
41 scope=IsSource,
42 activation=Planet()
43 & Unowned
44 & (LocalCandidate.LastTurnConquered < CurrentTurn)
45 & (LocalCandidate.LastTurnAttackedByShip < CurrentTurn),
46 accountinglabel="DEF_ROOT_DEFENSE",
47 priority=AFTER_ALL_TARGET_MAX_METERS_PRIORITY,
48 effects=SetShield(value=MinOf(float, Value(Target.MaxShield), Value + PLANET_SHIELD_FACTOR)),
49 ),
50 ]