|
|||||||||
| 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.AIUnit
public class AIUnit
Objects of this class contains AI-information for a single Unit.
The method doMission(Connection) is called once each turn, by
AIPlayer.startWorking(), to perform the assigned
Mission. Most of the methods in this class just delegates the
call to that mission.
Mission| Field Summary | |
|---|---|
private int |
dynamicPriority
The dynamic part of the transport priority. |
private Goal |
goal
The goal this AIUnit belongs to, if one has been assigned. |
private static java.util.logging.Logger |
logger
|
private Mission |
mission
The mission this unit has been assigned. |
private AIUnit |
transport
The AIUnit which has this Transportable in
it's transport list. |
private Unit |
unit
The FreeColGameObject this AIObject contains AI-information for. |
| 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, INFINITY, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG |
| Constructor Summary | |
|---|---|
AIUnit(AIMain aiMain,
org.w3c.dom.Element element)
Creates a new AIUnit. |
|
AIUnit(AIMain aiMain,
java.lang.String id)
Creates a new AIUnit. |
|
AIUnit(AIMain aiMain,
Unit unit)
Creates a new AIUnit. |
|
AIUnit(AIMain aiMain,
javax.xml.stream.XMLStreamReader in)
Creates a new AIUnit. |
|
| Method Summary | |
|---|---|
void |
abortWish(Wish w)
Aborts the given Wish. |
void |
dispose()
Disposes this object and any attached mission. |
void |
doMission(Connection connection)
Performs the mission this unit has been assigned. |
AIPlayer |
getAIOwner()
Gets the AIPlayer that owns this AIUnit. |
Connection |
getConnection()
|
Goal |
getGoal()
|
java.lang.String |
getId()
Returns the ID of this AIObject. |
Mission |
getMission()
Gets the mission this unit has been assigned. |
AIUnit |
getTransport()
Gets the carrier responsible for transporting this Transportable. |
Location |
getTransportDestination()
Returns the destination for this Transportable. |
Locatable |
getTransportLocatable()
Gets the Locatable which should be transported. |
int |
getTransportPriority()
Gets the priority of transporting this Transportable to
it's destination. |
Location |
getTransportSource()
Returns the source for this Transportable. |
Unit |
getUnit()
Gets the Unit this AIUnit controls. |
static java.lang.String |
getXMLElementTagName()
Returns the tag name of the root element representing this object. |
boolean |
hasMission()
Checks if this unit has been assigned a mission. |
void |
increaseTransportPriority()
Increases the transport priority of this Transportable. |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Reads information for this object from an XML stream. |
void |
setGoal(Goal g)
|
void |
setMission(Mission mission)
Assignes a mission to unit. |
void |
setTransport(AIUnit transport)
Sets the carrier responsible for transporting this Transportable. |
java.lang.String |
toString()
Returns a String-representation of this object. |
protected void |
toXMLImpl(javax.xml.stream.XMLStreamWriter out)
Writes this object to an XML stream. |
| Methods inherited from class net.sf.freecol.server.ai.AIObject |
|---|
getAIMain, getAIRandom, getGame, isUninitialized, readFromXML |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final java.util.logging.Logger logger
private Unit unit
private Mission mission
private Goal goal
private int dynamicPriority
private AIUnit transport
AIUnit which has this Transportable in
it's transport list. This Transportable has not been
scheduled for transport if this value is null.
| Constructor Detail |
|---|
public AIUnit(AIMain aiMain,
Unit unit)
AIUnit.
aiMain - The main AI-object.unit - The unit to make an AIObject for.
public AIUnit(AIMain aiMain,
org.w3c.dom.Element element)
AIUnit.
aiMain - The main AI-object.element - An Element containing an XML-representation
of this object.
public AIUnit(AIMain aiMain,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
AIUnit.
aiMain - The main AI-object.in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.AIObject.readFromXML(javax.xml.stream.XMLStreamReader)
public AIUnit(AIMain aiMain,
java.lang.String id)
AIUnit.
aiMain - The main AI-object.id - The unique ID of this object.| Method Detail |
|---|
public Unit getUnit()
Unit this AIUnit controls.
Unit.public void abortWish(Wish w)
Wish.
abortWish in interface Transportablew - The Wish to be aborted.public Locatable getTransportLocatable()
Locatable which should be transported.
getTransportLocatable in interface TransportableLocatable.public Location getTransportSource()
Transportable. This is
normally the location of the locatable.
getTransportSource in interface TransportableTransportable.public Location getTransportDestination()
Transportable.
This can either be the target Tile of the transport or the
target for the entire Transportable's mission. The
target for the tansport is determined by TransportMission in the latter case.
getTransportDestination in interface TransportableTransportable.public int getTransportPriority()
Transportable to
it's destination.
getTransportPriority in interface Transportablepublic void increaseTransportPriority()
Transportable.
This method gets called every turn the Transportable have
not been put on a carrier's transport list.
increaseTransportPriority in interface Transportablepublic AIUnit getTransport()
Transportable.
getTransport in interface TransportableAIUnit which has this
Transportable in it's transport list. This
Transportable has not been scheduled for transport
if this value is null.public void setTransport(AIUnit transport)
Transportable.
setTransport in interface Transportabletransport - The AIUnit which has this
Transportable in it's transport list. This
Transportable has not been scheduled for
transport if this value is null.public Mission getMission()
Mission.public boolean hasMission()
true if this unit has a mission.public void setMission(Mission mission)
mission - The new Mission.public void doMission(Connection connection)
connection - The Connection to use when communicating
with the server.public void dispose()
dispose in class AIObjectpublic java.lang.String getId()
AIObject.
getId in interface TransportablegetId in class FreeColObjectUnit this AIObject
controls.public void setGoal(Goal g)
public Goal getGoal()
public AIPlayer getAIOwner()
public Connection getConnection()
protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
toXMLImpl in class FreeColObjectout - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing to the
stream.
protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readFromXMLImpl in class FreeColObjectin - The input stream with the XML.
javax.xml.stream.XMLStreamException - if there are any problems reading from the
stream.public java.lang.String toString()
String-representation of this object.
toString in class java.lang.ObjectString representing this object for
debugging purposes.public static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||