165 List<CommodityOnMarketAPI> commodities =
new ArrayList<CommodityOnMarketAPI>();
166 for (CommodityOnMarketAPI com :
market.getCommoditiesCopy()) {
167 if (com.isNonEcon())
continue;
168 if (com.isMeta())
continue;
169 if (com.isPersonnel())
continue;
170 if (com.isIllegal())
continue;
172 if (com.getAvailable() <= 0)
continue;
173 if (com.getMaxSupply() <= 0)
continue;
175 commodities.add(com);
178 List<DestinationData> potential =
new ArrayList<DestinationData>();
182 for (MarketAPI other :
Global.
getSector().getEconomy().getMarketsCopy()) {
183 if (other ==
market)
continue;
184 if (other.isHidden())
continue;
185 if (other.isInvalidMissionTarget())
continue;
187 if (other.getEconGroup() ==
null &&
market.getEconGroup() !=
null)
continue;
188 if (other.getEconGroup() !=
null && !other.getEconGroup().equals(
market.getEconGroup()))
continue;
190 if (other.getStarSystem() ==
null)
continue;
193 for (CommodityOnMarketAPI com : commodities) {
195 CommodityOnMarketAPI otherCom = other.getCommodityData(com.getDemandClass());
196 if (otherCom.getMaxDemand() <= 0)
continue;
198 DestinationData
data =
new DestinationData(
market, other, com, otherCom);
199 if (
data.illegal)
continue;
200 if (
data.score > maxScore) {
201 maxScore =
data.score;
203 if (
data.distLY > maxDist) {
204 maxDist =
data.distLY;
209 if (maxDist > 10) maxDist = 10;
211 WeightedRandomPicker<DestinationData> picker =
new WeightedRandomPicker<DestinationData>(
random);
212 for (
int i = 0; i < potential.size(); i++) {
213 DestinationData d = potential.get(i);
214 if (d.score > maxScore * 0.5f && d.distLY > maxDist * 0.5f) {
215 picker.add(d, d.score * d.score * d.score);
232 DestinationData pick = picker.pick();
234 if (pick ==
null)
return;
241 quantity = (int) cargo.getMaxCapacity();
242 if (pick.com.isFuel()) {
243 quantity = (int) cargo.getMaxFuel();
252 if (pick.com.isFuel()) {
269 quantity *= Math.min(1f, 200f / pick.comFrom.getCommodity().getBasePrice());
271 int limit = (int) (pick.comFrom.getAvailable() * pick.comFrom.getCommodity().getEconUnit());
272 limit *= 0.75f + 0.5f *
random.nextFloat();
285 float base = pick.comFrom.getMarket().getSupplyPrice(pick.comFrom.getId(), 1,
true);
288 base = Math.min(100, 4000 /
quantity);
295 float minBase = 100f - 50f * Math.min(1f,
quantity / 500f);
296 minBase = (base + minBase) * 0.75f;
298 if (base < minBase) base = minBase;
302 float mult = pick.score / 30f;
306 if (mult < 0.75f) mult = 0.75f;
320 escrow = (int) (
quantity * pick.comFrom.getCommodity().getBasePrice());
324 if (
market.getFaction() == pick.dest.getFaction()) {
341 String
id =
"negotiate_id";
342 options.addOption(
"Negotiate a higher fee for the delivery",
id);
344 StoryOptionParams params =
new StoryOptionParams(
id, 1,
"negotiateDeliveryFee", Sounds.STORY_POINT_SPEND_INDUSTRY,
345 "Negotiated higher fee for delivery of " +
data.comFrom.getCommodity().getLowerCaseName() +
" to " +
data.dest.getName());
347 SetStoryOption.set(
dialog, params,
348 new BaseOptionStoryPointActionDelegate(
dialog, params) {
351 public void confirm() {
362 public String getTitle() {
368 public void createDescription(TooltipMakerAPI info) {
371 info.addSpacer(-opad);
373 info.setParaInsigniaLarge();
374 info.addPara(
"You're able to negotiate the delivery fee from %s up to " +
375 "%s.", 0f, Misc.getHighlightColor(),
376 Misc.getDGSCredits(
reward),
379 info.addSpacer(opad * 2f);
380 addActionCostSection(info);
466 if (
market.isPlayerOwned()) {
469 str =
"\"Oh, it's you, " + sir +
"!\", " +
getHeOrShe() +
470 " exclaims. Taking a moment to recover " +
getHisOrHer() +
" composure, " +
getHeOrShe() +
" says \"We've got a little logistical problem that could use " +
471 "your personal touch. " +
472 "There are %s units of " +
data.comFrom.getCommodity().getLowerCaseName() +
" that urgently need to be delivered " +
474 ", in the " +
data.dest.getStarSystem().getNameWithLowercaseType() +
". ";
476 str +=
"However, recent pirate activity has been making that difficult, and the regular trade fleets " +
477 "aren't quite up to the task.\"";
478 }
else if (
data.fromHasCells ||
data.hasCells) {
479 str +=
"However, recent Pather cell activity has been making that difficult, and the regular trade fleets " +
480 "aren't quite up to the task.\"";
482 str +=
"But, well, you know what trader captains are like. " +
483 "There have been some disagreements over hazard pay, and it's left us in the lurch.\"";
486 str =
"After a brief introduction, " +
getHeOrShe() +
" wastes no time in getting to the point.\n\n" +
487 "\"I've got %s units of " +
data.comFrom.getCommodity().getLowerCaseName() +
" that urgently need to be delivered " +
489 ", in the " +
data.dest.getStarSystem().getNameWithLowercaseType() +
". ";
491 str +=
"Recent pirate activity has been making that difficult, but you look like someone that could " +
492 "get the job done.\"";
493 }
else if (
data.fromHasCells ||
data.hasCells) {
494 str +=
"Recent Pather cell activity has been making that difficult, but I'm sure you can handle " +
497 str +=
"We've had some disputes with the regular shipping company, and it's left us in the lurch. " +
498 "Should be a milk run for someone like you, though.\"";
504 String where =
"located in hyperspace,";
505 if (
data.dest.getStarSystem() !=
null) {
507 where =
"located in the " +
data.dest.getStarSystem().getNameWithLowercaseType() +
"";
510 str +=
"\n\nYou recall that " +
data.dest.getName() +
" is under %s control, and " + where +
".";
513 if (
data.comFrom.isFuel()) {
514 int cap = cargo.getFreeFuelSpace();
516 str +=
" Your fleet's fuel tanks can hold an additional %s units of fuel.";
518 str +=
"%sYour fleet's fuel tanks are currently full.";
521 int cap = (int) cargo.getSpaceLeft();
523 str +=
" Your fleet's holds can accommodate an additional %s units of cargo.";
525 str +=
"%sYour fleet's cargo holds are currently full.";
529 if (
market.isPlayerOwned()) {
530 str +=
"\n\n" + Misc.ucFirst(
getHeOrShe()) +
" double-checks something on " +
getHisOrHer() +
" pad. " +
531 "\"The customer will pay %s upon delivery within %s days. Can you take this on?\"";
534 str +=
"\n\n" + Misc.ucFirst(
getHeOrShe()) +
" double-checks something on " +
getHisOrHer() +
" pad. " +
535 "\"The offer is %s credits, payable upon delivery within %s days. You'll also have to " +
536 "transfer %s to an escrow account. This will be returned to you " +
537 "when you complete the delivery - " +
538 "standard insurance procedure, you understand.\"";
540 str +=
"\n\n" + Misc.ucFirst(
getHeOrShe()) +
" double-checks something on " +
getHisOrHer() +
" pad. " +
541 "\"The offer is %s credits, payable upon delivery within %s days. You in?\"";
552 if (
data.comFrom.isFuel()) {
553 cap = cargo.getFreeFuelSpace();
555 cap = (int) cargo.getSpaceLeft();
557 return new String [] { Misc.getWithDGS(
quantity),
data.dest.getName(),
558 data.dest.getFaction().getPersonNamePrefix(),
560 cap > 1 ? Misc.getWithDGS(cap) :
" ",
561 Misc.getDGSCredits(
reward),
563 Misc.getDGSCredits(
escrow) };
567 return new Color [] { Misc.getHighlightColor(),
570 data.dest.getFaction().getBaseUIColor(),
572 Misc.getHighlightColor(),
573 Misc.getHighlightColor(),
574 Misc.getHighlightColor(),
575 Misc.getHighlightColor() };