|
|||||||||
| 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.common.model.FreeColGameObject
net.sf.freecol.common.model.Game
public class Game
The main component of the game model.
If an object of this class returns a non-null result to getViewOwner(),
then this object just represents a view of the game from a single player's
perspective. In that case, some information might be missing from the model.
| Field Summary | |
|---|---|
static java.lang.String |
CIBOLA_TAG
|
private java.util.List<java.lang.String> |
citiesOfCibola
The cities of Cibola remaining in this game. |
protected CombatModel |
combatModel
The combat model this game uses. |
protected Player |
currentPlayer
The name of the player whose turn it is. |
protected FreeColGameObjectListener |
freeColGameObjectListener
|
protected java.util.HashMap<java.lang.String,java.lang.ref.WeakReference<FreeColGameObject>> |
freeColGameObjects
Contains references to all objects created in this game. |
private static java.util.logging.Logger |
logger
|
private Map |
map
|
private NationOptions |
nationOptions
Describe nationOptions here. |
protected int |
nextId
The next available ID, that can be given to a new FreeColGameObject. |
protected java.util.List<Player> |
players
Contains all the players in the game. |
private boolean |
spanishSuccession
Whether the War of Spanish Succession has already taken place. |
private Specification |
specification
The Specification this game uses. |
private Turn |
turn
|
private Player |
unknownEnemy
A virtual player to use with enemy privateers |
private java.util.UUID |
uuid
Game UUID, persistent in savegame files |
protected Player |
viewOwner
The owner of this view of the game, or null if this game
has all the information. |
| Fields inherited from class net.sf.freecol.common.model.FreeColGameObject |
|---|
UNITS_TAG_NAME |
| 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 | |
|---|---|
protected |
Game(Game game,
javax.xml.stream.XMLStreamReader in)
Minimal constructor, Just necessary to call parent constructor |
protected |
Game(Specification specification)
This constructor is used by the Server to create a new Game with the given Specification. |
|
Game(javax.xml.stream.XMLStreamReader in,
java.lang.String viewOwnerUsername)
Initiate a new Game object from an XML-representation. |
| Method Summary | |
|---|---|
private void |
addOldOptions(OptionGroup group)
|
void |
addPlayer(Player player)
Adds the specified player to the game. |
boolean |
canAddNewPlayer()
Checks if a new Player can be added. |
boolean |
checkIntegrity()
Checks the integrity of this Gameuninitialized objects. |
boolean |
equals(java.lang.Object o)
Need to overwrite behavior of equals inherited from FreeColGameObject, since two games are not the same if they have the same id. |
private boolean |
fixIntegrity(java.util.List<java.lang.String> list)
Try to fix integrity problems |
java.lang.String |
getCityOfCibola()
Get the next name for a city of Cibola. |
CombatModel |
getCombatModel()
Get the CombatModel value. |
Player |
getCurrentPlayer()
Gets the current player. |
OptionGroup |
getDifficultyLevel()
Get the OptionGroup value. |
Player |
getFirstPlayer()
Gets the first player in this game. |
FreeColGameObject |
getFreeColGameObject(java.lang.String id)
Gets the FreeColGameObject with the specified ID. |
java.util.Iterator<FreeColGameObject> |
getFreeColGameObjectIterator()
Gets an Iterator of every registered
FreeColGameObject. |
FreeColGameObjectListener |
getFreeColGameObjectListener()
|
FreeColGameObject |
getFreeColGameObjectSafely(java.lang.String id)
Get the FreeColGameObject with the given id or null. |
java.util.List<Player> |
getLiveEuropeanPlayers()
Returns all the live European players known by the player of this game. |
Map |
getMap()
Gets the Map that is being used in this game. |
OptionGroup |
getMapGeneratorOptions()
Gets the MapGeneratorOptions that is associated with this
Game. |
FreeColObject |
getMessageDisplay(ModelMessage message)
Helper function to get the object to display with a message in this game. |
FreeColGameObject |
getMessageSource(ModelMessage message)
Helper function to get the source object of a message in this game. |
NationOptions |
getNationOptions()
Get the NationOptions value. |
Player |
getNextPlayer()
Gets the next current player. |
int |
getNumberOfPlayers()
|
Player |
getPlayer(java.lang.String nationID)
Return a Player identified by it's nation. |
Player |
getPlayerAfter(Player beforePlayer)
Gets the player after the given player. |
Player |
getPlayerByName(java.lang.String name)
Gets a Player specified by a name. |
java.util.Iterator<Player> |
getPlayerIterator()
Gets an Iterator of every Player in this
game. |
java.util.List<Player> |
getPlayers()
Gets an Vector containing every Player in
this game. |
Settlement |
getSettlement(java.lang.String name)
Finds a settlement by name. |
boolean |
getSpanishSuccession()
Get the SpanishSuccession value. |
Specification |
getSpecification()
Return the specification for this Game. |
java.util.Map<java.lang.String,java.lang.String> |
getStatistics()
Gets the statistics of this game. |
Turn |
getTurn()
Gets the current turn in this game. |
Player |
getUnknownEnemy()
Returns the "Unknown Enemy" Player, which is used for privateers. |
java.util.UUID |
getUUID()
Returns the unique identifier for this game. |
Nation |
getVacantNation()
Returns a vacant nation. |
java.util.List<Nation> |
getVacantNations()
Get the VacantNations value. |
Player |
getViewOwner()
Returns the owner of this view of the game, or null if
this game has all the information. |
static java.lang.String |
getXMLElementTagName()
Returns the tag name of the root element representing this object. |
private void |
initializeCitiesOfCibola()
Initialize the list of cities of Cibola. |
boolean |
isAllPlayersReadyToLaunch()
Checks if all players are ready to launch. |
boolean |
playerNameInUse(java.lang.String username)
Checks if the specified name is in use. |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
protected void |
readFromXMLPartialImpl(javax.xml.stream.XMLStreamReader in)
Partial reader, so that simple updates can be brief. |
FreeColGameObject |
removeFreeColGameObject(java.lang.String id)
Removes the FreeColGameObject with the specified ID. |
void |
removePlayer(Player player)
Removes the specified player from the game. |
void |
setCombatModel(CombatModel newCombatModel)
Set the CombatModel value. |
void |
setCurrentPlayer(Player newCp)
Sets the current player. |
void |
setFreeColGameObject(java.lang.String id,
FreeColGameObject freeColGameObject)
Registers a new FreeColGameObject with the specified ID. |
void |
setFreeColGameObjectListener(FreeColGameObjectListener freeColGameObjectListener)
|
void |
setMap(Map map)
Sets the Map that is going to be used in this game. |
void |
setNationOptions(NationOptions newNationOptions)
Set the NationOptions value. |
void |
setSpanishSuccession(boolean newSpanishSuccession)
Set the SpanishSuccession value. |
void |
setTurn(Turn newTurn)
Sets the current turn in this game. |
void |
setUnknownEnemy(Player player)
Sets the "Unknown Enemy" Player, which is used for privateers. |
protected void |
toXMLImpl(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
This method writes an XML-representation of this object to the given stream. |
protected void |
toXMLPartialImpl(javax.xml.stream.XMLStreamWriter out,
java.lang.String[] fields)
Partial writer, so that simple updates can be brief. |
| Methods inherited from class net.sf.freecol.common.model.FreeColGameObject |
|---|
dispose, disposeList, equals, fundamentalDispose, getFreeColGameObject, getFreeColGameObject, getGame, getIntegerID, hashCode, isDisposed, isUninitialized, newLocation, readFromXML, readFromXMLPartialByClass, setDefaultId, setGame, setId, toString, toXML, toXMLImpl, toXMLPartialByClass, updateFreeColGameObject |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String CIBOLA_TAG
private static final java.util.logging.Logger logger
private java.util.UUID uuid
private Player unknownEnemy
protected java.util.List<Player> players
private Map map
protected Player currentPlayer
protected Player viewOwner
null if this game
has all the information.
protected java.util.HashMap<java.lang.String,java.lang.ref.WeakReference<FreeColGameObject>> freeColGameObjects
protected int nextId
FreeColGameObject.
private Turn turn
private NationOptions nationOptions
private boolean spanishSuccession
protected FreeColGameObjectListener freeColGameObjectListener
private java.util.List<java.lang.String> citiesOfCibola
protected CombatModel combatModel
private Specification specification
| Constructor Detail |
|---|
protected Game(Specification specification)
specification -
protected Game(Game game,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
game - Gamein - XMLStreamReader
javax.xml.stream.XMLStreamException
public Game(javax.xml.stream.XMLStreamReader in,
java.lang.String viewOwnerUsername)
throws javax.xml.stream.XMLStreamException
Game object from an XML-representation.
Note that this is used on the client side; the game is really a partial view of the server-side game.
in - The XML stream to read the data from.viewOwnerUsername - The username of the owner of this view of the
game.
javax.xml.stream.XMLStreamException - if an error occured during parsing.ConnectController.login(String,
String, int)| Method Detail |
|---|
public java.util.UUID getUUID()
public Player getUnknownEnemy()
Player valuepublic void setUnknownEnemy(Player player)
player - a Player valuepublic final java.util.List<Nation> getVacantNations()
VacantNations value.
List valuepublic Player getViewOwner()
null if
this game has all the information. null, then it means that this
Game object has access to all information (ie is the
server model).
Player using this Game-object
as a view.public Settlement getSettlement(java.lang.String name)
name - The name of the Settlement.
Settlement or null if
there is no known Settlement with the
specified name (the settlement might not be visible to
a client).public Turn getTurn()
Turn.public void setTurn(Turn newTurn)
newTurn - The new Turn to set.public final CombatModel getCombatModel()
CombatModel value.
CombatModel valuepublic final void setCombatModel(CombatModel newCombatModel)
CombatModel value.
newCombatModel - The new CombatModel value.public final OptionGroup getDifficultyLevel()
OptionGroup value.
OptionGroup valuepublic void addPlayer(Player player)
player - The Player that shall be added to this
Game.public void removePlayer(Player player)
player - The Player that shall be removed from this
Game.
public void setFreeColGameObject(java.lang.String id,
FreeColGameObject freeColGameObject)
FreeColGameObject with the specified ID.
id - The unique ID of the FreeColGameObject.freeColGameObject - The FreeColGameObject that shall
be added to this Game.
java.lang.IllegalArgumentException - If either id
or freeColGameObject are
null.public void setFreeColGameObjectListener(FreeColGameObjectListener freeColGameObjectListener)
public FreeColGameObjectListener getFreeColGameObjectListener()
public FreeColGameObject getFreeColGameObject(java.lang.String id)
FreeColGameObject with the specified ID.
id - The identifier of the FreeColGameObject.
FreeColGameObject.
java.lang.IllegalArgumentException - If id == null, or id = "".public FreeColGameObject getFreeColGameObjectSafely(java.lang.String id)
FreeColGameObject with the given id or null. This method
does NOT throw if the id is invalid.
id - The id, may be null or invalid.
public FreeColGameObject removeFreeColGameObject(java.lang.String id)
FreeColGameObject with the specified ID.
id - The identifier of the FreeColGameObject that
shall be removed from this Game.
FreeColGameObject that has been removed.
java.lang.IllegalArgumentException - If id == null, or id = "".public Map getMap()
Map that is being used in this game.
Map that is being used in this game or
null if no Map has been created.public void setMap(Map map)
Map that is going to be used in this game.
map - The Map that is going to be used in this game.public final NationOptions getNationOptions()
NationOptions value.
NationOptions valuepublic final void setNationOptions(NationOptions newNationOptions)
NationOptions value.
newNationOptions - The new NationOptions value.public Nation getVacantNation()
public Player getPlayer(java.lang.String nationID)
Player identified by it's nation.
nationID - The nation.
Player of the given nation.public void setCurrentPlayer(Player newCp)
newCp - The new current player.public Player getCurrentPlayer()
Player currently
playing the Game.
public Player getNextPlayer()
getCurrentPlayer()public Player getPlayerAfter(Player beforePlayer)
beforePlayer - The Player before the
Player to be returned.
Player after the beforePlayer
in the list which determines the order each player becomes the
current player.getNextPlayer()public Player getFirstPlayer()
Player that was first added to this
Game.public java.util.Iterator<FreeColGameObject> getFreeColGameObjectIterator()
Iterator of every registered
FreeColGameObject.
This Iterator should be iterated at least once
in a while since it cleans the FreeColGameObject
cache.
Iterator containing every registered
FreeColGameObject.setFreeColGameObject(java.lang.String, net.sf.freecol.common.model.FreeColGameObject)public Player getPlayerByName(java.lang.String name)
Player specified by a name.
name - The name identifying the Player.
Player.public boolean playerNameInUse(java.lang.String username)
username - The name.
public java.util.Iterator<Player> getPlayerIterator()
Iterator of every Player in this
game.
Iterator.public java.util.List<Player> getPlayers()
Vector containing every Player in
this game.
Vector.public int getNumberOfPlayers()
public java.util.List<Player> getLiveEuropeanPlayers()
public boolean canAddNewPlayer()
Player can be added.
public boolean isAllPlayersReadyToLaunch()
public final boolean getSpanishSuccession()
SpanishSuccession value.
boolean valuepublic final void setSpanishSuccession(boolean newSpanishSuccession)
SpanishSuccession value.
newSpanishSuccession - The new SpanishSuccession value.public boolean checkIntegrity()
Gameuninitialized objects.
Detected problems gets written to the log.
true if the Game has
been loaded properly.private boolean fixIntegrity(java.util.List<java.lang.String> list)
public OptionGroup getMapGeneratorOptions()
MapGeneratorOptions that is associated with this
Game.
OptionGroupprivate void initializeCitiesOfCibola()
public java.lang.String getCityOfCibola()
public FreeColGameObject getMessageSource(ModelMessage message)
message - The ModelMessage to find the object in.
public FreeColObject getMessageDisplay(ModelMessage message)
message - The ModelMessage to find the object in.
public Specification getSpecification()
getSpecification in class FreeColGameObjectSpecification valuepublic boolean equals(java.lang.Object o)
equals in class FreeColGameObjecto - The FreeColGameObject to compare against this object.
FreeColGameObject are equal and false otherwise.public java.util.Map<java.lang.String,java.lang.String> getStatistics()
Map of the statistics.
protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
throws javax.xml.stream.XMLStreamException
Player will be added
to that representation if showAll is set to
false.
toXMLImpl in class FreeColGameObjectout - The target stream.player - The Player this XML-representation should be
made for, or null if
showAll == true.showAll - Only attributes visible to player will be
added to the representation if showAll is set
to false.toSavedGame - If true then information that is only
needed when saving a game is added.
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 a problem was encountered
during parsing.private void addOldOptions(OptionGroup group)
protected void toXMLPartialImpl(javax.xml.stream.XMLStreamWriter out,
java.lang.String[] fields)
throws javax.xml.stream.XMLStreamException
toXMLPartialImpl in class FreeColObjectout - The target stream.fields - The fields to write.
javax.xml.stream.XMLStreamException - If there are problems writing the stream.
protected void readFromXMLPartialImpl(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readFromXMLPartialImpl in class FreeColObjectin - The input stream with the XML.
javax.xml.stream.XMLStreamException - If there are problems reading the stream.public static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||