001package com.fs.starfarer.api.impl.campaign.intel.misc;
002
003import java.util.Set;
004
005import java.awt.Color;
006
007import com.fs.starfarer.api.Global;
008import com.fs.starfarer.api.campaign.SectorEntityToken;
009import com.fs.starfarer.api.campaign.SpecialItemSpecAPI;
010import com.fs.starfarer.api.campaign.TextPanelAPI;
011import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin;
012import com.fs.starfarer.api.impl.campaign.econ.impl.ItemEffectsRepo;
013import com.fs.starfarer.api.impl.campaign.ids.Commodities;
014import com.fs.starfarer.api.impl.campaign.ids.Items;
015import com.fs.starfarer.api.ui.SectorMapAPI;
016import com.fs.starfarer.api.ui.TooltipMakerAPI;
017import com.fs.starfarer.api.util.Misc;
018
019public class HypershuntIntel extends MapMarkerIntel {
020
021        public HypershuntIntel(SectorEntityToken entity, TextPanelAPI textPanel) {
022                
023                //String icon = Global.getSettings().getSpriteName("intel", "hypershunt");
024                String title = entity.getName();
025                
026                String text = null;
027//              if (entity.getStarSystem() != null) {
028//                      text = "Located in the " + entity.getStarSystem().getNameWithLowercaseTypeShort();
029//              }
030                setSound("ui_discovered_entity");
031                
032                setWithDeleteButton(false);
033                //setWithTimestamp(false);
034                
035                init(entity, title, text, null, true, textPanel);
036        }
037        
038        @Override
039        public String getIcon() {
040                return Global.getSettings().getSpriteName("intel", "hypershunt");
041        }
042
043        @Override
044        protected boolean withTextInDesc() {
045                return false;
046        }
047        
048        @Override
049        protected void addExtraBulletPoints(TooltipMakerAPI info, Color tc, float initPad, ListInfoMode mode) {
050                if (entity.getMemoryWithoutUpdate().getBoolean("$usable")) {
051                        info.addPara("Active", tc, initPad);
052                } else {
053                        info.addPara("Inactive", tc, initPad);
054                }
055        }
056        
057        public boolean defendersDefeated() {
058                return entity.getMemoryWithoutUpdate().getBoolean("$defenderFleetDefeated");
059        }
060        
061        @Override
062        protected void addPostDescriptionSection(TooltipMakerAPI info, float width, float height, float opad) {
063                //if (!entity.getMemoryWithoutUpdate().getBoolean("$hasDefenders")) {
064                if (defendersDefeated()) {
065                        SpecialItemSpecAPI spec = Global.getSettings().getSpecialItemSpec(Items.CORONAL_PORTAL);
066                        info.addPara("Allows colonies within %s light-years to build %s additional industry, "
067                                        + "provided they have a %s installed and have a steady supply of transplutonics.", 
068                                        opad, Misc.getHighlightColor(), 
069                                        "" + (int)ItemEffectsRepo.CORONAL_TAP_LIGHT_YEARS, 
070                                        "" + (int)ItemEffectsRepo.CORONAL_TAP_INDUSTRIES, 
071                                        spec.getName());
072                        
073                        if (!entity.getMemoryWithoutUpdate().getBoolean("$usable")) {
074                                // these must match the quantities specified in the rule "cTap_infoText"
075                                int crew = 1000;
076                                int metals = 20000;
077                                int transplutonics = 5000;
078                                info.showCost("Resources required to activate", false, (int)((width - opad) / 3f), 
079                                                Misc.getBasePlayerColor(), Misc.getDarkPlayerColor(), opad, 
080                                                new String [] {Commodities.CREW, Commodities.METALS, Commodities.RARE_METALS},
081                                                new int [] {crew, metals, transplutonics}, new boolean [] {false, false, false});
082                        }
083                }
084        }
085
086        public static HypershuntIntel getHypershuntIntel(SectorEntityToken entity) {
087                for (IntelInfoPlugin intel : Global.getSector().getIntelManager().getIntel(HypershuntIntel.class)) {
088                        if (((HypershuntIntel)intel).getEntity() == entity) return (HypershuntIntel)intel;
089                }
090                return null;
091        }
092
093        @Override
094        public Set<String> getIntelTags(SectorMapAPI map) {
095                Set<String> tags = super.getIntelTags(map);
096                //tags.add(Tags.INTEL_);
097                return tags;
098        }
099        
100        
101}
102
103
104
105