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
static int FULL_DELIVERY
           
static int IMPORTANT_DELIVERY
           
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
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ID_ATTRIBUTE_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.
 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.
 
Methods inherited from class net.sf.freecol.server.ai.AIObject
getAIMain, getGame, isUninitialized, readFromXML
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, hasAbility, hasAttribute, hasListeners, readFromXMLElement, removePropertyChangeListener, removePropertyChangeListener, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, writeAttribute, writeFreeColGameObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.freecol.server.ai.Transportable
getId
 

Field Detail

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
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.

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 objecy for debugging purposes.

getXMLElementTagName

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

Returns:
"aiGoods"