Package games.stendhal.server.entity.item

Examples of games.stendhal.server.entity.item.Item


    assertEquals("I'd like to comment on your #weapon, if I may.", getReply(npc));
   
    assertTrue(en.step(player, "weapon"));
    assertEquals("Oh, I can't comment on your weapon, as you have none equipped. That's not very wise in these dangerous times!", getReply(npc));
   
    final Item weapon = new Item("club", "club", "subclass", null);
    weapon.setEquipableSlots(Arrays.asList("lhand"));
    weapon.put("atk", 6);
    weapon.put("rate", 4);
    player.equipToInventoryOnly(weapon);

    assertTrue(player.isEquipped("club"));
   
    assertTrue(en.step(player, "weapon"));
    assertEquals("Well, your club has quite low damage capability, doesn't it? You should look for something with a better attack to rate ratio.", getReply(npc));
   
    player.drop(weapon);
   
    final Item weapon2 = new Item("ice sword", "sword", "subclass", null);
    weapon2.setEquipableSlots(Arrays.asList("lhand"));
    weapon2.put("atk", 29);
    weapon2.put("rate", 5);
    player.equipToInventoryOnly(weapon2);
    assertTrue(player.isEquipped("ice sword"));
   
    assertTrue(en.step(player, "weapon"));
    assertEquals("That ice sword is a powerful weapon, it has a good damage to rate ratio.", getReply(npc));
    player.drop(weapon2);
   
    final Item weapon3 = new Item("vampire sword", "sword", "subclass", null);
    weapon3.setEquipableSlots(Arrays.asList("lhand"));
    weapon3.put("atk", 22);
    weapon3.put("rate", 5);
    weapon3.put("lifesteal", 0.1);
    player.equipToInventoryOnly(weapon3);
    assertTrue(player.isEquipped("vampire sword"));
   
    assertTrue(en.step(player, "weapon"));
    assertEquals("Well, your vampire sword has quite low damage capability, doesn't it? You should look for something with a better attack to rate ratio. The positive lifesteal of 0.1 will increase your health as you use it.", getReply(npc));
    player.drop(weapon3);
   
    final Item weapon4 = new Item("club of thorns", "club", "subclass", null);
    weapon4.setEquipableSlots(Arrays.asList("lhand"));
    weapon4.put("atk", 48);
    weapon4.put("rate", 7);
    weapon4.put("lifesteal", -0.1);
    player.equipToInventoryOnly(weapon4);
    assertTrue(player.isEquipped("club of thorns"));
   
    assertTrue(en.step(player, "weapon"));
    assertEquals("That club of thorns is a powerful weapon, it has a good damage to rate ratio. It should be useful against strong creatures. Remember though that something weaker but faster may suffice against lower level creatures. The negative lifesteal of -0.1 will drain your health as you use it.", getReply(npc));
    player.drop(weapon4);
   
    final Item weapon5 = new Item("l hand sword", "sword", "subclass", null);
    weapon5.setEquipableSlots(Arrays.asList("lhand"));
    player.equipToInventoryOnly(weapon5);
    assertTrue(player.isEquipped("l hand sword"));
   
    assertTrue(en.step(player, "weapon"));
    assertEquals("I see you use twin swords. They have a superb damage capability but as you cannot wear a shield with them, you will find it harder to defend yourself if attacked.", getReply(npc));
    player.drop(weapon5);
   
    final Item weapon6 = new Item("black sword", "sword", "subclass", null);
    weapon6.setEquipableSlots(Arrays.asList("lhand"));
    weapon6.put("atk", 40);
    weapon6.put("rate", 7);
    player.equipToInventoryOnly(weapon6);
    assertTrue(player.isEquipped("black sword"));
   
    assertTrue(en.step(player, "weapon"));
    assertEquals("That black sword is a powerful weapon, it has a good damage to rate ratio. It should be useful against strong creatures. Remember though that something weaker but faster may suffice against lower level creatures.", getReply(npc));
    player.drop(weapon6);
   
    final Item weapon7 = new Item("obsidian knife", "sword", "subclass", null);
    weapon7.setEquipableSlots(Arrays.asList("lhand"));
    weapon7.put("atk", 4);
    weapon7.put("rate", 1);
    player.equipToInventoryOnly(weapon7);
    assertTrue(player.isEquipped("obsidian knife"));
   
    assertTrue(en.step(player, "weapon"));
    assertEquals("That obsidian knife is a powerful weapon, it has a good damage to rate ratio. Despite the fast rate being useful, the low attack will not help you against strong creatures. Something heavier would be better then.", getReply(npc));
    player.drop(weapon7);
   
    final Item weapon8 = new Item("assassin dagger", "sword", "subclass", null);
    weapon8.setEquipableSlots(Arrays.asList("lhand"));
    weapon8.put("atk", 6);
    weapon8.put("rate", 2);
    player.equipToInventoryOnly(weapon8);
    assertTrue(player.isEquipped("assassin dagger"));
   
    assertTrue(en.step(player, "weapon"));
    assertEquals("Well, your assassin dagger has quite low damage capability, doesn't it? You should look for something with a better attack to rate ratio. At least you can hit fast with it, so it may be good enough against creatures weaker than you.", getReply(npc));   
View Full Code Here


   */
  @Test
  public void testIsValidStackableDropAFew() {
    final Player bob = PlayerTestHelper.createPlayer("bob");
    final StendhalRPZone zone = new StendhalRPZone("dropzone");
    final Item dropitem = ItemTestHelper.createItem("drops", 5);
    zone.add(dropitem);
    zone.add(bob);
    MockStendlRPWorld.get().addRPZone(zone);

    final RPAction action = new RPAction();
    action.put(EquipActionConsts.BASE_ITEM, dropitem.getID().getObjectID());
    final int amounttodrop = 3;
    action.put(EquipActionConsts.QUANTITY, amounttodrop);
    final SourceObject so = SourceObject.createSourceObject(action, bob);
    assertTrue(so.isValid());
    assertEquals("return the amount to be dropped", amounttodrop, so.getQuantity());
View Full Code Here

   */
  @Test
  public void testIsValidStackableDropTooMany() {
    final Player bob = PlayerTestHelper.createPlayer("bob");
    final StendhalRPZone zone = new StendhalRPZone("dropzone");
    final Item dropitem = ItemTestHelper.createItem("drops", 5);
    zone.add(dropitem);
    zone.add(bob);
    MockStendlRPWorld.get().addRPZone(zone);

    final RPAction action = new RPAction();
    action.put(EquipActionConsts.BASE_ITEM, dropitem.getID().getObjectID());
    action.put(EquipActionConsts.QUANTITY, dropitem.getQuantity() + 3);
    final SourceObject so = SourceObject.createSourceObject(action, bob);
    assertTrue(so.isValid());
    assertEquals("too many are reduced to all", dropitem.getQuantity(), so.getQuantity());
  }
View Full Code Here

    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));
View Full Code Here

   
    // we choose to make it so that he had asked us to take a pizza to a specific npc so we have to remove the
    // old pizza and add the correct new flavour of pizza
   
    player.drop("pizza");
    Item item = ItemTestHelper.createItem("pizza");
    item.setInfoString("Pizza del Mare")
    player.getSlot("bag").add(item);
   
    final SpeakerNPC eliza = SingletonRepository.getNPCList().get("Eliza");
    en = eliza.getEngine();
    int xp = player.getXP();
    player.setQuest(questSlot, "Eliza;" + System.currentTimeMillis());
    en.step(player, "hi");
    assertEquals("Welcome to the #ferry service to #Athor #island! How can I #help you?", getReply(eliza));
    en.step(player, "pizza");
    // [16:55] kymara earns 30 experience points.
    assertEquals("Incredible! It's still hot! Here, buy something nice from these 170 pieces of gold!", getReply(eliza));
    assertFalse(player.isEquipped("pizza"));
    assertTrue(player.isEquipped("money"));
    assertThat(player.getXP(), greaterThan(xp));
    en.step(player, "bye");
    assertEquals("Goodbye!", getReply(eliza));
   
    // try saying pizza when you don't have one nor a quest for one
    en.step(player, "hi");
    assertEquals("Welcome to the #ferry service to #Athor #island! How can I #help you?", getReply(eliza));
    en.step(player, "pizza");
    assertEquals("A pizza? Where?", getReply(eliza));
    en.step(player, "bye");
    assertEquals("Goodbye!", getReply(eliza));
   
    SpeakerNPC npc1 = SingletonRepository.getNPCList().get("Leander");
    en = npc1.getEngine();
    // test rejecting quest
    en.step(player, "hi");
    assertEquals("Hallo! Glad to see you in my kitchen where I make #pizza and #sandwiches.", getReply(npc1));
    en.step(player, "pizza");
    assertEquals("I need someone who helps me delivering pizza. Maybe you could do that #task.", getReply(npc1));
    en.step(player, "task");
    assertEquals("I need you to quickly deliver a hot pizza. If you're fast enough, you might get quite a nice tip. So, will you do it?", getReply(npc1));
    en.step(player, "no");
    assertEquals("Too bad. I hope my daughter #Sally will soon come back from her camp to help me with the deliveries.", getReply(npc1));
    en.step(player, "sally");
    assertEquals("My daughter Sally might be able to help you get ham. She's a scout, you see; I think she's currently camped out south of Or'ril Castle.", getReply(npc1));
    en.step(player, "bye.");
    assertEquals("Bye.", getReply(npc1));
   
    en.step(player, "hi");
    assertEquals("Hallo! Glad to see you in my kitchen where I make #pizza and #sandwiches.", getReply(npc1));
    en.step(player, "pizza");
    assertEquals("I need someone who helps me delivering pizza. Maybe you could do that #task.", getReply(npc1));
    en.step(player, "task");
    assertEquals("I need you to quickly deliver a hot pizza. If you're fast enough, you might get quite a nice tip. So, will you do it?", getReply(npc1));
    en.step(player, "yes");
    assertTrue(getReply(npc1).startsWith("You must bring this Pizza "));
    en.step(player, "jenny");
    assertEquals("Jenny owns a mill in the plains north and a little east of Semos.", getReply(npc1));
    en.step(player, "bye");
    assertEquals("Bye.", getReply(npc1));
    assertTrue(player.hasQuest(questSlot));
   
    npc1 = SingletonRepository.getNPCList().get("Jenny");
    en = npc1.getEngine();
    xp = player.getXP();
    // testing taking too long to bring the pizza
    player.setQuest(questSlot, "Jenny;0");
    // we choose to make it so that he had asked us to take a pizza to a specific npc so we have to remove the
    // old pizza and add the correct new flavour of pizza
    player.drop("pizza");
    item = ItemTestHelper.createItem("pizza");
    item.setInfoString("Pizza Margherita")
    player.getSlot("bag").add(item);
   
    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(npc1));
    en.step(player, "pizza");
    assertFalse(player.isEquipped("pizza"));
    assertTrue(player.isQuestCompleted(questSlot));
    assertThat(player.getXP(), greaterThan(xp));
    // [16:58] kymara earns 5 experience points.
    assertEquals("It's a shame. Your pizza service can't deliver a hot pizza although the bakery is just around the corner.", getReply(npc1));
    en.step(player, "bye");
    assertEquals("Bye.", getReply(npc1));
   
   
    // ok, we've already tested getting pizza orders but now we're trying different npcs
    npc1 = SingletonRepository.getNPCList().get("Leander");
    en = npc1.getEngine();
   
    en.step(player, "hi");
    assertEquals("Hallo! Glad to see you in my kitchen where I make #pizza and #sandwiches.", getReply(npc1));
    en.step(player, "pizza");
    assertEquals("I need someone who helps me delivering pizza. Maybe you could do that #task.", getReply(npc1));
    en.step(player, "task");
    assertEquals("I need you to quickly deliver a hot pizza. If you're fast enough, you might get quite a nice tip. So, will you do it?", getReply(npc1));
    en.step(player, "yes");
    assertTrue(getReply(npc1).startsWith("You must bring this Pizza "));
    en.step(player, "bye");
    assertEquals("Bye.", getReply(npc1));
   
    npc1 = SingletonRepository.getNPCList().get("Katinka");
    en = npc1.getEngine();
    player.setQuest(questSlot, "Katinka;" + System.currentTimeMillis());
    // we choose to make it so that he had asked us to take a pizza to a DIFFERENT npc than Katinka
    // so we have to remove the
    // old pizza and add the WRONG new flavour of pizza
    player.drop("pizza");
    item = ItemTestHelper.createItem("pizza");
    item.setInfoString("Pizza Margherita")
    player.getSlot("bag").add(item);
   
    // on time
    en.step(player, "hi");
    assertEquals("Welcome to the Ados Wildlife Refuge! We rescue animals from being slaughtered by evil adventurers. But we need help... maybe you could do a #task for us?", getReply(npc1));
    en.step(player, "pizza");
    assertEquals("No, thanks. I like Pizza Vegetale better.", getReply(npc1));
    en.step(player, "bye");
    assertEquals("Goodbye!", getReply(npc1));
   
    // player find correct pizza
    player.drop("pizza");
    item = ItemTestHelper.createItem("pizza");
    item.setInfoString("Pizza Vegetale")
    player.getSlot("bag").add(item);
   
    en.step(player, "hi");
    assertEquals("Welcome to the Ados Wildlife Refuge! We rescue animals from being slaughtered by evil adventurers. But we need help... maybe you could do a #task for us?", getReply(npc1));
    en.step(player, "pizza");
    assertEquals("Yay! My Pizza Vegetale! Here, you can have 100 pieces of gold as a tip!", getReply(npc1));
    en.step(player, "bye");
    assertEquals("Goodbye!", getReply(npc1));
   
    npc1 = SingletonRepository.getNPCList().get("Leander");
    en = npc1.getEngine();
   
    en.step(player, "hi");
    assertEquals("Hallo! Glad to see you in my kitchen where I make #pizza and #sandwiches.", getReply(npc1));
    en.step(player, "pizza");
    assertEquals("I need someone who helps me delivering pizza. Maybe you could do that #task.", getReply(npc1));
    en.step(player, "task");
    assertEquals("I need you to quickly deliver a hot pizza. If you're fast enough, you might get quite a nice tip. So, will you do it?", getReply(npc1));
    en.step(player, "yes");
    assertTrue(getReply(npc1).startsWith("You must bring this Pizza "));
    en.step(player, "fidorea");
    assertEquals("Fidorea lives in Ados city. She is a makeup artist. You'll need to walk east from here.", getReply(npc1));
    en.step(player, "bye");
    assertEquals("Bye.", getReply(npc1));
    player.drop("pizza");
    item = ItemTestHelper.createItem("pizza");
    item.setInfoString("Pizza Napoli")
    player.getSlot("bag").add(item);
   
    npc1 = SingletonRepository.getNPCList().get("Fidorea");
    en = npc1.getEngine();
    player.setQuest(questSlot, "Fidorea;" + System.currentTimeMillis());
    // on time
    en.step(player, "hi");
    assertEquals("Hi, there. Do you need #help with anything?", getReply(npc1));
    en.step(player, "pizza");
    // [16:59] kymara earns 20 experience points.
    assertEquals("Thanks a lot! You're a born pizza deliverer. You can have these 150 pieces of gold as a tip!", getReply(npc1));
    en.step(player, "bye");
    assertEquals("Bye, come back soon.", getReply(npc1));
    assertFalse(player.isEquipped("pizza"));
   
    // try taking any pizza to fidorea when we didn't have a quest slot activated
    item = ItemTestHelper.createItem("pizza");
    player.getSlot("bag").add(item);
    player.removeQuest(questSlot);
    assertFalse(player.hasQuest(questSlot));
   
    en.step(player, "hi");
    assertEquals("Hi, there. Do you need #help with anything?", getReply(npc1));
    en.step(player, "pizza");
    // The flavor won't match
    assertEquals("No, thanks. I like Pizza Napoli better.", getReply(npc1));
    assertTrue(player.isEquipped("pizza"));
    en.step(player, "bye");
    assertEquals("Bye, come back soon.", getReply(npc1));
    // put the extra one on the ground now, we don't want it
    player.drop("pizza");
   
    npc1 = SingletonRepository.getNPCList().get("Leander");
    en = npc1.getEngine();
   
    en.step(player, "hi");
    assertEquals("Hallo! Glad to see you in my kitchen where I make #pizza and #sandwiches.", getReply(npc1));
    en.step(player, "pizza");
    assertEquals("I need someone who helps me delivering pizza. Maybe you could do that #task.", getReply(npc1));
    en.step(player, "task");
    assertEquals("I need you to quickly deliver a hot pizza. If you're fast enough, you might get quite a nice tip. So, will you do it?", getReply(npc1));
    en.step(player, "yes");
    assertTrue(getReply(npc1).startsWith("You must bring this Pizza "));
    en.step(player, "jenny");
    assertEquals("Jenny owns a mill in the plains north and a little east of Semos.", getReply(npc1));
    en.step(player, "bye");
    assertEquals("Bye.", getReply(npc1));
   
    // we choose to make it so that he had asked us to take a pizza to a specific npc so we have to remove the
    // old pizza and add the correct new flavour of pizza
   
    player.drop("pizza");
    item = ItemTestHelper.createItem("pizza");
    item.setInfoString("Pizza Margherita")
    player.getSlot("bag").add(item);
    npc1 = SingletonRepository.getNPCList().get("Jenny");
    en = npc1.getEngine();
    player.setQuest(questSlot, "Jenny;" + System.currentTimeMillis());
    // on time
    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(npc1));
    en.step(player, "pizza");
    // [17:00] kymara earns 10 experience points.
    assertEquals("Ah, you brought my Pizza Margherita! Very nice of you! Here, take 20 coins as a tip!", getReply(npc1));
    en.step(player, "bye");
    assertEquals("Bye.", getReply(npc1));
   
    npc1 = SingletonRepository.getNPCList().get("Leander");
    en = npc1.getEngine();
   
    en.step(player, "hi");
    assertEquals("Hallo! Glad to see you in my kitchen where I make #pizza and #sandwiches.", getReply(npc1));
    en.step(player, "pizza");
    assertEquals("I need someone who helps me delivering pizza. Maybe you could do that #task.", getReply(npc1));
    en.step(player, "task");
    assertEquals("I need you to quickly deliver a hot pizza. If you're fast enough, you might get quite a nice tip. So, will you do it?", getReply(npc1));
    en.step(player, "yes");
    assertTrue(getReply(npc1).startsWith("You must bring this Pizza "));
    en.step(player, "katinka");
    assertEquals("Katinka takes care of the animals at the Ados Wildlife Refuge. That's north east of here, on the way to Ados city.", getReply(npc1));
    en.step(player, "bye");
    assertEquals("Bye.", getReply(npc1));
   
    npc1 = SingletonRepository.getNPCList().get("Katinka");
    en = npc1.getEngine();
   
    player.drop("pizza");
    item = ItemTestHelper.createItem("pizza");
    item.setInfoString("Pizza Vegetale")
    player.getSlot("bag").add(item);
    // be late
    player.setQuest(questSlot, "Katinka;0");
   
    en.step(player, "hi");
    assertEquals("Welcome to the Ados Wildlife Refuge! We rescue animals from being slaughtered by evil adventurers. But we need help... maybe you could do a #task for us?", getReply(npc1));
    en.step(player, "pizza");
    assertEquals("Eek. I hate cold pizza. I think I'll feed it to the animals.", getReply(npc1));
    // [17:10] kymara earns 10 experience points.
    en.step(player, "bye");
    assertEquals("Goodbye!", getReply(npc1));
   
    npc1 = SingletonRepository.getNPCList().get("Leander");
    en = npc1.getEngine();
   
    en.step(player, "hi");
    assertEquals("Hallo! Glad to see you in my kitchen where I make #pizza and #sandwiches.", getReply(npc1));
    en.step(player, "pizza");
    assertEquals("I need someone who helps me delivering pizza. Maybe you could do that #task.", getReply(npc1));
    en.step(player, "task");
    assertEquals("I need you to quickly deliver a hot pizza. If you're fast enough, you might get quite a nice tip. So, will you do it?", getReply(npc1));
    en.step(player, "yes");
    assertTrue(getReply(npc1).startsWith("You must bring this Pizza "));
    en.step(player, "cyk");
    assertEquals("Cyk is currently on holiday on Athor Island. You'll easily recognize him by his blue hair. Go South East to find Athor ferry.", getReply(npc1));
    en.step(player, "bye");
    assertEquals("Bye.", getReply(npc1));
    player.setQuest(questSlot, "Cyk;" + System.currentTimeMillis());
    player.drop("pizza");
    item = ItemTestHelper.createItem("pizza");
    item.setInfoString("Pizza Hawaii")
    player.getSlot("bag").add(item);
    // test ask leander for task again before completing last
    en.step(player, "hi");
    assertEquals("Hallo! Glad to see you in my kitchen where I make #pizza and #sandwiches.", getReply(npc1));
    en.step(player, "pizza");
    assertEquals("I need someone who helps me delivering pizza. Maybe you could do that #task.", getReply(npc1));
    en.step(player, "task");
    assertEquals("You still have to deliver a pizza to Cyk, and hurry!", getReply(npc1));
    en.step(player, "bye");
    assertEquals("Bye.", getReply(npc1));
   
    npc1 = SingletonRepository.getNPCList().get("Cyk");
    en = npc1.getEngine();
    // on time
    en.step(player, "hi");
    assertEquals("Hello, player.", getReply(npc1));
    en.step(player, "pizza");
    // [17:10] kymara earns 50 experience points.
    assertEquals("Wow, I never believed you would really deliver this half over the world! Here, take these Pizza Hawaii bucks!", getReply(npc1));
   
    npc1 = SingletonRepository.getNPCList().get("Leander");
    en = npc1.getEngine();

    en.step(player, "hi");
    assertEquals("Hallo! Glad to see you in my kitchen where I make #pizza and #sandwiches.", getReply(npc1));
    en.step(player, "task");
    assertEquals("I need you to quickly deliver a hot pizza. If you're fast enough, you might get quite a nice tip. So, will you do it?", getReply(npc1));
    en.step(player, "yes");
    assertTrue(getReply(npc1).startsWith("You must bring this Pizza "));
    en.step(player, "haizen");
    assertEquals("Haizen is a magician who lives in a hut near the road to Ados. You'll need to walk east and north from here.", getReply(npc1));
   
    player.drop("pizza");
    item = ItemTestHelper.createItem("pizza");
    item.setInfoString("Pizza Diavolo")
    player.getSlot("bag").add(item);
   
    npc1 = SingletonRepository.getNPCList().get("Haizen");
    en = npc1.getEngine();
    player.setQuest(questSlot, "Haizen;" + System.currentTimeMillis());
    // on time
    en.step(player, "hi");
    assertEquals("Greetings! How may I help you?", getReply(npc1));
    en.step(player, "pizza");
    // [17:11] kymara earns 15 experience points.
    assertEquals("Ah, my Pizza Diavolo! And it's fresh out of the oven! Take these 80 coins as a tip!", getReply(npc1));
    en.step(player, "bye");
    assertEquals("Bye.", getReply(npc1));
   
    // Check coming back to leander after a failure
    // Add a test pizza, one that leander should not steal
    item = ItemTestHelper.createItem("pizza");
    player.getSlot("bag").add(item);
    // and then the pizza that belongs to Haizen
    item = ItemTestHelper.createItem("pizza");
    item.setInfoString("Pizza Diavolo")
    player.getSlot("bag").add(item);
    // Haizen allows 4 min delay. Set the time stamp 5min  to the past
    player.setQuest(questSlot, "Haizen;" + (System.currentTimeMillis() - 1000 * 60 * 5));
    en = leander.getEngine();
    en.setCurrentState(ConversationStates.IDLE);
View Full Code Here

public class ItemTestHelper {

  public static Item createItem() {
    ItemTestHelper.generateRPClasses();
    return new Item("item", "itemclass", "subclass", null);
  }
View Full Code Here

    return new Item("item", "itemclass", "subclass", null);
  }

  public static Item createItem(final String name) {
    ItemTestHelper.generateRPClasses();
    return new Item(name, "itemclass", "subclass", null);
  }
View Full Code Here

        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(
View Full Code Here

public class ItemTestHelperTest {

  @org.junit.Test
  public void testcreateItem() throws Exception {
    ItemTestHelper.createItem();
    final Item item = ItemTestHelper.createItem("blabla");
    assertEquals("blabla", item.getName());

  }
View Full Code Here

  public void testDropDice() {
    final StendhalRPZone localzone = new StendhalRPZone(ZONE_NAME, 20, 20); // zone with disabled collision detection
    final Player player = PlayerTestHelper.createPlayer("bob");
    localzone.add(player);

    Item item = SingletonRepository.getEntityManager().getItem("dice");
    player.equip(item, 1);

    assertEquals(0, localzone.getItemsOnGround().size());

    item = player.getFirstEquipped("dice");
    RPObject parent = item.getContainer();
    final RPAction action = new RPAction();
    action.put("type", "drop");
    action.put("baseitem", item.getID().getObjectID());
    action.put(EquipActionConsts.BASE_OBJECT, parent.getID().getObjectID());
    action.put(EquipActionConsts.BASE_SLOT, item.getContainerSlot().getName());
    action.put("x", player.getX());
    action.put("y", player.getY() + 1);

    new DropAction().onAction(player, action);
    assertEquals(0, player.events().size());
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.item.Item

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.