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;
006import com.fs.starfarer.api.impl.campaign.ids.Stats;
007import com.fs.starfarer.api.impl.campaign.ids.Strings;
008
009public class DefensiveSystems {
010        
011        public static final float FLUX_UPKEEP_REDUCTION = 25f;
012        
013        public static final float SHIELD_DAMAGE_REDUCTION = 20f;
014        public static final float PHASE_COOLDOWN_REDUCTION = 25f;
015        
016        public static final float FLUX_SHUNT_DISSIPATION = 10f;
017        
018
019        public static class Level1 implements ShipSkillEffect {
020
021                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
022                        stats.getShieldUpkeepMult().modifyMult(id, 1f - FLUX_UPKEEP_REDUCTION / 100f);
023                        stats.getPhaseCloakUpkeepCostBonus().modifyMult(id, 1f - FLUX_UPKEEP_REDUCTION / 100f);
024                }
025                
026                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
027                        stats.getShieldUpkeepMult().unmodify(id);
028                        stats.getPhaseCloakUpkeepCostBonus().unmodify(id);
029                }
030                
031                public String getEffectDescription(float level) {
032                        return "-" + (int)(FLUX_UPKEEP_REDUCTION) + "% flux generated by active shields and phase cloak";
033                }
034                
035                public String getEffectPerLevelDescription() {
036                        return null;
037                }
038                
039                public ScopeDescription getScopeDescription() {
040                        return ScopeDescription.PILOTED_SHIP;
041                }
042        }
043
044        public static class Level2A implements ShipSkillEffect {
045                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
046                        stats.getShieldDamageTakenMult().modifyMult(id, 1f - SHIELD_DAMAGE_REDUCTION / 100f);
047                }
048                
049                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
050                        stats.getShieldDamageTakenMult().unmodify(id);
051                }
052                
053                public String getEffectDescription(float level) {
054                        return "-" + (int)(SHIELD_DAMAGE_REDUCTION) + "% damage taken by shields";
055                }
056                
057                public String getEffectPerLevelDescription() {
058                        return null;
059                }
060
061                public ScopeDescription getScopeDescription() {
062                        return ScopeDescription.PILOTED_SHIP;
063                }
064        }
065        
066        public static class Level2B implements ShipSkillEffect {
067                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
068                        stats.getPhaseCloakCooldownBonus().modifyMult(id, 1f - PHASE_COOLDOWN_REDUCTION / 100f);
069                }
070                
071                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
072                        stats.getPhaseCloakCooldownBonus().unmodify(id);
073                }
074                
075                public String getEffectDescription(float level) {
076                        return "-" + (int)(PHASE_COOLDOWN_REDUCTION) + "% phase cloak cooldown";
077                }
078                
079                public String getEffectPerLevelDescription() {
080                        return null;
081                }
082                
083                public ScopeDescription getScopeDescription() {
084                        return ScopeDescription.PILOTED_SHIP;
085                }
086        }
087        
088        public static class Level3A implements ShipSkillEffect {
089
090                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
091                        stats.getHardFluxDissipationFraction().modifyFlat(id, FLUX_SHUNT_DISSIPATION / 100f);
092                }
093                
094                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
095                        stats.getHardFluxDissipationFraction().unmodify(id);
096                }       
097                
098                public String getEffectDescription(float level) {
099                        return "" + (int)(FLUX_SHUNT_DISSIPATION) + "% hard flux dissipation while shields are active";
100                }
101                
102                public String getEffectPerLevelDescription() {
103                        return null;
104                }
105                
106                public ScopeDescription getScopeDescription() {
107                        return ScopeDescription.PILOTED_SHIP;
108                }
109        }
110        
111        public static class Level3B implements ShipSkillEffect {
112                
113                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
114                        // 1f + 2 * (this stat), * 1.5 means 3x -> 4c
115                        stats.getDynamic().getStat(Stats.PHASE_TIME_BONUS_MULT).modifyFlat(id, 0.5f);
116                }
117                
118                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
119                        stats.getDynamic().getStat(Stats.PHASE_TIME_BONUS_MULT).unmodify(id);
120                }       
121                
122                public String getEffectDescription(float level) {
123                        return "Phase cloak time acceleration increased from 3" + Strings.X + " to 4" + Strings.X;
124                }
125                
126                public String getEffectPerLevelDescription() {
127                        return null;
128                }
129                
130                public ScopeDescription getScopeDescription() {
131                        return ScopeDescription.PILOTED_SHIP;
132                }
133        }
134        
135}