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

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


  @Test
  public void testVampireLordDescription() {
    for (String word : Arrays.asList("lord", "vampire", "skull ring")) {
      final Player player = PlayerTestHelper.createPlayer("me");     
      final SpeakerNPC npc = vs.npcs.get(VAMPIRE_NPC);
      final Engine en = vs.npcs.get(VAMPIRE_NPC).getEngine();
     
      en.setCurrentState(ConversationStates.ATTENDING);
     
      en.step(player, word);
      assertEquals("answer to '" + word + "'", "The Vampire Lord rules these Catacombs! And I'm afraid of him. I can only help you if you kill him and bring me his skull ring with the #goblet.", getReply(npc));
      assertEquals(en.getCurrentState(), ConversationStates.ATTENDING);
    }
  }
View Full Code Here


  @Test
  public void testVampiresGobletDescription() {
    for (String word : Arrays.asList("empty goblet", "goblet")) {
      final Player player = PlayerTestHelper.createPlayer("me");     
      final SpeakerNPC npc = vs.npcs.get(VAMPIRE_NPC);
      final Engine en = vs.npcs.get(VAMPIRE_NPC).getEngine();
     
      en.setCurrentState(ConversationStates.ATTENDING);
     
      en.step(player, word);
      assertEquals("answer to '" + word + "'", "Only a powerful talisman like this cauldron or a special goblet should contain blood.", getReply(npc));
      assertEquals(en.getCurrentState(), ConversationStates.ATTENDING);
    }
  }
View Full Code Here

 
  @Test
  public void askForFillingWithoutNeededItems() {
    final Player player = PlayerTestHelper.createPlayer("me");     
    final SpeakerNPC npc = vs.npcs.get(VAMPIRE_NPC);
    final Engine en = vs.npcs.get(VAMPIRE_NPC).getEngine();
   
    en.setCurrentState(ConversationStates.ATTENDING);
   
    en.step(player, "fill");
    // the list of needed items goes through various hashtables before
    // ending in the answer, so the order is very much implementation
    // defined. don't test for it - just test that Markovich wants
    // something
    String answer = getReply(npc);
    assertTrue("answer to 'fill'", answer.startsWith("I can only fill a goblet if you bring me "));
    assertEquals("should not have a '" + sickySlotName + "' slot", null, player.getQuest(sickySlotName));
    assertEquals(en.getCurrentState(), ConversationStates.ATTENDING);
  }
View Full Code Here

 
  @Test
  public void askForFillingWithIncompleteItems() {
    final Player player = PlayerTestHelper.createPlayer("me");     
    final SpeakerNPC npc = vs.npcs.get(VAMPIRE_NPC);
    final Engine en = vs.npcs.get(VAMPIRE_NPC).getEngine();
   
    Item item = SingletonRepository.getEntityManager().getItem("empty goblet");
    player.equipToInventoryOnly(item);
    item = SingletonRepository.getEntityManager().getItem("skull ring");
    player.equipToInventoryOnly(item);
    item = SingletonRepository.getEntityManager().getItem("bat entrails");
    player.equipToInventoryOnly(item);
    item = SingletonRepository.getEntityManager().getItem("vampirette entrails");
    player.equipToInventoryOnly(item);
   
    en.step(player, "fill");
    String answer = getReply(npc);
    assertTrue("answer to 'fill'", answer.startsWith("I can only fill a goblet if you bring me "));
    assertEquals("should not have a '" + sickySlotName + "' slot", null, player.getQuest(sickySlotName));
    assertEquals(en.getCurrentState(), ConversationStates.ATTENDING);
  }
View Full Code Here

 
  @Test
  public void askForFilling() {
    final Player player = PlayerTestHelper.createPlayer("me");     
    final SpeakerNPC npc = vs.npcs.get(VAMPIRE_NPC);
    final Engine en = vs.npcs.get(VAMPIRE_NPC).getEngine();
   
    en.setCurrentState(ConversationStates.ATTENDING);
   
    fillSlots(player);
   
    en.step(player, "fill");
    String answer = getReply(npc);
    assertTrue("answer to 'fill'", answer.startsWith("I need you to fetch me "));
    assertTrue("answer to 'fill'", answer.endsWith("for this job. Do you have it?"));
    assertEquals(en.getCurrentState(), ConversationStates.PRODUCTION_OFFERED);

    en.step(player, "bye");
    assertEquals("*cough* ... farewell ... *cough*", getReply(npc));
  }
View Full Code Here

  @Test
  public void startFillingGoblet() {
    for (String yes : ConversationPhrases.YES_MESSAGES) {
      final Player player = PlayerTestHelper.createPlayer("me");     
      final SpeakerNPC npc = vs.npcs.get(VAMPIRE_NPC);
      final Engine en = vs.npcs.get(VAMPIRE_NPC).getEngine();

      en.step(player, "hi");
      assertEquals("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.", getReply(npc));

      for(Map.Entry<String, Integer> it : requiredForFilling.entrySet()) {
        int amount = it.getValue();
        if (amount > 1) {
          PlayerTestHelper.equipWithStackableItem(player, it.getKey(), amount);
        } else {
          PlayerTestHelper.equipWithItem(player, it.getKey());
        }
      }

      en.step(player, "fill");
      assertEquals("I need you to fetch me 7 #'bat entrails', 7 #'vampirette entrails', a #'skull ring', and an #'empty goblet' for this job. Do you have it?", getReply(npc));

      en.step(player, yes);
      assertEquals("answer to '" + yes + "'", "OK, I will fill a goblet for you, but that will take some time. Please come back in 5 minutes.", getReply(npc));

      en.step(player, "bye");
      assertEquals("*cough* ... farewell ... *cough*", getReply(npc));

      // wait 5 minutes
      PlayerTestHelper.setPastTime(player, questSlot, 2, 5*60);

      en.step(player, "hi");
      assertEquals("Welcome back! I'm still busy with your order to fill a goblet for you. Come back in 5 minutes to get it.", getReply(npc));

      assertFalse(player.isEquipped("goblet"));
      for(String item : requiredForFilling.keySet()) {
        assertFalse("vampire took " + item, player.isEquipped(item));
      }

      assertEquals(en.getCurrentState(), ConversationStates.ATTENDING);
      assertTrue("player has " + sickySlotName + "slot", player.hasQuest(sickySlotName));

      en.step(player, "bye");
      assertEquals("*cough* ... farewell ... *cough*", getReply(npc));
    }
  }
View Full Code Here

  public void tryGettingGobletTooEarly() {
    String questState = "1;goblet;" + Long.toString(new Date().getTime());
    for (String hello : ConversationPhrases.GREETING_MESSAGES) {
      final Player player = PlayerTestHelper.createPlayer("me");     
      final SpeakerNPC npc = vs.npcs.get(VAMPIRE_NPC);
      final Engine en = vs.npcs.get(VAMPIRE_NPC).getEngine();
     
      en.setCurrentState(ConversationStates.IDLE);
      player.setQuest(sickySlotName, questState);
     
      en.step(player, hello);
      // This will fail if someone manages to stop the test
      // within the loop and continue later. (Or to run it on a
      // ridiculously slow computer)
      assertEquals("too early '" + hello + "'", "Welcome back! I'm still busy with your order to fill a goblet for you. Come back in 5 minutes to get it.", getReply(npc));
      assertEquals(en.getCurrentState(), ConversationStates.ATTENDING);
     
      // bothering Markovich should not affect the quest state
      // or give the goblet too early
      assertEquals(questState, player.getQuest(sickySlotName));
      assertFalse(player.isEquipped("goblet"));
View Full Code Here

    // 1 min in the future
    String questState = "1;goblet;" + Long.toString(new Date().getTime() + 60 * 1000);
    for (String hello : ConversationPhrases.GREETING_MESSAGES) {
      final Player player = PlayerTestHelper.createPlayer("me");     
      final SpeakerNPC npc = vs.npcs.get(VAMPIRE_NPC);
      final Engine en = vs.npcs.get(VAMPIRE_NPC).getEngine();
     
      en.setCurrentState(ConversationStates.IDLE);
      player.setQuest(sickySlotName, questState);
     
      en.step(player, hello);
      assertTrue("''" + hello + "' in future", getReply(npc).startsWith("Welcome back! I'm still busy with your order to fill a goblet for you. Come back in"));
      assertEquals(en.getCurrentState(), ConversationStates.ATTENDING);
     
      // bothering Markovich should not affect the quest state
      // or give the goblet too early
      assertEquals(questState, player.getQuest(sickySlotName));
      assertFalse(player.isEquipped("goblet"));
View Full Code Here

 
  @Test
  public void fillGoblet() {
    final Player player = PlayerTestHelper.createPlayer("me");     
    final SpeakerNPC npc = vs.npcs.get(VAMPIRE_NPC);
    final Engine en = vs.npcs.get(VAMPIRE_NPC).getEngine();
   
    // jump to the past
    String questState = "1;goblet;" + Long.toString(new Date().getTime() - 5 * 60 * 1000);
    for (String hello : ConversationPhrases.GREETING_MESSAGES) {
      en.setCurrentState(ConversationStates.IDLE);
      player.setQuest(sickySlotName, questState);
     
      en.step(player, hello);
      assertEquals("''" + hello + "' in past", "Welcome back! I'm done with your order. Here you have the goblet.", getReply(npc));
      assertEquals(en.getCurrentState(), ConversationStates.ATTENDING);
     
      assertEquals("done", player.getQuest(sickySlotName));
      assertTrue("player got the goblet", player.isEquipped("goblet"));
     
      final Item goblet = player.getFirstEquipped("goblet");
View Full Code Here

  @Test
  public void greetDwarfWithFullGobletNoKill() {
    for (String hello : ConversationPhrases.GREETING_MESSAGES) {
      final Player player = PlayerTestHelper.createPlayer("me")
      final SpeakerNPC npc = vs.npcs.get(DWARF_NPC);
      final Engine en = vs.npcs.get(DWARF_NPC).getEngine();
   
      en.setCurrentState(ConversationStates.IDLE);
      player.setQuest(questSlot, "start");
      Item item = SingletonRepository.getEntityManager().getItem("goblet");
      player.equipToInventoryOnly(item);
     
      en.step(player, hello);
      assertEquals("Hm, that goblet is not filled with vampire blood; it can't be, you have not killed the vampire lord. You must slay him.", getReply(npc));
      assertEquals(en.getCurrentState(), ConversationStates.IDLE);
    }
  }
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.