net.sf.freecol.server.ai
Class AIColony

java.lang.Object
  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
static java.lang.String COPYRIGHT
           
static java.lang.String LICENSE
           
static java.lang.String REVISION
           
 
Fields inherited from class net.sf.freecol.server.ai.AIObject
id, uninitialized
 
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.
 void createAIGoods()
          Creates a list of the goods which should be shipped to and from this colony.
 void createTileImprovements()
          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 getAvailableTools()
          Returns the available amount of tools.
 Colony getColony()
          Gets the Colony this AIColony controls.
 java.lang.String getID()
          Gets the ID of this object.
 java.util.Iterator<TileImprovement> getTileImprovementIterator()
          Returns an Iterator over all the TileImprovements 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.
protected  void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
          Reads information for this object from an XML stream.
 void rearrangeWorkers(Connection connection)
          Rearranges the workers within this colony.
 void removeAIGoods(AIGoods ag)
          Removes the given AIGoods from this colony's list.
 void removeWish(Wish w)
           
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, getGame, getRandom, isUninitialized, readFromXML, readFromXMLElement, toXML, toXMLElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
See Also:
Constant Field Values

LICENSE

public static final java.lang.String LICENSE
See Also:
Constant Field Values

REVISION

public static final java.lang.String REVISION
See Also:
Constant Field Values
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

createTileImprovements

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

See Also:
TileImprovement

getTileImprovementIterator

public java.util.Iterator<TileImprovement> getTileImprovementIterator()
Returns an Iterator over all the TileImprovements needed by this colony.

Returns:
The Iterator.
See Also:
TileImprovement

removeWish

public void removeWish(Wish w)

createAIGoods

public void createAIGoods()
Creates a list of the goods which should be shipped to and from this colony.


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()

getAvailableTools

public int getAvailableTools()
Returns the available amount of tools.

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

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.

getID

public java.lang.String getID()
Gets the ID of this object.

Specified by:
getID in class AIObject
Returns:
The same ID as the Colony this AIColony stores AI-specific information for.

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

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

getXMLElementTagName

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

Returns:
"aiColony"