001package com.fs.starfarer.api.impl.campaign.missions.luddic; 002 003import java.awt.Color; 004import java.util.List; 005import java.util.Map; 006 007import com.fs.starfarer.api.Global; 008import com.fs.starfarer.api.campaign.FactionAPI; 009import com.fs.starfarer.api.campaign.InteractionDialogAPI; 010import com.fs.starfarer.api.campaign.SectorEntityToken; 011import com.fs.starfarer.api.campaign.StarSystemAPI; 012import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin; 013import com.fs.starfarer.api.campaign.econ.MarketAPI; 014import com.fs.starfarer.api.campaign.rules.MemoryAPI; 015import com.fs.starfarer.api.characters.PersonAPI; 016import com.fs.starfarer.api.impl.campaign.ids.Tags; 017import com.fs.starfarer.api.impl.campaign.intel.misc.LuddicShrineIntel; 018import com.fs.starfarer.api.impl.campaign.missions.academy.GACelestialObject.Variation; 019import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithSearch; 020import com.fs.starfarer.api.ui.IntelUIAPI; 021import com.fs.starfarer.api.ui.TooltipMakerAPI; 022import com.fs.starfarer.api.util.Misc; 023import com.fs.starfarer.api.util.Misc.Token; 024 025public class LuddicPilgrimsPath extends HubMissionWithSearch { 026 027 public static enum Stage { 028 VISIT_SHRINES, 029 RETURN_TO_GILEAD, 030 COMPLETED, 031 } 032 033 public static String VISITED_SHRINE_JANGALA = "$lpp_visitedShrineJangala"; 034 public static String VISITED_SHRINE_KILLA = "$lpp_visitedShrineKilla"; 035 public static String VISITED_SHRINE_VOLTURN = "$lpp_visitedShrineVolturn"; 036 public static String VISITED_SHRINE_CHICOMOZTOC = "$lpp_visitedShrineChicomoztoc"; 037 public static String VISITED_SHRINE_GILEAD = "$lpp_visitedShrineGilead"; 038 public static String VISITED_SHRINE_BEHOLDER = "$lpp_visitedShrineBeholder"; 039 040 protected int xpRewardBase = 10000; 041 protected int xpRewardIncrease = 2000; 042 protected int num_rewards_given = 0; 043 044 //protected PersonAPI robed_man; 045 //protected PersonAPI some_kid; 046 //protected PersonAPI robot; 047 048 protected MarketAPI volturn; 049 protected MarketAPI gilead; 050 protected MarketAPI jangala; 051 protected MarketAPI hesperus; 052 protected SectorEntityToken killa; 053 protected SectorEntityToken beholder_station; 054 //public static float MISSION_DAYS = 120f; 055 056 //protected int payment; 057 //protected int paymentHigh; 058 059 @Override 060 protected boolean create(MarketAPI createdAt, boolean barEvent) { 061 // if already accepted by the player, abort 062 if (!setGlobalReference("$lpp_ref", "$lpp_inProgress")) { 063 return false; 064 } 065 066 volturn = Global.getSector().getEconomy().getMarket("volturn"); 067 if (volturn == null) return false; 068 //if (!volturn.getFactionId().equals("sindrian_diktat")) return false; 069 070 071 gilead = Global.getSector().getEconomy().getMarket("gilead"); 072 if (gilead == null) return false; 073 074 jangala = Global.getSector().getEconomy().getMarket("jangala"); 075 if (jangala == null) return false; 076 077 hesperus = Global.getSector().getEconomy().getMarket("hesperus"); 078 if (hesperus == null) return false; 079 080 // Find Killa! 081 StarSystemAPI yma = Global.getSector().getStarSystem("yma"); 082 for (SectorEntityToken curr : yma.getEntitiesWithTag(Tags.LUDDIC_SHRINE)) { 083 killa = curr; 084 break; 085 } 086 if (killa == null) return false; 087 088 // Find Beholder Station! 089 StarSystemAPI kumarikandam = Global.getSector().getStarSystem("kumari kandam"); 090 for (SectorEntityToken curr : kumarikandam.getEntitiesWithTag(Tags.LUDDIC_SHRINE)) { 091 beholder_station = curr; 092 break; 093 } 094 if (beholder_station == null) return false; 095 096 setStartingStage(Stage.VISIT_SHRINES); 097 addSuccessStages(Stage.COMPLETED); 098 099 setStoryMission(); 100 //addTag(Tags.INTEL_SHRINES); 101 102 // yes, these exact numbers. 103 //payment = 10000; 104 //paymentHigh = 17000; 105 106 107 // TODO - makeImportant all the shrines! 108 setStageOnGlobalFlag(Stage.RETURN_TO_GILEAD, "$lpp_visitedAllShrines"); 109 110 makeImportant(gilead, "$lpp_finishPilgrimage", Stage.RETURN_TO_GILEAD); 111 //setStageOnMemoryFlag(Stage.COMPLETED, gilead, "$lpp_completed"); 112 113 setStageOnGlobalFlag(Stage.COMPLETED, "$lpp_completed"); 114 115 116 117 setName("The Pilgrim's Path"); 118 setRepFactionChangesNone(); 119 setRepPersonChangesNone(); 120 121 beginStageTrigger(Stage.COMPLETED); 122 triggerMakeNonStoryCritical("jangala", "hesperus", "gilead", "volturn"); 123 triggerSetGlobalMemoryValue("$lpp_missionCompleted", true); 124 endTrigger(); 125 126 127 //makeImportant(coureuse, null, Stage.TALK_TO_COUREUSE); 128// Global.getSector().getMemoryWithoutUpdate().unset("$gaFC_triedToSeeCavin"); 129 return true; 130 } 131 132 protected void updateInteractionDataImpl() { 133 set("$lpp_stage", getCurrentStage()); 134 //set("$anh_robedman", robed_man); 135 } 136 137 @Override 138 protected boolean callAction(String action, String ruleId, final InteractionDialogAPI dialog, 139 List<Token> params, final Map<String, MemoryAPI> memoryMap) { 140// if ("THEDUEL".equals(action)) { 141// TextPanelAPI text = dialog.getTextPanel(); 142// text.setFontOrbitronUnnecessarilyLarge(); 143// Color color = Misc.getBasePlayerColor(); 144// color = Global.getSector().getFaction(Factions.HEGEMONY).getBaseUIColor(); 145// text.addPara("THE DUEL", color); 146// text.setFontInsignia(); 147// text.addImage("misc", "THEDUEL"); 148// return true; 149// } 150 151 if ("giveVisitXP".equals(action)) 152 { 153 num_rewards_given++; 154 long xp_to_give = (long)(num_rewards_given * xpRewardIncrease + xpRewardBase); 155 Global.getSector().getPlayerStats().addXP(xp_to_give, dialog.getTextPanel()); 156 return true; 157 } 158 else if ("giveLastVisitXP".equals(action)) 159 { 160 num_rewards_given++; 161 long xp_to_give = (long)(num_rewards_given * xpRewardIncrease + xpRewardBase); 162 163 // it's possible the player visited shrines before taking on the mission 164 // so add all that XP as a lump sum onto the end 165 int visited_shrines = getNumberOfShrinesVisited(); 166 if (num_rewards_given < visited_shrines) 167 { 168 for (int i = num_rewards_given; i < visited_shrines; i++) 169 { 170 xp_to_give += (long)(i * xpRewardIncrease + xpRewardBase); 171 } 172 } 173 174 Global.getSector().getPlayerStats().addXP(xp_to_give, dialog.getTextPanel()); 175 return true; 176 } 177 else if ("checkShrinesVisited".equals(action)) { 178 179 int visited_shrines = getNumberOfShrinesVisited(); 180 int numberOfShrinesToComplete = 6; 181 System.out.print("checkShrinesVisited = " + Integer.toString(visited_shrines)); 182 183 if( visited_shrines >= numberOfShrinesToComplete) { 184 Global.getSector().getMemoryWithoutUpdate().set("$lpp_visitedAllShrines", true); 185 } 186 return true; 187 } 188 else if ("postMissionCleanup".equals(action)) { 189 // clean up any unneeded memory things. 190 Global.getSector().getMemoryWithoutUpdate().unset("$lpp_didHesperusFirstShrineAttempt"); 191 Global.getSector().getMemoryWithoutUpdate().unset("$lpp_didHookStart"); 192 gilead.getMemoryWithoutUpdate().unset("$lpp_finishPilgrimage"); 193 return true; 194 } 195 196 return super.callAction(action, ruleId, dialog, params, memoryMap); 197 } 198 199 @Override 200 public void createSmallDescription(TooltipMakerAPI info, float width, float height) { 201 Color h = Misc.getHighlightColor(); 202 Color g = Misc.getGrayColor(); 203 float pad = 3f; 204 float opad = 10f; 205 206 FactionAPI faction = getFactionForUIColors(); 207 PersonAPI person = getPerson(); 208 209 info.addImage(Global.getSettings().getSpriteName("illustrations", "luddic_shrine"), width, opad); 210 211 addDescriptionForCurrentStage(info, width, height); 212 213 addBulletPoints(info, ListInfoMode.IN_DESC); 214 } 215 216 217 @Override 218 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) { 219 float opad = 10f; 220 Color h = Misc.getHighlightColor(); 221 //Color h2 = Misc.getDarkHighlightColor(); 222 //FactionAPI church = Global.getSector().getFaction(Factions.LUDDIC_CHURCH); 223 224 //info.addImage(robed_man.getPortraitSprite(), width, 128, opad); 225 /* 226 if (Global.getSector().getMemoryWithoutUpdate().getBoolean(VISITED_SHRINE_JANGALA)) { 227 228 } 229 */ 230 231 if (currentStage == Stage.VISIT_SHRINES) { 232 info.addPara("Visit the six shrines of the Pilgrim's Path. The pilgrimage is traditionally completed by returning to Gilead, in the Canaan system.", opad); 233 } 234 else if (currentStage == Stage.RETURN_TO_GILEAD) { 235 info.addPara("Return to the shrine of Gilead in the Canaan system to complete the Pilgrim's Path.", opad); 236 } 237 238 LuddicShrineIntel.addShowShrinesButton(this, width, height, info); 239 } 240 241 @Override 242 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) { 243 Color h = Misc.getHighlightColor(); 244 if (currentStage == Stage.VISIT_SHRINES) { 245 info.addPara("Visit the six Luddic shrines", tc, pad); 246 return true; 247 } 248 else if (currentStage == Stage.RETURN_TO_GILEAD) { 249 info.addPara("Complete the pilgrimage on Gilead, in the Canaan system", tc, pad); 250 return true; 251 } 252 return false; 253 254 /* 255 Color h = Misc.getHighlightColor(); 256 if (currentStage == Stage.DROP_OFF) { 257 info.addPara("Deliver " + getWithoutArticle(thing) + " to specified location in the " + 258 system.getNameWithLowercaseTypeShort(), tc, pad); 259 return true; 260 } 261 */ 262 } 263 264 @Override 265 public String getBaseName() { 266 return "Pilgrim's Path"; 267 } 268 269 @Override 270 public String getPostfixForState() { 271 if (startingStage != null) { 272 return ""; 273 } 274 return super.getPostfixForState(); 275 } 276 277 public void buttonPressConfirmed(Object buttonId, IntelUIAPI ui) { 278 if (buttonId == LuddicShrineIntel.BUTTON_SHOW_SHRINES) { 279 LuddicShrineIntel.toggleShrineList(this, ui); 280 return; 281 } 282 super.buttonPressConfirmed(buttonId, ui); 283 } 284 285 286 public int getNumberOfShrinesVisited() { 287 int count = 0; 288 289 for (IntelInfoPlugin intel : Global.getSector().getIntelManager().getIntel(LuddicShrineIntel.class)) { 290 LuddicShrineIntel shrine = (LuddicShrineIntel) intel; 291 if (LuddicShrineIntel.isVisited(shrine.getEntity())) { 292 count++; 293 } 294 } 295 296 System.out.print(" Shrine count found = " + count); 297 return count; 298 } 299 300 301 302 public static int getTotalShrines() { 303 return Global.getSector().getIntelManager().getIntel(LuddicShrineIntel.class).size(); 304 } 305} 306 307 308 309 310