Starsector API
Loading...
Searching...
No Matches
StandardPerseanLeagueActivityCause.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.events;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.campaign.StarSystemAPI;
6import com.fs.starfarer.api.campaign.econ.MarketAPI;
7import com.fs.starfarer.api.impl.campaign.intel.PerseanLeagueMembership;
8import com.fs.starfarer.api.impl.campaign.rulecmd.HA_CMD;
9import com.fs.starfarer.api.ui.MapParams;
10import com.fs.starfarer.api.ui.TooltipMakerAPI;
11import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
12import com.fs.starfarer.api.ui.UIPanelAPI;
13import com.fs.starfarer.api.util.Misc;
14
16
18 public static int LARGE_COLONY = 5;
19 public static int MEDIUM_COLONY = 4;
20 public static int COUNT_IF_MEDIUM = 2;
21
22 public static float MAX_MAG = 0.5f;
23
27
28 @Override
29 public TooltipCreator getTooltip() {
30 return new BaseFactorTooltip() {
31 public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) {
32 float opad = 10f;
33 tooltip.addPara("Going to Kazeron and negotiating to join the League is likely to get "
34 + "this harassment to stop. If "
35 + "left unchecked, this low-grade conflict will eventually come to a head and is likely to "
36 + "be resolved one way or another.", 0f, Misc.getHighlightColor(),
37 "join the League");
38
39 tooltip.addPara("Event progress value is based on the number and size of colonies "
40 + "under your control. Requires one size %s colony, or at least %s colonies with one "
41 + "being at least size %s.", opad, Misc.getHighlightColor(),
43
44 MarketAPI kazeron = PerseanLeagueHostileActivityFactor.getKazeron(false);
45 if (kazeron != null && kazeron.getStarSystem() != null) {
46// tooltip.addPara("%s, size: %s, stability: %s", opad, Misc.getHighlightColor(),
47// kazeron.getName(),
48// "" + kazeron.getSize(),
49// "" + (int) kazeron.getStabilityValue());
50
51 MapParams params = new MapParams();
52 params.showSystem(kazeron.getStarSystem());
53 float w = tooltip.getWidthSoFar();
54 float h = Math.round(w / 1.6f);
55 params.positionToShowAllMarkersAndSystems(true, Math.min(w, h));
56 UIPanelAPI map = tooltip.createSectorMap(w, h, params, kazeron.getName() + " (" + kazeron.getStarSystem().getNameWithLowercaseTypeShort() + ")");
57 tooltip.addCustom(map, opad);
58 }
59 }
60 };
61 }
62
63 @Override
64 public boolean shouldShow() {
65 return getProgress() != 0;
66 }
67
68 @Override
69 public String getProgressStr() {
70 //if (KantaCMD.playerHasProtection()) return EventFactor.NEGATED_FACTOR_PROGRESS;
71 return super.getProgressStr();
72 }
73
74 @Override
76 //if (KantaCMD.playerHasProtection()) return Misc.getPositiveHighlightColor();
77 // TODO Auto-generated method stub
78 return super.getProgressColor(intel);
79 }
80
81 public int getProgress() {
82 //if (true) return 0;
83 if (!HA_CMD.canPlayerJoinTheLeague()) {
84 return 0;
85 }
86
87// if (Global.getSector().getPlayerMemoryWithoutUpdate().getBoolean(
88// PerseanLeagueHostileActivityFactor.DEFEATED_BLOCKADE)) {
90 return 0;
91 }
92
93 int score = 0;
94 for (MarketAPI market : Misc.getPlayerMarkets(false)) {
95 int size = market.getSize();
96// if (size <= 4) {
97// score += size * 2;
98// } else if (size == 5) {
99// score += size * 2 + 2;
100// } else if (size == 6) {
101// score += size * 2 + 4;
102// } else {
103// score += size * 3;
104// }
105 if (size <= 4) {
106 score += size;
107 } else if (size == 5) {
108 score += size + 2;
109 } else if (size == 6) {
110 score += size + 4;
111 } else {
112 score += size + 6;
113 }
114 }
115
116 int progress = score;
117
118 return progress;
119 }
120
121
122 public String getDesc() {
123 return "Colony presence and size";
124 }
125
126
127 public float getMagnitudeContribution(StarSystemAPI system) {
128 //if (KantaCMD.playerHasProtection()) return 0f;
129 if (getProgress() <= 0) return 0f;
130
131 return (0.4f + 0.6f * intel.getMarketPresenceFactor(system)) * MAX_MAG;
132 }
133
134}
135
136
137
138
139
140