Starsector API
Loading...
Searching...
No Matches
PiracyRespite.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.econ;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.impl.campaign.intel.events.PiracyRespiteScript;
6import com.fs.starfarer.api.impl.campaign.rulecmd.KantaCMD;
7import com.fs.starfarer.api.ui.TooltipMakerAPI;
8import com.fs.starfarer.api.util.Misc;
9
11
12 public static boolean NEW_MODE = true;
13 //public static float ACCESSIBILITY_BONUS = 0.3f;
14 public static float ACCESSIBILITY_BONUS = 0.1f;
15 public static float ACCESSIBILITY_BONUS_KANTA = 0.1f;
16
17 public PiracyRespite() {
18 }
19
20
21 public static float getBonus() {
22 float bonus = ACCESSIBILITY_BONUS;
25 }
26 return bonus;
27 }
28
29 public void apply(String id) {
30 if (NEW_MODE) return;
31 String text = Misc.ucFirst(getName().toLowerCase());
33 text += " (with Kanta's Protection)";
34 }
36 }
37
38 public void unapply(String id) {
39 if (NEW_MODE) return;
41 }
42
43 @Override
44 public void createTooltipAfterDescription(TooltipMakerAPI tooltip, boolean expanded) {
46 if (script == null) return;
47
48 Color h = Misc.getHighlightColor();
49
50 float opad = 10f;
51
52 if (NEW_MODE) {
54 tooltip.addPara("Your colonies have %s, and pirates are wary of "
55 + "attacking trade fleets serving them lest they attract her wrath. "
56 + "Shipping disruptions from piracy are virtually eliminated.", opad, Misc.getPositiveHighlightColor(),
57 "Kanta's Protection");
58 } else {
59 tooltip.addPara("You've defeated a large armada sent against your colonies, and pirates are wary of "
60 + "attacking trade fleets serving them, "
61 + "resulting in a greatly reduced number of shipping disruptions.", opad);
62 }
63 } else {
64 int rem = Math.round(script.getDaysRemaining());
65 String days = rem == 1 ? "day" : "days";
66
68 tooltip.addPara("Your colonies have %s, resulting in an "
69 + "increased accessibility bonus.", opad, Misc.getPositiveHighlightColor(),
70 "Kanta's Protection");
71 }
72
73 if (rem >= 0) {
74 tooltip.addPara("%s accessibility (%s " + days + " remaining).",
75 opad, h,
76 "+" + (int)Math.round(getBonus() * 100f) + "%", "" + rem);
77 } else {
78 tooltip.addPara("%s accessibility.",
79 opad, h,
80 "+" + (int)Math.round(getBonus() * 100f) + "%");
81 }
82 }
83 }
84
85 @Override
86 public boolean hasCustomTooltip() {
87 return true;
88 }
89
90}
91
92
93
94
95
void modifyFlat(String source, float value)
void createTooltipAfterDescription(TooltipMakerAPI tooltip, boolean expanded)
static String ucFirst(String str)
Definition Misc.java:559
static Color getHighlightColor()
Definition Misc.java:792
static Color getPositiveHighlightColor()
Definition Misc.java:822
LabelAPI addPara(String format, float pad, Color hl, String... highlights)