Package games.stendhal.server.entity.item

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


    int legs = 0;
    int boots = 0;
    int cloak = 0;
    int weapon = 0;

    Item item;
   
    if (hasShield()) {
      item = getShield();
      shield = (int) (item.getDefense() / getItemLevelModifier(item));
    }

    if (hasArmor()) {
      item = getArmor();
      armor = (int) (item.getDefense() / getItemLevelModifier(item));
    }

    if (hasHelmet()) {
      item = getHelmet();
      helmet = (int) (item.getDefense() / getItemLevelModifier(item));
    }

    if (hasLegs()) {
      item = getLegs();
      legs = (int) (item.getDefense() / getItemLevelModifier(item));
    }

    if (hasBoots()) {
      item = getBoots();
      boots = (int) (item.getDefense() / getItemLevelModifier(item));
    }

    if (hasCloak()) {
      item = getCloak();
      cloak = (int) (item.getDefense() / getItemLevelModifier(item));
    }

    final List<Item> targetWeapons = getWeapons();
    for (final Item weaponItem : targetWeapons) {
      weapon += weaponItem.getDefense() / getItemLevelModifier(weaponItem);
View Full Code Here


   * Get the maximum distance attack range.
   *
   * @return maximum range, or 0 if the entity can't attack from distance
   */
  public int getMaxRangeForArcher() {
    final Item rangeWeapon = getRangeWeapon();
    final StackableItem ammunition = getAmmunition();
    final StackableItem missiles = getMissileIfNotHoldingOtherWeapon();
    int maxRange;
    if ((rangeWeapon != null) && (ammunition != null)
        && (ammunition.getQuantity() > 0)) {
      maxRange = rangeWeapon.getInt("range") + ammunition.getInt("range");
    } else if ((missiles != null) && (missiles.getQuantity() > 0)) {
      maxRange = missiles.getInt("range");
    } else {
      // The entity doesn't hold the necessary distance weapons.
      maxRange = 0;
View Full Code Here

    final Entity entity = source.getEntity();
    final String itemName = source.getEntityName();
 
    logger.debug("Checking if entity is bound");
    if (entity instanceof Item) {
      final Item item = (Item) entity;
      if (item.isBound() && !player.isBoundTo(item)) {
        player.sendPrivateText("This " + itemName
            + " is a special reward for " + item.getBoundTo()
            + ". You do not deserve to use it.");
        return;
      }
     
    }
View Full Code Here

  public Item transform(RPObject rpobject) {
    // We simply ignore corpses...
    if (rpobject.get("type").equals("item")) {
   
      final String name = UpdateConverter.updateItemName(rpobject.get("name"));
      final Item item = UpdateConverter.updateItem(name);

      if (item == null) {
        // no such item in the game anymore
        return null;
      }
     
      item.setID(rpobject.getID());

      if (rpobject.has("persistent")
          && (rpobject.getInt("persistent") == 1)) {
        /*
         * Keep [new] rpclass
         */
        final RPClass rpclass = item.getRPClass();
        item.fill(rpobject);
        item.setRPClass(rpclass);

        // If we've updated the item name we don't want persistent reverting it
        item.put("name", name);
      }

      if (item instanceof StackableItem) {
        int quantity = 1;
        if (rpobject.has("quantity")) {
          quantity = rpobject.getInt("quantity");
        } else {
          logger.warn("Adding quantity=1 to "
              + rpobject
              + ". Most likely cause is that this item was not stackable in the past");
        }
        ((StackableItem) item).setQuantity(quantity);

        if (quantity <= 0) {
          logger.warn("Ignoring item "
              + name
              + " because this item has an invalid quantity: "
              + quantity);
          return null;
        }
      }

      // make sure saved individual information is
      // restored
      final String[] individualAttributes = { "infostring",
          "description", "bound", "undroppableondeath" };
      for (final String attribute : individualAttributes) {
        if (rpobject.has(attribute)) {
          item.put(attribute, rpobject.get(attribute));
        }
      }

      if (rpobject.has("logid")) {
        item.put("logid", rpobject.get("logid"));
      }
     
      // Contents, if the item has slot(s)
      for (RPSlot slot : rpobject.slots()) {
        RPSlot itemSlot = item.getSlot(slot.getName());
        for (RPObject obj : slot) {
          // Transform the contents too
          itemSlot.add(transform(obj));
        }
      }
View Full Code Here

    final int oldX = entity.getX();
    final int oldY = entity.getY();

    if (entity instanceof Item) {
      final Item item = (Item) entity;
      StackableItem stackableItem = null;

      if (item instanceof StackableItem) {
        stackableItem = (StackableItem) item;
      }

      Item newItem;

      if ((quantity > 0) && (stackableItem != null) && (quantity < stackableItem.getQuantity())) {
        newItem = removeFromWorld(player, stackableItem, quantity);
      } else {
        item.onRemoveFromGround();
        newItem = item;
      }

      newItem.setPosition(x, y);
      if (newItem != item) {
        zone.add(newItem);
      }
      newItem.notifyWorldAboutChanges();
      newItem.onPutOnGround(player);

      new ItemLogger().displace(player, newItem, zone, oldX, oldY, x, y);
    } else {
      entity.setPosition(x, y);
      entity.notifyWorldAboutChanges();
View Full Code Here

        }
      }

      if (type != null) {
        new GameEvent(player.getName(), SUMMONAT, changed.getName(), slotName, type).raise();
        final Item item = manager.getItem(type);

        if (action.has(AMOUNT) && (item instanceof StackableItem)) {
          ((StackableItem) item).setQuantity(action.getInt(AMOUNT));
        }
View Full Code Here

          "I have met Ceryl at the library, he's the librarian there.",
          "I promised to fetch the black book from Jynath.",
          "I do not have the black book Jynath has."),
        quest.getHistory(pl));

    final Item item = SingletonRepository.getEntityManager().getItem(
        "black book");
    assertNotNull(item);
    item.setBoundTo(pl.getName());
    pl.equipOrPutOnGround(item);
    assertEquals(3, quest.getHistory(pl).size());
    assertEquals(Arrays.asList(
          "I have met Ceryl at the library, he's the librarian there.",
          "I promised to fetch the black book from Jynath.",
View Full Code Here

          new ItemLogger().destroyOnLogin(player, slot, rpobject);
         
          continue;
        }
       
        Item item = transformer.transform(rpobject);
       
        // log removed items
        if (item == null) {
          int quantity = 1;
          if (rpobject.has("quantity")) {
View Full Code Here

    assertEquals(wc.askForItemsAfterPlayerSaidHeHasItems(), getReply(npc));

    en.stepTest(pl, "bardiche");
    assertEquals(wc.respondToOfferOfNotExistingItem("bardiche"), getReply(npc));

        Item cloak = new Item("bardiche", "", "", null);
    pl.getSlot("bag").add(cloak);

    assertTrue(en.stepTest(pl, "bardiche"));
    assertEquals(wc.respondToItemBrought(), getReply(npc));

    assertTrue(en.stepTest(pl, "bardiche"));
    assertEquals(wc.respondToOfferOfNotMissingItem(), getReply(npc));

    cloak = new Item("stone cloak", "", "", null);
    pl.getSlot("bag").add(cloak);

    for (final String cloakName : wc.getNeededItems()) {
      cloak = new Item(cloakName, "", "", null);
      pl.getSlot("bag").add(cloak);
      assertTrue(en.step(pl, cloakName));
    }

    assertEquals(wc.respondToLastItemBrought(), getReply(npc));
View Full Code Here

   
    getSlot(OFFER_ITEM_SLOT_NAME).clear();
       
    final RPObject itemObject = object.getSlot(OFFER_ITEM_SLOT_NAME).getFirst();

    final Item entity = new ItemTransformer().transform(itemObject);

    // log removed items
    if (entity == null) {
      int quantity = 1;
      if (itemObject.has("quantity")) {
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.