Starsector API
Loading...
Searching...
No Matches
BlockadeFGI.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.group;
2
3import java.awt.Color;
4import java.util.List;
5
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.campaign.FactionAPI;
8import com.fs.starfarer.api.campaign.StarSystemAPI;
9import com.fs.starfarer.api.campaign.econ.MarketAPI;
10import com.fs.starfarer.api.impl.campaign.ids.Conditions;
11import com.fs.starfarer.api.impl.campaign.intel.group.FGBlockadeAction.FGBlockadeParams;
12import com.fs.starfarer.api.ui.Alignment;
13import com.fs.starfarer.api.ui.LabelAPI;
14import com.fs.starfarer.api.ui.TooltipMakerAPI;
15import com.fs.starfarer.api.util.IntervalUtil;
16import com.fs.starfarer.api.util.Misc;
17
18public class BlockadeFGI extends GenericRaidFGI {
19
20 protected FGBlockadeParams blockadeParams;
21 protected IntervalUtil interval = new IntervalUtil(0.1f, 0.3f);
22
23 public BlockadeFGI(GenericRaidParams params, FGBlockadeParams blockadeParams) {
24 super(null);
25 if (params.noun == null) {
26 params.noun = "blockade";
27 }
28 if (params.forcesNoun == null) {
29 params.forcesNoun = "blockading forces";
30 }
31
32
33 this.params = params;
34 this.blockadeParams = blockadeParams;
35 setRandom(params.random);
36
38 }
39
40 protected GenericPayloadAction createPayloadAction() {
41 return new FGBlockadeAction(blockadeParams, params.payloadDays);
42 }
43
44 public float getAccessibilityPenalty() {
46 if (str < 0) {
47 return 0f;
48 } else if (str == 0) {
49 return blockadeParams.accessibilityPenalty * 0.5f;
50 } else {
51 return blockadeParams.accessibilityPenalty;
52 }
53 }
54
55
56 public void advance(float amount) {
57 super.advance(amount);
58
59 if (isEnded() || isEnding() || isAborted() || isSpawning()) return;
60
61 float days = Misc.getDays(amount);
62 interval.advance(days);
63 if (interval.intervalElapsed()) {
64
67 } else {
69 }
70
72 }
73 }
74
75 protected void periodicUpdate() {
76
77 }
78
79 protected void applyBlockadeCondition() {
81 if (str < 0) {
83 return;
84 }
85
86 for (MarketAPI market : Misc.getMarketsInLocation(getTargetSystem(), blockadeParams.targetFaction)) {
87 if (!market.hasCondition(Conditions.BLOCKADED)) {
88 market.addCondition(Conditions.BLOCKADED, this);
89 }
90 }
91 }
92
93 protected void unapplyBlockadeCondition() {
94 for (MarketAPI market : Misc.getMarketsInLocation(getTargetSystem(), blockadeParams.targetFaction)) {
95 market.removeCondition(Conditions.BLOCKADED);
96 }
97 }
98
99
100 @Override
101 protected void notifyEnding() {
102 super.notifyEnding();
103
105 }
106
107 @Override
108 protected void addBasicDescription(TooltipMakerAPI info, float width, float height, float opad) {
109 info.addImage(getFaction().getLogo(), width, 128, opad);
110
111 StarSystemAPI system = raidAction.getWhere();
112
113 String noun = getNoun();
114
115 info.addPara(Misc.ucFirst(faction.getPersonNamePrefixAOrAn()) + " %s " + noun + " " + getOfString() + " "
116 + "the " + system.getNameWithLowercaseTypeShort() + ".", opad,
117 faction.getBaseUIColor(), faction.getPersonNamePrefix());
118 }
119
120 protected String getOfString() {
121 return "of";
122 }
123
124 protected void addAssessmentSection(TooltipMakerAPI info, float width, float height, float opad) {
125 Color h = Misc.getHighlightColor();
126 Color bad = Misc.getNegativeHighlightColor();
127
128 FactionAPI faction = getFaction();
129
130 List<MarketAPI> targets = params.raidParams.allowedTargets;
131
132 String noun = getNoun();
133 String forcesNoun = getForcesNoun();
134 if (!isEnding() && !isSucceeded() && !isFailed()) {
135
136 FactionAPI other = Global.getSector().getFaction(blockadeParams.targetFaction);
137 boolean hostile = getFaction().isHostileTo(blockadeParams.targetFaction);
138
139 info.addSectionHeading("Assessment",
140 faction.getBaseUIColor(), faction.getDarkUIColor(), Alignment.MID, opad);
141
142 boolean started = isCurrent(PAYLOAD_ACTION);
143 float remaining = getETAUntil(PAYLOAD_ACTION, true) - getETAUntil(TRAVEL_ACTION, true);
144 if (remaining > 0 && remaining < 1) remaining = 1;
145 String days = (int)remaining == 1 ? "day" : "days";
146
147 if (started) days = "more " + days;
148
149 LabelAPI label = info.addPara("The " + noun + " will last for approximately %s " + days
150 + ", causing a %s accessibility penalty "
151 + "for all %s colonies in the " +
152 getTargetSystem().getNameWithLowercaseTypeShort() + ".", opad, h,
153 "" + (int) remaining,
154 "" + (int) Math.round(blockadeParams.accessibilityPenalty * 100f) + "%",
155 other.getPersonNamePrefix());
156 label.setHighlight("" + (int) remaining,
157 "" + (int) Math.round(blockadeParams.accessibilityPenalty * 100f) + "%",
158 other.getPersonNamePrefix());
159 label.setHighlightColors(h, h, other.getBaseUIColor());
160
161 if (!hostile) {
162 info.addPara("The " + forcesNoun + " are not nominally hostile, but will harass shipping and "
163 + "attempt to maintain control over the system's jump-points.", opad,
164 Misc.getHighlightColor(), "not nominally hostile");
165 } else {
166 info.addPara("The " + forcesNoun + " are actively hostile, but will not directly attack colonies "
167 + "in the system and will instead "
168 + "attempt to maintain control over the system's jump-points. If a defended planet "
169 + "happens to be near a jump-point, however, the situation is apt to get hot very quickly.",
170 opad, Misc.getNegativeHighlightColor(), "actively hostile");
171 }
172
173 addStrengthDesc(info, opad, getTargetSystem(), forcesNoun,
174 "the " + noun + " is unlikely to be effective",
175 "the " + noun + " is likely to only be partially effective",
176 "the " + noun + " is likely to be fully effective");
177
178 addPostAssessmentSection(info, width, height, opad);
179 }
180 }
181
182 protected void addPostAssessmentSection(TooltipMakerAPI info, float width, float height, float opad) {
183
184 }
185
186 public FGBlockadeParams getBlockadeParams() {
187 return blockadeParams;
188 }
189
190}
191
192
193
194
195
196
197
198
199
static SectorAPI getSector()
Definition Global.java:59
void addPostAssessmentSection(TooltipMakerAPI info, float width, float height, float opad)
void addAssessmentSection(TooltipMakerAPI info, float width, float height, float opad)
void addBasicDescription(TooltipMakerAPI info, float width, float height, float opad)
BlockadeFGI(GenericRaidParams params, FGBlockadeParams blockadeParams)
boolean addStrengthDesc(TooltipMakerAPI info, float opad, StarSystemAPI system, String forces, String outcomeFailure, String outcomeUncertain, String outcomeSuccess)