|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.server.ai.AIMain
public class AIMain
The main AI-class. Keeps references to all other AI-classes.
| Field Summary | |
|---|---|
static java.lang.String |
COPYRIGHT
|
static java.lang.String |
LICENSE
|
static java.lang.String |
REVISION
|
| Constructor Summary | |
|---|---|
AIMain(FreeColServer freeColServer)
Creates a new AIMain and searches the current
game for FreeColGameObjects. |
|
AIMain(FreeColServer freeColServer,
org.w3c.dom.Element element)
Creates a new AIMain and reads the given element. |
|
AIMain(FreeColServer freeColServer,
javax.xml.stream.XMLStreamReader in)
Creates a new AIMain and reads the given element. |
|
| Method Summary | |
|---|---|
void |
addAIObject(java.lang.String id,
AIObject aiObject)
Adds a reference to the given AIObject. |
boolean |
checkIntegrity()
Checks the integrity of this AIMain
by checking if there are any
uninitialized objects. |
void |
findNewObjects(boolean overwrite)
Searches for new FreeColGameObjects. |
AIObject |
getAIObject(FreeColGameObject fcgo)
Gets the AIObject for the given
FreeColGameObject. |
AIObject |
getAIObject(java.lang.String id)
Gets the AIObject identified by the given ID. |
FreeColGameObject |
getFreeColGameObject(java.lang.String id)
Gets the FreeColGameObject with the given ID. |
FreeColServer |
getFreeColServer()
Gets the main controller object for the server. |
Game |
getGame()
Returns the game. |
java.lang.String |
getNextID()
Gets a unique ID for identifying an AIObject. |
PseudoRandom |
getRandom()
Returns an instance of PseudoRandom. |
static java.lang.String |
getXMLElementTagName()
Returns the tag name of the root element representing this object. |
void |
ownerChanged(FreeColGameObject source,
Player oldOwner,
Player newOwner)
|
void |
readFromXML(javax.xml.stream.XMLStreamReader in)
Reads all the AIObjects and other AI-related information
from XML data. |
void |
readFromXMLElement(org.w3c.dom.Element element)
Initialize this object from an XML-representation of this object. |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Reads all the AIObjects and other AI-related information
from XML data. |
void |
removeAIObject(java.lang.String id)
Removes a reference to the given AIObject. |
void |
removeFreeColGameObject(java.lang.String id)
Removes the AIObject for the given FreeColGameObject. |
void |
setFreeColGameObject(java.lang.String id,
FreeColGameObject freeColGameObject)
Creates a new AIObject for a given
FreeColGameObject. |
void |
toXML(javax.xml.stream.XMLStreamWriter out)
Writes all of the AIObjects and other AI-related
information to an XML-stream. |
org.w3c.dom.Element |
toXMLElement(org.w3c.dom.Document document)
This method writes an XML-representation of this object to the given stream. |
protected void |
toXMLImpl(javax.xml.stream.XMLStreamWriter out)
Writes all of the AIObjects and other AI-related
information to an XML-stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String COPYRIGHT
public static final java.lang.String LICENSE
public static final java.lang.String REVISION
| Constructor Detail |
|---|
public AIMain(FreeColServer freeColServer)
AIMain and searches the current
game for FreeColGameObjects.
freeColServer - The main controller object for the
server.findNewObjects()
public AIMain(FreeColServer freeColServer,
org.w3c.dom.Element element)
AIMain and reads the given element.
freeColServer - The main controller object for the
server.element - The Element (in a DOM-parsed XML-tree)
that describes this object.readFromXMLElement(org.w3c.dom.Element)
public AIMain(FreeColServer freeColServer,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
AIMain and reads the given element.
freeColServer - The main controller object for the
server.in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.readFromXML(javax.xml.stream.XMLStreamReader)| Method Detail |
|---|
public FreeColServer getFreeColServer()
FreeColServer-object.public java.lang.String getNextID()
AIObject.
public boolean checkIntegrity()
AIMain
by checking if there are any
uninitialized objects.
Detected problems gets written to the log.
true if the Game has
been loaded properly.public Game getGame()
Game.public PseudoRandom getRandom()
PseudoRandom. It that can be
used to generate random numbers.
PseudoRandom.public void findNewObjects(boolean overwrite)
FreeColGameObjects. An AI-object is
created for each new object.
overwrite - Determines wether any old AIObject
should be overwritten or not.public AIObject getAIObject(FreeColGameObject fcgo)
AIObject for the given
FreeColGameObject.
fcgo - The FreeColGameObject to find
the AIObject for.
AIObject.getAIObject(String)public AIObject getAIObject(java.lang.String id)
AIObject identified by the given ID.
id - The ID of the AIObject.
AIObject.getAIObject(FreeColGameObject)
public void addAIObject(java.lang.String id,
AIObject aiObject)
AIObject.
id - The ID of the AIObject.aiObject - The AIObject to store a reference
for.
java.lang.IllegalStateException - if an AIObject with
the same id has already been created.public void removeAIObject(java.lang.String id)
AIObject.
id - The ID of the AIObject.public FreeColGameObject getFreeColGameObject(java.lang.String id)
FreeColGameObject with the given ID.
This is just a convenience method for:
Game.getFreeColGameObject(java.lang.String)
id - The ID of the FreeColGameObject to find.
FreeColGameObject.
public void ownerChanged(FreeColGameObject source,
Player oldOwner,
Player newOwner)
ownerChanged in interface FreeColGameObjectListener
public void setFreeColGameObject(java.lang.String id,
FreeColGameObject freeColGameObject)
AIObject for a given
FreeColGameObject. This method gets called
whenever a new object gets added to the Game.
setFreeColGameObject in interface FreeColGameObjectListenerid - The ID of the FreeColGameObject to add.freeColGameObject - The FreeColGameObject to add.AIObject,
FreeColGameObject,
FreeColGameObject.getID()public void removeFreeColGameObject(java.lang.String id)
AIObject for the given FreeColGameObject.
removeFreeColGameObject in interface FreeColGameObjectListenerid - The ID of the FreeColGameObject.public org.w3c.dom.Element toXMLElement(org.w3c.dom.Document document)
document - The Document.
public void readFromXMLElement(org.w3c.dom.Element element)
element - An XML-element that will be used to initialize
this object.
protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
AIObjects and other AI-related
information to an XML-stream.
out - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
public void toXML(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
AIObjects and other AI-related
information to an XML-stream.
out - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
public void readFromXML(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
AIObjects and other AI-related information
from XML data.
in - The input stream with the XML.
javax.xml.stream.XMLStreamException - if an error occured during parsing.
protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
AIObjects and other AI-related information
from XML data.
in - The input stream with the XML.
javax.xml.stream.XMLStreamException - if an error occured during parsing.public static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||