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 float ACCESSIBILITY_BONUS = 0.3f;
13 public static float ACCESSIBILITY_BONUS = 0.1f;
14 public static float ACCESSIBILITY_BONUS_KANTA = 0.1f;
15
16 public PiracyRespite() {
17 }
18
19
20 public static float getBonus() {
21 float bonus = ACCESSIBILITY_BONUS;
22 if (KantaCMD.playerHasProtection()) {
24 }
25 return bonus;
26 }
27
28 public void apply(String id) {
29 String text = Misc.ucFirst(getName().toLowerCase());
30 if (KantaCMD.playerHasProtection()) {
31 text += " (with Kanta's Protection)";
32 }
33 market.getAccessibilityMod().modifyFlat(id, getBonus(), text);
34 }
35
36 public void unapply(String id) {
37 market.getAccessibilityMod().unmodifyFlat(id);
38 }
39
40 @Override
41 public void createTooltipAfterDescription(TooltipMakerAPI tooltip, boolean expanded) {
42 PiracyRespiteScript script = PiracyRespiteScript.get();
43 if (script == null) return;
44
45 Color h = Misc.getHighlightColor();
46
47 float opad = 10f;
48
49 int rem = Math.round(script.getDaysRemaining());
50 String days = rem == 1 ? "day" : "days";
51
52 if (KantaCMD.playerHasProtection()) {
53 tooltip.addPara("Your colonies have %s, resulting in an "
54 + "increased accessibility bonus.", opad, Misc.getPositiveHighlightColor(),
55 "Kanta's Protection");
56 }
57
58 if (rem >= 0) {
59 tooltip.addPara("%s accessibility (%s " + days + " remaining).",
60 opad, h,
61 "+" + (int)Math.round(getBonus() * 100f) + "%", "" + rem);
62 } else {
63 tooltip.addPara("%s accessibility.",
64 opad, h,
65 "+" + (int)Math.round(getBonus() * 100f) + "%");
66 }
67 }
68
69 @Override
70 public boolean hasCustomTooltip() {
71 return true;
72 }
73
74}
75
76
77
78
79
void createTooltipAfterDescription(TooltipMakerAPI tooltip, boolean expanded)