Starsector API
Loading...
Searching...
No Matches
GalatianAcademyStipend.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.tutorial;
2
3import com.fs.starfarer.api.Global;
4import com.fs.starfarer.api.campaign.econ.MarketAPI;
5import com.fs.starfarer.api.campaign.econ.MonthlyReport;
6import com.fs.starfarer.api.campaign.econ.MonthlyReport.FDNode;
7import com.fs.starfarer.api.campaign.listeners.EconomyTickListener;
8import com.fs.starfarer.api.impl.campaign.shared.SharedData;
9import com.fs.starfarer.api.ui.TooltipMakerAPI;
10import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
11import com.fs.starfarer.api.util.Misc;
12
13public class GalatianAcademyStipend implements EconomyTickListener, TooltipCreator {
14
15 public static float DURATION = 365 + 365 + 365 + 20;
16 public static int STIPEND = 15000;
17
18 protected long startTime = 0;
20 Global.getSector().getListenerManager().addListener(this);
21 startTime = Global.getSector().getClock().getTimestamp();
22 Global.getSector().getMemoryWithoutUpdate().set("$playerReceivingGAStipend", true);
23 }
24
25 public void reportEconomyTick(int iterIndex) {
26 if (!Global.getSettings().getBoolean("enableStipend")) return;
27
28 int lastIterInMonth = (int) Global.getSettings().getFloat("economyIterPerMonth") - 1;
29 if (iterIndex != lastIterInMonth) return;
30
31 float daysActive = Global.getSector().getClock().getElapsedDaysSince(startTime);
32 MarketAPI ancyra = Global.getSector().getEconomy().getMarket("ancyra_market");
33 if (daysActive > DURATION || ancyra == null) {
34 Global.getSector().getListenerManager().removeListener(this);
35 Global.getSector().getMemoryWithoutUpdate().unset("$playerReceivingGAStipend");
36 return;
37 }
38
39
40
41 MonthlyReport report = SharedData.getData().getCurrentReport();
42
43
44 int stipend = getStipend();
45 FDNode fleetNode = report.getNode(MonthlyReport.FLEET);
46
47 FDNode stipendNode = report.getNode(fleetNode, "GA_stipend");
48 stipendNode.income = stipend;
49 stipendNode.name = "Stipend from Galatia Academy";
50 stipendNode.icon = Global.getSettings().getSpriteName("income_report", "generic_income");
51 stipendNode.tooltipCreator = this;
52 }
53
54 protected int getStipend() {
55 return STIPEND;
56 }
57
58 public void reportEconomyMonthEnd() {
59 }
60
61 public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) {
62 float daysActive = Global.getSector().getClock().getElapsedDaysSince(startTime);
63 tooltip.addPara("A monthly stipend of %s from the Galatian Academy, " +
64 "for the aid you've recently rendered.",
65 0f, Misc.getHighlightColor(), Misc.getDGSCredits(getStipend()));
66
67 float rem = DURATION - daysActive;
68 int months = (int) (rem / 30f);
69 //if (months > 0 && months <= 12) {
70 if (months > 0) {
71 tooltip.addPara("You should continue receiving the stipend for another %s months.", 10f,
72 Misc.getHighlightColor(), "" + months);
73 } else if (months <= 0) {
74 tooltip.addPara("This month's payment was the last.", 10f);
75 }
76 }
77
78 public float getTooltipWidth(Object tooltipParam) {
79 return 450;
80 }
81
82 public boolean isTooltipExpandable(Object tooltipParam) {
83 return false;
84 }
85}
86
87
88
static SettingsAPI getSettings()
Definition Global.java:51
static SectorAPI getSector()
Definition Global.java:59
void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam)
String getSpriteName(String category, String id)
boolean getBoolean(String key)