1package com.fs.starfarer.api.impl.campaign.skills;
4import java.util.ArrayList;
5import java.util.Collections;
6import java.util.Comparator;
7import java.util.HashSet;
11import com.fs.starfarer.api.GameState;
12import com.fs.starfarer.api.Global;
13import com.fs.starfarer.api.campaign.AICoreOfficerPlugin;
14import com.fs.starfarer.api.campaign.CampaignFleetAPI;
15import com.fs.starfarer.api.campaign.FleetDataAPI;
16import com.fs.starfarer.api.characters.CustomSkillDescription;
17import com.fs.starfarer.api.characters.FleetTotalItem;
18import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;
19import com.fs.starfarer.api.characters.MutableCharacterStatsAPI.SkillLevelAPI;
20import com.fs.starfarer.api.characters.PersonAPI;
21import com.fs.starfarer.api.characters.SkillSpecAPI;
22import com.fs.starfarer.api.combat.MutableShipStatsAPI;
23import com.fs.starfarer.api.combat.ShipHullSpecAPI.ShipTypeHints;
24import com.fs.starfarer.api.combat.ShipVariantAPI;
25import com.fs.starfarer.api.fleet.FleetMemberAPI;
26import com.fs.starfarer.api.impl.campaign.ids.HullMods;
27import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
28import com.fs.starfarer.api.impl.hullmods.Automated;
29import com.fs.starfarer.api.ui.BaseTooltipCreator;
30import com.fs.starfarer.api.ui.TooltipMakerAPI;
31import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
32import com.fs.starfarer.api.util.Misc;
72 public static enum ThresholdBonusType {
123 String baysStr =
"fighter bays";
124 if (bays == 1) baysStr =
"fighter bay";
126 info.
addPara(
indent +
"Maximum at %s or less fighter bays in fleet, your fleet has %s " + baysStr,
131 info.
addPara(
indent +
"Maximum at %s or less fighter bays in fleet",
146 "" + (
int) threshold,
147 "" + (
int)Math.round(op));
151 "" + (
int) threshold);
157 String opStr =
"points";
158 if (op == 1) opStr =
"point";
159 info.
addPara(
indent +
"Maximum at %s or less total combat ship ordnance points in fleet, your fleet has %s " + opStr,
161 "" + (
int) threshold,
162 "" + (
int)Math.round(op));
164 info.
addPara(
indent +
"Maximum at %s or less total combat ship ordnance points in fleet",
166 "" + (
int) threshold);
176 "" + (
int) threshold,
177 "" + (
int)Math.round(op));
181 "" + (
int) threshold);
189 String opStr =
"points";
190 if (op == 1) opStr =
"point";
191 info.
addPara(
indent +
"Maximum at %s or less total ordnance points in fleet, your fleet has %s " + opStr,
193 "" + (
int) threshold,
194 "" + (
int)Math.round(op));
196 info.
addPara(
indent +
"Maximum at %s or less total ordnance points in fleet",
198 "" + (
int) threshold);
209 "" + (
int)Math.round(op));
220 String opStr =
"points";
221 if (op == 1) opStr =
"point";
222 info.
addPara(
indent +
"Maximum at %s or less total combat phase ship ordnance points in fleet, your fleet has %s " + opStr,
225 "" + (
int)Math.round(op));
227 info.
addPara(
indent +
"Maximum at %s or less total combat phase ship ordnance points in fleet",
237 info.
addPara(
indent +
"Maximum at %s or less total automated ship points*, your fleet's total is %s ",
240 "" + (
int)Math.round(op));
242 info.
addPara(
indent +
"Maximum at %s or less total automated ship points* for fleet",
250 String opStr =
"points";
251 if (op == 1) opStr =
"point";
252 info.
addPara(
indent +
"Maximum at %s or less total automated ship points* in fleet, your fleet has %s " + opStr,
255 "" + (
int)Math.round(op));
257 info.
addPara(
indent +
"Maximum at %s or less total automated ship points* in fleet",
267 info.
addPara(
indent +
"Maximum at %s or less total " +
RECOVERY_COST +
" for ships with Militarized Subsystems, your fleet's total is %s",
270 "" + (
int)Math.round(op));
280 String opStr =
"points";
281 if (op == 1) opStr =
"point";
282 info.
addPara(
indent +
"Maximum at %s or less total ordnance points for ships with Militarized Subsystems, your fleet has %s " + opStr,
285 "" + (
int)Math.round(op));
287 info.
addPara(
indent +
"Maximum at %s or less total ordnance points for ships with Militarized Subsystems",
295 String key,
float maxBonus, ThresholdBonusType type) {
301 String key,
float maxBonus, ThresholdBonusType type) {
305 if (data ==
null)
return maxBonus;
306 if (cStats.
getFleet() ==
null)
return maxBonus;
309 if (bonus !=
null)
return bonus;
311 float currValue = 0f;
312 float threshold = 1f;
314 if (type == ThresholdBonusType.FIGHTER_BAYS) {
317 }
else if (type == ThresholdBonusType.OP) {
320 }
else if (type == ThresholdBonusType.OP_LOW) {
323 }
else if (type == ThresholdBonusType.OP_ALL_LOW) {
326 }
else if (type == ThresholdBonusType.OP_ALL) {
329 }
else if (type == ThresholdBonusType.MILITARIZED_OP) {
332 }
else if (type == ThresholdBonusType.PHASE_OP) {
335 }
else if (type == ThresholdBonusType.AUTOMATED_POINTS) {
355 item.label =
"Total ordnance points";
357 item.label =
"All ships";
363 public void addDescription(
TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
365 tooltip.
addPara(
"The total deployment points of all the ships in your fleet.", 0f);
367 public List<FleetMemberPointContrib> getContributors() {
379 item.label =
"Combat ship ordnance points";
381 item.label =
"Combat ships";
384 item.sortOrder = 100;
387 public void addDescription(
TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
389 tooltip.
addPara(
"The total deployment points of all the combat ships in your fleet.", 0f);
391 public List<FleetMemberPointContrib> getContributors() {
403 item.label =
"Automated ships";
405 item.sortOrder = 350;
408 public void addDescription(
TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
410 tooltip.
addPara(
"The total deployment points of all the automated ships in your fleet, "
411 +
"with additional points for ships controlled by AI cores.", 0f);
413 public List<FleetMemberPointContrib> getContributors() {
425 item.label =
"Phase ship ordnance points";
427 item.label =
"Phase ships";
430 item.sortOrder = 200;
433 public void addDescription(
TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
435 tooltip.
addPara(
"The total deployment points of all the non-civilian phase ships in your fleet.", 0f);
437 public List<FleetMemberPointContrib> getContributors() {
448 item.label =
"Militarized ship ordnance points";
450 item.label =
"Militarized ships";
453 item.sortOrder = 300;
456 public void addDescription(
TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
458 tooltip.
addPara(
"The total deployment points of all the ships in your fleet that have "
459 +
"the \"Militarized Subsystems\" hullmod.", 0f);
461 public List<FleetMemberPointContrib> getContributors() {
472 item.label =
"Fighter bays";
474 item.sortOrder = 400;
477 public void addDescription(
TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
479 tooltip.
addPara(
"The total number of fighter bays in your fleet. Both empty and filled "
480 +
"fighter bays are counted. Built-in fighter bays can be removed from a ship by "
481 +
"installing the \"Converted Fighter Bay\" hullmod.", 0f);
483 public List<FleetMemberPointContrib> getContributors() {
497 public float getTooltipWidth(Object tooltipParam) {
500 @SuppressWarnings(
"unchecked")
501 public void createTooltip(
TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
507 tooltip.
addPara(
"Certain skills will have reduced effects if this value exceeds a "
508 +
"skill-specific threshold; see the specific skill for details. Mothballed "
509 +
"ships are not counted towards the total.", opad);
511 tooltip.
addPara(
"Skills using this value:", opad);
513 List<SkillLevelAPI> skills = (List<SkillLevelAPI>) tooltipParam;
516 float initPad = opad;
518 for (SkillLevelAPI skill : skills) {
519 if (seen.contains(skill))
continue;
521 String label = skill.getSkill().getName() +
" (" + skill.getSkill().getGoverningAptitudeName() +
")";
522 label = skill.getSkill().getGoverningAptitudeName() +
" - " + skill.getSkill().getName();
524 skill.getSkill().getGoverningAptitudeColor(), initPad);
530 Collections.sort(members,
new Comparator<FleetMemberPointContrib>() {
531 public int compare(FleetMemberPointContrib o1, FleetMemberPointContrib o2) {
532 return o2.points - o1.points;
536 tooltip.
addPara(
"Ships contributing to this value:", opad);
539 if (members.isEmpty()) {
541 tooltip.
addPara(
"None", initPad);
544 float gridWidth = 450f;
549 if (members.size() == max + 1) {
550 max = members.size();
552 for (FleetMemberPointContrib member : members) {
557 tooltip.
addToGrid(0, i++, label,
"+" + member.points);
561 if (members.size() > max) {
562 tooltip.
addPara(
"And %s other ships with a smaller contribution.", opad,
579 str +=
" (mothballed)";
586 float bonus = maxBonus * threshold / Math.max(value, threshold);
590 float bonus = maxBonus * threshold / Math.max(value, threshold);
591 if (bonus > 0 && bonus < 1) bonus = 1;
593 if (bonus < maxBonus) {
594 bonus = Math.min(bonus, maxBonus - 1f);
596 bonus = (float) Math.round(bonus);
602 if (stats ==
null || stats.
getFleetMember() ==
null)
return false;
606 if (member ==
null)
return false;
608 return stats !=
null && stats.
getVariant() !=
null &&
613 if (stats ==
null || stats.
getFleetMember() ==
null)
return false;
618 if (member ==
null)
return false;
620 return stats !=
null && stats.
getVariant() !=
null &&
629 if (stats ==
null || stats.
getFleetMember() ==
null)
return false;
634 if (member ==
null)
return false;
653 public static class FleetMemberPointContrib {
656 public FleetMemberPointContrib(
FleetMemberAPI member,
int points) {
658 this.member = member;
659 this.points = points;
667 if (curr.isMothballed())
continue;
670 return Math.round(op);
676 if (curr.isMothballed())
continue;
677 int pts = (int) Math.round(
getPoints(curr, stats));
678 result.add(
new FleetMemberPointContrib(curr, pts));
686 if (curr.isMothballed())
continue;
690 return Math.round(op);
696 if (curr.isMothballed())
continue;
698 int pts = (int) Math.round(
getPoints(curr, stats));
699 result.add(
new FleetMemberPointContrib(curr, pts));
707 if (curr.isMothballed())
continue;
708 if (curr.isPhaseShip()) {
713 return Math.round(op);
719 if (curr.isMothballed())
continue;
720 if (curr.isPhaseShip()) {
722 int pts = (int) Math.round(
getPoints(curr, stats));
723 result.add(
new FleetMemberPointContrib(curr, pts));
732 if (curr.isMothballed())
continue;
736 return Math.round(op);
742 if (curr.isMothballed())
continue;
744 int pts = (int) Math.round(
getPoints(curr, stats));
745 result.add(
new FleetMemberPointContrib(curr, pts));
754 if (curr.isMothballed())
continue;
766 if (slotId ==
null)
continue;
768 if (variant ==
null)
continue;
778 if (curr.isMothballed())
continue;
781 if (pts <= 0)
continue;
782 result.add(
new FleetMemberPointContrib(curr, pts));
790 if (curr.isMothballed())
continue;
797 if (mult == 0) mult = 1;
799 points += Math.round(
getPoints(curr, stats) * mult);
801 return Math.round(points);
807 if (curr.isMothballed())
continue;
811 int pts = (int) Math.round(
getPoints(curr, stats));
815 if (mult == 0) mult = 1;
817 result.add(
new FleetMemberPointContrib(curr, Math.round(pts * mult)));
837 if (member ==
null)
return null;
839 if (commander ==
null) {
840 boolean orig =
false;
850 if (commander !=
null) {
864 if (member ==
null)
return null;
static GameState getCurrentState()
static SectorAPI getSector()
static final String MILITARIZED_SUBSYSTEMS
static final String CIVGRADE
static final String INDENT
static final String BULLET
void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill, TooltipMakerAPI info, float width)
static FleetDataAPI getFleetData(MutableShipStatsAPI stats)
ScopeDescription getScopeDescription()
FleetTotalItem getCombatOPTotal()
static List< FleetMemberPointContrib > getAutomatedPointsDetail(FleetDataAPI data, MutableCharacterStatsAPI stats)
FleetTotalItem getFighterBaysTotal()
void addOPThresholdInfo(TooltipMakerAPI info, FleetDataAPI data, MutableCharacterStatsAPI cStats)
static MutableCharacterStatsAPI getCommanderStats(MutableShipStatsAPI stats)
static float AUTOMATED_POINTS_THRESHOLD
static String RECOVERY_COST
void addPhaseOPThresholdInfo(TooltipMakerAPI info, FleetDataAPI data, MutableCharacterStatsAPI cStats)
static float getTotalOP(FleetDataAPI data, MutableCharacterStatsAPI stats)
static float getPhaseOP(FleetDataAPI data, MutableCharacterStatsAPI stats)
static List< FleetMemberPointContrib > getPhaseOPDetail(FleetDataAPI data, MutableCharacterStatsAPI stats)
void addAutomatedThresholdInfo(TooltipMakerAPI info, FleetDataAPI data, MutableCharacterStatsAPI cStats)
static List< FleetMemberPointContrib > getMilitarizedOPDetail(FleetDataAPI data, MutableCharacterStatsAPI stats)
static boolean hasFighterBays(MutableShipStatsAPI stats)
static List< FleetMemberPointContrib > getTotalOPDetail(FleetDataAPI data, MutableCharacterStatsAPI stats)
static boolean isInCampaign()
static float getMilitarizedOP(FleetDataAPI data, MutableCharacterStatsAPI stats)
static String getValueLabelForMember(FleetMemberAPI member)
static float OP_LOW_THRESHOLD
static boolean isMilitarized(FleetMemberAPI member)
void init(MutableCharacterStatsAPI stats, SkillSpecAPI skill)
static float OP_ALL_LOW_THRESHOLD
static boolean isCivilian(MutableShipStatsAPI stats)
float computeAndCacheThresholdBonus(MutableShipStatsAPI stats, String key, float maxBonus, ThresholdBonusType type)
static float OP_ALL_THRESHOLD
TooltipCreator getTooltipCreator(final TooltipCreatorSkillEffectPlugin plugin)
float getThresholdBasedBonus(float maxBonus, float value, float threshold)
static float getNumFighterBays(FleetDataAPI data)
FleetTotalItem getOPTotal()
FleetTotalItem getPhaseOPTotal()
static List< FleetMemberPointContrib > getNumFighterBaysDetail(FleetDataAPI data)
static boolean USE_RECOVERY_COST
void addOPThresholdInfo(TooltipMakerAPI info, FleetDataAPI data, MutableCharacterStatsAPI cStats, float threshold)
float getThresholdBasedRoundedBonus(float maxBonus, float value, float threshold)
static float TOOLTIP_WIDTH
static boolean isCivilian(FleetMemberAPI member)
static boolean isMilitarized(MutableShipStatsAPI stats)
static float getTotalCombatOP(FleetDataAPI data, MutableCharacterStatsAPI stats)
FleetTotalItem getMilitarizedOPTotal()
static float OP_THRESHOLD
void addMilitarizedOPThresholdInfo(TooltipMakerAPI info, FleetDataAPI data, MutableCharacterStatsAPI cStats)
static float PHASE_OP_THRESHOLD
static float MILITARIZED_OP_THRESHOLD
static boolean hasFighterBays(FleetMemberAPI member)
static float getNumBaysIncludingModules(FleetMemberAPI member)
String getEffectPerLevelDescription()
void initElite(MutableCharacterStatsAPI stats, SkillSpecAPI skill)
boolean hasCustomDescription()
FleetTotalItem getAutomatedPointsTotal()
String getEffectDescription(float level)
void addOPThresholdAll(TooltipMakerAPI info, FleetDataAPI data, MutableCharacterStatsAPI cStats, float threshold)
float computeAndCacheThresholdBonus(FleetDataAPI data, MutableCharacterStatsAPI cStats, String key, float maxBonus, ThresholdBonusType type)
static float getPoints(FleetMemberAPI member, MutableCharacterStatsAPI stats)
static float getAutomatedPoints(FleetDataAPI data, MutableCharacterStatsAPI stats)
static float FIGHTER_BAYS_THRESHOLD
void addFighterBayThresholdInfo(TooltipMakerAPI info, FleetDataAPI data)
static List< FleetMemberPointContrib > getTotalCombatOPDetail(FleetDataAPI data, MutableCharacterStatsAPI stats)
static boolean isAutomatedNoPenalty(MutableShipStatsAPI stats)
static Color getTextColor()
static Color setAlpha(Color color, int alpha)
static boolean isAutomated(MutableShipStatsAPI stats)
static Color getGrayColor()
static Color getHighlightColor()
static String AUTOMATED_POINTS_VALUE
static String AUTOMATED_POINTS_MULT
FleetDataAPI getFleetData()
void setForceNoSync(boolean forceNoSync)
List< FleetMemberAPI > getMembersListCopy()
Map< String, Object > getCacheClearedOnSync()
CampaignFleetAPI getPlayerFleet()
MutableCharacterStatsAPI getPlayerStats()
float getSkillLevel(String id)
CampaignFleetAPI getFleet()
MutableCharacterStatsAPI getStats()
MutableStat getNumFighterBays()
ShipVariantAPI getVariant()
FleetMemberAPI getFleetMember()
String getHullNameWithDashClass()
EnumSet< ShipTypeHints > getHints()
int getOrdnancePoints(MutableCharacterStatsAPI stats)
List< String > getModuleSlots()
ShipVariantAPI getModuleVariant(String slotId)
String getFullDesignationWithHullName()
boolean hasHullMod(String id)
ShipHullSpecAPI getHullSpec()
PersonAPI getFleetCommander()
PersonAPI getFleetCommanderForStats()
ShipVariantAPI getVariant()
FleetDataAPI getFleetData()
float getDeploymentPointsCost()
ShipHullSpecAPI getHullSpec()
MutableShipStatsAPI getStats()
FleetDataAPI getFleetDataForStats()
void addDescription(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam)
List< FleetMemberPointContrib > getContributors()