1package com.fs.starfarer.api.impl.campaign.submarkets;
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.Script;
7import com.fs.starfarer.api.campaign.CampaignFleetAPI;
8import com.fs.starfarer.api.campaign.CargoStackAPI;
9import com.fs.starfarer.api.campaign.CoreUIAPI;
10import com.fs.starfarer.api.campaign.econ.SubmarketAPI;
11import com.fs.starfarer.api.fleet.FleetMemberAPI;
12import com.fs.starfarer.api.impl.campaign.ids.Strings;
13import com.fs.starfarer.api.ui.TooltipMakerAPI;
14import com.fs.starfarer.api.util.Highlights;
15import com.fs.starfarer.api.util.Misc;
19 private boolean playerPaidToUnlock =
false;
31 if (
market.isPlayerOwned())
return false;
32 return super.isIllegalOnSubmarket(stack, action);
37 if (
market.isPlayerOwned())
return false;
38 return super.isIllegalOnSubmarket(commodityId, action);
43 if (
market.isPlayerOwned() ||
44 (
market.getFaction() !=
null &&
market.getFaction().isNeutralFaction()))
return false;
45 return super.isIllegalOnSubmarket(member, action);
72 return "Illegal to put into storage here";
91 this.playerPaidToUnlock = playerPaidToUnlock;
95 if (playerPaidToUnlock)
return OnClickAction.OPEN_SUBMARKET;
96 return OnClickAction.SHOW_TEXT_DIALOG;
99 private int getUnlockCost() {
103 private boolean canPlayerAffordUnlock() {
105 int credits = (int) playerFleet.getCargo().getCredits().get();
106 return credits >= getUnlockCost();
110 if (canPlayerAffordUnlock()) {
111 return "Gaining access to storage at this colony requires a one-time fee of " + getUnlockCost() +
" credits.";
113 return "Gaining access to storage at this colony requires a one-time fee of " + getUnlockCost() +
" credits, which you can't afford.";
117 Highlights h =
new Highlights();
118 h.setText(
"" + getUnlockCost());
119 if (canPlayerAffordUnlock()) {
120 h.setColors(Misc.getHighlightColor());
122 h.setColors(Misc.getNegativeHighlightColor());
127 if (canPlayerAffordUnlock()) {
128 return new DialogOption [] {
129 new DialogOption(
"Pay",
new Script() {
132 playerFleet.getCargo().getCredits().subtract(getUnlockCost());
133 playerPaidToUnlock =
true;
136 new DialogOption(
"Never mind",
null)
139 return new DialogOption [] {
140 new DialogOption(
"Never mind",
null)
168 if (!
market.isInEconomy())
return;
172 if (
market.isPlayerOwned()) {
173 tooltip.addPara(Misc.getTokenReplaced(
"$market is under your control, and there " +
174 "are no storage fees or expenses.",
market.getPrimaryEntity()), opad);
178 float f = Misc.getStorageFeeFraction();
179 int percent = (int) (f * 100f);
181 Color h = Misc.getHighlightColor();
183 if (!playerPaidToUnlock) {
184 tooltip.addPara(
"Requires a one-time access fee of %s, and a monthly fee equal to %s of the " +
185 "base value of the items in storage.", opad, h,
186 "" + getUnlockCost() + Strings.C,
"" + percent +
"%");
190 int cargoCost = (int) (Misc.getStorageCargoValue(
market) * f);
191 int shipCost = (int) (Misc.getStorageShipValue(
market) * f);
193 if (cargoCost + shipCost > 0) {
195 tooltip.addPara(
"Monthly fees and expenses (%s of base value of stored items):", opad, h,
"" + percent +
"%");
196 tooltip.beginGridFlipped(300, 1, 80, 10);
198 tooltip.addToGrid(0, j++,
"Ships in storage", Misc.getDGSCredits(shipCost));
199 tooltip.addToGrid(0, j++,
"Cargo in storage", Misc.getDGSCredits(cargoCost));
200 tooltip.addGrid(pad);
202 tooltip.addPara(
"Monthly fees and expenses are equal to %s of base value of the stored items.", opad, h,
"" + percent +
"%");
static SectorAPI getSector()
Highlights getTooltipAppendixHighlights(CoreUIAPI ui)
DialogOption[] getDialogOptions(CoreUIAPI ui)
void createTooltipAfterDescription(TooltipMakerAPI tooltip, boolean expanded)
void updateCargoPrePlayerInteraction()
boolean isIllegalOnSubmarket(FleetMemberAPI member, TransferAction action)
String getDialogText(CoreUIAPI ui)
Highlights getDialogTextHighlights(CoreUIAPI ui)
boolean isEnabled(CoreUIAPI ui)
void init(SubmarketAPI submarket)
void setPlayerPaidToUnlock(boolean playerPaidToUnlock)
boolean isIllegalOnSubmarket(CargoStackAPI stack, TransferAction action)
boolean isParticipatesInEconomy()
OnClickAction getOnClickAction(CoreUIAPI ui)
String getTooltipAppendix(CoreUIAPI ui)
String getIllegalTransferText(CargoStackAPI stack, TransferAction action)
boolean isIllegalOnSubmarket(String commodityId, TransferAction action)