From a39ac85b15026f95aed701305d6511213a05e915 Mon Sep 17 00:00:00 2001 From: Hanmac Date: Sat, 10 Jun 2017 13:24:52 +0000 Subject: [PATCH] FCollection: can't inherit from Set anymore because the interfaces might colide --- .../src/main/java/forge/util/collect/FCollection.java | 6 +++++- forge-game/src/main/java/forge/game/GameAction.java | 2 +- .../src/main/java/forge/game/combat/AttackConstraints.java | 4 ++-- forge-game/src/main/java/forge/game/combat/Combat.java | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/forge-core/src/main/java/forge/util/collect/FCollection.java b/forge-core/src/main/java/forge/util/collect/FCollection.java index 0ca6ec8375e..7a6e6aef7e1 100644 --- a/forge-core/src/main/java/forge/util/collect/FCollection.java +++ b/forge-core/src/main/java/forge/util/collect/FCollection.java @@ -28,7 +28,7 @@ import java.util.Set; * @param the type of the elements this collection contains. * @see FCollectionView */ -public class FCollection implements List, Set, FCollectionView, Cloneable, Serializable { +public class FCollection implements List, /*Set,*/ FCollectionView, Cloneable, Serializable { private static final long serialVersionUID = -1664555336364294106L; private static final FCollection EMPTY = new EmptyFCollection(); @@ -200,6 +200,10 @@ public class FCollection implements List, Set, FCollectionView, Clon public boolean isEmpty() { return set.isEmpty(); } + + public Set asSet() { + return set; + } /** * Check whether this collection contains a particular object. diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index a69273c0116..c527d3b8b92 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -680,7 +680,7 @@ public class GameAction { } public final void checkStaticAbilities() { - checkStaticAbilities(true, new CardCollection()); + checkStaticAbilities(true, Sets.newHashSet()); } public final void checkStaticAbilities(final boolean runEvents, final Set affectedCards) { if (isCheckingStaticAbilitiesOnHold()) { diff --git a/forge-game/src/main/java/forge/game/combat/AttackConstraints.java b/forge-game/src/main/java/forge/game/combat/AttackConstraints.java index c3b037f1aa0..55ec882f20b 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackConstraints.java +++ b/forge-game/src/main/java/forge/game/combat/AttackConstraints.java @@ -179,7 +179,7 @@ public class AttackConstraints { // Now try all others (plus empty attack) and count their violations final FCollection> legalAttackers = collectLegalAttackers(reqs, myMax); - possible.putAll(Maps.asMap(legalAttackers, FN_COUNT_VIOLATIONS)); + possible.putAll(Maps.asMap(legalAttackers.asSet(), FN_COUNT_VIOLATIONS)); possible.put(Collections.emptyMap(), countViolations(Collections.emptyMap())); // take the case with the fewest violations @@ -260,7 +260,7 @@ public class AttackConstraints { } for (final Predicate predicateRestriction : predicateRestrictions) { - if (Iterables.any(Sets.union(myAttackers.keySet(), reserved), predicateRestriction)) { + if (Iterables.any(Sets.union(myAttackers.keySet(), reserved.asSet()), predicateRestriction)) { // predicate fulfilled already, ignore! continue; } diff --git a/forge-game/src/main/java/forge/game/combat/Combat.java b/forge-game/src/main/java/forge/game/combat/Combat.java index 2e9db03bd31..2366a640c1b 100644 --- a/forge-game/src/main/java/forge/game/combat/Combat.java +++ b/forge-game/src/main/java/forge/game/combat/Combat.java @@ -214,7 +214,7 @@ public class Combat { } public final Map getAttackersAndDefenders() { - return Maps.asMap(getAttackers(), new Function() { + return Maps.asMap(getAttackers().asSet(), new Function() { @Override public GameEntity apply(final Card attacker) { return getDefenderByAttacker(attacker);