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("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


   * 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

   * Tests for quest.
   */
  @Test
  public void testQuest() {
    final SpeakerNPC tad = getNPC("Tad");
    final Engine engineTad = tad.getEngine();
    engineTad.step(player, ConversationPhrases.GREETING_MESSAGES.get(0));
    assertTrue(tad.isTalking());
    assertEquals(SSSHH_COME_HERE, getReply(tad));
    engineTad.step(player, "task");
    assertTrue(tad.isTalking());
    assertEquals(
        "I'm not feeling well... I need to get a bottle of medicine made. Can you fetch me an empty #flask?",
        getReply(tad));
    engineTad.step(player, "yes");
    assertTrue(player.hasQuest(QUEST_SLOT));
    engineTad.step(player, ConversationPhrases.GOODBYE_MESSAGES.get(0));
    assertFalse(tad.isTalking());
    assertEquals("Bye.", getReply(tad));

    final StackableItem flask = new StackableItem("flask", "", "", null);
    flask.setQuantity(1);
    flask.setID(new ID(2, ZONE_NAME));
    player.getSlot("bag").add(flask);
    assertTrue(player.isEquipped("flask"));
    engineTad.step(player, ConversationPhrases.GREETING_MESSAGES.get(0));
    assertTrue(tad.isTalking());
    assertEquals(
        "Ok, you got the flask! Here take this money to cover your expense. Now, I need you to take it to #ilisa... she'll know what to do next.",
        getReply(tad));
    assertTrue(player.hasQuest(QUEST_SLOT));
    assertEquals("ilisa", player.getQuest(QUEST_SLOT));
    engineTad.step(player, ConversationPhrases.GOODBYE_MESSAGES.get(0));

    final SpeakerNPC ilisa = getNPC("Ilisa");
    final Engine engineIlisa = ilisa.getEngine();
    engineIlisa.step(player, ConversationPhrases.GREETING_MESSAGES.get(0));
    assertEquals(
        "Ah, I see you have that flask. #Tad needs medicine, right? Hmm... I'll need a #herb. Can you help?",
        getReply(ilisa));
    engineIlisa.step(player, "yes");
    assertEquals("North of Semos, near the tree grove, grows a herb called arandula. Here is a picture I drew so you know what to look for.",getReply(ilisa));
    assertEquals("corpse&herbs", player.getQuest(QUEST_SLOT));
    engineIlisa.step(player, "tad");
    assertEquals("He needs a very powerful potion to heal himself. He offers a good reward to anyone who will help him.", getReply(ilisa));
    engineIlisa.step(player, ConversationPhrases.GOODBYE_MESSAGES.get(0));
    assertEquals("Bye.", getReply(ilisa));

    engineTad.step(player, ConversationPhrases.GREETING_MESSAGES.get(0));
    assertTrue(tad.isTalking());

    assertEquals("Tad has already asked and the quest was accepted",
        "*sniff* *sniff* I still feel ill, please hurry with that #favour for me.", getReply(tad));
    engineTad.step(player, ConversationPhrases.GOODBYE_MESSAGES.get(0));
    assertFalse(tad.isTalking());
    assertEquals("Bye.", getReply(tad));

    engineIlisa.step(player, ConversationPhrases.GREETING_MESSAGES.get(0));
    assertEquals("Can you fetch those #herbs for the #medicine?", getReply(ilisa));
    engineIlisa.step(player, ConversationPhrases.GOODBYE_MESSAGES.get(0));
    assertEquals("Bye.", getReply(ilisa));
   
    // doesn't work as it causes an npe and adding it to setUp() doesn't help
    //PlayerTestHelper.equipWithItem(player, "arandula");
    final StackableItem arandula = new StackableItem("arandula", "", "", null);
    arandula.setQuantity(1);
    arandula.setID(new ID(2, ZONE_NAME));
    player.getSlot("bag").add(arandula);
    engineIlisa.step(player, ConversationPhrases.GREETING_MESSAGES.get(0));
    assertEquals(
        "Okay! Thank you. Now I will just mix these... a pinch of this... and a few drops... there! Can you ask #Tad to stop by and collect it? I want to see how he's doing.",
        getReply(ilisa));
    engineIlisa.step(player, ConversationPhrases.GOODBYE_MESSAGES.get(0));
    assertEquals("Bye.", getReply(ilisa));
   
    assertEquals("potion", player.getQuest(QUEST_SLOT));
   
    engineTad.step(player, ConversationPhrases.GREETING_MESSAGES.get(0));
View Full Code Here

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

    assertTrue(en.step(player, "hi Fleur"));
    assertEquals("Hi! Are you here to #trade?", getReply(npc));

    assertTrue(en.step(player, "bye"));
    assertEquals("Come back soon!", getReply(npc));
  }
View Full Code Here

   * Tests buying pansy seed from Jenny.
   */
  @Test
  public void testSellingPansySeed() {
    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));

    equipWithMoney(player, 30);
    assertTrue(en.step(player, "buy 3 pansy seed"));
    assertEquals("3 pansy seeds will cost 30. Do you want to buy them?", getReply(npc));

    assertTrue(en.step(player, "yes"));
    assertEquals("Congratulations! Here are your pansy seeds!", getReply(npc));
    assertTrue(player.isEquipped("seed", 3));
  }
View Full Code Here

   * Tests for buyFlower.
   */
  @Test
  public void testBuyFlower() {
    final SpeakerNPC npc = getNPC("Fleur");
    final Engine en = npc.getEngine();

    assertTrue(en.step(player, "hi"));
    assertEquals("Hi! Are you here to #trade?", getReply(npc));

    assertTrue(en.step(player, "job"));
    assertEquals("I sell roses in this here market.", getReply(npc));

    assertTrue(en.step(player, "trade"));
    assertEquals("I sell rose.", getReply(npc));

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

    assertTrue(en.step(player, "buy"));
    assertEquals("A rose will cost 50. 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 candle"));
    assertEquals("Sorry, I don't sell candles.", 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 rose"));
    assertEquals("A rose will cost 50. 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 rose"));
    assertEquals("A rose will cost 50. Do you want to buy it?", getReply(npc));

    assertTrue(en.step(player, "yes"));
    assertEquals("Sorry, you don't have enough money!", getReply(npc));

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

    assertTrue(en.step(player, "yes"));
    assertEquals("Sorry, you don't have enough money!", getReply(npc));

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

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

    assertTrue(en.step(player, "yes"));
    assertEquals("Congratulations! Here is your rose!", getReply(npc));

    assertTrue(player.isEquipped("rose"));

    // equip with enough money to buy five roses
    assertTrue(equipWithMoney(player, 250));
    assertTrue(en.step(player, "buy 5 roses"));
    assertEquals("5 roses will cost 250. Do you want to buy them?", getReply(npc));

    assertTrue(en.step(player, "yes"));
    assertEquals("Congratulations! Here are your roses!", getReply(npc));

    assertTrue(player.isEquipped("rose", 6));
    assertFalse(player.isEquipped("rose", 7));
  }
View Full Code Here

   * Tests buying daisies seed from Jenny.
   */
  @Test
  public void testSellingDaisiesSeed() {
    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));

    equipWithMoney(player, 20);
    assertTrue(en.step(player, "buy daisies seed"));
    assertEquals("A daisies seed will cost 20. Do you want to buy it?", getReply(npc));

    assertTrue(en.step(player, "yes"));
    assertEquals("Congratulations! Here is your daisies seed!", getReply(npc));
    assertTrue(player.isEquipped("seed"));
    Item seed = player.getFirstEquipped("seed");
    assertEquals("daisies", seed.getInfoString());

    equipWithMoney(player, 100);
    assertTrue(en.step(player, "buy five daisies seeds"));
    assertEquals("5 daisies seeds will cost 100. Do you want to buy them?", getReply(npc));

    assertTrue(en.step(player, "yes"));
    assertEquals("Congratulations! Here are your daisies seeds!", getReply(npc));
  }
View Full Code Here

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

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

    assertTrue(en.step(player, "bye"));
    assertEquals("Farewell and godspeed!", getReply(npc));
  }
View Full Code Here

   */
  @Test
  public void testHiAndBye() {
   
    final SpeakerNPC npc = getNPC("Erna");
    final Engine en = npc.getEngine();
   
    en.step(player, "hi");
    assertTrue(npc.isTalking());
    assertEquals(
        "Welcome to the Semos bakery! We'll #bake fine bread for anyone who helps bring our #flour delivery from the mill.",
        getReply(npc));
    en.step(player, "bye");
    assertFalse(npc.isTalking());
    assertEquals("Bye.", getReply(npc));
  }
View Full Code Here

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

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

    assertTrue(en.step(player, "job"));
    assertEquals("My job? I'm a well known warrior, strange that you haven't heard of me!", getReply(npc));

    assertTrue(en.step(player, "quest"));
    assertEquals("Thanks, but I don't need any help at the moment.", getReply(npc));

    assertTrue(en.step(player, "help"));
    assertEquals("If you want, I can tell you about the #creatures I have encountered.", getReply(npc));

    assertTrue(en.step(player, "offer"));
    assertEquals("I offer you information on #creatures I've seen for a reasonable fee.", getReply(npc));

    assertTrue(en.step(player, "creatures"));
    assertEquals("Which creature you would like to hear more about?", getReply(npc));

    //do a false monster test
    assertTrue(en.step(player, "C-Monster"));
    assertEquals("I have never heard of such a creature! Please tell the name again.", getReply(npc));

    //test with not having enough cash
    assertTrue(en.step(player, "angel"));
    assertEquals("This information costs 490. Are you still interested?", getReply(npc));

    assertFalse(player.isEquipped("money", 490));
    assertTrue(en.step(player, "yes"));
    assertEquals("You don't have enough money with you.", getReply(npc));

    //test with having the cash
    assertTrue(equipWithMoney(player, 490));
    assertTrue(player.isEquipped("money", 490));

    assertTrue(en.step(player, "creatures"));
    assertEquals("Which creature you would like to hear more about?", getReply(npc));

    assertTrue(en.step(player, "angel"));
    assertEquals("This information costs 490. Are you still interested?", getReply(npc));

    //lazy assertion since the phrases differ each time.  assume that the npc repeats the creature
    assertTrue(en.step(player, "yes"));
    assertTrue(getReply(npc).toLowerCase().contains("angel"));

    //say goodbye
    assertTrue(en.step(player, "bye"));
    assertEquals("Farewell and godspeed!", 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.