Package games.stendhal.server.entity.npc

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


    return false;
  }
 
  @Override
  public ChatCondition getTransactionCondition() {
    return new ChatCondition() {
      public boolean fire(Player player, Sentence sentence, Entity npc) {
        ItemParserResult res = parse(sentence);
        return canDealWith(res.getChosenItemName());
      }
    };
View Full Code Here


      reward.add(new IncreaseKarmaAction(35.0));
      reward.add(new SetQuestAction(QUEST_SLOT, "food_brought"));

      npc.add(ConversationStates.ATTENDING,
        itemName,
        new ChatCondition() {
          public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
            return player.hasQuest(QUEST_SLOT)
                && player.getQuest(QUEST_SLOT).equals(itemName)
                && player.isEquipped(itemName, REQUIRED_FOOD);
          }
View Full Code Here

    final int y = MathHelper.parseInt(attributes.get("y"));
    final String orientation = attributes.get("orientation");
    final String image = attributes.get("image");
    final int autoclose = MathHelper.parseInt(attributes.get("autoclose"));
   
    ChatCondition condition = null;
    final String condString = attributes.get("condition");
    if (condString != null) {
      final GroovyShell interp = new GroovyShell(new Binding());
      String code = "import games.stendhal.server.entity.npc.condition.*;\r\n"
        + condString;
View Full Code Here

    ConversationStates state = IDLE;
    ConversationStates nextState = ATTENDING;

    final String triggers = "boo";

    final ChatCondition cc = new ChatCondition() {
      public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
        assertEquals(triggers, sentence.getTriggerExpression().getNormalized());
        return true;
      }
    };
View Full Code Here

  @Test
  public final void testGetCondition() {
    Transition t = new Transition(someconst, Arrays.asList(ConversationParser.createTriggerExpression("trigger")),
                    null, false, idle_0, null, null);
    assertNull(t.getCondition());
    final ChatCondition cond = new ChatCondition() {
      public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
        return false;
      }
    };
    t = new Transition(someconst, Arrays.asList(ConversationParser.createTriggerExpression("trigger")),
View Full Code Here

                            // Rat Children (Agnus)
                            new QuestCompletedCondition("find_rat_kids"),
                            // Find Ghosts (Carena)
                            new QuestCompletedCondition("find_ghosts"),
                            // Meet Angels (any of the cherubs)
                            new ChatCondition() {
                              public boolean fire(final Player player, final Sentence sentence, final Entity entity) {
                                if (!player.hasQuest("seven_cherubs")) {
                                  return false;
                                }
                                final String npcDoneText = player.getQuest("seven_cherubs");
                                final String[] done = npcDoneText.split(";");
                                final int left = 7 - done.length;
                                return left < 0;
                              }
                            })));

    // earn over 250 karma
    achievements.add(createAchievement("friend.karma.250", "Good Samaritan", "Earn a very good karma",
        Achievement.MEDIUM_BASE_SCORE, true,
        new ChatCondition() {
      public boolean fire(final Player player, final Sentence sentence, final Entity entity) {
        return player.getKarma()>250;
      }
    }));
View Full Code Here

   * Tests for equalsthisandsingle.
   */
  @Test
  public void testEqualsthisandsingle() throws Exception {
    final String QUEST_SLOT = "quest";
    final ChatCondition andcon =  new AndCondition(new QuestInStateCondition(QUEST_SLOT, "start")
       , new KilledCondition("dark elf archer", "dark elf captain", "thing"));

    final ChatCondition instate = new QuestInStateCondition(QUEST_SLOT, "start");
      assertFalse(andcon.equals(instate));
      assertFalse(instate.equals(andcon));
  }
View Full Code Here

    taxman.addReply("tax", "All house owners must #pay taxes to the state.");

    taxman.add(ConversationStates.ATTENDING,
        "pay",
        new ChatCondition() {
          public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
            return getUnpaidTaxPeriods(player) > 0;
          }
    },
    ConversationStates.QUESTION_1,
    "Do you want to pay your taxes now?",
    null);

    taxman.add(ConversationStates.ATTENDING,
           Arrays.asList("pay", "payment"),
           new ChatCondition() {
             public boolean fire(final Player player, final Sentence sentence, final Entity npc) {
               return getUnpaidTaxPeriods(player) <= 0;
             }
           },
           ConversationStates.ATTENDING,
View Full Code Here

    playerReturnsAfterCompletingQuest(scientistNpc);
  }

  private void playerReturnsToFetchReward(SpeakerNPC npc) {
    // time has passed
    final ChatCondition condition = new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestStateStartsWithCondition(QUEST_SLOT,"decorating"),
            new TimePassedCondition(QUEST_SLOT, 1, 5)
          );
    final ChatAction action = new MultipleActions(
                      new SetQuestAction(QUEST_SLOT,"done"),
                      new IncreaseKarmaAction(20),
                      new IncreaseXPAction(10000),
                      // here, true = bind them to player
                      new EquipItemAction("black legs", 1, true)
                    );
    npc.add(ConversationStates.IDLE,
        ConversationPhrases.GREETING_MESSAGES,
        condition,
        ConversationStates.IDLE,
        "Here are the black legs. Now I beg you to wear them. The symbol of my pain is done. Fare thee well.",
        action);
   
    // time has not yet passed
    final ChatCondition notCondition = new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
        new QuestStateStartsWithCondition(QUEST_SLOT,"decorating"),
        new NotCondition( new TimePassedCondition(QUEST_SLOT, 1, 5))
      );
    ChatAction reply = new SayTimeRemainingAction(QUEST_SLOT, 1, 5, "I did not finish decorating the legs. " +
            "Please check back in");
View Full Code Here

        null,
        reply);
  }
 
  private void playerReturnsAfterKillingTheImperialScientist(SpeakerNPC npc) {
    final ChatCondition condition = new AndCondition(
        new QuestStateStartsWithCondition(QUEST_SLOT, "kill_scientist"),
        new KilledForQuestCondition(QUEST_SLOT, 1),
        new PlayerHasItemWithHimCondition("goblet")
      );
    ChatAction action = new MultipleActions(
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.