org.starhope.appius.game.inventory
Class GenericItemReference

java.lang.Object
  extended by org.starhope.appius.util.SimpleDataRecord<GenericItemReference>
      extended by org.starhope.appius.game.inventory.GenericItemReference
All Implemented Interfaces:
com.whirlycott.cache.Cacheable, Serializable, Comparable<GenericItemReference>, AbstractItem, CTime, DataRecord, HasSubversionRevision

public class GenericItemReference
extends SimpleDataRecord<GenericItemReference>
implements AbstractItem

This represents an abstract/template item found in a store.

XXX Some day, the pricing information needs to be isolated in the shopping stores, and eliminate the Tootsville™-style default logic of all items having only one canonical price. The NPC storekeepers and such should set up the pricing and handle the trading, without having prices hard-coded universally for all instances of a given item.

Author:
brpocock@star-hope.org
See Also:
Serialized Form

Field Summary
private  boolean canTrade
          Whether this item can be traded, dropped, or given away.
private  Currency currency
          the currency units for the price
private  String description
          user-visible description
private  int effectsTypeID
          The ID of the ItemEffectsType to determine the ItemEffects for this item.
private  char equipSlot
          The effects slot for this item.
private  EquipType equipType
           Whether this item is an equippable item which traps a specific class of events is indicated by this field.
private  HealthType healthType
          Health interpretation is determined by this enumeration type.
private  int itemID
          unique database ID
private  InventoryItemType itemType
          the general class or slot of items to which this belongs.
private  BigDecimal price
          price in currency units
private  RarityRating rarity
          how rare is this item when items are randomly given out
private static long serialVersionUID
          Java serialization UID
private  String title
          user-visible title
 
Fields inherited from class org.starhope.appius.util.SimpleDataRecord
myLoader, timeLastChanged, timeLastSaved
 
Constructor Summary
GenericItemReference(RecordLoader<GenericItemReference> loader)
          WRITEME: Document this constructor brpocock@star-hope.org
 
Method Summary
 boolean canTrade()
          WRITEME: Document this method brpocock@star-hope.org
static GenericItemReference getByID(int itemID)
          Deprecated. user Nomenclator.getDataRecord(Class, int)
 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.
 Collection<ItemCollection> getCollections()
          XXX contains SQL, TODO check SQL
 Currency getCurrency()
           
 String getDescription()
          Get the user-visible description of the item
 int getEffectsTypeID()
           
 char getEquipSlot()
           
 EquipType getEquipType()
          Get the type of events which this item, when equipped, provides; e.g.
 HealthType getHealthType()
          Get the measurement type for interpreting this type of item's health indicator
 int getItemID()
           
 InventoryItemType getItemType()
           
private static int getMaxID()
          XXX: contains SQL
 BigDecimal getPrice()
           
static GenericItemReference getRandomItem(RarityRating minRarity, RarityRating maxRarity)
           
 RarityRating getRarity()
           
 String getSubversionRevision()
           Return the Subversion revision level of this class's source code file, as supplied via the special "$Rev: " sequence.
 String getTitle()
           
 void setCanTrade(boolean equals)
          WRITEME: Document this method brpocock@star-hope.org
 void setDescription(String string)
          WRITEME: Document this method brpocock@star-hope.org
 int setEffectsTypeID(int newEffectsType)
          set the ItemEffects class type ID pointer (via ItemEffectsType table indirection) for this item type.
 char setEquipSlot(char slot)
           Set the slot into which a piece of equipment is mounted.
 EquipType setEquipType(EquipType newEquipType)
          Set the type of events which this item, when equipped, provides; e.g.
 HealthType setHealthType(HealthType newHealthType)
          Set the measurement type for interpreting this type of item's health indicator.
 void setItemID(int newItemID)
           
 void setItemType(InventoryItemType inventoryItemType)
          WRITEME: Document this method brpocock@star-hope.org
 void setPrice(Currency newCurrency, BigDecimal newPrice)
           
 void setPrice(Currency units, int int1)
          WRITEME: Document this method brpocock@star-hope.org
 void setRarity(RarityRating newRarity)
           
 void setTitle(String newTitle)
           
 org.json.JSONObject toJSON()
          WRITEME: document this method (brpocock@star-hope.org, Aug 27, 2009)
 String toString()
           
 
Methods inherited from class org.starhope.appius.util.SimpleDataRecord
changed, checkStale, compareTo, equals, finalize, getRecordLoader, getTimeLastChanged, getTimeLastSaved, hashCode, isBeingLoaded, markAsLoaded, markAsSaved, markForReload, onRemove, onRetrieve, onStore, save, setRecordLoader
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.starhope.appius.util.DataRecord
checkStale, getRecordLoader, isBeingLoaded, markAsLoaded, markAsSaved, setRecordLoader
 
Methods inherited from interface org.starhope.appius.util.CTime
getTimeLastChanged, getTimeLastSaved
 
Methods inherited from interface com.whirlycott.cache.Cacheable
onRemove, onRetrieve, onStore
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Java serialization UID

See Also:
Constant Field Values

canTrade

private boolean canTrade
Whether this item can be traded, dropped, or given away. If this is false, then the item is stuck forever in inventory (barring NPC actions or similar) once it has been lodged there.


currency

private Currency currency
the currency units for the price


description

private String description
user-visible description


itemID

private int itemID
unique database ID


itemType

private InventoryItemType itemType
the general class or slot of items to which this belongs. Used principally for equipping items into particular slots and displaying inventory listings.


price

private BigDecimal price
price in currency units


rarity

private RarityRating rarity
how rare is this item when items are randomly given out


title

private String title
user-visible title


healthType

private HealthType healthType
Health interpretation is determined by this enumeration type.


equipType

private EquipType equipType

Whether this item is an equippable item which traps a specific class of events is indicated by this field.


effectsTypeID

private int effectsTypeID
The ID of the ItemEffectsType to determine the ItemEffects for this item.


equipSlot

private char equipSlot
The effects slot for this item. See discussion at setEquipSlot(char)

Constructor Detail

GenericItemReference

public GenericItemReference(RecordLoader<GenericItemReference> loader)
WRITEME: Document this constructor brpocock@star-hope.org

Parameters:
loader - WRITEME
Method Detail

getByID

@Deprecated
public static GenericItemReference getByID(int itemID)
Deprecated. user Nomenclator.getDataRecord(Class, int)

WRITEME: Document this method brpocock@star-hope.org

Parameters:
itemID - WRITEME
Returns:
WRITEME

getMaxID

private static int getMaxID()
XXX: contains SQL

Returns:
the maximum ID for an item

getRandomItem

public static GenericItemReference getRandomItem(RarityRating minRarity,
                                                 RarityRating maxRarity)
Parameters:
minRarity - the minimum rarity of an item to be chosen
maxRarity - the maximum rarity of an item to be chosen
Returns:
a random item with a rarity within that range

canTrade

public boolean canTrade()
WRITEME: Document this method brpocock@star-hope.org

Returns:
WRITEME

getCacheableID

public int getCacheableID()
                   throws NotFoundException
Description copied from interface: DataRecord
Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.

Specified by:
getCacheableID in interface DataRecord
Returns:
an unique ID number
Throws:
NotFoundException - if the item doesn't have a distinct numeric ID
See Also:
DataRecord.getCacheableID()

getCacheableIdent

public String getCacheableIdent()
Description copied from interface: DataRecord
Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.

Specified by:
getCacheableIdent in interface DataRecord
Returns:
an unique identifier string
See Also:
DataRecord.getCacheableIdent()

getCollections

public Collection<ItemCollection> getCollections()
XXX contains SQL, TODO check SQL

Specified by:
getCollections in interface AbstractItem
Returns:
the set of collections of which this item may be a part
See Also:
AbstractItem.getCollections()

getCurrency

public Currency getCurrency()
Specified by:
getCurrency in interface AbstractItem
Returns:
the currency measuring the price
See Also:
AbstractItem.getCurrency()

getDescription

public String getDescription()
Description copied from interface: AbstractItem
Get the user-visible description of the item

Specified by:
getDescription in interface AbstractItem
Returns:
the description of the item
See Also:
AbstractItem.getDescription()

getEffectsTypeID

public int getEffectsTypeID()
Returns:
the ID of the ItemEffectsType to determine the ItemEffects for this item.

getEquipSlot

public char getEquipSlot()
Returns:
The effects slot for this item. See discussion at setEquipSlot(char)

getEquipType

public EquipType getEquipType()
Get the type of events which this item, when equipped, provides; e.g. armour.

Returns:
the equipment slot type

getHealthType

public HealthType getHealthType()
Get the measurement type for interpreting this type of item's health indicator

Returns:
the type of interpretation for this item's health

getItemID

public int getItemID()
Specified by:
getItemID in interface AbstractItem
Returns:
the item's ID
See Also:
AbstractItem.getItemID()

getItemType

public InventoryItemType getItemType()
Returns:
the type of this item

getPrice

public BigDecimal getPrice()
Specified by:
getPrice in interface AbstractItem
Returns:
the item's price
See Also:
AbstractItem.getPrice()

getRarity

public RarityRating getRarity()
Specified by:
getRarity in interface AbstractItem
Returns:
the rarity rating of this item
See Also:
AbstractItem.getRarity()

getSubversionRevision

public String getSubversionRevision()
Description copied from interface: 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: ";
 }
 

Specified by:
getSubversionRevision in interface HasSubversionRevision
Returns:
The Subversion revision level for this class's source code file.
See Also:
HasSubversionRevision.getSubversionRevision()

getTitle

public String getTitle()
Specified by:
getTitle in interface AbstractItem
Returns:
the title of the item
See Also:
AbstractItem.getTitle()

setCanTrade

public void setCanTrade(boolean equals)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
equals - WRITEME

setDescription

public void setDescription(String string)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
string - WRITEME

setEffectsTypeID

public int setEffectsTypeID(int newEffectsType)
set the ItemEffects class type ID pointer (via ItemEffectsType table indirection) for this item type. Note that if the item is currently set to return a getEquipType() of EquipType EquipType.SILENT, setting a non-null handler will force it to EquipType.PASSIVE. Likewise, setting this to a -1 (null) handler ID will revert to EquipType.SILENT.

Parameters:
newEffectsType - the ID of the new ItemEffectsType to be applied
Returns:
the new effects type ID

setEquipSlot

public char setEquipSlot(char slot)

Set the slot into which a piece of equipment is mounted. If an equipment item has no effects (purely cosmetic), it mounts into equipment slot ' ' (EquipType.SILENT); if it has passive effects but does not consume user actions, it goes in slot '.' ( EquipType.PASSIVE); if it consumes a user input action type of some kind, it goes into a slot which will typically be a single letter or digit. Punctuation marks are reserved for future globally reserved values, so please stick with 'A'..'Z' & '0'..'9' for game-specific purposes in defining such slots.

Note that equipment slots are not the same as either inventory slots (see InventoryItem.getSlotNumber(), which uniquely define a specific item instance throughout the game universe, nor are they the same as clothing/furniture item types (InventoryItemType), which are used to define slots and valences for clothing and equipment with regards to how and where it is held or mounted, and not what interface actions it consumes and/or alters.

The Commands.do_click(JSONObject, org.starhope.appius.user.AbstractUser, org.starhope.appius.game.Room) handler will redirect events of the type Shift + Click to slot “1,” Control (Command) + Click to slot “2,“ and Alt (Option) + Click to slot “3.”

Parameters:
slot - the slot into which this type of item is placed (equpment slot)
Returns:
the slot into which this type of item is placed (equipment slot)

setEquipType

public EquipType setEquipType(EquipType newEquipType)
Set the type of events which this item, when equipped, provides; e.g. armour (PASSIVE) or a tool (ACTIVE)

Parameters:
newEquipType - the equipment slot type
Returns:
the new equipment slot type

setHealthType

public HealthType setHealthType(HealthType newHealthType)
Set the measurement type for interpreting this type of item's health indicator.

Parameters:
newHealthType - The measurement type to be used to interpret this type of item's health indicator.
Returns:
the new health type

setItemID

public void setItemID(int newItemID)
Specified by:
setItemID in interface AbstractItem
Parameters:
newItemID - the new item ID
See Also:
AbstractItem.setItemID(int)

setItemType

public void setItemType(InventoryItemType inventoryItemType)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
inventoryItemType - WRITEME

setPrice

public void setPrice(Currency newCurrency,
                     BigDecimal newPrice)
Specified by:
setPrice in interface AbstractItem
Parameters:
newPrice - the new price
newCurrency - the currency units
See Also:
AbstractItem.setPrice(Currency,java.math.BigDecimal)

setPrice

public void setPrice(Currency units,
                     int int1)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
units - WRITEME
int1 - WRITEME

setRarity

public void setRarity(RarityRating newRarity)
Parameters:
newRarity - the rarity to set

setTitle

public void setTitle(String newTitle)
Specified by:
setTitle in interface AbstractItem
Parameters:
newTitle - the new title
See Also:
AbstractItem.setTitle(java.lang.String)

toJSON

public org.json.JSONObject toJSON()
Description copied from interface: AbstractItem
WRITEME: document this method (brpocock@star-hope.org, Aug 27, 2009)

Specified by:
toJSON in interface AbstractItem
Returns:
WRITEME
See Also:
AbstractItem.toJSON()

toString

public String toString()
Overrides:
toString in class SimpleDataRecord<GenericItemReference>
See Also:
Object.toString()