/* $Id: ArmorForDagobert.java,v 1.52 2011/02/10 19:28:11 kymara Exp $ */
/***************************************************************************
* (C) Copyright 2003-2011 - Stendhal *
***************************************************************************
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
package games.stendhal.server.maps.quests;
import games.stendhal.server.entity.npc.ChatAction;
import games.stendhal.server.entity.npc.ConversationPhrases;
import games.stendhal.server.entity.npc.ConversationStates;
import games.stendhal.server.entity.npc.SpeakerNPC;
import games.stendhal.server.entity.npc.action.DropItemAction;
import games.stendhal.server.entity.npc.action.EquipItemAction;
import games.stendhal.server.entity.npc.action.IncreaseKarmaAction;
import games.stendhal.server.entity.npc.action.IncreaseXPAction;
import games.stendhal.server.entity.npc.action.MultipleActions;
import games.stendhal.server.entity.npc.action.SetQuestAction;
import games.stendhal.server.entity.npc.action.SetQuestAndModifyKarmaAction;
import games.stendhal.server.entity.npc.condition.AndCondition;
import games.stendhal.server.entity.npc.condition.GreetingMatchesNameCondition;
import games.stendhal.server.entity.npc.condition.NotCondition;
import games.stendhal.server.entity.npc.condition.OrCondition;
import games.stendhal.server.entity.npc.condition.PlayerHasItemWithHimCondition;
import games.stendhal.server.entity.npc.condition.QuestCompletedCondition;
import games.stendhal.server.entity.npc.condition.QuestInStateCondition;
import games.stendhal.server.entity.npc.condition.QuestNotCompletedCondition;
import games.stendhal.server.entity.player.Player;
import games.stendhal.server.maps.Region;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
/**
* QUEST: Armor for Dagobert
*
* PARTICIPANTS:
* <ul>
* <li>Dagobert, the consultant at the bank of Semos</li>
* </ul>
*
* STEPS:
* <ul>
* <li>Dagobert asks you to find a leather cuirass.</li>
* <li>You get a leather cuirass, e.g. by killing a cyclops.</li>
* <li>Dagobert sees your leather cuirass and asks for it and then thanks you.</li>
* </ul>
*
* REWARD:
* <ul>
* <li>50 XP</li>
* <li>80 gold</li>
* <li>Karma: 10</li>
* <li>Access to vault</li>
* </ul>
*
* REPETITIONS:
* <ul>
* <li>None</li>
* </ul>
*/
public class ArmorForDagobert extends AbstractQuest {
private static final String QUEST_SLOT = "armor_dagobert";
@Override
public List<String> getHistory(final Player player) {
final List<String> res = new ArrayList<String>();
if (!player.hasQuest(QUEST_SLOT)) {
return res;
}
res.add("I have met Dagobert. He is the consultant at the bank in Semos.");
final String questState = player.getQuest(QUEST_SLOT);
if ("rejected".equals(questState)) {
res.add("He asked me to find a leather cuirass but I rejected his request.");
}
if (player.isQuestInState(QUEST_SLOT, "start", "done")) {
res.add("I promised to find a leather cuirass for him because he has been robbed.");
}
if (("start".equals(questState) && (player.isEquipped("leather cuirass") || player.isEquipped("pauldroned leather cuirass"))) || "done".equals(questState)) {
res.add("I found a leather cuirass and will take it to Dagobert.");
}
if ("done".equals(questState)) {
res.add("I took the leather cuirass to Dagobert. As a little thank you, he will allow me to use a private vault.");
}
return res;
}
private void prepareRequestingStep() {
final SpeakerNPC npc = npcs.get("Dagobert");
npc.add(
ConversationStates.ATTENDING,
ConversationPhrases.QUEST_MESSAGES,
new QuestNotCompletedCondition(QUEST_SLOT),
ConversationStates.QUEST_OFFERED,
"I'm so afraid of being robbed. I don't have any protection. Do you think you can help me?",
null);
npc.add(
ConversationStates.ATTENDING,
ConversationPhrases.QUEST_MESSAGES,
new QuestCompletedCondition(QUEST_SLOT),
ConversationStates.ATTENDING,
"Thank you very much for the armor, but I don't have any other task for you.",
null);
// player is willing to help
npc.add(
ConversationStates.QUEST_OFFERED,
ConversationPhrases.YES_MESSAGES,
null,
ConversationStates.ATTENDING,
"Once I had a nice #'leather cuirass', but it was destroyed during the last robbery. If you find a new one, I'll give you a reward.",
new SetQuestAndModifyKarmaAction(QUEST_SLOT, "start", 5.0));
// player is not willing to help
npc.add(
ConversationStates.QUEST_OFFERED,
ConversationPhrases.NO_MESSAGES, null,
ConversationStates.ATTENDING,
"Well, then I guess I'll just duck and cover.",
new SetQuestAndModifyKarmaAction(QUEST_SLOT, "rejected", -5.0));
// player wants to know what a leather cuirass is
npc.add(
ConversationStates.ATTENDING,
Arrays.asList("leather cuirass", "leather", "cuirass"),
null,
ConversationStates.ATTENDING,
"A leather cuirass is the traditional cyclops armor. Some cyclopes are living in the dungeon deep under the city.",
null);
}
private void prepareBringingStep() {
final SpeakerNPC npc = npcs.get("Dagobert");
// player returns while quest is still active
npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "start"),
new OrCondition(
new PlayerHasItemWithHimCondition("leather cuirass"),
new PlayerHasItemWithHimCondition("pauldroned leather cuirass"))),
ConversationStates.QUEST_ITEM_BROUGHT,
"Excuse me, please! I have noticed the leather cuirass you're carrying. Is it for me?",
null);
npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "start"),
new NotCondition(new OrCondition(
new PlayerHasItemWithHimCondition("leather cuirass"),
new PlayerHasItemWithHimCondition("pauldroned leather cuirass")))),
ConversationStates.ATTENDING,
"Luckily I haven't been robbed while you were away. I would be glad to receive a leather cuirass. Anyway, how can I #help you?",
null);
final List<ChatAction> reward = new LinkedList<ChatAction>();
reward.add(new EquipItemAction("money", 80));
reward.add(new IncreaseXPAction(50));
reward.add(new SetQuestAction(QUEST_SLOT, "done"));
reward.add(new IncreaseKarmaAction(10));
final List<ChatAction> reward1 = new LinkedList<ChatAction>(reward);
reward1.add(new DropItemAction("leather cuirass"));
npc.add(
ConversationStates.QUEST_ITEM_BROUGHT,
ConversationPhrases.YES_MESSAGES,
// make sure the player isn't cheating by putting the armor
// away and then saying "yes"
new PlayerHasItemWithHimCondition("leather cuirass"),
ConversationStates.ATTENDING, "Oh, I am so thankful! Here is some gold I found ... ehm ... somewhere. Now that you have proven yourself a trusted customer, you may have access to your own private banking #vault any time you like.",
new MultipleActions(reward1));
final List<ChatAction> reward2 = new LinkedList<ChatAction>(reward);
reward2.add(new DropItemAction("pauldroned leather cuirass"));
npc.add(
ConversationStates.QUEST_ITEM_BROUGHT,
ConversationPhrases.YES_MESSAGES,
// make sure the player isn't cheating by putting the armor
// away and then saying "yes"
new AndCondition(
new NotCondition(new PlayerHasItemWithHimCondition("leather cuirass")),
new PlayerHasItemWithHimCondition("pauldroned leather cuirass")),
ConversationStates.ATTENDING, "Oh, I am so thankful! Here is some gold I found ... ehm ... somewhere. Now that you have proven yourself a trusted customer, you may have access to your own private banking #vault any time you like.",
new MultipleActions(reward2));
npc.add(
ConversationStates.QUEST_ITEM_BROUGHT,
ConversationPhrases.NO_MESSAGES,
null,
ConversationStates.ATTENDING,
"Well then, I hope you find another one which you can give to me before I get robbed again.",
null);
}
@Override
public void addToWorld() {
super.addToWorld();
fillQuestInfo(
"Armor For Dagobert",
"Dagobert, the consultant at the bank of Semos, needs protection.",
false);
prepareRequestingStep();
prepareBringingStep();
}
@Override
public String getSlotName() {
return QUEST_SLOT;
}
@Override
public String getName() {
return "ArmorForDagobert";
}
@Override
public int getMinLevel() {
return 0;
}
@Override
public String getRegion() {
return Region.SEMOS_CITY;
}
}