Package net.sf.freecol.server.ai.mission
Class IdleAtSettlementMission
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.server.ai.AIObject
-
- net.sf.freecol.server.ai.mission.Mission
-
- net.sf.freecol.server.ai.mission.IdleAtSettlementMission
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>,ObjectWithId
public class IdleAtSettlementMission extends Mission
Mission for idling in a settlement.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Loggerloggerprivate static java.lang.StringtagThe tag for this mission.static java.lang.StringTAG-
Fields inherited from class net.sf.freecol.server.ai.mission.Mission
AIUNITDIED, AIUNITNULL, MINIMUM_TRANSPORT_PRIORITY, NO_MORE_MOVES_LEFT, NO_PATH_TO_TARGET, NORMAL_TRANSPORT_PRIORITY, TARGETINVALID, TARGETNOTFOUND, TARGETNULL, TARGETOWNERSHIP, UNITNOTAPERSON, UNITNOTOFFENSIVE, UNITNOTONMAP
-
Fields inherited from class net.sf.freecol.server.ai.AIObject
initialized
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
-
Constructor Summary
Constructors Constructor Description IdleAtSettlementMission(AIMain aiMain, AIUnit aiUnit)Creates a mission for the givenAIUnit.IdleAtSettlementMission(AIMain aiMain, AIUnit aiUnit, FreeColXMLReader xr)Creates a newIdleAtSettlementMissionfrom a reader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MissiondoMission(LogBuilder lb)Performs the mission.LocationfindTarget()Finds a new target for this mission.intgetBaseTransportPriority()Get the base transport priority for the unit performing this mission.LocationgetTarget()Gets the target of this mission, if any.java.lang.StringgetXMLTagName()Get the serialization tag for this object.java.lang.StringinvalidReason()Why is this mission invalid? Mission subclasses must implement this routine, which probably should start by checking invalidAIUnitReason.booleanisOneTime()Should this mission be considered a mere fallback to be replaced at will? Missions are not one-time by default, true one-time missions must override this routine.private booleanisSafe()Is the unit in a safe location where it can idle, or should it move?voidsetTarget(Location target)Sets the target of this mission, if any.-
Methods inherited from class net.sf.freecol.server.ai.mission.Mission
dispose, findCircleTarget, getAIPlayer, getAIRandom, getAIUnit, getBestSettlement, getEuropeanAIPlayer, getPlayer, getTransportDestination, getUnit, invalidAIUnitReason, invalidAttackReason, invalidMissionReason, invalidMissionReason, invalidNewMissionReason, invalidTargetReason, invalidTargetReason, invalidTransportableReason, isTargetReason, isValid, lbAt, lbAttack, lbDodge, lbDone, lbDrop, lbFail, lbMove, lbRetarget, lbWait, moveRandomly, moveRandomlyTurn, readAttributes, resolveBlockage, retargetMission, setInitialized, toString, toXML, travelToTarget, writeAttributes
-
Methods inherited from class net.sf.freecol.server.ai.AIObject
addAIObjectWithId, checkIntegrity, checkIntegrity, copyIn, getAIMain, getGame, getSpecification, isDisposed, setGame, setSpecification
-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, equals, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getAbilities, getClassIndex, getDefenceModifiers, getDisplayObject, getFeatureContainer, getFreeColObjectClass, getFreeColObjectClassByName, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSuffix, getSuffix, hasAbility, hasAbility, hasAbility, hashCode, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readChild, readChildren, readFromXML, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setId, toXML, toXMLPartial, toXMLPartial, writeChildren
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
tag
private static final java.lang.String tag
The tag for this mission.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IdleAtSettlementMission
public IdleAtSettlementMission(AIMain aiMain, AIUnit aiUnit)
Creates a mission for the givenAIUnit.- Parameters:
aiMain- The main AI-object.aiUnit- TheAIUnitthis mission is created for.
-
IdleAtSettlementMission
public IdleAtSettlementMission(AIMain aiMain, AIUnit aiUnit, FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Creates a newIdleAtSettlementMissionfrom a reader.- Parameters:
aiMain- The main AI-object.aiUnit- TheAIUnitthis mission is created for.xr- The input stream containing the XML.- Throws:
javax.xml.stream.XMLStreamException- if a problem was encountered during parsing.- See Also:
FreeColObject.readFromXML(net.sf.freecol.common.io.FreeColXMLReader)
-
-
Method Detail
-
isSafe
private boolean isSafe()
Is the unit in a safe location where it can idle, or should it move?- Returns:
- True if the unit is safe.
-
getBaseTransportPriority
public int getBaseTransportPriority()
Get the base transport priority for the unit performing this mission.- Overrides:
getBaseTransportPriorityin classMission- Returns:
- A base transport priority.
-
getTarget
public Location getTarget()
Gets the target of this mission, if any.
-
setTarget
public void setTarget(Location target)
Sets the target of this mission, if any. The actual target is handled in the missions that really have them, this is a helper to make sure the unit is updated.
-
findTarget
public Location findTarget()
Finds a new target for this mission.- Specified by:
findTargetin classMission- Returns:
- A new target for this mission.
-
isOneTime
public boolean isOneTime()
Should this mission be considered a mere fallback to be replaced at will? Missions are not one-time by default, true one-time missions must override this routine.
-
invalidReason
public java.lang.String invalidReason()
Why is this mission invalid? Mission subclasses must implement this routine, which probably should start by checking invalidAIUnitReason. A mission can be invalid for a number of subclass-specific reasons. For example: a seek-and-destroy mission could be invalid because of a improved stance towards the targeted player.- Specified by:
invalidReasonin classMission- Returns:
- A reason for mission invalidity, or null if none found.
-
doMission
public Mission doMission(LogBuilder lb)
Performs the mission.
-
getXMLTagName
public java.lang.String getXMLTagName()
Get the serialization tag for this object.- Specified by:
getXMLTagNamein classFreeColObject- Returns:
- The tag.
-
-