001package com.fs.starfarer.api.impl.campaign.fleets;
002
003import java.util.List;
004import java.util.Random;
005
006import org.lwjgl.util.vector.Vector2f;
007
008import com.fs.starfarer.api.Global;
009import com.fs.starfarer.api.campaign.FactionAPI;
010import com.fs.starfarer.api.campaign.FactionAPI.ShipPickMode;
011import com.fs.starfarer.api.campaign.FactionDoctrineAPI;
012import com.fs.starfarer.api.campaign.econ.MarketAPI;
013import com.fs.starfarer.api.characters.PersonAPI;
014import com.fs.starfarer.api.combat.ShipVariantAPI;
015import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers;
016import com.fs.starfarer.api.util.Misc;
017
018/**
019 * Parameters for generic fleet creation.
020 * Fleet point values are targets not hard limits.
021 * 
022 * "Pts" are fleet points in this implementation, unlike FleetFactoryV2. 
023 * 
024 * @author Alex Mosolov
025 *
026 *
027 * Copyright 2015 Fractal Softworks, LLC
028 */
029public class FleetParamsV3 {
030        /**
031         * Use setSource() to set the source or directly call updateQualityAndProducerFromSourceMarket()
032         * to set the quality. Otherwise, the market's quality won't get used. 
033         */
034        public MarketAPI source;
035        
036        public Vector2f locInHyper;
037        public float quality;
038        public String factionId;
039        public String fleetType;
040        
041        public float combatPts;
042        public float freighterPts;      
043        public float tankerPts;         
044        public float transportPts;      
045        public float linerPts;
046        public float utilityPts;
047        
048        public FactionAPI factionOverride = null;
049        
050        
051        /**
052         * 0: fighter, 4: capital
053         */
054        public int maxShipSize = 1000;
055        
056        /**
057         *  0: fighter, 4: capital, only affects combat ships; smaller ships will still be added with remaining fleet points.
058         */
059        public int minShipSize = 0;
060        
061        public float qualityMod = 0f;
062        public Float qualityOverride = null;
063        public Integer averageSMods = null;
064        public boolean withOfficers = true;
065//      public boolean applyDoctrineFleetSize = true;
066//      public boolean applyMarketSizeToFleetSize = true;
067//      public boolean applyShipsDeficit = true;
068        public Boolean ignoreMarketFleetSizeMult = null;
069        public Boolean onlyApplyFleetSizeToCombatShips = null;
070        public Boolean doNotPrune = null;
071        public Boolean doNotAddShipsBeforePruning = null;
072        public ShipPickMode modeOverride = null;
073        
074        public int officerLevelBonus = 0;
075        public int officerNumberBonus = 0;
076        public Integer maxOfficersToAdd = null;
077        public float officerNumberMult = 1;
078        public int officerLevelLimit = 0;
079        public int commanderLevelLimit = 0;
080//      public int maxOfficers = -1;
081//      public int minOfficers = -1;
082        public Random random = null;
083        public PersonAPI commander;
084        
085        public Boolean noCommanderSkills;
086        public Boolean forceAllowPhaseShipsEtc;
087        public Boolean treatCombatFreighterSettingAsFraction;
088        public FactionDoctrineAPI doctrineOverride = null;
089        //public Boolean forceNoTimestamp;
090        public Long timestamp;
091        
092        public Integer maxNumShips;
093        public Boolean onlyRetainFlagship;
094        public String flagshipVariantId;
095        public ShipVariantAPI flagshipVariant;
096        //public Boolean allowEmptyFleet = null;
097        
098        public HubMissionWithTriggers.OfficerQuality aiCores = null;
099        public boolean doNotIntegrateAICores = false;
100        
101        // Used in FleetFactoryV3 to pass some data between methods. Do not use directly.
102        public transient ShipPickMode mode;
103        public transient boolean banPhaseShipsEtc;
104        public transient Boolean blockFallback = null;
105
106        public Boolean allWeapons = null;
107        
108        /**
109         * If non-null: these ship variants will be added to the fleet before anything else
110         */
111        public List<String> addShips;
112        
113        public FleetParamsV3(MarketAPI source, Vector2f locInHyper, String factionId, Float qualityOverride, String fleetType,
114                        float combatPts, float freighterPts, float tankerPts,
115                        float transportPts, float linerPts,
116                        float utilityPts, float qualityMod) {
117                if (source != null) {
118                        init(source, fleetType, factionId, combatPts, freighterPts, tankerPts, transportPts, linerPts, utilityPts, qualityMod);
119                        if (factionId != null) {
120                                this.factionId = factionId;
121                        }
122                        this.qualityOverride = qualityOverride;
123                        this.locInHyper = locInHyper;
124                } else {
125                        init(locInHyper, factionId, qualityOverride, fleetType,
126                                        combatPts, freighterPts, tankerPts, transportPts, linerPts, utilityPts, qualityMod);
127                }
128        }
129        
130        public FleetParamsV3() {
131                
132        }
133                        
134        public FleetParamsV3(Vector2f locInHyper, String factionId, Float qualityOverride, String fleetType,
135                        float combatPts, float freighterPts, float tankerPts,
136                        float transportPts, float linerPts,
137                        float utilityPts, float qualityMod) {
138                init(locInHyper, factionId, qualityOverride, fleetType,
139                                combatPts, freighterPts, tankerPts, transportPts, linerPts, utilityPts, qualityMod);
140        }
141        
142        public FleetParamsV3(MarketAPI source, String fleetType,
143                        float combatPts, float freighterPts, float tankerPts,
144                        float transportPts, float linerPts,
145                        float utilityPts, float qualityMod) {
146                init(source, fleetType, null, combatPts, freighterPts, tankerPts, transportPts, linerPts, utilityPts, qualityMod);
147        }
148        
149        public void init(MarketAPI source, String fleetType, String factionId,
150                        float combatPts, float freighterPts, float tankerPts,
151                        float transportPts, float linerPts,
152                        float utilityPts, float qualityMod) {
153                init(source.getLocationInHyperspace(), null, null, 
154                                fleetType, combatPts, freighterPts, tankerPts, transportPts, linerPts, utilityPts, qualityMod);
155                this.factionId = source.getFactionId();
156                if (factionId != null) {
157                        this.factionId = factionId;
158                }
159                this.source = source;
160                timestamp = Global.getSector().getClock().getTimestamp();
161                updateQualityAndProducerFromSourceMarket();
162        }
163        
164        public void init(Vector2f locInHyper, String factionId, Float qualityOverride, String fleetType,
165                        float combatPts, float freighterPts, float tankerPts,
166                        float transportPts, float linerPts,
167                        float utilityPts, float qualityMod) {
168                this.locInHyper = locInHyper;
169                this.factionId = factionId;
170                this.qualityOverride = qualityOverride;
171                this.fleetType = fleetType;
172                this.combatPts = combatPts;
173                this.freighterPts = freighterPts;
174                this.tankerPts = tankerPts;
175                this.transportPts = transportPts;
176                this.linerPts = linerPts;
177                this.utilityPts = utilityPts;
178                this.qualityMod = qualityMod;
179        }
180        
181        public void setSource(MarketAPI source, boolean updateQuality) {
182                this.source = source;
183                if (updateQuality) {
184                        updateQualityAndProducerFromSourceMarket();
185                }
186        }
187        
188        
189        public void updateQualityAndProducerFromSourceMarket() {
190                if (source != null) {
191                        this.quality = Misc.getShipQuality(source, factionId);
192                }
193                
194//              this.quality = 0f;
195//              if (producer != null) {
196//                      this.quality = producer.getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD).computeEffective(0f);
197//              }
198//              if (source != null) {
199//                      this.quality += source.getStats().getDynamic().getMod(Stats.FLEET_QUALITY_MOD).computeEffective(0f);
200//                      //this.quality += source.getFaction().getDoctrine().getShipQualityContribution();
201//              } else if (factionId != null) {
202//                      this.quality += Global.getSector().getFaction(factionId).getDoctrine().getShipQualityContribution();
203//              }
204        }
205        
206        public float getTotalPts() {
207                return combatPts + freighterPts + tankerPts + transportPts + linerPts + utilityPts;
208        }
209        
210        
211}
212
213
214
215
216
217
218
219
220
221
222