private void getClaspStep() {
// don't overlap with any states from producer adder since he is a mithril bar producer
final SpeakerNPC npc = npcs.get("Pedinghaus");
// offer the clasp when prompted
npc.add(ConversationStates.ATTENDING,
Arrays.asList("clasp", "mithril clasp", "ida", "cloak", "mithril cloak"),
new QuestInStateCondition(mithrilcloak.getQuestSlot(), "need_clasp"),
ConversationStates.SERVICE_OFFERED,
"A clasp? Whatever you say! I am still so happy from that letter you brought me, it would be my pleasure to make something for you. I only need one mithril bar. Do you have it?",
null);
// player says yes they want a clasp made and claim they have the mithril
npc.add(
ConversationStates.SERVICE_OFFERED,
ConversationPhrases.YES_MESSAGES,
new QuestInStateCondition(mithrilcloak.getQuestSlot(), "need_clasp"),
ConversationStates.ATTENDING,
null,
new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
if (player.isEquipped("mithril bar")) {
player.drop("mithril bar");
npc.say("What a lovely piece of mithril that is, even if I do say so myself ... Good, please come back in "
+ REQUIRED_MINUTES_CLASP + " minutes and hopefully your clasp will be ready!");
player.setQuest(mithrilcloak.getQuestSlot(), "forgingclasp;" + System.currentTimeMillis());
player.notifyWorldAboutChanges();
} else {
npc.say("You can't fool an old wizard, and I'd know mithril when I see it. Come back when you have at least one bar.");
}
}
});
// player says they don't have any mithril yet
npc.add(
ConversationStates.SERVICE_OFFERED,
ConversationPhrases.NO_MESSAGES,
null,
ConversationStates.ATTENDING,
"Well, if you should like me to cast any mithril bars just say.",
null);
npc.add(ConversationStates.ATTENDING,
Arrays.asList("clasp", "mithril clasp", "ida", "cloak", "mithril cloak"),
new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "forgingclasp;"),
ConversationStates.ATTENDING, null, new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
final String[] tokens = player.getQuest(mithrilcloak.getQuestSlot()).split(";");
// minutes -> milliseconds
final long delay = REQUIRED_MINUTES_CLASP * MathHelper.MILLISECONDS_IN_ONE_MINUTE;
final long timeRemaining = (Long.parseLong(tokens[1]) + delay)
- System.currentTimeMillis();
if (timeRemaining > 0L) {
npc.say("I haven't finished yet, please return in "
+ TimeUtil.approxTimeUntil((int) (timeRemaining / 1000L)) + ".");
return;
}
npc.say("Here, your clasp is ready!");
player.addXP(100);
player.addKarma(15);
final Item clasp = SingletonRepository.getEntityManager().getItem(
"mithril clasp");
clasp.setBoundTo(player.getName());