"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) {
npc.say("Sorry, I can't lend out sugar, only a #sugar #mill.");
}
});
// too low level
add(ConversationStates.ATTENDING,
ITEMS,
new LevelLessThanCondition(6),
ConversationStates.ATTENDING,
"Sorry, as you have little experience in this world I can't trust you with my tools.",
null);
// currently has borrowed an item
add(ConversationStates.ATTENDING,
ITEMS,
new QuestActiveCondition(QUEST_SLOT),
ConversationStates.ATTENDING,
"You can't borrow from me again till you #return the last tool I lent you.",
null);
// haven't done pizza
add(ConversationStates.ATTENDING,
ITEMS,
new QuestNotCompletedCondition("pizza_delivery"),
ConversationStates.ATTENDING,
"Only pizza deliverers can borrow tools, please deliver one for Leander and then ask me again.",
null);
// player asks about pay from attending state
add(ConversationStates.ATTENDING, "pay",
new QuestActiveCondition(QUEST_SLOT),
ConversationStates.QUESTION_1,
"If you lost what I lent you, you can pay " + COST + " money. Do you want to pay now?",
null);
// player asks about return from attending state
add(ConversationStates.ATTENDING, "return",
new AndCondition(new QuestActiveCondition(QUEST_SLOT), new PlayerHasRecordedItemWithHimCondition(QUEST_SLOT)),
ConversationStates.QUESTION_2,
"Do you want to return what you borrowed now?",
null);
// player asks about return from attending state
add(ConversationStates.ATTENDING, "return",
new AndCondition(new QuestActiveCondition(QUEST_SLOT), new NotCondition(new PlayerHasRecordedItemWithHimCondition(QUEST_SLOT))),
ConversationStates.QUESTION_1,
"You don't have it with you! Do you want to pay " + COST + " money for it now?",
null);
}};