Starsector API
Loading...
Searching...
No Matches
CrewTraining.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.skills;
2
3import com.fs.starfarer.api.campaign.FleetDataAPI;
4import com.fs.starfarer.api.characters.FleetTotalItem;
5import com.fs.starfarer.api.characters.FleetTotalSource;
6import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;
7import com.fs.starfarer.api.characters.ShipSkillEffect;
8import com.fs.starfarer.api.characters.SkillSpecAPI;
9import com.fs.starfarer.api.combat.MutableShipStatsAPI;
10import com.fs.starfarer.api.combat.ShipAPI.HullSize;
11import com.fs.starfarer.api.ui.TooltipMakerAPI;
12
13public class CrewTraining {
14
15 public static float PEAK_SECONDS = 30f;
16 public static float CR_PERCENT = 15f;
17
18 public static class Level1 extends BaseSkillEffectDescription implements ShipSkillEffect, FleetTotalSource {
19
20 public FleetTotalItem getFleetTotalItem() {
21 return getCombatOPTotal();
22 }
23
24 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
25 if (!isCivilian(stats)) {
26 float crBonus = computeAndCacheThresholdBonus(stats, "ct_cr", CR_PERCENT, ThresholdBonusType.OP);
27 stats.getMaxCombatReadiness().modifyFlat(id, crBonus * 0.01f, "Crew Training skill");
28 }
29 }
30
31 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
33 }
34
35 public String getEffectDescription(float level) {
36 return null;
37 }
38
39 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
40 TooltipMakerAPI info, float width) {
41 init(stats, skill);
42
43 FleetDataAPI data = getFleetData(null);
44 float crBonus = computeAndCacheThresholdBonus(data, stats, "ct_cr", CR_PERCENT, ThresholdBonusType.OP);
45
46 info.addPara("+%s maximum combat readiness for combat ships (maximum: %s)", 0f, hc, hc,
47 "" + (int) crBonus + "%",
48 "" + (int) CR_PERCENT + "%");
49 addOPThresholdInfo(info, data, stats, OP_THRESHOLD);
50 }
51 }
52 public static class Level2 extends BaseSkillEffectDescription implements ShipSkillEffect, FleetTotalSource {
53
54 public FleetTotalItem getFleetTotalItem() {
55 return getCombatOPTotal();
56 }
57
58 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
59 if (!isCivilian(stats)) {
60 float peakTimeBonus = computeAndCacheThresholdBonus(stats, "ct_peak", PEAK_SECONDS, ThresholdBonusType.OP);
61 stats.getPeakCRDuration().modifyFlat(id, peakTimeBonus);
62 }
63 }
64
65 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
66 stats.getPeakCRDuration().unmodifyFlat(id);
67 }
68
69 public String getEffectDescription(float level) {
70 return null;
71 }
72
73 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
74 TooltipMakerAPI info, float width) {
75 init(stats, skill);
76
77 FleetDataAPI data = getFleetData(null);
78 float peakTimeBonus = computeAndCacheThresholdBonus(data, stats, "ct_peak", PEAK_SECONDS, ThresholdBonusType.OP);
79
80 info.addPara("+%s seconds peak operating time for combat ships (maximum: %s)", 0f, hc, hc,
81 "" + (int) peakTimeBonus,
82 "" + (int) PEAK_SECONDS);
83 addOPThresholdInfo(info, data, stats, OP_THRESHOLD);
84 }
85 }
86
87
88
89}
90
91
92
93
94
void modifyFlat(String source, float value)
void modifyFlat(String source, float value)
void addOPThresholdInfo(TooltipMakerAPI info, FleetDataAPI data, MutableCharacterStatsAPI cStats)
void init(MutableCharacterStatsAPI stats, SkillSpecAPI skill)
float computeAndCacheThresholdBonus(MutableShipStatsAPI stats, String key, float maxBonus, ThresholdBonusType type)
LabelAPI addPara(String format, float pad, Color hl, String... highlights)