private void prepareBringingStep() {
final SpeakerNPC npc = npcs.get("Carmen");
npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestActiveCondition(QUEST_SLOT)),
ConversationStates.ATTENDING,
"Hi again. I can #heal you, or if you brought me #ingredients I'll happily take those!",
null);
/* player asks what exactly is missing (says ingredients) */
npc.add(ConversationStates.ATTENDING, "ingredients", null,
ConversationStates.QUESTION_2, null,
new SayRequiredItemsFromCollectionAction(QUEST_SLOT, "I need [items]. Did you bring something?"));
npc.add(ConversationStates.ATTENDING,
ConversationPhrases.QUEST_MESSAGES,
new QuestActiveCondition(QUEST_SLOT),
ConversationStates.QUESTION_2,
null, new SayRequiredItemsFromCollectionAction(QUEST_SLOT, "I need [items]. Did you bring something?"));
/* player says he has a required item with him (says yes) */
npc.add(ConversationStates.QUESTION_2,
ConversationPhrases.YES_MESSAGES, null,
ConversationStates.QUESTION_2, "Great, what did you bring?",
null);
ChatAction completeAction = new MultipleActions(
new SetQuestAction(QUEST_SLOT, "done"),
new SayTextAction("Great! Now I can heal many people for free. Thanks a lot. Take this for your work."),
new IncreaseXPAction(50),
new IncreaseKarmaAction(5),
new EquipItemAction("minor potion", 5)
);
/* add triggers for the item names */
final ItemCollection items = new ItemCollection();
items.addFromQuestStateString(NEEDED_ITEMS);
for (final Map.Entry<String, Integer> entry : items.entrySet()) {
String itemName = entry.getKey();
String singular = Grammar.singular(itemName);
List<String> sl = new ArrayList<String>();
sl.add(itemName);
// handle the porcino/porcini singular/plural case with item name "porcini"
if (!singular.equals(itemName)) {
sl.add(singular);
}
// also allow to understand the misspelled "porcinis"
if (itemName.equals("porcini")) {
sl.add("porcinis");
}
npc.add(ConversationStates.QUESTION_2, sl, null,
ConversationStates.QUESTION_2, null,
new CollectRequestedItemsAction(
itemName, QUEST_SLOT,
"Good, do you have anything else?", "You have already brought " +
Grammar.quantityplnoun(entry.getValue(), itemName) + " for me but thank you anyway.",
completeAction, ConversationStates.ATTENDING));
}
/* player says he didn't bring any items (says no) */
npc.add(ConversationStates.ATTENDING, ConversationPhrases.NO_MESSAGES,
new QuestActiveCondition(QUEST_SLOT),
ConversationStates.ATTENDING,
"Ok, well just let me know if I can #help you with anything else.",
null);
/* player says he didn't bring any items to different question */
npc.add(ConversationStates.QUESTION_2,
ConversationPhrases.NO_MESSAGES,
new QuestActiveCondition(QUEST_SLOT),
ConversationStates.ATTENDING,
"Ok, well just let me know if I can #help you with anything else.", null);
/* says quest and quest can't be started nor is active*/
npc.add(ConversationStates.ATTENDING,