|
|||||||||
| 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.TileItem
net.sf.freecol.common.model.Resource
public class Resource
Represents a locatable goods of a specified type and quantity.
| Field Summary | |
|---|---|
private static java.util.logging.Logger |
logger
|
private int |
quantity
|
private ResourceType |
type
|
| 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 | |
|---|---|
Resource(Game game,
Tile tile,
ResourceType type)
Creates a standard Resource-instance. |
|
Resource(Game game,
Tile tile,
ResourceType type,
int quantity)
Creates a standard Resource-instance. |
|
Resource(Game game,
javax.xml.stream.XMLStreamReader in)
|
|
| Method Summary | |
|---|---|
GoodsType |
getBestGoodsType()
Returns the best GoodsType |
int |
getBonus(GoodsType goodsType,
UnitType unitType,
int potential)
Returns the bonus (checking available stock) for next turn. |
java.lang.String |
getNameKey()
|
int |
getQuantity()
Returns the current quantity. |
ResourceType |
getType()
Returns the ResourceType of this Resource. |
static java.lang.String |
getXMLElementTagName()
Gets 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 . |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
void |
setQuantity(int newQuantity)
Returns the current quantity. |
java.lang.String |
toString()
Returns a textual representation of this object. |
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. |
int |
useQuantity(GoodsType goodsType,
UnitType unitType,
int potential)
Reduces the available quantity by the bonus output of GoodsType. |
int |
useQuantity(int usedQuantity)
Reduces the value quantity. |
| 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, toXML, toXMLImpl, toXMLPartialByClass, updateFreeColGameObject |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static java.util.logging.Logger logger
private ResourceType type
private int quantity
| Constructor Detail |
|---|
public Resource(Game game,
Tile tile,
ResourceType type,
int quantity)
Resource-instance.
This constructor asserts that the game, tile and type are valid.
game - The Game in which this object belongs.tile - The Tile on which this object sits.type - The ResourceType of this Resource.quantity - an int value
public Resource(Game game,
Tile tile,
ResourceType type)
Resource-instance.
This constructor asserts that the game, tile and type are valid.
game - The Game in which this object belongs.tile - The Tile on which this object sits.type - The ResourceType of this Resource.
public Resource(Game game,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException| Method Detail |
|---|
public java.lang.String toString()
toString in class FreeColGameObjectString of either:
public java.lang.String getNameKey()
public ResourceType getType()
ResourceType of this Resource.
public int getQuantity()
public void setQuantity(int newQuantity)
public final int getZIndex()
ZIndex value.
getZIndex in class TileItemint valuepublic GoodsType getBestGoodsType()
public int getBonus(GoodsType goodsType,
UnitType unitType,
int potential)
goodsType - The GoodsType to checkunitType - an UnitType valuepotential - Potential of Tile + Improvements
int value
public int useQuantity(GoodsType goodsType,
UnitType unitType,
int potential)
GoodsType.
goodsType - The GoodsType to checkunitType - an UnitType valuepotential - Potential of Tile + Improvements
int valuepublic int useQuantity(int usedQuantity)
quantity.
usedQuantity - The quantity that was used up.
public boolean isTileTypeAllowed(TileType tileType)
isTileTypeAllowed in class TileItemtileType - a TileType value
boolean value
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 static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||