001package com.fs.starfarer.api.impl.hullmods;
002
003import com.fs.starfarer.api.combat.BaseHullMod;
004import com.fs.starfarer.api.combat.MutableShipStatsAPI;
005import com.fs.starfarer.api.combat.ShipAPI;
006import com.fs.starfarer.api.combat.ShipAPI.HullSize;
007import com.fs.starfarer.api.impl.campaign.ids.Stats;
008
009public class CompromisedStructure extends BaseHullMod {
010        public static float DEPLOYMENT_COST_MULT = 0.8f;
011        
012        public static void modifyCost(HullSize hullSize, MutableShipStatsAPI stats, String id) {
013                stats.getSuppliesToRecover().modifyMult(id, DEPLOYMENT_COST_MULT);
014                
015                float effect = stats.getDynamic().getValue(Stats.DMOD_REDUCE_MAINTENANCE, 0);
016                if (effect > 0) {
017                        stats.getSuppliesPerMonth().modifyMult(id, DEPLOYMENT_COST_MULT);
018                }
019        }
020        public static String getCostDescParam(int index, int startIndex) {
021                if (index - startIndex == 0) {
022                        return "" + (int) Math.round((1f - DEPLOYMENT_COST_MULT) * 100f) + "%";
023                }
024                return null;
025        }
026        
027        public static float ARMOR_PENALTY_MULT = 0.8f;
028        public static float HULL_PENALTY_MULT = 0.8f;
029        
030        public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
031                
032                float effect = stats.getDynamic().getValue(Stats.DMOD_EFFECT_MULT);
033                float armorMult = ARMOR_PENALTY_MULT + (1f - ARMOR_PENALTY_MULT) * (1f - effect);
034                float hullMult = HULL_PENALTY_MULT + (1f - HULL_PENALTY_MULT) * (1f - effect);
035                
036                stats.getArmorBonus().modifyMult(id, armorMult);
037                stats.getHullBonus().modifyMult(id, hullMult);
038                modifyCost(hullSize, stats, id);
039        }
040                
041        public String getDescriptionParam(int index, HullSize hullSize, ShipAPI ship) {
042                float effect = 1f;
043                if (ship != null) effect = ship.getMutableStats().getDynamic().getValue(Stats.DMOD_EFFECT_MULT);
044                
045                float armorMult = ARMOR_PENALTY_MULT + (1f - ARMOR_PENALTY_MULT) * (1f - effect);
046                float hullMult = HULL_PENALTY_MULT + (1f - HULL_PENALTY_MULT) * (1f - effect);
047                
048                if (index == 0) return "" + (int) Math.round((1f - armorMult) * 100f) + "%";
049                if (index == 1) return "" + (int) Math.round((1f - hullMult) * 100f) + "%";
050                if (index >= 2) return getCostDescParam(index, 2); 
051                return null;
052        }
053        
054        
055}
056
057
058
059