private void step_3() {
final SpeakerNPC npc = npcs.get("Baldemar");
npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestStateStartsWithCondition(QUEST_SLOT, "start")),
ConversationStates.ATTENDING, null,
new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
final String[] tokens = player.getQuest(QUEST_SLOT).split(";");
int idx1 = 1;
for (ItemData itemdata : neededItems.values()) {
itemdata.resetAmount();
itemdata.subAmount(tokens[idx1]);
idx1++;
}
boolean missingSomething = false;
int size = neededItems.size();
for (int idx = 1; !missingSomething && idx <= size; idx++) {
ItemData itemData = neededItems.get(idx);
missingSomething = proceedItem(player, raiser,
itemData);
}
if (player.hasKilledSolo("black giant") && !missingSomething) {
raiser.say("You've brought everything I need to forge the shield. Come back in "
+ REQUIRED_MINUTES
+ " minutes and it will be ready.");
player.setQuest(QUEST_SLOT, "forging;" + System.currentTimeMillis());
} else {
if (!player.hasKilledSolo("black giant") && !missingSomething) {
raiser.say("This shield can only be given to those who have killed a black giant, and without the help of others.");
}
StringBuilder sb = new StringBuilder(30);
sb.append("start");
for (ItemData id : neededItems.values()) {
sb.append(";");
sb.append(id.getAlreadyBrought());
}
player.setQuest(QUEST_SLOT, sb.toString());
}
}
private boolean proceedItem(final Player player,
final EventRaiser engine, final ItemData itemData) {
if (itemData.getStillNeeded() > 0) {
if (player.isEquipped(itemData.getName(), itemData.getStillNeeded())) {
player.drop(itemData.getName(), itemData.getStillNeeded());
itemData.setAmount(0);
} else {
final int amount = player.getNumberOfEquipped(itemData.getName());
if (amount > 0) {
player.drop(itemData.getName(), amount);
itemData.subAmount(amount);
}
engine.say(itemData.getAnswer());
return true;
}
}
return false;
}
});
npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestStateStartsWithCondition(QUEST_SLOT, "forging;")),
ConversationStates.IDLE, null, new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
final String[] tokens = player.getQuest(QUEST_SLOT).split(";");