|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.model.FreeColObject
net.sf.freecol.server.ai.AIObject
net.sf.freecol.server.ai.mission.Mission
public abstract class Mission
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 | |
|---|---|
private AIUnit |
aiUnit
|
private static java.util.logging.Logger |
logger
|
protected static int |
MINIMUM_TRANSPORT_PRIORITY
|
protected static int |
NO_MORE_MOVES_LEFT
|
protected static int |
NO_PATH_TO_TARGET
|
protected static int |
NORMAL_TRANSPORT_PRIORITY
|
| Fields inherited from class net.sf.freecol.server.ai.AIObject |
|---|
uninitialized |
| Fields inherited from class net.sf.freecol.common.model.FreeColObject |
|---|
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE |
| 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. |
protected void |
exploreLostCityRumour(Connection connection)
Makes the unit explore the lost city rumour located on it's current Tile (if any). |
PathNode |
findNearestColony(Unit unit)
|
protected PathNode |
findTarget(int maxTurns)
Finds the best target to attack within the given range. |
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. |
protected void |
move(Connection connection,
Map.Direction direction)
Moves the unit owning this mission in the given direction. |
protected void |
moveButDontAttack(Connection connection,
Map.Direction direction)
|
protected void |
moveRandomly(Connection connection)
|
protected Map.Direction |
moveTowards(Connection connection,
PathNode pathNode)
Moves the unit owning this mission using the given pathNode. |
protected Map.Direction |
moveTowards(Connection connection,
Tile tile)
Moves the unit owning this mission towards the given Tile. |
protected void |
moveUnitToAmerica(Connection connection,
Unit unit)
|
protected void |
moveUnitToEurope(Connection connection,
Unit unit)
|
protected boolean |
sellCargoInEurope(Connection connection,
Unit carrier,
Goods goods)
|
protected void |
setAIUnit(AIUnit aiUnit)
Sets the AI-unit this mission has been created for. |
protected void |
unitLeavesShip(Connection connection,
Unit u)
|
protected boolean |
unloadCargoInColony(Connection connection,
Unit carrier,
Goods goods)
|
| Methods inherited from class net.sf.freecol.server.ai.AIObject |
|---|
getAIMain, getAIRandom, getGame, getXMLElementTagName, isUninitialized, readFromXML |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final java.util.logging.Logger logger
protected static final int MINIMUM_TRANSPORT_PRIORITY
protected static final int NORMAL_TRANSPORT_PRIORITY
protected static final int NO_PATH_TO_TARGET
protected static final int NO_MORE_MOVES_LEFT
private AIUnit aiUnit
| Constructor Detail |
|---|
public Mission(AIMain aiMain)
aiMain - The main AI-object.
public Mission(AIMain aiMain,
AIUnit aiUnit)
AIUnit.
aiMain - The main AI-object.aiUnit - The AIUnit this mission
is created for.
java.lang.NullPointerException - if aiUnit == null.| Method Detail |
|---|
protected Map.Direction moveTowards(Connection connection,
Tile tile)
Tile.
This is done in a loop until the tile is reached, there are no moves left,
the path to the target cannot be found or that the next step is not a move.
connection - The Connection to use
when communicating with the server.tile - The Tile the unit should move towards.
NO_MORE_MOVES_LEFT if there are no more moves left and
NO_PATH_TO_TARGET if there is no path to follow.
If a direction is returned, it is guaranteed that moving in that direction
is not an illegal move, but a direction also gets returned
if the resulting move would be an Unit.MoveType.ATTACK etc. A direction
can also be returned during the path, if the path has been blocked.
protected Map.Direction moveTowards(Connection connection,
PathNode pathNode)
pathNode.
This is done in a loop until the end of the path is reached, the next step is not a move
or when there are no moves left.
connection - The Connection to use
when communicating with the server.pathNode - The first node of the path.
NO_MORE_MOVES_LEFT if there are no more moves left.
If a direction is returned, it is guaranteed that moving in that direction
is not an illegal move. A directions gets returned when
moving in the given direction would not be a Unit.MoveType.MOVE or
Unit.MoveType.MOVE_HIGH_SEAS.protected void moveRandomly(Connection connection)
protected void move(Connection connection,
Map.Direction direction)
connection - The Connection to use
when communicating with the server.direction - The direction to move the unit.
protected void moveUnitToAmerica(Connection connection,
Unit unit)
protected void moveUnitToEurope(Connection connection,
Unit unit)
protected void moveButDontAttack(Connection connection,
Map.Direction direction)
protected void exploreLostCityRumour(Connection connection)
Tile (if any).
connection - The Connection to make the request on.protected PathNode findTarget(int maxTurns)
maxTurns - The maximum number of turns the unit is allowed
to spend in order to reach the target.
null if no target can
be found.public Tile getTransportDestination()
null if no transport is needed.public int getTransportPriority()
protected boolean unloadCargoInColony(Connection connection,
Unit carrier,
Goods goods)
protected boolean sellCargoInEurope(Connection connection,
Unit carrier,
Goods goods)
public void dispose()
dispose in class AIObjectpublic abstract void doMission(Connection connection)
connection - The Connection to the server.public boolean isValid()
true.public Unit getUnit()
Unit.public AIUnit getAIUnit()
AIUnit.protected void setAIUnit(AIUnit aiUnit)
aiUnit - The AIUnit.public java.lang.String getDebuggingInfo()
String. Should be
replaced by subclasses.
public void attack(Connection connection,
Unit unit,
Map.Direction direction)
protected void unitLeavesShip(Connection connection,
Unit u)
public boolean buyGoods(Connection connection,
Unit carrier,
GoodsType goodsType,
int amount)
public PathNode findNearestColony(Unit unit)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||