Package net.sf.freecol.common.model
Class LostCityRumour
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.FreeColGameObject
-
- net.sf.freecol.common.model.TileItem
-
- net.sf.freecol.common.model.LostCityRumour
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>,Locatable,Named,ObjectWithId
public class LostCityRumour extends TileItem
Represents a lost city rumour.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLostCityRumour.RumourTypeConstants describing types of Lost City Rumours.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Loggerloggerprivate static intMAYAN_PROPHESY_YEARprivate java.lang.StringnameThe name of this rumour, or null, if it has none.private static java.lang.StringNAME_TAGprivate static intrumourNothingstatic java.lang.StringTAGprivate static java.lang.StringTILE_TAGprivate LostCityRumour.RumourTypetypeThe type of the rumour.private static java.lang.StringTYPE_TAG-
Fields inherited from class net.sf.freecol.common.model.FreeColGameObject
initialized
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
-
Constructor Summary
Constructors Constructor Description LostCityRumour(Game game, java.lang.String id)Creates a newLostCityRumourinstance.LostCityRumour(Game game, Tile tile)Creates a newLostCityRumourinstance.LostCityRumour(Game game, Tile tile, LostCityRumour.RumourType type, java.lang.String name)Creates a newLostCityRumourinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intapplyBonus(GoodsType goodsType, UnitType unitType, int potential)Applies the production bonus for the given goods type and unit type to the given potential production.booleancanProduce(GoodsType goodsType, UnitType unitType)Does this tile item allow its enclosing tile to produce a given goods type?Constants.IntegrityTypecheckIntegrity(boolean fix, LogBuilder lb)Checks the integrity of this game object.LostCityRumour.RumourTypechooseType(Unit unit, java.util.Random random)Chooses a type of Lost City Rumour.<T extends FreeColObject>
booleancopyIn(T other)Copy another FreeColObject into this one if it is compatible.Map.LayergetLayer()Get the layer associated with this tile item.java.lang.StringgetName()Get the name of this rumour.java.lang.StringgetNameKey()Gets the name of this named object.ModelMessagegetNothingMessage(Player player, boolean mounds, java.util.Random random)Get the message for a "nothing" rumour.java.util.stream.Stream<Modifier>getProductionModifiers(GoodsType goodsType, UnitType unitType)Gets the production modifiers for the given type of goods and unit.LostCityRumour.RumourTypegetType()Get the type of rumour.java.lang.StringgetXMLTagName()Get the serialization tag for this object.intgetZIndex()Get theZIndexvalue.booleanisComplete()Is this improvement complete?booleanisNatural()Is this a natural TileItem?booleanisTileTypeAllowed(TileType tileType)Is a tile type compatible with this tile item?protected voidreadAttributes(FreeColXMLReader xr)Reads the attributes of this object from an XML stream.voidsetType(LostCityRumour.RumourType newType)Set the type of rumour.protected voidwriteAttributes(FreeColXMLWriter xw)Write the attributes of this object to a stream.-
Methods inherited from class net.sf.freecol.common.model.TileItem
getLocation, getSpaceTaken, getTile, isInEurope, setLocation
-
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
dispose, disposeResources, equals, fundamentalDispose, getClassIndex, getDisposables, getGame, getLinkTarget, getSpecification, hashCode, intern, internId, isDisposed, isInitialized, isInternable, readFromXML, setGame, setSpecification
-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getAbilities, getDefenceModifiers, getDisplayObject, getFeatureContainer, getFreeColObjectClass, getFreeColObjectClassByName, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSuffix, getSuffix, hasAbility, hasAbility, hasAbility, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readChild, readChildren, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setId, toString, toXML, toXML, toXMLPartial, toXMLPartial, writeChildren
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
MAYAN_PROPHESY_YEAR
private static final int MAYAN_PROPHESY_YEAR
- See Also:
- Constant Field Values
-
rumourNothing
private static int rumourNothing
-
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.
-
NAME_TAG
private static final java.lang.String NAME_TAG
- See Also:
- Constant Field Values
-
TILE_TAG
private static final java.lang.String TILE_TAG
- See Also:
- Constant Field Values
-
TYPE_TAG
private static final java.lang.String TYPE_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LostCityRumour
public LostCityRumour(Game game, Tile tile)
Creates a newLostCityRumourinstance.- Parameters:
game- The enclosingGame.tile- TheTilewhere the LCR is.
-
LostCityRumour
public LostCityRumour(Game game, Tile tile, LostCityRumour.RumourType type, java.lang.String name)
Creates a newLostCityRumourinstance.- Parameters:
game- The enclosingGame.tile- TheTilewhere the LCR is.type- The type of rumour.name- The name of the rumour.
-
LostCityRumour
public LostCityRumour(Game game, java.lang.String id)
Creates a newLostCityRumourinstance.- Parameters:
game- The enclosingGame.id- The object identifier.
-
-
Method Detail
-
getType
public final LostCityRumour.RumourType getType()
Get the type of rumour.- Returns:
- The
RumourType.
-
setType
public final void setType(LostCityRumour.RumourType newType)
Set the type of rumour.- Parameters:
newType- The new rumour type.
-
getName
public final java.lang.String getName()
Get the name of this rumour.- Returns:
- The name.
-
chooseType
public LostCityRumour.RumourType chooseType(Unit unit, 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. The scouting outcome is based on three factors: good/bad percent rumour difficulty option, expert scout or not, DeSoto or not. FIXME: Make RumourType a FreeColSpecObjectType and move all the magic numbers in here to the specification.- Parameters:
unit- TheUnitexploring (optional).random- A random number source.- Returns:
- The type of rumour.
-
getNothingMessage
public ModelMessage getNothingMessage(Player player, boolean mounds, java.util.Random random)
Get the message for a "nothing" rumour.- Parameters:
player- ThePlayerto generate the message for.mounds- Is this rumour a result of exploring "strange mounds"?random- A pseudo-random number source.- Returns:
- A suitable
ModelMessage.
-
getNameKey
public java.lang.String getNameKey()
Gets the name of this named object. Try to avoid using this directly except in i18n-related routines or to implement itself in more complext objects.- Specified by:
getNameKeyin interfaceNamed- Specified by:
getNameKeyin classTileItem- Returns:
- The name of the
Named.
-
getZIndex
public final int getZIndex()
Get theZIndexvalue.
-
isTileTypeAllowed
public boolean isTileTypeAllowed(TileType tileType)
Is a tile type compatible with this tile item?- Specified by:
isTileTypeAllowedin classTileItem- Parameters:
tileType- TheTileTypeto check.- Returns:
- True if the tile type is compatible.
-
applyBonus
public int applyBonus(GoodsType goodsType, UnitType unitType, int potential)
Applies the production bonus for the given goods type and unit type to the given potential production.- Specified by:
applyBonusin classTileItem- Parameters:
goodsType- TheGoodsTypeto produce.unitType- TheUnitTypethat is to work.potential- The base potential production.- Returns:
- The production with resource bonuses.
-
canProduce
public boolean canProduce(GoodsType goodsType, UnitType unitType)
Does this tile item allow its enclosing tile to produce a given goods type?- Specified by:
canProducein classTileItem- Parameters:
goodsType- TheGoodsTypeto produce.unitType- The optionalunitTypeto produce with.- Returns:
- True if this tile item produces the goods.
-
getProductionModifiers
public java.util.stream.Stream<Modifier> getProductionModifiers(GoodsType goodsType, UnitType unitType)
Gets the production modifiers for the given type of goods and unit.- Specified by:
getProductionModifiersin classTileItem- Parameters:
goodsType- TheGoodsTypeto produce.unitType- The optionalunitTypeto produce them.- Returns:
- A stream of the applicable modifiers.
-
isNatural
public boolean isNatural()
Is this a natural TileItem?
-
isComplete
public boolean isComplete()
Is this improvement complete?- Specified by:
isCompletein classTileItem- Returns:
- True if complete.
-
getLayer
public Map.Layer getLayer()
Get the layer associated with this tile item.
-
checkIntegrity
public Constants.IntegrityType checkIntegrity(boolean fix, LogBuilder lb)
Checks the integrity of this game object.- Overrides:
checkIntegrityin classTileItem- Parameters:
fix- If true, fix problems if possible.lb- ALogBuilderto log to.- Returns:
- A suitable
IntegrityType.
-
copyIn
public <T extends FreeColObject> boolean copyIn(T other)
Copy another FreeColObject into this one if it is compatible.
-
writeAttributes
protected void writeAttributes(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
Write the attributes of this object to a stream. To be overridden if required by any object that has attributes and uses the toXML(FreeColXMLWriter, String) call.- Overrides:
writeAttributesin classFreeColObject- Parameters:
xw- TheFreeColXMLWriterto write to.- Throws:
javax.xml.stream.XMLStreamException- if there are any problems writing to the stream.
-
readAttributes
protected void readAttributes(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the attributes of this object from an XML stream.- Overrides:
readAttributesin classFreeColGameObject- Parameters:
xr- TheFreeColXMLReaderto read from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
getXMLTagName
public java.lang.String getXMLTagName()
Get the serialization tag for this object.- Specified by:
getXMLTagNamein classFreeColObject- Returns:
- The tag.
-
-