Package games.stendhal.server.entity.item

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


      for (final RPObject object : slot) {
        if (!(object instanceof Item)) {
          continue;
        }

        final Item item = (Item) object;
        final String itemName = item.getName();

        if (itemName.equals(name)) {
          found += item.getQuantity();

          if (found >= amount) {
            return true;
          }
        }
View Full Code Here


    for (final String slotName : Constants.CARRYING_SLOTS) {
      final RPSlot slot = getSlot(slotName);

      for (final RPObject object : slot) {
        if (object instanceof Item) {
          final Item item = (Item) object;
          if (item.getName().equals(name)) {
            result += item.getQuantity();
          }
        }
      }
    }
View Full Code Here

  public final void testFire() {
    final Player player = PlayerTestHelper.createPlayer("player");
    PlayerHasItemWithHimCondition cond = new PlayerHasItemWithHimCondition(
        "itemname");
    assertFalse(cond.fire(player, null, null));
    Item item = ItemTestHelper.createItem("itemname");
    player.getSlot("bag").add(item);
    assertTrue(cond.fire(player, null, null));
    cond = new PlayerHasItemWithHimCondition("itemname", 2);
    assertFalse(cond.fire(player, null, null));
    item = ItemTestHelper.createItem("itemname");
View Full Code Here

    int result = 0;

    for (final RPSlot slot : slots()) {
      for (final RPObject object : slot) {
        if (object instanceof Item) {
          final Item item = (Item) object;
          if (item.getName().equals(name)) {
            result += item.getQuantity();
          }
        }
      }
    }
View Full Code Here

    for (final String slotName : Constants.CARRYING_SLOTS) {
      final RPSlot slot = getSlot(slotName);

      for (final RPObject object : slot) {
        if (object instanceof Item) {
          final Item item = (Item) object;
          if (item.getName().equals(name)) {
            return item;
          }
        }
      }
    }
View Full Code Here

    for (final String slotName : Constants.CARRYING_SLOTS) {
      final RPSlot slot = getSlot(slotName);

      for (final RPObject object : slot) {
        if (object instanceof Item) {
          final Item item = (Item) object;
          if (item.getName().equals(name)) {
            result.add(item);
          }
        }
      }
    }
View Full Code Here

      final RPSlot rpslot = getSlot(slot);
      // traverse all slot items
      for (final RPObject object : rpslot) {
        // is it the right type
        if (object instanceof Item) {
          final Item item = (Item) object;
          if (item.isOfClass(clazz)) {
            return item;
          }
        }
      }
    }
View Full Code Here

    final String[] weaponsClasses = {"club", "sword", "axe", "ranged", "missile"};

    for (final String weaponClass : weaponsClasses) {
      final String[] slots = { "lhand", "rhand" };
      for (final String slot : slots) {
        final Item item = getEquippedItemClass(slot, weaponClass);
        if (item != null) {
          return item;
        }
      }
    }
View Full Code Here

    return null;
  }

  public List<Item> getWeapons() {
    final List<Item> weapons = new ArrayList<Item>();
    Item weaponItem = getWeapon();
    if (weaponItem != null) {
      weapons.add(weaponItem);

      // pair weapons
      if (weaponItem.getName().startsWith("l hand ")) {
        // check if there is a matching right-hand weapon in
        // the other hand.
        final String rpclass = weaponItem.getItemClass();
        weaponItem = getEquippedItemClass("rhand", rpclass);
        if ((weaponItem != null)
            && (weaponItem.getName().startsWith("r hand "))) {
          weapons.add(weaponItem);
        } else {
          // You can't use a left-hand weapon without the matching
          // right-hand weapon. Hmmm... but why not?
          weapons.clear();
        }
      } else {
        // You can't hold a right-hand weapon with your left hand, for
        // ergonomic reasons ;)
        if (weaponItem.getName().startsWith("r hand ")) {
          weapons.clear();
        }
      }
    }
View Full Code Here

    return isEquippedItemClass("lhand", "shield")
        || isEquippedItemClass("rhand", "shield");
  }

  public Item getShield() {
    final Item item = getEquippedItemClass("lhand", "shield");
    if (item != null) {
      return item;
    } else {
      return getEquippedItemClass("rhand", "shield");
    }
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.