21 public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
22 if (dialog ==
null)
return false;
23 if (!(dialog.getInteractionTarget() instanceof CampaignFleetAPI))
return false;
26 CampaignFleetAPI other = (CampaignFleetAPI) dialog.getInteractionTarget();
27 FactionAPI faction = other.getFaction();
29 MemoryAPI memory = memoryMap.get(MemKeys.ENTITY);
30 CargoInspectionResult result = (CargoInspectionResult) memory.get(
"$cargoInspectionResult");
32 float totalIllegalFound = 0f;
33 for (CargoStackAPI stack : result.getIllegalFound().getStacksCopy()) {
34 totalIllegalFound += stack.getSize();
36 float capacity = playerFleet.getCargo().getMaxCapacity();
38 float repLoss = totalIllegalFound / 10f * totalIllegalFound / capacity;
39 repLoss = Math.round(repLoss);
40 if (repLoss > 5) repLoss = 5f;
41 if (repLoss == 0 && totalIllegalFound > 0) repLoss = 1f;
43 RepActionEnvelope envelope =
new RepActionEnvelope(RepActions.CUSTOMS_CAUGHT_SMUGGLING, repLoss, dialog.getTextPanel());