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