rails.game
Class StartPacket

java.lang.Object
  extended by rails.game.StartPacket

public class StartPacket
extends java.lang.Object

A Start Packet comprises a number of Start Items. The typical start packet must be completely sold out before normal share buying can start (but there are exceptions to this rule).


Field Summary
static java.lang.String DEFAULT_NAME
          Default name
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
StartPacket(java.lang.String name, java.lang.String roundClassName)
          Constructor.
 
Method Summary
 boolean areAllSold()
          Check if all items have bene sold.
 void configureFromXML(Tag tag)
          Configure the start packet from the contents of a <StartPacket> XML element.
 StartItem getFirstItem()
          Get the first start item.
 StartItem getFirstUnsoldItem()
          Get the first start item that has not yet been sold.
 StartItem getItem(int index)
           
 java.util.List<StartItem> getItems()
          Get the items of this start packet.
 int getMinimumIncrement()
           
 int getMinimumInitialIncrement()
           
 int getModulus()
           
 int getNumberOfItems()
           
 java.lang.String getRoundClassName()
          Get the name of the StartRound class that will sell out this packet.
 java.util.List<StartItem> getUnsoldItems()
          Get all not yet sold start items.
protected  void init(GameManagerI gameManager)
          This method must be called after all XML parsing has completed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NAME

public static final java.lang.String DEFAULT_NAME
Default name

See Also:
Constant Field Values

log

protected static org.apache.log4j.Logger log
Constructor Detail

StartPacket

StartPacket(java.lang.String name,
            java.lang.String roundClassName)
Constructor. Only takes the packet and class named. Actual initialisation is done in configureFromXML().

Parameters:
name - The start packet name.
roundClassName - The StartRound class name.
Method Detail

configureFromXML

public void configureFromXML(Tag tag)
                      throws ConfigurationException
Configure the start packet from the contents of a <StartPacket> XML element.

Parameters:
element - The <StartPacket> Element object.
Throws:
ConfigurationException - if anything goes wrong.

init

protected void init(GameManagerI gameManager)
This method must be called after all XML parsing has completed. It will set the relationships between all start packets and the start items that each one contains.


getItems

public java.util.List<StartItem> getItems()
Get the items of this start packet.

Returns:
The List of start items.

getItem

public StartItem getItem(int index)

getFirstItem

public StartItem getFirstItem()
Get the first start item. This one often gets a special treatment (price reduction).

Returns:
first item

getFirstUnsoldItem

public StartItem getFirstUnsoldItem()
Get the first start item that has not yet been sold. In many cases this is the only item that can be bought immediately.

Returns:
first unsold item

getUnsoldItems

public java.util.List<StartItem> getUnsoldItems()
Get all not yet sold start items.

Returns:
A List of all unsold items.

areAllSold

public boolean areAllSold()
Check if all items have bene sold.

Returns:
True if all items have been sold.

getRoundClassName

public java.lang.String getRoundClassName()
Get the name of the StartRound class that will sell out this packet.

Returns:
StartRound subclass name.

getNumberOfItems

public int getNumberOfItems()

getMinimumIncrement

public int getMinimumIncrement()

getMinimumInitialIncrement

public int getMinimumInitialIncrement()

getModulus

public int getModulus()