Package games.stendhal.server.entity.npc.behaviour.impl

Examples of games.stendhal.server.entity.npc.behaviour.impl.ProducerBehaviour


          player.notifyWorldAboutChanges();
        }
      }
    }
   
    final ProducerBehaviour behaviour = new SpecialProducerBehaviour("make", "silk thread",
                                     requiredResources, REQUIRED_MINUTES_THREAD);

    npc.add(ConversationStates.ATTENDING,
        "make",
        new QuestInStateCondition(mithrilcloak.getQuestSlot(), "need_fabric"), ConversationStates.ATTENDING, null,
        new ProducerBehaviourAction(behaviour) {
          @Override
          public void fireRequestOK(final ItemParserResult res, Player player, Sentence sentence, EventRaiser npc) {
            // Find out how much items we shall produce.
            if (res.getAmount() < 40) {
              npc.say("Do you really want so few? I'm not wasting my time with that! Any decent sized pieces of fabric needs at least 40 spools of thread! You should at least #make #40.");
              return;
            } else if (res.getAmount() > 1000) {
              /*logger.warn("Decreasing very large amount of "
               *    + behaviour.getAmount()
               *    + " " + behaviour.getChosenItemName()
               *    + " to 40 for player "
               *    + player.getName() + " talking to "
               *    + npc.getName() + " saying " + sentence);
               */
              res.setAmount(40);
            }

            if (behaviour.askForResources(res, npc, player)) {
              currentBehavRes = res;
              npc.setCurrentState(ConversationStates.PRODUCTION_OFFERED);
            }
          }

          @Override
          public void fireRequestError(final ItemParserResult res, final Player player, final Sentence sentence, final EventRaiser raiser) {
            raiser.say(behaviour.getErrormessage(res, "#make", "produce"));
          }
        });
   
    npc.add(ConversationStates.PRODUCTION_OFFERED,
        ConversationPhrases.YES_MESSAGES, null,
        ConversationStates.ATTENDING, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            behaviour.transactAgreedDeal(currentBehavRes, npc, player);

            currentBehavRes = null;
          }
        });

    npc.add(ConversationStates.PRODUCTION_OFFERED,
        ConversationPhrases.NO_MESSAGES, null,
        ConversationStates.ATTENDING, "OK, no problem.", null);

    npc.add(ConversationStates.ATTENDING,
        behaviour.getProductionActivity(),
        new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "makingthread;"),
        ConversationStates.ATTENDING, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence,
              final EventRaiser npc) {
            npc.say("I still haven't finished your last order!");
          }
        });
    // player returns and says hi while sacs being made
    npc.add(ConversationStates.IDLE,
      ConversationPhrases.GREETING_MESSAGES,
      new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
          new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "makingthread;")),
      ConversationStates.ATTENDING, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence,
              final EventRaiser npc) {
            behaviour.giveProduct(npc, player);
          }
        });
    // player returns and doesn't need fabric and sacs not being made
    npc.add(ConversationStates.IDLE,
      ConversationPhrases.GREETING_MESSAGES,
View Full Code Here


    final Map<String, Integer> requiredResources = new TreeMap<String, Integer>()
    requiredResources.put("vampirette entrails", 7);
    requiredResources.put("bat entrails", 7);
    requiredResources.put("skull ring", 1);
    requiredResources.put("empty goblet", 1);
    final ProducerBehaviour behaviour = new ProducerBehaviour(
        "sicky_fill_goblet", "fill", "goblet", requiredResources,
        5 * 60, true);
    new ProducerAdder().addProducer(npc, behaviour,
      "Please don't try to kill me...I'm just a sick old #vampire. Do you have any #blood I could drink? If you have an #empty goblet I will #fill it with blood for you in my cauldron.");

View Full Code Here

    // Open orders - do not state if ready to collect or not, yet

    for (final Pair<String, ProducerBehaviour> producer : producers) {
      String npcName = producer.first();
      ProducerBehaviour behaviour = producer.second();
      String questSlot =  behaviour.getQuestSlot();
      String activity =  behaviour.getProductionActivity();
      String product =  behaviour.getProductName();
      if (player.hasQuest(questSlot) && !player.isQuestCompleted(questSlot)) {
        int amount = behaviour.getNumberOfProductItems(player);
        if (behaviour.isOrderReady(player)) {
          // put all completed orders first - player wants to collect these!
          sb.insert(0,"\n" + npcName + " has finished " + Grammar.gerundForm(activity)
              + " your " + Grammar.plnoun(amount,product) + ".");
        } else {
          String timeleft = behaviour.getApproximateRemainingTime(player);
          // put all ongoing orders last
          sb.append("\n" + npcName + " is " + Grammar.gerundForm(activity)
              + " " + Grammar.quantityplnoun(amount, product, "a") + " and will be ready in " + timeleft + ".");
        }
           
View Full Code Here

  public List<String> getWorkingProducerNames(final Player player) {
    List<String> res = new LinkedList<String>();

    for (final Pair<String, ProducerBehaviour> producer : producers) {
      String npcName = producer.first();
      ProducerBehaviour behaviour = producer.second();
      String questSlot =  behaviour.getQuestSlot();
      if (player.hasQuest(questSlot) && !player.isQuestCompleted(questSlot)) {
        if (behaviour.isOrderReady(player)) {
          // put all completed orders first - player wants to collect these!
          res.add(0, npcName);
        } else {
          res.add(npcName);
        }
View Full Code Here

   * @return details
   */
  public String getProductionDescription(final Player player, final String npcName) {
    for (final Pair<String, ProducerBehaviour> producer : producers) {
      if(npcName.equals(producer.first())) {
        ProducerBehaviour behaviour = producer.second();
        String activity =  behaviour.getProductionActivity();
        String product =  behaviour.getProductName();
        return npcName + " " + Grammar.plural(activity) + " " + Grammar.plural(product) + ".";
      }
    }
    return "";
  }
View Full Code Here

   */
  public List<String> getProductionDetails(final Player player, final String npcName) {
    List<String> res = new LinkedList<String>();
    for (final Pair<String, ProducerBehaviour> producer : producers) {
      if(npcName.equals(producer.first())) {
        ProducerBehaviour behaviour = producer.second();
        String questSlot =  behaviour.getQuestSlot();
        String activity =  behaviour.getProductionActivity();
        String product =  behaviour.getProductName();
        if (player.hasQuest(questSlot) && !player.isQuestCompleted(questSlot)) {
          int amount = behaviour.getNumberOfProductItems(player);
          if (behaviour.isOrderReady(player)) {
            // put all completed orders first - player wants to collect these!
            res.add(npcName + " has finished " + Grammar.gerundForm(activity)
              + " your " + Grammar.plnoun(amount,product) + ".");
          } else {
            String timeleft = behaviour.getApproximateRemainingTime(player);
            // put all ongoing orders last
            res.add("\n" + npcName + " is " + Grammar.gerundForm(activity)
              + " " + Grammar.quantityplnoun(amount, product, "a") + " and will be ready in " + timeleft + ".");
          }
           
View Full Code Here

   * @return list of item names
   */
  public List<String> getProducedItemNames(final String clazz) {
    List<String> res = new LinkedList<String>();
    for (final Pair<String, ProducerBehaviour> producer : producers) {
      final ProducerBehaviour behaviour = producer.second();
      final String product =  behaviour.getProductName();
      final Item item = SingletonRepository.getEntityManager().getItem(product);
      if (item.isOfClass(clazz)) {
        res.add(product);
      }
    }
View Full Code Here

   * @param itemName produced item
   * @return details about the produced item
   */
  public String getProducedItemDetails(final String itemName) {
    for (final Pair<String, ProducerBehaviour> producer : producers) {
      ProducerBehaviour behaviour = producer.second();
      String product =  behaviour.getProductName();

      if(itemName.equals(product)) {
        String npcName = producer.first();
        String activity =  behaviour.getProductionActivity();
        String resources = behaviour.getRequiredResourceNames(1);
        return  npcName + " " + Grammar.plural(activity) + " " + Grammar.plural(product) + ", which need " + resources + " each.";
      }
    }
    return "";
  }
View Full Code Here

        // Pedinghaus makes mithril if you bring him mithril nugget and wood
        final Map<String, Integer> requiredResources = new TreeMap<String, Integer>()
        requiredResources.put("wood", 20);
        requiredResources.put("mithril nugget", 1);

        final ProducerBehaviour behaviour = new ProducerBehaviour("Pedinghaus_cast_mithril",
            "cast", "mithril bar", requiredResources, 18 * 60);

        new ProducerAdder().addProducer(this, behaviour,
                "Greetings. I sense you may be interested in mithril. If you desire me to #cast you a #'mithril bar', just say the word.");
        addReply("wood",
View Full Code Here

        requiredResources.put("tomato", 1);
        requiredResources.put("button mushroom", 2);
        requiredResources.put("porcini", 1);
        requiredResources.put("ham", 1);

        final ProducerBehaviour behaviour = new ProducerBehaviour("kroip_make_pizza", "make", "pizza",
                requiredResources, 5 * 60, true);

        new ProducerAdder().addProducer(this, behaviour,
                "Welkom!");
      }
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.npc.behaviour.impl.ProducerBehaviour

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.