127 protected boolean create(MarketAPI createdAt,
boolean barEvent) {
130 boolean allowArmsDealer =
true;
131 boolean allowTrader = createdAt !=
null && createdAt.getCommodityData(Commodities.SHIPS).getMaxSupply() > 0;
132 boolean allowMilitary = allowTrader && createdAt !=
null && Misc.isMilitary(createdAt);
133 if (createdAt.isPlayerOwned()) {
135 allowMilitary =
false;
137 if (Factions.PIRATES.equals(createdAt.getFaction().getId())) {
138 allowMilitary =
false;
144 setGiverRank(Ranks.CITIZEN);
145 post = Ranks.POST_ARMS_DEALER;
146 setGiverTags(Tags.CONTACT_UNDERWORLD);
147 setGiverFaction(Factions.PIRATES);
149 List<String> posts =
new ArrayList<String>();
150 posts.add(Ranks.POST_SUPPLY_OFFICER);
151 if (Misc.isMilitary(createdAt)) {
152 posts.add(Ranks.POST_BASE_COMMANDER);
154 if (Misc.hasOrbitalStation(createdAt)) {
155 posts.add(Ranks.POST_STATION_COMMANDER);
157 post = pickOne(posts);
158 setGiverRank(pickOne(Ranks.GROUND_CAPTAIN, Ranks.GROUND_COLONEL, Ranks.GROUND_MAJOR,
159 Ranks.SPACE_COMMANDER, Ranks.SPACE_CAPTAIN, Ranks.SPACE_ADMIRAL));
160 setGiverTags(Tags.CONTACT_MILITARY);
161 }
else if (allowTrader) {
162 setGiverRank(Ranks.CITIZEN);
163 post = pickOne(Ranks.POST_TRADER, Ranks.POST_COMMODITIES_AGENT, Ranks.POST_PORTMASTER,
164 Ranks.POST_MERCHANT, Ranks.POST_INVESTOR, Ranks.POST_EXECUTIVE,
165 Ranks.POST_SENIOR_EXECUTIVE, Ranks.POST_ADMINISTRATOR);
166 setGiverTags(Tags.CONTACT_TRADE);
168 setGiverFaction(Factions.INDEPENDENT);
171 if (post ==
null && allowArmsDealer) {
172 setGiverRank(Ranks.CITIZEN);
173 post = Ranks.POST_ARMS_DEALER;
174 setGiverTags(Tags.CONTACT_UNDERWORLD);
175 setGiverFaction(Factions.PIRATES);
177 if (post ==
null)
return false;
180 if (post.equals(Ranks.POST_SENIOR_EXECUTIVE) ||
181 post.equals(Ranks.POST_BASE_COMMANDER) ||
182 post.equals(Ranks.POST_ADMINISTRATOR)) {
183 setGiverImportance(pickHighImportance());
184 }
else if (post.equals(Ranks.POST_ARMS_DEALER)) {
187 setGiverImportance(pickImportance());
190 findOrCreateGiver(createdAt,
false,
false);
191 setGiverIsPotentialContactOnSuccess();
194 PersonAPI person = getPerson();
195 if (person ==
null)
return false;
197 if (!setPersonMissionRef(person,
"$cpc_ref")) {
201 market = getPerson().getMarket();
202 if (
market ==
null)
return false;
203 if (Misc.getStorage(
market) ==
null)
return false;
209 armsDealer = getPerson().hasTag(Tags.CONTACT_UNDERWORLD);
216 if (capMult > 1) capMult = 1f;
219 if (person.hasTag(Tags.CONTACT_MILITARY) && allowMilitary) {
225 PersonImportance imp = getPerson().getImportance();
235 }
else if (person.hasTag(Tags.CONTACT_MILITARY) && allowMilitary) {
239 }
else if (person.hasTag(Tags.CONTACT_TRADE) && allowTrader) {
245 setStartingStage(Stage.WAITING);
246 setSuccessStage(Stage.DELIVERED);
247 setFailureStage(Stage.FAILED);
250 connectWithDaysElapsed(Stage.WAITING, Stage.DELIVERED,
PROD_DAYS);
252 setStageOnMarketDecivilized(Stage.FAILED,
market);
259 boolean [] add =
new boolean[3];
260 add[genRandom.nextInt(add.length)] =
true;
261 add[genRandom.nextInt(add.length)] =
true;
262 add[genRandom.nextInt(add.length)] =
true;
264 PersonImportance imp = getPerson().getImportance();
265 if (imp == PersonImportance.VERY_HIGH) {
271 Set<WeaponType> wTypes =
new LinkedHashSet<WeaponAPI.WeaponType>();
272 Set<WeaponSize> wSizes =
new LinkedHashSet<WeaponAPI.WeaponSize>();
273 Set<HullSize> hullSizes =
new LinkedHashSet<HullSize>();
275 WeightedRandomPicker<WeaponType> wTypePicker =
new WeightedRandomPicker<WeaponType>(genRandom);
276 wTypePicker.add(WeaponType.BALLISTIC);
277 wTypePicker.add(WeaponType.ENERGY);
278 wTypePicker.add(WeaponType.MISSILE);
279 WeightedRandomPicker<WeaponSize> wSizePicker =
new WeightedRandomPicker<WeaponSize>(genRandom);
280 wSizePicker.add(WeaponSize.SMALL);
281 wSizePicker.add(WeaponSize.MEDIUM);
282 wSizePicker.add(WeaponSize.LARGE);
291 wSizes.add(WeaponSize.SMALL);
292 wTypes.add(wTypePicker.pickAndRemove());
293 nWeapons = 5 + genRandom.nextInt(6);
294 nFighters = 1 + genRandom.nextInt(3);
298 wSizePicker.remove(WeaponSize.LARGE);
299 wSizes.add(wSizePicker.pickAndRemove());
300 wTypes.add(wTypePicker.pickAndRemove());
301 hullSizes.add(HullSize.FRIGATE);
302 nWeapons = 10 + genRandom.nextInt(6);
303 nShips = 5 + genRandom.nextInt(3);
304 nFighters = 3 + genRandom.nextInt(3);
310 wSizes.add(wSizePicker.pickAndRemove());
311 wSizes.add(wSizePicker.pickAndRemove());
312 wTypes.add(wTypePicker.pickAndRemove());
313 hullSizes.add(HullSize.FRIGATE);
314 hullSizes.add(HullSize.DESTROYER);
315 nWeapons = 20 + genRandom.nextInt(6);
316 nShips = 10 + genRandom.nextInt(3);
317 nFighters = 5 + genRandom.nextInt(3);
321 wSizes.add(wSizePicker.pickAndRemove());
322 wSizes.add(wSizePicker.pickAndRemove());
323 wTypes.add(wTypePicker.pickAndRemove());
324 wTypes.add(wTypePicker.pickAndRemove());
325 hullSizes.add(HullSize.FRIGATE);
326 hullSizes.add(HullSize.DESTROYER);
327 hullSizes.add(HullSize.CRUISER);
328 nWeapons = 20 + genRandom.nextInt(6);
329 nShips = 10 + genRandom.nextInt(3);
330 nFighters = 7 + genRandom.nextInt(3);
333 wSizes.add(WeaponSize.SMALL);
334 wSizes.add(WeaponSize.MEDIUM);
335 wSizes.add(WeaponSize.LARGE);
337 hullSizes.add(HullSize.FRIGATE);
338 hullSizes.add(HullSize.DESTROYER);
339 hullSizes.add(HullSize.CRUISER);
340 hullSizes.add(HullSize.CAPITAL_SHIP);
342 wTypes.add(WeaponType.BALLISTIC);
343 wTypes.add(WeaponType.ENERGY);
344 wTypes.add(WeaponType.MISSILE);
352 FactionProductionAPI prod =
Global.
getSector().getPlayerFaction().getProduction().clone();
356 WeightedRandomPicker<String> picker =
new WeightedRandomPicker<String>(genRandom);
359 if (spec.hasTag(Items.TAG_NO_DEALER))
continue;
360 if (spec.hasTag(Tags.NO_SELL) && !spec.hasTag(Items.TAG_DEALER))
continue;
361 if (spec.hasTag(Tags.RESTRICTED))
continue;
362 if (spec.getHints().contains(ShipTypeHints.HIDE_IN_CODEX))
continue;
363 if (spec.getHints().contains(ShipTypeHints.UNBOARDABLE))
continue;
364 if (spec.isDefaultDHull())
continue;
365 if (spec.isDHullOldMethod())
continue;
366 if (
"shuttlepod".equals(spec.getHullId()))
continue;
367 if (
ships.contains(spec.getHullId()))
continue;
368 if (!hullSizes.contains(spec.getHullSize()))
continue;
369 float cost = prod.createSampleItem(ProductionItemType.SHIP, spec.getHullId(), 1).getBaseCost();
372 picker.add(spec.getHullId(), 10f);
378 for (
int i = 0; i < num && !picker.isEmpty(); i++) {
379 ships.add(picker.pickAndRemove());
384 WeightedRandomPicker<String> picker =
new WeightedRandomPicker<String>(genRandom);
387 if (spec.hasTag(Items.TAG_NO_DEALER))
continue;
388 if (spec.hasTag(Tags.NO_SELL) && !spec.hasTag(Items.TAG_DEALER))
continue;
389 if (spec.hasTag(Tags.RESTRICTED))
continue;
390 if (spec.getAIHints().contains(AIHints.SYSTEM))
continue;
391 if (
weapons.contains(spec.getWeaponId()))
continue;
392 if (!wTypes.contains(spec.getType()))
continue;
393 if (!wSizes.contains(spec.getSize()))
continue;
394 float cost = prod.createSampleItem(ProductionItemType.WEAPON, spec.getWeaponId(), 1).getBaseCost();
397 picker.add(spec.getWeaponId(), 10f);
403 for (
int i = 0; i < num && !picker.isEmpty(); i++) {
404 weapons.add(picker.pickAndRemove());
409 WeightedRandomPicker<String> picker =
new WeightedRandomPicker<String>(genRandom);
414 if (spec.hasTag(Items.TAG_NO_DEALER))
continue;
415 if (spec.hasTag(Tags.NO_SELL) && !spec.hasTag(Items.TAG_DEALER))
continue;
416 if (spec.hasTag(Tags.RESTRICTED))
continue;
417 if (
fighters.contains(spec.getId()))
continue;
418 float cost = prod.createSampleItem(ProductionItemType.FIGHTER, spec.getId(), 1).getBaseCost();
421 picker.add(spec.getId(), 10f);
427 for (
int i = 0; i < num && !picker.isEmpty(); i++) {
428 fighters.add(picker.pickAndRemove());
471 Color h = Misc.getHighlightColor();
472 if (currentStage == Stage.WAITING) {
473 float elapsed = getElapsedInCurrentStage();
474 int d = (int) Math.round(
PROD_DAYS - elapsed);
475 PersonAPI person = getPerson();
477 LabelAPI label = info.addPara(
"The order will be delivered to storage " +
market.getOnOrAt() +
" " +
market.getName() +
478 " in %s " + getDayOrDays(d) +
".", opad,
479 Misc.getHighlightColor(),
"" + d);
480 label.setHighlight(
market.getName(),
"" + d);
481 label.setHighlightColors(
market.getFaction().getBaseUIColor(), h);
487 }
else if (currentStage == Stage.DELIVERED) {
488 float elapsed = getElapsedInCurrentStage();
489 int d = (int) Math.round(elapsed);
490 LabelAPI label = info.addPara(
"The order was delivered to storage " +
market.getOnOrAt() +
" " +
market.getName() +
491 " %s " + getDayOrDays(d) +
" ago.", opad,
492 Misc.getHighlightColor(),
"" + d);
493 label.setHighlight(
market.getName(),
"" + d);
494 label.setHighlightColors(
market.getFaction().getBaseUIColor(), h);
497 addDeleteButton(info, width);
498 }
else if (currentStage == Stage.FAILED) {
499 if (
market.hasCondition(Conditions.DECIVILIZED)) {
500 info.addPara(
"This order will not be completed because %s" +
501 " has decivilized.", opad,
504 info.addPara(
"You've learned that this order will not be completed.", opad);
562 public void setCurrentStage(Object next, InteractionDialogAPI dialog, Map<String, MemoryAPI> memoryMap) {
563 super.setCurrentStage(next, dialog, memoryMap);
565 if (currentStage == Stage.DELIVERED) {
566 StoragePlugin plugin = (StoragePlugin) Misc.getStorage(getPerson().getMarket());
567 if (plugin ==
null)
return;
568 plugin.setPlayerPaidToUnlock(
true);
570 CargoAPI cargo = plugin.getCargo();
571 for (CargoAPI curr :
data.data.values()) {
572 cargo.addAll(curr,
true);
578 PersonAPI person = getPerson();
579 if (person ==
null || person.getMarket() ==
null)
return;
580 String patrolFaction = person.getMarket().getFactionId();
581 if (patrolFaction.equals(person.getFaction().getId()) ||
582 Misc.isPirateFaction(person.getMarket().getFaction()) ||
583 Misc.isDecentralized(person.getMarket().getFaction()) ||
584 patrolFaction.equals(Factions.PLAYER)) {
592 e.
triggerCreateFleet(FleetSize.LARGE, FleetQuality.DEFAULT, patrolFaction, FleetTypes.PATROL_LARGE,
new Vector2f());
594 "information regarding the arms dealer",
"it",
595 "information concerning the activities of known arms dealer, " + person.getNameString(),
596 getRoundNumber(
cost / 2),
597 false, ComplicationRepImpact.FULL,
600 e.triggerSetPatrol();
666 cost = prod.getTotalCurrentCost();
667 data =
new ProductionData();
668 CargoAPI cargo =
data.getCargo(
"Order manifest");
670 float quality = ShipQuality.getShipQuality(
market,
market.getFactionId());
672 quality = Math.max(quality, 1.5f);
677 ships.getFleetData().setShipNameRandom(genRandom);
678 DefaultFleetInflaterParams p =
new DefaultFleetInflaterParams();
680 p.mode = ShipPickMode.PRIORITY_THEN_ALL;
681 p.persistent =
false;
682 p.seed = genRandom.nextLong();
685 FleetInflater inflater = Misc.getInflater(
ships, p);
686 ships.setInflater(inflater);
688 for (ItemInProductionAPI item : prod.getCurrent()) {
689 int count = item.getQuantity();
691 if (item.getType() == ProductionItemType.SHIP) {
692 for (
int i = 0; i < count; i++) {
693 ships.getFleetData().addFleetMember(item.getSpecId() +
"_Hull");
695 }
else if (item.getType() == ProductionItemType.FIGHTER) {
696 cargo.addFighters(item.getSpecId(), count);
697 }
else if (item.getType() == ProductionItemType.WEAPON) {
698 cargo.addWeapons(item.getSpecId(), count);
703 ships.inflateIfNeeded();
704 for (FleetMemberAPI member :
ships.getFleetData().getMembersListCopy()) {
706 if (member.getVariant().getSource() == VariantSource.REFIT) {
707 member.getVariant().clear();
709 cargo.getMothballedShips().addFleetMember(member);
714 if (
data ==
null)
return;
716 Color h = Misc.getHighlightColor();
717 Color g = Misc.getGrayColor();
718 Color tc = Misc.getTextColor();
723 List<String> keys =
new ArrayList<String>(
data.data.keySet());
724 Collections.sort(keys,
new Comparator<String>() {
725 public int compare(String o1, String o2) {
726 return o1.compareTo(o2);
730 for (String key : keys) {
731 CargoAPI cargo =
data.data.get(key);
732 if (cargo.isEmpty() &&
733 ((cargo.getMothballedShips() ==
null ||
734 cargo.getMothballedShips().getMembersListCopy().isEmpty()))) {
738 info.addSectionHeading(key,
faction.getBaseUIColor(),
faction.getDarkUIColor(),
739 Alignment.MID, opad);
741 if (!cargo.getStacksCopy().isEmpty()) {
742 info.addPara(
"Ship weapons and fighters:", opad);
743 info.showCargo(cargo, 20,
true, opad);
746 if (!cargo.getMothballedShips().getMembersListCopy().isEmpty()) {
747 CountingMap<String> counts =
new CountingMap<String>();
748 for (FleetMemberAPI member : cargo.getMothballedShips().getMembersListCopy()) {
749 counts.add(member.getVariant().getHullSpec().getHullName() +
" " + member.getVariant().getDesignation());
752 info.addPara(
"Ship hulls:", opad);
753 info.showShips(cargo.getMothballedShips().getMembersListCopy(), 20,
true,
754 getCurrentStage() == Stage.WAITING, opad);