net.sf.freecol.common.model
Class LostCityRumour

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.TileItem
              extended by net.sf.freecol.common.model.LostCityRumour
All Implemented Interfaces:
Locatable

public class LostCityRumour
extends TileItem

Represents a lost city rumour.


Nested Class Summary
static class LostCityRumour.RumourType
          Constants describing types of Lost City Rumours.
 
Field Summary
private static java.util.logging.Logger logger
           
private  java.lang.String name
          The name of this rumour, or null, if it has none.
private  LostCityRumour.RumourType type
          The type of the rumour.
 
Fields inherited from class net.sf.freecol.common.model.TileItem
RESOURCE_ZINDEX, RUMOUR_ZINDEX, tile
 
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
LostCityRumour(Game game, Tile tile)
          Creates a new LostCityRumour instance.
LostCityRumour(Game game, Tile tile, LostCityRumour.RumourType type, java.lang.String name)
          Creates a new LostCityRumour instance.
LostCityRumour(Game game, javax.xml.stream.XMLStreamReader in)
          Creates a new LostCityRumour instance.
 
Method Summary
 LostCityRumour.RumourType chooseType(Unit unit, int difficulty, java.util.Random random)
          Chooses a type of Lost City Rumour.
 java.lang.String getName()
          Get the Name value.
 LostCityRumour.RumourType getType()
          Get the Type value.
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
 int getZIndex()
          Get the ZIndex value.
 boolean isTileTypeAllowed(TileType tileType)
          Returns true if the TileItem is compatible with the given TileType.
protected  void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
          Initialize this object from an XML-representation of this object.
 void setName(java.lang.String newName)
          Set the Name value.
 void setType(LostCityRumour.RumourType newType)
          Set the Type value.
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.
 
Methods inherited from class net.sf.freecol.common.model.TileItem
getLocation, getSpaceTaken, getTile, setLocation
 
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
dispose, disposeList, equals, equals, fundamentalDispose, getFreeColGameObject, getFreeColGameObject, getGame, getIntegerID, getSpecification, 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, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setSpecification, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, 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

type

private LostCityRumour.RumourType type
The type of the rumour. A RumourType, or null if the type has not yet been determined.


name

private java.lang.String name
The name of this rumour, or null, if it has none. Rumours such as the Seven Cities of Gold and Fountains of Youth may have individual names.

Constructor Detail

LostCityRumour

public LostCityRumour(Game game,
                      Tile tile)
Creates a new LostCityRumour instance.

Parameters:
game - a Game value
tile - a Tile value

LostCityRumour

public LostCityRumour(Game game,
                      Tile tile,
                      LostCityRumour.RumourType type,
                      java.lang.String name)
Creates a new LostCityRumour instance.

Parameters:
game - a Game value
tile - a Tile value
type - a RumourType value
name - a String value

LostCityRumour

public LostCityRumour(Game game,
                      javax.xml.stream.XMLStreamReader in)
               throws javax.xml.stream.XMLStreamException
Creates a new LostCityRumour instance.

Parameters:
game - a Game value
in - a XMLStreamReader value
Throws:
javax.xml.stream.XMLStreamException - if an error occurs
Method Detail

getType

public final LostCityRumour.RumourType getType()
Get the Type value.

Returns:
a RumourType value

setType

public final void setType(LostCityRumour.RumourType newType)
Set the Type value.

Parameters:
newType - The new Type value.

getName

public final java.lang.String getName()
Get the Name value.

Returns:
a String value

setName

public final void setName(java.lang.String newName)
Set the Name value.

Parameters:
newName - The new Name value.

getZIndex

public final int getZIndex()
Get the ZIndex value.

Specified by:
getZIndex in class TileItem
Returns:
an int value

isTileTypeAllowed

public boolean isTileTypeAllowed(TileType tileType)
Returns true if the TileItem is compatible with the given TileType.

Specified by:
isTileTypeAllowed in class TileItem
Parameters:
tileType - a TileType value
Returns:
a boolean value

chooseType

public LostCityRumour.RumourType chooseType(Unit unit,
                                            int difficulty,
                                            java.util.Random random)
Chooses a type of Lost City Rumour. The type of rumour depends on the exploring unit, as well as player settings.

Parameters:
unit - The Unit exploring (optional).
difficulty - The difficulty level.
random - A random number source.
Returns:
The type of rumour. TODO: Make RumourType a FreeColGameObjectType and move all the magic numbers in here to the specification.

toXMLImpl

protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out,
                         Player player,
                         boolean showAll,
                         boolean toSavedGame)
                  throws javax.xml.stream.XMLStreamException
This method writes an XML-representation of this object to the given stream.

Only attributes visible to the given Player will be added to that representation if showAll is set to false.

Specified by:
toXMLImpl in class FreeColGameObject
Parameters:
out - 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.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readFromXMLImpl

protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
                        throws javax.xml.stream.XMLStreamException
Initialize this object from an XML-representation of this object.

Overrides:
readFromXMLImpl in class FreeColObject
Parameters:
in - The input stream with the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

getXMLElementTagName

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

Returns:
"lostCityRumour".