Debian Codegraph @

test-scripting/species/species_macros/planet_defense.py

raw
1 # // param1: value
2 # NATIVE_PLANETARY_DEFENSE
3 # '''EffectsGroup
4 # scope = Source
5 # activation = And [
6 # Planet
7 # Unowned
8 # ]
9 # accountinglabel = "NATIVE_PLANETARY_DEFENSE_LABEL"
10 # effects = SetMaxDefense value = Value + ( @1@ )
11 # '''
12
13 from macros.misc import PLANET_DEFENSE_FACTOR
14 from macros.priorities import (
15 AFTER_ALL_TARGET_MAX_METERS_PRIORITY,
16 TARGET_AFTER_2ND_SCALING_PRIORITY,
17 )
18
19 try:
20 from focs._effects import (
21 CurrentTurn,
22 EffectsGroup,
23 Focus,
24 GameRule,
25 IsSource,
26 LocalCandidate,
27 MinOf,
28 NamedReal,
29 Planet,
30 SetDefense,
31 SetMaxDefense,
32 SetTargetHappiness,
33 Target,
34 Unowned,
35 Value,
36 )
37 except ModuleNotFoundError:
38 pass
39
40
41 STANDARD_DEFENSE_GROWTH = EffectsGroup( # increase 1 per turn, up to max
42 scope=IsSource,
43 activation=Planet() & Unowned & (LocalCandidate.LastTurnAttackedByShip < CurrentTurn),
44 accountinglabel="DEF_ROOT_DEFENSE",
45 priority=AFTER_ALL_TARGET_MAX_METERS_PRIORITY,
46 effects=SetDefense(value=MinOf(float, Value(Target.MaxDefense), Value + PLANET_DEFENSE_FACTOR)),
47 )
48
49
50 PROTECTION_FOCUS_DEFENSE = EffectsGroup(
51 scope=IsSource,
52 activation=Planet() & Focus(type=["FOCUS_PROTECTION"]),
53 stackinggroup="FOCUS_PROTECTION_DEFENSE_STACK",
54 accountinglabel="FOCUS_PROTECTION_LABEL",
55 priority=TARGET_AFTER_2ND_SCALING_PRIORITY,
56 effects=[
57 SetMaxDefense(value=Value * 2),
58 SetTargetHappiness(
59 value=Value
60 + NamedReal(
61 name="PROTECION_FOCUS_STABILITY_BONUS",
62 value=GameRule(type=float, name="RULE_PROTECTION_FOCUS_STABILITY"),
63 )
64 ),
65 ],
66 )
67
68
69 AVERAGE_PLANETARY_DEFENSE = [
70 PROTECTION_FOCUS_DEFENSE,
71 STANDARD_DEFENSE_GROWTH,
72 ]
73
74
75 # #include "../macros/priorities.macros"