From: "Enrico Weigelt, metux IT consult" <[email protected]>
---
src/net/sf/freecol/common/model/Tile.java | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/net/sf/freecol/common/model/Tile.java
b/src/net/sf/freecol/common/model/Tile.java
index ab0485296ef..ecb8dacb3df 100644
--- a/src/net/sf/freecol/common/model/Tile.java
+++ b/src/net/sf/freecol/common/model/Tile.java
@@ -1781,12 +1781,19 @@ public final class Tile extends UnitLocation implements
Named, Ownable {
* @return The {@code AbstractGoods} to produce.
*/
public AbstractGoods getBestFoodProduction() {
- final Comparator<AbstractGoods> goodsComp
- = Comparator.comparingInt(ag ->
- getPotentialProduction(ag.getType(), null));
- return maximize(flatten(getType().getAvailableProductionTypes(true),
- pt -> pt.getOutputs()),
- AbstractGoods::isFoodType, goodsComp);
+ AbstractGoods best_ag = null;
+ int best_pot = 0;
+ for (ProductionType pt : getType().getAvailableProductionTypes(true))
+ for (AbstractGoods ag : pt.getOutputs())
+ if (ag.isFoodType()) {
+ int pot = getPotentialProduction(ag.getType(), null);
+ if (best_ag == null || best_pot < pot) {
+ best_ag = ag;
+ best_pot = pot;
+ }
+ }
+
+ return best_ag;
}
--
2.11.0.rc0.7.gbe5a750
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Freecol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freecol-developers