Beispiel #1
0
  /**
   * @param itemId
   * @param count
   * @return Creates new Item instance. If count is greater than template maxStackCount, count value
   *     will be cut to maximum allowed This method will return null if ItemTemplate for itemId was
   *     not found.
   */
  public Item newItem(int itemId, int count) {
    ItemTemplate itemTemplate = DataManager.ITEM_DATA.getItemTemplate(itemId);
    if (itemTemplate == null) {
      log.error(
          "Item was not populated correctly. Item template is missing for item id: " + itemId);
      return null;
    }

    int maxStackCount = itemTemplate.getMaxStackCount();
    if (count > maxStackCount && maxStackCount != 0) {
      count = maxStackCount;
    }

    // TODO if Item object will contain ownerId - item can be saved to DB before return
    return new Item(aionObjectsIDFactory.nextId(), itemTemplate, count, false, 0);
  }