net.sf.freecol.server.ai.goal
Class GotoAdjacentGoal
java.lang.Object
net.sf.freecol.common.model.FreeColObject
net.sf.freecol.server.ai.AIObject
net.sf.freecol.server.ai.goal.Goal
net.sf.freecol.server.ai.goal.GotoAdjacentGoal
- All Implemented Interfaces:
- GoalConstants
public class GotoAdjacentGoal
- extends Goal
|
Field Summary |
private static java.util.logging.Logger |
logger
|
private Tile |
target
|
|
Method Summary |
java.lang.String |
getGoalDescription()
Returns a string describing just this goal. |
protected java.util.Iterator<AIUnit> |
getOwnedAIUnitsIterator()
Since internal implementation details may vary,
each Goal will define an iterator over all of its units. |
protected java.util.Iterator<Goal> |
getSubGoalIterator()
Since internal implementation details may vary,
each Goal will define an iterator over all of its subgoals. |
protected void |
plan()
This is the method that actually does the planning for this goal. |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Reads information for this object from an XML stream. |
protected void |
removeUnit(AIUnit u)
Ensures that a unit moved to another Goal is properly removed from this. |
protected void |
toXMLImpl(javax.xml.stream.XMLStreamWriter out)
Writes this object to an XML stream. |
| Methods inherited from class net.sf.freecol.server.ai.goal.Goal |
addUnit, addUnitToParent, cancelGoal, canYieldUnit, doPlanning, getAbsoluteWeight, getDebugDescription, getParentWeight, getWeight, getXMLElementTagName, getYieldedUnitWeight, isFinished, needsPlanning, normalizeSubGoalWeights, requestWorker, setNeedsPlanningRecursive, setWeight, validateOwnedUnits, yieldUnit |
| 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, readAttributes, readChildren, readFromArrayElement, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXMLElement, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, setId, toArrayElement, toArrayElement, toListElement, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, writeAttribute, writeAttributes, writeChildren, writeFreeColGameObject |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
private static final java.util.logging.Logger logger
target
private Tile target
GotoAdjacentGoal
public GotoAdjacentGoal(AIPlayer p,
Goal g,
float w,
AIUnit u,
Tile t)
getOwnedAIUnitsIterator
protected java.util.Iterator<AIUnit> getOwnedAIUnitsIterator()
- Description copied from class:
Goal
- Since internal implementation details may vary,
each Goal will define an iterator over all of its units.
- Specified by:
getOwnedAIUnitsIterator in class Goal
- Returns:
- An Iterator over all
AIUnit currently managed by this goal.
getSubGoalIterator
protected java.util.Iterator<Goal> getSubGoalIterator()
- Description copied from class:
Goal
- Since internal implementation details may vary,
each Goal will define an iterator over all of its subgoals.
- Specified by:
getSubGoalIterator in class Goal
- Returns:
- An Iterator over all currently existing subgoals.
removeUnit
protected void removeUnit(AIUnit u)
- Description copied from class:
Goal
- Ensures that a unit moved to another Goal is properly removed from this.
If a unit is removed from this goal via
Goal.yieldUnit(UnitType,AIObject),
or if the Unit contained in the AIUnit no longer is valid,
this method is called to clean up any remaining references to the unit.
Any implementation of this will need to iterate over all AIUnit object
references used by this goal, and remove those that equal the given parameter.
- Specified by:
removeUnit in class Goal
- Parameters:
u - The AIUnit supposed to be removed from this goal.
plan
protected void plan()
- Description copied from class:
Goal
- This is the method that actually does the planning for this goal.
It should contain:
- calling
Goal.validateOwnedUnits() to remove AIUnits no longer
containing a valid unit
- putting units on the
Goal.availableUnitsList to work
- eventually by adding it to one of the subgoals, or
- by adding it back to the
AIPlayer, or
- last but not least, by spending their movement points for some internal mission
- requesting new units (via a method like
Goal.requestWorker(GoodsType,int))
- managing direct subgoals, including:
- creating new ones, if necessary
- cancelling those with isFinished()==true
- setting new weights using
Goal.setWeight(float)
- setting our own isFinished status
- Specified by:
plan in class Goal
getGoalDescription
public java.lang.String getGoalDescription()
- Description copied from class:
Goal
- Returns a string describing just this goal.
An implementing class may override this method to add specialized information.
Used by
getDebugDescription.
- Overrides:
getGoalDescription in class Goal
- Returns:
- a string describing this goal
toXMLImpl
protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
- Description copied from class:
Goal
- Writes this object to an XML stream.
- Specified by:
toXMLImpl in class Goal
- 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
- Description copied from class:
Goal
- Reads information for this object from an XML stream.
- Specified by:
readFromXMLImpl in class Goal
- Parameters:
in - The input stream with the XML.
- Throws:
javax.xml.stream.XMLStreamException - if there are any problems reading from the
stream.