From: "Enrico Weigelt, metux IT consult" <[email protected]>
---
.../sf/freecol/client/gui/panel/PlayersTable.java | 11 ++++++----
src/net/sf/freecol/common/model/Game.java | 17 +++++++++------
src/net/sf/freecol/common/model/Nation.java | 7 ++++--
src/net/sf/freecol/common/model/NationOptions.java | 12 ++++++++---
src/net/sf/freecol/common/model/Specification.java | 25 ++++++++++++----------
5 files changed, 45 insertions(+), 27 deletions(-)
diff --git a/src/net/sf/freecol/client/gui/panel/PlayersTable.java
b/src/net/sf/freecol/client/gui/panel/PlayersTable.java
index bf5524512a7..50b3b835959 100644
--- a/src/net/sf/freecol/client/gui/panel/PlayersTable.java
+++ b/src/net/sf/freecol/client/gui/panel/PlayersTable.java
@@ -26,10 +26,10 @@ import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.function.Predicate;
import javax.swing.AbstractCellEditor;
import javax.swing.DefaultCellEditor;
@@ -445,9 +445,12 @@ public final class PlayersTable extends JTable {
this.preGameController = preGameController;
this.nationOptions = nationOptions;
this.thisPlayer = thisPlayer;
- final Predicate<Nation> nationPred = n -> !n.isUnknownEnemy()
- && nationOptions.getNations().get(n) != null;
- this.nations = transform(spec.getNations(), nationPred);
+
+ this.nations = new ArrayList<>();
+ for (Nation n : spec.getNations())
+ if (!n.isUnknownEnemy() && nationOptions.getNations().get(n)
!= null)
+ this.nations.add(n);
+
for (Nation n : this.nations) this.nationMap.put(n, null);
this.nationMap.put(thisPlayer.getNation(), thisPlayer);
}
diff --git a/src/net/sf/freecol/common/model/Game.java
b/src/net/sf/freecol/common/model/Game.java
index c98265b33e8..7a2eab3e712 100644
--- a/src/net/sf/freecol/common/model/Game.java
+++ b/src/net/sf/freecol/common/model/Game.java
@@ -858,10 +858,11 @@ public class Game extends FreeColGameObject {
* @return A vacant {@code Nation} or null if none found.
*/
public Nation getVacantNation() {
- Entry<Nation, NationState> entry
- = find(nationOptions.getNations().entrySet(),
- matchKey(NationState.AVAILABLE, Entry::getValue));
- return (entry == null) ? null : entry.getKey();
+ for (Entry<Nation, NationState> e :
nationOptions.getNations().entrySet())
+ if (e.getValue() == NationState.AVAILABLE)
+ return e.getKey();
+
+ return null;
}
/**
@@ -870,9 +871,11 @@ public class Game extends FreeColGameObject {
* @return A list of available {@code Nation}s.
*/
public final List<Nation> getVacantNations() {
- return transform(nationOptions.getNations().entrySet(),
- matchKey(NationState.AVAILABLE, Entry::getValue),
- Entry::getKey);
+ List<Nation> result = new ArrayList<>();
+ for (Entry<Nation, NationState> e :
nationOptions.getNations().entrySet())
+ if (NationState.AVAILABLE == e.getValue())
+ result.add(e.getKey());
+ return result;
}
/**
diff --git a/src/net/sf/freecol/common/model/Nation.java
b/src/net/sf/freecol/common/model/Nation.java
index 61126b5d6e6..efbaa55b448 100644
--- a/src/net/sf/freecol/common/model/Nation.java
+++ b/src/net/sf/freecol/common/model/Nation.java
@@ -175,8 +175,11 @@ public class Nation extends FreeColSpecObjectType {
* @return The rebel {@code Nation}, or null if not applicable.
*/
public final Nation getRebelNation() {
- return find(getSpecification().getEuropeanNations(),
- matchKey(this, Nation::getREFNation));
+ for (Nation n : getSpecification().getEuropeanNations())
+ if (n == this)
+ return n;
+
+ return null;
}
/**
diff --git a/src/net/sf/freecol/common/model/NationOptions.java
b/src/net/sf/freecol/common/model/NationOptions.java
index 977df9cbeb1..c86948305de 100644
--- a/src/net/sf/freecol/common/model/NationOptions.java
+++ b/src/net/sf/freecol/common/model/NationOptions.java
@@ -318,9 +318,15 @@ public class NationOptions extends FreeColSpecObject {
StringBuilder sb = new StringBuilder(128);
sb.append(NATIONAL_ADVANTAGES_TAG).append(": ")
.append(nationalAdvantages).append('\n');
- forEachMapEntry(nations,
- e -> sb.append(' ').append(e.getKey().getId())
- .append(' ').append(e.getValue()).append('\n'));
+
+ for (Map.Entry<Nation, NationState> e : nations.entrySet()) {
+ sb.append(' ');
+ sb.append(e.getKey().getId());
+ sb.append(' ');
+ sb.append(e.getValue());
+ sb.append('\n');
+ }
+
return sb.toString();
}
}
diff --git a/src/net/sf/freecol/common/model/Specification.java
b/src/net/sf/freecol/common/model/Specification.java
index 6cf037897c5..4154bc6b0c8 100644
--- a/src/net/sf/freecol/common/model/Specification.java
+++ b/src/net/sf/freecol/common/model/Specification.java
@@ -548,7 +548,11 @@ public final class Specification {
nationTypes.clear();
nationTypes.addAll(indianNationTypes);
nationTypes.addAll(europeanNationTypes);
- REFNationTypes.addAll(transform(europeanNationTypes,
NationType::isREF));
+
+ for (EuropeanNationType nt : europeanNationTypes)
+ if (nt.isREF())
+ REFNationTypes.add(nt);
+
europeanNationTypes.removeAll(REFNationTypes);
experts.clear();
@@ -2102,8 +2106,8 @@ public final class Specification {
});
// Nation FOUND_COLONY -> FOUNDS_COLONIES
- for (EuropeanNationType ent : transform(europeanNationTypes,
- nt -> nt.hasAbility(Ability.FOUND_COLONY))) {
+ for (EuropeanNationType ent : europeanNationTypes) {
+ if (!ent.hasAbility(Ability.FOUND_COLONY)) continue;
ent.removeAbilities(Ability.FOUND_COLONY);
ent.addAbility(new Ability(Ability.FOUNDS_COLONIES, ent, true));
}
@@ -2169,10 +2173,9 @@ public final class Specification {
// ability to have man-o-war. Older specs used
// INDEPENDENCE_DECLARED but we can not directly use that or
// the REF gets access to colonialRegulars.
- for (NationType ent : transform(europeanNationTypes,
- nt -> nt.isREF() &&
!nt.hasAbility(Ability.INDEPENDENT_NATION))) {
- ent.addAbility(new Ability(Ability.INDEPENDENT_NATION));
- }
+ for (NationType ent : europeanNationTypes)
+ if (ent.isREF() && !ent.hasAbility(Ability.INDEPENDENT_NATION))
+ ent.addAbility(new Ability(Ability.INDEPENDENT_NATION));
// Resource type modifiers had the wrong priority
forEach(flatten(resourceTypeList, ResourceType::getModifiers), m -> {
@@ -2209,10 +2212,10 @@ public final class Specification {
}
// European nation type production modifier indexes moved to the spec
- for (Modifier mod : transform(flatten(europeanNationTypes,
- EuropeanNationType::getModifiers), goodsPred)) {
- mod.setModifierIndex(Modifier.NATION_PRODUCTION_INDEX);
- }
+ for (EuropeanNationType ent : europeanNationTypes)
+ for (Modifier m : ent.getModifiers())
+ if (allTypes.get(m.getId()) instanceof GoodsType)
+ m.setModifierIndex(Modifier.NATION_PRODUCTION_INDEX);
// TownHall, Chapel et al now have unattended production types
// (replacing modifiers).
--
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