001package com.fs.starfarer.api.impl.hullmods;
002
003import java.util.HashMap;
004import java.util.Map;
005
006import com.fs.starfarer.api.combat.MutableShipStatsAPI;
007import com.fs.starfarer.api.combat.ShipAPI.HullSize;
008import com.fs.starfarer.api.impl.campaign.ids.HullMods;
009
010public class AdditionalBerthing extends BaseLogisticsHullMod {
011
012        public static float MIN_FRACTION = 0.3f;
013        public static float MAINTENANCE_PERCENT = 50;
014        
015        public static float SMOD_MULT = 2f;
016        
017        private static Map mag = new HashMap();
018        static {
019                mag.put(HullSize.FRIGATE, 30f);
020                mag.put(HullSize.DESTROYER, 60f);
021                mag.put(HullSize.CRUISER, 100f);
022                mag.put(HullSize.CAPITAL_SHIP, 200f);
023        }
024        
025        public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
026                
027                
028                float mod = (Float) mag.get(hullSize);
029                if (stats.getVariant() != null) {
030                        mod = Math.max(stats.getVariant().getHullSpec().getMaxCrew() * MIN_FRACTION, mod);
031                }
032                boolean sMod = isSMod(stats);
033                if (sMod) mod *= SMOD_MULT; 
034                stats.getMaxCrewMod().modifyFlat(id, mod);
035                
036                if (!sMod && stats.getVariant() != null && stats.getVariant().hasHullMod(HullMods.CIVGRADE) && !stats.getVariant().hasHullMod(HullMods.MILITARIZED_SUBSYSTEMS)) {
037                        stats.getSuppliesPerMonth().modifyPercent(id, MAINTENANCE_PERCENT);
038                }
039        }
040        
041//      public String getSModDescriptionParam(int index, HullSize hullSize) {
042//              if (index == 0) return "" + (int) Math.round((SMOD_MULT - 1f) * 100f) + "%";
043//              return null;
044//      }
045        
046        public String getDescriptionParam(int index, HullSize hullSize) {
047                if (index == 0) return "" + ((Float) mag.get(HullSize.FRIGATE)).intValue();
048                if (index == 1) return "" + ((Float) mag.get(HullSize.DESTROYER)).intValue();
049                if (index == 2) return "" + ((Float) mag.get(HullSize.CRUISER)).intValue();
050                if (index == 3) return "" + ((Float) mag.get(HullSize.CAPITAL_SHIP)).intValue();
051                if (index == 4) return "" + (int) Math.round(MIN_FRACTION * 100f) + "%";
052                if (index == 5) return "" + (int)Math.round(MAINTENANCE_PERCENT) + "%";
053                return null;
054        }
055
056}
057
058
059
060