Starsector API
Loading...
Searching...
No Matches
ItemEffectsRepo.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.econ.impl;
2
3import java.util.ArrayList;
4import java.util.HashMap;
5import java.util.LinkedHashSet;
6import java.util.List;
7import java.util.Map;
8import java.util.Set;
9
10import com.fs.starfarer.api.Global;
11import com.fs.starfarer.api.campaign.SpecialItemData;
12import com.fs.starfarer.api.campaign.econ.CommoditySpecAPI;
13import com.fs.starfarer.api.campaign.econ.Industry;
14import com.fs.starfarer.api.campaign.econ.InstallableIndustryItemPlugin.InstallableItemDescriptionMode;
15import com.fs.starfarer.api.campaign.econ.MarketAPI;
16import com.fs.starfarer.api.campaign.econ.MarketConditionAPI;
17import com.fs.starfarer.api.campaign.rules.MemoryAPI;
18import com.fs.starfarer.api.characters.MarketConditionSpecAPI;
19import com.fs.starfarer.api.impl.campaign.FusionLampEntityPlugin;
20import com.fs.starfarer.api.impl.campaign.econ.ResourceDepositsCondition;
21import com.fs.starfarer.api.impl.campaign.ids.Commodities;
22import com.fs.starfarer.api.impl.campaign.ids.Conditions;
23import com.fs.starfarer.api.impl.campaign.ids.Industries;
24import com.fs.starfarer.api.impl.campaign.ids.Items;
25import com.fs.starfarer.api.impl.campaign.ids.Stats;
26import com.fs.starfarer.api.impl.campaign.ids.Strings;
27import com.fs.starfarer.api.ui.TooltipMakerAPI;
28import com.fs.starfarer.api.util.Misc;
29
30@SuppressWarnings("serial")
31public class ItemEffectsRepo {
32
33 public static String NOT_A_GAS_GIANT = "not a gas giant";
34 public static String NOT_HABITABLE = "not habitable";
35 public static String HABITABLE = "habitable";
36 public static String GAS_GIANT = "gas giant";
37 public static String NO_ATMOSPHERE = "no atmosphere";
38 public static String NOT_EXTREME_WEATHER = "no extreme weather";
39 public static String NOT_EXTREME_TECTONIC_ACTIVITY = "no extreme tectonic activity";
40 public static String NO_TRANSPLUTONIC_ORE_DEPOSITS = "no transplutonic ore deposits";
41 public static String NO_VOLATILES_DEPOSITS = "no volatiles deposits";
42 public static String HOT_OR_EXTREME_HEAT = "hot or extreme heat";
43 public static String COLD_OR_EXTREME_COLD = "cold or extreme cold";
44
45 public static int CORONAL_TAP_LIGHT_YEARS = 10;
46 public static String CORONAL_TAP_RANGE = "coronal hypershunt within " + CORONAL_TAP_LIGHT_YEARS + " light-years";
47
48 public static int CORONAL_TAP_TRANSPLUTONICS = 10;
49 public static int CORONAL_TAP_INDUSTRIES = 1;
50
51 public static int FUSION_LAMP_FARMING_BONUS = 0;
52 public static int FUSION_LAMP_VOLATILES = 10;
53 public static float FUSION_LAMP_SHORTAGE_HAZARD = 0.5f;
54 public static List<String> FUSION_LAMP_CONDITIONS = new ArrayList<String>();
55 static {
56 FUSION_LAMP_CONDITIONS.add(Conditions.COLD);
57 FUSION_LAMP_CONDITIONS.add(Conditions.VERY_COLD);
58 FUSION_LAMP_CONDITIONS.add(Conditions.POOR_LIGHT);
59 FUSION_LAMP_CONDITIONS.add(Conditions.DARK);
60 }
61
62 public static float CORRUPTED_NANOFORGE_QUALITY_BONUS = 0.2f;
63 public static float PRISTINE_NANOFORGE_QUALITY_BONUS = 0.5f;
64
65 public static int CORRUPTED_NANOFORGE_PROD = 1;
66 public static int PRISTINE_NANOFORGE_PROD = 3;
67
68 public static int SYNCHROTRON_FUEL_BONUS = 3;
69
70 public static int MANTLE_BORE_MINING_BONUS = 3;
71 public static List<String> MANTLE_BORE_COMMODITIES = new ArrayList<String>();
72 static {
73 MANTLE_BORE_COMMODITIES.add(Commodities.ORE);
74 MANTLE_BORE_COMMODITIES.add(Commodities.RARE_ORE);
75 MANTLE_BORE_COMMODITIES.add(Commodities.ORGANICS);
76 }
77
78 public static int PLASMA_DYNAMO_MINING_BONUS = 3;
79 public static List<String> PLASMA_DYNAMO_COMMODITIES = new ArrayList<String>();
80 static {
81 PLASMA_DYNAMO_COMMODITIES.add(Commodities.VOLATILES);
82 }
83
84 public static int BIOFACTORY_PROD_BONUS = 2;
85
86 public static int CATALYTIC_CORE_BONUS = 3;
87
88 public static float FULLERENE_SPOOL_ACCESS_BONUS = 0.3f;
89
90 public static int SOIL_NANITES_BONUS = 2;
91
92 public static float CRYOARITHMETIC_FLEET_SIZE_BONUS_HOT = 0.25f;
93 public static float CRYOARITHMETIC_FLEET_SIZE_BONUS_VERY_HOT = 1f;
94
95 public static float DRONE_REPLICATOR_BONUS_MULT = 1.5f;
96
97 public static int DEALMAKER_INCOME_PERCENT_BONUS = 50;
98
99
100 public static Map<String, InstallableItemEffect> ITEM_EFFECTS = new HashMap<String, InstallableItemEffect>() {{
102 public void apply(Industry industry) {
103 Industry farming = getFarming(industry);
104 if (farming != null && FUSION_LAMP_FARMING_BONUS > 0) {
105 if (farming.isFunctional()) {
106 farming.getSupplyBonusFromOther().modifyFlat(spec.getId(), FUSION_LAMP_FARMING_BONUS,
107 Misc.ucFirst(spec.getName().toLowerCase()) + " (" + industry.getCurrentName() + ")");
108 } else {
109 farming.getSupplyBonusFromOther().unmodifyFlat(spec.getId());
110 }
111 }
112 if (industry instanceof BaseIndustry) {
113 BaseIndustry b = (BaseIndustry) industry;
114 b.demand(9, Commodities.VOLATILES, FUSION_LAMP_VOLATILES, Misc.ucFirst(spec.getName().toLowerCase()));
115
116 MemoryAPI memory = getLampMemory(industry);
117 float h = getShortageHazard(industry);
118 if (h > 0) {
119 industry.getMarket().getHazard().modifyFlat(spec.getId(), h,
120 Misc.ucFirst(spec.getName().toLowerCase()) + " volatiles shortage");
121 if (memory != null) {
122 // so that FusionLampEntityPlugin knows to flicker during a shortage
123 memory.set(FusionLampEntityPlugin.VOLATILES_SHORTAGE_KEY, h / FUSION_LAMP_SHORTAGE_HAZARD);
124 }
125 }
126 }
127 for (String id : FUSION_LAMP_CONDITIONS) {
128 industry.getMarket().suppressCondition(id);
129 }
130 }
131 public void unapply(Industry industry) {
132 Industry farming = getFarming(industry);
133 if (farming != null && FUSION_LAMP_FARMING_BONUS > 0) {
134 farming.getSupplyBonusFromOther().unmodifyFlat(spec.getId());
135 }
136 if (industry instanceof BaseIndustry) {
137 BaseIndustry b = (BaseIndustry) industry;
138 b.demand(9, Commodities.VOLATILES, 0, null);
139 industry.getMarket().getHazard().unmodifyFlat(spec.getId());
140 MemoryAPI memory = getLampMemory(industry);
141 if (memory != null) {
143 }
144 }
145 for (String id : FUSION_LAMP_CONDITIONS) {
146 industry.getMarket().unsuppressCondition(id);
147 }
148 }
149 protected MemoryAPI getLampMemory(Industry industry) {
150 if (industry instanceof PopulationAndInfrastructure) {
152 if (b.lamp != null) {
153 return b.lamp.getMemoryWithoutUpdate();
154 }
155 }
156 return null;
157 }
158 protected float getShortageHazard(Industry industry) {
159 int volatilesDemand = industry.getDemand(Commodities.VOLATILES).getQuantity().getModifiedInt();
160 if (volatilesDemand <= 0 || FUSION_LAMP_SHORTAGE_HAZARD <= 0) return 0f;
162 float f = 1f - v / (float) volatilesDemand;
163 float h = Math.round(f * FUSION_LAMP_SHORTAGE_HAZARD * 100f) / 100f;
164 if (h > 0) {
165 industry.getMarket().getHazard().modifyFlat(spec.getId(), h,
166 Misc.ucFirst(spec.getName().toLowerCase()) + " volatiles shortage");
167 }
168 return h;
169 }
170 protected Industry getFarming(Industry industry) {
171 String farmingId = Industries.FARMING;
172 Industry farming = industry.getMarket().getIndustry(farmingId);
173 if (farming == null) {
174 farmingId = Industries.AQUACULTURE;
175 farming = industry.getMarket().getIndustry(farmingId);
176 }
177 return farming;
178 }
179 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
180 InstallableItemDescriptionMode mode, String pre, float pad) {
181// List<String> conds = new ArrayList<String>();
182// for (String id : FUSION_LAMP_CONDITIONS) {
183// MarketConditionSpecAPI mc = Global.getSettings().getMarketConditionSpec(id);
184// conds.add(mc.getName());
185// }
186// text.addPara(pre + "Counters the effects of " + Misc.getAndJoined(conds) + ". Increases heat on non-cold planets. " +
187// "Adds demand for %s units of volatiles.",
188// pad, Misc.getHighlightColor(),
189// "" + FUSION_LAMP_VOLATILES);
190 text.addPara(pre + "Increases heat on non-cold planets. " +
191 "Adds demand for %s units of volatiles.",
192 pad, Misc.getHighlightColor(),
193 "" + FUSION_LAMP_VOLATILES);
194 }
195 @Override
196 public String getSpecialNotesName() {
197 return "Counters";
198 }
199 @Override
200 public List<String> getSpecialNotes(Industry industry) {
201 List<String> conds = new ArrayList<String>();
202 for (String id : FUSION_LAMP_CONDITIONS) {
204 conds.add(mc.getName().toLowerCase());
205 }
206 return conds;
207 }
208 @Override
209 public Set<String> getConditionsRelatedToRequirements(Industry industry) {
210 Set<String> list = super.getConditionsRelatedToRequirements(industry);
211 list.addAll(FUSION_LAMP_CONDITIONS);
212 list.add(Conditions.HOT);
213 list.add(Conditions.VERY_HOT);
214 return list;
215 }
216
217 });
219 Items.CORRUPTED_NANOFORGE, CORRUPTED_NANOFORGE_PROD, 0) {
220 public void apply(Industry industry) {
221 super.apply(industry);
222 industry.getMarket().getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD)
223 .modifyFlat("nanoforge", CORRUPTED_NANOFORGE_QUALITY_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
224 }
225 public void unapply(Industry industry) {
226 super.unapply(industry);
228 }
229 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
230 InstallableItemDescriptionMode mode, String pre, float pad) {
231 String heavyIndustry = "heavy industry ";
232 if (mode == InstallableItemDescriptionMode.MANAGE_ITEM_DIALOG_LIST) {
233 heavyIndustry = "";
234 }
235 text.addPara(pre + "Increases ship and weapon production quality by %s. " +
236 "Increases " + heavyIndustry + "production by %s unit." +
237 " On habitable worlds, causes pollution which becomes permanent.",
238 pad, Misc.getHighlightColor(),
239 "" + (int) Math.round(CORRUPTED_NANOFORGE_QUALITY_BONUS * 100f) + "%",
240 "" + (int) CORRUPTED_NANOFORGE_PROD);
241 }
242 });
244 Items.PRISTINE_NANOFORGE, PRISTINE_NANOFORGE_PROD, 0) {
245 public void apply(Industry industry) {
246 super.apply(industry);
247 industry.getMarket().getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD)
248 .modifyFlat("nanoforge", PRISTINE_NANOFORGE_QUALITY_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
249 }
250 public void unapply(Industry industry) {
251 super.unapply(industry);
253 }
254 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
255 InstallableItemDescriptionMode mode, String pre, float pad) {
256 String heavyIndustry = "heavy industry ";
257 if (mode == InstallableItemDescriptionMode.MANAGE_ITEM_DIALOG_LIST) {
258 heavyIndustry = "";
259 }
260 text.addPara(pre + "Increases ship and weapon production quality by %s. " +
261 "Increases " + heavyIndustry + "production by %s units." +
262 " On habitable worlds, causes pollution which becomes permanent.",
263 pad, Misc.getHighlightColor(),
264 "" + (int) Math.round(PRISTINE_NANOFORGE_QUALITY_BONUS * 100f) + "%",
265 "" + (int) PRISTINE_NANOFORGE_PROD);
266 }
267 });
268 put(Items.SYNCHROTRON, new BoostIndustryInstallableItemEffect(
269 Items.SYNCHROTRON, SYNCHROTRON_FUEL_BONUS, 0) {
270 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
271 InstallableItemDescriptionMode mode, String pre, float pad) {
272 //text.addPara(pre + "Increases fuel production and demand for volatiles by %s.",
273 text.addPara(pre + "Increases fuel production output by %s units.",
274 pad, Misc.getHighlightColor(), "" + SYNCHROTRON_FUEL_BONUS);
275 }
276 @Override
277 public String[] getSimpleReqs(Industry industry) {
278 return new String [] {NO_ATMOSPHERE};
279 }
280 });
281 put(Items.MANTLE_BORE, new BaseInstallableItemEffect(Items.MANTLE_BORE) {
282 protected Set<String> getAffectedCommodities(Industry industry) {
283 MarketAPI market = industry.getMarket();
284
285 Set<String> result = new LinkedHashSet<String>();
286 for (MarketConditionAPI mc : market.getConditions()) {
287 String cid = mc.getId();
288 String commodity = ResourceDepositsCondition.COMMODITY.get(cid);
289 for (String curr : MANTLE_BORE_COMMODITIES) {
290 if (curr.equals(commodity)) {
291 result.add(curr);
292 }
293 }
294 }
295 return result;
296 }
297 public void apply(Industry industry) {
298 if (industry instanceof BaseIndustry) {
299 BaseIndustry b = (BaseIndustry) industry;
300 Set<String> list = getAffectedCommodities(industry);
301
302 if (!list.isEmpty()) {
303 //b.demand(spec.getId(), Commodities.HEAVY_MACHINERY, MANTLE_BORE_MINING_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
304 for (String curr : list) {
305 b.supply(spec.getId(), curr, MANTLE_BORE_MINING_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
306 }
307 }
308 }
309 }
310 public void unapply(Industry industry) {
311 if (industry instanceof BaseIndustry) {
312 BaseIndustry b = (BaseIndustry) industry;
313
314 //b.demand(spec.getId(), Commodities.HEAVY_MACHINERY, 0, null);
315 for (String curr : MANTLE_BORE_COMMODITIES) {
316 b.supply(spec.getId(), curr, 0, null);
317 }
318 }
319 }
320 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
321 InstallableItemDescriptionMode mode, String pre, float pad) {
322 List<String> commodities = new ArrayList<String>();
323 for (String curr : MANTLE_BORE_COMMODITIES) {
324 CommoditySpecAPI c = Global.getSettings().getCommoditySpec(curr);
325 commodities.add(c.getName().toLowerCase());
326 }
327 text.addPara(pre + "Increases " + Misc.getAndJoined(commodities) + " production by %s units.",
328 pad, Misc.getHighlightColor(),
329 "" + MANTLE_BORE_MINING_BONUS);
330// text.addPara(pre + "Increases " + Misc.getAndJoined(commodities) + " production by %s units. " +
331// "Increases demand for heavy machinery by %s units.",
332// pad, Misc.getHighlightColor(),
333// "" + MANTLE_BORE_MINING_BONUS,
334// "" + MANTLE_BORE_MINING_BONUS);
335 }
336 @Override
337 public String[] getSimpleReqs(Industry industry) {
338 return new String [] {NOT_A_GAS_GIANT, NOT_HABITABLE};
339 }
340 });
341 put(Items.PLASMA_DYNAMO, new BaseInstallableItemEffect(Items.PLASMA_DYNAMO) {
342 protected Set<String> getAffectedCommodities(Industry industry) {
343 MarketAPI market = industry.getMarket();
344
345 Set<String> result = new LinkedHashSet<String>();
346 for (MarketConditionAPI mc : market.getConditions()) {
347 String cid = mc.getId();
348 String commodity = ResourceDepositsCondition.COMMODITY.get(cid);
349 for (String curr : PLASMA_DYNAMO_COMMODITIES) {
350 if (curr.equals(commodity)) {
351 result.add(curr);
352 }
353 }
354 }
355 return result;
356 }
357 public void apply(Industry industry) {
358 if (industry instanceof BaseIndustry) {
359 BaseIndustry b = (BaseIndustry) industry;
360 Set<String> list = getAffectedCommodities(industry);
361
362 if (!list.isEmpty()) {
363 //b.demand(spec.getId(), Commodities.HEAVY_MACHINERY, PLASMA_DYNAMO_MINING_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
364 for (String curr : list) {
365 b.supply(spec.getId(), curr, PLASMA_DYNAMO_MINING_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
366 }
367 }
368 }
369 }
370 public void unapply(Industry industry) {
371 if (industry instanceof BaseIndustry) {
372 BaseIndustry b = (BaseIndustry) industry;
373
374 //b.demand(spec.getId(), Commodities.HEAVY_MACHINERY, 0, null);
375 for (String curr : PLASMA_DYNAMO_COMMODITIES) {
376 b.supply(spec.getId(), curr, 0, null);
377 }
378 }
379 }
380 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
381 InstallableItemDescriptionMode mode, String pre, float pad) {
382 List<String> commodities = new ArrayList<String>();
383 for (String curr : PLASMA_DYNAMO_COMMODITIES) {
384 CommoditySpecAPI c = Global.getSettings().getCommoditySpec(curr);
385 commodities.add(c.getName().toLowerCase());
386 }
387 text.addPara(pre + "Increases " + Misc.getAndJoined(commodities) + " production by %s units.",
388 pad, Misc.getHighlightColor(),
389 "" + PLASMA_DYNAMO_MINING_BONUS);
390// text.addPara(pre + "Increases " + Misc.getAndJoined(commodities) + " production by %s units. " +
391// "Increases demand for heavy machinery by %s units.",
392// pad, Misc.getHighlightColor(),
393// "" + PLASMA_DYNAMO_MINING_BONUS,
394// "" + PLASMA_DYNAMO_MINING_BONUS);
395 }
396 @Override
397 public String[] getSimpleReqs(Industry industry) {
398 return new String [] {GAS_GIANT};
399 }
400 });
401 put(Items.BIOFACTORY_EMBRYO, new BoostIndustryInstallableItemEffect(
402 Items.BIOFACTORY_EMBRYO, BIOFACTORY_PROD_BONUS, 0) {
403 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
404 InstallableItemDescriptionMode mode, String pre, float pad) {
405 text.addPara(pre + "Increases light industry production by %s units.",
406 pad, Misc.getHighlightColor(),
407 "" + (int) BIOFACTORY_PROD_BONUS);
408 }
409 @Override
410 public String[] getSimpleReqs(Industry industry) {
411 return new String [] {HABITABLE};
412 }
413 });
414 put(Items.CATALYTIC_CORE, new BoostIndustryInstallableItemEffect(
415 Items.CATALYTIC_CORE, CATALYTIC_CORE_BONUS, 0) {
416 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
417 InstallableItemDescriptionMode mode, String pre, float pad) {
418 text.addPara(pre + "Increases refining production by %s units.",
419 pad, Misc.getHighlightColor(),
420 "" + (int) CATALYTIC_CORE_BONUS);
421 }
422 @Override
423 public String[] getSimpleReqs(Industry industry) {
424 return new String [] {NO_ATMOSPHERE};
425 }
426 });
427 put(Items.FULLERENE_SPOOL, new BaseInstallableItemEffect(Items.FULLERENE_SPOOL) {
428 public void apply(Industry industry) {
429 industry.getMarket().getAccessibilityMod().modifyFlat(spec.getId(),
430 FULLERENE_SPOOL_ACCESS_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
431 }
432 public void unapply(Industry industry) {
433 industry.getMarket().getAccessibilityMod().unmodifyFlat(spec.getId());
434 }
435 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
436 InstallableItemDescriptionMode mode, String pre, float pad) {
437 text.addPara(pre + "Increases colony accessibility by %s.",
438 pad, Misc.getHighlightColor(),
439 "" + (int) Math.round(FULLERENE_SPOOL_ACCESS_BONUS * 100f) + "%");
440 }
441 @Override
442 public String[] getSimpleReqs(Industry industry) {
443 return new String [] {NOT_A_GAS_GIANT, NOT_EXTREME_WEATHER, NOT_EXTREME_TECTONIC_ACTIVITY};
444 }
445 });
446 put(Items.SOIL_NANITES, new BoostIndustryInstallableItemEffect(
447 Items.SOIL_NANITES, SOIL_NANITES_BONUS, 0) {
448 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
449 InstallableItemDescriptionMode mode, String pre, float pad) {
450 text.addPara(pre + "Increases farming production by %s units.",
451 pad, Misc.getHighlightColor(),
452 "" + (int) SOIL_NANITES_BONUS);
453 }
454 @Override
455 public String[] getSimpleReqs(Industry industry) {
456 return new String [] {NO_TRANSPLUTONIC_ORE_DEPOSITS, NO_VOLATILES_DEPOSITS};
457 }
458 });
459 put(Items.CRYOARITHMETIC_ENGINE, new BaseInstallableItemEffect(Items.CRYOARITHMETIC_ENGINE) {
460 public void apply(Industry industry) {
461 float bonus = 0f;
462 if (industry.getMarket().hasCondition(Conditions.HOT)) {
463 bonus = CRYOARITHMETIC_FLEET_SIZE_BONUS_HOT;
464 } else if (industry.getMarket().hasCondition(Conditions.VERY_HOT)) {
465 bonus = CRYOARITHMETIC_FLEET_SIZE_BONUS_VERY_HOT;
466 }
467 industry.getMarket().getStats().getDynamic().getMod(Stats.COMBAT_FLEET_SIZE_MULT)
468 .modifyFlat(spec.getId(), bonus, Misc.ucFirst(spec.getName().toLowerCase()));
469 }
470 public void unapply(Industry industry) {
471 industry.getMarket().getStats().getDynamic().getMod(Stats.COMBAT_FLEET_SIZE_MULT).unmodifyFlat(spec.getId());
472 }
473 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
474 InstallableItemDescriptionMode mode, String pre, float pad) {
475 text.addPara(pre + "Increases size of fleets launched by colony by %s for hot worlds, and " +
476 "by %s for worlds with extreme heat.",
477 pad, Misc.getHighlightColor(),
478 "" + (int) Math.round(CRYOARITHMETIC_FLEET_SIZE_BONUS_HOT * 100f) + "%",
479 "" + (int) Math.round(CRYOARITHMETIC_FLEET_SIZE_BONUS_VERY_HOT * 100f) + "%");
480 }
481 @Override
482 public String[] getSimpleReqs(Industry industry) {
483 return new String [] {HOT_OR_EXTREME_HEAT};
484 }
485 });
486 put(Items.DRONE_REPLICATOR, new BaseInstallableItemEffect(Items.DRONE_REPLICATOR) {
487 public void apply(Industry industry) {
488 industry.getMarket().getStats().getDynamic().getMod(Stats.GROUND_DEFENSES_MOD)
489 .modifyMult(spec.getId(), DRONE_REPLICATOR_BONUS_MULT, Misc.ucFirst(spec.getName().toLowerCase()));
490 }
491 public void unapply(Industry industry) {
492 industry.getMarket().getStats().getDynamic().getMod(Stats.GROUND_DEFENSES_MOD).unmodifyMult(spec.getId());
493 }
494 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
495 InstallableItemDescriptionMode mode, String pre, float pad) {
496 text.addPara(pre + "Colony's ground defenses increased by %s.",
497 pad, Misc.getHighlightColor(),
498 Strings.X + DRONE_REPLICATOR_BONUS_MULT);
499 }
500 });
501 put(Items.DEALMAKER_HOLOSUITE, new BaseInstallableItemEffect(Items.DEALMAKER_HOLOSUITE) {
502 public void apply(Industry industry) {
503 industry.getMarket().getIncomeMult().modifyPercent(spec.getId(), DEALMAKER_INCOME_PERCENT_BONUS,
504 Misc.ucFirst(spec.getName().toLowerCase()));
505 }
506 public void unapply(Industry industry) {
507 industry.getMarket().getIncomeMult().unmodifyPercent(spec.getId());
508 }
509 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
510 InstallableItemDescriptionMode mode, String pre, float pad) {
511 text.addPara(pre + "Colony's income increased by %s.",
512 pad, Misc.getHighlightColor(),
513 "" + (int)DEALMAKER_INCOME_PERCENT_BONUS + "%");
514 }
515 });
516 put(Items.CORONAL_PORTAL, new BaseInstallableItemEffect(Items.CORONAL_PORTAL) {
517 public void apply(Industry industry) {
518 if (industry instanceof BaseIndustry) {
519 BaseIndustry b = (BaseIndustry) industry;
520 b.demand(8, Commodities.RARE_METALS, CORONAL_TAP_TRANSPLUTONICS, Misc.ucFirst(spec.getName().toLowerCase()));
521
522 if (!hasShortage(industry)) {
523 industry.getMarket().getStats().getDynamic().getMod(Stats.MAX_INDUSTRIES).modifyFlat(
524 spec.getId(), CORONAL_TAP_INDUSTRIES);
525 } else {
526 industry.getMarket().getStats().getDynamic().getMod(Stats.MAX_INDUSTRIES).unmodifyFlat(spec.getId());
527 }
528 }
529 }
530 public void unapply(Industry industry) {
531 if (industry instanceof BaseIndustry) {
532 BaseIndustry b = (BaseIndustry) industry;
533 b.demand(8, Commodities.RARE_METALS, 0, null);
534 industry.getMarket().getStats().getDynamic().getMod(Stats.MAX_INDUSTRIES).unmodifyFlat(spec.getId());
535 }
536 }
537 protected boolean hasShortage(Industry industry) {
538 //if (true) return false;
539 int transplutonicsDemand = industry.getDemand(Commodities.RARE_METALS).getQuantity().getModifiedInt();
540 float v = industry.getMarket().getCommodityData(Commodities.RARE_METALS).getAvailable();
541 float f = 1f - v / (float) transplutonicsDemand;
542 return f > 0;
543 }
544 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
545 InstallableItemDescriptionMode mode, String pre, float pad) {
546 text.addPara(pre + "Increases the maximum number of industries at a colony by %s when demand for " +
547 "%s units of transplutonics is fully met.",
548 pad, Misc.getHighlightColor(),
549 "" + (int)CORONAL_TAP_INDUSTRIES,
550 "" + (int)CORONAL_TAP_TRANSPLUTONICS);
551 }
552 @Override
553 public String[] getSimpleReqs(Industry industry) {
554 return new String [] {CORONAL_TAP_RANGE};
555 }
556 });
557 }};
558
559
560
561
562
563}
564
565
566
567
568
569
570
static SettingsAPI getSettings()
Definition Global.java:57
void modifyFlat(String source, float value)
Map< String, MutableCommodityQuantity > demand
static String ucFirst(String str)
Definition Misc.java:559
static Color getHighlightColor()
Definition Misc.java:792
MarketConditionSpecAPI getMarketConditionSpec(String conditionId)
MutableCommodityQuantity getDemand(String id)
CommodityOnMarketAPI getCommodityData(String commodityId)
LabelAPI addPara(String format, float pad, Color hl, String... highlights)