}
void fixRingStep(final SpeakerNPC npc) {
npc.add(ConversationStates.ATTENDING, Arrays.asList("emerald ring", "life", "emerald"),
new AndCondition(new PlayerHasItemWithHimCondition("emerald ring"),
new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING))),
ConversationStates.QUEST_ITEM_BROUGHT,
null,
new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
final RingOfLife emeraldRing = (RingOfLife) player.getFirstEquipped("emerald ring");
if (emeraldRing.isBroken()) {
npc.say("What a pity, your emerald ring is broken. I can fix it, for a #price.");
} else {
// ring is not broken so he just lets player know
// where it can be fixed
npc.say("I see you already have an emerald ring. If it gets broken, you can come to me to fix it.");
npc.setCurrentState(ConversationStates.ATTENDING);
}
}
});
npc.add(ConversationStates.ATTENDING,
Arrays.asList("emerald ring", "life", "emerald"),
new AndCondition(new NotCondition(new PlayerHasItemWithHimCondition("emerald ring")),
new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING))),
ConversationStates.ATTENDING,
"It is difficult to get the ring of life. Do a favour for a powerful elf in Nal'wor and you may receive one as a reward."
, null);
npc.add(ConversationStates.ATTENDING,
Arrays.asList("emerald ring", "life", "emerald"),
new AndCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING),
new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING + "unbound")),
new TimePassedCondition(QUEST_SLOT,1,REQUIRED_MINUTES)),
ConversationStates.ATTENDING,
"I'm pleased to say, your ring of life is fixed! It's good as new now.",
new MultipleActions(
new IncreaseXPAction(500),
new SetQuestAction(QUEST_SLOT, "done"),
new EquipItemAction("emerald ring", 1, true)));
npc.add(ConversationStates.ATTENDING,
Arrays.asList("emerald ring", "life", "emerald"),
new AndCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING),
new QuestStateStartsWithCondition(QUEST_SLOT, FORGING + "unbound"),
new TimePassedCondition(QUEST_SLOT,1,REQUIRED_MINUTES)),
ConversationStates.ATTENDING,
"I'm pleased to say, your ring of life is fixed! It's good as new now.",
new MultipleActions(
new IncreaseXPAction(500),
new SetQuestAction(QUEST_SLOT, "done"),
new EquipItemAction("emerald ring", 1, false)));
npc.add(ConversationStates.ATTENDING,
Arrays.asList("emerald ring", "life", "emerald"),
new AndCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING),
new NotCondition(new TimePassedCondition(QUEST_SLOT,1,REQUIRED_MINUTES))),
ConversationStates.IDLE, null,
new SayTimeRemainingAction(QUEST_SLOT,1, REQUIRED_MINUTES,"I haven't finished fixing your ring of life. Please check back in"));
npc.add(ConversationStates.QUEST_ITEM_BROUGHT,
"price",
null,
ConversationStates.QUEST_ITEM_BROUGHT,
"The charge for my service is " + REQUIRED_MONEY
+ " money, and I need " + REQUIRED_GOLD
+ " gold bars and " + REQUIRED_GEM
+ " emerald to fix the ring. Do you want to pay now?",
null);
npc.add(ConversationStates.QUEST_ITEM_BROUGHT,
ConversationPhrases.YES_MESSAGES,
new AndCondition(
new PlayerHasItemWithHimCondition("gold bar", REQUIRED_GOLD),
new PlayerHasItemWithHimCondition("money", REQUIRED_MONEY),
new PlayerHasItemWithHimCondition("emerald", REQUIRED_GEM)),
ConversationStates.IDLE,
"Okay, that's all I need to fix the ring. Come back in "
+ REQUIRED_MINUTES
+ " minutes and it will be ready. Bye for now.",
new MultipleActions(
new DropItemAction("gold bar", REQUIRED_GOLD),
new DropItemAction("emerald", REQUIRED_GEM),
new DropItemAction("money", REQUIRED_MONEY),
new ChatAction() {
public void fire(final Player player,
final Sentence sentence,
final EventRaiser npc) {
final RingOfLife emeraldRing = (RingOfLife) player.getFirstEquipped("emerald ring");
if (player.isBoundTo(emeraldRing)) {
player.setQuest(QUEST_SLOT, "forging;"
+ System.currentTimeMillis());
} else {
player.setQuest(QUEST_SLOT, "forgingunbound;"
+ System.currentTimeMillis());
}
}
},
new DropItemAction("emerald ring")));
npc.add(ConversationStates.QUEST_ITEM_BROUGHT,
ConversationPhrases.YES_MESSAGES,
new NotCondition(new AndCondition(
new PlayerHasItemWithHimCondition("gold bar", REQUIRED_GOLD),
new PlayerHasItemWithHimCondition("money", REQUIRED_MONEY),
new PlayerHasItemWithHimCondition("emerald", REQUIRED_GEM))),
ConversationStates.IDLE,
"Come back when you have the money, the gem and the gold. Goodbye.",