Beispiel #1
0
 /**
  * Chooses a type of goods for some of the natives in a settlement to manufacture. Simple rule:
  * choose the refined goods that is the greatest shortage for which there is a surplus of the raw
  * material.
  *
  * @return A <code>GoodsType</code> to manufacture, or null if none suitable.
  */
 private GoodsType goodsToMake() {
   GoodsType wantGoods = null;
   int diff, wantAmount = -1;
   for (GoodsType g : getSpecification().getGoodsTypeList()) {
     GoodsType produced;
     if (g.isRawMaterial()
         && (produced = g.getOutputType()) != null
         && !produced.isBreedable()
         && produced.isStorable()
         && getGoodsCount(g) > getWantedGoodsAmount(g)
         && (diff = getWantedGoodsAmount(produced) - getGoodsCount(produced)) > wantAmount) {
       wantGoods = produced;
       wantAmount = diff;
     }
   }
   return wantGoods;
 }