1package com.fs.starfarer.api.impl.campaign.rulecmd.salvage.special;
3import com.fs.starfarer.api.Global;
4import com.fs.starfarer.api.campaign.CampaignFleetAPI;
5import com.fs.starfarer.api.campaign.InteractionDialogAPI;
6import com.fs.starfarer.api.characters.PersonAPI;
7import com.fs.starfarer.api.impl.campaign.ids.Commodities;
8import com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity;
9import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.SalvageSpecialInteraction.SalvageSpecialData;
10import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.SalvageSpecialInteraction.SalvageSpecialPlugin;
14 public static final String
OPEN =
"open";
15 public static final String
NOT_NOW =
"not_now";
17 public static enum SleeperSpecialType {
30 public static class SleeperPodsSpecialData
implements SalvageSpecialData {
31 public SleeperSpecialType type;
34 public PersonAPI officer;
35 public SleeperPodsSpecialData(SleeperSpecialType type, PersonAPI officer) {
37 this.officer = officer;
40 public SleeperPodsSpecialData(SleeperSpecialType type,
int min,
int max) {
46 public SalvageSpecialPlugin createSpecialPlugin() {
51 private SleeperPodsSpecialData data;
53 private int quantity = 1;
59 public void init(InteractionDialogAPI
dialog, Object specialData) {
60 super.init(
dialog, specialData);
62 data = (SleeperPodsSpecialData) specialData;
77 quantity = data.min +
random.nextInt(data.max - data.min + 1);
79 if (data.type == SleeperSpecialType.ORGANS) {
81 if (quantity < 1) quantity = 1;
86 int crewBerths = (int) (player.getCargo().getMaxPersonnel() - player.getCargo().getTotalPersonnel());
89 if (crewBerths < 0) crewBerths = 0;
92 SleeperSpecialType type = data.type;
94 if (type == SleeperSpecialType.CREW) quantity = Math.min(crewBerths, quantity);
95 if (type == SleeperSpecialType.MARINES) quantity = Math.min(crewBerths, quantity);
97 if (type == SleeperSpecialType.ADMIN || type == SleeperSpecialType.OFFICER) quantity = 1;
123 addText(
"While making a preliminary assessment, your salvage crews " +
124 "find some occupied sleeper pods still running on backup power.");
127 options.addOption(
"Attempt to open the pods",
OPEN);
136 addText(
"While making a preliminary assessment, your salvage crews " +
137 "find some occupied mil-grade sleeper pods still running on backup power.");
140 options.addOption(
"Attempt to open the pods",
OPEN);
149 addText(
"While making a preliminary assessment, your salvage crews " +
150 "find a single occupied sleeper pod still running on backup power.");
153 options.addOption(
"Attempt to open the pod",
OPEN);
163 addText(
"While making a preliminary assessment, your salvage crews " +
164 "find some occupied sleeper pods still running on backup power.");
167 options.addOption(
"Attempt to open the pods",
OPEN);
176 if (
OPEN.equals(optionData)) {
180 addText(
"One by one, the pods begin to open as the thawing process completes. " +
181 "Most of the occupants come through alive, if somewhat dazed.");
183 playerFleet.getCargo().addCommodity(Commodities.CREW, quantity);
188 addText(
"One by one, the pods begin to open as the thawing process completes. " +
189 "Most of the occupants come through alive, if somewhat dazed.");
191 playerFleet.getCargo().addCommodity(Commodities.MARINES, quantity);
196 addText(
"The thawing process completes, and the pod opens. " +
197 "It contains an experienced officer, who joins you out of gratitude for being rescued.");
199 playerFleet.getFleetData().addOfficer(data.officer);
203 addText(
"The thawing process completes, and the pod opens. " +
204 "It contains an experienced planetary administrator, who joins you out of gratitude for being rescued.");
210 addText(
"One by one, the pods begin to open as the thawing process completes. " +
211 "Unfortunately, it's been too long, or something went wrong along the way, and there are no survivors - at least, not with any brain activity.");
213 playerFleet.getCargo().addCommodity(Commodities.ORGANS, quantity);
221 }
else if (
NOT_NOW.equals(optionData)) {
static SectorAPI getSector()
static void addAdminGainText(PersonAPI admin, TextPanelAPI text)
static void addOfficerGainText(PersonAPI officer, TextPanelAPI text)
static void addCommodityGainText(String commodityId, int quantity, TextPanelAPI text)
void setDone(boolean done)
InteractionDialogAPI dialog
void addText(String format)
void setShowAgain(boolean showAgain)
void setEndWithContinue(boolean endWithContinue)
CampaignFleetAPI playerFleet
static final String NOT_NOW
void optionSelected(String optionText, Object optionData)
void init(InteractionDialogAPI dialog, Object specialData)