Package games.stendhal.server.entity.npc

Examples of games.stendhal.server.entity.npc.ChatCondition


        // player has met io before and has a pk skull
        add(ConversationStates.IDLE,
            ConversationPhrases.GREETING_MESSAGES,
            new AndCondition(new GreetingMatchesNameCondition(getName()),
                new QuestStartedCondition("meet_io"),
                new ChatCondition() {
                  public boolean fire(final Player player, final Sentence sentence, final Entity entity) {
                    return player.isBadBoy() ;
                  }
                }),
                ConversationStates.QUESTION_1,
                null,
                new SayTextWithPlayerNameAction("Hi again, [name]. I sense you have been branded with the mark of a killer. Do you wish to have it removed?"));
       
        // player has met io before and has not got a pk skull
        add(ConversationStates.IDLE,
            ConversationPhrases.GREETING_MESSAGES,
            new AndCondition(new GreetingMatchesNameCondition(getName()),
                new QuestStartedCondition("meet_io"),
                new ChatCondition() {
                  public boolean fire(final Player player, final Sentence sentence, final Entity entity) {
                    return !player.isBadBoy() ;
                  }
                }),
                ConversationStates.ATTENDING,
View Full Code Here


    zone.add(npc);
    npc.setDescription("You see Gordon. He keeps an eye on the signs close to him.");
  }

  private static ChatCondition getRentMatchCond() {
    return new ChatCondition() {
      public boolean fire(Player player, Sentence sentence, Entity npc) {
        String txt = sentence.getOriginalText();

              //TODO replaced by using sentence matching "[you] rent"
        if (txt.startsWith("rent") || txt.startsWith("you rent")) {
View Full Code Here

    // player says hi before starting the quest
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
          new ChatCondition() {
            public boolean fire(final Player player, final Sentence sentence, final Entity entity) {
              return !player.hasQuest(QUEST_SLOT) && player.isQuestCompleted(OLD_QUEST);
            }
          }),
        ConversationStates.QUEST_2_OFFERED,
View Full Code Here

      });
    }

    npc.add(ConversationStates.ATTENDING,
        ConversationPhrases.NO_MESSAGES,
        new ChatCondition() {
          public boolean fire(final Player player, final Sentence sentence, final Entity entity) {
            return !player.isQuestCompleted(QUEST_SLOT);
          }
        },
        ConversationStates.ATTENDING,
        "Ok. If you want help, just say.",
        null);

    // player says he didn't bring any cloaks to different question
    npc.add(ConversationStates.QUESTION_2,
        ConversationPhrases.NO_MESSAGES,
        new ChatCondition() {
          public boolean fire(final Player player, final Sentence sentence, final Entity entity) {
            return !player.isQuestCompleted(QUEST_SLOT);
          }
        }, ConversationStates.ATTENDING, "Okay then. Come back later.",
        null);
View Full Code Here

            new RepairingPriceCalculationStrategy(new HashSet<String>()),
            new HashSet<String>(Arrays.asList("buckler")));
    final Engine engine = npc.getEngine();
   
    //sentence was not recognized     
    ChatCondition errorCondition = new SentenceHasErrorCondition();
    engine.add(ConversationStates.ATTENDING, "repair", errorCondition,
        false, ConversationStates.ATTENDING,
        null, new ComplainAboutSentenceErrorAction());
   
    //sentence recognized but not able to repair
    ChatCondition cannotRepair = new AndCondition(
        new NotCondition(new SentenceHasErrorCondition()),
        new NotCondition(repairerBehaviour.getTransactionCondition()));
   
    engine.add(ConversationStates.ATTENDING, "repair", cannotRepair,
        false, ConversationStates.ATTENDING,
        null, repairerBehaviour.getRejectedTransactionAction());
   
    //recognized and able to repair
    ChatCondition recognizedCondition = new AndCondition(
        new NotCondition(new SentenceHasErrorCondition()),
        repairerBehaviour.getTransactionCondition());
   
    engine.add(ConversationStates.ATTENDING, "repair",
        recognizedCondition, false, ConversationStates.REPAIR_OFFERED,
View Full Code Here

    engine.add(ConversationStates.ATTENDING, "buy", new SentenceHasErrorCondition(),
        false, ConversationStates.ATTENDING,
        null, new ComplainAboutSentenceErrorAction());

    ChatCondition condition = new AndCondition(
      new NotCondition(new SentenceHasErrorCondition()),
      new NotCondition(sellerBehaviour.getTransactionCondition()));
    engine.add(ConversationStates.ATTENDING, "buy", condition,
      false, ConversationStates.ATTENDING,
      null, sellerBehaviour.getRejectedTransactionAction());
View Full Code Here

 
  private void getOutfitsStep() {
    tam = npcs.get("Tamara");
    tam.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(tam.getName()),
            new ChatCondition() {
              public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
                return marriage.isEngaged(player);
              }
            }),
        ConversationStates.ATTENDING,
        "Welcome! If you're a bride-to-be I can #help you get ready for your wedding",
        null);
    tam.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(tam.getName()),
            new ChatCondition() {
              public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
                return !marriage.isEngaged(player);
              }
            }),
        ConversationStates.IDLE,
        "Sorry, I can't help you, I am busy getting dresses ready for brides-to-be!",
        null);

    tim = npcs.get("Timothy");
    tim.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(tim.getName()),
          new ChatCondition() {
            public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
              return marriage.isEngaged(player);
            }
          }),
        ConversationStates.ATTENDING,
        "Good day! If you're a prospective groom I can #help you prepare for your wedding.",
        null);
    tim.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(tim.getName()),
          new ChatCondition() {
            public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
              return !marriage.isEngaged(player);
            }
          }),
        ConversationStates.IDLE,
View Full Code Here

     */

    priest = npcs.get("Priest");
    priest.add(ConversationStates.ATTENDING,
          "marry",
          new ChatCondition() {
            public boolean fire(final Player player, final Sentence sentence,
                final Entity npc) {
              return player.hasQuest(marriage.getQuestSlot())
                  && player.getQuest(marriage.getQuestSlot()).startsWith(
                      "engaged")
                  && player.isEquipped("wedding ring");
            }
          },
          // TODO: make sure the pair getting married are engaged to each
          // other, if this is desired.
          ConversationStates.ATTENDING,
          null,
          new ChatAction() {

            public void fire(final Player player, final Sentence sentence,
                final EventRaiser npc) {
              // find out whom the player wants to marry.
              final String brideName = sentence.getSubjectName();
 
              if (brideName == null) {
                npc.say("You have to tell me who you want to marry.");
              } else {
                startMarriage((SpeakerNPC) npc.getEntity(), player, brideName);
              }
            }
          });

    priest.add(ConversationStates.QUESTION_1,
          ConversationPhrases.YES_MESSAGES,
          null,
          ConversationStates.QUESTION_2,
          null,
          new ChatAction() {

            public void fire(final Player player, final Sentence sentence,
                final EventRaiser npc) {
              askBride();
            }
          });

    priest.add(ConversationStates.QUESTION_1,
          ConversationPhrases.NO_MESSAGES,
          null,
          ConversationStates.IDLE,
          "What a pity! Goodbye!",
          null);

    priest.add(ConversationStates.QUESTION_2,
          ConversationPhrases.YES_MESSAGES,
          null,
          ConversationStates.ATTENDING,
          null,
          new ChatAction() {

            public void fire(final Player player, final Sentence sentence,
                final EventRaiser npc) {
              finishMarriage();
            }
          });

    priest.add(ConversationStates.QUESTION_2,
          ConversationPhrases.NO_MESSAGES,
          null,
          ConversationStates.IDLE,
          "What a pity! Goodbye!",
          null);

    // What he responds to marry if you haven't fulfilled all objectives
    // before hand
    priest.add(ConversationStates.ATTENDING,
          "marry",
          new ChatCondition() {
            public boolean fire(final Player player, final Sentence sentence,
                final Entity npc) {
              return (!player.hasQuest(marriage.getQuestSlot())
                  || (player.hasQuest(marriage.getQuestSlot())  && player.getQuest(marriage.getQuestSlot()).startsWith("engaged") && !player.isEquipped("wedding ring")));
            }
          },
          ConversationStates.ATTENDING,
          "You're not ready to be married yet. Come back when you are properly engaged, and bring your wedding ring. And try to remember not to leave your partner behind ....",
          null);

    // What he responds to marry if you are already married
    priest.add(ConversationStates.ATTENDING,
        "marry",
        new ChatCondition() {
          public boolean fire(final Player player, final Sentence sentence,
              final Entity npc) {
            return (player.isQuestCompleted(marriage.getQuestSlot()));
          }
        },
View Full Code Here

    clerk = npcs.get("Wilfred");

    clerk.add(ConversationStates.ATTENDING,
        "divorce",
        new ChatCondition() {
          public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
            return (player.isQuestCompleted(marriage.getQuestSlot()))
                && player.isEquipped("wedding ring") && player.isEquipped("money",200*player.getLevel());
          }
        },
        ConversationStates.QUESTION_3,
        null,
           new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            Player husband;
            Player wife;
            String partnerName;
            String additional = "";
            husband = player;
            partnerName = husband.getQuest(marriage.getSpouseQuestSlot());
            wife = SingletonRepository.getRuleProcessor().getPlayer(
                partnerName);
            if ((wife != null)
                && wife.hasQuest(marriage.getQuestSlot())
                && wife.getQuest(marriage.getSpouseQuestSlot()).equals(
                    husband.getName())) {
              if (wife.isEquipped("money", 200*wife.getLevel())) {
                additional = partnerName + " has their fee of " + 200*wife.getLevel() + " and will also be charged.";
              } else {
                additional = partnerName + " doesn't have their fee of " + 200*wife.getLevel() + " and will lose 3% xp instead.";
              }
            }
            npc.say("There's an offer currently, you can pay to divorce instead of losing xp. It will cost you " + 200* player.getLevel() + " money. " + additional + " Do you want to divorce, and pay the money instead of losing xp?");
          }
        });

    clerk.add(ConversationStates.ATTENDING,
          "divorce",
          new ChatCondition() {
            public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
              return (player.isQuestCompleted(marriage.getQuestSlot()))
                && player.isEquipped("wedding ring") && !player.isEquipped("money",200*player.getLevel());
            }
          },
          ConversationStates.QUESTION_3,
          null,
          new ChatAction() {
            public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
              Player husband;
              Player wife;
              String partnerName;
              String additional = "";
              husband = player;
              partnerName = husband.getQuest(marriage.getSpouseQuestSlot());
              wife = SingletonRepository.getRuleProcessor().getPlayer(partnerName);
              if ((wife != null)
                && wife.hasQuest(marriage.getQuestSlot())
                && wife.getQuest(marriage.getSpouseQuestSlot()).equals(
                                           husband.getName())) {
                if (wife.isEquipped("money", 200*wife.getLevel())) {
                  additional = partnerName + " has their fee of " + 200*wife.getLevel() + " and will also be charged.";
                } else {
                  additional = partnerName + " doesn't have their fee of " + 200*wife.getLevel() + " and will lose 3% xp instead.";
                }
              }
              npc.say("There's an offer currently, you can pay to divorce instead of losing xp. It would cost you " + 200* player.getLevel() + " money, but you do not have sufficent money here with you. " + additional + " You can take the penalty of losing 3% of your xp. Do you want to divorce, and lose the xp?");
            }
          });
   
    clerk.add(ConversationStates.ATTENDING,
          "divorce",
          new ChatCondition() {
            public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
              return (player.hasQuest(marriage.getQuestSlot())
                  && player.getQuest(marriage.getQuestSlot()).equals("just_married"))
                  && player.isEquipped("wedding ring");
            }
          },
          ConversationStates.QUESTION_3,
          "I see you haven't been on your honeymoon yet. Are you sure you want to divorce so soon?",
          null);

    clerk.add(ConversationStates.ATTENDING,
        "divorce",
        new NotCondition(
          // isMarriedCondition()
          new ChatCondition() {
            public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
              return (player.isQuestCompleted(marriage.getQuestSlot()) ||
                  (player.hasQuest(marriage.getQuestSlot()) && player.getQuest(marriage.getQuestSlot()).equals("just_married")));
            }
          }
        ), ConversationStates.ATTENDING,
        "You're not even married. Stop wasting my time!",
        null);

    clerk.add(ConversationStates.ATTENDING,
        "divorce",
        new AndCondition(
          // isMarriedCondition()
          new ChatCondition() {
            public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
              return (player.isQuestCompleted(marriage.getQuestSlot()) ||
                  (player.hasQuest(marriage.getQuestSlot()) && player.getQuest(marriage.getQuestSlot()).equals("just_married")));
            }
          },
View Full Code Here

     */
    private void preparePlayerGetsSheepStep() {
        final SpeakerNPC npc = npcs.get("Nishiya");

        // If quest is not done or started yet ask player for help (if he does not have a sheep already)
        ChatCondition playerHasNoSheep = new ChatCondition() {
            public boolean fire(Player player, Sentence sentence, Entity npc) {
                return !player.hasSheep();
            }
        };
        npc.add(
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.npc.ChatCondition

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.