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() +
")");
109 farming.getSupplyBonusFromOther().unmodifyFlat(spec.getId());
112 if (industry instanceof BaseIndustry) {
113 BaseIndustry b = (BaseIndustry) industry;
114 b.demand(9, Commodities.VOLATILES, FUSION_LAMP_VOLATILES, Misc.ucFirst(spec.getName().toLowerCase()));
116 MemoryAPI memory = getLampMemory(industry);
117 float h = getShortageHazard(industry);
119 industry.getMarket().getHazard().modifyFlat(spec.getId(), h,
120 Misc.ucFirst(spec.getName().toLowerCase()) +
" volatiles shortage");
121 if (memory != null) {
123 memory.set(FusionLampEntityPlugin.VOLATILES_SHORTAGE_KEY, h / FUSION_LAMP_SHORTAGE_HAZARD);
127 for (String id : FUSION_LAMP_CONDITIONS) {
128 industry.getMarket().suppressCondition(id);
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());
138 b.
demand(9, Commodities.VOLATILES, 0,
null);
139 industry.getMarket().getHazard().unmodifyFlat(spec.getId());
140 MemoryAPI memory = getLampMemory(industry);
141 if (memory !=
null) {
145 for (String
id : FUSION_LAMP_CONDITIONS) {
146 industry.getMarket().unsuppressCondition(
id);
149 protected MemoryAPI getLampMemory(Industry industry) {
152 if (b.
lamp !=
null) {
153 return b.
lamp.getMemoryWithoutUpdate();
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;
161 float v = industry.getMarket().getCommodityData(Commodities.VOLATILES).getAvailable();
162 float f = 1f - v / (float) volatilesDemand;
163 float h = Math.round(f * FUSION_LAMP_SHORTAGE_HAZARD * 100f) / 100f;
165 industry.getMarket().getHazard().modifyFlat(spec.getId(), h,
166 Misc.ucFirst(spec.getName().toLowerCase()) +
" volatiles shortage");
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);
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) {
184 conds.add(mc.getName());
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);
193 Items.CORRUPTED_NANOFORGE, CORRUPTED_NANOFORGE_PROD, 0) {
194 public void apply(Industry industry) {
195 super.apply(industry);
196 industry.getMarket().getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD)
197 .modifyFlat(
"nanoforge", CORRUPTED_NANOFORGE_QUALITY_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
199 public void unapply(Industry industry) {
201 industry.getMarket().getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD).unmodifyFlat(
"nanoforge");
203 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
204 InstallableItemDescriptionMode mode, String pre,
float pad) {
205 String heavyIndustry =
"heavy industry ";
206 if (mode == InstallableItemDescriptionMode.MANAGE_ITEM_DIALOG_LIST) {
209 text.addPara(pre +
"Increases ship and weapon production quality by %s. " +
210 "Increases " + heavyIndustry +
"production by %s unit." +
211 " On habitable worlds, causes pollution which becomes permanent.",
212 pad, Misc.getHighlightColor(),
213 "" + (
int) Math.round(CORRUPTED_NANOFORGE_QUALITY_BONUS * 100f) +
"%",
214 "" + (
int) CORRUPTED_NANOFORGE_PROD);
218 Items.PRISTINE_NANOFORGE, PRISTINE_NANOFORGE_PROD, 0) {
219 public void apply(Industry industry) {
220 super.apply(industry);
221 industry.getMarket().getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD)
222 .modifyFlat(
"nanoforge", PRISTINE_NANOFORGE_QUALITY_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
224 public void unapply(Industry industry) {
226 industry.getMarket().getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD).unmodifyFlat(
"nanoforge");
228 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
229 InstallableItemDescriptionMode mode, String pre,
float pad) {
230 String heavyIndustry =
"heavy industry ";
231 if (mode == InstallableItemDescriptionMode.MANAGE_ITEM_DIALOG_LIST) {
234 text.addPara(pre +
"Increases ship and weapon production quality by %s. " +
235 "Increases " + heavyIndustry +
"production by %s units." +
236 " On habitable worlds, causes pollution which becomes permanent.",
237 pad, Misc.getHighlightColor(),
238 "" + (
int) Math.round(PRISTINE_NANOFORGE_QUALITY_BONUS * 100f) +
"%",
239 "" + (
int) PRISTINE_NANOFORGE_PROD);
242 put(Items.SYNCHROTRON,
new BoostIndustryInstallableItemEffect(
243 Items.SYNCHROTRON, SYNCHROTRON_FUEL_BONUS, 0) {
244 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
245 InstallableItemDescriptionMode mode, String pre, float pad) {
247 text.addPara(pre +
"Increases fuel production output by %s units.",
248 pad, Misc.getHighlightColor(),
"" + SYNCHROTRON_FUEL_BONUS);
251 public String[] getSimpleReqs(Industry industry) {
252 return new String [] {NO_ATMOSPHERE};
255 put(Items.MANTLE_BORE,
new BaseInstallableItemEffect(Items.MANTLE_BORE) {
256 protected Set<String> getAffectedCommodities(Industry industry) {
257 MarketAPI market = industry.getMarket();
259 Set<String> result = new LinkedHashSet<String>();
260 for (MarketConditionAPI mc : market.getConditions()) {
261 String cid = mc.getId();
262 String commodity = ResourceDepositsCondition.COMMODITY.get(cid);
263 for (String curr : MANTLE_BORE_COMMODITIES) {
264 if (curr.equals(commodity)) {
271 public void apply(Industry industry) {
272 if (industry instanceof BaseIndustry) {
273 BaseIndustry b = (BaseIndustry) industry;
274 Set<String> list = getAffectedCommodities(industry);
276 if (!list.isEmpty()) {
278 for (String curr : list) {
279 b.supply(spec.getId(), curr, MANTLE_BORE_MINING_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
284 public void unapply(Industry industry) {
285 if (industry instanceof BaseIndustry) {
286 BaseIndustry b = (BaseIndustry) industry;
289 for (String curr : MANTLE_BORE_COMMODITIES) {
290 b.supply(spec.getId(), curr, 0,
null);
294 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
295 InstallableItemDescriptionMode mode, String pre,
float pad) {
296 List<String> commodities =
new ArrayList<String>();
297 for (String curr : MANTLE_BORE_COMMODITIES) {
298 CommoditySpecAPI c = Global.getSettings().getCommoditySpec(curr);
299 commodities.add(c.getName().toLowerCase());
301 text.addPara(pre +
"Increases " + Misc.getAndJoined(commodities) +
" production by %s units.",
302 pad, Misc.getHighlightColor(),
303 "" + MANTLE_BORE_MINING_BONUS);
311 public String[] getSimpleReqs(Industry industry) {
312 return new String [] {NOT_A_GAS_GIANT, NOT_HABITABLE};
315 put(Items.PLASMA_DYNAMO,
new BaseInstallableItemEffect(Items.PLASMA_DYNAMO) {
316 protected Set<String> getAffectedCommodities(Industry industry) {
317 MarketAPI market = industry.getMarket();
319 Set<String> result = new LinkedHashSet<String>();
320 for (MarketConditionAPI mc : market.getConditions()) {
321 String cid = mc.getId();
322 String commodity = ResourceDepositsCondition.COMMODITY.get(cid);
323 for (String curr : PLASMA_DYNAMO_COMMODITIES) {
324 if (curr.equals(commodity)) {
331 public void apply(Industry industry) {
332 if (industry instanceof BaseIndustry) {
333 BaseIndustry b = (BaseIndustry) industry;
334 Set<String> list = getAffectedCommodities(industry);
336 if (!list.isEmpty()) {
338 for (String curr : list) {
339 b.supply(spec.getId(), curr, PLASMA_DYNAMO_MINING_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
344 public void unapply(Industry industry) {
345 if (industry instanceof BaseIndustry) {
346 BaseIndustry b = (BaseIndustry) industry;
349 for (String curr : PLASMA_DYNAMO_COMMODITIES) {
350 b.supply(spec.getId(), curr, 0,
null);
354 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
355 InstallableItemDescriptionMode mode, String pre,
float pad) {
356 List<String> commodities =
new ArrayList<String>();
357 for (String curr : PLASMA_DYNAMO_COMMODITIES) {
358 CommoditySpecAPI c = Global.getSettings().getCommoditySpec(curr);
359 commodities.add(c.getName().toLowerCase());
361 text.addPara(pre +
"Increases " + Misc.getAndJoined(commodities) +
" production by %s units.",
362 pad, Misc.getHighlightColor(),
363 "" + PLASMA_DYNAMO_MINING_BONUS);
371 public String[] getSimpleReqs(Industry industry) {
372 return new String [] {GAS_GIANT};
375 put(Items.BIOFACTORY_EMBRYO,
new BoostIndustryInstallableItemEffect(
376 Items.BIOFACTORY_EMBRYO, BIOFACTORY_PROD_BONUS, 0) {
377 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
378 InstallableItemDescriptionMode mode, String pre, float pad) {
379 text.addPara(pre +
"Increases light industry production by %s units.",
380 pad, Misc.getHighlightColor(),
381 "" + (int) BIOFACTORY_PROD_BONUS);
384 public String[] getSimpleReqs(Industry industry) {
385 return new String [] {HABITABLE};
388 put(Items.CATALYTIC_CORE,
new BoostIndustryInstallableItemEffect(
389 Items.CATALYTIC_CORE, CATALYTIC_CORE_BONUS, 0) {
390 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
391 InstallableItemDescriptionMode mode, String pre, float pad) {
392 text.addPara(pre +
"Increases refining production by %s units.",
393 pad, Misc.getHighlightColor(),
394 "" + (int) CATALYTIC_CORE_BONUS);
397 public String[] getSimpleReqs(Industry industry) {
398 return new String [] {NO_ATMOSPHERE};
401 put(Items.FULLERENE_SPOOL,
new BaseInstallableItemEffect(Items.FULLERENE_SPOOL) {
402 public void apply(Industry industry) {
403 industry.getMarket().getAccessibilityMod().modifyFlat(spec.getId(),
404 FULLERENE_SPOOL_ACCESS_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
406 public void unapply(Industry industry) {
407 industry.getMarket().getAccessibilityMod().unmodifyFlat(spec.getId());
409 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
410 InstallableItemDescriptionMode mode, String pre,
float pad) {
411 text.addPara(pre +
"Increases colony accessibility by %s.",
412 pad, Misc.getHighlightColor(),
413 "" + (
int) Math.round(FULLERENE_SPOOL_ACCESS_BONUS * 100f) +
"%");
416 public String[] getSimpleReqs(Industry industry) {
417 return new String [] {NOT_A_GAS_GIANT, NOT_EXTREME_WEATHER, NOT_EXTREME_TECTONIC_ACTIVITY};
420 put(Items.SOIL_NANITES,
new BoostIndustryInstallableItemEffect(
421 Items.SOIL_NANITES, SOIL_NANITES_BONUS, 0) {
422 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
423 InstallableItemDescriptionMode mode, String pre, float pad) {
424 text.addPara(pre +
"Increases farming production by %s units.",
425 pad, Misc.getHighlightColor(),
426 "" + (int) SOIL_NANITES_BONUS);
429 public String[] getSimpleReqs(Industry industry) {
430 return new String [] {NO_TRANSPLUTONIC_ORE_DEPOSITS, NO_VOLATILES_DEPOSITS};
433 put(Items.CRYOARITHMETIC_ENGINE,
new BaseInstallableItemEffect(Items.CRYOARITHMETIC_ENGINE) {
434 public void apply(Industry industry) {
436 if (industry.getMarket().hasCondition(Conditions.HOT)) {
437 bonus = CRYOARITHMETIC_FLEET_SIZE_BONUS_HOT;
438 } else if (industry.getMarket().hasCondition(Conditions.VERY_HOT)) {
439 bonus = CRYOARITHMETIC_FLEET_SIZE_BONUS_VERY_HOT;
441 industry.getMarket().getStats().getDynamic().getMod(Stats.COMBAT_FLEET_SIZE_MULT)
442 .modifyFlat(spec.getId(), bonus, Misc.ucFirst(spec.getName().toLowerCase()));
444 public void unapply(Industry industry) {
445 industry.getMarket().getStats().getDynamic().getMod(Stats.COMBAT_FLEET_SIZE_MULT).unmodifyFlat(spec.getId());
447 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
448 InstallableItemDescriptionMode mode, String pre,
float pad) {
449 text.addPara(pre +
"Increases size of fleets launched by colony by %s for hot worlds, and " +
450 "by %s for worlds with extreme heat.",
451 pad, Misc.getHighlightColor(),
452 "" + (
int) Math.round(CRYOARITHMETIC_FLEET_SIZE_BONUS_HOT * 100f) +
"%",
453 "" + (
int) Math.round(CRYOARITHMETIC_FLEET_SIZE_BONUS_VERY_HOT * 100f) +
"%");
456 public String[] getSimpleReqs(Industry industry) {
457 return new String [] {HOT_OR_EXTREME_HEAT};
460 put(Items.DRONE_REPLICATOR,
new BaseInstallableItemEffect(Items.DRONE_REPLICATOR) {
461 public void apply(Industry industry) {
462 industry.getMarket().getStats().getDynamic().getMod(Stats.GROUND_DEFENSES_MOD)
463 .modifyMult(spec.getId(), DRONE_REPLICATOR_BONUS_MULT, Misc.ucFirst(spec.getName().toLowerCase()));
465 public void unapply(Industry industry) {
466 industry.getMarket().getStats().getDynamic().getMod(Stats.GROUND_DEFENSES_MOD).unmodifyMult(spec.getId());
468 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
469 InstallableItemDescriptionMode mode, String pre,
float pad) {
470 text.addPara(pre +
"Colony's ground defenses increased by %s.",
471 pad, Misc.getHighlightColor(),
472 Strings.X + DRONE_REPLICATOR_BONUS_MULT);
475 put(Items.DEALMAKER_HOLOSUITE,
new BaseInstallableItemEffect(Items.DEALMAKER_HOLOSUITE) {
476 public void apply(Industry industry) {
477 industry.getMarket().getIncomeMult().modifyPercent(spec.getId(), DEALMAKER_INCOME_PERCENT_BONUS,
478 Misc.ucFirst(spec.getName().toLowerCase()));
480 public void unapply(Industry industry) {
481 industry.getMarket().getIncomeMult().unmodifyPercent(spec.getId());
483 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
484 InstallableItemDescriptionMode mode, String pre,
float pad) {
485 text.addPara(pre +
"Colony's income increased by %s.",
486 pad, Misc.getHighlightColor(),
487 "" + (
int)DEALMAKER_INCOME_PERCENT_BONUS +
"%");
490 put(Items.CORONAL_PORTAL,
new BaseInstallableItemEffect(Items.CORONAL_PORTAL) {
491 public void apply(Industry industry) {
492 if (industry instanceof BaseIndustry) {
493 BaseIndustry b = (BaseIndustry) industry;
494 b.demand(8, Commodities.RARE_METALS, CORONAL_TAP_TRANSPLUTONICS, Misc.ucFirst(spec.getName().toLowerCase()));
496 if (!hasShortage(industry)) {
497 industry.getMarket().getStats().getDynamic().getMod(Stats.MAX_INDUSTRIES).modifyFlat(
498 spec.getId(), CORONAL_TAP_INDUSTRIES);
500 industry.getMarket().getStats().getDynamic().getMod(Stats.MAX_INDUSTRIES).unmodifyFlat(spec.getId());
504 public void unapply(Industry industry) {
505 if (industry instanceof BaseIndustry) {
506 BaseIndustry b = (BaseIndustry) industry;
507 b.demand(8, Commodities.RARE_METALS, 0,
null);
508 industry.getMarket().getStats().getDynamic().getMod(Stats.MAX_INDUSTRIES).unmodifyFlat(spec.getId());
511 protected boolean hasShortage(Industry industry) {
513 int transplutonicsDemand = industry.getDemand(Commodities.RARE_METALS).getQuantity().getModifiedInt();
514 float v = industry.getMarket().getCommodityData(Commodities.RARE_METALS).getAvailable();
515 float f = 1f - v / (float) transplutonicsDemand;
518 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
519 InstallableItemDescriptionMode mode, String pre,
float pad) {
520 text.addPara(pre +
"Increases the maximum number of industries at a colony by %s when demand for " +
521 "%s units of transplutonics is fully met.",
522 pad, Misc.getHighlightColor(),
523 "" + (
int)CORONAL_TAP_INDUSTRIES,
524 "" + (
int)CORONAL_TAP_TRANSPLUTONICS);
527 public String[] getSimpleReqs(Industry industry) {
528 return new String [] {CORONAL_TAP_RANGE};