rlgamekit.item
Class ItemCatalog

java.lang.Object
  extended by rlgamekit.item.ItemCatalog

public class ItemCatalog
extends java.lang.Object

A catalog structure for items.


Constructor Summary
ItemCatalog(ItemConfiguration config)
          Build a new item catalog with the given item configuartion
 
Method Summary
 void addItem(AbstractItem ait)
          Add an item to the item list.
 AbstractItem getAbstractItem(java.lang.String key)
          Items are addressed by their keys.
 AbstractItem[] getAllItemsSorted()
           
 ItemConfiguration getItemConfiguration()
           
 void moveItem(int index, int offset)
          Move an item in the item list.
 void read(java.io.BufferedReader reader, boolean itemsOnly)
           
 void removeItem(java.lang.String key)
          Remove an item from the item list.
 void write(java.io.Writer writer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ItemCatalog

public ItemCatalog(ItemConfiguration config)
Build a new item catalog with the given item configuartion

Parameters:
config - The item configuration to use for all itemsVec in this catalog.
Method Detail

getItemConfiguration

public ItemConfiguration getItemConfiguration()
Returns:
The item configuration of the items in this catalog.

getAbstractItem

public AbstractItem getAbstractItem(java.lang.String key)
Items are addressed by their keys.

Parameters:
key - The item key.
Returns:
The item for the key or null if not found.

getAllItemsSorted

public AbstractItem[] getAllItemsSorted()
Returns:
The items of this catalog in the catalogs natural order.

addItem

public void addItem(AbstractItem ait)
Add an item to the item list.

Parameters:
ait - The item to add.

removeItem

public void removeItem(java.lang.String key)
Remove an item from the item list.

Parameters:
key - The item key.

moveItem

public void moveItem(int index,
                     int offset)
Move an item in the item list. This method swaps the items from position index and index+offset

Parameters:
index - Base item index.
offset - Second item offset from base index.

read

public void read(java.io.BufferedReader reader,
                 boolean itemsOnly)
          throws java.io.IOException
Throws:
java.io.IOException

write

public void write(java.io.Writer writer)
           throws java.io.IOException
Throws:
java.io.IOException