42 public static List<PSToggleButtonRowData>
OTHER_FACTORS =
new ArrayList<>();
49 public static interface PlanetFilter {
51 public boolean shouldShow();
52 default String getOtherFactorId() {
55 default String getOtherFactorButtonText() {
59 public void createTooltip(
TooltipMakerAPI info,
float width, String param);
60 default float getTooltipWidth() {
63 default boolean isTooltipExpandable() {
66 default boolean hasTooltip() {
80 public static class MarketConditionData
implements PlanetFilter {
82 public String conditionId;
84 public boolean reqSurvey;
85 public MarketConditionData(String conditionId) {
86 this.id =
"ps_mc_" + conditionId;
87 this.conditionId = conditionId;
95 String selected = params.get(
id);
96 if (selected ==
null)
return true;
98 if (entity.
getMarket() ==
null)
return false;
113 public void createTooltip(TooltipMakerAPI info,
float width, String param) {
116 String name = spec.
getName().toLowerCase();
117 info.addPara(
"Require " + Misc.getAOrAnFor(name) +
" " + name +
" to be present.", opad);
118 info.setCodexEntryId(CodexDataV2.getConditionEntryId(conditionId));
122 public boolean shouldShow() {
127 public static class ColonyItemData
implements PlanetFilter {
129 public String itemId;
130 public SpecialItemSpecAPI item;
131 public ColonyItemData(String itemId) {
132 this.id =
"ps_item_" + itemId;
133 this.itemId = itemId;
135 item = Global.getSettings().getSpecialItemSpec(itemId);
139 public boolean accept(SectorEntityToken entity, Map<String, String> params) {
140 String selected = params.get(
id);
141 if (selected ==
null)
return true;
143 if (entity.getMarket() ==
null)
return false;
145 if (itemId.equals(Items.CORONAL_PORTAL)) {
146 Pair<SectorEntityToken, Float> p = PopulationAndInfrastructure.getNearestCoronalTap(entity.getLocationInHyperspace(),
false,
true);
147 if (p ==
null || p.two > ItemEffectsRepo.CORONAL_TAP_LIGHT_YEARS)
return false;
155 if (itemId.equals(Items.ORBITAL_FUSION_LAMP)) {
156 for (String
id : ItemEffectsRepo.FUSION_LAMP_CONDITIONS) {
157 if (entity.getMarket().hasCondition(
id))
return true;
162 InstallableItemEffect effect = ItemEffectsRepo.ITEM_EFFECTS.get(itemId);
164 BaseIndustry fake =
new Farming();
165 fake.setMarket(entity.getMarket());
167 return effect.getUnmetRequirements(fake,
true).isEmpty();
171 public boolean shouldShow() {
172 if (itemId.equals(Items.CORONAL_PORTAL)) {
173 for (IntelInfoPlugin intel : Global.getSector().getIntelManager().getIntel(HypershuntIntel.class)) {
174 HypershuntIntel hypershunt = (HypershuntIntel) intel;
175 if (hypershunt.defendersDefeated())
return true;
179 return SharedUnlockData.get().isPlayerAwareOfSpecialItem(itemId);
183 public void createTooltip(TooltipMakerAPI info,
float width, String param) {
188 SpecialItemPlugin plugin = item.getNewPluginInstance(
null);
189 if (plugin instanceof GenericSpecialItemPlugin) {
190 ((GenericSpecialItemPlugin) plugin).setTooltipIsForPlanetSearch(
true);
192 plugin.createTooltip(info,
false,
null,
null);
193 if (plugin instanceof GenericSpecialItemPlugin) {
194 ((GenericSpecialItemPlugin) plugin).setTooltipIsForPlanetSearch(
false);
197 info.setCodexEntryId(CodexDataV2.getItemEntryId(item.getId()));
201 public float getTooltipWidth() {
202 return item.getNewPluginInstance(
null).getTooltipWidth();
206 public boolean isTooltipExpandable() {
207 return item.getNewPluginInstance(
null).isTooltipExpandable();
212 public static class ResourceDepositsData
implements PlanetFilter {
215 public String idNone;
217 public String iconNone = Global.getSettings().getSpriteName(
"intel",
"planet_search_none");
218 public String iconAny = Global.getSettings().getSpriteName(
"intel",
"planet_search_any");
219 public List<String> conditions =
new ArrayList<>();
220 public ResourceDepositsData(String
id, String title) {
222 this.idAny =
id +
"_any";
223 this.idNone =
id +
"_none";
228 public boolean accept(SectorEntityToken entity, Map<String, String> params) {
229 String selected = params.get(
id);
230 if (selected ==
null)
return true;
232 if (idAny.equals(selected)) {
235 if (entity.getMarket() ==
null) {
239 MarketAPI market = entity.getMarket();
240 if (market.getSurveyLevel() != SurveyLevel.FULL) {
245 if (idNone.equals(selected)) {
246 for (String cid : conditions) {
247 if (market.hasCondition(cid)) {
253 boolean foundAtLeastSelected =
false;
254 for (String cid : conditions) {
255 if (cid.equals(selected)) {
256 foundAtLeastSelected =
true;
258 if (foundAtLeastSelected && market.hasCondition(cid)) {
267 public boolean shouldShow() {
272 public void createTooltip(TooltipMakerAPI info,
float width, String param) {
274 if (param == idAny) {
275 info.addTitle(title +
" not required");
276 info.addPara(
"Disregard the presence or absence of " + title.toLowerCase() +
" on the planet, both are acceptable.", opad);
277 }
else if (param == idNone) {
278 info.addTitle(
"No " + title.toLowerCase());
279 info.addPara(
"Require that no " + title.toLowerCase() +
" be present on the planet.", opad);
280 }
else if (conditions.contains(param)) {
281 MarketConditionSpecAPI spec = Global.getSettings().getMarketConditionSpec(param);
283 info.addTitle(spec.getName());
284 info.addPara(
"Require " + spec.getName().toLowerCase() +
" or better.", opad);
285 info.setCodexEntryId(CodexDataV2.getConditionEntryId(param));
291 public static enum PSToggleButtonRowMode {
296 public static class PSToggleButtonData {
299 public boolean defaultState =
false;
301 public PSToggleButtonData(String
id, String text,
boolean defaultState) {
304 this.defaultState = defaultState;
308 public static class PSToggleButtonRowData
implements PlanetFilter {
311 public PSToggleButtonRowMode mode;
312 public List<PSToggleButtonData> buttons =
new ArrayList<>();
313 public float prevPad = 0f;
314 public PSToggleButtonRowData(String
id, String title, PSToggleButtonRowMode mode) {
320 public void add(String
id, String text,
boolean defaultState) {
321 buttons.add(
new PSToggleButtonData(
id, text, defaultState));
325 public boolean accept(SectorEntityToken entity, Map<String, String> params) {
330 public boolean shouldShow() {
334 public void createTooltip(TooltipMakerAPI info,
float width, String param) {
340 PSToggleButtonRowData type =
new PSToggleButtonRowData(
"type",
null, PSToggleButtonRowMode.ANY) {
342 public boolean accept(SectorEntityToken entity, Map<String, String> params) {
343 if (params.containsKey(
"stars") && entity.isStar()) {
346 if (params.containsKey(
"gas_giants") &&
347 entity instanceof PlanetAPI && ((PlanetAPI)entity).isGasGiant()) {
350 if (params.containsKey(
"planets") && !entity.isStar() &&
351 !(entity instanceof PlanetAPI && ((PlanetAPI)entity).isGasGiant())) {
357 public void createTooltip(TooltipMakerAPI info,
float width, String param) {
359 if (param.equals(
"stars")) {
360 info.addTitle(
"Stars");
361 info.addPara(
"Show stars and black holes.", opad);
362 }
else if (param.equals(
"gas_giants")) {
363 info.addTitle(
"Gas giants");
364 info.addPara(
"Show gas giants.", opad);
365 }
else if (param.equals(
"planets")) {
366 info.addTitle(
"Planets");
367 info.addPara(
"Show non-gas-giant planets and stations.", opad);
372 type.add(
"stars",
"Stars",
false);
373 type.add(
"gas_giants",
"Gas giants",
true);
374 type.add(
"planets",
"Planets",
true);
376 PSToggleButtonRowData populated =
new PSToggleButtonRowData(
"populated",
null, PSToggleButtonRowMode.ANY) {
378 public boolean accept(SectorEntityToken entity, Map<String, String> params) {
379 boolean conditionMarketOnly =
true;
380 if (entity.getMarket() !=
null) {
381 conditionMarketOnly = entity.getMarket().isPlanetConditionMarketOnly();
383 if (params.containsKey(
"populated") && !conditionMarketOnly) {
386 if (params.containsKey(
"claimed") && conditionMarketOnly) {
387 FactionAPI claimedBy = Misc.getClaimingFaction(entity);
388 if (claimedBy !=
null)
return true;
390 if (params.containsKey(
"unclaimed") && conditionMarketOnly) {
391 FactionAPI claimedBy = Misc.getClaimingFaction(entity);
392 if (claimedBy ==
null)
return true;
397 public void createTooltip(TooltipMakerAPI info,
float width, String param) {
399 if (param.equals(
"populated")) {
400 info.addTitle(
"Populated");
401 info.addPara(
"Show populated planets.", opad);
402 }
else if (param.equals(
"claimed")) {
403 info.addTitle(
"Claimed");
404 info.addPara(
"Show uninhabited planets that are in a system claimed by a faction.", opad);
405 info.addPara(
"Colonization is inadvisable.", opad);
406 }
else if (param.equals(
"unclaimed")) {
407 info.addTitle(
"Unclaimed");
408 info.addPara(
"Show uninhabited and unclaimed planets.", opad);
412 populated.add(
"populated",
"Populated",
false);
413 populated.add(
"claimed",
"Claimed",
false);
414 populated.add(
"unclaimed",
"Unclaimed",
true);
416 PSToggleButtonRowData surveyed =
new PSToggleButtonRowData(
"surveyed",
null, PSToggleButtonRowMode.ANY) {
418 public boolean accept(SectorEntityToken entity, Map<String, String> params) {
419 if (entity.getMarket() ==
null) {
420 if (entity.isStar())
return true;
423 if (params.containsKey(
"surveyed") && entity.getMarket().getSurveyLevel() == SurveyLevel.FULL) {
426 if (params.containsKey(
"unsurveyed") && entity.getMarket().getSurveyLevel() != SurveyLevel.FULL) {
432 public void createTooltip(TooltipMakerAPI info,
float width, String param) {
434 if (param.equals(
"surveyed")) {
435 info.addTitle(
"Surveyed");
436 info.addPara(
"Show fully surveyed planets.", opad);
437 }
else if (param.equals(
"unsurveyed")) {
438 info.addTitle(
"Unsurveyed");
439 info.addPara(
"Show planets that have not been fully surveyed.", opad);
443 surveyed.add(
"surveyed",
"Surveyed",
true);
444 surveyed.add(
"unsurveyed",
"Unsurveyed",
true);
446 PSToggleButtonRowData hazard =
new PSToggleButtonRowData(
"hazard",
"Hazard rating", PSToggleButtonRowMode.ONE) {
448 public boolean accept(SectorEntityToken entity, Map<String, String> params) {
449 if (entity.getMarket() ==
null) {
450 if (entity.isStar() && params.containsKey(
"haz_any"))
return true;
454 if (entity.getMarket().getSurveyLevel() != SurveyLevel.FULL &&
455 !params.containsKey(
"haz_any")) {
459 float hazard = entity.getMarket().getHazardValue();
460 hazard = Math.round(hazard * 100f) / 100f;
462 float test = 1000000f;
463 if (params.containsKey(
"haz_1")) test = 1f;
464 if (params.containsKey(
"haz_2")) test = 1.5f;
465 if (params.containsKey(
"haz_3")) test = 2f;
467 return hazard <= test;
470 public void createTooltip(TooltipMakerAPI info,
float width, String param) {
472 Color h = Misc.getHighlightColor();
473 info.addTitle(
"Hazard rating");
474 if (param.equals(
"haz_any")) {
475 info.addPara(
"Do not filter out any planets based on their hazard rating.", opad);
478 if (param.equals(
"haz_1")) {
480 }
else if (param.equals(
"haz_2")) {
482 }
else if (param.equals(
"haz_3")) {
485 info.addPara(
"Only show planets with a hazard rating of %s or lower.", opad, h, rating);
489 hazard.add(
"haz_any",
"Any",
true);
490 hazard.add(
"haz_1",
"100%-",
false);
491 hazard.add(
"haz_2",
"150%-",
false);
492 hazard.add(
"haz_3",
"200%-",
false);
495 PSToggleButtonRowData stablePoints =
new PSToggleButtonRowData(
"stable_locs",
"Stable locations", PSToggleButtonRowMode.ONE) {
497 public boolean accept(SectorEntityToken entity, Map<String, String> params) {
498 StarSystemAPI system = entity.getStarSystem();
499 if (system ==
null)
return false;
501 String key =
"$core_ps_stableLocations";
503 if (system.getMemoryWithoutUpdate().contains(key)) {
504 num = system.getMemoryWithoutUpdate().getInt(key);
506 num = Misc.getNumStableLocations(entity.getStarSystem());
507 system.getMemoryWithoutUpdate().set(key, num, 0f);
511 if (params.containsKey(
"stable_1")) test = 1;
512 if (params.containsKey(
"stable_2")) test = 2;
513 if (params.containsKey(
"stable_3")) test = 3;
518 public void createTooltip(TooltipMakerAPI info,
float width, String param) {
520 Color h = Misc.getHighlightColor();
521 info.addTitle(
"Stable locations");
522 if (param.equals(
"stable_0")) {
523 info.addPara(
"Do not filter out any planets based on the number of stable locations in the star system they are in.", opad);
526 if (param.equals(
"stable_1")) {
528 }
else if (param.equals(
"stable_2")) {
530 }
else if (param.equals(
"stable_3")) {
533 info.addPara(
"Only show planets with %s or more stable locations in the star system they're in,"
534 +
" including locations already in use by objectives or similar.", opad, h, locs);
538 stablePoints.add(
"stable_0",
"Any",
true);
539 stablePoints.add(
"stable_1",
"1+",
false);
540 stablePoints.add(
"stable_2",
"2+",
false);
541 stablePoints.add(
"stable_3",
"3+",
false);
542 stablePoints.prevPad = 2f;
545 ResourceDepositsData ore =
new ResourceDepositsData(
"ore",
"Ore");
546 ore.conditions.add(Conditions.ORE_SPARSE);
547 ore.conditions.add(Conditions.ORE_MODERATE);
548 ore.conditions.add(Conditions.ORE_ABUNDANT);
549 ore.conditions.add(Conditions.ORE_RICH);
550 ore.conditions.add(Conditions.ORE_ULTRARICH);
552 ResourceDepositsData rareOre =
new ResourceDepositsData(
"rare_ore",
"Transplutonic ore");
553 rareOre.conditions.add(Conditions.RARE_ORE_SPARSE);
554 rareOre.conditions.add(Conditions.RARE_ORE_MODERATE);
555 rareOre.conditions.add(Conditions.RARE_ORE_ABUNDANT);
556 rareOre.conditions.add(Conditions.RARE_ORE_RICH);
557 rareOre.conditions.add(Conditions.RARE_ORE_ULTRARICH);
559 ResourceDepositsData volatiles =
new ResourceDepositsData(
"volatiles",
"Volatiles");
560 volatiles.conditions.add(Conditions.VOLATILES_TRACE);
561 volatiles.conditions.add(Conditions.VOLATILES_DIFFUSE);
562 volatiles.conditions.add(Conditions.VOLATILES_ABUNDANT);
563 volatiles.conditions.add(Conditions.VOLATILES_PLENTIFUL);
565 ResourceDepositsData organics =
new ResourceDepositsData(
"organics",
"Organics");
566 organics.conditions.add(Conditions.ORGANICS_TRACE);
567 organics.conditions.add(Conditions.ORGANICS_COMMON);
568 organics.conditions.add(Conditions.ORGANICS_ABUNDANT);
569 organics.conditions.add(Conditions.ORGANICS_PLENTIFUL);
571 ResourceDepositsData farmland =
new ResourceDepositsData(
"farmland",
"Farmland");
572 farmland.conditions.add(Conditions.FARMLAND_POOR);
573 farmland.conditions.add(Conditions.FARMLAND_ADEQUATE);
574 farmland.conditions.add(Conditions.FARMLAND_RICH);
575 farmland.conditions.add(Conditions.FARMLAND_BOUNTIFUL);
577 ResourceDepositsData ruins =
new ResourceDepositsData(
"ruins",
"Ruins");
578 ruins.conditions.add(Conditions.RUINS_SCATTERED);
579 ruins.conditions.add(Conditions.RUINS_WIDESPREAD);
580 ruins.conditions.add(Conditions.RUINS_EXTENSIVE);
581 ruins.conditions.add(Conditions.RUINS_VAST);
584 ResourceDepositsData hab =
new ResourceDepositsData(
"habitable",
"Hab");
585 hab.conditions.add(Conditions.HABITABLE);
587 ResourceDepositsData cold =
new ResourceDepositsData(
"cold",
"Cold");
588 cold.conditions.add(Conditions.COLD);
589 cold.conditions.add(Conditions.VERY_COLD);
591 ResourceDepositsData heat =
new ResourceDepositsData(
"heat",
"Heat");
592 heat.conditions.add(Conditions.HOT);
593 heat.conditions.add(Conditions.VERY_HOT);
595 ResourceDepositsData atmo =
new ResourceDepositsData(
"atmo",
"Atmo");
596 atmo.conditions.add(Conditions.NO_ATMOSPHERE);
598 ResourceDepositsData weather =
new ResourceDepositsData(
"weather",
"Wthr");
599 weather.conditions.add(Conditions.EXTREME_WEATHER);
601 ResourceDepositsData darkness =
new ResourceDepositsData(
"darkness",
"Dark");
602 darkness.conditions.add(Conditions.POOR_LIGHT);
603 darkness.conditions.add(Conditions.DARK);
605 ResourceDepositsData tectonics =
new ResourceDepositsData(
"tectonics",
"Tect");
606 tectonics.conditions.add(Conditions.TECTONIC_ACTIVITY);
607 tectonics.conditions.add(Conditions.EXTREME_TECTONIC_ACTIVITY);
707 List<SpecialItemSpecAPI> items =
new ArrayList<>();
708 for (SpecialItemSpecAPI spec : Global.getSettings().getAllSpecialItemSpecs()) {
709 if (spec.hasTag(Tags.PLANET_SEARCH)) {
713 Collections.sort(items, (s1, s2) -> s1.getName().compareTo(s2.getName()));
717 List<MarketConditionSpecAPI> conditions =
new ArrayList<>();
718 for (MarketConditionSpecAPI spec : Global.getSettings().getAllMarketConditionSpecs()) {
719 if (spec.hasTag(Tags.PLANET_SEARCH)) {
720 conditions.add(spec);
723 Collections.sort(conditions, (c1, c2) -> c1.getName().compareTo(c2.getName()));