001package com.fs.starfarer.api.impl.campaign.intel.misc;
002
003import java.util.Random;
004import java.util.Set;
005
006import java.awt.Color;
007
008import com.fs.starfarer.api.Global;
009import com.fs.starfarer.api.campaign.PlanetAPI;
010import com.fs.starfarer.api.campaign.SectorEntityToken;
011import com.fs.starfarer.api.impl.campaign.ids.Commodities;
012import com.fs.starfarer.api.impl.campaign.ids.Tags;
013import com.fs.starfarer.api.plugins.SurveyPlugin;
014import com.fs.starfarer.api.ui.SectorMapAPI;
015import com.fs.starfarer.api.ui.TooltipMakerAPI;
016import com.fs.starfarer.api.ui.TooltipMakerAPI.PlanetInfoParams;
017import com.fs.starfarer.api.util.Misc;
018
019public class RemoteSurveyDataForPlanetIntel extends FleetLogIntel {
020
021        protected PlanetAPI planet;
022        protected String minClass;
023        
024        public RemoteSurveyDataForPlanetIntel(PlanetAPI planet) {
025                this.planet = planet;
026                
027                setSound("ui_discovered_entity");
028                setIconId("remote_survey_data");
029                
030                setRemoveTrigger(planet);
031                setRemoveSurveyedPlanet(true);
032                
033                minClass = pickMinClass();
034                
035                setListInfoParam(DISCOVERED_PARAM);
036                Global.getSector().getIntelManager().addIntel(this, false, null);
037                setListInfoParam(null);
038        }
039        
040        public String pickMinClass() {
041                SurveyPlugin plugin = (SurveyPlugin) Global.getSettings().getNewPluginInstance("surveyPlugin");
042                String type = plugin.getSurveyDataType(planet);
043                int typeNum = 0;
044                if (Commodities.SURVEY_DATA_1.equals(type)) {
045                        typeNum = 1;
046                } else if (Commodities.SURVEY_DATA_2.equals(type)) {
047                        typeNum = 2;
048                } else if (Commodities.SURVEY_DATA_3.equals(type)) {
049                        typeNum = 3;
050                } else if (Commodities.SURVEY_DATA_4.equals(type)) {
051                        typeNum = 4;
052                } else if (Commodities.SURVEY_DATA_5.equals(type)) {
053                        typeNum = 5;
054                }
055                
056                Random random = Misc.getRandom(Misc.getSalvageSeed(planet, true), 0);
057                if (random.nextBoolean()) {
058                        typeNum--;
059                }
060                if (typeNum < 1) typeNum = 1;
061                
062                switch (typeNum) {
063                case 1: return "Class I";
064                case 2: return "Class II";
065                case 3: return "Class III";
066                case 4: return "Class IV";
067                }
068                return "Class V";
069        }
070        
071        @Override
072        protected String getName() {
073                String name = "Remote Survey: " + minClass + "+ " + planet.getTypeNameWithWorld(); 
074                return name;
075        }
076
077
078        @Override
079        public void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode) {
080                Color c = getTitleColor(mode);
081                info.addPara(getName(), c, 0f);
082                addBulletPoints(info, mode);
083        }
084        
085        protected void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode) {
086                Color h = Misc.getHighlightColor();
087                Color g = Misc.getGrayColor();
088                float pad = 3f;
089                float opad = 10f;
090                
091                float initPad = pad;
092                if (mode == ListInfoMode.IN_DESC) initPad = opad;
093                
094                Color tc = getBulletColorForMode(mode);
095                //boolean isUpdate = getListInfoParam() != null;
096                
097                bullet(info);
098                //info.addPara(str, tc, initPad);
099                initPad = 0f;
100                unindent(info);
101        }       
102        
103        @Override
104        public void createSmallDescription(TooltipMakerAPI info, float width, float height) {
105                Color h = Misc.getHighlightColor();
106                Color g = Misc.getGrayColor();
107                Color tc = Misc.getTextColor();
108                float pad = 3f;
109                float opad = 10f;
110                
111                PlanetInfoParams params = new PlanetInfoParams();
112                params.showConditions = true;
113                params.showName = true;
114                params.withClass = true;
115                params.classStrOverride = minClass + "+";
116                params.scaleEvenWhenShowingName = true;
117                params.conditionsYOffset = 32f;
118                params.showHazardRating = true;
119                info.showPlanetInfo(planet, width, width / 1.62f, params, opad + params.conditionsYOffset);
120                info.addPara("A remote survey has indicated that " + planet.getName() + " is " + minClass + " or higher "
121                                + "and is likely the most promising candidate "
122                                + "for a full survey operation in the " + planet.getStarSystem().getNameWithLowercaseTypeShort() + ".", opad + 18f,
123                                h, minClass + " or higher", "most promising candidate");
124
125                addBulletPoints(info, ListInfoMode.IN_DESC);
126                
127                addLogTimestamp(info, tc, opad);
128                addDeleteButton(info, width);
129        }
130
131        @Override
132        public Set<String> getIntelTags(SectorMapAPI map) {
133                Set<String> tags = super.getIntelTags(map);
134                tags.remove(Tags.INTEL_FLEET_LOG);
135                tags.add(Tags.INTEL_EXPLORATION);
136                return tags;
137        }
138
139        @Override
140        public SectorEntityToken getMapLocation(SectorMapAPI map) {
141                return planet;
142        }
143        
144        
145        
146}
147
148
149
150