Examples of ChatAction


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

    npc.addMatching(ConversationStates.QUEST_ITEM_QUESTION,
        // match for all numbers as trigger expression
        ExpressionType.NUMERAL, new JokerExprMatcher(),
        new TextHasNumberCondition(1, 5000),
        ConversationStates.ATTENDING, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {

                        final int required = (sentence.getNumeral().getAmount());
            if (player.drop("money" , required * MOSS_COST)) {
              npc.say("Ok, here's your " + Integer.toString(required) + " pieces of twilight moss. Don't take too much at once.");
View Full Code Here

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

     * can check if that was the food type he was asked to bring.
     */
    npc.add(ConversationStates.QUEST_OFFERED,
      ConversationPhrases.YES_MESSAGES, null,
      ConversationStates.ATTENDING, null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          final String food = player.getQuest(QUEST_SLOT);
          npc.say("Thank you! I hope it doesn't take too long to collect. Don't forget to say '"
            + food + "' when you have it.");
          // player.setQuest(QUEST_SLOT, food);
          player.addKarma(5.0);
          // set food to null?
        }
      });

    // Player says no. they might get asked to bring a different food next
    // time but they've lost karma.
    npc.add(ConversationStates.QUEST_OFFERED,
        ConversationPhrases.NO_MESSAGES,
        null,
        ConversationStates.IDLE,
        "I'm not sure how I'll survive next year now. Good bye, cruel soul.",
        new SetQuestAndModifyKarmaAction(QUEST_SLOT, "rejected", -5.0));

    // Player asks what supplies he needs, and a random choice of what he
    // wants is made.
    npc.add(ConversationStates.QUEST_ITEM_QUESTION,
        "supplies",
        null,
        ConversationStates.QUEST_OFFERED,
        null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            final String food = Rand.rand(FOOD_LIST);
            player.setQuest(QUEST_SLOT, food);
            npc.say("If you could get me " + REQUIRED_FOOD
                + " pieces of " + food
View Full Code Here

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

    final SpeakerNPC npc = npcs.get("Alrak");

    /** If player has quest and has brought the food, and says so, take it */
    for(final String itemName : FOOD_LIST) {
      final List<ChatAction> reward = new LinkedList<ChatAction>();
      reward.add(new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            if (player.drop(itemName, REQUIRED_FOOD)) {
              npc.say("Great! You brought the " + itemName + "!");
            }
          } });
View Full Code Here

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

  private void step_3() {

    final SpeakerNPC npc = npcs.get("Andy");
   
    ChatAction addRandomNumberOfItemsAction = new ChatAction() {
      public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
        //add random number of soups
        final StackableItem soup = (StackableItem) SingletonRepository.getEntityManager()
            .getItem("soup");
        int amount;
View Full Code Here

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

            "fee",
            new AndCondition(new LevelGreaterThanCondition(MIN_LEVEL - 1),
                new TimePassedCondition(QUEST_SLOT, DAYS_BEFORE_REPEAT * MINUTES_IN_DAYS)),
                ConversationStates.QUEST_OFFERED,
                null,
                new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            npc.say("The fee is your current level, multiplied by " + COST_FACTOR + " and payable in cash. At your level of "
                + player.getLevel() + " the fee is " + COST_FACTOR * player.getLevel() + " money. Do you want to fight?");     
          }
        });

        // player meets conditions, first remind them of the dangers and wait for a 'yes'
        add(ConversationStates.ANY,
            Arrays.asList("challenge", "fight", "battle"),
            new AndCondition(new LevelGreaterThanCondition(MIN_LEVEL - 1),
                new TimePassedCondition(QUEST_SLOT, DAYS_BEFORE_REPEAT * MINUTES_IN_DAYS)),
                ConversationStates.QUEST_OFFERED,
                "I accept your challenge. If you can pay the #fee, I will summon an island with " + NUMBER_OF_CREATURES
                + " dangerous creatures for you to face. So, are you sure you want to enter the adventure island?",
                null);
        // player returns within DAYS_BEFORE_REPEAT days, and his island has expired
        add(ConversationStates.ANY,
            Arrays.asList("challenge", "fight", "battle", "fee"),
            new AndCondition(
                new NotCondition(new TimePassedCondition(QUEST_SLOT, DAYS_BEFORE_REPEAT * MINUTES_IN_DAYS)),
                new NotCondition(new AdventureZoneExistsCondition())
            ),
            ConversationStates.ATTENDING,
            null,
            new SayTimeRemainingAction(QUEST_SLOT, DAYS_BEFORE_REPEAT * MINUTES_IN_DAYS, "Your life force will not support the island so soon after you last visited. You will be ready again in"));

        // player returns within DAYS_BEFORE_REPEAT days, if the zone still exists that he was in before, send him straight up.
        add(ConversationStates.ANY,
            Arrays.asList("challenge", "fight", "battle", "fee"),
            new AndCondition(
                new NotCondition(new TimePassedCondition(QUEST_SLOT, DAYS_BEFORE_REPEAT * MINUTES_IN_DAYS)),
                new AdventureZoneExistsCondition()
            ),
            ConversationStates.QUESTION_1,
            "The island which I recently summoned for you, remains for you to visit at no extra cost. Do you wish to return to it?",
            null);

        // player below MIN_LEVEL
        add(ConversationStates.ANY,
            Arrays.asList("challenge", "fight", "battle", "fee"),
            new LevelLessThanCondition(MIN_LEVEL),
            ConversationStates.ATTENDING,
            "You are too weak to fight against " + NUMBER_OF_CREATURES  + " at once. Come back when you are at least Level " + MIN_LEVEL + ".",
            null);
        // all conditions are met and player says yes he wants to fight
        add(ConversationStates.QUEST_OFFERED,
            ConversationPhrases.YES_MESSAGES,
            new LevelGreaterThanCondition(MIN_LEVEL - 1),
            ConversationStates.IDLE,
            null,
            new ChallengeChatAction());
        // player was reminded of dangers and he doesn't want to fight
        add(ConversationStates.QUEST_OFFERED,
            ConversationPhrases.NO_MESSAGES,
            null,
            ConversationStates.ATTENDING,
            "Fair enough.",
            null)

        // player wishes to return to an existing adventure island
        add(ConversationStates.QUESTION_1,
            ConversationPhrases.YES_MESSAGES,
            // check again it does exist
            new AdventureZoneExistsCondition(),
            ConversationStates.IDLE,
            null,
            new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            final String zoneName = player.getName() + "_adventure_island";
            final StendhalRPZone zone = SingletonRepository.getRPWorld().getZone(zoneName);
            player.teleport(zone, 4, 4, Direction.DOWN, null);
            player.notifyWorldAboutChanges();
View Full Code Here

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

    final String triggers = "boo";

    final ConversationStates nextState = ConversationStates.ATTENDING;
    final String reply = "huch";
    final ChatAction action = new ChatAction() {
      public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
        assertEquals("boo", sentence.getTriggerExpression().getNormalized());
      }
    };
    en.add(state, triggers, null, false, nextState, reply, action);
View Full Code Here

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

  public void testaddExistingActionNull() throws Exception {
    final Engine en = new Engine(new SpeakerNPC("bob"));

    en.add(IDLE, (String)null, null, false, IDLE, null, null);
    assertThat(en.getTransitions().size(), is(1));
    en.add(IDLE, (String)null, null, false, IDLE, null, new ChatAction() {
      public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
        // empty method
      }
    });
    assertThat(en.getTransitions().size(), is(2));
View Full Code Here

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

  @Test
  public void testaddnewNullAction() throws Exception {
    final Engine en = new Engine(new SpeakerNPC("bob"));


    en.add(IDLE, (String)null, null, false, IDLE, null, new ChatAction() {
      public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
        // empty method
      }
    });
    assertThat(en.getTransitions().size(), is(1));
View Full Code Here

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

   * Tests for addSameAction.
   */
  @Test
  public void testaddSameAction() throws Exception {
    final Engine en = new Engine(new SpeakerNPC("bob"));
    ChatAction chatAction = new ChatAction() {

      public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
        // empty method
      }
    };
View Full Code Here

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

   * Tests for addNotSameAction.
   */
  @Test
  public void testaddNotSameAction() throws Exception {
    final Engine en = new Engine(new SpeakerNPC("bob"));
    ChatAction chatAction1 = new ChatAction() {

      public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
        // empty method
      }
    };
    ChatAction chatAction2 = new ChatAction() {

      public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
        // empty method
      }
    };
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.