Starsector API
Loading...
Searching...
No Matches
CommodityIconCounts.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.econ;
2
3import com.fs.starfarer.api.Global;
4import com.fs.starfarer.api.campaign.econ.CommodityOnMarketAPI;
5
6public class CommodityIconCounts {
7
8 protected CommodityOnMarketAPI com;
9
10 public int available;
11 public int production;
12 public int demand;
13 public int nonDemandExport;
14 public int deficit;
15 public int imports;
17 public int demandMet;
18 public int globalExport;
20 public int canNotExport;
21 public int extra;
22
23 public CommodityIconCounts(CommodityOnMarketAPI com) {
24 this.com = com;
25
26// int shippingGlobal = CommodityMarketData.getShippingCapacity(com.getMarket(), false);
27// int shippingInFaction = CommodityMarketData.getShippingCapacity(com.getMarket(), true);
28 int shippingGlobal = Global.getSettings().getShippingCapacity(com.getMarket(), false);
29 int shippingInFaction = Global.getSettings().getShippingCapacity(com.getMarket(), true);
30
31// if (com.getId().equals("food") && com.getMarket().getId().equals("jangala")) {
32// System.out.println("efwefwef");
33// }
34
35 available = com.getAvailable();
36 production = com.getMaxSupply();
37// if (com.getCommodity().isPrimary()) {
38// List<CommodityOnMarket> withSameDemandClass = ((Market)com.getMarket()).getCommoditiesWithClass(com.getDemandClass());
39// for (CommodityOnMarket other : withSameDemandClass) {
40// if (com == other) continue;
41// production += other.getMaxSupply();
42// }
43// }
44 production = Math.min(production, available);
45
46 int export = 0;
47 demand = com.getMaxDemand();
48 export = (int) Math.min(production, shippingGlobal);
49
50 extra = available - Math.max(export, demand);
51 if (extra < 0) extra = 0;
52
54 demandMet = Math.min(available, demand);
55
57 //imports = available - production - extra;
59
60
62 if (demandMetWithLocal > demand && demand > 0) {
65 }
66
69 canNotExport = 0;
70
71
72// if (com.getMarket().getName().equals("Stral") && com.getId().equals(Commodities.SUPPLIES)) {
73// System.out.println("wefwefe");
74// }
75
76 if (globalExport > shippingGlobal) {
77 inFactionOnlyExport = globalExport - shippingGlobal;
78 globalExport = shippingGlobal;
79 }
80 if (globalExport + inFactionOnlyExport > shippingInFaction) {
81 canNotExport = globalExport + inFactionOnlyExport - shippingInFaction;
83 }
84
86 if (aboveMax > 0) {
87 inFactionOnlyExport -= aboveMax;
88 if (inFactionOnlyExport < 0) {
90 }
91 }
92
93
95 if (canNotExport < 0) canNotExport = 0;
97 if (imports < 0) imports = 0;
98 if (deficit < 0) deficit = 0;
100 }
101
102}
103
104
105
106
107
108
109
110
static SettingsAPI getSettings()
Definition Global.java:51
int getShippingCapacity(MarketAPI market, boolean inFaction)