28 public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
29 if (dialog ==
null)
return false;
31 String missionId = params.get(0).getString(memoryMap);
32 Boolean accept =
null;
33 if (params.size() > 1) {
34 accept = params.get(1).getBoolean(memoryMap);
37 if (accept ==
null) accept =
true;
41 throw new RuntimeException(
"Mission with spec [" + missionId +
"] not found");
44 HubMission mission = spec.createMission();
46 SectorEntityToken entity = dialog.getInteractionTarget();
47 PersonAPI person = entity.getActivePerson();
55 long seed = BarEventManager.getInstance().getSeed(
null, person, extra);
57 mission.setGenRandom(
new Random(seed));
60 mission.setPersonOverride(person);
62 String key =
"$beginMission_seedExtra";
63 String extra = person.getMemoryWithoutUpdate().getString(key);
64 long seed = BarEventManager.getInstance().getSeed(
null, person, extra);
65 person.getMemoryWithoutUpdate().set(key,
"" + seed);
66 mission.setGenRandom(
new Random(seed));
69 mission.createAndAbortIfFailed(entity.getMarket(),
false);
71 if (mission.isMissionCreationAborted()) {
72 MemoryAPI memory = memoryMap.get(MemKeys.LOCAL);
73 if (memory ==
null && dialog.getInteractionTarget() !=
null) {
74 if (dialog.getInteractionTarget().getActivePerson() !=
null) {
75 memory = dialog.getInteractionTarget().getActivePerson().getMemoryWithoutUpdate();
77 memory = dialog.getInteractionTarget().getMemoryWithoutUpdate();
80 memory.set(
"$missionCreationFailed", mission.getMissionId());
87 mission.accept(dialog, memoryMap);