1package com.fs.starfarer.api.impl.campaign;
4import java.util.HashMap;
7import com.fs.starfarer.api.GameState;
8import com.fs.starfarer.api.Global;
9import com.fs.starfarer.api.campaign.CampaignFleetAPI;
10import com.fs.starfarer.api.combat.BaseHullMod;
11import com.fs.starfarer.api.combat.MutableShipStatsAPI;
12import com.fs.starfarer.api.combat.ShipAPI;
13import com.fs.starfarer.api.combat.ShipAPI.HullSize;
14import com.fs.starfarer.api.fleet.FleetMemberAPI;
15import com.fs.starfarer.api.impl.campaign.ids.Stats;
16import com.fs.starfarer.api.ui.LabelAPI;
17import com.fs.starfarer.api.ui.TooltipMakerAPI;
18import com.fs.starfarer.api.util.Misc;
22 private static Map mag =
new HashMap();
24 mag.put(HullSize.FRIGATE, 10f);
25 mag.put(HullSize.DESTROYER, 25f);
26 mag.put(HullSize.CRUISER, 30f);
27 mag.put(HullSize.CAPITAL_SHIP, 40f);
31 public static final float MIN_CR = 0.1f;
35 stats.getDynamic().getMod(Stats.SALVAGE_VALUE_MULT_MOD).modifyFlat(
id, (Float) mag.get(hullSize) * 0.01f);
43 if (index == 0)
return "" + ((Float) mag.get(HullSize.FRIGATE)).intValue() +
"%";
44 if (index == 1)
return "" + ((Float) mag.get(HullSize.DESTROYER)).intValue() +
"%";
45 if (index == 2)
return "" + ((Float) mag.get(HullSize.CRUISER)).intValue() +
"%";
46 if (index == 3)
return "" + ((Float) mag.get(HullSize.CAPITAL_SHIP)).intValue() +
"%";
64 public void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship,
float width,
boolean isForModSpec) {
67 Color h = Misc.getHighlightColor();
68 Color bad = Misc.getNegativeHighlightColor();
70 tooltip.addPara(
"Each additional ship with a salvage gantry provides diminishing returns. " +
71 "The higher the highest recovery bonus from a single ship in the fleet, the later diminishing returns kick in.", opad);
73 if (isForModSpec || ship ==
null)
return;
78 float currShipMod = (Float) mag.get(hullSize) * 0.01f;
83 tooltip.addPara(
"The total resource recovery bonus for your fleet is %s.", opad, h,
84 "" + (
int)Math.round(fleetMod * 100f) +
"%");
86 float cr = ship.getCurrentCR();
87 for (FleetMemberAPI member :
Global.
getSector().getPlayerFleet().getFleetData().getMembersListCopy()) {
88 if (member.getId().equals(ship.getFleetMemberId())) {
89 cr = member.getRepairTracker().getCR();
94 LabelAPI label = tooltip.addPara(
"This ship's combat readiness is below %s " +
95 "and the gantry can not be utilized. Bringing this ship into readiness " +
96 "would increase the fleetwide bonus to %s.",
98 "" + (
int) Math.round(
MIN_CR * 100f) +
"%",
99 "" + (int)Math.round(fleetModWithOneMore * 100f) +
"%");
100 label.setHighlightColors(bad, h);
101 label.setHighlight(
"" + (
int) Math.round(
MIN_CR * 100f) +
"%",
"" + (int)Math.round(fleetModWithOneMore * 100f) +
"%");
107 if (fleetMod > currShipMod) {
108 tooltip.addPara(
"Removing this ship would decrease it to %s. Adding another ship of the same type " +
109 "would increase it to %s.", opad, h,
110 "" + (
int)Math.round(fleetModWithoutThisShip * 100f) +
"%",
111 "" + (int)Math.round(fleetModWithOneMore * 100f) +
"%");
113 tooltip.addPara(
"Adding another ship of the same type " +
114 "would increase it to %s.", opad, h,
115 "" + (
int)Math.round(fleetModWithOneMore * 100f) +
"%");
119 tooltip.addPara(
"The fleetwide post-battle salvage bonus is %s.", opad, h,
136 for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy()) {
137 if (member.isMothballed())
continue;
138 if (member.getRepairTracker().getCR() <
MIN_CR)
continue;
140 if (member.getId().equals(skipId)) {
143 float v = member.getStats().getDynamic().getMod(Stats.SALVAGE_VALUE_MULT_MOD).computeEffective(0f);
144 if (v <= 0)
continue;
148 if (v > max) max = v;
151 if (add > max) max = add;
154 if (max <= 0)
return 0f;
155 float units = total / max;
156 if (units <= 1)
return max;
157 float mult = Misc.logOfBase(2.5f, units) + 1f;
158 float result = total * mult / units;
162 result = Math.round(result * 100f) / 100f;
163 result = Math.max(result, 0.01f);
static SettingsAPI getSettings()
static SectorAPI getSector()
static float getAdjustedGantryModifier(CampaignFleetAPI fleet, String skipId, float add)
void advanceInCombat(ShipAPI ship, float amount)
boolean shouldAddDescriptionToTooltip(HullSize hullSize, ShipAPI ship, boolean isForModSpec)
String getDescriptionParam(int index, HullSize hullSize)
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
static float getAdjustedGantryModifierForPostCombatSalvage(CampaignFleetAPI fleet)
static final float MIN_CR
static final float BATTLE_SALVAGE_MULT
void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec)
GameState getCurrentState()