Package games.stendhal.server.entity.slot

Examples of games.stendhal.server.entity.slot.EntitySlot


      tryUse(player, entity);
    }
  }

  private void useItemInSlot(final Player player, final RPAction action) {
    final EntitySlot slot = EntityHelper.getSlot(player, action);
    final Entity object = EntityHelper.entityFromSlot(player, action);
    if ((object != null) && canAccessSlot(player, slot, object.getBaseContainer())) {
      tryUse(player, object);
    }
  }
View Full Code Here


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

    if (data.getSourceItems().get(0).getContainerBaseOwner() != data.getPlayer()) {
      return false;
    }

    // Is the target slot owned by the player?
    EntitySlot targetSlot = data.getTargetSlot();
    if (!targetSlot.hasAsAncestor(data.getPlayer())) {
      return false;
    }

    // Target slot needs to be a single item slot
    return targetSlot.getCapacity() == 1;
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  public boolean preCheck(final Entity entity, final Player player) {
    final StendhalRPZone zone = player.getZone();

    if (parent != null) {
      final EntitySlot rpslot = (EntitySlot) parent.getSlot(slot);
      rpslot.clearErrorMessage();
      if (!rpslot.isReachableForThrowingThingsIntoBy(player)) {
        player.sendPrivateText(rpslot.getErrorMessage());
        logger.debug("Unreachable slot");
        return false;
      }

      if (rpslot.isFull()) {
        boolean isStackable = false;
        // is the entity stackable
        if (entity instanceof Stackable<?>) {
          final Stackable<?> stackEntity = (Stackable<?>) entity;
          // now check if it can be stacked on top of another item
          final Iterator<RPObject> it = rpslot.iterator();
          while (it.hasNext()) {
            final RPObject object = it.next();

            if (object instanceof Stackable<?>) {
              // found another stackable
              @SuppressWarnings("rawtypes")
              final Stackable other = (Stackable<?>) object;
              if (other.isStackable(stackEntity)) {
                // other is the same type...merge them
                isStackable = true;
              }
            }
          }
        }

        if (!isStackable) {
          // entity cannot be stacked on top of another...
          // so the equip is invalid
          player.sendPrivateText("There is no space in there.");
          return false;
        }
      }

      // check if someone tried to put an item into itself (maybe
      // through various levels of indirection)
      if (rpslot.hasAsAncestor(entity)) {
        logger.warn("tried to put item " + entity.getID()
            + " into itself, equip rejected");
        return false;
      }

      if (entity instanceof Item) {
        Item item = (Item) entity;
        if (item.isBound() && rpslot.isTargetBoundCheckRequired()) {
          player.sendPrivateText("You cannot put this special quest reward there because it can only be used by you.");
          return false;
        }
       
        // check if an item that is sent to a trade slot is not damaged
        if (item.getDeterioration() > 0 && rpslot.getName().equals("trade")) {
          player.sendPrivateText("You must not trade a damaged item with other players.");
          return false;
        }
      }
     
View Full Code Here

   *
   * @return name of slot
   */
  public String getContentSlotName() {
    if (parent != null) {
      final EntitySlot entitySlot = parent.getEntitySlot(slot);
      return entitySlot.getContentSlotName();
    } else {
      return null;
    }
  }
View Full Code Here

  private static boolean isValidBaseSlot(final Player player, final RPSlot baseSlot) {
    if (! (baseSlot instanceof EntitySlot)) {
      return false;
    }
    EntitySlot slot = (EntitySlot) baseSlot;
    slot.clearErrorMessage();
    boolean res = slot.isReachableForTakingThingsOutOfBy(player);
    if (!res) {
      logger.debug("Unreachable slot");
      player.sendPrivateText(slot.getErrorMessage());
    }
    return res;
  }
View Full Code Here

      data.setErrorMessage("");
      return;
    }

    // Walk the slot path
    EntitySlot slot = null;
    while (it.hasNext()) {
      String slotName = it.next();
      if (!parent.hasSlot(slotName)) {
        data.setErrorMessage("");
        return;
      }
      slot = parent.getEntitySlot(slotName);
      if (!it.hasNext()) {
        break;
      }

      final RPObject.ID itemId = new RPObject.ID(MathHelper.parseInt(it.next()), "");
      if (!slot.has(itemId)) {
        data.setErrorMessage("");
        return;
      }
      parent = (Entity) slot.get(itemId);
    }
    data.setTargetRoot(root);
    data.setTargetSlot(slot);
  }
View Full Code Here

  }

  public void equip(final List<EquipItem> items) {
    for (final EquipItem equippedItem : items) {
      if (!hasSlot(equippedItem.slot)) {
        addSlot(new EntitySlot(equippedItem.slot, equippedItem.slot));
      }

      final RPSlot slot = getSlot(equippedItem.slot);
      final Item item = SingletonRepository.getEntityManager().getItem(equippedItem.name);
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.slot.EntitySlot

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.