Package games.stendhal.server.entity.item

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


    final RingOfLife ring = (RingOfLife) SingletonRepository.getEntityManager().getItem("emerald ring");
    ring.damage();
    player.equipToInventoryOnly(ring);
    ring.setBoundTo(player.getName());
    orderfixandfetchordered(player);
    final Item ringafter = player.getFirstEquipped("emerald ring");
    assertTrue(ringafter.isBound());
    assertTrue(player.isBoundTo(ringafter));
    assertEquals("You see an emerald ring, known as ring of life. Wear it, and you risk less from death.", ringafter.getDescription());
    assertEquals("You see an emerald ring, known as the ring of life. Wear it, and you risk less from death. It is a special quest reward for player, and cannot be used by others.", ringafter.describe());

    assertEquals("Bye, my friend.", getReply(npc));
 
  }
View Full Code Here


    ring.damage();
    player.equipToInventoryOnly(ring);
   
    assertFalse(ring.isBound());
    orderfixandfetchordered(player);
    final Item ringafter = player.getFirstEquipped("emerald ring");
    assertFalse(ringafter.isBound());
 
  }
View Full Code Here

   * @param object
   * @return true if item is bound false otherwise
   */
  protected boolean isItemBoundToOtherPlayer(final Player player, final RPObject object) {
    if (object instanceof Item) {
      final Item item = (Item) object;
      if (item.isBound() && !player.isBoundTo(item)) {
        player.sendPrivateText("This "
            + item.getName()
            + " is a special reward for " + item.getBoundTo()
            + ". You do not deserve to use it.");
        return true;
      }
    }
    return false;
View Full Code Here

       
        player.drop("empty scroll", 1);

        String infostring = zone.getName() + " " + x + " " + y;

        Item scroll = SingletonRepository.getEntityManager().getItem("marked scroll");       
        scroll.setInfoString(infostring);
       
        // add a description if the player wanted one
        if (action.has(TARGET)) {
          String description = action.get(TARGET) + " " + action.get("args");
          scroll.setDescription("You see a scroll marked by " + player.getName() + ". It says: \""+ description +"\". ");
        }

        player.equipOrPutOnGround(scroll);

      } else {
View Full Code Here

    assertEquals("Farewell", getReply(npc));

    // -----------------------------------------------

    // superkym gets 10 iron
    Item item = ItemTestHelper.createItem("iron", 10);
    player.getSlot("bag").add(item);

    en.step(player, "hi");
    assertEquals("I cannot #forge it without the missing 5 pieces of iron.", getReply(npc));
    en.step(player, "forge");
View Full Code Here

    for (final String itemName : CLOAKS.subList(1, CLOAKS.size())) {
      en.stepTest(player, itemName);
      assertEquals("Oh, I'm disappointed. You don't really have "
          + Grammar.a_noun(itemName) + " with you.", getReply(npc));
     
      final Item cloak = new Item(itemName, "", "", null);
      player.getSlot("bag").add(cloak);
      en.stepTest(player, itemName);
      assertEquals("Wow, thank you! What else did you bring?", getReply(npc));
     
      en.stepTest(player, itemName);
      assertEquals("You're terribly forgetful, you already brought that one to me.", getReply(npc));
    }
   
    // check the message again now that it has changed
    en.stepTest(player, "cloaks");
    assertEquals(stillWantedMessage(player), getReply(npc));
   
    // Give the last one too. Try lying first again just to be sure
    final String lastCloak = CLOAKS.get(0);
    en.stepTest(player, lastCloak);
    assertEquals("Oh, I'm disappointed. You don't really have "
        + Grammar.a_noun(lastCloak) + " with you.", getReply(npc));
    final Item cloak = new Item(lastCloak, "", "", null);
    player.getSlot("bag").add(cloak);
    en.stepTest(player, lastCloak);
    assertEquals("Answer to last brought cloak", "Oh, yay! You're so kind, I bet you'll have great Karma now! Here, take these killer boots. I think they're gorgeous but they don't fit me!", getReply(npc));
   
    // check the rewards
    assertEquals(karma + 5.0 + 100.0, player.getKarma(), 0.01);
    assertEquals(100000, player.getXP());
    assertEquals("done;rewarded", player.getQuest(QUEST_NAME));
    assertEquals(true, player.isEquipped("killer boots"));
   
    final Item boots = player.getFirstEquipped("killer boots");
    assertEquals("player", boots.getBoundTo());
  }
View Full Code Here

    en.stepTest(player, ConversationPhrases.GREETING_MESSAGES.get(0));
    assertEquals("Message for the compatibility hack""Oh! I didn't reward you for helping me again! Here, take these boots. I think they're gorgeous but they don't fit me :(", getReply(npc));
    assertEquals("done;rewarded", player.getQuest(QUEST_NAME));
    assertTrue("The player got the boots", player.isEquipped("killer boots"));
   
    final Item boots = player.getFirstEquipped("killer boots");
    assertEquals("player", boots.getBoundTo());
  }
View Full Code Here

    if (object instanceof Entity) {
      ((Entity) object).onAdded(this);
    }

    if (object instanceof Item) {
      final Item item = (Item) object;
      if (player != null) {
        // let item decide what to do when it's thrown by a player
        item.onPutOnGround(player);
      } else {
        // otherwise follow expire
        item.onPutOnGround(expire);
      }
      itemsOnGround.add(item);
    }

    /*
 
View Full Code Here

        final RPObject object = objectsIterator.next();
        if (!(object instanceof Item)) {
          continue;
        }

        final Item item = (Item) object;

        if (!item.getName().equals(name)) {
          continue;
        }

        if (item instanceof StackableItem) {
          // The item is stackable, we try to remove
          // multiple ones.
          final int quantity = item.getQuantity();
          if (toDrop >= quantity) {
            new ItemLogger().destroy(this, slot, item);
            slot.remove(item.getID());
            toDrop -= quantity;
            // Recreate the iterator to prevent
            // ConcurrentModificationExceptions.
            // This inefficient, but simple.
            objectsIterator = slot.iterator();
          } else {
            ((StackableItem) item).setQuantity(quantity - toDrop);
            new ItemLogger().splitOff(this, item, toDrop);
            toDrop = 0;
          }
        } else {
          // The item is not stackable, so we only remove a
          // single one.
          slot.remove(item.getID());
          new ItemLogger().destroy(this, slot, item);
          toDrop--;
          // recreate the iterator to prevent
          // ConcurrentModificationExceptions.
          objectsIterator = slot.iterator();
View Full Code Here

    }

    super.remove(id);

    if (object instanceof Item) {
      final Item item = (Item) object;
      itemsOnGround.remove(item);
      item.onRemoveFromGround();
    }

    return object;
  }
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.