Starsector API
Loading...
Searching...
No Matches
AFavorForKanta.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.missions;
2
3import java.awt.Color;
4import java.util.Map;
5
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.campaign.CargoAPI;
8import com.fs.starfarer.api.campaign.InteractionDialogAPI;
9import com.fs.starfarer.api.campaign.econ.Industry;
10import com.fs.starfarer.api.campaign.econ.MarketAPI;
11import com.fs.starfarer.api.campaign.listeners.ColonyPlayerHostileActListener;
12import com.fs.starfarer.api.campaign.rules.MemoryAPI;
13import com.fs.starfarer.api.characters.PersonAPI;
14import com.fs.starfarer.api.impl.campaign.ids.Factions;
15import com.fs.starfarer.api.impl.campaign.ids.People;
16import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithSearch;
17import com.fs.starfarer.api.impl.campaign.rulecmd.KantaCMD;
18import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.TempData;
19import com.fs.starfarer.api.ui.TooltipMakerAPI;
20import com.fs.starfarer.api.util.Misc;
21
22public class AFavorForKanta extends HubMissionWithSearch implements ColonyPlayerHostileActListener {
23
24 public static float MISSION_DAYS = 365f;
25
26 public static enum Stage {
27 BOMBARD,
28 COMPLETED,
29 FAILED,
30 FAILED_NO_PENALTY,
31 }
32
33 protected MarketAPI market;
34
35 @Override
36 protected boolean create(MarketAPI createdAt, boolean barEvent) {
37 //genRandom = Misc.random;
38
39 PersonAPI person = People.getPerson(People.KANTA);
40 if (person == null) return false;
41
42 MarketAPI kantasDen = person.getMarket();
43
44 setPersonOverride(person);
45
46 setStoryMission();
47 setNoAbandon();
48
49 if (!setGlobalReference("$affk_ref", "$affk_inProgress")) {
50 return false;
51 }
52
53 String commission = Misc.getCommissionFactionId();
54
55 if (kantasDen != null) {
56 requireMarketIsNot(kantasDen);
57 }
58 requireMarketFactionNotPlayer();
59 requireMarketFactionNot(Factions.PIRATES);
60 requireMarketIsMilitary();
61 requireMarketTacticallyBombardable();
62 requireMarketNotHidden();
63 requireMarketNotInHyperspace();
64
65 if (commission != null) {
66 preferMarketFactionNot(commission);
67 }
68 preferMarketFactionNotHostileTo(Factions.PLAYER);
69
70 market = pickMarket();
71 if (market == null) return false;
72
73 makeImportant(market, "$affk_target", Stage.BOMBARD);
74
75 setStartingStage(Stage.BOMBARD);
76 setSuccessStage(Stage.COMPLETED);
77 setFailureStage(Stage.FAILED);
78
79 setStageOnMemoryFlag(Stage.COMPLETED, market, "$affk_completed");
80 setTimeLimit(Stage.FAILED, MISSION_DAYS, null);
81 //setTimeLimit(Stage.FAILED, 0.5f, null);
82
83 // handled in endFailure calling KantaCMD.loseProtection()
84 setRepPenaltyFaction(0f);
85 setRepPenaltyPerson(0f);
86
87 addNoPenaltyFailureStages(Stage.FAILED_NO_PENALTY);
88 connectWithMarketDecivilized(Stage.BOMBARD, Stage.FAILED_NO_PENALTY, market);
89 setStageOnMarketDecivilized(Stage.FAILED_NO_PENALTY, market);
90
91
92 triggerCreateLargePatrolAroundMarket(market, Stage.BOMBARD, 0f);
93 triggerCreateLargePatrolAroundMarket(market, Stage.BOMBARD, 0f);
94 triggerCreateMediumPatrolAroundMarket(market, Stage.BOMBARD, 0f);
95 triggerCreateSmallPatrolAroundMarket(market, Stage.BOMBARD, 0f);
96
97 return true;
98 }
99
100 @Override
101 protected void endAbandonImpl() {
102 super.endAbandonImpl();
103 endFailureImpl(null, null);
104 }
105
106 @Override
107 protected void endFailureImpl(InteractionDialogAPI dialog, Map<String, MemoryAPI> memoryMap) {
108 if (currentStage == Stage.FAILED) {
109 KantaCMD.loseProtection(dialog);
110 }
111 }
112
113
114
115 protected void updateInteractionDataImpl() {
116 set("$affk_systemName", market.getStarSystem().getNameWithLowercaseTypeShort());
117 set("$affk_marketName", market.getName());
118 set("$affk_marketOnOrAt", market.getOnOrAt());
119 }
120
121 @Override
122 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) {
123 float opad = 10f;
124 Color h = Misc.getHighlightColor();
125 if (currentStage == Stage.BOMBARD) {
126 addStandardMarketDesc("Perform a tactical bombardment of", market, info, opad);
127 addBombardmentInfo(market, info, opad);
128 } else if (currentStage == Stage.FAILED) {
129 //info.addPara("Kanta's Protection lost", Misc.getNegativeHighlightColor(), opad);
130 info.addPara("Kanta's Protection lost", opad);
131 }
132 }
133
134 @Override
135 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) {
136 Color h = Misc.getHighlightColor();
137 if (currentStage == Stage.BOMBARD) {
138 info.addPara("Tactically bombard " + market.getName() +
139 " in the " + market.getStarSystem().getNameWithLowercaseTypeShort(), tc, pad);
140 return true;
141 }
142// else if (currentStage == Stage.FAILED) {
143// //info.addPara("Kanta's Protection lost", Misc.getNegativeHighlightColor(), opad);
144// info.addPara("You have failed this mission and lost Kanta's protection.", pad);
145// return true;
146// } else if (currentStage == Stage.FAILED_NO_PENALTY) {
147// info.addPara("You have failed this mission through no fault of your own, and retain Kanta's protection.", pad);
148// return true;
149// }
150 return false;
151 }
152
153 protected String getMissionTypeNoun() {
154 return "task";
155 }
156
157 @Override
158 public String getBaseName() {
159 //return "Bombard " + market.getName();
160 return "A Favor for Kanta";
161 }
162
163
164 @Override
165 public void acceptImpl(InteractionDialogAPI dialog, Map<String, MemoryAPI> memoryMap) {
166 super.acceptImpl(dialog, memoryMap);
167 Global.getSector().getListenerManager().addListener(this);
168 }
169
170 @Override
171 protected void notifyEnding() {
172 super.notifyEnding();
173 Global.getSector().getListenerManager().removeListener(this);
174 }
175
176 public void reportRaidToDisruptFinished(InteractionDialogAPI dialog,
177 MarketAPI market, TempData actionData, Industry industry) {
178 // TODO Auto-generated method stub
179 }
180
181
182
183 public void reportRaidForValuablesFinishedBeforeCargoShown(InteractionDialogAPI dialog,
184 MarketAPI market, TempData actionData,
185 CargoAPI cargo) {
186 // TODO Auto-generated method stub
187 }
188
189
191 InteractionDialogAPI dialog, MarketAPI market, TempData actionData) {
192 // TODO Auto-generated method stub
193
194 }
195
196 public void reportTacticalBombardmentFinished(InteractionDialogAPI dialog,
197 MarketAPI market, TempData actionData) {
198 if (this.market == market) {
199 Global.getSector().getListenerManager().removeListener(this);
200 // need to set non-zero expiration since bombardment code advances the market with 0/very small elapsed time
201 // a few times, so if set to 0 the value would be removed from memory
202 market.getMemoryWithoutUpdate().set("$affk_bombardedColony", true, 1f);
203 }
204 }
205
206}
207
208
209
210
211
static SectorAPI getSector()
Definition Global.java:59
void reportSaturationBombardmentFinished(InteractionDialogAPI dialog, MarketAPI market, TempData actionData)
void reportTacticalBombardmentFinished(InteractionDialogAPI dialog, MarketAPI market, TempData actionData)
void endFailureImpl(InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap)
void reportRaidToDisruptFinished(InteractionDialogAPI dialog, MarketAPI market, TempData actionData, Industry industry)
void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height)
boolean create(MarketAPI createdAt, boolean barEvent)
void acceptImpl(InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap)
boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad)
void reportRaidForValuablesFinishedBeforeCargoShown(InteractionDialogAPI dialog, MarketAPI market, TempData actionData, CargoAPI cargo)