|
|||||||||
| 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.TileItemContainer
public class TileItemContainer
Contains TileItems and can be used by a Tile
to make certain tasks easier.
| Field Summary | |
|---|---|
private static java.util.logging.Logger |
logger
|
private Tile |
tile
The owner of this TileItemContainer. |
private java.util.Comparator<TileItem> |
tileItemComparator
|
private java.util.List<TileItem> |
tileItems
All tile items sorted by zIndex. |
| 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 | |
|---|---|
TileItemContainer(Game game,
Tile tile)
Creates an empty TileItemContainer. |
|
TileItemContainer(Game game,
Tile tile,
javax.xml.stream.XMLStreamReader in)
Initiates a new TileItemContainer from an XML stream. |
|
| Method Summary | ||
|---|---|---|
TileImprovement |
addRiver(int magnitude,
int style)
Creates a river TileImprovement and adds to this Tile/Container. |
|
TileItem |
addTileItem(TileItem item)
Adds a TileItem to this container. |
|
boolean |
contains(TileItem t)
Checks if the specified TileItem is in this container. |
|
void |
copyFrom(TileItemContainer tic)
|
|
void |
copyFrom(TileItemContainer tic,
boolean importResources)
|
|
void |
copyFrom(TileItemContainer tic,
boolean importResources,
boolean copyOnlyNatural)
|
|
void |
dispose()
Removes all references to this object. |
|
TileImprovement |
findTileImprovementType(TileImprovementType type)
Checks if a TileImprovement of this Type is already in this container. |
|
java.util.List<TileImprovement> |
getCompletedImprovements()
Returns a List of the completed
TileImprovements in this
TileItemContainer. |
|
TileImprovement |
getImprovement(TileImprovementType type)
Gets the tile improvement of the given type if any. |
|
java.util.List<TileImprovement> |
getImprovements()
Returns a List of the TileImprovements
in this TileItemContainer. |
|
private java.util.List<TileImprovement> |
getImprovements(boolean completedOnly)
Returns a List of the TileImprovements
in this TileItemContainer. |
|
LostCityRumour |
getLostCityRumour()
Get the LostCityRumour value. |
|
int |
getMoveCost(int basicMoveCost,
Tile fromTile)
Determine the movement cost to this Tile from
another Tile. |
|
java.util.Set<Modifier> |
getProductionBonus(GoodsType goodsType,
UnitType unitType)
Describe getProductionBonus method here. |
|
Resource |
getResource()
Returns the Resource item or null. |
|
TileImprovement |
getRiver()
Returns the river improvement or null. |
|
TileImprovement |
getRoad()
Returns the road improvement or null. |
|
Tile |
getTile()
Return the Tile this TileItemContainer belongs to. |
|
java.util.List<TileItem> |
getTileItems()
Get the TileItems value. |
|
int |
getTotalBonusPotential(GoodsType g,
UnitType unitType,
int tilePotential,
boolean onlyNatural)
Determine the total bonus for a GoodsType. |
|
static java.lang.String |
getXMLElementTagName()
Gets the tag name of the root element representing this object. |
|
boolean |
hasImprovement(TileImprovementType type)
Will check whether this tile has a completed improvement of the given type. |
|
private void |
invalidateCache()
Invalidate the production cache of the owning colony, if there is one, but only if the tile is actually being used. |
|
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
|
|
removeAll(java.lang.Class<T> c)
|
|
void |
removeIncompatibleImprovements()
Remove improvements incompatible with the given TileType. |
|
TileImprovement |
removeRiver()
Removes the river TileImprovement from this Tile/Container. |
|
TileItem |
removeTileItem(TileItem item)
Removes TileItem from this container. |
|
void |
setTileItems(java.util.List<TileItem> newTileItems)
Set the TileItems value. |
|
java.lang.String |
toString()
Creates a String representation of this
TileItemContainer. |
|
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.FreeColGameObject |
|---|
disposeList, equals, equals, fundamentalDispose, getFreeColGameObject, getFreeColGameObject, getGame, getIntegerID, getSpecification, hashCode, isDisposed, isUninitialized, newLocation, readFromXML, readFromXMLPartialByClass, setDefaultId, setGame, setId, toXML, toXMLImpl, toXMLPartialByClass, updateFreeColGameObject |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final java.util.logging.Logger logger
private Tile tile
TileItemContainer.
private java.util.List<TileItem> tileItems
private final java.util.Comparator<TileItem> tileItemComparator
| Constructor Detail |
|---|
public TileItemContainer(Game game,
Tile tile)
TileItemContainer.
game - The Game in which this TileItemContainer belong.tile - The Tile this TileItemContainer will be containg TileItems for.
public TileItemContainer(Game game,
Tile tile,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
TileItemContainer from an XML stream.
game - The Game in which this TileItemContainer
belong.tile - The Tile using this TileItemContainer
for storing it's TileItem.in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.| Method Detail |
|---|
private void invalidateCache()
public Tile getTile()
Tile this TileItemContainer belongs to.
Tile valuepublic final java.util.List<TileItem> getTileItems()
TileItems value.
List valuepublic final void setTileItems(java.util.List<TileItem> newTileItems)
TileItems value.
newTileItems - The new TileItems value.public Resource getResource()
Resource item or null.
Resource valuepublic TileImprovement getImprovement(TileImprovementType type)
type - The TileImprovementType to look for.
public TileImprovement getRoad()
TileImprovement valuepublic TileImprovement getRiver()
TileImprovement valuepublic final LostCityRumour getLostCityRumour()
LostCityRumour value.
LostCityRumour valuepublic void removeIncompatibleImprovements()
public java.util.List<TileImprovement> getImprovements()
List of the TileImprovements
in this TileItemContainer.
List.public java.util.List<TileImprovement> getCompletedImprovements()
List of the completed
TileImprovements in this
TileItemContainer.
List.private java.util.List<TileImprovement> getImprovements(boolean completedOnly)
List of the TileImprovements
in this TileItemContainer.
List.
public int getTotalBonusPotential(GoodsType g,
UnitType unitType,
int tilePotential,
boolean onlyNatural)
true, in
which case only natural Improvements will be considered. This
is necessary in order to calculate secondary production, which
does not profit from artificial Improvements, such as plowing.
g - a GoodsType valueunitType - an UnitType valuetilePotential - an int valueonlyNatural - a boolean value
public java.util.Set<Modifier> getProductionBonus(GoodsType goodsType,
UnitType unitType)
getProductionBonus method here.
goodsType - a GoodsType valueunitType - a UnitType value
Modifier value
public int getMoveCost(int basicMoveCost,
Tile fromTile)
Tile from
another Tile.
Does not consider special unit abilities.
basicMoveCost - The basic cost.fromTile - The Tile to move from.
public TileItem addTileItem(TileItem item)
TileItem to this container.
item - The TileItem to add to this container.
null on errorpublic TileItem removeTileItem(TileItem item)
item - The TileItem to remove from this container.
public <T extends TileItem> void removeAll(java.lang.Class<T> c)
public void copyFrom(TileItemContainer tic)
public void copyFrom(TileItemContainer tic,
boolean importResources)
public void copyFrom(TileItemContainer tic,
boolean importResources,
boolean copyOnlyNatural)
public boolean contains(TileItem t)
TileItem is in this container.
t - The TileItem to test the presence of.
public TileImprovement findTileImprovementType(TileImprovementType type)
type - The TileImprovementType to test the presence of.
public boolean hasImprovement(TileImprovementType type)
type - The type to check for.
public void dispose()
dispose in class FreeColGameObject
public TileImprovement addRiver(int magnitude,
int style)
TileImprovement and adds to this Tile/Container.
Checking for overwrite is done by addTileItem(net.sf.freecol.common.model.TileItem).
magnitude - The Magnitude of the river to be createdstyle - an int value
public TileImprovement removeRiver()
TileImprovement from this Tile/Container.
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.public java.lang.String toString()
String representation of this
TileItemContainer.
toString in class FreeColGameObjectpublic static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||