26 public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
27 if (dialog ==
null)
return false;
28 if (!(dialog.getInteractionTarget() instanceof CampaignFleetAPI))
return false;
31 CampaignFleetAPI fleet = (CampaignFleetAPI) dialog.getInteractionTarget();
33 FactionAPI faction = fleet.getFaction();
34 TextPanelAPI text = dialog.getTextPanel();
37 text.addParagraph(
"Admiral skills:");
38 for (SkillLevelAPI skill : fleet.getCommanderStats().getSkillsCopy()) {
39 if (skill.getSkill().isAdmiralSkill()) {
40 text.addParagraph(
" " + skill.getSkill().getId());
46 MemoryAPI mem = fleet.getMemoryWithoutUpdate();
47 if (!mem.contains(
"$shownFleetDescAlready")) {
48 mem.set(
"$shownFleetDescAlready",
true, 0);
51 boolean smuggler = mem.getBoolean(MemFlags.MEMORY_KEY_SMUGGLER);
52 boolean trader = mem.getBoolean(MemFlags.MEMORY_KEY_TRADE_FLEET);
54 Color hl = Misc.getHighlightColor();
55 Color red = Misc.getNegativeHighlightColor();
57 RouteData route = RouteManager.getInstance().getRoute(EconomyFleetRouteManager.SOURCE_ID, fleet);
58 if ((trader || smuggler) && route !=
null) {
59 EconomyRouteData data = (EconomyRouteData) route.getCustom();
61 Integer
id = route.getCurrentSegmentId();
63 String from = data.from.getName();
64 String to = data.to.getName();
66 if (
id >= EconomyFleetRouteManager.ROUTE_DST_LOAD) {
67 from = data.to.getName();
68 to = data.from.getName();
72 if (
id <= EconomyFleetRouteManager.ROUTE_DST_UNLOAD) {
73 cargo = EconomyRouteData.getCargoList(data.cargoDeliver);
74 if (!cargo.isEmpty() &&
id == EconomyFleetRouteManager.ROUTE_SRC_LOAD) cargo +=
" (being loaded)";
76 cargo = EconomyRouteData.getCargoList(data.cargoReturn);
77 if (!cargo.isEmpty() &&
id == EconomyFleetRouteManager.ROUTE_DST_LOAD) cargo +=
" (being loaded)";
80 if (trader || smuggler) {
81 LabelAPI label = text.addParagraph(
"You encounter " + fleet.getFaction().getPersonNamePrefixAOrAn() +
" " +
82 fleet.getFaction().getPersonNamePrefix() +
" "+ fleet.getName().toLowerCase() +
".");
83 label.highlightFirst(fleet.getFaction().getPersonNamePrefix());
84 label.setHighlightColor(fleet.getFaction().getBaseUIColor());
86 text.setFontSmallInsignia();
88 text.addParagraph(
"--------------------------------------------------------------------------------------------------------------");
89 if (data.from.isHidden()) {
90 text.addPara(
"Port of origin: %s", hl,
"Unknown");
92 text.addPara(
"Port of origin: %s", hl, data.from.getName());
94 text.addPara(
"Current destination: %s", hl, to);
95 if (from.equals(data.to.getName())) {
96 text.addPara(
"Returning from: %s", hl, data.to.getName());
98 if (cargo.isEmpty()) {
99 text.addPara(
"No cargo");
101 text.addPara(
"Cargo: %s", hl, cargo);
105 text.addParagraph(
"--------------------------------------------------------------------------------------------------------------");
106 text.setFontInsignia();
108 int penalty = Math.round(ShippingDisruption.getPenaltyForShippingLost(data.from.getSize(), data.size) * 100f);
111 if (!fleet.getFaction().isPlayerFaction()) {
112 if (data.from.isHidden()) {
113 text.addPara(
"If this fleet does not reach its destination safely, it will cause a shortage " +
114 "of the commodities it carries. " +
115 "In addition, its loss would reduce the accessibility of its port of origin by %s for up to three months.",
116 Misc.getTextColor(), Misc.getHighlightColor(),
"" + penalty +
"%");
118 text.addPara(
"If this fleet does not reach its destination safely, it will cause a shortage " +
119 "of the commodities it carries. " +
120 "In addition, its loss would reduce the accessbility of " + data.from.getName() +
" by %s for up to three months.",
121 Misc.getTextColor(), Misc.getHighlightColor(),
"" + penalty +
"%");
127 if (!fleet.getFaction().isPlayerFaction() && !fleet.getFaction().isNeutralFaction()) {
128 if (fleet.getMemoryWithoutUpdate().getBoolean(MemFlags.MEMORY_KEY_NO_REP_IMPACT)) {
129 if (Misc.isDecentralized(fleet.getFaction())) {
133 text.addPara(
"Engaging this fleet in battle will not cause any changes to your reputation with the faction it nominally belongs to.",
134 Misc.getHighlightColor(),
"will not cause any changes to your reputation");
136 text.addPara(
"This fleet is operating without official sanction from the faction it nominally belongs to. " +
137 "Engaging it in battle will not cause any changes to your reputation.",
138 Misc.getHighlightColor(),
"will not cause any changes to your reputation");
140 }
else if (fleet.getMemoryWithoutUpdate().getBoolean(MemFlags.MEMORY_KEY_LOW_REP_IMPACT) && fleet.knowsWhoPlayerIs()) {
141 if (Misc.isDecentralized(fleet.getFaction())) {
146 text.addPara(
"Engaging this fleet in battle will not cause immediate hostilities " +
147 "with the faction it nominally belongs to, though it will slightly strain the relationship.",
148 Misc.getHighlightColor(),
"will not cause immediate hostilities");
150 text.addPara(
"This fleet is either operating in a legal gray area or its behavior " +
151 "falls outside accepted norms. Engaging it in battle will not cause immediate hostilities " +
152 "with the faction it nominally belongs to, though it will slightly strain the relationship.",
153 Misc.getHighlightColor(),
"will not cause immediate hostilities");