001package com.fs.starfarer.api.impl.campaign.intel.events;
002
003import java.awt.Color;
004
005import com.fs.starfarer.api.Global;
006import com.fs.starfarer.api.ui.TooltipMakerAPI;
007import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
008import com.fs.starfarer.api.util.Misc;
009
010public class HABlowbackFactor extends BaseEventFactor {
011        
012        public static boolean ENABLED = true;
013        
014        public static float FRACTION = Global.getSettings().getFloat("blowbackFraction");
015        public static float PER_MONTH = Global.getSettings().getFloat("blowbackPerMonth");
016        public static float ON_RESET = Global.getSettings().getFloat("blowbackOnReset");
017        
018        public HABlowbackFactor() {
019                
020        }
021
022        @Override
023        public boolean shouldShow(BaseEventIntel intel) {
024                return ENABLED;
025//              return true;
026//              if (true) return true;
027//              int p = Math.round(((HostileActivityEventIntel)intel).getBlowback());
028//              return p > 0;
029        }
030        
031        @Override
032        public TooltipCreator getMainRowTooltip(final BaseEventIntel intel) {
033                return new BaseFactorTooltip() {
034                        @Override
035                        public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) {
036                                float opad = 10f;
037                                Color h = Misc.getHighlightColor();
038                                
039                                tooltip.addPara("Actions that postpone a crisis often have unintended consequences and "
040                                                + "cause their own problems in the long run. Ultimately, crises can not be avoided, "
041                                                + "and must instead be dealt with and exploited for the opportunities they provide.", 0f);
042                                
043                                int p = Math.round(((HostileActivityEventIntel)intel).getBlowback());
044                                tooltip.addPara("Will contribute %s of the points per month to event progress, and will "
045                                                + "also increase the value that progress is reset to after a crisis.", opad, h,
046                                                "" + Math.round(PER_MONTH * 100f) + "%");
047                                
048                                tooltip.addPara("Points remaining: %s", opad, h, "" + p);
049                        }
050                        
051                };
052        }
053
054        @Override
055        public String getProgressStr(BaseEventIntel intel) {
056                if (getProgress(intel) <= 0) return "";
057                return super.getProgressStr(intel);
058        }
059        
060        @Override
061        public int getProgress(BaseEventIntel intel) {
062                if (!ENABLED) return 0;
063                
064                int p = Math.round(((HostileActivityEventIntel)intel).getBlowback());
065                int amt = Math.round(p * PER_MONTH);
066                if (amt <= 0 && p > 0) {
067                        amt = 1;
068                }
069                return amt;
070        }
071
072        @Override
073        public String getDesc(BaseEventIntel intel) {
074                return "Blowback";
075        }
076        
077        @Override
078        public Color getDescColor(BaseEventIntel intel) {
079                if (getProgress(intel) > 0) return Misc.getTextColor();
080                return Misc.getGrayColor();
081        }
082
083}
084
085
086
087
088