Debian Codegraph @

test-scripting/species/species_macros/stockpile.py

raw
1 from macros.base_prod import STOCKPILE_PER_POP
2 from macros.priorities import (
3 AFTER_ALL_TARGET_MAX_METERS_PRIORITY,
4 TARGET_EARLY_BEFORE_SCALING_PRIORITY,
5 )
6
7 try:
8 from focs._effects import (
9 Abs,
10 CurrentTurn,
11 EffectsGroup,
12 Focus,
13 HasSpecies,
14 Homeworld,
15 IsSource,
16 LocalCandidate,
17 MinOf,
18 OwnedBy,
19 Planet,
20 SetMaxStockpile,
21 SetStockpile,
22 Source,
23 Target,
24 TargetPopulation,
25 Value,
26 )
27 except ModuleNotFoundError:
28 pass
29
30
31 def STOCKPILE_PER_POP_EFFECTSGROUP__SNIP(label: str, value) -> dict:
32 return {
33 "scope": IsSource,
34 "activation": Planet(),
35 "accountinglabel": label + "_STOCKPILE_LABEL",
36 "priority": TARGET_EARLY_BEFORE_SCALING_PRIORITY,
37 "effects": SetMaxStockpile(value=value),
38 }
39
40
41 STANDARD_STOCKPILE = [
42 EffectsGroup( # increase or decrease towards target meter, when not recently conquered
43 scope=IsSource,
44 activation=Planet()
45 & (LocalCandidate.LastTurnConquered < CurrentTurn)
46 & (LocalCandidate.System.LastTurnBattleHere < CurrentTurn),
47 priority=AFTER_ALL_TARGET_MAX_METERS_PRIORITY,
48 effects=SetStockpile(
49 value=Value
50 + MinOf(float, Abs(float, Value(Target.MaxStockpile) - Value), 1)
51 * (1 - 2 * (Value > Value(Target.MaxStockpile)))
52 ),
53 ),
54 # increase stockpile for species if Homeworld is set to stockpile focus
55 EffectsGroup(
56 scope=Planet()
57 & OwnedBy(empire=Source.Owner)
58 & HasSpecies(name=[Source.Species])
59 & ~Homeworld(name=[Source.Species]),
60 activation=Planet() & Focus(type=["FOCUS_STOCKPILE"]) & Homeworld(),
61 stackinggroup="HOMEWORLD_STOCKPILE_FOCUS_BONUS_LABEL",
62 accountinglabel="HOMEWORLD_STOCKPILE_FOCUS_BONUS_LABEL",
63 effects=SetMaxStockpile(value=(Value + 2 * Target.Population * STOCKPILE_PER_POP)),
64 ),
65 # removes residual stockpile capacity from a dead planet
66 EffectsGroup(scope=IsSource, activation=Planet() & TargetPopulation(high=0), effects=SetStockpile(value=0)),
67 ]
68
69 # NO_STOCKPILE
70 # '''
71 # '''
72
73 # BAD_STOCKPILE
74 # '''[[STOCKPILE_PER_POP_EFFECTSGROUP(BAD,Value + 0.5 * Target.Population * [[STOCKPILE_PER_POP]])]]
75 # [[STANDARD_STOCKPILE]]
76 # '''
77
78
79 AVERAGE_STOCKPILE = [
80 EffectsGroup(
81 # Skip the AVERAGE_STOCKPILE_DESC, same as for the other *_STOCKPILE macros
82 **STOCKPILE_PER_POP_EFFECTSGROUP__SNIP("AVERAGE", Value + 1 * Target.Population * STOCKPILE_PER_POP)
83 ),
84 *STANDARD_STOCKPILE,
85 ]
86
87
88 # GOOD_STOCKPILE
89 # '''[[STOCKPILE_PER_POP_EFFECTSGROUP(GOOD,Value + 3 * Target.Population * [[STOCKPILE_PER_POP]])]]
90 # [[STANDARD_STOCKPILE]]
91 # '''
92
93 # GREAT_STOCKPILE
94 # '''[[STOCKPILE_PER_POP_EFFECTSGROUP(GREAT,Value + 10 * Target.Population * [[STOCKPILE_PER_POP]])]]
95 # [[STANDARD_STOCKPILE]]
96 # '''
97
98 # ULTIMATE_STOCKPILE
99 # '''[[STOCKPILE_PER_POP_EFFECTSGROUP(ULTIMATE, Value + 15 * Target.Population * [[STOCKPILE_PER_POP]])]]
100 # [[STANDARD_STOCKPILE]]
101 # '''
102
103 # STOCKPILE_PER_POP_EFFECTSGROUP
104 # ''' EffectsGroup
105 # description = "@1@_STOCKPILE_DESC"
106 # [[STOCKPILE_PER_POP_EFFECTSGROUP__SNIP(@1@,@2@)]]
107 # '''
108
109
110 # #include "../macros/base_prod.macros"
111 # #include "../macros/priorities.macros"