net.sf.freecol.server.ai
Class AIGoods

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.server.ai.AIObject
          extended by net.sf.freecol.server.ai.AIGoods
All Implemented Interfaces:
Transportable

public class AIGoods
extends AIObject
implements Transportable

Objects of this class contains AI-information for a single Goods.


Field Summary
private  Location destination
           
static int FULL_DELIVERY
           
private  Goods goods
           
static int IMPORTANT_DELIVERY
           
private static java.util.logging.Logger logger
           
static int TOOLS_FOR_BUILDING
          The extra priority value added to the base value of TOOLS_FOR_COLONY_PRIORITY if a building is lacking tools.
static int TOOLS_FOR_COLONY_PRIORITY
          The priority of tools intended for a Colony with none stored at the present (and with no special needs).
static int TOOLS_FOR_IMPROVEMENT
          The extra priority value added to the base value of TOOLS_FOR_COLONY_PRIORITY for each ColonyTile needing a terrain improvement.
static int TOOLS_FOR_PIONEER
          The extra priority value added to the base value of TOOLS_FOR_COLONY_PRIORITY if a Pioneer is lacking tools
private  AIUnit transport
           
private  int transportPriority
           
 
Fields inherited from class net.sf.freecol.server.ai.AIObject
uninitialized
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG
 
Constructor Summary
AIGoods(AIMain aiMain, org.w3c.dom.Element element)
          Creates a new AIGoods.
AIGoods(AIMain aiMain, Location location, GoodsType type, int amount, Location destination)
          Creates a new AIGoods.
AIGoods(AIMain aiMain, java.lang.String id)
          Creates a new AIGoods.
AIGoods(AIMain aiMain, javax.xml.stream.XMLStreamReader in)
          Creates a new AIGoods.
 
Method Summary
 void abortWish(Wish w)
          Aborts the given Wish.
 void dispose()
          Disposes this object.
 Goods getGoods()
          Gets the goods this AIGoods is controlling.
 AIUnit getTransport()
          Gets the carrier responsible for transporting this Transportable.
 Location getTransportDestination()
          Returns the destination for this Transportable.
 Locatable getTransportLocatable()
          Gets the Locatable which should be transported.
 int getTransportPriority()
          Gets the priority of transporting this Transportable to it's destination.
 Location getTransportSource()
          Returns the source for this Transportable.
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
 void increaseTransportPriority()
          Increases the transport priority of this Transportable.
protected  void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
          Reads information for this object from an XML stream.
 void setGoods(Goods goods)
          Sets the goods this AIGoods is controlling.
 void setTransport(AIUnit transport)
          Sets the carrier responsible for transporting this Transportable.
 void setTransportPriority(int transportPriority)
          Sets the priority of getting the goods to the getTransportDestination().
 java.lang.String toString()
          Returns a String-representation of this object.
protected  void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          Writes this object to an XML stream.
 
Methods inherited from class net.sf.freecol.server.ai.AIObject
getAIMain, getAIRandom, getGame, isUninitialized, readFromXML
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, getSpecification, hasAbility, hasAttribute, hasListeners, readAttributes, readAttributes, readChild, readChild, readChildren, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXMLElement, readFromXMLImpl, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setId, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, writeAttribute, writeAttributes, writeChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.freecol.server.ai.Transportable
getId
 

Field Detail

logger

private static final java.util.logging.Logger logger

IMPORTANT_DELIVERY

public static final int IMPORTANT_DELIVERY
See Also:
Constant Field Values

FULL_DELIVERY

public static final int FULL_DELIVERY
See Also:
Constant Field Values

TOOLS_FOR_COLONY_PRIORITY

public static final int TOOLS_FOR_COLONY_PRIORITY
The priority of tools intended for a Colony with none stored at the present (and with no special needs).

See Also:
Constant Field Values

TOOLS_FOR_IMPROVEMENT

public static final int TOOLS_FOR_IMPROVEMENT
The extra priority value added to the base value of TOOLS_FOR_COLONY_PRIORITY for each ColonyTile needing a terrain improvement.

See Also:
Constant Field Values

TOOLS_FOR_PIONEER

public static final int TOOLS_FOR_PIONEER
The extra priority value added to the base value of TOOLS_FOR_COLONY_PRIORITY if a Pioneer is lacking tools

See Also:
Constant Field Values

TOOLS_FOR_BUILDING

public static final int TOOLS_FOR_BUILDING
The extra priority value added to the base value of TOOLS_FOR_COLONY_PRIORITY if a building is lacking tools. The number of tools is also added to the total amount.

See Also:
Constant Field Values

goods

private Goods goods

destination

private Location destination

transportPriority

private int transportPriority

transport

private AIUnit transport
Constructor Detail

AIGoods

public AIGoods(AIMain aiMain,
               Location location,
               GoodsType type,
               int amount,
               Location destination)
Creates a new AIGoods.

Parameters:
aiMain - The main AI-object.
location - The location of the goods.
type - The type of goods.
amount - The amount of goods.
destination - The destination of the goods. This is the Location to which the goods should be transported.

AIGoods

public AIGoods(AIMain aiMain,
               org.w3c.dom.Element element)
Creates a new AIGoods.

Parameters:
aiMain - The main AI-object.
element - An Element containing an XML-representation of this object.

AIGoods

public AIGoods(AIMain aiMain,
               javax.xml.stream.XMLStreamReader in)
        throws javax.xml.stream.XMLStreamException
Creates a new AIGoods.

Parameters:
aiMain - The main AI-object.
in - The input stream containing the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

AIGoods

public AIGoods(AIMain aiMain,
               java.lang.String id)
Creates a new AIGoods.

Parameters:
aiMain - The main AI-object.
id - The unique ID of this object.
Method Detail

abortWish

public void abortWish(Wish w)
Aborts the given Wish.

Specified by:
abortWish in interface Transportable
Parameters:
w - The Wish to be aborted.

getTransportSource

public Location getTransportSource()
Returns the source for this Transportable. This is normally the location of the locatable.

Specified by:
getTransportSource in interface Transportable
Returns:
The source for this Transportable.

getTransportDestination

public Location getTransportDestination()
Returns the destination for this Transportable. This can either be the target Tile of the transport or the target for the entire Transportable's mission. The target for the tansport is determined by TransportMission in the latter case.

Specified by:
getTransportDestination in interface Transportable
Returns:
The destination for this Transportable.

getTransportLocatable

public Locatable getTransportLocatable()
Gets the Locatable which should be transported.

Specified by:
getTransportLocatable in interface Transportable
Returns:
The Locatable.

getTransportPriority

public int getTransportPriority()
Gets the priority of transporting this Transportable to it's destination.

Specified by:
getTransportPriority in interface Transportable
Returns:
The priority of the transport.

increaseTransportPriority

public void increaseTransportPriority()
Increases the transport priority of this Transportable. This method gets called every turn the Transportable have not been put on a carrier's transport list.

Specified by:
increaseTransportPriority in interface Transportable

getTransport

public AIUnit getTransport()
Gets the carrier responsible for transporting this Transportable.

Specified by:
getTransport in interface Transportable
Returns:
The AIUnit which has this Transportable in it's transport list. This Transportable has not been scheduled for transport if this value is null.

dispose

public void dispose()
Disposes this object.

Overrides:
dispose in class AIObject

setTransport

public void setTransport(AIUnit transport)
Sets the carrier responsible for transporting this Transportable.

Specified by:
setTransport in interface Transportable
Parameters:
transport - The AIUnit which has this Transportable in it's transport list. This Transportable has not been scheduled for transport if this value is null.

setTransportPriority

public void setTransportPriority(int transportPriority)
Sets the priority of getting the goods to the getTransportDestination().

Parameters:
transportPriority - The priority.

getGoods

public Goods getGoods()
Gets the goods this AIGoods is controlling.

Returns:
The Goods.

setGoods

public void setGoods(Goods goods)
Sets the goods this AIGoods is controlling.

Parameters:
goods - The Goods.

toXMLImpl

protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
                  throws javax.xml.stream.XMLStreamException
Writes this object to an XML stream.

Specified by:
toXMLImpl in class FreeColObject
Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readFromXMLImpl

protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
                        throws javax.xml.stream.XMLStreamException
Reads information for this object from an XML stream.

Overrides:
readFromXMLImpl in class FreeColObject
Parameters:
in - The input stream with the XML.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems reading from the stream.

toString

public java.lang.String toString()
Returns a String-representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
A String representing this object for debugging purposes.

getXMLElementTagName

public static java.lang.String getXMLElementTagName()
Returns the tag name of the root element representing this object.

Returns:
"aiGoods"