001package com.fs.starfarer.api.impl.campaign.skills;
002
003import com.fs.starfarer.api.characters.ShipSkillEffect;
004import com.fs.starfarer.api.combat.MutableShipStatsAPI;
005import com.fs.starfarer.api.combat.ShipAPI.HullSize;
006
007public class SystemsExpertise {
008        
009        
010        //public static final float CHARGES_PERCENT = 100f;
011        public static float BONUS_CHARGES = 1f;
012        public static float REGEN_PERCENT = 50f;
013        public static float SYSTEM_COOLDOWN_REDUCTION_PERCENT = 33f;
014        public static float RANGE_PERCENT = 50f;
015        
016        public static float PEAK_TIME_BONUS = 30f;
017        public static float OVERLOAD_REDUCTION = 25f;
018        public static float MALFUNCTION_CHANCE_MULT = 0.5f;
019        
020        public static float ELITE_DAMAGE_REDUCTION = 10f;
021        
022
023        public static class Level1 implements ShipSkillEffect {
024                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
025                        //stats.getSystemUsesBonus().modifyPercent(id, CHARGES_PERCENT);
026                        stats.getSystemUsesBonus().modifyFlat(id, BONUS_CHARGES);
027                }
028                
029                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
030                        stats.getSystemUsesBonus().unmodifyPercent(id);
031                }
032                
033                public String getEffectDescription(float level) {
034                        //return "If the ship's system has charges: +" + (int)(CHARGES_PERCENT) + "% charges";
035                        return "If the ship's system has charges: +1 charge";
036                }
037                
038                public String getEffectPerLevelDescription() {
039                        return null;
040                }
041                
042                public ScopeDescription getScopeDescription() {
043                        return ScopeDescription.PILOTED_SHIP;
044                }
045        }
046        
047        public static class Level2 implements ShipSkillEffect {
048                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
049                        stats.getSystemRegenBonus().modifyPercent(id, REGEN_PERCENT);
050                }
051                
052                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
053                        stats.getSystemRegenBonus().unmodifyPercent(id);
054                }
055                
056                public String getEffectDescription(float level) {
057                        return "If the ship's system regenerates charges: +" + (int)(REGEN_PERCENT) + "% regeneration rate";
058                }
059                
060                public String getEffectPerLevelDescription() {
061                        return null;
062                }
063                
064                public ScopeDescription getScopeDescription() {
065                        return ScopeDescription.PILOTED_SHIP;
066                }
067        }
068        
069        public static class Level3 implements ShipSkillEffect {
070                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
071                        stats.getSystemRangeBonus().modifyPercent(id, RANGE_PERCENT);
072                }
073                
074                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
075                        stats.getSystemRangeBonus().unmodifyPercent(id);
076                }
077                
078                public String getEffectDescription(float level) {
079                        return "If the ship's system has range: +" + (int)(RANGE_PERCENT) + "% range";
080                }
081                
082                public String getEffectPerLevelDescription() {
083                        return null;
084                }
085                
086                public ScopeDescription getScopeDescription() {
087                        return ScopeDescription.PILOTED_SHIP;
088                }
089        }
090
091        public static class Level4 implements ShipSkillEffect {
092                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
093                        stats.getSystemCooldownBonus().modifyMult(id, 1f - SYSTEM_COOLDOWN_REDUCTION_PERCENT / 100f);
094                }
095                
096                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
097                        stats.getSystemCooldownBonus().unmodify(id);
098                }
099                
100                public String getEffectDescription(float level) {
101                        return "If the ship's system has a cooldown: -" + (int)(SYSTEM_COOLDOWN_REDUCTION_PERCENT) + "% cooldown";
102                }
103                
104                public String getEffectPerLevelDescription() {
105                        return null;
106                }
107                
108                public ScopeDescription getScopeDescription() {
109                        return ScopeDescription.PILOTED_SHIP;
110                }
111        }
112
113
114        public static class Level5 implements ShipSkillEffect {
115                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
116                        stats.getPeakCRDuration().modifyFlat(id, PEAK_TIME_BONUS);
117                }
118                
119                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
120                        stats.getPeakCRDuration().unmodifyFlat(id);
121                }
122                
123                public String getEffectDescription(float level) {
124                        return "+" + (int)(PEAK_TIME_BONUS) + " seconds peak operating time";
125                }
126                
127                public String getEffectPerLevelDescription() {
128                        return null;
129                }
130                
131                public ScopeDescription getScopeDescription() {
132                        return ScopeDescription.PILOTED_SHIP;
133                }
134        }
135        
136        public static class Level6 implements ShipSkillEffect {
137                
138                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
139                        stats.getOverloadTimeMod().modifyMult(id, 1f - OVERLOAD_REDUCTION / 100f);
140                }
141                
142                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
143                        stats.getOverloadTimeMod().unmodify(id);
144                }       
145                
146                public String getEffectDescription(float level) {
147                        return "-" + (int)(OVERLOAD_REDUCTION) + "% overload duration";
148                }
149                
150                public String getEffectPerLevelDescription() {
151                        return null;
152                }
153                
154                public ScopeDescription getScopeDescription() {
155                        return ScopeDescription.PILOTED_SHIP;
156                }
157        }
158        
159        public static class Level7 implements ShipSkillEffect {
160                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
161                        stats.getWeaponMalfunctionChance().modifyMult(id, MALFUNCTION_CHANCE_MULT);     
162                        stats.getEngineMalfunctionChance().modifyMult(id, MALFUNCTION_CHANCE_MULT);     
163                }
164                
165                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
166                        stats.getWeaponMalfunctionChance().unmodifyMult(id);    
167                        stats.getEngineMalfunctionChance().unmodifyMult(id);    
168                }
169                
170                public String getEffectDescription(float level) {
171                        String percent = "" + (int)Math.round((1f - MALFUNCTION_CHANCE_MULT) * 100f) + "%";
172                        return "Chance of malfunctions when at low combat readiness reduced by " + percent;
173                }
174                
175                public String getEffectPerLevelDescription() {
176                        return null;
177                }
178                
179                public ScopeDescription getScopeDescription() {
180                        return ScopeDescription.PILOTED_SHIP;
181                }
182        }
183        
184        public static class Level8 implements ShipSkillEffect {
185                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
186                        stats.getArmorDamageTakenMult().modifyMult(id, 1f - ELITE_DAMAGE_REDUCTION / 100f);
187                        stats.getHullDamageTakenMult().modifyMult(id, 1f - ELITE_DAMAGE_REDUCTION / 100f);
188                        stats.getShieldDamageTakenMult().modifyMult(id, 1f - ELITE_DAMAGE_REDUCTION / 100f);
189                }
190                
191                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
192                        stats.getArmorDamageTakenMult().unmodifyMult(id);
193                        stats.getHullDamageTakenMult().unmodifyMult(id);
194                        stats.getShieldDamageTakenMult().unmodifyMult(id);      
195                }
196                
197                public String getEffectDescription(float level) {
198                        String percent = "-" + (int)ELITE_DAMAGE_REDUCTION + "%";
199                        return percent + " damage taken";
200                }
201                
202                public String getEffectPerLevelDescription() {
203                        return null;
204                }
205                
206                public ScopeDescription getScopeDescription() {
207                        return ScopeDescription.PILOTED_SHIP;
208                }
209        }
210        
211        
212}