Package games.stendhal.server.entity.npc.fsm

Examples of games.stendhal.server.entity.npc.fsm.Engine


    quest.setNpc(npc);
    final BringListOfItemsQuestLogic logic = new BringListOfItemsQuestLogic(quest);
    logic.welcomeNewPlayer();

    final Player player = PlayerTestHelper.createPlayer("player");
    final Engine en = npc.getEngine();
    en.step(player, "hi");
    assertTrue(npc.isTalking());
    assertEquals(quest.welcomeBeforeStartingQuest(), getReply(npc));
  }
View Full Code Here


  public final void rejectQuest() {
    SingletonRepository.getNPCList().add(new SpeakerNPC("Josephine"));
    final CloakCollector cc = new CloakCollector();
    cc.addToWorld();
    final SpeakerNPC npc = cc.getNPC();
    final Engine en = npc.getEngine();
    final Player monica = PlayerTestHelper.createPlayer("player");

    en.stepTest(monica, ConversationPhrases.GREETING_MESSAGES.get(0));
    assertEquals(cc.welcomeBeforeStartingQuest(), getReply(npc));

    en.stepTest(monica, cc.getAdditionalTriggerPhraseForQuest().get(0));
    assertEquals(cc.respondToQuest(), getReply(npc));

    en.stepTest(monica, cc.getTriggerPhraseToEnumerateMissingItems().get(0));
    assertEquals(cc.firstAskForMissingItems(cc.getNeededItems()), getReply(npc));

    en.stepTest(monica, "no");
    assertEquals(cc.respondToQuestRefusal(), getReply(npc));
  }
View Full Code Here

    final BringListOfItemsQuestLogic logic = new BringListOfItemsQuestLogic(quest);
    logic.welcomePlayerAfterQuest();

    final Player player = PlayerTestHelper.createPlayer("player");
    player.setQuest(quest.getSlotName(), "done");
    final Engine en = npc.getEngine();
    en.step(player, "hi");
    assertFalse(npc.isTalking());
  }
View Full Code Here

    final BringListOfItemsQuestLogic logic = new BringListOfItemsQuestLogic(quest);
    logic.welcomePlayerAfterQuest();

    final Player player = PlayerTestHelper.createPlayer("player");
    player.setQuest(quest.getSlotName(), "done");
    final Engine en = npc.getEngine();
    en.step(player, "hi");
    assertTrue(npc.isTalking());
    assertEquals(quest.welcomeAfterQuestIsCompleted(), getReply(npc));
  }
View Full Code Here

    quest.setNpc(npc);
    final BringListOfItemsQuestLogic logic = new BringListOfItemsQuestLogic(quest);
    logic.addToWorld();

    final Player player = PlayerTestHelper.createPlayer("player");
    final Engine en = npc.getEngine();
    en.step(player, "hi");
    assertTrue(npc.isTalking());
    assertEquals("first hi", quest.welcomeBeforeStartingQuest(), getReply(npc));
    npc.put("text", "");

    en.step(player, ConversationPhrases.QUEST_MESSAGES.get(0));
    assertEquals("answer to quest", quest.respondToQuest(), getReply(npc));

    en.step(player, ConversationPhrases.YES_MESSAGES.get(0));
    assertEquals("answer to quests accepted", quest.respondToQuestAcception(), getReply(npc));
    assertTrue(player.hasQuest(quest.getSlotName()));
    assertFalse(npc.isTalking());
    en.step(player, ConversationPhrases.GREETING_MESSAGES.get(0));
    assertTrue(npc.isTalking());

    en.step(player, quest.getTriggerPhraseToEnumerateMissingItems().get(0));
    assertEquals("i have not brought anything yet it should be all needed items",
        "#one, #two, and #three", getReply(npc));

    StackableItem item = new StackableItem("one", "", "", null);
    item.setQuantity(10);
    item.setID(new ID(2, "testzone"));
    player.getSlot("bag").add(item);
    en.step(player, "yes");
    assertEquals("item brought", quest.askForItemsAfterPlayerSaidHeHasItems(), getReply(npc));

    en.step(player, "one");
    assertEquals("item brought", quest.respondToItemBrought(), getReply(npc));
    en.step(player, "one");
    assertEquals("item brought", quest.respondToOfferOfNotMissingItem(), getReply(npc));
    npc.remove("text");
    assertEquals(ConversationStates.QUESTION_1, en.getCurrentState());
    en.step(player, quest.getTriggerPhraseToEnumerateMissingItems().get(0));
    final List<String> missing = new LinkedList<String>(quest.getNeededItems());
    missing.remove("one");
    assertEquals("two and three are missing", "#two and #three", getReply(npc));
    en.step(player, "two");
    assertEquals("item brought", quest.respondToOfferOfNotExistingItem("two"), getReply(npc));

    item = new StackableItem("two", "", "", null);
    item.setQuantity(10);
    item.setID(new ID(2, "testzone"));
    player.getSlot("bag").add(item);
    item = new StackableItem("three", "", "", null);
    item.setQuantity(10);
    item.setID(new ID(2, "testzone"));
    player.getSlot("bag").add(item);
    en.step(player, "three");
    assertEquals("item brought", quest.respondToItemBrought(), getReply(npc));
    en.step(player, "two");
    assertEquals("last item brought", quest.respondToLastItemBrought(), getReply(npc));
  }
View Full Code Here

    SingletonRepository.getNPCList().add(new SpeakerNPC("Josephine"));
    final CloakCollector cc = new CloakCollector();
    cc.addToWorld();
 
    final SpeakerNPC npc = cc.getNPC();
    final Engine en = npc.getEngine();
    final Player monica = PlayerTestHelper.createPlayer("monica");

    en.stepTest(monica, ConversationPhrases.GREETING_MESSAGES.get(0));
    assertEquals(cc.welcomeBeforeStartingQuest(), getReply(npc));

    en.stepTest(monica, cc.getAdditionalTriggerPhraseForQuest().get(0));
    assertEquals(cc.respondToQuest(), getReply(npc));

    en.stepTest(monica, "elf cloak");
    assertEquals(
        "You haven't seen one before? Well, it's a elf cloak. So, will you find them all?",
        getReply(npc));

    en.stepTest(monica, "pink cloak");
    assertEquals("I don't know pink cloak. Can you name me another cloak please?", getReply(npc));

    en.stepTest(monica, ConversationPhrases.YES_MESSAGES.get(0));
    assertEquals(cc.respondToQuestAcception(), getReply(npc));
    assertFalse(npc.isTalking());
    npc.remove("text");

    assertTrue("the quest was accepted, so it should be started",
        cc.isStarted(monica));
    assertFalse(cc.isCompleted(monica));

    en.stepTest(monica, ConversationPhrases.GREETING_MESSAGES.get(0));
    assertEquals(cc.welcomeDuringActiveQuest(), getReply(npc));
    npc.remove("text");
    en.stepTest(monica, ConversationPhrases.YES_MESSAGES.get(0));
    assertEquals(cc.askForItemsAfterPlayerSaidHeHasItems(), getReply(npc));

    en.stepTest(monica, "elf cloak");
    assertEquals(cc.respondToOfferOfNotExistingItem("elf cloak"),
        getReply(npc));

    Item cloak = new Item("elf cloak", "", "", null);
    monica.getSlot("bag").add(cloak);
    en.stepTest(monica, "elf cloak");
    assertEquals(cc.respondToItemBrought(), getReply(npc));
    en.stepTest(monica, "elf cloak");
    assertEquals(cc.respondToOfferOfNotMissingItem(), getReply(npc));

    cloak = new Item("stone cloak", "", "", null);
    monica.getSlot("bag").add(cloak);

    for (final String cloakName : cc.getNeededItems()) {
      cloak = new Item(cloakName, "", "", null);
      monica.getSlot("bag").add(cloak);
      en.step(monica, cloakName);
    }

    assertEquals(cc.respondToLastItemBrought(), getReply(npc));
    en.step(monica, ConversationPhrases.GOODBYE_MESSAGES.get(0));
    assertTrue(cc.isCompleted(monica));
  }
View Full Code Here

    final BringListOfItemsQuestLogic logic = new BringListOfItemsQuestLogic(quest);
    logic.addToWorld();

    final Player player = PlayerTestHelper.createPlayer("player");

    final Engine en = npc.getEngine();
    en.step(player, "hi");
    assertTrue(npc.isTalking());
    assertEquals("first hi", quest.welcomeBeforeStartingQuest(), getReply(npc));
    npc.put("text", "");

    en.step(player, ConversationPhrases.QUEST_MESSAGES.get(0));
    assertEquals("answer to quest", quest.respondToQuest(), getReply(npc));

    en.step(player, ConversationPhrases.YES_MESSAGES.get(0));
    assertEquals("answer to quests accepted", quest.respondToQuestAcception(), getReply(npc));
  }
View Full Code Here

  @Test
  public void requestQuest()  {
    for (String request : ConversationPhrases.QUEST_MESSAGES) {
      final Player player = PlayerTestHelper.createPlayer("me");     
      final SpeakerNPC npc = vs.npcs.get(DWARF_NPC);
      final Engine en = vs.npcs.get(DWARF_NPC).getEngine();
     
      assertFalse(player.hasQuest(questSlot));
      en.setCurrentState(ConversationStates.ATTENDING);
     
      en.step(player, request);
      assertEquals(request, "I can forge a powerful life stealing sword for you. You will need to go to the Catacombs below Semos Graveyard and fight the Vampire Lord. Are you interested?", getReply(npc));
      assertEquals(en.getCurrentState(), ConversationStates.QUEST_OFFERED);
    }
  }
View Full Code Here

  @Test
  public void requestAgainAfterDone() {
    for (String request : ConversationPhrases.QUEST_MESSAGES) {
      final Player player = PlayerTestHelper.createPlayer("me");     
      final SpeakerNPC npc = vs.npcs.get(DWARF_NPC);
      final Engine en = vs.npcs.get(DWARF_NPC).getEngine();
   
      player.setQuest(questSlot, "done");
      en.setCurrentState(ConversationStates.ATTENDING);
     
      en.step(player, request);
      assertEquals(request, "What are you bothering me for now? You've got your sword, go and use it!", getReply(npc));
      assertEquals(en.getCurrentState(), ConversationStates.ATTENDING);
    }
  }
View Full Code Here

 
  @Test public void requestWhileQuestActive() {
    for (String request : ConversationPhrases.QUEST_MESSAGES) {
      final Player player = PlayerTestHelper.createPlayer("me");     
      final SpeakerNPC npc = vs.npcs.get(DWARF_NPC);
      final Engine en = vs.npcs.get(DWARF_NPC).getEngine();
   
      // getting to this state should not be possible while the quest is active,
      // but there's a response for it in the quest. test for a sane answer in
      // case the implementation changes
      for (String state : Arrays.asList("start", "forging")) {
        player.setQuest(questSlot, state);
        en.setCurrentState(ConversationStates.ATTENDING);
     
        en.step(player, request);
        assertEquals(request, "Why are you bothering me when you haven't completed your quest yet?", getReply(npc));
        assertEquals(en.getCurrentState(), ConversationStates.ATTENDING);
      }
    }
  }
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.npc.fsm.Engine

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.