示例#1
0
 /** {@inheritDoc} */
 protected void readChild(XMLStreamReader in) throws XMLStreamException {
   if (GoodsContainer.getXMLElementTagName().equals(in.getLocalName())) {
     goodsContainer =
         getGame()
             .getFreeColGameObject(in.getAttributeValue(null, ID_ATTRIBUTE), GoodsContainer.class);
     if (goodsContainer == null) {
       goodsContainer = new GoodsContainer(getGame(), this, in);
     } else {
       goodsContainer.readFromXML(in);
     }
   } else {
     super.readChild(in);
   }
 }
示例#2
0
 /**
  * Checks if this <code>Location</code> contains the specified <code>Locatable</code>.
  *
  * @param locatable The <code>Locatable</code> to test the presence of.
  * @return
  *     <ul>
  *       <li><i>true</i> if the specified <code>Locatable</code> is on this <code>Location</code>
  *           and
  *       <li><i>false</i> otherwise.
  *     </ul>
  */
 public boolean contains(Locatable locatable) {
   if (locatable instanceof Goods) {
     return goodsContainer.contains((Goods) locatable);
   } else {
     return super.contains(locatable);
   }
 }
示例#3
0
 /** {@inheritDoc} */
 protected void writeChildren(
     XMLStreamWriter out, Player player, boolean showAll, boolean toSavedGame)
     throws XMLStreamException {
   super.writeChildren(out, player, showAll, toSavedGame);
   if (goodsContainer != null) {
     goodsContainer.toXML(out, player, showAll, toSavedGame);
   }
 }
示例#4
0
  /**
   * Removes all references to this object.
   *
   * @return A list of disposed objects.
   */
  public List<FreeColGameObject> disposeList() {
    List<FreeColGameObject> objects = new ArrayList<FreeColGameObject>();
    if (goodsContainer != null) {
      objects.addAll(goodsContainer.disposeList());
      goodsContainer = null;
    }
    objects.addAll(super.disposeList());

    return objects;
  }
示例#5
0
 /**
  * Gets the amount of one type of Goods at this Settlement.
  *
  * @param type The type of goods to look for.
  * @return The amount of this type of Goods at this Location.
  */
 public int getGoodsCount(GoodsType type) {
   return goodsContainer.getGoodsCount(type);
 }
示例#6
0
 /**
  * Describe <code>addGoods</code> method here.
  *
  * @param type a <code>GoodsType</code> value
  * @param amount an <code>int</code> value
  */
 public boolean addGoods(GoodsType type, int amount) {
   return goodsContainer.addGoods(type, amount);
 }
示例#7
0
 /**
  * Removes all Goods of the given type from the Settlement.
  *
  * @param type a <code>GoodsType</code> value
  */
 public Goods removeGoods(GoodsType type) {
   return goodsContainer.removeGoods(type);
 }
示例#8
0
 /**
  * Removes the given Goods from the Settlement.
  *
  * @param goods a <code>Goods</code> value
  */
 public Goods removeGoods(AbstractGoods goods) {
   return goodsContainer.removeGoods(goods);
 }
示例#9
0
 /**
  * Removes a specified amount of a type of Goods from this Settlement.
  *
  * @param type The type of Goods to remove from this settlement.
  * @param amount The amount of Goods to remove from this settlement.
  */
 public Goods removeGoods(GoodsType type, int amount) {
   return goodsContainer.removeGoods(type, amount);
 }
示例#10
0
 /**
  * Gets an <code>List</code> with every <code>Goods</code> in this <code>Colony</code>. There is
  * only one <code>Goods</code> for each type of goods.
  *
  * @return The <code>Iterator</code>.
  */
 public List<Goods> getCompactGoods() {
   return goodsContainer.getCompactGoods();
 }
示例#11
0
 /**
  * Gets an <code>Iterator</code> of every <code>Goods</code> in this <code>GoodsContainer</code>.
  * Each <code>Goods</code> have a maximum amount of GoodsContainer.CARGO_SIZE.
  *
  * @return The <code>Iterator</code>.
  */
 public Iterator<Goods> getGoodsIterator() {
   return goodsContainer.getGoodsIterator();
 }