Starsector API
Loading...
Searching...
No Matches
TriTachLoanBarEvent.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.bar.events;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.campaign.CargoAPI;
7import com.fs.starfarer.api.campaign.OptionPanelAPI;
8import com.fs.starfarer.api.campaign.PersonImportance;
9import com.fs.starfarer.api.campaign.RepLevel;
10import com.fs.starfarer.api.campaign.TextPanelAPI;
11import com.fs.starfarer.api.campaign.econ.MarketAPI;
12import com.fs.starfarer.api.characters.PersonAPI;
13import com.fs.starfarer.api.impl.campaign.ids.Factions;
14import com.fs.starfarer.api.impl.campaign.ids.Ranks;
15import com.fs.starfarer.api.impl.campaign.ids.Sounds;
16import com.fs.starfarer.api.impl.campaign.ids.Tags;
17import com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity;
18import com.fs.starfarer.api.impl.campaign.rulecmd.SetStoryOption;
19import com.fs.starfarer.api.impl.campaign.rulecmd.SetStoryOption.BaseOptionStoryPointActionDelegate;
20import com.fs.starfarer.api.impl.campaign.rulecmd.SetStoryOption.StoryOptionParams;
21import com.fs.starfarer.api.ui.TooltipMakerAPI;
22import com.fs.starfarer.api.util.Misc;
23
25
26 public static int REPAYMENT_DAYS = 400;
27
29 super();
30 }
31
32 public boolean shouldShowAtMarket(MarketAPI market) {
33 if (!super.shouldShowAtMarket(market)) return false;
34
35 if (!market.getFactionId().equals(Factions.TRITACHYON)) {
36 return false;
37 }
38
39 if (market.getStabilityValue() < 4) return false;
40
41 if (Global.getSector().getFaction(Factions.TRITACHYON).getRelToPlayer().isAtBest(RepLevel.HOSTILE)) {
42 return false;
43 }
44
45 return true;
46 }
47
48 protected int loanAmount;
49 protected int repaymentAmount;
50 protected int repaymentDays;
51 //protected boolean negotiated = false;
52
53 @Override
54 protected void regen(MarketAPI market) {
55 if (this.market == market) return;
56
57 super.regen(market);
58
59 loanAmount = 200000 + random.nextInt(6) * 10000;
60 repaymentAmount = (int) (loanAmount * 1.5f);
61 //repaymentDays = 365;
63 }
64
65 @Override
66 protected void doStandardConfirmActions() {
67 CargoAPI cargo = Global.getSector().getPlayerFleet().getCargo();
68 cargo.getCredits().add(loanAmount);
69
70 TextPanelAPI text = dialog.getTextPanel();
71 AddRemoveCommodity.addCreditsGainText(loanAmount, text);
72
74 }
75
76 protected int getNegotiatedAmount() {
77 return repaymentAmount - (int) ((repaymentAmount - loanAmount) * 0.5f);
78 }
79
80 protected void addStoryOption() {
81 String id = "negotiate_id";
82 options.addOption("Negotiate a lower rate on the loan", id);
83
84 StoryOptionParams params = new StoryOptionParams(id, 1, "negotiateLoanRate", Sounds.STORY_POINT_SPEND_TECHNOLOGY,
85 "Negotiated lower rate on " + Misc.getDGSCredits(loanAmount) + " loan from Tri-Tachyon investor");
86
87 SetStoryOption.set(dialog, params,
88 new BaseOptionStoryPointActionDelegate(dialog, params) {
89
90 @Override
91 public void confirm() {
92 super.confirm();
94 //negotiated = true;
95 dialog.getTextPanel().addPara(getNegotiatedText());
96 OptionPanelAPI options = dialog.getOptionPanel();
97 options.clearOptions();
98 options.addOption("Continue", OPTION_CONFIRM);
99 //optionSelected(null, OPTION_CONFIRM);
100 }
101
102 @Override
103 public String getTitle() {
104 //return "Negotiating loan repayment";
105 return null;
106 }
107
108 @Override
109 public void createDescription(TooltipMakerAPI info) {
110 float opad = 10f;
111 info.setParaInsigniaLarge();
112
113 info.addSpacer(-opad * 1f);
114
115 info.addPara("The loan amount is %s.",
116 0f, Misc.getHighlightColor(),
117 Misc.getDGSCredits(loanAmount));
118
119 info.addPara("You're able to negotiate the repayment amount from %s down to " +
120 "%s.", opad, Misc.getHighlightColor(),
121 Misc.getDGSCredits(repaymentAmount),
122 Misc.getDGSCredits(getNegotiatedAmount()));
123
124 info.addSpacer(opad * 2f);
125 addActionCostSection(info);
126 }
127
128 });
129 }
130
131 @Override
132 public void optionSelected(String optionText, Object optionData) {
133 super.optionSelected(optionText, optionData);
134 }
135
136 protected void createIntel() {
137 TriTachLoanIntel intel = new TriTachLoanIntel(this, market);
138 Global.getSector().getIntelManager().addIntel(intel, false, dialog.getTextPanel());
139 }
140
141 @Override
142 protected String getPersonFaction() {
143 return Factions.TRITACHYON;
144 }
145
146 @Override
147 protected String getPersonRank() {
148 return Ranks.CITIZEN;
149 }
150
151// do this after load is repaid
152// @Override
153// protected void doExtraConfirmActions() {
154// ContactIntel.addPotentialContact(person, market, text);
155// }
156
157 @Override
158 protected void adjustPerson(PersonAPI person) {
159 super.adjustPerson(person);
160 person.setImportanceAndVoice(PersonImportance.MEDIUM, random);
161 person.addTag(Tags.CONTACT_TRADE);
162 }
163
164 @Override
165 protected String getPersonPost() {
166 return Ranks.POST_EXECUTIVE;
167 }
168
169 @Override
170 protected float getPriceMult() {
171 return 0;
172 }
173
174 @Override
175 protected String getPrompt() {
176 return "A Tri-Tachyon careerist sits at a spotless table, sipping something expensive-looking.";
177 }
178
179 @Override
180 protected String getOptionText() {
181 return "Introduce yourself to the Tri-Tachyon " + getManOrWoman() + " and try to land some investment credits";
182 }
183
184 @Override
185 protected String getMainText() {
186 return "A young Tri-Tachyon factioneer in a perfect suit sips from some insubstantial drink " +
187 "as sophisticated as it is expensive. After introductions " + getHeOrShe() +
188 " quickly cuts to the point, and says \"I'm simply in the business of statistics, and " +
189 "I like your growth potential. I think that you can take my %s now and pay " +
190 "%s back to me in, oh, %s days. If not, \"" + getHeOrShe() +
191 " mimics a stricken look, \"I'll ruin your reputation across Tri-Tachyon space. What do you say?\"";
192 }
193
194 @Override
195 protected String [] getMainTextTokens() {
196 return new String [] { Misc.getDGSCredits(loanAmount), Misc.getDGSCredits(repaymentAmount),
197 "" + (int)repaymentDays };
198 }
199 @Override
200 protected Color [] getMainTextColors() {
201 return new Color [] { Misc.getHighlightColor(), Misc.getHighlightColor(), Misc.getHighlightColor() };
202 }
203
204 @Override
205 protected String getConfirmText() {
206 return "Accept the deal and order another round to celebrate";
207 }
208
209 @Override
210 protected String getCancelText() {
211 return "Decline the deal, explaining that you're \"just here to network\"";
212 }
213
214 protected String getNegotiatedText() {
215 return "The Tri-Tachyon " + getManOrWoman() + "'s smile freezes in place as you launch into a sophisticated " +
216 " pitch to modify the proposed terms. You notice " + getHisOrHer() +
217 " eyes tracking rapidly, navigating some ocular data interface as you speak; " + getHeOrShe() +
218 " seems thrown off-balance by your savvy, and never quite recovers that signature megacorp implacability." +
219 " By the time it is agreed that a substantially lower repayment figure will benefit all parties, the dazed " +
220 "investor finds " + getHisOrHer() + " drink has gone flat. " + getHeOrShe() + " brusquely orders a replacement.";
221 }
222
223 @Override
224 protected String getAcceptText() {
225 return "You leave the lounge rich in credits, having exchanged secure comm keys with the " +
226 "Tri-Tachyon shark and receiving the transfer immediately. Your head spins with plans " +
227 "for how to leverage your new assets - and a bit from the drink, you admit to yourself.";
228 }
229
230
231
232 public int getLoanAmount() {
233 return loanAmount;
234 }
235
236 public void setLoanAmount(int loanAmount) {
237 this.loanAmount = loanAmount;
238 }
239
240 public int getRepaymentAmount() {
241 return repaymentAmount;
242 }
243
245 this.repaymentAmount = repaymentAmount;
246 }
247
248 public int getRepaymentDays() {
249 return repaymentDays;
250 }
251
253 this.repaymentDays = repaymentDays;
254 }
255
256 protected boolean showCargoCap() {
257 return false;
258 }
259
260}
261
262
263
static SectorAPI getSector()
Definition Global.java:59