net.sf.freecol.server.ai
Class ColonyPlan

java.lang.Object
  extended by net.sf.freecol.server.ai.ColonyPlan

public class ColonyPlan
extends java.lang.Object

Objects of this class describes the plan the AI has for a Colony.

A ColonyPlan contains WorkLocationPlans which defines the production of each Building and ColonyTile.

See Also:
Colony

Nested Class Summary
 class ColonyPlan.Buildable
           
 class ColonyPlan.Production
           
 
Field Summary
static int ARTILLERY_PRIORITY
           
static int BUILDING_PRIORITY
           
static int CHURCH_PRIORITY
           
static int CUSTOMS_HOUSE_PRIORITY
           
static int DOCKS_PRIORITY
           
static int SCHOOL_PRIORITY
           
static int TOWN_HALL_PRIORITY
           
static int UPGRADE_PRIORITY
           
static int WAGON_TRAIN_PRIORITY
           
static int WAREHOUSE_PRIORITY
           
 
Constructor Summary
ColonyPlan(AIMain aiMain, Colony colony)
          Creates a new ColonyPlan.
ColonyPlan(AIMain aiMain, org.w3c.dom.Element element)
          Creates a new ColonyPlan.
 
Method Summary
 void adjustProductionAndManufacture()
           
 void adjustProductionAndManufactureFor(GoodsType rawMat, GoodsType producedGoods)
           
 void create()
          Creates a plan for this colony.
 AIMain getAIMain()
          Gets the main AI-object.
 ColonyPlan.Production getBestProduction(UnitType unitType)
           
 java.util.Iterator<BuildableType> getBuildable()
          Gets an Iterator for everything to be built in the Colony.
 GoodsType getBuildingReqGoods()
           
 Colony getColony()
          Gets the Colony this ColonyPlan controls.
 int getFoodProduction()
          Returns the production of food according to this plan.
 Game getGame()
          Get the Game this object is associated to.
 GoodsType getPrimaryRawMaterial()
           
 int getProductionOf(GoodsType goodsType)
          Returns the production of the given type of goods according to this plan.
 ColonyProfile getProfile()
          Get the Profile value.
 GoodsType getSecondaryRawMaterial()
           
 java.util.List<WorkLocationPlan> getSortedWorkLocationPlans()
          Returns the WorkLocationPlans associated with this ColonyPlan sorted by production in a decreasing order.
 java.util.List<WorkLocationPlan> getWorkLocationPlans()
          Returns the WorkLocationPlans associated with this ColonyPlan.
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 ColonyPlan.
 void setProfile(ColonyProfile newProfile)
          Set the Profile value.
 java.lang.String toString()
          Creates a String representation of this plan.
 org.w3c.dom.Element toXMLElement(org.w3c.dom.Document document)
          Creates an XML-representation of this object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DOCKS_PRIORITY

public static final int DOCKS_PRIORITY
See Also:
Constant Field Values

ARTILLERY_PRIORITY

public static final int ARTILLERY_PRIORITY
See Also:
Constant Field Values

CHURCH_PRIORITY

public static final int CHURCH_PRIORITY
See Also:
Constant Field Values

WAGON_TRAIN_PRIORITY

public static final int WAGON_TRAIN_PRIORITY
See Also:
Constant Field Values

SCHOOL_PRIORITY

public static final int SCHOOL_PRIORITY
See Also:
Constant Field Values

UPGRADE_PRIORITY

public static final int UPGRADE_PRIORITY
See Also:
Constant Field Values

CUSTOMS_HOUSE_PRIORITY

public static final int CUSTOMS_HOUSE_PRIORITY
See Also:
Constant Field Values

TOWN_HALL_PRIORITY

public static final int TOWN_HALL_PRIORITY
See Also:
Constant Field Values

WAREHOUSE_PRIORITY

public static final int WAREHOUSE_PRIORITY
See Also:
Constant Field Values

BUILDING_PRIORITY

public static final int BUILDING_PRIORITY
See Also:
Constant Field Values
Constructor Detail

ColonyPlan

public ColonyPlan(AIMain aiMain,
                  Colony colony)
Creates a new ColonyPlan.

Parameters:
aiMain - The main AI-object.
colony - The colony to make a ColonyPlan for.

ColonyPlan

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

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

getWorkLocationPlans

public java.util.List<WorkLocationPlan> getWorkLocationPlans()
Returns the WorkLocationPlans associated with this ColonyPlan.

Returns:
The list of WorkLocationPlans .

getSortedWorkLocationPlans

public java.util.List<WorkLocationPlan> getSortedWorkLocationPlans()
Returns the WorkLocationPlans associated with this ColonyPlan sorted by production in a decreasing order.

Returns:
The list of WorkLocationPlans .

getProfile

public final ColonyProfile getProfile()
Get the Profile value.

Returns:
a ColonyProfile value

setProfile

public final void setProfile(ColonyProfile newProfile)
Set the Profile value.

Parameters:
newProfile - The new Profile value.

getBuildable

public java.util.Iterator<BuildableType> getBuildable()
Gets an Iterator for everything to be built in the Colony.

Returns:
An iterator containing all the Buildable sorted by priority (highest priority first).

getAIMain

public AIMain getAIMain()
Gets the main AI-object.

Returns:
The main AI-object.

getGame

public Game getGame()
Get the Game this object is associated to.

Returns:
The Game.

create

public void create()
Creates a plan for this colony. That is; determines what type of goods each tile should produce and what type of goods that should be manufactured.


getProductionOf

public int getProductionOf(GoodsType goodsType)
Returns the production of the given type of goods according to this plan.

Parameters:
goodsType - The type of goods to check the production for.
Returns:
The maximum possible production of the given type of goods according to this ColonyPlan.

getFoodProduction

public int getFoodProduction()
Returns the production of food according to this plan.

Returns:
The maximum possible food production according to this ColonyPlan.

getBestProduction

public ColonyPlan.Production getBestProduction(UnitType unitType)

adjustProductionAndManufacture

public void adjustProductionAndManufacture()

adjustProductionAndManufactureFor

public void adjustProductionAndManufactureFor(GoodsType rawMat,
                                              GoodsType producedGoods)

getBuildingReqGoods

public GoodsType getBuildingReqGoods()

getPrimaryRawMaterial

public GoodsType getPrimaryRawMaterial()

getSecondaryRawMaterial

public GoodsType getSecondaryRawMaterial()

getColony

public Colony getColony()
Gets the Colony this ColonyPlan controls.

Returns:
The Colony.

toXMLElement

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

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

Parameters:
element - The XML-representation.

getXMLElementTagName

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

Returns:
"colonyPlan"

toString

public java.lang.String toString()
Creates a String representation of this plan.

Overrides:
toString in class java.lang.Object