net.sf.freecol.server.model
Class ServerGame

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.FreeColGameObject
          extended by net.sf.freecol.common.model.Game
              extended by net.sf.freecol.server.model.ServerGame
All Implemented Interfaces:
ServerModelObject

public class ServerGame
extends Game
implements ServerModelObject

The server representation of the game.


Field Summary
private static java.util.logging.Logger logger
           
 
Fields inherited from class net.sf.freecol.common.model.Game
CIBOLA_TAG, combatModel, currentPlayer, freeColGameObjectListener, freeColGameObjects, nextId, players, viewOwner
 
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
ServerGame(FreeColGameObjectListener freeColGameObjectListener, javax.xml.stream.XMLStreamReader in, java.util.List<java.lang.String> serverStrings, Specification specification)
          Initiate a new ServerGame with information from a saved game.
ServerGame(Specification specification)
          Creates a new game model.
 
Method Summary
 Player checkForWinner()
          Checks if anybody has won this game.
 void csNewTurn(java.util.Random random, ChangeSet cs)
          New turn for this game.
private  void csSpanishSuccession(ChangeSet cs, Event spanishSuccession)
          Checks for and if necessary performs the War of Spanish Succession changes.
 java.lang.String getNextID()
          Get a unique ID to identify a FreeColGameObject.
 java.util.List<ServerModelObject> getServerModelObjects()
          Collects a list of all the ServerModelObjects in this game.
 java.lang.String getServerXMLElementTagName()
          Returns the tag name of the root element representing this object.
 boolean isNextPlayerInNewTurn()
          Is the next player in a new turn?
private  java.lang.Object makeServerObject(java.lang.String type, java.lang.String id)
          Makes a trivial server object in this game given a server object tag and an id.
 
Methods inherited from class net.sf.freecol.common.model.Game
addPlayer, canAddNewPlayer, checkIntegrity, equals, getCityOfCibola, getCombatModel, getCurrentPlayer, getDifficultyLevel, getFirstPlayer, getFreeColGameObject, getFreeColGameObjectIterator, getFreeColGameObjectListener, getFreeColGameObjectSafely, getLiveEuropeanPlayers, getMap, getMapGeneratorOptions, getMessageDisplay, getMessageSource, getNationOptions, getNextPlayer, getNumberOfPlayers, getPlayer, getPlayerAfter, getPlayerByName, getPlayerIterator, getPlayers, getSettlement, getSpanishSuccession, getSpecification, getStatistics, getTurn, getUnknownEnemy, getUUID, getVacantNation, getVacantNations, getViewOwner, getXMLElementTagName, isAllPlayersReadyToLaunch, playerNameInUse, readFromXMLImpl, readFromXMLPartialImpl, removeFreeColGameObject, removePlayer, setCombatModel, setCurrentPlayer, setFreeColGameObject, setFreeColGameObjectListener, setMap, setNationOptions, setSpanishSuccession, setTurn, setUnknownEnemy, toXMLImpl, toXMLPartialImpl
 
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 net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, hasAbility, hasAttribute, hasListeners, readAttributes, readAttributes, readChild, readChild, readChildren, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXMLElement, readFromXMLImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setSpecification, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, writeAttribute, writeAttributes, writeChildren
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger
Constructor Detail

ServerGame

public ServerGame(Specification specification)
Creates a new game model.

Parameters:
specification - The Specification to use in this game.
See Also:
FreeColServer

ServerGame

public ServerGame(FreeColGameObjectListener freeColGameObjectListener,
                  javax.xml.stream.XMLStreamReader in,
                  java.util.List<java.lang.String> serverStrings,
                  Specification specification)
           throws javax.xml.stream.XMLStreamException
Initiate a new ServerGame with information from a saved game.

Parameters:
freeColGameObjectListener - A listener that should be monitoring this Game.
in - The input stream containing the XML.
serverStrings - A list of server object type,ID pairs to create. in this Game.
specification - The Specification to use in this game.
Throws:
javax.xml.stream.XMLStreamException - if an error occurred during parsing.
See Also:
FreeColServer.loadGame(net.sf.freecol.common.io.FreeColSavegameFile)
Method Detail

makeServerObject

private java.lang.Object makeServerObject(java.lang.String type,
                                          java.lang.String id)
                                   throws java.lang.ClassNotFoundException,
                                          java.lang.IllegalAccessException,
                                          java.lang.InstantiationException,
                                          java.lang.reflect.InvocationTargetException,
                                          java.lang.NoSuchMethodException
Makes a trivial server object in this game given a server object tag and an id.

Parameters:
type - The server object tag.
id - The id.
Returns:
A trivial server object.
Throws:
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException

getNextID

public java.lang.String getNextID()
Get a unique ID to identify a FreeColGameObject.

Returns:
A unique ID.

checkForWinner

public Player checkForWinner()
Checks if anybody has won this game.

Returns:
The Player who has won the game or null if none.

isNextPlayerInNewTurn

public boolean isNextPlayerInNewTurn()
Is the next player in a new turn?


csNewTurn

public void csNewTurn(java.util.Random random,
                      ChangeSet cs)
New turn for this game.

Specified by:
csNewTurn in interface ServerModelObject
Parameters:
random - A Random number source.
cs - A ChangeSet to update.

csSpanishSuccession

private void csSpanishSuccession(ChangeSet cs,
                                 Event spanishSuccession)
Checks for and if necessary performs the War of Spanish Succession changes.

Parameters:
cs - A ChangeSet to update.
spanishSuccession - an Event value

getServerXMLElementTagName

public java.lang.String getServerXMLElementTagName()
Returns the tag name of the root element representing this object.

Specified by:
getServerXMLElementTagName in interface ServerModelObject
Returns:
"serverGame".

getServerModelObjects

public java.util.List<ServerModelObject> getServerModelObjects()
Collects a list of all the ServerModelObjects in this game.

Returns:
A list of all the ServerModelObjects in this game.