Examples of Engine


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

   * 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

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

   * 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

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

  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

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

   * 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

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

   * 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

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

   * 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

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

  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

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

    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

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

   * Tests for hiAndbye.
   */
  @Test
  public void testHiAndbye() {
    final SpeakerNPC npc = getNPC("Tad");
    final Engine en = npc.getEngine();
    en.step(player, ConversationPhrases.GREETING_MESSAGES.get(0));
    assertTrue(npc.isTalking());
    assertEquals(SSSHH_COME_HERE, getReply(npc));
    en.step(player, "task");
    assertTrue(npc.isTalking());
    assertEquals(
        "I'm not feeling well... I need to get a bottle of medicine made. Can you fetch me an empty #flask?",
        getReply(npc));
    en.step(player, "flask");
    assertTrue(npc.isTalking());
    assertEquals("You could probably get a flask from #Margaret.", getReply(npc));
    en.step(player, ConversationPhrases.GOODBYE_MESSAGES.get(0));
    assertFalse(npc.isTalking());
    assertEquals("Bye.", getReply(npc));
  }
View Full Code Here

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

   * Tests for hiNoAndHiAgain.
   */
  @Test
  public void testHiNoAndHiAgain() {
    final SpeakerNPC npc = getNPC("Tad");
    final Engine en = npc.getEngine();
    en.step(player, ConversationPhrases.GREETING_MESSAGES.get(0));
    assertTrue(npc.isTalking());

    en.step(player, "task");
    assertTrue(npc.isTalking());
    assertEquals(
        "I'm not feeling well... I need to get a bottle of medicine made. Can you fetch me an empty #flask?",
        getReply(npc));
    en.step(player, "No");
    assertTrue(npc.isTalking());
    assertEquals("Oh, please won't you change your mind? *sneeze*", getReply(npc));
    en.step(player, ConversationPhrases.GOODBYE_MESSAGES.get(0));
    assertFalse(npc.isTalking());
    assertFalse(player.hasQuest(QUEST_SLOT));
    assertEquals("Bye.", getReply(npc));
    en.step(player, ConversationPhrases.GREETING_MESSAGES.get(0));
    assertTrue(npc.isTalking());
    assertEquals(MedicineForTadTest.SSSHH_COME_HERE, getReply(npc));
    en.step(player, ConversationPhrases.GOODBYE_MESSAGES.get(0));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.