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

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


   * 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 buyCat.
   */
  @Test
  public void testBuyCat() {
    final SpeakerNPC npc = getNPC("Felina");
    final Engine en = npc.getEngine();

    assertTrue(en.step(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));

    assertTrue(en.step(player, "care"));
    assertEquals("Cats love chicken and fish. Just place a piece on the ground and your cat will run over to eat it. You can right-click on her and choose 'Look' at any time, to check up on her weight; she will gain one unit of weight for every piece of chicken she eats.", getReply(npc));

    // There is currently no quest response defined for Felina.
    assertFalse(en.step(player, "quest"));

    assertTrue(en.step(player, "buy"));
    assertEquals("A cat will cost 100. Do you want to buy it?", getReply(npc));
    assertTrue(en.step(player, "no"));
    assertEquals("Ok, how else may I help you?", getReply(npc));

    assertTrue(en.step(player, "buy dog"));
    assertEquals("Sorry, I don't sell dogs.", getReply(npc));

    assertTrue(en.step(player, "buy house"));
    assertEquals("Sorry, I don't sell houses.", getReply(npc));

    assertTrue(en.step(player, "buy someunknownthing"));
    assertEquals("Sorry, I don't sell someunknownthings.", getReply(npc));

    assertTrue(en.step(player, "buy a glass of wine"));
    assertEquals("Sorry, I don't sell glasses of wine.", getReply(npc));

    assertTrue(en.step(player, "buy a hand full of peace"));
    assertEquals("Sorry, I don't sell hand fulls of peace.", getReply(npc));

    assertTrue(en.step(player, "buy cat"));
    assertEquals("A cat will cost 100. Do you want to buy it?", getReply(npc));

    assertTrue(en.step(player, "no"));
    assertEquals("Ok, how else may I help you?", getReply(npc));

    assertTrue(en.step(player, "buy cat"));
    assertEquals("A cat will cost 100. Do you want to buy it?", getReply(npc));

    assertTrue(en.step(player, "yes"));
    assertEquals("You don't seem to have enough money.", getReply(npc));

    assertTrue(en.step(player, "buy two cats"));
    assertEquals("2 cats will cost 200. Do you want to buy them?", getReply(npc));

    assertTrue(en.step(player, "yes"));
    assertEquals("Hmm... I just don't think you're cut out for taking care of more than one cat at once.", getReply(npc));

    // equip with enough money to buy the cat
    assertTrue(equipWithMoney(player, 500));
    assertTrue(en.step(player, "buy cat"));
    assertEquals("A cat will cost 100. Do you want to buy it?", getReply(npc));

    assertFalse(player.hasPet());

    assertTrue(en.step(player, "yes"));
    assertEquals("Here you go, a cute little kitten! Your kitten will eat any piece of chicken or fish you place on the ground. Enjoy her!", getReply(npc));

    assertTrue(player.hasPet());

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

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

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

    assertTrue(en.step(player, "sell cat"));
    assertEquals("Sell??? What kind of a monster are you? Why would you ever sell your beautiful cat?", getReply(npc));
  }
View Full Code Here

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

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

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

  public void testBuySheep() {
    final StendhalRPWorld world = SingletonRepository.getRPWorld();
    registerPlayer(player, world.getZone(ZONE_NAME));

    final SpeakerNPC npc = getNPC("Nishiya");
    final Engine en = npc.getEngine();

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

    assertTrue(en.step(player, "job"));
    assertEquals("I work as a sheep seller.", getReply(npc));

    assertTrue(en.step(player, "offer"));
    assertEquals("I sell sheep.", getReply(npc));

    assertTrue(en.step(player, "buy"));
    assertEquals("A sheep will cost 30. Do you want to buy it?", getReply(npc));
    assertTrue(en.step(player, "no"));
    assertEquals("Ok, how else may I help you?", getReply(npc));

    assertTrue(en.step(player, "buy dog"));
    assertEquals("Sorry, I don't sell dogs.", getReply(npc));

    assertTrue(en.step(player, "buy house"));
    assertEquals("Sorry, I don't sell houses.", getReply(npc));

    assertTrue(en.step(player, "buy someunknownthing"));
    assertEquals("Sorry, I don't sell someunknownthings.", getReply(npc));

    assertTrue(en.step(player, "buy sheep"));
    assertEquals("A sheep will cost 30. Do you want to buy it?", getReply(npc));

    assertTrue(en.step(player, "no"));
    assertEquals("Ok, how else may I help you?", getReply(npc));

    assertTrue(en.step(player, "buy sheep"));
    assertEquals("A sheep will cost 30. Do you want to buy it?", getReply(npc));

    assertTrue(en.step(player, "yes"));
    assertEquals("You don't seem to have enough money.", getReply(npc));

    // equip with enough money to buy one sheep
    assertTrue(equipWithMoney(player, 30));

    assertTrue(en.step(player, "buy 2 sheep"));
    assertEquals("2 sheep will cost 60. Do you want to buy them?", getReply(npc));

    assertTrue(en.step(player, "yes"));
    assertEquals("Hmm... I just don't think you're cut out for taking care of a whole flock of sheep at once.", getReply(npc));

    assertTrue(en.step(player, "buy sheep"));
    assertEquals("A sheep will cost 30. Do you want to buy it?", getReply(npc));

    assertFalse(player.hasSheep());

    assertTrue(en.step(player, "yes"));
    assertEquals("Here you go, a nice fluffy little sheep! Take good care of it, now...", getReply(npc));

    assertTrue(player.hasSheep());
  }
View Full Code Here

   * Tests for sellSheep.
   */
  @Test
  public void testSellSheep() {
    final SpeakerNPC npc = getNPC("Nishiya");
    final Engine en = npc.getEngine();

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

    assertTrue(en.step(player, "sell"));
    assertEquals("Once you've gotten your sheep up to a weight of 100, you can take her to Sato in Semos; he will buy her from you.", getReply(npc));

    assertTrue(en.step(player, "sell sheep"));
    assertEquals("Once you've gotten your sheep up to a weight of 100, you can take her to Sato in Semos; he will buy her from you.", getReply(npc));
  }
View Full Code Here

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

    assertTrue(en.step(player, "hi Jenny"));
    assertEquals("Greetings! I am Jenny, the local miller. If you bring me some #grain, I can #mill it into flour for you.", getReply(npc));

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

   * Tests for quest.
   */
  @Test
  public void testQuest() {
    final SpeakerNPC npc = getNPC("Jenny");
    final Engine en = npc.getEngine();

    assertTrue(en.step(player, "hi"));
    assertEquals("Greetings! I am Jenny, the local miller. If you bring me some #grain, I can #mill it into flour for you.", getReply(npc));

    assertTrue(en.step(player, "job"));
    assertEquals("I run this windmill, where I can #mill people's #grain into flour for them. I also supply the bakery in Semos.", getReply(npc));

    assertTrue(en.step(player, "grain"));
    assertEquals("There's a farm nearby; they usually let people harvest there. You'll need a scythe, of course.", getReply(npc));

    assertTrue(en.step(player, "help"));
    assertEquals("Do you know the bakery in Semos? I'm proud to say they use my flour. But the wolves ate my delivery boy again recently... they're probably running out.", getReply(npc));

    assertTrue(en.step(player, "mill"));
    assertEquals("I can only mill a sack of flour if you bring me 5 #'sheaves of grain'.", getReply(npc));

    assertTrue(en.step(player, "mill flour"));
    assertEquals("I can only mill a sack of flour if you bring me 5 #'sheaves of grain'.", getReply(npc));

    assertTrue(en.step(player, "mill two sacks of flour"));
    assertEquals("I can only mill 2 sacks of flour if you bring me 10 #'sheaves of grain'.", getReply(npc));

    assertTrue(en.step(player, "mill grain"));
    assertEquals("Sorry, I don't produce sheaves of grain.", getReply(npc));

    assertTrue(equipWithStackableItem(player, "grain", 10));

    assertTrue(en.step(player, "mill two sacks of flour"));
    assertEquals("I need you to fetch me 10 #'sheaves of grain' for this job. Do you have it?", getReply(npc));

    assertTrue(en.step(player, "yes"));
    assertEquals("OK, I will mill 2 sacks of flour for you, but that will take some time. Please come back in 4 minutes.", getReply(npc));

    assertFalse(player.isEquipped("flour"));

    assertTrue(en.step(player, "bye"));
    assertEquals("Bye.", getReply(npc));

    // wait one minute
    setPastTime(player, QUEST_SLOT, 2, 1*60);

    assertTrue(en.step(player, "hi"));
    assertEquals("Welcome back! I'm still busy with your order to mill 2 sacks of flour for you. Come back in 3 minutes to get it.", getReply(npc));

    assertFalse(player.isEquipped("flour"));

    assertTrue(en.step(player, "bye"));
    assertEquals("Bye.", getReply(npc));

    // wait four minutes
    setPastTime(player, QUEST_SLOT, 2, 4*60);

    assertTrue(en.step(player, "hi"));
    assertEquals("Welcome back! I'm done with your order. Here you have 2 sacks of flour.", getReply(npc));

    assertTrue(player.isEquipped("flour", 2));

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

  public final void rejectQuest() {
    SingletonRepository.getNPCList().add(new SpeakerNPC("Balduin"));
    final WeaponsCollector2 wc = new WeaponsCollector2();
    wc.addToWorld();
    final SpeakerNPC npc = wc.getNPC();
    final Engine en = npc.getEngine();
    final Player pl = PlayerTestHelper.createPlayer("player");

    // set previous quest to done
    pl.setQuest("weapons_collector", "done");

    assertTrue(en.stepTest(pl, ConversationPhrases.GREETING_MESSAGES.get(0)));
    assertEquals(
        "Greetings, old friend. If you are willing, I have another #quest for you.",
        getReply(npc));

    assertTrue(en.stepTest(pl, ConversationPhrases.QUEST_MESSAGES.get(0)));
    assertEquals(
        "Recent adventurers to these parts describe strange new creatures with weapons"
            + " I have never seen. Would you fight these creatures and bring their weapons to me?",
        getReply(npc));
    en.stepTest(pl, "no");
    assertEquals("Well, maybe someone else will happen by and help me.",
        getReply(npc));
  }
View Full Code Here

    SingletonRepository.getNPCList().add(new SpeakerNPC("Balduin"));
    final WeaponsCollector2 wc = new WeaponsCollector2();
 
    wc.addToWorld();
    final SpeakerNPC npc = wc.getNPC();
    final Engine en = npc.getEngine();
    final Player pl = PlayerTestHelper.createPlayer("player");

    // set previous quest to done
    pl.setQuest("weapons_collector", "done");

    assertTrue(en.stepTest(pl, "hello"));
    assertEquals(
        "Greetings, old friend. If you are willing, I have another #quest for you.",
        getReply(npc));

    assertTrue(en.stepTest(pl, "quest"));
    assertEquals(
        "Recent adventurers to these parts describe strange new creatures with weapons"
            + " I have never seen. Would you fight these creatures and bring their weapons to me?",
        getReply(npc));

    assertTrue(en.stepTest(pl, ConversationPhrases.YES_MESSAGES.get(0)));
    assertEquals(
        "Wonderful. Now, the #list is small but the risk may be great. If you return safely, I have another reward for you.",
        getReply(npc));

    assertTrue(en.stepTest(pl, "list"));
    assertEquals(
        "There are 3 weapons still missing from my newest collection: #'morning star', #staff, and #'great sword'."
            + " Do you have anything like that with you?",
        getReply(npc));

    assertTrue(en.stepTest(pl, "no"));
    assertEquals("Let me know as soon as you find them. Farewell.",
        getReply(npc));

    // start another conversation
    assertTrue(en.stepTest(pl, "hi"));
    assertEquals(
        "Welcome back. I hope you have come to help me with my latest #list of weapons.",
        getReply(npc));

    assertTrue(en.stepTest(pl, "list"));
    assertEquals(
        "There are 3 weapons still missing from my newest collection: #'morning star', #staff, and #'great sword'."
            + " Do you have anything like that with you?",
        getReply(npc));

    assertTrue(en.stepTest(pl, "yes"));
    assertEquals("What did you find?", getReply(npc));

    Item weapon = new Item("morning star", "", "", null);
    pl.getSlot("bag").add(weapon);

    assertTrue(en.stepTest(pl, "morning star"));
    assertEquals("Thank you very much! Do you have anything more for me?",
        getReply(npc));

    assertTrue(en.stepTest(pl, "morning star"));
    assertEquals(
        "I already have that one. Do you have any other weapon for me?",
        getReply(npc));

    for (final String cloakName : wc.getNeededItems()) {
      weapon = new Item(cloakName, "", "", null);
      pl.getSlot("bag").add(weapon);
      en.step(pl, cloakName);
    }

    assertEquals(
        "At last, my collection is complete! Thank you very much; here, take this pair of swords in exchange!",
        getReply(npc));
    en.step(pl, ConversationPhrases.GOODBYE_MESSAGES.get(0));

    assertTrue(wc.isCompleted(pl));
  }
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.