|
||||||||||
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.AIMain
public class AIMain
The main AI-class. Keeps references to all other AI-classes.
Field Summary |
---|
Fields inherited from class net.sf.freecol.common.model.FreeColObject |
---|
ID_ATTRIBUTE_TAG |
Constructor Summary | |
---|---|
AIMain(FreeColServer freeColServer)
Creates a new AIMain and searches the current
game for FreeColGameObject s. |
|
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. |
java.util.Random |
getAIRandom()
Gets the random number generator to be used in the AI. |
java.util.HashMap<java.lang.String,java.lang.Long> |
getAIStatistics()
Computes how many objects of each class have been created, to track memory leaks over time |
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 . |
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 |
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 . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AIMain(FreeColServer freeColServer)
AIMain
and searches the current
game for FreeColGameObject
s.
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.FreeColObject.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.FreeColObject.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 java.util.Random getAIRandom()
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 FreeColGameObjectListener
id
- The ID of the FreeColGameObject
to add.freeColGameObject
- The FreeColGameObject
to add.AIObject
,
FreeColGameObject
,
FreeColObject.getId()
public void removeFreeColGameObject(java.lang.String id)
AIObject
for the given FreeColGameObject
.
removeFreeColGameObject
in interface FreeColGameObjectListener
id
- The ID of the FreeColGameObject
.public static java.lang.String getXMLElementTagName()
public java.util.HashMap<java.lang.String,java.lang.Long> getAIStatistics()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |