net.sf.freecol.server.ai
Class AIColony

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

public class AIColony
extends AIObject

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


Field Summary
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ID_ATTRIBUTE_TAG
 
Constructor Summary
AIColony(AIMain aiMain, Colony colony)
          Creates a new AIColony.
AIColony(AIMain aiMain, org.w3c.dom.Element element)
          Creates a new AIColony.
AIColony(AIMain aiMain, java.lang.String id)
          Creates a new AIColony.
AIColony(AIMain aiMain, javax.xml.stream.XMLStreamReader in)
          Creates a new AIColony.
 
Method Summary
 void addGoodsWish(GoodsWish gw)
          Add a GoodsWish to the wish list.
static Unit bestUnitForWorkLocation(java.util.Collection<Unit> units, WorkLocation workLocation, GoodsType goodsType)
           
 boolean canBuildEquipment(EquipmentType equipmentType)
          Returns true if this AIColony can build the given type of equipment.
 void createAIGoods()
          Creates a list of the goods which should be shipped out of this colony.
 void createTileImprovementPlans()
          Creates a list of the Tile-improvements which will increase the production by this Colony.
 void dispose()
          Disposes this AIColony.
 java.util.Iterator<AIGoods> getAIGoodsIterator()
          Returns an Iterator of the goods to be shipped from this colony.
 int getAvailableGoods(GoodsType goodsType)
          Returns the available amount of the GoodsType given.
 Colony getColony()
          Gets the Colony this AIColony controls.
 ColonyPlan getColonyPlan()
           
 java.util.Iterator<TileImprovementPlan> getTileImprovementPlanIterator()
          Returns an Iterator over all the TileImprovementPlans needed by this colony.
 java.util.Iterator<Wish> getWishIterator()
          Gets an Iterator for every Wish the Colony has.
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
 boolean isBadlyDefended()
           
 void rearrangeWorkers(Connection connection)
          Rearranges the workers within this colony.
 void removeAIGoods(AIGoods ag)
          Removes the given AIGoods from this colony's list.
 boolean removeTileImprovementPlan(TileImprovementPlan plan)
          Removes a TileImprovementPlan from the list
 void removeWish(Wish w)
           
 
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, toString, wait, wait, wait
 

Constructor Detail

AIColony

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

Parameters:
aiMain - The main AI-object.
colony - The colony to make an AIObject for.

AIColony

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

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

AIColony

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

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.

AIColony

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

Parameters:
aiMain - The main AI-object.
id -
Method Detail

getColony

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

Returns:
The Colony.

dispose

public void dispose()
Disposes this AIColony.

Overrides:
dispose in class AIObject

getAIGoodsIterator

public java.util.Iterator<AIGoods> getAIGoodsIterator()
Returns an Iterator of the goods to be shipped from this colony. The item with the highest transport priority gets returned first by this Iterator.

Returns:
The Iterator.

getWishIterator

public java.util.Iterator<Wish> getWishIterator()
Gets an Iterator for every Wish the Colony has.

Returns:
The Iterator. The items with the highest value appears first in the Iterator
See Also:
Wish

createTileImprovementPlans

public void createTileImprovementPlans()
Creates a list of the Tile-improvements which will increase the production by this Colony.

See Also:
TileImprovementPlan

getTileImprovementPlanIterator

public java.util.Iterator<TileImprovementPlan> getTileImprovementPlanIterator()
Returns an Iterator over all the TileImprovementPlans needed by this colony.

Returns:
The Iterator.
See Also:
TileImprovementPlan

removeTileImprovementPlan

public boolean removeTileImprovementPlan(TileImprovementPlan plan)
Removes a TileImprovementPlan from the list

Returns:
True if it was successfully deleted, false otherwise

isBadlyDefended

public boolean isBadlyDefended()

removeWish

public void removeWish(Wish w)

addGoodsWish

public void addGoodsWish(GoodsWish gw)
Add a GoodsWish to the wish list.

Parameters:
gw - The GoodsWish to be added.

removeAIGoods

public void removeAIGoods(AIGoods ag)
Removes the given AIGoods from this colony's list. The AIGoods-object is not disposed as part of this operation. Use that method instead to remove the object completely (this method would then be called indirectly).

Parameters:
ag - The AIGoods to be removed.
See Also:
AIGoods.dispose()

createAIGoods

public void createAIGoods()
Creates a list of the goods which should be shipped out of this colony. This is the list getAIGoodsIterator() returns the Iterator for.


getAvailableGoods

public int getAvailableGoods(GoodsType goodsType)
Returns the available amount of the GoodsType given.

Returns:
The amount of tools not needed for the next thing we are building.

canBuildEquipment

public boolean canBuildEquipment(EquipmentType equipmentType)
Returns true if this AIColony can build the given type of equipment. Unlike the method of the Colony, this takes goods "reserved" for building or breeding purposes into account.

Parameters:
equipmentType - an EquipmentType value
Returns:
a boolean value
See Also:
Settlement.canBuildEquipment(EquipmentType equipmentType)

rearrangeWorkers

public void rearrangeWorkers(Connection connection)
Rearranges the workers within this colony. This is done according to the ColonyPlan, although minor adjustments can be done to increase production.

Parameters:
connection - The Connection to be used when communicating with the server.

bestUnitForWorkLocation

public static Unit bestUnitForWorkLocation(java.util.Collection<Unit> units,
                                           WorkLocation workLocation,
                                           GoodsType goodsType)

getColonyPlan

public ColonyPlan getColonyPlan()

getXMLElementTagName

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

Returns:
"aiColony"