Starsector API
Loading...
Searching...
No Matches
HegemonyAICoresActivityCause.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.events;
2
3import java.awt.Color;
4import java.util.List;
5
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.campaign.StarSystemAPI;
8import com.fs.starfarer.api.campaign.econ.Industry;
9import com.fs.starfarer.api.campaign.econ.MarketAPI;
10import com.fs.starfarer.api.impl.campaign.ids.Commodities;
11import com.fs.starfarer.api.impl.campaign.ids.Factions;
12import com.fs.starfarer.api.impl.campaign.intel.PerseanLeagueMembership;
13import com.fs.starfarer.api.ui.LabelAPI;
14import com.fs.starfarer.api.ui.TooltipMakerAPI;
15import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
16import com.fs.starfarer.api.util.Misc;
17
19
20 public static int IGNORE_COLONY_THRESHOLD = 3;
21
22
26
27 @Override
28 public TooltipCreator getTooltip() {
29 return new BaseFactorTooltip() {
30 public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) {
31 float opad = 10f;
32 tooltip.addPara("The Hegemony considers the use of %s illegal, though it is unlikely "
33 + "to take much notice of what goes on at colonies of size %s or smaller.", 0f,
34 Misc.getHighlightColor(), "AI cores", "" + IGNORE_COLONY_THRESHOLD);
35
37 Color c = Global.getSector().getFaction(Factions.PERSEAN).getBaseUIColor();
38 LabelAPI label = tooltip.addPara("However, your membership in the Persean League makes it politically "
39 + "difficult for the Hegemony to pursue the matter.", opad);
40 label.setHighlight("Persean League", "politically difficult");
41 label.setHighlightColors(c, Misc.getPositiveHighlightColor());
42 }
43 }
44 };
45 }
46
47 public boolean isNegatedByPLMembership() {
48 //if (true) return true;
50 }
51
52 @Override
53 public String getProgressStr() {
55 return super.getProgressStr();
56 }
57
58 @Override
60 if (isNegatedByPLMembership()) return Misc.getPositiveHighlightColor();
61 return super.getProgressColor(intel);
62 }
63
64 @Override
65 public boolean shouldShow() {
66 return getProgress() != 0 || isNegatedByPLMembership();
67 }
68
69 public int getProgress() {
70 return getProgress(true);
71 }
72 public int getProgress(boolean checkNegated) {
74 if (checkNegated && isNegatedByPLMembership()) return 0;
75
76 int progress = (int) Math.round(getTotalAICorePoints());
77
78 float unit = Global.getSettings().getFloat("hegemonyProgressUnit");
79 float mult = Global.getSettings().getFloat("hegemonyProgressMult");
80 //progress = 200;
81 int rem = progress;
82 float adjusted = 0;
83 while (rem > unit) {
84 adjusted += unit;
85 rem -= unit;
86 rem *= mult;
87 }
88 adjusted += rem;
89
90 int reduced = Math.round(adjusted);
91 if (progress > 0 && reduced < 1) reduced = 1;
92 progress = reduced;
93
94// int reduced = (int) Math.round(Math.pow(progress, 0.8f));
95// if (progress > 0 && reduced <= 0) reduced = 1;
96// progress = reduced;
97
98 return progress;
99 }
100
101 public String getDesc() {
102 return "AI core use";
103 }
104
105 public float getTotalAICorePoints() {
106 float total = 0f;
107 for (StarSystemAPI system : Misc.getPlayerSystems(false)) {
108 total += getAICorePoints(system);
109 }
110 return total;
111 }
112
113 public static float getAICorePoints(StarSystemAPI system) {
114 float total = 0f;
115 List<MarketAPI> markets = Misc.getMarketsInLocation(system, Factions.PLAYER);
116 for (MarketAPI market : markets) {
117 if (market.getSize() <= IGNORE_COLONY_THRESHOLD) continue;
118 float interest = getAICorePoints(market);
119 total += interest;
120 }
121 return total;
122 }
123
124 public static float getAICorePoints(MarketAPI market) {
125 float total = 0f;
126
127 float admin = Global.getSettings().getFloat("hegemonyPointsAdmin");
128 float alpha = Global.getSettings().getFloat("hegemonyPointsAlpha");
129 float beta = Global.getSettings().getFloat("hegemonyPointsBeta");
130 float gamma = Global.getSettings().getFloat("hegemonyPointsGamma");
131
132 String aiCoreId = market.getAdmin().getAICoreId();
133 if (aiCoreId != null) {
134 total += admin;
135 }
136
137 for (Industry ind : market.getIndustries()) {
138 String core = ind.getAICoreId();
139 if (Commodities.ALPHA_CORE.equals(core)) {
140 total += alpha;
141 } else if (Commodities.BETA_CORE.equals(core)) {
142 total += beta;
143 } else if (Commodities.GAMMA_CORE.equals(core)) {
144 total += gamma;
145 }
146 }
147
148 return total;
149 }
150
151 public float getMagnitudeContribution(StarSystemAPI system) {
153 if (isNegatedByPLMembership()) return 0f;
154
155 if (getProgress() <= 0) return 0f;
156
157 List<MarketAPI> markets = Misc.getMarketsInLocation(system, Factions.PLAYER);
158
159 float perAICorePoint = Global.getSettings().getFloat("hegemonyPerAICorePoint");
160
161 float total = 0f;
162 for (MarketAPI market : markets) {
163 float points = getAICorePoints(market);
164 total += points;
165 }
166
167 total = Math.round(total * 100f) / 100f;
168
169 return total;
170 }
171
172}
static SettingsAPI getSettings()
Definition Global.java:51
static SectorAPI getSector()
Definition Global.java:59