mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
Guava migration - Inline Predicates.in
This commit is contained in:
@@ -2450,7 +2450,7 @@ public class ComputerUtil {
|
||||
// not enough good choices, need to fill the rest
|
||||
int minDiff = min - goodChoices.size();
|
||||
if (minDiff > 0) {
|
||||
goodChoices.addAll(Aggregates.random(CardLists.filter(validCards, Predicates.not(Predicates.in(goodChoices))), minDiff));
|
||||
goodChoices.addAll(Aggregates.random(CardLists.filter(validCards, Predicates.not(goodChoices::contains)), minDiff));
|
||||
return goodChoices;
|
||||
}
|
||||
|
||||
|
||||
@@ -924,7 +924,7 @@ public class ComputerUtilCost {
|
||||
public static CardCollection paymentChoicesWithoutTargets(Iterable<Card> choices, SpellAbility source, Player ai) {
|
||||
if (source.usesTargeting()) {
|
||||
final CardCollection targets = new CardCollection(source.getTargets().getTargetCards());
|
||||
choices = Iterables.filter(choices, Predicates.not(Predicates.and(CardPredicates.isController(ai), Predicates.in(targets))));
|
||||
choices = Iterables.filter(choices, Predicates.not(Predicates.and(CardPredicates.isController(ai), targets::contains)));
|
||||
}
|
||||
return new CardCollection(choices);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.util;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
@@ -44,7 +43,4 @@ public class Predicates {
|
||||
return x -> Objects.equals(target, x);
|
||||
}
|
||||
|
||||
public static <T> Predicate<T> in(Collection<? extends T> target) {
|
||||
return target::contains;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public final class FServerManager {
|
||||
broadcastExcept(event, Collections.singleton(notTo));
|
||||
}
|
||||
public void broadcastExcept(final NetEvent event, final Collection<RemoteClient> notTo) {
|
||||
broadcastTo(event, Iterables.filter(clients.values(), Predicates.not(Predicates.in(notTo))));
|
||||
broadcastTo(event, Iterables.filter(clients.values(), Predicates.not(notTo::contains)));
|
||||
}
|
||||
private void broadcastTo(final NetEvent event, final Iterable<RemoteClient> to) {
|
||||
for (final RemoteClient client : to) {
|
||||
|
||||
Reference in New Issue
Block a user