001package com.fs.starfarer.api.campaign.econ; 002 003import java.awt.Color; 004import java.util.Collection; 005import java.util.LinkedHashSet; 006import java.util.List; 007import java.util.Random; 008import java.util.Set; 009 010import org.lwjgl.util.vector.Vector2f; 011 012import com.fs.starfarer.api.campaign.CampaignFleetAPI; 013import com.fs.starfarer.api.campaign.CommDirectoryAPI; 014import com.fs.starfarer.api.campaign.FactionAPI; 015import com.fs.starfarer.api.campaign.FactionAPI.ShipPickParams; 016import com.fs.starfarer.api.campaign.LocationAPI; 017import com.fs.starfarer.api.campaign.PlanetAPI; 018import com.fs.starfarer.api.campaign.SectorEntityToken; 019import com.fs.starfarer.api.campaign.StarSystemAPI; 020import com.fs.starfarer.api.campaign.rules.HasMemory; 021import com.fs.starfarer.api.campaign.rules.MemoryAPI; 022import com.fs.starfarer.api.characters.PersonAPI; 023import com.fs.starfarer.api.combat.MutableStat; 024import com.fs.starfarer.api.combat.MutableStatWithTempMods; 025import com.fs.starfarer.api.combat.StatBonus; 026import com.fs.starfarer.api.fleet.MutableMarketStatsAPI; 027import com.fs.starfarer.api.fleet.ShipFilter; 028import com.fs.starfarer.api.fleet.ShipRolePick; 029import com.fs.starfarer.api.impl.campaign.econ.impl.ConstructionQueue; 030import com.fs.starfarer.api.impl.campaign.population.PopulationComposition; 031 032public interface MarketAPI extends HasMemory { 033 034 public static enum MarketInteractionMode { 035 LOCAL, 036 REMOTE, 037 } 038 039 public static enum SurveyLevel { 040 NONE, 041 SEEN, 042 PRELIMINARY, 043 FULL 044 } 045 046 SectorEntityToken getPrimaryEntity(); 047 Set<SectorEntityToken> getConnectedEntities(); 048 049 /** 050 * Returns string ID of the specified object. 051 * @return String Id 052 */ 053 String getId(); 054 String getName(); 055 int getSize(); 056 057 //Vector2f getLocation(); 058 059 void setSize(int size); 060 061 List<CommodityOnMarketAPI> getAllCommodities(); 062 CommodityOnMarketAPI getCommodityData(String commodityId); 063 List<CommodityOnMarketAPI> getCommoditiesWithTag(String tag); 064 List<CommodityOnMarketAPI> getCommoditiesWithTags(String ... tags); 065 066 MarketDemandAPI getDemand(String demandClass); 067 List<MarketDemandAPI> getDemandWithTag(String tag); 068 069 List<MarketConditionAPI> getConditions(); 070 /** 071 * Adds market condition to specified MarketAPI object. 072 * Example: String "ORE_MODERATE" from Conditions class or "ore_moderate" id from market_conditions.csv. 073 * @param id String id of condition. 074 */ 075 String addCondition(String id); 076 077 /** 078 * Returns token which can be used to remove this specific condition. 079 * @param id 080 * @param param 081 * @return 082 */ 083 String addCondition(String id, Object param); 084 085 /** 086 * Removes all copies of this condition. 087 * @param id 088 */ 089 void removeCondition(String id); 090 091 /** 092 * Removes specific copy of a condition. 093 * @param token return value from addCondition() 094 */ 095 void removeSpecificCondition(String token); 096 097 boolean hasCondition(String id); 098 boolean hasSpecificCondition(String token); 099 void reapplyConditions(); 100 void reapplyCondition(String token); 101 102 MarketDemandDataAPI getDemandData(); 103 104// StabilityTrackerAPI getStabilityTracker(); 105 106 MutableStat getTariff(); 107 108 /** 109 * Modifier for the price the market is willing to buy things at. 110 * Only the multiplier part of this works. 111 * @return 112 */ 113 StatBonus getDemandPriceMod(); 114 115 /** 116 * Modifier for the price the market is willing to sell things at. 117 * @return 118 */ 119 StatBonus getSupplyPriceMod(); 120 121 122 /** 123 * Price for the market selling quantity of given commodity, given the current stockpile/demand/etc. 124 * @param commodityId 125 * @param quantity 126 * @return 127 */ 128 float getSupplyPrice(String commodityId, double quantity, boolean isPlayerPrice); 129 130 131 /** 132 * Price for the market buying quantity of given commodity, given the current stockpile/demand/etc. 133 * @param commodityId 134 * @param quantity 135 * @return 136 */ 137 float getDemandPrice(String commodityId, double quantity, boolean isPlayerPrice); 138 139 140 /** 141 * @param commodityId 142 * @param quantity 143 * @param existingTransactionUtility positive for stuff sold to market, negative for stuff bought from market. 144 * @param isPlayerPrice 145 * @return 146 */ 147 float getDemandPriceAssumingExistingTransaction(String commodityId, double quantity, double existingTransactionUtility, boolean isPlayerPrice); 148 149 /** 150 * @param commodityId 151 * @param quantity 152 * @param existingTransactionUtility positive for stuff sold to market, negative for stuff bought from market. 153 * @param isPlayerPrice 154 * @return 155 */ 156 float getSupplyPriceAssumingExistingTransaction(String commodityId, double quantity, double existingTransactionUtility, boolean isPlayerPrice); 157 158 /** 159 * Checks against FactionAPI.getIllegalCommodities() for the faction owning the market. 160 * @param commodityId 161 * @return 162 */ 163 boolean isIllegal(String commodityId); 164 165 /** 166 * Checks against FactionAPI.getIllegalCommodities() for the faction owning the market. 167 * @param com 168 * @return 169 */ 170 boolean isIllegal(CommodityOnMarketAPI com); 171 172 MutableStatWithTempMods getStability(); 173 174 /** 175 * Integer value from 0 to 10, inclusive. 176 * @return float value 177 */ 178 float getStabilityValue(); 179 180 FactionAPI getFaction(); 181 String getFactionId(); 182 183 void addSubmarket(String specId); 184 boolean hasSubmarket(String specId); 185 List<SubmarketAPI> getSubmarketsCopy(); 186 void removeSubmarket(String specId); 187 SubmarketAPI getSubmarket(String specId); 188 189 /** 190 * Sets the ownership of the market to a faction. 191 * Example: "Factions.PIRATES" from Factions class or "pirates" from pirates.faction. 192 * An entry in the factions.csv is needed to point the game to correct .faction file. 193 * 194 * @param factionId String id of faction. 195 */ 196 void setFactionId(String factionId); 197 198 199 /** 200 * Updates the local price multiplier (based on stability). 201 */ 202 void updatePriceMult(); 203 MemoryAPI getMemory(); 204 205 MemoryAPI getMemoryWithoutUpdate(); 206 207 /** 208 * May add more than one ship if a fallback specifies to add multiple ships. 209 * (For example, 2 small freighters if a medium freighter isn't available.) 210 * 211 * See FactionAPI.pickShipAndAddToFleet for return value explanation. 212 * @return 213 */ 214 float pickShipAndAddToFleet(String role, ShipPickParams params, CampaignFleetAPI fleet); 215 216 float pickShipAndAddToFleet(String role, String factionId, ShipPickParams params, CampaignFleetAPI fleet); 217 218 float getShipQualityFactor(); 219 220 221 StarSystemAPI getStarSystem(); 222 LocationAPI getContainingLocation(); 223 224 225 Vector2f getLocationInHyperspace(); 226 void setPrimaryEntity(SectorEntityToken primaryEntity); 227 228 229// /** 230// * Will be null unless inited. Repeated invocations will do nothing. 231// */ 232// void initCommDirectory(); 233 234 /** 235 * @return 236 */ 237 CommDirectoryAPI getCommDirectory(); 238 239 void addPerson(PersonAPI person); 240 void removePerson(PersonAPI person); 241 List<PersonAPI> getPeopleCopy(); 242 MutableMarketStatsAPI getStats(); 243 244 List<ShipRolePick> pickShipsForRole(String role, ShipPickParams params, 245 Random random, ShipFilter filter); 246 List<ShipRolePick> pickShipsForRole(String role, String factionId, ShipPickParams params, Random random, ShipFilter filter); 247 248 249 boolean isPlanetConditionMarketOnly(); 250 void setPlanetConditionMarketOnly(boolean isPlanetConditionMarketOnly); 251 void setName(String name); 252 MutableStat getHazard(); 253 254 /** 255 * 1f = 100%. 256 * @return 257 */ 258 float getHazardValue(); 259 260// boolean isSurveyed(); 261// void setSurveyed(boolean surveyed); 262 PlanetAPI getPlanetEntity(); 263 264 SurveyLevel getSurveyLevel(); 265 266 /** 267 * Sets the survey level of the specified market object. Reference the MarketAPI enum SurveyLevel for full list. 268 * Example: MarketAPI.SurveyLevel.FULL for fully surveyed market. Reference 269 * @param MarketAPI SurveyLevel 270 */ 271 void setSurveyLevel(SurveyLevel surveyLevel); 272 273 274 void advance(float amount); 275 boolean isForceNoConvertOnSave(); 276 void setForceNoConvertOnSave(boolean forceNoConvertOnSave); 277 void updatePrices(); 278 279 /** 280 * Get a condition using its unique id. 281 * @param token 282 * @return 283 */ 284 MarketConditionAPI getSpecificCondition(String token); 285 286 287 /** 288 * Get the first condition of a specific type; id is non-unique. 289 * @param id 290 * @return 291 */ 292 MarketConditionAPI getFirstCondition(String id); 293 boolean isInEconomy(); 294 295 List<Industry> getIndustries(); 296 297 /** 298 * Set industry string id to add an industry to market. 299 * Example: "Industries.MINING" from Industries class or "mining" from industries.csv. 300 * 301 * @param id String id of industry 302 */ 303 void addIndustry(String id); 304 305 /** 306 * Pass in null for mode when calling this from API code. 307 * @param id 308 * @param mode 309 */ 310 void removeIndustry(String id, MarketInteractionMode mode, boolean forUpgrade); 311 void reapplyIndustries(); 312 313 /** 314 * Same as getLocationInHyperspace(). 315 * @return 316 */ 317 Vector2f getLocation(); 318 319 /** 320 * In-system, i.e. not affected by fuel shortages etc. 321 * @return 322 */ 323 Industry getIndustry(String id); 324 325 boolean hasIndustry(String id); 326 List<CommodityOnMarketAPI> getCommoditiesCopy(); 327 MarketConditionAPI getCondition(String id); 328 329 float getIndustryUpkeep(); 330 float getIndustryIncome(); 331 boolean hasWaystation(); 332 Industry instantiateIndustry(String id); 333 MarketAPI clone(); 334 void clearCommodities(); 335 boolean isPlayerOwned(); 336 void setPlayerOwned(boolean playerOwned); 337 float getPrevStability(); 338 float getExportIncome(boolean withOverhead); 339 float getNetIncome(); 340 MutableStat getIncomeMult(); 341 MutableStat getUpkeepMult(); 342 PopulationComposition getPopulation(); 343 PopulationComposition getIncoming(); 344 void setPopulation(PopulationComposition population); 345 void setIncoming(PopulationComposition incoming); 346// StatBonus getIncomingImmigrationMod(); 347// StatBonus getOutgoingImmigrationMod(); 348 349 LinkedHashSet<MarketImmigrationModifier> getImmigrationModifiers(); 350 LinkedHashSet<MarketImmigrationModifier> getTransientImmigrationModifiers(); 351 void addImmigrationModifier(MarketImmigrationModifier mod); 352 void removeImmigrationModifier(MarketImmigrationModifier mod); 353 void addTransientImmigrationModifier(MarketImmigrationModifier mod); 354 void removeTransientImmigrationModifier(MarketImmigrationModifier mod); 355 List<MarketImmigrationModifier> getAllImmigrationModifiers(); 356 357// boolean isAllowImport(); 358// void setAllowImport(boolean allowImport); 359// boolean isAllowExport(); 360// void setAllowExport(boolean allowExport); 361 362 float getIncentiveCredits(); 363 void setIncentiveCredits(float incentiveCredits); 364 365 boolean isImmigrationIncentivesOn(); 366 void setImmigrationIncentivesOn(Boolean incentivesOn); 367 368 369 boolean isFreePort(); 370 void setFreePort(boolean freePort); 371 boolean isImmigrationClosed(); 372 void setImmigrationClosed(boolean closed); 373 boolean wasIncomingSetBefore(); 374 void addCondition(MarketConditionAPI mc); 375 376 PersonAPI getAdmin(); 377 /** 378 * The old admin, if any, is removed from the market and its comm directory. 379 * @param admin 380 */ 381 void setAdmin(PersonAPI admin); 382 float getDaysInExistence(); 383 void setDaysInExistence(float daysInExistence); 384 /** 385 * o = 0%, 1 = 100%. 386 * @return 387 */ 388 StatBonus getAccessibilityMod(); 389 boolean hasSpaceport(); 390 void setHasSpaceport(boolean hasSpaceport); 391 void setHasWaystation(boolean hasWaystation); 392 393 /** 394 * Markets with the same economy group will not be visible from markets outside this group 395 * (in "nearby markets" dialog etc) and will only trade with each other. null by default, which 396 * forms its own group. 397 * @return 398 */ 399 String getEconGroup(); 400 401 /** 402 * Markets with the same economy group will not be visible from markets outside this group 403 * (in "nearby markets" dialog etc) and will only trade with each other. null by default, which 404 * forms its own group. 405 */ 406 void setEconGroup(String econGroup); 407 408 void addIndustry(String id, List<String> params); 409 boolean hasTag(String tag); 410 void addTag(String tag); 411 void removeTag(String tag); 412 Collection<String> getTags(); 413 void clearTags(); 414 String getOnOrAt(); 415 416 Color getTextColorForFactionOrPlanet(); 417 Color getDarkColorForFactionOrPlanet(); 418 419 /** 420 * Hidden markets do not offer missions or otherwise participate in events/intel/etc that would 421 * indirectly reveal their existence to the player. 422 * @return 423 */ 424 boolean isHidden(); 425 426 /** 427 * Hidden markets do not offer missions or otherwise participate in events/intel/etc that would 428 * indirectly reveal their existence to the player. Hidden markets also do not participate in the economy. 429 */ 430 void setHidden(Boolean hidden); 431 432 boolean isUseStockpilesForShortages(); 433 void setUseStockpilesForShortages(boolean useStockpilesForShortages); 434 float getShortageCounteringCost(); 435 void addSubmarket(SubmarketAPI submarket); 436 ConstructionQueue getConstructionQueue(); 437 boolean isInHyperspace(); 438 439 LinkedHashSet<String> getSuppressedConditions(); 440 boolean isConditionSuppressed(String id); 441 void suppressCondition(String id); 442 void unsuppressCondition(String id); 443 float getImmigrationIncentivesCost(); 444 boolean isInvalidMissionTarget(); 445 void setInvalidMissionTarget(Boolean invalidMissionTarget); 446 void setSuppressedConditions(LinkedHashSet<String> suppressedConditions); 447 void setRetainSuppressedConditionsSetWhenEmpty(Boolean retainSuppressedConditionsSetWhenEmpty); 448 float getGrossIncome(); 449 boolean hasFunctionalIndustry(String id); 450 451 /** 452 * Transient. Do not use unless the market is a faked-up one. 453 * @param faction 454 */ 455 void setCachedFaction(FactionAPI faction); 456} 457 458 459 460 461