001package com.fs.starfarer.api.impl.campaign.intel.events;
002
003import com.fs.starfarer.api.Global;
004import com.fs.starfarer.api.campaign.FactionAPI;
005import com.fs.starfarer.api.campaign.StarSystemAPI;
006import com.fs.starfarer.api.campaign.econ.MarketAPI;
007import com.fs.starfarer.api.impl.campaign.ids.Conditions;
008import com.fs.starfarer.api.impl.campaign.ids.Factions;
009import com.fs.starfarer.api.ui.TooltipMakerAPI;
010import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
011import com.fs.starfarer.api.util.Misc;
012
013public class LuddicChurchStandardActivityCause extends BaseHostileActivityCause2 {
014
015        public static float MAX_MAG = 0.3f;
016        
017        public LuddicChurchStandardActivityCause(HostileActivityEventIntel intel) {
018                super(intel);
019        }
020
021        @Override
022        public TooltipCreator getTooltip() {
023                return new BaseFactorTooltip() {
024                        public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) {
025                                float opad = 10f;
026                                tooltip.addPara("Negotiating with the Luddic Church about controlling the "
027                                                + "immigration of the faithful to your colonies "
028                                                + "is likely to get this harassment to stop. If "
029                                                + "left unchecked, this low-grade conflict will eventually come to a head and is likely to "
030                                                + "be resolved one way or another.", 0f, Misc.getHighlightColor(),
031                                                "Negotiating");
032                                
033                                FactionAPI f = Global.getSector().getFaction(Factions.LUDDIC_CHURCH);
034                                tooltip.addPara("Event progress value is based on the number and size of colonies "
035                                                + "with the \"Luddic Majority\" condition.", opad, f.getBaseUIColor(),
036                                                "Luddic Majority");
037                        }
038                };
039        }
040        
041        public int getProgress() {
042                if (LuddicChurchHostileActivityFactor.isDefeatedExpedition()) return 0;
043                if (LuddicChurchHostileActivityFactor.isMadeDeal()) return 0;
044
045
046                int score = 0;
047                for (MarketAPI market : Misc.getPlayerMarkets(false)) {
048                        if (!market.hasCondition(Conditions.LUDDIC_MAJORITY)) continue;
049                        
050                        int size = market.getSize();
051                        score += size;
052//                      if (size <= 4) {
053//                              score += size * 2;
054//                      } else if (size == 5) {
055//                              score += size * 2 + 2;
056//                      } else if (size == 6) {
057//                              score += size * 2 + 4;
058//                      } else {
059//                              score += size * 3;
060//                      }
061                }
062                
063                int progress = score;
064                
065                return progress;
066        }
067        
068        
069        public String getDesc() {
070                return "Colonies with a Luddic Majority";
071        }
072
073        
074        public float getMagnitudeContribution(StarSystemAPI system) {
075                //if (KantaCMD.playerHasProtection()) return 0f;
076                if (getProgress() <= 0) return 0f;
077                
078                float total = 0f;
079                for (MarketAPI market : Misc.getMarketsInLocation(system, Factions.PLAYER)) {
080                        if (!market.hasCondition(Conditions.LUDDIC_MAJORITY)) continue;
081                        total += market.getSize();
082                }
083                
084                float f = total / 6f;
085                if (f > 1f) f = 1f;
086                
087                return f * MAX_MAG; 
088        }
089
090}
091
092
093
094
095
096
097
098