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

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


  @Test
  public void greetDwarfWithFullGobletWithKill() {
    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);
      player.setSharedKill("vampire lord");
     
      en.step(player, hello);
      assertEquals("You have battled hard to bring that goblet. I will use it to #forge the vampire sword", getReply(npc));
      assertEquals(en.getCurrentState(), ConversationStates.QUEST_ITEM_BROUGHT);
    }
  }
View Full Code Here


  }
  @Test
  public void askAboutForging() {
    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.QUEST_ITEM_BROUGHT);
    player.setQuest(questSlot, "start");
   
    en.step(player, "forge");
    assertEquals("Bring me 10 #iron bars to forge the sword with. Don't forget to bring the goblet too.", getReply(npc));
    assertEquals(en.getCurrentState(), ConversationStates.QUEST_ITEM_BROUGHT);
  }
View Full Code Here

 
  @Test
  public void askAboutIron() {
    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.QUEST_ITEM_BROUGHT);
    player.setQuest(questSlot, "start");
   
    en.step(player, "iron");
    assertEquals("You know, collect the iron ore lying around and get it cast! Bye!", getReply(npc));
    assertEquals(en.getCurrentState(), ConversationStates.IDLE);
  }
View Full Code Here

  @Test
  public void greetDwarfWithRequiredItems() {
    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);
     
      PlayerTestHelper.equipWithStackableItem(player, "iron", 10);
     
      player.setSharedKill("vampire lord");
     
      en.step(player, hello);
      assertEquals("You've brought everything I need to make the vampire sword. Come back in 10 minutes and it will be ready", getReply(npc));
      assertFalse("dwarf took the goblet", player.isEquipped("goblet"));
      assertFalse("dwarf took the iron", player.isEquipped("iron"));
      assertTrue("in forging state", player.getQuest(questSlot).startsWith("forging;"));
      assertEquals(en.getCurrentState(), ConversationStates.IDLE);
    }
  }
View Full Code Here

  public void tryGettingSwordTooEarly() {
    String questState = "forging;" + Long.toString(new Date().getTime());
    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, questState);
     
      en.step(player, hello);
      assertEquals("too early '" + hello + "'", "I haven't finished forging the sword. Please check back in 10 minutes.", getReply(npc));
      assertEquals(en.getCurrentState(), ConversationStates.IDLE);
     
      // should not make any change in quest state, or give the sword
      assertEquals(questState, player.getQuest(questSlot));
      assertFalse(player.isEquipped("vampire sword"));
    }
View Full Code Here

  public void gettingTheSword() {
    String questState = "forging;" + Long.toString(new Date().getTime() - 10 * 60 * 1000);
    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();
      int xp = player.getXP();
      double karma = player.getKarma();
     
      en.setCurrentState(ConversationStates.IDLE);
      player.setQuest(questSlot, questState);
     
      en.step(player, hello);
      assertEquals("I have finished forging the mighty Vampire Sword. You deserve this. Now i'm going back to work, goodbye!", getReply(npc));
      assertEquals(en.getCurrentState(), ConversationStates.IDLE);
     
      assertEquals("done", player.getQuest(questSlot));
      assertTrue("got the sword", player.isEquipped("vampire sword"));
     
      final Item sword = player.getFirstEquipped("vampire sword");
View Full Code Here

  public void testHiAndBye() {
    final Player player = createPlayer("player");

    SpeakerNPC npc = SingletonRepository.getNPCList().get("Katinka");
    assertNotNull(npc);
    final Engine en1 = npc.getEngine();
    assertTrue("test text recognition with additional text after 'hi'",
        en1.step(player, "hi Katinka"));
    assertTrue(npc.isTalking());
    assertEquals(
        "Welcome to the Ados Wildlife Refuge! We rescue animals from being slaughtered by evil adventurers. But we need help... maybe you could do a #task for us?",
        getReply(npc));
    assertTrue("test text recognition with additional text after 'bye'",
        en1.step(player, "bye bye"));
    assertFalse(npc.isTalking());
    assertEquals("Goodbye!", getReply(npc));

    npc = SingletonRepository.getNPCList().get("Dr. Feelgood");
    assertNotNull(npc);
    final Engine en = npc.getEngine();
    assertTrue(en.step(player, "hi"));
    assertFalse(npc.isTalking());
    assertEquals(
        "Sorry, can't stop to chat. The animals are all sick because they don't have enough food. See yourself out, won't you?",
        getReply(npc));
    assertFalse(en.step(player, "bye"));
    assertFalse(npc.isTalking());
    assertEquals(null, getReply(npc));
  }
View Full Code Here

  public void testDoQuest() {
    final Player player = createPlayer("player");

    final SpeakerNPC katinkaNpc = SingletonRepository.getNPCList().get("Katinka");
    assertNotNull(katinkaNpc);
    final Engine enKatinka = katinkaNpc.getEngine();
    final SpeakerNPC feelgoodNpc = SingletonRepository.getNPCList().get("Dr. Feelgood");
    assertNotNull(feelgoodNpc);
    final Engine enFeelgood = feelgoodNpc.getEngine();
    assertTrue("test saying 'Hallo' instead of 'hi'", enKatinka.step(
        player, "Hallo"));
    assertEquals(
        "Welcome to the Ados Wildlife Refuge! We rescue animals from being slaughtered by evil adventurers. But we need help... maybe you could do a #task for us?",
        getReply(katinkaNpc));

    assertTrue(enKatinka.step(player, "task"));
    assertEquals(
        "Our animals are hungry. We need more food to feed them. Can you help us?",
        getReply(katinkaNpc));

    assertTrue(enKatinka.step(player, "yes"));
    assertTrue(player.hasQuest("zoo_food"));
    assertTrue(getReply(katinkaNpc).startsWith("Oh, thank you! Please help us by bringing"));

    assertTrue(enKatinka.step(player, "bye"));
    assertEquals("Goodbye!", getReply(katinkaNpc));
    assertTrue(player.hasQuest("zoo_food"));
    assertTrue(player.getQuest("zoo_food").startsWith("start;"));
    // feelgood is still in sorrow
    assertTrue(enFeelgood.step(player, "hi"));
    assertFalse(feelgoodNpc.isTalking());
    assertEquals(
        "Sorry, can't stop to chat. The animals are all sick because they don't have enough food. See yourself out, won't you?",
        getReply(feelgoodNpc));
    assertFalse(enFeelgood.step(player, "bye"));
    assertFalse(feelgoodNpc.isTalking());
    assertEquals(null, getReply(feelgoodNpc));
   
    // test compatibility with old
    player.setQuest("zoo_food","start");
    // bother katinka again
    assertTrue(enKatinka.step(player, "hi"));
    assertEquals("Welcome back! Have you brought the 10 pieces of ham?",
        getReply(katinkaNpc));
    assertTrue("lie", enKatinka.step(player, "yes"));
    assertEquals(
        "*sigh* I SPECIFICALLY said that we need 10 pieces of ham!",
        getReply(katinkaNpc));
    assertTrue(enKatinka.step(player, "bye"));
    assertEquals("Goodbye!", getReply(katinkaNpc));
    // equip player with to less needed stuff
    final StackableItem ham = new StackableItem("ham", "", "", null);
    ham.setQuantity(5);
    ham.setID(new ID(2, ZONE_NAME));
    player.getSlot("bag").add(ham);
    assertEquals(5, player.getNumberOfEquipped("ham"));

    // bother katinka again
    assertTrue(enKatinka.step(player, "hi"));
    assertEquals("Welcome back! Have you brought the 10 pieces of ham?",
        getReply(katinkaNpc));
    assertTrue("lie", enKatinka.step(player, "yes"));
    assertEquals(
        "*sigh* I SPECIFICALLY said that we need 10 pieces of ham!",
        getReply(katinkaNpc));
    assertTrue(enKatinka.step(player, "bye"));
    assertEquals("Goodbye!", getReply(katinkaNpc));
    // equip player with to needed stuff
    final StackableItem ham2 = new StackableItem("ham", "", "", null);
    ham2.setQuantity(5);
    ham2.setID(new ID(3, ZONE_NAME));
    player.getSlot("bag").add(ham2);
    assertEquals(10, player.getNumberOfEquipped("ham"));
    // bring stuff to katinka
    assertTrue(enKatinka.step(player, "hi"));
    assertEquals("Welcome back! Have you brought the 10 pieces of ham?",
        getReply(katinkaNpc));
    assertTrue(enKatinka.step(player, "yes"));
    assertEquals("Thank you! You have rescued our rare animals.",
        getReply(katinkaNpc));
    assertTrue(enKatinka.step(player, "bye"));
    assertEquals("Goodbye!", getReply(katinkaNpc));
   
    assertTrue(player.getQuest("zoo_food").startsWith("done;"));
   
    // feelgood is reacting
    assertTrue(enFeelgood.step(player, "hi"));
    assertTrue(feelgoodNpc.isTalking());
    assertEquals(
        "Hello! Now that the animals have enough food, they don't get sick that easily, and I have time for other things. How can I help you?",
        getReply(feelgoodNpc));
    assertTrue(enFeelgood.step(player, "offers"));

    assertEquals(
        "I sell antidote, minor potion, potion, and greater potion.",
        getReply(feelgoodNpc));
    assertTrue(enFeelgood.step(player, "bye"));
    assertEquals("Bye!", getReply(feelgoodNpc));
  }
View Full Code Here

   * Tests for hiAndBye.
   */
  @Test
  public void testHiAndBye() {
    final SpeakerNPC npc = getNPC("Felina");
    final Engine en = npc.getEngine();

    assertTrue(en.step(player, "hi Felina"));
    assertEquals("Greetings! How may I help you?", getReply(npc));

    assertTrue(en.step(player, "bye"));
    assertEquals("Bye.", getReply(npc));
  }
View Full Code Here

   * Tests for logic.
   */
  @Test
  public void testLogic() {
    final SpeakerNPC npc = getNPC("Felina");
    final Engine en = npc.getEngine();

    npc.listenTo(player, "hi");
    assertEquals("Greetings! How may I help you?", getReply(npc));

    assertTrue(en.step(player, "job"));
    assertEquals("I sell cats. Well, really they are just little kittens when I sell them to you but if you #care for them well they grow into cats.", getReply(npc));

    assertNotNull(npc.getAttending());
    npc.preLogic();
    assertEquals("Bye.", getReply(npc));
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.