null);
add(ConversationStates.ATTENDING, "borrow",
new AndCondition(
new LevelGreaterThanCondition(5),
new QuestCompletedCondition("pizza_delivery"),
new QuestNotActiveCondition(QUEST_SLOT)),
ConversationStates.ATTENDING,
"I lend out " + Grammar.enumerateCollectionWithHash(ITEMS) + ". If you're interested, please say which you want.",
null);
// player already has borrowed something it didn't return and will pay for it
add(ConversationStates.ATTENDING, "borrow",
new AndCondition(new QuestActiveCondition(QUEST_SLOT), new NotCondition(new PlayerHasRecordedItemWithHimCondition(QUEST_SLOT))),
ConversationStates.QUESTION_1,
"You didn't return what I last lent you! Do you want to pay for it at a cost of " + COST + " money?",
null);
// player already has borrowed something it didn't return and will return it
add(ConversationStates.ATTENDING, "borrow",
new AndCondition(new QuestActiveCondition(QUEST_SLOT), new PlayerHasRecordedItemWithHimCondition(QUEST_SLOT)),
ConversationStates.QUESTION_2,
"You didn't return what I last lent you! Do you want to return it now?",
null);
// player wants to pay for previous item
final List<ChatAction> payment = new LinkedList<ChatAction>();
payment.add(new DropItemAction("money", COST));
payment.add(new SetQuestAction(QUEST_SLOT, "done"));
payment.add(new DecreaseKarmaAction(10));
add(ConversationStates.QUESTION_1,
ConversationPhrases.YES_MESSAGES,
new PlayerHasItemWithHimCondition("money", COST),
ConversationStates.ATTENDING,
"Thanks. Just let me know if you want to #borrow any tools again.",
new MultipleActions(payment));
// player already has borrowed something and wants to return it
final List<ChatAction> returnitem = new LinkedList<ChatAction>();
returnitem.add(new DropRecordedItemAction(QUEST_SLOT));
returnitem.add(new SetQuestAction(QUEST_SLOT, "done"));
add(ConversationStates.QUESTION_2,
ConversationPhrases.YES_MESSAGES,
new PlayerHasRecordedItemWithHimCondition(QUEST_SLOT),
ConversationStates.ATTENDING,
"Thank you! Just let me know if you want to #borrow any tools again.",
new MultipleActions(returnitem));
// don't want to pay for it now
add(ConversationStates.QUESTION_1,
ConversationPhrases.NO_MESSAGES,
null,
ConversationStates.ATTENDING,
"No problem. Take as long as you need, but you can't borrow other tools till you return the last, or pay for it.",
null);
// don't want to return it now
add(ConversationStates.QUESTION_2,
ConversationPhrases.NO_MESSAGES,
null,
ConversationStates.ATTENDING,
"No problem. Take as long as you need, but you can't borrow other tools till you return the last, or pay for it.",
null);
// saying the item name and storing that item name into the quest slot, and giving the item
for(final String itemName : ITEMS) {
add(ConversationStates.ATTENDING,
itemName,
new AndCondition(
new LevelGreaterThanCondition(5),
new QuestCompletedCondition("pizza_delivery"),
new QuestNotActiveCondition(QUEST_SLOT)),
ConversationStates.ATTENDING,
null,
new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
final Item item = SingletonRepository.getEntityManager().getItem(itemName);
if (item == null) {
npc.say("Sorry, something went wrong. Could you say correctly the item, please?");
} else {
player.equipOrPutOnGround(item);
player.setQuest(QUEST_SLOT, itemName);
npc.say("Here you are! Don't forget to #return it or you have to pay!");
}
}
});
}
// additionally add "sugar" as trigger word
add(ConversationStates.ATTENDING,
"sugar",
new AndCondition(
new LevelGreaterThanCondition(5),
new QuestCompletedCondition("pizza_delivery"),
new QuestNotActiveCondition(QUEST_SLOT)),
ConversationStates.ATTENDING,
null,
new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {