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

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


   * Tests for hiAndMakeNoStuff.
   */
  @Test
  public void testHiAndMakeNoStuff() {
    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, "make");
    assertTrue(npc.isTalking());
    assertEquals(
        "I can only bake a loaf of bread if you bring me 2 #'sacks of flour'.",
        getReply(npc));
    en.step(player, "bye");
    assertFalse(npc.isTalking());
    assertEquals("Bye.", getReply(npc));
  }
View Full Code Here


   * Tests for baking a single bread.
   */
  @Test
  public void testBakeSingleBread() {
    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));
    final StackableItem flour = new StackableItem("flour", "", "", null);
    flour.setQuantity(2);
    flour.setID(new ID(2, ZONE_NAME));
    player.getSlot("bag").add(flour);
    assertEquals(2, player.getNumberOfEquipped("flour"));

    en.step(player, "make");
    assertTrue(npc.isTalking());
    assertEquals(
        "I need you to fetch me 2 #'sacks of flour' for this job. Do you have it?",
        getReply(npc));
    en.step(player, "yes");
    final String[] questStatus = player.getQuest(QUEST1).split(";");
    final String[] expected = { "1", "bread", "" };
    assertEquals("amount", expected[0], questStatus[0]);
    assertEquals("item", expected[1], questStatus[1]);

    assertTrue(npc.isTalking());
    assertEquals(
        "OK, I will bake a loaf of bread for you, but that will take some time. Please come back in 10 minutes.",
        getReply(npc));
    assertEquals(0, player.getNumberOfEquipped("flour"));
    assertEquals(0, player.getNumberOfEquipped("bread"));
    en.step(player, "bye");
    assertFalse(npc.isTalking());
    player.setQuest(QUEST1, "1;;0");

    en.step(player, "hi");
    assertEquals(
        "Welcome back! I'm done with your order. Here you have the loaf of bread.",
        getReply(npc));
    assertEquals(1, player.getNumberOfEquipped("bread"));
  }
View Full Code Here

   * Tests for baking multiple breads.
   */
  @Test
  public void testBakeMultipleBreads() {
    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));
    final StackableItem flour = new StackableItem("flour", "", "", null);
    flour.setQuantity(4);
    flour.setID(new ID(2, ZONE_NAME));
    player.getSlot("bag").add(flour);
    assertEquals(4, player.getNumberOfEquipped("flour"));

    en.step(player, "make 2 breads");
    assertTrue(npc.isTalking());
    assertEquals(
        "I need you to fetch me 4 #'sacks of flour' for this job. Do you have it?",
        getReply(npc));
    en.step(player, "yes");
    final String[] questStatus = player.getQuest(QUEST1).split(";");
    final String[] expected = { "2", "bread", "" };
    assertEquals("amount", expected[0], questStatus[0]);
    assertEquals("item", expected[1], questStatus[1]);

    assertTrue(npc.isTalking());
    assertEquals(
        "OK, I will bake 2 loaves of bread for you, but that will take some time. Please come back in 20 minutes.",
        getReply(npc));
    assertEquals(0, player.getNumberOfEquipped("flour"));
    assertEquals(0, player.getNumberOfEquipped("bread"));
    en.step(player, "bye");
    assertFalse(npc.isTalking());
    player.setQuest(QUEST1, "2;;0");

    en.step(player, "hi");
    assertEquals(
        "Welcome back! I'm done with your order. Here you have 2 loaves of bread.",
        getReply(npc));
    assertEquals(2, player.getNumberOfEquipped("bread"));
  }
View Full Code Here

   * Tests for baking multiple breads without naming them.
   */
  @Test
  public void testBakeMultipleWithoutName() {
    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));
    final StackableItem flour = new StackableItem("flour", "", "", null);
    flour.setQuantity(6);
    flour.setID(new ID(2, ZONE_NAME));
    player.getSlot("bag").add(flour);
    assertEquals(6, player.getNumberOfEquipped("flour"));

    en.step(player, "make 3");
    assertTrue(npc.isTalking());
    assertEquals(
        "I need you to fetch me 6 #'sacks of flour' for this job. Do you have it?",
        getReply(npc));
    en.step(player, "yes");
    final String[] questStatus = player.getQuest(QUEST1).split(";");
    final String[] expected = { "3", "bread", "" };
    assertEquals("amount", expected[0], questStatus[0]);
    assertEquals("item", expected[1], questStatus[1]);

    assertTrue(npc.isTalking());
    assertEquals(
        "OK, I will bake 3 loaves of bread for you, but that will take some time. Please come back in 30 minutes.",
        getReply(npc));
    assertEquals(0, player.getNumberOfEquipped("flour"));
    assertEquals(0, player.getNumberOfEquipped("bread"));
    en.step(player, "bye");
    assertFalse(npc.isTalking());
    player.setQuest(QUEST1, "3;;0");

    en.step(player, "hi");
    assertEquals(
        "Welcome back! I'm done with your order. Here you have 3 loaves of bread.",
        getReply(npc));
    assertEquals(3, player.getNumberOfEquipped("bread"));
  }
View Full Code Here

   * Tests for borrowing the sugar mill.
   */
  @Test
  public void testBorrowSugarMill() {
    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, "borrow");
    assertTrue(npc.isTalking());
    assertEquals(
        "Oh sorry, I don't lend equipment to people with so little experience as you.",
        getReply(npc));

    // level up
    player.setLevel(10);
    en.step(player, "borrow");
    assertTrue(npc.isTalking());
    assertEquals(
        "You'll have to speak to Leander and ask if you can help with the pizza before I'm allowed to lend you anything.",
        getReply(npc));

    player.setQuest("pizza_delivery", "done");
    en.step(player, "borrow");
    assertTrue(npc.isTalking());
    assertEquals(
        "I lend out #'sugar mill' and #'pestle and mortar'. If you're interested, please say which you want.",
        getReply(npc));

    en.step(player, "sugar mill");
    assertTrue(npc.isTalking());
    assertEquals(
        "Here you are! Don't forget to #return it or you have to pay!",
        getReply(npc));
    final String[] questStatus = player.getQuest(QUEST2).split(";");
    assertEquals("sugar mill", questStatus[0]);

    en.step(player, "bye");
    assertFalse(npc.isTalking());
    player.setQuest(QUEST2, ";");

    assertEquals(1, player.getNumberOfEquipped("sugar mill"));

    en.step(player, "hi");
    assertEquals(
        "Welcome to the Semos bakery! We'll #bake fine bread for anyone who helps bring our #flour delivery from the mill.",
        getReply(npc));
  }
View Full Code Here

   * Tests for borrowing sugar.
   */
  @Test
  public void testBorrowSugar() {
    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, "borrow");
    assertTrue(npc.isTalking());
    assertEquals(
        "Oh sorry, I don't lend equipment to people with so little experience as you.",
        getReply(npc));

    // level up
    player.setLevel(10);
    en.step(player, "borrow");
    assertTrue(npc.isTalking());
    assertEquals(
        "You'll have to speak to Leander and ask if you can help with the pizza before I'm allowed to lend you anything.",
        getReply(npc));

    player.setQuest("pizza_delivery", "done");
    en.step(player, "borrow");
    assertTrue(npc.isTalking());
    assertEquals(
        "I lend out #'sugar mill' and #'pestle and mortar'. If you're interested, please say which you want.",
        getReply(npc));

    en.step(player, "sugar");
    assertTrue(npc.isTalking());
    assertEquals(
        "Sorry, I can't lend out sugar, only a #sugar #mill.",
        getReply(npc));

    en.step(player, "bye");
    assertFalse(npc.isTalking());
    player.setQuest(QUEST2, ";");

    assertEquals(0, player.getNumberOfEquipped("sugar mill"));

    en.step(player, "hi");
    assertEquals(
        "Welcome to the Semos bakery! We'll #bake fine bread for anyone who helps bring our #flour delivery from the mill.",
        getReply(npc));
  }
View Full Code Here

   * Tests for borrowing pestle and mortar.
   */
  @Test
  public void testBorrowPestleMortar() {
    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, "borrow");
    assertTrue(npc.isTalking());
    assertEquals(
        "Oh sorry, I don't lend equipment to people with so little experience as you.",
        getReply(npc));

    // level up
    player.setLevel(10);
    en.step(player, "borrow");
    assertTrue(npc.isTalking());
    assertEquals(
        "You'll have to speak to Leander and ask if you can help with the pizza before I'm allowed to lend you anything.",
        getReply(npc));

    player.setQuest("pizza_delivery", "done");
    en.step(player, "borrow");
    assertTrue(npc.isTalking());
    assertEquals(
        "I lend out #'sugar mill' and #'pestle and mortar'. If you're interested, please say which you want.",
        getReply(npc));

    en.step(player, "pestle and mortar");
    assertTrue(npc.isTalking());
    assertEquals(
        "Here you are! Don't forget to #return it or you have to pay!",
        getReply(npc));
    final String[] questStatus = player.getQuest(QUEST2).split(";");
    assertEquals("pestle and mortar", questStatus[0]);

    en.step(player, "bye");
    assertFalse(npc.isTalking());
    player.setQuest(QUEST2, ";");

    assertEquals(1, player.getNumberOfEquipped("pestle and mortar"));

    en.step(player, "hi");
    assertEquals(
        "Welcome to the Semos bakery! We'll #bake fine bread for anyone who helps bring our #flour delivery from the mill.",
        getReply(npc));
  }
View Full Code Here

   * Tests for borrowing pestle and mortar with additional space.
   */
  @Test
  public void testBorrowPestleAndMortarWithSpace() {
    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, "borrow");
    assertTrue(npc.isTalking());
    assertEquals(
        "Oh sorry, I don't lend equipment to people with so little experience as you.",
        getReply(npc));

    // level up
    player.setLevel(10);
    en.step(player, "borrow");
    assertTrue(npc.isTalking());
    assertEquals(
        "You'll have to speak to Leander and ask if you can help with the pizza before I'm allowed to lend you anything.",
        getReply(npc));

    player.setQuest("pizza_delivery", "done");
    en.step(player, "borrow");
    assertTrue(npc.isTalking());
    assertEquals(
        "I lend out #'sugar mill' and #'pestle and mortar'. If you're interested, please say which you want.",
        getReply(npc));

    en.step(player, "pestle and  mortar");
    assertTrue(npc.isTalking());
    assertEquals(
        "Here you are! Don't forget to #return it or you have to pay!",
        getReply(npc));
    final String[] questStatus = player.getQuest(QUEST2).split(";");
    assertEquals("pestle and mortar", questStatus[0]);

    en.step(player, "bye");
    assertFalse(npc.isTalking());
    player.setQuest(QUEST2, ";");

    assertEquals(1, player.getNumberOfEquipped("pestle and mortar"));

    en.step(player, "hi");
    assertEquals(
        "Welcome to the Semos bakery! We'll #bake fine bread for anyone who helps bring our #flour delivery from the mill.",
        getReply(npc));
  }
View Full Code Here

    final BarMaidNPC barmaidConfigurator = new BarMaidNPC();
    final StendhalRPZone zone = new StendhalRPZone("testzone");
    barmaidConfigurator.configureZone(zone, null);
    final SpeakerNPC barMaid = (SpeakerNPC) zone.getNPCList().get(0);
    assertThat(barMaid.getName(), is("Siandra"));
    final Engine engine = barMaid.getEngine();
    engine.setCurrentState(ConversationStates.IDLE);

    Sentence sentence = new SentenceImplementation(new Expression("hi", ExpressionType.VERB));
    engine.step(PlayerTestHelper.createPlayer("bob"), sentence);
    assertThat(engine.getCurrentState(), is(ConversationStates.ATTENDING));
    assertThat(getReply(barMaid), is("Hi!"));

    sentence = new SentenceImplementation(new Expression("bye", ExpressionType.VERB));
    engine.step(PlayerTestHelper.createPlayer("bob"), sentence);
    assertThat(engine.getCurrentState(), is(ConversationStates.IDLE));
    assertThat(getReply(barMaid), is("Bye bye!"));
  }
View Full Code Here

    final BarMaidNPC barmaidConfigurator = new BarMaidNPC();
    final StendhalRPZone zone = new StendhalRPZone("testzone");
    barmaidConfigurator.configureZone(zone, null);
    final SpeakerNPC barMaid = (SpeakerNPC) zone.getNPCList().get(0);
    assertThat(barMaid.getName(), is("Siandra"));
    final Engine engine = barMaid.getEngine();
    engine.setCurrentState(ConversationStates.ATTENDING);

    Sentence sentence = new SentenceImplementation(new Expression("job", ExpressionType.VERB));
    engine.step(PlayerTestHelper.createPlayer("bob"), sentence);
    assertThat(engine.getCurrentState(), is(ConversationStates.ATTENDING));
    assertThat("job text", getReply(barMaid),
        is("I'm a bar maid. But we've run out of food to feed our customers, can you #offer any?"));

    sentence = new SentenceImplementation(new Expression("help", ExpressionType.VERB));
    engine.step(PlayerTestHelper.createPlayer("bob"), sentence);
    assertThat(engine.getCurrentState(), is(ConversationStates.ATTENDING));
    assertThat("help text", getReply(barMaid),
        is("If you could #offer any meat, ham or cheese to restock our larders I'd be grateful."));

    sentence = new SentenceImplementation(new Expression("quest", ExpressionType.VERB));
    engine.step(PlayerTestHelper.createPlayer("bob"), sentence);
    assertThat(engine.getCurrentState(), is(ConversationStates.ATTENDING));
    assertThat("quest text", getReply(barMaid), is("Just #offers of food is enough, thank you."));
  }
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.