Ejemplo n.º 1
0
  /**
   * Loot item from a dead body
   *
   * @param Targ Target Inventory
   * @param Index Item Index
   */
  public void Take(ItemList Targ, int Index) {
    // Add item to character inventory

    // unequip item
    if (Targ.ITEM_NAME.elementAt(Index).indexOf("<Eq>") != -1) {
      Targ.ItemEffect(Index, this);
    }
    this.INVENTORY.addItem(
        Targ.ITEM_NAME.elementAt(Index),
        Targ.ITEM_PRICE.elementAt(Index),
        1,
        Targ.ITEM_IMAGE.elementAt(Index),
        Targ.ITEM_TAG.elementAt(Index),
        Targ.STATS.elementAt(Index));

    // Remove item from target inven
    Targ.removeItem(Index, 1);
  }
Ejemplo n.º 2
0
  /**
   * Buy an item from a shopkeeper
   *
   * @param Targ Target Inventory
   * @param Index Item Index
   */
  public void Buy(ItemList Targ, int Index) {
    // If item is too expensive
    if (Targ.ITEM_PRICE.elementAt(Index) > this.GOLD) {
      JOptionPane.showMessageDialog(null, "Too rich for your blood");
      return;
    }

    // add Item to character inventory
    this.INVENTORY.addItem(
        Targ.ITEM_NAME.elementAt(Index),
        Targ.ITEM_PRICE.elementAt(Index),
        1,
        Targ.ITEM_IMAGE.elementAt(Index),
        Targ.ITEM_TAG.elementAt(Index),
        Targ.STATS.elementAt(Index));

    // remove Gold
    this.GOLD -= Targ.ITEM_PRICE.elementAt(Index);

    // remove item from target inventory
    Targ.removeItem(Index, 1);
  }