Package net.sf.freecol.server.ai.mission
Class UnitSeekAndDestroyMission
- 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.UnitSeekAndDestroyMission
 
 
 
 
- 
- All Implemented Interfaces:
- java.lang.Comparable<FreeColObject>,- ObjectWithId
 
 public final class UnitSeekAndDestroyMission extends Mission Mission for attacking a specific target, be it a Unit or a Settlement.
- 
- 
Field SummaryFields Modifier and Type Field Description private static java.util.logging.Loggerloggerprivate static java.lang.StringtagThe tag for this mission.static java.lang.StringTAGprivate LocationtargetThe object we are trying to destroy.private static java.lang.StringTARGET_TAGprivate LocationtransportTargetThe object we are trying to destroy.- 
Fields inherited from class net.sf.freecol.server.ai.mission.MissionAIUNITDIED, 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.AIObjectinitialized
 - 
Fields inherited from class net.sf.freecol.common.model.FreeColObjectARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
 
- 
 - 
Constructor SummaryConstructors Constructor Description UnitSeekAndDestroyMission(AIMain aiMain, AIUnit aiUnit, FreeColXMLReader xr)Creates a newUnitSeekAndDestroyMissionfrom a reader.UnitSeekAndDestroyMission(AIMain aiMain, AIUnit aiUnit, Location target)Creates a mission for the givenAIUnit.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MissiondoMission(LogBuilder lb)Performs the mission.static LocationextractTarget(AIUnit aiUnit, PathNode path)Extract a valid target for this mission from a path.static LocationfindMissionTarget(AIUnit aiUnit, int range, boolean deferOK)Finds a suitable seek-and-destroy target for an AI unit.LocationfindTarget()Finds a new target for this mission.private static PathNodefindTargetPath(AIUnit aiUnit, int range, boolean deferOK)Finds a suitable seek-and-destroy target path for an AI unit.intgetBaseTransportPriority()Get the base transport priority for the unit performing this mission.private static GoalDecidergetGoalDecider(AIUnit aiUnit, boolean deferOK)Gets aGoalDeciderfor finding the best colonyTile, optionally falling back to the nearest colony.LocationgetTarget()Gets the target of this mission, if any.LocationgetTransportDestination()Gets the destination of a required transport.java.lang.StringgetXMLTagName()Get the serialization tag for this object.static java.lang.StringinvalidMissionReason(AIUnit aiUnit)Why would this mission be invalid with the given AI unit?static java.lang.StringinvalidMissionReason(AIUnit aiUnit, Location loc)Why would this mission be invalid with the given AI unit and location?java.lang.StringinvalidReason()Why is this mission invalid? Mission subclasses must implement this routine, which probably should start by checking invalidAIUnitReason.private static java.lang.StringinvalidSettlementReason(AIUnit aiUnit, Settlement settlement)Why would a UnitSeekAndDestroyMission be invalid with the given unit and settlement.private static java.lang.StringinvalidTargetReason(AIUnit aiUnit, Unit unit)Why would a UnitSeekAndDestroyMission be invalid with the given unit and target unit.private static java.lang.StringinvalidUnitReason(AIUnit aiUnit)Why would a UnitSeekAndDestroyMission be invalid with the given unit.protected voidreadAttributes(FreeColXMLReader xr)Reads the attributes of this object from an XML stream.static intscorePath(AIUnit aiUnit, PathNode path)Evaluate a potential seek and destroy mission for a given unit to a given tile.private static intscoreSettlementPath(AIUnit aiUnit, PathNode path, Settlement settlement)Scores a potential attack on a settlement.private static intscoreUnitPath(AIUnit aiUnit, PathNode path, Unit defender)Scores a potential attack on a unit.voidsetTarget(Location target)Sets the target of this mission, if any.protected voidwriteAttributes(FreeColXMLWriter xw)Write the attributes of this object to a stream.- 
Methods inherited from class net.sf.freecol.server.ai.mission.Missiondispose, findCircleTarget, getAIPlayer, getAIRandom, getAIUnit, getBestSettlement, getEuropeanAIPlayer, getPlayer, getUnit, invalidAIUnitReason, invalidAttackReason, invalidNewMissionReason, invalidTargetReason, invalidTargetReason, invalidTransportableReason, isOneTime, isTargetReason, isValid, lbAt, lbAttack, lbDodge, lbDone, lbDrop, lbFail, lbMove, lbRetarget, lbWait, moveRandomly, moveRandomlyTurn, resolveBlockage, retargetMission, setInitialized, toString, toXML, travelToTarget
 - 
Methods inherited from class net.sf.freecol.server.ai.AIObjectaddAIObjectWithId, checkIntegrity, checkIntegrity, copyIn, getAIMain, getGame, getSpecification, isDisposed, setGame, setSpecification
 - 
Methods inherited from class net.sf.freecol.common.model.FreeColObjectaddAbility, 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- 
loggerprivate static final java.util.logging.Logger logger 
 - 
TAGpublic static final java.lang.String TAG - See Also:
- Constant Field Values
 
 - 
tagprivate static final java.lang.String tag The tag for this mission.- See Also:
- Constant Field Values
 
 - 
targetprivate Location target The object we are trying to destroy. This can be a eitherSettlementor aUnit.
 - 
transportTargetprivate Location transportTarget The object we are trying to destroy. This can be a eitherSettlementor aUnit.
 - 
TARGET_TAGprivate static final java.lang.String TARGET_TAG - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
UnitSeekAndDestroyMissionpublic UnitSeekAndDestroyMission(AIMain aiMain, AIUnit aiUnit, Location target) Creates a mission for the givenAIUnit.- Parameters:
- aiMain- The main AI-object.
- aiUnit- The- AIUnitthis mission is created for.
- target- The object we are trying to destroy. This can be either a- Settlementor a- Unit.
 
 - 
UnitSeekAndDestroyMissionpublic UnitSeekAndDestroyMission(AIMain aiMain, AIUnit aiUnit, FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException Creates a newUnitSeekAndDestroyMissionfrom a reader.- Parameters:
- aiMain- The main AI-object.
- aiUnit- The- AIUnitthis 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- 
extractTargetpublic static Location extractTarget(AIUnit aiUnit, PathNode path) Extract a valid target for this mission from a path.- Parameters:
- aiUnit- The- AIUnitto perform the mission.
- path- A- PathNodeto extract a target from.
- Returns:
- A target for this mission, or null if none found.
 
 - 
scoreSettlementPathprivate static int scoreSettlementPath(AIUnit aiUnit, PathNode path, Settlement settlement) Scores a potential attack on a settlement. Do not cheat and look inside the settlement. Just use visible facts about it. FIXME: if we are the REF and there is a significant Tory population inside, assume traitors have briefed us.- Parameters:
- aiUnit- The- AIUnitto do the mission.
- path- The- PathNodeto take to the settlement.
- settlement- The- Settlementto attack.
- Returns:
- A score of the desirability of the mission.
 
 - 
scoreUnitPathprivate static int scoreUnitPath(AIUnit aiUnit, PathNode path, Unit defender) Scores a potential attack on a unit.- Parameters:
- aiUnit- The- AIUnitto do the mission.
- path- The- PathNodeto take to the settlement.
- defender- The- Unitto attack.
- Returns:
- A score of the desirability of the mission.
 
 - 
scorePathpublic static int scorePath(AIUnit aiUnit, PathNode path) Evaluate a potential seek and destroy mission for a given unit to a given tile.- Parameters:
- aiUnit- The- AIUnitto do the mission.
- path- A- PathNodeto take to the target.
- Returns:
- A score for the proposed mission.
 
 - 
getGoalDeciderprivate static GoalDecider getGoalDecider(AIUnit aiUnit, boolean deferOK) Gets aGoalDeciderfor finding the best colonyTile, optionally falling back to the nearest colony.- Parameters:
- aiUnit- The- AIUnitthat is searching.
- deferOK- Not used in this mission.
- Returns:
- A suitable GoalDecider.
 
 - 
findTargetPathprivate static PathNode findTargetPath(AIUnit aiUnit, int range, boolean deferOK) Finds a suitable seek-and-destroy target path for an AI unit.- Parameters:
- aiUnit- The- AIUnitto find a target for.
- range- An upper bound on the number of moves.
- deferOK- Not implemented in this mission.
- Returns:
- A path to the target, or null if none found.
 
 - 
findMissionTargetpublic static Location findMissionTarget(AIUnit aiUnit, int range, boolean deferOK) Finds a suitable seek-and-destroy target for an AI unit.- Parameters:
- aiUnit- The- AIUnitto find a target for.
- range- An upper bound on the number of moves.
- deferOK- Not implemented in this mission.
- Returns:
- A suitable target, or null if none found.
 
 - 
invalidUnitReasonprivate static java.lang.String invalidUnitReason(AIUnit aiUnit) Why would a UnitSeekAndDestroyMission be invalid with the given unit.- Parameters:
- aiUnit- The- AIUnitto test.
- Returns:
- A reason why the mission would be invalid, or null if none found.
 
 - 
invalidSettlementReasonprivate static java.lang.String invalidSettlementReason(AIUnit aiUnit, Settlement settlement) Why would a UnitSeekAndDestroyMission be invalid with the given unit and settlement.- Parameters:
- aiUnit- The- AIUnitto seek-and-destroy with.
- settlement- The- Settlementto test.
- Returns:
- A reason why the mission would be invalid, or null if none found.
 
 - 
invalidTargetReasonprivate static java.lang.String invalidTargetReason(AIUnit aiUnit, Unit unit) Why would a UnitSeekAndDestroyMission be invalid with the given unit and target unit.- Parameters:
- aiUnit- The- AIUnitto seek-and-destroy with.
- unit- The target- Unitto test.
- Returns:
- A reason why the mission would be invalid, or null if none found.
 
 - 
invalidMissionReasonpublic static java.lang.String invalidMissionReason(AIUnit aiUnit) Why would this mission be invalid with the given AI unit?- Parameters:
- aiUnit- The- AIUnitto check.
- Returns:
- A reason for mission invalidity, or null if none found.
 
 - 
invalidMissionReasonpublic static java.lang.String invalidMissionReason(AIUnit aiUnit, Location loc) Why would this mission be invalid with the given AI unit and location?- Parameters:
- aiUnit- The- AIUnitto check.
- loc- The- Locationto check.
- Returns:
- A reason for invalidity, or null if none found.
 
 - 
getBaseTransportPrioritypublic int getBaseTransportPriority() Get the base transport priority for the unit performing this mission.- Overrides:
- getBaseTransportPriorityin class- Mission
- Returns:
- A base transport priority.
 
 - 
getTransportDestinationpublic Location getTransportDestination() Gets the destination of a required transport. Override this in the child mission classes if there is a useful intermediate point to deliver the unit distinct from the target.- Overrides:
- getTransportDestinationin class- Mission
- Returns:
- The mission target, or null if the mission is invalid, otherwise lacks a target (e.g. UnitWanderHostile), or the unit does not need transport.
 
 - 
getTargetpublic Location getTarget() Gets the target of this mission, if any.
 - 
setTargetpublic 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.
 - 
findTargetpublic Location findTarget() Finds a new target for this mission.- Specified by:
- findTargetin class- Mission
- Returns:
- A new target for this mission.
 
 - 
invalidReasonpublic 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 class- Mission
- Returns:
- A reason for mission invalidity, or null if none found.
 
 - 
doMissionpublic Mission doMission(LogBuilder lb) Performs the mission.
 - 
writeAttributesprotected void writeAttributes(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException Write the attributes of this object to a stream. To be overridden if required by any object that has attributes and uses the toXML(FreeColXMLWriter, String) call.- Overrides:
- writeAttributesin class- Mission
- Parameters:
- xw- The- FreeColXMLWriterto write to.
- Throws:
- javax.xml.stream.XMLStreamException- if there are any problems writing to the stream.
 
 - 
readAttributesprotected void readAttributes(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException Reads the attributes of this object from an XML stream.- Overrides:
- readAttributesin class- Mission
- Parameters:
- xr- The- FreeColXMLReaderto read from.
- Throws:
- javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
 
 - 
getXMLTagNamepublic java.lang.String getXMLTagName() Get the serialization tag for this object.- Specified by:
- getXMLTagNamein class- FreeColObject
- Returns:
- The tag.
 
 
- 
 
-