mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
FCollection: can't inherit from Set anymore because the interfaces might colide
This commit is contained in:
@@ -28,7 +28,7 @@ import java.util.Set;
|
|||||||
* @param <T> the type of the elements this collection contains.
|
* @param <T> the type of the elements this collection contains.
|
||||||
* @see FCollectionView
|
* @see FCollectionView
|
||||||
*/
|
*/
|
||||||
public class FCollection<T> implements List<T>, Set<T>, FCollectionView<T>, Cloneable, Serializable {
|
public class FCollection<T> implements List<T>, /*Set<T>,*/ FCollectionView<T>, Cloneable, Serializable {
|
||||||
private static final long serialVersionUID = -1664555336364294106L;
|
private static final long serialVersionUID = -1664555336364294106L;
|
||||||
|
|
||||||
private static final FCollection<?> EMPTY = new EmptyFCollection<Object>();
|
private static final FCollection<?> EMPTY = new EmptyFCollection<Object>();
|
||||||
@@ -201,6 +201,10 @@ public class FCollection<T> implements List<T>, Set<T>, FCollectionView<T>, Clon
|
|||||||
return set.isEmpty();
|
return set.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<T> asSet() {
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether this collection contains a particular object.
|
* Check whether this collection contains a particular object.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -680,7 +680,7 @@ public class GameAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void checkStaticAbilities() {
|
public final void checkStaticAbilities() {
|
||||||
checkStaticAbilities(true, new CardCollection());
|
checkStaticAbilities(true, Sets.<Card>newHashSet());
|
||||||
}
|
}
|
||||||
public final void checkStaticAbilities(final boolean runEvents, final Set<Card> affectedCards) {
|
public final void checkStaticAbilities(final boolean runEvents, final Set<Card> affectedCards) {
|
||||||
if (isCheckingStaticAbilitiesOnHold()) {
|
if (isCheckingStaticAbilitiesOnHold()) {
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public class AttackConstraints {
|
|||||||
|
|
||||||
// Now try all others (plus empty attack) and count their violations
|
// Now try all others (plus empty attack) and count their violations
|
||||||
final FCollection<Map<Card, GameEntity>> legalAttackers = collectLegalAttackers(reqs, myMax);
|
final FCollection<Map<Card, GameEntity>> legalAttackers = collectLegalAttackers(reqs, myMax);
|
||||||
possible.putAll(Maps.asMap(legalAttackers, FN_COUNT_VIOLATIONS));
|
possible.putAll(Maps.asMap(legalAttackers.asSet(), FN_COUNT_VIOLATIONS));
|
||||||
possible.put(Collections.<Card, GameEntity>emptyMap(), countViolations(Collections.<Card, GameEntity>emptyMap()));
|
possible.put(Collections.<Card, GameEntity>emptyMap(), countViolations(Collections.<Card, GameEntity>emptyMap()));
|
||||||
|
|
||||||
// take the case with the fewest violations
|
// take the case with the fewest violations
|
||||||
@@ -260,7 +260,7 @@ public class AttackConstraints {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (final Predicate<Card> predicateRestriction : predicateRestrictions) {
|
for (final Predicate<Card> 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!
|
// predicate fulfilled already, ignore!
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ public class Combat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final Map<Card, GameEntity> getAttackersAndDefenders() {
|
public final Map<Card, GameEntity> getAttackersAndDefenders() {
|
||||||
return Maps.asMap(getAttackers(), new Function<Card, GameEntity>() {
|
return Maps.asMap(getAttackers().asSet(), new Function<Card, GameEntity>() {
|
||||||
@Override
|
@Override
|
||||||
public GameEntity apply(final Card attacker) {
|
public GameEntity apply(final Card attacker) {
|
||||||
return getDefenderByAttacker(attacker);
|
return getDefenderByAttacker(attacker);
|
||||||
|
|||||||
Reference in New Issue
Block a user