Examples of RPSlot


Examples of marauroa.common.game.RPSlot

              newKills.put(newAttr, value);
          }
        }

        final RPSlot slot = object.getSlot("!kills");
        slot.remove(kills.getID());
        slot.add(newKills);
    }
  }
View Full Code Here

Examples of marauroa.common.game.RPSlot

 
  @Override
  protected boolean isAllowed(final RPEntity user) {
    // check if the player is carrying a matching HouseKey
    for (final String slotName : Constants.CARRYING_SLOTS) {
      final RPSlot slot = user.getSlot(slotName);

      for (final RPObject object : slot) {
        if (!(object instanceof HouseKey)) {
          continue;
        }
View Full Code Here

Examples of marauroa.common.game.RPSlot

    if (item instanceof Stackable<?>) {
      // first try to put the item on an existing stack
      final Stackable<?> stackEntity = (Stackable<?>) item;
      for (final String slotName : slotNames) {
        if (hasSlot(slotName)) {
          final RPSlot rpslot = getSlot(slotName);
          for (final RPObject object : rpslot) {
            if (object instanceof Stackable<?>) {
              // found another stackable
              @SuppressWarnings("rawtypes")
              final Stackable other = (Stackable<?>) object;
              if (other.isStackable(stackEntity)) {
                return slotName;
              }
            }
          }
        }
      }
    }

    // We can't stack it on another item. Check if we can simply
    // add it to an empty cell.
    for (final String slot : slotNames) {
      if (hasSlot(slot)) {
        final RPSlot rpslot = getSlot(slot);

        // check that this slot is reachable (e. g. fixed keyring)
        if (rpslot instanceof EntitySlot) {
          EntitySlot entitySlot = (EntitySlot) rpslot;
          if (!entitySlot.isReachableForThrowingThingsIntoBy(this)) {
            continue;
          }
        }

        if (!rpslot.isFull()) {
          return slot;
        }
      }
    }
    return null;
View Full Code Here

Examples of marauroa.common.game.RPSlot

    }

    int toDrop = amount;

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

      Iterator<RPObject> objectsIterator = slot.iterator();
      while (objectsIterator.hasNext()) {
        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();
        }

        if (toDrop == 0) {
          updateItemAtkDef();
          notifyWorldAboutChanges();
View Full Code Here

Examples of marauroa.common.game.RPSlot

    final String slotName = action.get(EquipActionConsts.BASE_SLOT);
    if (!parent.hasSlot(slotName)) {
      data.setErrorMessage("");
      return;
    }
    final RPSlot slot = ((EntitySlot) parent.getSlot(slotName)).getWriteableSlot();
    if (slot == null || !(slot instanceof EntitySlot)) {
      data.setErrorMessage("");
      return;
    }

    final RPObject.ID baseItemId = new RPObject.ID(action.getInt(EquipActionConsts.BASE_ITEM), "");
    if (!slot.has(baseItemId)) {
      data.setErrorMessage("");
      return;
    }
    final Entity entity = (Entity) slot.get(baseItemId);

    data.addSourceItem(entity);
    data.setSourceRoot(parent);
    data.addSourceSlot((EntitySlot) slot);
  }
View Full Code Here

Examples of marauroa.common.game.RPSlot

   *            the item that should be removed
   * @return true iff dropping the item was successful.
   */
  public boolean drop(final Item item) {
    for (final String slotName : Constants.CARRYING_SLOTS) {
      final RPSlot slot = getSlot(slotName);

      final Iterator<RPObject> objectsIterator = slot.iterator();
      while (objectsIterator.hasNext()) {
        final RPObject object = objectsIterator.next();
        if (object instanceof Item) {
          if (object == item) {
            slot.remove(object.getID());
            new ItemLogger().destroy(this, slot, item);
            return true;
          }
        }
      }
View Full Code Here

Examples of marauroa.common.game.RPSlot

      if (!entity.hasSlot(slotName)) {
        data.setErrorMessage("");
        return;
      }

      final RPSlot slot = ((EntitySlot) entity.getSlot(slotName)).getWriteableSlot();
      if (slot == null) {
        data.setErrorMessage("");
        return;
      }
      if (!it.hasNext()) {
        data.setErrorMessage("");
        return;
      }
      final RPObject.ID itemId = new RPObject.ID(MathHelper.parseInt(it.next()), "");
      if (!slot.has(itemId)) {
        data.setErrorMessage("");
        return;
      }

      entity = (Entity) slot.get(itemId);
    }

    // if the item is not contained, the item is on the ground
    if (parent == entity) {
      data.addSourceItem(entity);
View Full Code Here

Examples of marauroa.common.game.RPSlot

    }

    int found = 0;

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

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

Examples of marauroa.common.game.RPSlot

   */
  public int getNumberOfEquipped(final String name) {
    int result = 0;

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

Examples of marauroa.common.game.RPSlot

   * @return The item, or a stack of stackable items, or null if nothing was
   *         found
   */
  public Item getFirstEquipped(final String name) {
    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)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.