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) {
140 MemoryAPI memory = getLampMemory(industry);
141 if (memory !=
null) {
145 for (String
id : FUSION_LAMP_CONDITIONS) {
152 if (b.
lamp !=
null) {
158 protected float getShortageHazard(
Industry industry) {
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;
166 Misc.
ucFirst(spec.getName().toLowerCase()) +
" volatiles shortage");
173 if (farming ==
null) {
180 InstallableItemDescriptionMode mode, String pre,
float pad) {
190 text.
addPara(pre +
"Increases heat on non-cold planets. " +
191 "Adds demand for %s units of volatiles.",
193 "" + FUSION_LAMP_VOLATILES);
196 public String getSpecialNotesName() {
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());
209 public Set<String> getConditionsRelatedToRequirements(
Industry industry) {
210 Set<String> list = super.getConditionsRelatedToRequirements(industry);
211 list.addAll(FUSION_LAMP_CONDITIONS);
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()));
225 public void unapply(
Industry industry) {
226 super.unapply(industry);
230 InstallableItemDescriptionMode mode, String pre,
float pad) {
231 String heavyIndustry =
"heavy industry ";
232 if (mode == InstallableItemDescriptionMode.MANAGE_ITEM_DIALOG_LIST) {
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.",
239 "" + (
int) Math.round(CORRUPTED_NANOFORGE_QUALITY_BONUS * 100f) +
"%",
240 "" + (
int) CORRUPTED_NANOFORGE_PROD);
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()));
250 public void unapply(
Industry industry) {
251 super.unapply(industry);
255 InstallableItemDescriptionMode mode, String pre,
float pad) {
256 String heavyIndustry =
"heavy industry ";
257 if (mode == InstallableItemDescriptionMode.MANAGE_ITEM_DIALOG_LIST) {
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.",
264 "" + (
int) Math.round(PRISTINE_NANOFORGE_QUALITY_BONUS * 100f) +
"%",
265 "" + (
int) PRISTINE_NANOFORGE_PROD);
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) {
273 text.addPara(pre +
"Increases fuel production output by %s units.",
274 pad, Misc.getHighlightColor(),
"" + SYNCHROTRON_FUEL_BONUS);
277 public String[] getSimpleReqs(Industry industry) {
278 return new String [] {NO_ATMOSPHERE};
281 put(Items.MANTLE_BORE,
new BaseInstallableItemEffect(Items.MANTLE_BORE) {
282 protected Set<String> getAffectedCommodities(Industry industry) {
283 MarketAPI market = industry.getMarket();
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)) {
297 public void apply(Industry industry) {
298 if (industry instanceof BaseIndustry) {
299 BaseIndustry b = (BaseIndustry) industry;
300 Set<String> list = getAffectedCommodities(industry);
302 if (!list.isEmpty()) {
304 for (String curr : list) {
305 b.supply(spec.getId(), curr, MANTLE_BORE_MINING_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
310 public void unapply(Industry industry) {
311 if (industry instanceof BaseIndustry) {
312 BaseIndustry b = (BaseIndustry) industry;
315 for (String curr : MANTLE_BORE_COMMODITIES) {
316 b.supply(spec.getId(), curr, 0,
null);
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());
327 text.addPara(pre +
"Increases " + Misc.getAndJoined(commodities) +
" production by %s units.",
328 pad, Misc.getHighlightColor(),
329 "" + MANTLE_BORE_MINING_BONUS);
337 public String[] getSimpleReqs(Industry industry) {
338 return new String [] {NOT_A_GAS_GIANT, NOT_HABITABLE};
341 put(Items.PLASMA_DYNAMO,
new BaseInstallableItemEffect(Items.PLASMA_DYNAMO) {
342 protected Set<String> getAffectedCommodities(Industry industry) {
343 MarketAPI market = industry.getMarket();
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)) {
357 public void apply(Industry industry) {
358 if (industry instanceof BaseIndustry) {
359 BaseIndustry b = (BaseIndustry) industry;
360 Set<String> list = getAffectedCommodities(industry);
362 if (!list.isEmpty()) {
364 for (String curr : list) {
365 b.supply(spec.getId(), curr, PLASMA_DYNAMO_MINING_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
370 public void unapply(Industry industry) {
371 if (industry instanceof BaseIndustry) {
372 BaseIndustry b = (BaseIndustry) industry;
375 for (String curr : PLASMA_DYNAMO_COMMODITIES) {
376 b.supply(spec.getId(), curr, 0,
null);
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());
387 text.addPara(pre +
"Increases " + Misc.getAndJoined(commodities) +
" production by %s units.",
388 pad, Misc.getHighlightColor(),
389 "" + PLASMA_DYNAMO_MINING_BONUS);
397 public String[] getSimpleReqs(Industry industry) {
398 return new String [] {GAS_GIANT};
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);
410 public String[] getSimpleReqs(Industry industry) {
411 return new String [] {HABITABLE};
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);
423 public String[] getSimpleReqs(Industry industry) {
424 return new String [] {NO_ATMOSPHERE};
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()));
432 public void unapply(Industry industry) {
433 industry.getMarket().getAccessibilityMod().unmodifyFlat(spec.getId());
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) +
"%");
442 public String[] getSimpleReqs(Industry industry) {
443 return new String [] {NOT_A_GAS_GIANT, NOT_EXTREME_WEATHER, NOT_EXTREME_TECTONIC_ACTIVITY};
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);
455 public String[] getSimpleReqs(Industry industry) {
456 return new String [] {NO_TRANSPLUTONIC_ORE_DEPOSITS, NO_VOLATILES_DEPOSITS};
459 put(Items.CRYOARITHMETIC_ENGINE,
new BaseInstallableItemEffect(Items.CRYOARITHMETIC_ENGINE) {
460 public void apply(Industry industry) {
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;
467 industry.getMarket().getStats().getDynamic().getMod(Stats.COMBAT_FLEET_SIZE_MULT)
468 .modifyFlat(spec.getId(), bonus, Misc.ucFirst(spec.getName().toLowerCase()));
470 public void unapply(Industry industry) {
471 industry.getMarket().getStats().getDynamic().getMod(Stats.COMBAT_FLEET_SIZE_MULT).unmodifyFlat(spec.getId());
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) +
"%");
482 public String[] getSimpleReqs(Industry industry) {
483 return new String [] {HOT_OR_EXTREME_HEAT};
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()));
491 public void unapply(Industry industry) {
492 industry.getMarket().getStats().getDynamic().getMod(Stats.GROUND_DEFENSES_MOD).unmodifyMult(spec.getId());
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);
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()));
506 public void unapply(Industry industry) {
507 industry.getMarket().getIncomeMult().unmodifyPercent(spec.getId());
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 +
"%");
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()));
522 if (!hasShortage(industry)) {
523 industry.getMarket().getStats().getDynamic().getMod(Stats.MAX_INDUSTRIES).modifyFlat(
524 spec.getId(), CORONAL_TAP_INDUSTRIES);
526 industry.getMarket().getStats().getDynamic().getMod(Stats.MAX_INDUSTRIES).unmodifyFlat(spec.getId());
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());
537 protected boolean hasShortage(Industry industry) {
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;
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);
553 public String[] getSimpleReqs(Industry industry) {
554 return new String [] {CORONAL_TAP_RANGE};