net.sf.freecol.server.ai.mission
Class Mission

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.mission.Mission
Direct Known Subclasses:
BuildColonyMission, CashInTreasureTrainMission, DefendSettlementMission, IdleAtColonyMission, IndianBringGiftMission, IndianDemandMission, PioneeringMission, PrivateerMission, ScoutingMission, TransportMission, UnitSeekAndDestroyMission, UnitWanderHostileMission, UnitWanderMission, WishRealizationMission, WorkInsideColonyMission

public abstract class Mission
extends AIObject

A mission describes what a unit should do; attack, build colony, wander etc. Every AIUnit should have a mission. By extending this class, you create different missions.


Field Summary
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ID_ATTRIBUTE_TAG
 
Constructor Summary
Mission(AIMain aiMain)
          Creates a mission.
Mission(AIMain aiMain, AIUnit aiUnit)
          Creates a mission for the given AIUnit.
 
Method Summary
 void attack(Connection connection, Unit unit, Map.Direction direction)
           
 boolean buyGoods(Connection connection, Unit carrier, GoodsType goodsType, int amount)
           
 void dispose()
          Disposes this mission by removing any references to it.
abstract  void doMission(Connection connection)
          Performs the mission.
 PathNode findNearestColony(Unit unit)
           
 AIUnit getAIUnit()
          Gets the AI-unit this mission has been created for.
 java.lang.String getDebuggingInfo()
          Gets debugging information about this mission.
 Tile getTransportDestination()
          Returns the destination of a required transport.
 int getTransportPriority()
          Returns the priority of getting the unit to the transport destination.
 Unit getUnit()
          Gets the unit this mission has been created for.
 boolean isValid()
          Checks if this mission is still valid to perform.
 
Methods inherited from class net.sf.freecol.server.ai.AIObject
getAIMain, getGame, getXMLElementTagName, 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

Mission

public Mission(AIMain aiMain)
Creates a mission.

Parameters:
aiMain - The main AI-object.

Mission

public Mission(AIMain aiMain,
               AIUnit aiUnit)
Creates a mission for the given AIUnit.

Parameters:
aiMain - The main AI-object.
aiUnit - The AIUnit this mission is created for.
Throws:
java.lang.NullPointerException - if aiUnit == null.
Method Detail

getTransportDestination

public Tile getTransportDestination()
Returns the destination of a required transport.

Returns:
The destination of a required transport or null if no transport is needed.

getTransportPriority

public int getTransportPriority()
Returns the priority of getting the unit to the transport destination.

Returns:
The priority.

dispose

public void dispose()
Disposes this mission by removing any references to it.

Overrides:
dispose in class AIObject

doMission

public abstract void doMission(Connection connection)
Performs the mission. This method should be implemented by a subclass.

Parameters:
connection - The Connection to the server.

isValid

public boolean isValid()
Checks if this mission is still valid to perform.

A mission can be invalidated for a number of reasons. For example: a seek-and-destroy mission can be invalidated in case the relationship towards the targeted player improves.

Returns:
The default value: true.

getUnit

public Unit getUnit()
Gets the unit this mission has been created for.

Returns:
The Unit.

getAIUnit

public AIUnit getAIUnit()
Gets the AI-unit this mission has been created for.

Returns:
The AIUnit.

getDebuggingInfo

public java.lang.String getDebuggingInfo()
Gets debugging information about this mission. This string is a short representation of this object's state.

Returns:
An empty String. Should be replaced by subclasses.

attack

public void attack(Connection connection,
                   Unit unit,
                   Map.Direction direction)

buyGoods

public boolean buyGoods(Connection connection,
                        Unit carrier,
                        GoodsType goodsType,
                        int amount)

findNearestColony

public PathNode findNearestColony(Unit unit)