Starsector API
All Classes Namespaces Files Functions Variables
LuddicCraftBarEvent.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.campaign.econ.CommodityOnMarketAPI;
6import com.fs.starfarer.api.campaign.econ.MarketAPI;
7import com.fs.starfarer.api.characters.PersonAPI;
8import com.fs.starfarer.api.impl.campaign.econ.impl.BaseIndustry;
9import com.fs.starfarer.api.impl.campaign.ids.Commodities;
10import com.fs.starfarer.api.impl.campaign.ids.Factions;
11import com.fs.starfarer.api.impl.campaign.ids.Ranks;
12import com.fs.starfarer.api.impl.campaign.ids.Tags;
13import com.fs.starfarer.api.impl.campaign.intel.contacts.ContactIntel;
14import com.fs.starfarer.api.util.Misc;
15
17
19 super();
20 }
21
22 public boolean shouldShowAtMarket(MarketAPI market) {
23 if (!super.shouldShowAtMarket(market)) return false;
25
26 if (!market.getFactionId().equals(Factions.LUDDIC_CHURCH) &&
27 !market.getFactionId().equals(Factions.LUDDIC_PATH)) {
28 return false;
29 }
30
31 if (market.getStabilityValue() < 4) return false;
32
33 CommodityOnMarketAPI com = market.getCommodityData(commodity);
34 if (com.getMaxSupply() <= 0) return false;
35 if (com.getAvailable() < com.getMaxDemand()) return false;
36
37 return true;
38 }
39
40 @Override
41 protected String getCommodityId() {
42 return Commodities.DOMESTIC_GOODS;
43 }
44
45 @Override
46 protected void doExtraConfirmActions() {
47 ContactIntel.addPotentialContact(person, market, text);
48 }
49
50 @Override
51 protected void adjustPerson(PersonAPI person) {
52 super.adjustPerson(person);
53 person.setImportanceAndVoice(pickMediumImportance(), random);
54 person.addTag(Tags.CONTACT_TRADE);
55 }
56
57 @Override
58 protected String getPersonPost() {
59 return Ranks.POST_GUILDMASTER;
60 }
61
62 @Override
63 protected String getPersonFaction() {
64 return Factions.LUDDIC_CHURCH;
65 }
66
67 @Override
68 protected String getPersonRank() {
69 return Ranks.CITIZEN;
70 }
71
72 @Override
73 protected int computeQuantity() {
74 int quantity = 30 + 10 * random.nextInt(4);
75
76 CommodityOnMarketAPI com = market.getCommodityData(commodity);
77 int size = Math.min(com.getAvailable(), com.getMaxSupply());
78 if (size < 1) size = 1;
79 quantity *= Math.max(1, BaseIndustry.getSizeMult(size) - 2);
80 return quantity;
81 }
82
83 @Override
84 protected float getPriceMult() {
85 return 0.75f;
86 }
87
88 @Override
89 protected String getPrompt() {
90 return "A tough looking " + getManOrWoman() + " whose worn but well-tailored work suit bears the " +
91 "sigil of a crafts guild sits at a corner table bearing the remnants of a spare meal.";
92
93 }
94
95 @Override
96 protected String getOptionText() {
97 return "Strike up a conversation with the tough-looking " + getManOrWoman() + "";
98 }
99
100 @Override
101 protected String getMainText() {
102 String heOrShe = getHeOrShe();
103 String himOrHer = getHimOrHer();
104
105 return "You buy " + himOrHer + " a drink and strike up a conversation. " +
106 Misc.ucFirst(heOrShe) + " turns out to be one of the masters of a local craft guild " +
107 " with a bit of a problem. \"His holiness, the Curate Astropolitan, turns his mind to spiritual " +
108 "rather than practical matters.\" " +
109 Misc.ucFirst(heOrShe) + " explains that the commercial bureaucracy of " + market.getName() +
110 " is understaffed and overworked. \"Ludd forgive me, but bills aren't paid by prayer.\"\n\n" +
111 Misc.ucFirst(heOrShe) + " explains that there are %s units of domestic goods gathering dust " +
112 "in a guild warehouse. If they could be quietly sold at even the under-market price " +
113 "of %s each, don't mind the tariffs, it'd be nothing more than an act of charity.";
114 }
115
116 @Override
117 protected String [] getMainTextTokens() {
118 return new String [] { Misc.getWithDGS(quantity), Misc.getDGSCredits(unitPrice) };
119 }
120 @Override
121 protected Color [] getMainTextColors() {
122 return new Color [] { Misc.getHighlightColor(), Misc.getHighlightColor() };
123 }
124
125 @Override
126 protected String getConfirmText() {
127 return "Accept the deal and transfer " + Misc.getDGSCredits(unitPrice * quantity) + " to the guild";
128 }
129
130 @Override
131 protected String getCancelText() {
132 return "Decline the deal; \"Patience is a virtue, after all\"";
133 }
134
135 @Override
136 protected String getAcceptText() {
137 return "\"Praise be to Providence for bringing you to me!\" exclaims the guild-master " +
138 "with a broad smile and a clap on the back. Soon enough, your cargo manifest " +
139 "counts %s additional units of domestic goods, \"recovered from deep space salvage\".";
140 }
141
142 @Override
143 protected String [] getAcceptTextTokens() {
144 return new String [] { Misc.getWithDGS(quantity)};
145 }
146 @Override
147 protected Color [] getAcceptTextColors() {
148 return new Color [] {Misc.getHighlightColor() };
149 }
150
151}
152
153
154