|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.starhope.appius.util.SimpleDataRecord<InventoryItem>
org.starhope.appius.game.inventory.InventoryItem
public class InventoryItem
The InventoryItem is the main class for all items which can be placed into the user's inventory. It also has interface elements for the common behaviour of “equipping” the item in some way, giving and receiving items (including purchasing them and trading with other players), and so forth.
WRITEME — ItemEffects
InventoryItemType
,
GenericItemReference
, and how they all get along
Field Summary | |
---|---|
protected boolean |
active
if true, the item is equipped/active |
(package private) List<Colour> |
colours
The colours that define the appearance of this item. |
private String |
facing
WRITEME: Document this brpocock@star-hope.org |
private BigDecimal |
health
The health of the item |
protected int |
itemID
the item ID |
protected int |
ownerID
user owning this item |
private int |
roomNumber
room number (of all rooms owned by the given owner) |
private static long |
serialVersionUID
Java serialisation unique ID |
protected int |
slotNumber
The slot/series in which this occurs in the player's inventory |
protected InventoryItemType |
type
WRITEME |
private double |
x
WRITEME: Document this brpocock@star-hope.org |
private double |
y
WRITEME: Document this brpocock@star-hope.org |
private double |
z
WRITEME: Document this brpocock@star-hope.org |
Fields inherited from class org.starhope.appius.util.SimpleDataRecord |
---|
myLoader, timeLastChanged, timeLastSaved |
Constructor Summary | |
---|---|
InventoryItem()
WRITEME: Document this constructor brpocock@star-hope.org |
|
InventoryItem(RecordLoader<InventoryItem> loader)
WRITEME: Document this constructor brpocock@star-hope.org |
Method Summary | |
---|---|
void |
changeHealth(int delta)
|
private void |
checkEquipChange()
Check whether the user needs an equipment update |
void |
destroy()
Destroy an item altogether. |
boolean |
equals(Object obj)
|
void |
equip()
WRITEME: document this method (brpocock@star-hope.org, Nov 24, 2009) |
static InventoryItem |
getByID(int idByWhichToGet)
get the inventory item with the given inventory slot ID |
static InventoryItem |
getByID(RecordLoader<InventoryItem> loader,
int idByWhichToGet)
Get an inventory item based upon the database ID |
int |
getCacheableID()
Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier (
DataRecord.getCacheableIdent() or both. |
String |
getCacheableIdent()
Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier (
DataRecord.getCacheableIdent() or both. |
Colour |
getColor()
|
Colour |
getColour()
|
Colour |
getColour(int index)
|
List<Colour> |
getColours()
|
String |
getFacing()
WRITEME: Document this method brpocock@star-hope.org |
GenericItemReference |
getGenericItem()
|
BigDecimal |
getHealth()
|
int |
getID()
|
ItemEffects |
getItemEffects()
Get an ItemEffects class for this item, if any |
int |
getItemID()
|
private AbstractUser |
getOnlineOwner()
If the owner is online, get the owner |
AbstractUser |
getOwner()
|
int |
getOwnerID()
|
int |
getRoomIndex()
|
int |
getSlotNumber()
|
String |
getSubversionRevision()
Return the Subversion revision level of this class's source code file, as supplied via the special "$Rev: " sequence. |
InventoryItemType |
getType()
|
int |
getTypeID()
|
double |
getX()
|
double |
getY()
|
double |
getZ()
|
int |
hashCode()
This is an overriding method. |
boolean |
isActive()
|
private void |
reportBug(String bug,
Throwable e)
Report a bug via AppiusClaudiusCaecus with the slot
number for convenience in debugging |
void |
setActive(boolean beActive)
|
void |
setColour(Colour newColour)
Deprecated. use setColour(List) or
setColour(int, Colour) |
void |
setColour(int newColour)
Deprecated. use setColour(List) or
setColour(int, Colour) |
void |
setColour(int index,
Colour newColour)
Set a particular colour. |
void |
setColour(List<Colour> newColours)
Set the colours of a multi-colour item. |
void |
setFacing(String newFacing)
Set the facing direction of this item (typically furniture) |
void |
setHealth(BigDecimal newHealth)
|
void |
setItemID(int newID)
|
void |
setOwner(AbstractUser owner)
|
void |
setOwnerID(int ownerID1)
|
void |
setRoom(Room room)
|
void |
setRoomNumber(int i)
|
void |
setSlotHarsh(int slotNumber_force)
This is only to be used by addItem. |
void |
setSlotNumber(int slot)
|
void |
setType(InventoryItemType newType)
set the InventoryItemType of this item |
void |
setTypeID(int newTypeID)
|
void |
setX(double newX)
set the X ordinate of this item, within its container. |
void |
setY(double newY)
set the Y abcessa of this item, within its container. |
void |
setZ(double newZ)
set the Z ordinate of this item, within its container. |
org.json.JSONObject |
toJSON()
|
String |
toString()
This is an overriding method. |
void |
unequip()
un-equip an item (set it to be inactive) |
void |
unsetRoom(Room room)
remove the variable(s) set in the room to represent this item. |
Methods inherited from class org.starhope.appius.util.SimpleDataRecord |
---|
changed, checkStale, compareTo, finalize, getRecordLoader, getTimeLastChanged, getTimeLastSaved, isBeingLoaded, markAsLoaded, markAsSaved, markForReload, onRemove, onRetrieve, onStore, save, setRecordLoader |
Methods inherited from class java.lang.Object |
---|
clone, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
protected boolean active
final List<Colour> colours
private String facing
private BigDecimal health
protected int itemID
protected int ownerID
private int roomNumber
protected int slotNumber
protected InventoryItemType type
private double x
private double y
private double z
Constructor Detail |
---|
public InventoryItem()
public InventoryItem(RecordLoader<InventoryItem> loader)
loader
- the loaderMethod Detail |
---|
public static InventoryItem getByID(int idByWhichToGet)
idByWhichToGet
- inventory slot number
public static InventoryItem getByID(RecordLoader<InventoryItem> loader, int idByWhichToGet)
loader
- record loader to obtain the itemidByWhichToGet
- the database ID of an inventory item of any
kind
public void changeHealth(int delta)
delta
- the amount by which to change the healthprivate void checkEquipChange()
public void destroy()
public boolean equals(Object obj)
equals
in class SimpleDataRecord<InventoryItem>
Object.equals(java.lang.Object)
public void equip()
public int getCacheableID()
DataRecord
DataRecord.getCacheableID()
or a string identifier (
DataRecord.getCacheableIdent()
or both.
DataRecord.getCacheableID()
public String getCacheableIdent()
DataRecord
DataRecord.getCacheableID()
or a string identifier (
DataRecord.getCacheableIdent()
or both.
DataRecord.getCacheableIdent()
public Colour getColor()
public Colour getColour()
public Colour getColour(int index)
index
- the colour index position
public List<Colour> getColours()
public String getFacing()
public GenericItemReference getGenericItem()
GenericItemReference
of the same kind as
thispublic BigDecimal getHealth()
public int getID()
public ItemEffects getItemEffects() throws NotFoundException
ItemEffects
class for this item, if any
NotFoundException
- if no item effects are definedpublic int getItemID()
private AbstractUser getOnlineOwner() throws NotFoundException
NotFoundException
- if the owner isn't online (or isn't a
valid ownerID)public AbstractUser getOwner()
public int getOwnerID()
public int getRoomIndex()
public int getSlotNumber()
slotNumber
public String getSubversionRevision()
HasSubversionRevision
Return the Subversion revision level of this class's source code file, as supplied via the special "$Rev: " sequence.
As an example,the Subversion revision string for this file is "$Rev: 1968 $"
@Override public String getSubversionRevision () { return "$Rev: "; }
HasSubversionRevision.getSubversionRevision()
public InventoryItemType getType()
public int getTypeID()
public double getX()
public double getY()
public double getZ()
public int hashCode()
hashCode
in class SimpleDataRecord<InventoryItem>
Object.hashCode()
public boolean isActive()
private void reportBug(String bug, Throwable e)
AppiusClaudiusCaecus
with the slot
number for convenience in debugging
bug
- the bug stringe
- an exception thrown@Setter(getter="isActive") public void setActive(boolean beActive)
beActive
- true if the item is active@Deprecated public void setColour(Colour newColour)
setColour(List)
or
setColour(int, Colour)
newColour
- the new colour@Deprecated public void setColour(int newColour)
setColour(List)
or
setColour(int, Colour)
newColour
- the new colour, or -1 for no colour.public void setColour(int index, Colour newColour)
index
- the index position of the colournewColour
- the new colourpublic void setColour(List<Colour> newColours)
newColours
- the ordered set of colours@Setter public void setFacing(String newFacing)
newFacing
- the new facing directions@Setter public void setHealth(BigDecimal newHealth)
newHealth
- the health to set@Setter public void setItemID(int newID)
newID
- the item ID represented by this inventory slotpublic void setOwner(AbstractUser owner)
owner
- owner@Setter public void setOwnerID(int ownerID1)
ownerID1
- owner's userIDpublic void setRoom(Room room)
room
- the room in which this item is found@Setter(getter="getRoomIndex") public void setRoomNumber(int i)
i
- room index@Setter(getter="getSlotNumber") public void setSlotHarsh(int slotNumber_force)
slotNumber_force
- The retrieved slot number from an insert.public void setSlotNumber(int slot)
slot
- new slot numberpublic void setType(InventoryItemType newType)
InventoryItemType
of this item
newType
- the new type@Setter public void setTypeID(int newTypeID) throws GameLogicException
newTypeID
- the new type ID
GameLogicException
- if the type ID is not valid@Setter public void setX(double newX)
newX
- new X@Setter public void setY(double newY)
newY
- new Y@Setter public void setZ(double newZ)
newZ
- new Zpublic org.json.JSONObject toJSON()
CastsToJSON.toJSON()
public String toString()
toString
in class SimpleDataRecord<InventoryItem>
Object.toString()
public void unequip()
public void unsetRoom(Room room)
room
- some room
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |