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

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


   
  @Test
  public void rejectQuest() {
    final Player player = PlayerTestHelper.createPlayer("me");     
    final SpeakerNPC npc = vs.npcs.get(DWARF_NPC);
    final Engine en = vs.npcs.get(DWARF_NPC).getEngine();
    final double karma = player.getKarma();
   
    assertFalse(player.hasQuest(questSlot));
    en.setCurrentState(ConversationStates.QUEST_OFFERED);
     
    en.step(player, "no");
    assertEquals("Refusing", "Oh, well forget it then. You must have a better sword than I can forge, huh? Bye.", getReply(npc));
    assertEquals("karma penalty", karma - 5.0, player.getKarma(), 0.01);
    assertFalse(player.isEquipped("empty goblet"));
    assertEquals(en.getCurrentState(), ConversationStates.IDLE);
  }
View Full Code Here


  @Test
  public void acceptQuest() {
    for (String answer : ConversationPhrases.YES_MESSAGES) {
      final Player player = PlayerTestHelper.createPlayer("me");     
      final SpeakerNPC npc = vs.npcs.get(DWARF_NPC);
      final Engine en = vs.npcs.get(DWARF_NPC).getEngine();
      final double karma = player.getKarma();
     
      assertFalse(player.hasQuest(questSlot));
      en.setCurrentState(ConversationStates.QUEST_OFFERED);
     
      en.step(player, answer);
      assertEquals("Then you need this #goblet. Take it to the Semos #Catacombs.", getReply(npc));
      assertEquals("karma bonus", karma + 5.0, player.getKarma(), 0.01);
      assertTrue("Player is given a goblet", player.isEquipped("empty goblet"));
      assertEquals(en.getCurrentState(), ConversationStates.ATTENDING);
    }
  }
View Full Code Here

   */
  @Test
  public void testDwarfsExplanations() {
    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.ATTENDING);
    en.step(player, "catacombs");
    assertEquals("answer to 'catacombs'", "The Catacombs of north Semos of the ancient #stories.", getReply(npc));
    assertEquals(en.getCurrentState(), ConversationStates.ATTENDING);
   
    en.step(player, "goblet");
    assertEquals("answer to 'goblet'", "Go fill it with the blood of the enemies you meet in the #Catacombs.", getReply(npc));
  }
View Full Code Here

  @Test
  public void greetDwarfWithGoblet() {
    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();
     
      assertFalse(player.hasQuest(questSlot));
      en.setCurrentState(ConversationStates.IDLE);
      player.setQuest(questSlot, "start");
     
      final Item goblet = SingletonRepository.getEntityManager().getItem("empty goblet");
      player.equipToInventoryOnly(goblet);
     
      en.step(player, hello);
      assertEquals(hello, "Did you lose your way? The Catacombs are in North Semos. Don't come back without a full goblet! Bye!", getReply(npc));
      assertEquals(en.getCurrentState(), ConversationStates.IDLE);
    }
  }
View Full Code Here

  @Test
  public void greetDwarfWithLostGoblet() {
    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();
     
      assertFalse(player.hasQuest(questSlot));
      assertFalse(player.isEquipped("empty goblet"));
      assertFalse(player.isEquipped("goblet"));
      en.setCurrentState(ConversationStates.IDLE);
      player.setQuest(questSlot, "start");
     
      en.step(player, hello);
      assertEquals(hello, "I hope you didn't lose your goblet! Do you need another?", getReply(npc));
      assertEquals(en.getCurrentState(), ConversationStates.QUESTION_1);
    }
  }
View Full Code Here

  @Test
  public void getAnotherGoblet() {
    for (String answer : ConversationPhrases.YES_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));
      assertFalse(player.isEquipped("empty goblet"));
      assertFalse(player.isEquipped("goblet"));
      en.setCurrentState(ConversationStates.QUESTION_1);
      player.setQuest(questSlot, "start");
     
      en.step(player, answer);
      assertEquals(answer, "You stupid ..... Be more careful next time. Bye!", getReply(npc));
      assertEquals(en.getCurrentState(), ConversationStates.IDLE);
      assertTrue("Player is given a goblet", player.isEquipped("empty goblet"));
    }
  }
View Full Code Here

 
  @Test
  public void refuseAnotherGoblet() {
    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));
    assertFalse(player.isEquipped("empty goblet"));
    assertFalse(player.isEquipped("goblet"));
    en.setCurrentState(ConversationStates.QUESTION_1);
    player.setQuest(questSlot, "start");
     
    en.step(player, "no");
    assertEquals("Then why are you back here? Go slay some vampires! Bye!", getReply(npc));
    assertEquals(en.getCurrentState(), ConversationStates.IDLE);
    assertFalse("Player is not given a goblet", player.isEquipped("empty goblet"));
  }
View Full Code Here

  @Test
  public void sayHelloToVampire() {
    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.step(player, hello);
      assertEquals("vampires greeting", "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));
      assertEquals(en.getCurrentState(), ConversationStates.ATTENDING);
      en.setCurrentState(ConversationStates.IDLE);
    }
  }
View Full Code Here

  @Test
  public void sayByeToVampire() {
    for (String bye : ConversationPhrases.GOODBYE_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.ATTENDING);
      en.step(player, bye);
      assertEquals("vampires bye message", "*cough* ... farewell ... *cough*", getReply(npc));
      assertEquals(en.getCurrentState(), ConversationStates.IDLE);
    }
  }
View Full Code Here

  @Test
  public void testBloodMaterialDescription() {
    for (String material : Arrays.asList("blood", "vampirette entrails", "bat entrails")) {
      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, material);
      assertEquals("answer to '" + material + "'", "I need blood. I can take it from the entrails of the alive and undead. I will mix the bloods together for you and #fill your #goblet, if you let me drink some too. But I'm afraid of the powerful #lord.", 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.