net.sf.freecol.server.ai
Class WorkLocationPlan

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.ValuedAIObject
              extended by net.sf.freecol.server.ai.WorkLocationPlan
All Implemented Interfaces:
java.lang.Comparable<ValuedAIObject>

public class WorkLocationPlan
extends ValuedAIObject

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


Field Summary
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ID_ATTRIBUTE_TAG
 
Constructor Summary
WorkLocationPlan(AIMain aiMain, org.w3c.dom.Element element)
          Creates a new WorkLocationPlan.
WorkLocationPlan(AIMain aiMain, WorkLocation workLocation, GoodsType goodsType)
          Creates a new WorkLocationPlan.
 
Method Summary
 TileImprovementPlan createTileImprovementPlan()
          Gets a TileImprovementPlan which will improve the production of the goods type specified by this WorkLocationPlan.
 GoodsType getGoodsType()
          Gets the type of goods which should be produced at the WorkLocation.
 int getProductionOf(GoodsType goodsType)
          Gets the production of the given type of goods according to this WorkLocationPlan.
 WorkLocation getWorkLocation()
          Gets the WorkLocation this WorkLocationPlan controls.
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
 void readFromXMLElement(org.w3c.dom.Element element)
          Updates this object from an XML-representation of a WorkLocationPlan.
 void setGoodsType(GoodsType goodsType)
          Sets the type of goods to be produced at the WorkLocation.
 org.w3c.dom.Element toXMLElement(org.w3c.dom.Document document)
          Creates an XML-representation of this object.
 TileImprovementPlan updateTileImprovementPlan(TileImprovementPlan tip)
          Updates the given TileImprovementPlan.
 
Methods inherited from class net.sf.freecol.server.ai.ValuedAIObject
compareTo, getValue, setValue
 
Methods inherited from class net.sf.freecol.server.ai.AIObject
dispose, 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, removePropertyChangeListener, removePropertyChangeListener, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, writeAttribute, writeFreeColGameObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkLocationPlan

public WorkLocationPlan(AIMain aiMain,
                        WorkLocation workLocation,
                        GoodsType goodsType)
Creates a new WorkLocationPlan.

Parameters:
aiMain - The main AI-object.
workLocation - The WorkLocation to create a plan for.
goodsType - The goodsType to be produced on the workLocation using this plan.

WorkLocationPlan

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

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

createTileImprovementPlan

public TileImprovementPlan createTileImprovementPlan()
Gets a TileImprovementPlan which will improve the production of the goods type specified by this WorkLocationPlan.

Returns:
The TileImprovementPlan if there is an improvement, plow or build road, which will increase the production of the goods type specified by this plan. null gets returned if this plan is for a Building or that the Tile does not have an improvement.

updateTileImprovementPlan

public TileImprovementPlan updateTileImprovementPlan(TileImprovementPlan tip)
Updates the given TileImprovementPlan.

Parameters:
tip - The TileImprovementPlan to update.
Returns:
The same TileImprovementPlan-object as provided to the method or null if there is no more need for the improvement.

getWorkLocation

public WorkLocation getWorkLocation()
Gets the WorkLocation this WorkLocationPlan controls.

Returns:
The WorkLocation.

getProductionOf

public int getProductionOf(GoodsType goodsType)
Gets the production of the given type of goods according to this WorkLocationPlan. The plan has been created for either a ColonyTile or a Building. If this is a plan for a ColonyTile then the maximum possible production of the tile gets returned, while the Building-plans only returns a number used for identifying the value of the goods produced.

Parameters:
goodsType - The type of goods to get the production for.
Returns:
The production.

getGoodsType

public GoodsType getGoodsType()
Gets the type of goods which should be produced at the WorkLocation.

Returns:
The type of goods.
See Also:
Goods, WorkLocation

setGoodsType

public void setGoodsType(GoodsType goodsType)
Sets the type of goods to be produced at the WorkLocation.

Parameters:
goodsType - The type of goods.
See Also:
Goods, WorkLocation

toXMLElement

public org.w3c.dom.Element toXMLElement(org.w3c.dom.Document document)
Creates an XML-representation of this object.

Overrides:
toXMLElement in class FreeColObject
Parameters:
document - The Document in which the XML-representation should be created.
Returns:
The XML-representation.

readFromXMLElement

public void readFromXMLElement(org.w3c.dom.Element element)
Updates this object from an XML-representation of a WorkLocationPlan.

Overrides:
readFromXMLElement in class FreeColObject
Parameters:
element - The XML-representation.

getXMLElementTagName

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

Returns:
"workLocationPlan"