001package com.fs.starfarer.api.impl.campaign.intel.events; 002 003import java.awt.Color; 004 005import com.fs.starfarer.api.campaign.StarSystemAPI; 006import com.fs.starfarer.api.campaign.econ.MarketAPI; 007import com.fs.starfarer.api.impl.campaign.intel.PerseanLeagueMembership; 008import com.fs.starfarer.api.impl.campaign.rulecmd.HA_CMD; 009import com.fs.starfarer.api.ui.MapParams; 010import com.fs.starfarer.api.ui.TooltipMakerAPI; 011import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator; 012import com.fs.starfarer.api.ui.UIPanelAPI; 013import com.fs.starfarer.api.util.Misc; 014 015public class StandardPerseanLeagueActivityCause extends BaseHostileActivityCause2 { 016 017 /** IF CHANGING THESE: ALSO UPDATE THE plReynardHannanJoinSelNo RULE **/ 018 public static int LARGE_COLONY = 5; 019 public static int MEDIUM_COLONY = 4; 020 public static int COUNT_IF_MEDIUM = 3; 021 022 public static float MAX_MAG = 0.5f; 023 024 public StandardPerseanLeagueActivityCause(HostileActivityEventIntel intel) { 025 super(intel); 026 } 027 028 @Override 029 public TooltipCreator getTooltip() { 030 return new BaseFactorTooltip() { 031 public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) { 032 float opad = 10f; 033 tooltip.addPara("Going to Kazeron and negotiating to join the League is likely to get " 034 + "this harassment to stop. If " 035 + "left unchecked, this low-grade conflict will eventually come to a head and is likely to " 036 + "be resolved one way or another.", 0f, Misc.getHighlightColor(), 037 "join the League"); 038 039 tooltip.addPara("Event progress value is based on the number and size of colonies " 040 + "under your control. Requires one size %s colony, or at least %s colonies with one " 041 + "being at least size %s.", opad, Misc.getHighlightColor(), 042 "" + LARGE_COLONY, "" + COUNT_IF_MEDIUM, "" + MEDIUM_COLONY); 043 044 MarketAPI kazeron = PerseanLeagueHostileActivityFactor.getKazeron(false); 045 if (kazeron != null && kazeron.getStarSystem() != null) { 046// tooltip.addPara("%s, size: %s, stability: %s", opad, Misc.getHighlightColor(), 047// kazeron.getName(), 048// "" + kazeron.getSize(), 049// "" + (int) kazeron.getStabilityValue()); 050 051 MapParams params = new MapParams(); 052 params.showSystem(kazeron.getStarSystem()); 053 float w = tooltip.getWidthSoFar(); 054 float h = Math.round(w / 1.6f); 055 params.positionToShowAllMarkersAndSystems(true, Math.min(w, h)); 056 UIPanelAPI map = tooltip.createSectorMap(w, h, params, kazeron.getName() + " (" + kazeron.getStarSystem().getNameWithLowercaseTypeShort() + ")"); 057 tooltip.addCustom(map, opad); 058 } 059 } 060 }; 061 } 062 063 @Override 064 public boolean shouldShow() { 065 return getProgress() != 0; 066 } 067 068 @Override 069 public String getProgressStr() { 070 //if (KantaCMD.playerHasProtection()) return EventFactor.NEGATED_FACTOR_PROGRESS; 071 return super.getProgressStr(); 072 } 073 074 @Override 075 public Color getProgressColor(BaseEventIntel intel) { 076 //if (KantaCMD.playerHasProtection()) return Misc.getPositiveHighlightColor(); 077 // TODO Auto-generated method stub 078 return super.getProgressColor(intel); 079 } 080 081 public int getProgress() { 082 //if (true) return 0; 083 if (!HA_CMD.canPlayerJoinTheLeague()) { 084 return 0; 085 } 086 087// if (Global.getSector().getPlayerMemoryWithoutUpdate().getBoolean( 088// PerseanLeagueHostileActivityFactor.DEFEATED_BLOCKADE)) { 089 if (PerseanLeagueMembership.isDefeatedBlockadeOrPunEx()) { 090 return 0; 091 } 092 093 int score = 0; 094 for (MarketAPI market : Misc.getPlayerMarkets(false)) { 095 int size = market.getSize(); 096// if (size <= 4) { 097// score += size * 2; 098// } else if (size == 5) { 099// score += size * 2 + 2; 100// } else if (size == 6) { 101// score += size * 2 + 4; 102// } else { 103// score += size * 3; 104// } 105 if (size <= 4) { 106 score += size; 107 } else if (size == 5) { 108 score += size + 2; 109 } else if (size == 6) { 110 score += size + 4; 111 } else { 112 score += size + 6; 113 } 114 } 115 116 int progress = score; 117 118 return progress; 119 } 120 121 122 public String getDesc() { 123 return "Colony presence and size"; 124 } 125 126 127 public float getMagnitudeContribution(StarSystemAPI system) { 128 //if (KantaCMD.playerHasProtection()) return 0f; 129 if (getProgress() <= 0) return 0f; 130 131 return (0.4f + 0.6f * intel.getMarketPresenceFactor(system)) * MAX_MAG; 132 } 133 134} 135 136 137 138 139 140