Package net.sf.freecol.server.ai.mission
Class TransportMission
- 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.TransportMission
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>,ObjectWithId
public final class TransportMission extends Mission
Mission for transporting units and goods on a carrier.- See Also:
Unit
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classTransportMission.CargoResult
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<Cargo>cargoesA list ofCargos to work on.private static intDESTINATION_UPPER_BOUNDInsist transport lists remain simple by imposing an upper bound on the distinct destination locations to visit.private static java.util.logging.Loggerloggerprivate static intMINIMUM_GOLD_TO_STAY_IN_EUROPEprivate static java.lang.Stringtagstatic java.lang.StringTAGprivate LocationtargetThe current target location to travel to.private static java.lang.StringTARGET_TAG-
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 TransportMission(AIMain aiMain, AIUnit aiUnit)Creates a mission for the givenAIUnit.TransportMission(AIMain aiMain, AIUnit aiUnit, FreeColXMLReader xr)Creates a newTransportMissionfrom a reader.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleanaddCargo(Cargo cargo, int index, LogBuilder lb)Add the given Cargo to the cargoes list.private voidcheckCargoes(LogBuilder lb)Checks for invalid cargoes, and units and goods on board but not in the cargoes list.private java.lang.StringclearCargoes()Clears all the cargoes.intdestinationCapacity()How many more destinations are desirable on the current cargoes list? Must be public! This is checked in European AI player.private intdestinationCount()Count distinct non-adjacent destinations in a list of cargoes.voiddispose()Disposes of thisMission.MissiondoMission(LogBuilder lb)Performs the mission.private voiddoTransport(LogBuilder lb)Perform the transport load/unload operations on arrival at the target for the top cargo.private voiddropTransportable(TransportableAIObject t)If this carrier is the current carrier of a transportable, drop it.private booleandumpCargo(Cargo cargo, LogBuilder lb)Dump a currently carried cargo.booleandumpTransportable(TransportableAIObject t, LogBuilder lb)Dump a transportable.LocationfindTarget()Finds a new target for this mission.booleanforceCollection(AIUnit aiu, LogBuilder lb)Drop all collections so that cargo is delivered only, then collect this unit.private CargogetBestCargo(Unit carrier)What is the best transportable for a carrier to collect?LocationgetTarget()Gets the target of this mission, if any.TilegetTransportDestination()Gets the destination of a required transport.LocationgetTransportTarget(TransportableAIObject t)Get the collection location for an uncollected transportable.intgetTransportTurns(TransportableAIObject t)Get the expected turns for an uncollected transport Public so that mobile transportables (units) can renege on transport if they find themselves better able to get there themselves.java.lang.StringgetXMLTagName()Get the serialization tag for this object.private static java.lang.StringinvalidCargoReason(Cargo cargo)Why would this mission be invalid with a given cargo? Checks the cargo locations.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.StringinvalidUnitReason(AIUnit aiUnit)Why would an TransportMission be invalid with the given unit?private booleanisCarrying(TransportableAIObject t)Checks if the carrier using this mission is carrying the givenTransportableAIObject.booleanisEmpty()Is there nothing currently queued for this carrier?booleanisTransporting(TransportableAIObject t)Is a transportable waiting for delivery on the cargoes list?CargomakeCargo(TransportableAIObject t, LogBuilder lb)For a given transportable, work out where the carrier has to go to advance the cargo (target), and what to do there (mode), allowing a newCargoto be defined.private voidoptimizeCargoes(LogBuilder lb)Sets the current target.private booleanqueueCargo(Cargo cargo, boolean requireMatch, LogBuilder lb)Incrementally queue a cargo to the cargoes list.booleanqueueTransportable(TransportableAIObject t, boolean requireMatch, LogBuilder lb)Wrapper for queueCargo.protected voidreadAttributes(FreeColXMLReader xr)Reads the attributes of this object from an XML stream.protected voidreadChild(FreeColXMLReader xr)Reads a single child object.protected voidreadChildren(FreeColXMLReader xr)Reads the children of this object from an XML stream.private voidremoveCargo(Cargo cargo)Removes the given Cargo from the cargoes list.booleanremoveTransportable(TransportableAIObject t)Removes the givenTransportableAIObjectfrom the cargo list.private booleanrequeueCargo(Cargo cargo, LogBuilder lb)Requeue an existing cargo.booleanrequeueTransportable(TransportableAIObject t, LogBuilder lb)Retargets a transportable that should already be on board the carrier.private floatscoreCargoOrder(Location initialLocation, java.util.List<Cargo> order)Calculates a score for a proposed list ofCargos using the current unit.voidsetTarget(Location target)Sets the target of this mission, if any.private booleanshouldAttack(Unit other)Decide if this unit has a good chance of defeating another.booleanspaceAvailable(Cargo cargo)Is there space available for a new cargo?booleanspaceAvailable(TransportableAIObject t)Is there space available for a new cargo?voidsuppressEuropeanTrade(GoodsType type, LogBuilder lb)Suppress European trade in a type of goods which is about to be boycotted.private booleantAdd(Cargo cargo, int index)Adds a cargo to the cargoes list.private voidtakeTransportable(TransportableAIObject t)If this carrier is the not the current carrier of a transportable, make it so.private java.util.List<Cargo>tClear()Clears the cargoes list.private java.util.List<Cargo>tCopy()Gets the cargoes.private CargotFind(TransportableAIObject t)Find aCargowith the givenTransportableAIObject.private CargotFirst()Gets the first cargo.java.lang.StringtoFullString()More verbose version of toString().private booleantRemove(Cargo cargo)Remove a cargo from the cargoes list.private voidtRetarget()Reset the carrier target after a change to the first cargo.private TransportMission.CargoResulttryCargo(Cargo cargo, LogBuilder lb)Check aCargofor continued validity and whether action is needed at the current location.private java.util.List<Cargo>tSet(java.util.List<Cargo> nxt, boolean setSpace)Sets the cargoes to a new list.private inttSize()Gets the size of the cargoes.private voidtSpace()Sets the spaceLeft fields in the cargoes.private java.util.List<Cargo>unwrapCargoes(java.util.List<Cargo> ts)Unwrap a wrapped list of cargoes.private java.util.List<Cargo>wrapCargoes()Wrap up the compatible cargoes in a list.protected voidwriteAttributes(FreeColXMLWriter xw)Write the attributes of this object to a stream.protected voidwriteChildren(FreeColXMLWriter xw)Write the children of this object to a stream.-
Methods inherited from class net.sf.freecol.server.ai.mission.Mission
findCircleTarget, getAIPlayer, getAIRandom, getAIUnit, getBaseTransportPriority, 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.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, readFromXML, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setId, toXML, toXMLPartial, toXMLPartial
-
-
-
-
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
- See Also:
- Constant Field Values
-
DESTINATION_UPPER_BOUND
private static final int DESTINATION_UPPER_BOUND
Insist transport lists remain simple by imposing an upper bound on the distinct destination locations to visit.- See Also:
- Constant Field Values
-
MINIMUM_GOLD_TO_STAY_IN_EUROPE
private static final int MINIMUM_GOLD_TO_STAY_IN_EUROPE
- See Also:
- Constant Field Values
-
cargoes
private final java.util.List<Cargo> cargoes
A list ofCargos to work on.
-
target
private Location target
The current target location to travel to.
-
TARGET_TAG
private static final java.lang.String TARGET_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TransportMission
public TransportMission(AIMain aiMain, AIUnit aiUnit)
Creates a mission for the givenAIUnit.- Parameters:
aiMain- The main AI-object.aiUnit- TheAIUnitthis mission is created for.
-
TransportMission
public TransportMission(AIMain aiMain, AIUnit aiUnit, FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Creates a newTransportMissionfrom 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
-
isCarrying
private boolean isCarrying(TransportableAIObject t)
Checks if the carrier using this mission is carrying the givenTransportableAIObject.- Parameters:
t- TheTransportableAIObjectto check.- Returns:
- True if the carrier is carrying the transportable.
-
isTransporting
public boolean isTransporting(TransportableAIObject t)
Is a transportable waiting for delivery on the cargoes list?- Parameters:
t- TheTransportableAIObjectto check.- Returns:
- True if the transportable is queued in this mission.
-
shouldAttack
private boolean shouldAttack(Unit other)
Decide if this unit has a good chance of defeating another. If there is cargo aboard, be more conservative. FIXME: magic numbers to the spec.- Parameters:
other- The otherUnitto attack.- Returns:
- True if the attack should proceed.
-
tCopy
private java.util.List<Cargo> tCopy()
Gets the cargoes.- Returns:
- A copy of the list of cargoes.
-
tClear
private java.util.List<Cargo> tClear()
Clears the cargoes list.- Returns:
- The old cargoes list.
-
tSet
private java.util.List<Cargo> tSet(java.util.List<Cargo> nxt, boolean setSpace)
Sets the cargoes to a new list.- Parameters:
nxt- The new cargoes list.setSpace- If true, call tSpace to reset the space left values.- Returns:
- The old cargoes list.
-
tSize
private int tSize()
Gets the size of the cargoes.- Returns:
- The size of the cargoes.
-
tFind
private Cargo tFind(TransportableAIObject t)
Find aCargowith the givenTransportableAIObject.- Parameters:
t- TheTransportableAIObjectto look for.- Returns:
- The
Cargofound, or null if none found.
-
tFirst
private Cargo tFirst()
Gets the first cargo.- Returns:
- The first valid cargo, or null if none found.
-
tAdd
private boolean tAdd(Cargo cargo, int index)
Adds a cargo to the cargoes list.- Parameters:
cargo- TheCargoto add.index- The position to add it.- Returns:
- True if the addition succeeded or the cargo was already present.
-
tRemove
private boolean tRemove(Cargo cargo)
Remove a cargo from the cargoes list.- Parameters:
cargo- TheCargoto remove.- Returns:
- True if the remove succeeded.
-
tSpace
private void tSpace()
Sets the spaceLeft fields in the cargoes. To be called with synchronized (cargoes).
-
tRetarget
private void tRetarget()
Reset the carrier target after a change to the first cargo.
-
destinationCount
private int destinationCount()
Count distinct non-adjacent destinations in a list of cargoes.- Returns:
- The number of distinct destinations.
-
destinationCapacity
public int destinationCapacity()
How many more destinations are desirable on the current cargoes list? Must be public! This is checked in European AI player.- Returns:
- The number of desired extra destinations.
-
dropTransportable
private void dropTransportable(TransportableAIObject t)
If this carrier is the current carrier of a transportable, drop it.- Parameters:
t- TheTransportableAIObjectto check.
-
takeTransportable
private void takeTransportable(TransportableAIObject t)
If this carrier is the not the current carrier of a transportable, make it so.- Parameters:
t- TheTransportableAIObjectto check.
-
getTransportTarget
public Location getTransportTarget(TransportableAIObject t)
Get the collection location for an uncollected transportable. Public so that mobile transportables (units) can move to the collection point.- Parameters:
t- TheTransportableAIObjectto collect.- Returns:
- The collection
Location, or null if not found.
-
getTransportTurns
public int getTransportTurns(TransportableAIObject t)
Get the expected turns for an uncollected transport Public so that mobile transportables (units) can renege on transport if they find themselves better able to get there themselves.- Parameters:
t- TheTransportableAIObjectto collect.- Returns:
- The expected transport turns.
-
wrapCargoes
private java.util.List<Cargo> wrapCargoes()
Wrap up the compatible cargoes in a list. O(N^2) alas.- Returns:
- A wrapped list of cargoes.
-
unwrapCargoes
private java.util.List<Cargo> unwrapCargoes(java.util.List<Cargo> ts)
Unwrap a wrapped list of cargoes.- Parameters:
ts- The list ofCargos to unwrap.- Returns:
- The unwrapped list of cargoes.
-
clearCargoes
private java.lang.String clearCargoes()
Clears all the cargoes.- Returns:
- A message about the cargoes being cleared.
-
isEmpty
public boolean isEmpty()
Is there nothing currently queued for this carrier?- Returns:
- True if there is no work allocated to this carrier.
-
makeCargo
public Cargo makeCargo(TransportableAIObject t, LogBuilder lb)
For a given transportable, work out where the carrier has to go to advance the cargo (target), and what to do there (mode), allowing a newCargoto be defined. AIUnit cargo is harder than AIGoods, because AIUnits might have their own inland paths, and thus we need to consider drop nodes.- Parameters:
t- TheTransportableAIObjectto consider.lb- ALogBuilderto log to.- Returns:
- A new
Cargodefining the action to take with theTransportableAIObject, or null if impossible.
-
addCargo
private boolean addCargo(Cargo cargo, int index, LogBuilder lb)
Add the given Cargo to the cargoes list.- Parameters:
cargo- TheCargoto add.index- The index of where to add the cargo.lb- ALogBuilderto log to.- Returns:
- True if the cargo was added.
-
removeCargo
private void removeCargo(Cargo cargo)
Removes the given Cargo from the cargoes list.- Parameters:
cargo- TheCargoto remove.
-
spaceAvailable
public boolean spaceAvailable(Cargo cargo)
Is there space available for a new cargo?- Parameters:
cargo- TheCargoto check.- Returns:
- True if there is space available for this cargo.
-
spaceAvailable
public boolean spaceAvailable(TransportableAIObject t)
Is there space available for a new cargo?- Parameters:
t- TheTransportableAIObjectto check.- Returns:
- True if there is space available for this transportable.
-
queueCargo
private boolean queueCargo(Cargo cargo, boolean requireMatch, LogBuilder lb)
Incrementally queue a cargo to the cargoes list. If the carrier is at the collection point favour immediate collection. Otherwise try to place it with other cargoes with the same target, but do not break the space restrictions. If this does not work, it has to go at the end.- Parameters:
cargo- The newCargoto add.requireMatch- Fail if an existing destination is not matched.lb- ALogBuilderto log to.- Returns:
- True if the cargo was queued.
-
dumpCargo
private boolean dumpCargo(Cargo cargo, LogBuilder lb)
Dump a currently carried cargo.- Parameters:
cargo- TheCargoto dump.lb- ALogBuilderto log to.- Returns:
- True if the cargo is no longer on board and not on the transport list, or is on board but is scheduled to be dumped.
-
requeueCargo
private boolean requeueCargo(Cargo cargo, LogBuilder lb)
Requeue an existing cargo. Typically done when the target changes.- Parameters:
cargo- TheCargoto requeue.lb- ALogBuilderto log to.- Returns:
- True if the queuing succeeded.
-
checkCargoes
private void checkCargoes(LogBuilder lb)
Checks for invalid cargoes, and units and goods on board but not in the cargoes list. On exit from this routine, every cargo on board should be on the cargoes list but the list is not necessarily going to be in a sensible order.- Parameters:
lb- ALogBuilderto log to.
-
tryCargo
private TransportMission.CargoResult tryCargo(Cargo cargo, LogBuilder lb)
Check aCargofor continued validity and whether action is needed at the current location.- Parameters:
cargo- TheCargoto check.lb- ALogBuilderto log to.- Returns:
- TCONTINUE if the
Cargoshould continue, TDONE if it has completed, TFAIL if it has failed, TNEXT if it has progressed to the next stage, TRETRY if a blockage has occurred and it should be retried,
-
doTransport
private void doTransport(LogBuilder lb)
Perform the transport load/unload operations on arrival at the target for the top cargo.- Parameters:
lb- ALogBuilderto log to.
-
scoreCargoOrder
private float scoreCargoOrder(Location initialLocation, java.util.List<Cargo> order)
Calculates a score for a proposed list ofCargos using the current unit. Disallows routes that would overfill the carrier. Useful for comparing proposed cargo delivery routes. The score is based primarily on the number of turns it takes, but to break ties we also consider the hold*turn product to reduce the risk of losses due to enemy action.- Parameters:
initialLocation- The initialLocation.order- An ordering ofCargos.- Returns:
- A score for the cargo ordering.
-
optimizeCargoes
private void optimizeCargoes(LogBuilder lb)
Sets the current target. Tries all permutations of cargoes and picks the fastest/safest one. Leaves the cargoes in the order they are expected to execute, with valid spaceLeft values.- Parameters:
lb- ALogBuilderto log to.
-
getBestCargo
private Cargo getBestCargo(Unit carrier)
What is the best transportable for a carrier to collect?- Parameters:
carrier- The carrierUnitto consider.- Returns:
- The best available new
Cargo, or null if none found.
-
invalidUnitReason
private static java.lang.String invalidUnitReason(AIUnit aiUnit)
Why would an TransportMission be invalid with the given unit?- Parameters:
aiUnit- TheAIUnitto test.- Returns:
- A reason why the mission would be invalid with the unit, or null if none found.
-
invalidCargoReason
private static java.lang.String invalidCargoReason(Cargo cargo)
Why would this mission be invalid with a given cargo? Checks the cargo locations. A location becomes invalid if: - step is a null location - step is disposed - step is a captured settlement- Parameters:
cargo- TheCargoto test.- Returns:
- A reason why the mission would be invalid, or null if none found.
-
invalidMissionReason
public static java.lang.String invalidMissionReason(AIUnit aiUnit)
Why would this mission be invalid with the given AI unit?- Parameters:
aiUnit- TheAIUnitto check.- Returns:
- A reason for mission invalidity, or null if none found.
-
invalidMissionReason
public static java.lang.String invalidMissionReason(AIUnit aiUnit, Location loc)
Why would this mission be invalid with the given AI unit and location?- Parameters:
aiUnit- TheAIUnitto check.loc- TheLocationto check.- Returns:
- A reason for invalidity, or null if none found.
-
removeTransportable
public boolean removeTransportable(TransportableAIObject t)
Removes the givenTransportableAIObjectfrom the cargo list.- Parameters:
t- TheTransportableAIObjectto remove.- Returns:
- True if the removal succeeded.
-
requeueTransportable
public boolean requeueTransportable(TransportableAIObject t, LogBuilder lb)
Retargets a transportable that should already be on board the carrier.- Parameters:
t- TheTransportableAIObjectto retarget.lb- ALogBuilderto log to.- Returns:
- True if the retargeting succeeded.
-
queueTransportable
public boolean queueTransportable(TransportableAIObject t, boolean requireMatch, LogBuilder lb)
Wrapper for queueCargo. Public for the benefit of EuropeanAIPlayer.allocateTransportables and CashInTreasureTrain.doMission.- Parameters:
t- TheTransportableAIObjectto add.requireMatch- Fail if an existing destination is not matched.lb- ALogBuilderto log to.- Returns:
- True if the transportable was queued.
-
dumpTransportable
public boolean dumpTransportable(TransportableAIObject t, LogBuilder lb)
Dump a transportable.- Parameters:
t- TheTransportableAIObjectto dump.lb- ALogBuilderto log to.- Returns:
- True if the transportable is no longer on board, queued, or was reset to be dumped at the next stop.
-
forceCollection
public boolean forceCollection(AIUnit aiu, LogBuilder lb)
Drop all collections so that cargo is delivered only, then collect this unit. Useful for prioritizing treasure collection.- Parameters:
aiu- TheAIUnitto collect.lb- ALogBuilderto log to.- Returns:
- True if the unit was queued.
-
suppressEuropeanTrade
public void suppressEuropeanTrade(GoodsType type, LogBuilder lb)
Suppress European trade in a type of goods which is about to be boycotted.- Parameters:
type- TheGoodsTypeto suppress.lb- ALogBuilderto log to.
-
getTransportDestination
public Tile 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 classMission- 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.
-
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.
-
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.
-
toFullString
public java.lang.String toFullString()
More verbose version of toString().- Returns:
- A summary of this mission including its transportables.
-
writeAttributes
protected 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 classMission- Parameters:
xw- TheFreeColXMLWriterto write to.- Throws:
javax.xml.stream.XMLStreamException- if there are any problems writing to the stream.
-
writeChildren
protected void writeChildren(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
Write the children of this object to a stream. To be overridden if required by any object that has children and uses the toXML(FreeColXMLWriter, String) call.- Overrides:
writeChildrenin classFreeColObject- Parameters:
xw- TheFreeColXMLWriterto write to.- Throws:
javax.xml.stream.XMLStreamException- if there are any problems writing to the stream.
-
readAttributes
protected void readAttributes(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the attributes of this object from an XML stream.- Overrides:
readAttributesin classMission- Parameters:
xr- TheFreeColXMLReaderto read from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
readChildren
protected void readChildren(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the children of this object from an XML stream.- Overrides:
readChildrenin classFreeColObject- Parameters:
xr- TheFreeColXMLReaderto read from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
readChild
protected void readChild(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads a single child object. Subclasses must override to read their enclosed elements. This particular instance of the routine always throws XMLStreamException because we should never arrive here. However it is very useful to always call super.readChild() when an unexpected tag is encountered, as the exception thrown here provides some useful debugging context.- Overrides:
readChildin classFreeColObject- Parameters:
xr- TheFreeColXMLReaderto read from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
getXMLTagName
public java.lang.String getXMLTagName()
Get the serialization tag for this object.- Specified by:
getXMLTagNamein classFreeColObject- Returns:
- The tag.
-
-