Starsector API
Loading...
Searching...
No Matches
FluxRegulation.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.skills;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.campaign.FleetDataAPI;
6import com.fs.starfarer.api.characters.CharacterStatsSkillEffect;
7import com.fs.starfarer.api.characters.FleetTotalItem;
8import com.fs.starfarer.api.characters.FleetTotalSource;
9import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;
10import com.fs.starfarer.api.characters.ShipSkillEffect;
11import com.fs.starfarer.api.characters.SkillSpecAPI;
12import com.fs.starfarer.api.combat.MutableShipStatsAPI;
13import com.fs.starfarer.api.combat.ShipAPI.HullSize;
14import com.fs.starfarer.api.ui.TooltipMakerAPI;
15import com.fs.starfarer.api.util.Misc;
16
17public class FluxRegulation {
18
19 public static int VENTS_BONUS = 5;
20 public static int CAPACITORS_BONUS = 5;
21
22 public static float DISSIPATION_PERCENT = 10;
23 public static float CAPACITY_PERCENT = 10;
24
25 public static class Level1 extends BaseSkillEffectDescription implements ShipSkillEffect, FleetTotalSource {
26
27 public FleetTotalItem getFleetTotalItem() {
28 return getCombatOPTotal();
29 }
30
31 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
32 if (!isCivilian(stats)) {
33 float disBonus = computeAndCacheThresholdBonus(stats, "fr_dis", DISSIPATION_PERCENT, ThresholdBonusType.OP);
34 float capBonus = computeAndCacheThresholdBonus(stats, "fr_cap", CAPACITY_PERCENT, ThresholdBonusType.OP);
35 stats.getFluxDissipation().modifyPercent(id, disBonus);
36 stats.getFluxCapacity().modifyPercent(id, capBonus);
37 }
38 }
39
40 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
41 stats.getFluxDissipation().unmodifyPercent(id);
42 stats.getFluxCapacity().unmodifyPercent(id);
43 }
44
45 public String getEffectDescription(float level) {
46 return null;
47 }
48
49// float op = getTotalOP(data, cStats);
50// bonus = getThresholdBasedRoundedBonus(DISSIPATION_PERCENT, op, OP_THRESHOLD);
51//
52// float op = getTotalOP(data, cStats);
53// bonus = getThresholdBasedRoundedBonus(CAPACITY_PERCENT, op, FIGHTER_BAYS_THRESHOLD);
54
55
56 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
57 TooltipMakerAPI info, float width) {
58 init(stats, skill);
59
60 //info.addSpacer(5f);
61
62 FleetDataAPI data = getFleetData(null);
63 float disBonus = computeAndCacheThresholdBonus(data, stats, "fr_dis", DISSIPATION_PERCENT, ThresholdBonusType.OP);
64 float capBonus = computeAndCacheThresholdBonus(data, stats, "fr_cap", CAPACITY_PERCENT, ThresholdBonusType.OP);
65
66 float opad = 10f;
67 Color c = Misc.getBasePlayerColor();
68 info.addPara("Affects: %s", opad + 5f, Misc.getGrayColor(), c, "all combat ships, including carriers and militarized civilian ships");
69
70 info.addPara("+%s flux dissipation for combat ships (maximum: %s)", opad, hc, hc,
71 "" + (int) disBonus + "%",
72 "" + (int) DISSIPATION_PERCENT + "%");
73
74// addFighterBayThresholdInfo(info, data);
75// info.addSpacer(5f);
76
77 info.addPara("+%s flux capacity for combat ships (maximum: %s)", 0f, hc, hc,
78 "" + (int) capBonus + "%",
79 "" + (int) CAPACITY_PERCENT + "%");
80 addOPThresholdInfo(info, data, stats);
81
82 //info.addSpacer(5f);
83 }
84
85 public ScopeDescription getScopeDescription() {
86 return ScopeDescription.ALL_SHIPS;
87 }
88 }
89
90 public static class Level2 implements CharacterStatsSkillEffect {
91 public void apply(MutableCharacterStatsAPI stats, String id, float level) {
92 stats.getMaxCapacitorsBonus().modifyFlat(id, CAPACITORS_BONUS);
93 }
94
95 public void unapply(MutableCharacterStatsAPI stats, String id) {
96 stats.getMaxCapacitorsBonus().unmodify(id);
97 }
98
99 public String getEffectDescription(float level) {
100 return "+" + (int) CAPACITORS_BONUS + " maximum flux capacitors";
101 }
102
103 public String getEffectPerLevelDescription() {
104 return null;
105 }
106
107 public ScopeDescription getScopeDescription() {
108 return ScopeDescription.ALL_SHIPS;
109 }
110 }
111
112 public static class Level3 implements CharacterStatsSkillEffect {
113 public void apply(MutableCharacterStatsAPI stats, String id, float level) {
114 //stats.getShipOrdnancePointBonus().modifyPercent(id, 50f);
115 stats.getMaxVentsBonus().modifyFlat(id, VENTS_BONUS);
116 }
117
118 public void unapply(MutableCharacterStatsAPI stats, String id) {
119 //stats.getShipOrdnancePointBonus().unmodifyPercent(id);
120 stats.getMaxVentsBonus().unmodify(id);
121 }
122
123 public String getEffectDescription(float level) {
124 return "+" + (int) VENTS_BONUS + " maximum flux vents";
125 }
126
127 public String getEffectPerLevelDescription() {
128 return null;
129 }
130
131 public ScopeDescription getScopeDescription() {
132 return ScopeDescription.ALL_SHIPS;
133 }
134 }
135
136}
137
138
139
140
141
void addOPThresholdInfo(TooltipMakerAPI info, FleetDataAPI data, MutableCharacterStatsAPI cStats)
void init(MutableCharacterStatsAPI stats, SkillSpecAPI skill)
float computeAndCacheThresholdBonus(MutableShipStatsAPI stats, String key, float maxBonus, ThresholdBonusType type)