1 /* $Id$ */ 2 /*************************************************************************** 3 * (C) Copyright 2003 - Marauroa * 4 *************************************************************************** 5 *************************************************************************** 6 * * 7 * This program is free software; you can redistribute it and/or modify * 8 * it under the terms of the GNU General Public License as published by * 9 * the Free Software Foundation; either version 2 of the License, or * 10 * (at your option) any later version. * 11 * * 12 ***************************************************************************/ 13 package games.stendhal.client.entity; 14 15 import marauroa.common.game.RPObject; 16 17 /** 18 * This is a stackable item. 19 */ 20 public class StackableItem extends Item { 21 /** 22 * Quantity property. 23 */ 24 public static final Property PROP_QUANTITY = new Property(); 25 26 /** 27 * The item quantity. 28 */ 29 private int quantity; 30 31 /** 32 * Create a stackable item. 33 */ StackableItem()34 public StackableItem() { 35 quantity = 0; 36 } 37 38 // 39 // StackableItem 40 // 41 42 /** 43 * Get the item quantity. 44 * 45 * @return The number of items. 46 */ getQuantity()47 public int getQuantity() { 48 return quantity; 49 } 50 51 // 52 // RPObjectChangeListener 53 // 54 55 /** 56 * The object added/changed attribute(s). 57 * 58 * @param object 59 * The base object. 60 * @param changes 61 * The changes. 62 */ 63 @Override onChangedAdded(final RPObject object, final RPObject changes)64 public void onChangedAdded(final RPObject object, final RPObject changes) { 65 super.onChangedAdded(object, changes); 66 67 if (changes.has("quantity")) { 68 quantity = changes.getInt("quantity"); 69 fireChange(PROP_QUANTITY); 70 } 71 } 72 } 73