From b46c1deeb4d03f0ee478b3c435c2ad9213e863cc Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 12:03:59 -0400 Subject: [PATCH 01/68] Guava migration - Preliminary --- .../main/java/forge/card/CardRulesPredicates.java | 4 ++-- forge-core/src/main/java/forge/card/DeckHints.java | 14 ++++++-------- forge-game/src/main/java/forge/game/card/Card.java | 1 + .../src/forge/adventure/util/CardUtil.java | 9 +++++---- .../java/forge/gamemodes/quest/BoosterUtils.java | 5 ++--- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/forge-core/src/main/java/forge/card/CardRulesPredicates.java b/forge-core/src/main/java/forge/card/CardRulesPredicates.java index af5d1297cc5..4f581532dc6 100644 --- a/forge-core/src/main/java/forge/card/CardRulesPredicates.java +++ b/forge-core/src/main/java/forge/card/CardRulesPredicates.java @@ -196,7 +196,7 @@ public static Predicate coreType(final boolean isEqual, final String try { return CardRulesPredicates.coreType(isEqual, Enum.valueOf(CardType.CoreType.class, what)); } catch (final Exception e) { - return com.google.common.base.Predicates.alwaysFalse(); + return x -> false; } } @@ -226,7 +226,7 @@ public static Predicate superType(final boolean isEqual, final String try { return CardRulesPredicates.superType(isEqual, Enum.valueOf(CardType.Supertype.class, what)); } catch (final Exception e) { - return com.google.common.base.Predicates.alwaysFalse(); + return x -> false; } } diff --git a/forge-core/src/main/java/forge/card/DeckHints.java b/forge-core/src/main/java/forge/card/DeckHints.java index ef38a23da89..7cc175e2d92 100644 --- a/forge-core/src/main/java/forge/card/DeckHints.java +++ b/forge-core/src/main/java/forge/card/DeckHints.java @@ -123,14 +123,12 @@ public Map> filterByType(Iterable cardList) for (Pair pair : filters) { Type type = pair.getLeft(); String param = pair.getRight(); - Iterable cards = getCardsForFilter(cardList, type, param); - if (cards != null) { - // if a type is used more than once intersect respective matches - if (ret.containsKey(type)) { - Iterables.retainAll(cards, new FCollection<>(ret.get(type))); - } - ret.put(type, cards); + List cards = getCardsForFilter(cardList, type, param); + // if a type is used more than once intersect respective matches + if (ret.containsKey(type)) { + cards.retainAll(new FCollection<>(ret.get(type))); } + ret.put(type, cards); } return ret; } @@ -166,7 +164,7 @@ private Pair parseHint(String hint) { return pair; } - private Iterable getCardsForFilter(Iterable cardList, Type type, String param) { + private List getCardsForFilter(Iterable cardList, Type type, String param) { List cards = new ArrayList<>(); // this is case ABILITY, but other types can also use this when the implicit parsing would miss diff --git a/forge-game/src/main/java/forge/game/card/Card.java b/forge-game/src/main/java/forge/game/card/Card.java index ddbf16e1a2f..cf0beabb337 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -21,6 +21,7 @@ import com.google.common.base.Optional; import com.google.common.base.Predicates; import com.google.common.collect.*; +import com.google.common.collect.Iterables; import forge.GameCommand; import forge.StaticData; import forge.card.*; diff --git a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java index cdf0526385e..e348784c563 100644 --- a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java +++ b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java @@ -5,6 +5,7 @@ import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import forge.StaticData; import forge.adventure.data.ConfigData; import forge.adventure.data.GeneratedDeckData; @@ -804,15 +805,15 @@ public static Deck generateRandomBoosterPackAsDeck(final Predicate } public static PaperCard getCardByName(String cardName) { - List validCards = Arrays.asList(Iterables.toArray(Iterables.filter(getFullCardPool(Config.instance().getSettingData().useAllCardVariants), - input -> input.getCardName().equals(cardName)), PaperCard.class)); + List validCards = Lists.newArrayList(Iterables.filter(getFullCardPool(Config.instance().getSettingData().useAllCardVariants), + input -> input.getCardName().equals(cardName))); return validCards.get(Current.world().getRandom().nextInt(validCards.size())); } public static PaperCard getCardByNameAndEdition(String cardName, String edition) { - List validCards = Arrays.asList(Iterables.toArray(Iterables.filter(getFullCardPool(Config.instance().getSettingData().useAllCardVariants), - input -> input.getCardName().equals(cardName) && input.getEdition().equals(edition)), PaperCard.class)); + List validCards = Lists.newArrayList(Iterables.filter(getFullCardPool(Config.instance().getSettingData().useAllCardVariants), + input -> input.getCardName().equals(cardName) && input.getEdition().equals(edition))); if (validCards.isEmpty()) { System.err.println("Unexpected behavior: tried to call getCardByNameAndEdition for card " + cardName + " from the edition " + edition + ", but didn't find it in the DB. A random existing instance will be returned."); diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java index e3d851abecc..063ab710f10 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java @@ -449,7 +449,7 @@ private static List generateCards( */ public static Predicate parseRulesLimitation(final String input) { if (null == input || "random".equalsIgnoreCase(input)) { - return Predicates.alwaysTrue(); + return null; } if (input.equalsIgnoreCase("black")) return CardRulesPredicates.Presets.IS_BLACK; @@ -491,8 +491,7 @@ private static List parseReward(final String s) { if (temp.length > 2) { Predicate cr = parseRulesLimitation(temp[1]); - //noinspection RedundantCast - if (Predicates.alwaysTrue() != (Object) cr) { // guava has a single instance for always-const predicates + if (cr != null) { preds.add(Predicates.compose(cr, PaperCard::getRules)); } } From bb520b1a60c18d088528f2c16ae1ab72a6c9f400 Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 12:04:24 -0400 Subject: [PATCH 02/68] Guava migration - Create migration scaffold --- .../src/main/java/forge/util/Iterables.java | 193 ++++++++++++++++++ .../src/main/java/forge/util/Predicates.java | 115 +++++++++++ 2 files changed, 308 insertions(+) create mode 100644 forge-core/src/main/java/forge/util/Iterables.java create mode 100644 forge-core/src/main/java/forge/util/Predicates.java diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java new file mode 100644 index 00000000000..8516f8cea95 --- /dev/null +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -0,0 +1,193 @@ +package forge.util; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.StreamSupport; + +/** + * Provides helper methods for Iterables similar to the Guava library, + * but supporting Java 8's implementation of Iterators instead. + */ +public class Iterables { + private Iterables(){} + + //TODO: Migrate everything below. + + public static Iterable filter(Iterable iterable, Predicate filter) { + return () -> StreamSupport.stream(iterable.spliterator(), false).filter(filter).iterator(); + } + public static Iterable filter(final Iterable iterable, final Class desiredType) { + return () -> StreamSupport.stream(iterable.spliterator(), false) + .filter(desiredType::isInstance) + .map(desiredType::cast) + .iterator(); + } + + public static boolean any(Iterable iterable, Predicate test) { + return StreamSupport.stream(iterable.spliterator(), false).anyMatch(test); + } + + public static boolean all(Iterable iterable, Predicate test) { + return StreamSupport.stream(iterable.spliterator(), false).allMatch(test); + } + + @SuppressWarnings("OptionalGetWithoutIsPresent") + public static T find(Iterable iterable, Predicate predicate) { + return StreamSupport.stream(iterable.spliterator(), false).filter(predicate).findFirst().get(); + } + public static T find(Iterable iterable, Predicate predicate, T defaultValue) { + return StreamSupport.stream(iterable.spliterator(), false).filter(predicate).findFirst().orElse(defaultValue); + } + public static Optional tryFind(Iterable iterable, Predicate predicate) { + return StreamSupport.stream(iterable.spliterator(), false).filter(predicate).findFirst(); + } + + public static int indexOf(Iterable iterable, Predicate predicate) { + int index = 0; + for(T i : iterable) { + if(predicate.test(i)) + return index; + index++; + } + return -1; + } + + public static Iterable transform(final Iterable iterable, final Function function) { + return () -> StreamSupport.stream(iterable.spliterator(), false).map(function).iterator(); + } + + //TODO: Inline everything below. + + public static Iterable filter(Collection iterable, Predicate filter) { + return () -> iterable.stream().filter(filter).iterator(); + } + public static boolean any(Collection iterable, Predicate test) { + return iterable.stream().anyMatch(test); + } + public static boolean all(Collection iterable, Predicate test) { + return iterable.stream().allMatch(test); + } + public static T find(Collection iterable, Predicate predicate) { + return iterable.stream().filter(predicate).findFirst().get(); + } + public static T find(Collection iterable, Predicate predicate, T defaultValue) { + return iterable.stream().filter(predicate).findFirst().orElse(defaultValue); + } + + public static boolean removeIf(Iterable iterable, Predicate test) { + //TODO: Convert parameter type + return ((Collection) iterable).removeIf(test); + } + + public static int size(Collection collection) { + return collection.size(); + } + + public static boolean contains(Collection collection, Object element) { + return collection.contains(element); + } + + public static boolean addAll(Collection collection, Collection toAdd) { + return collection.addAll(toAdd); + } + + public static void addAll(Collection collection, Iterable toAdd) { + toAdd.forEach(collection::add); + } + + public static T getFirst(List iterable, T defaultValue) { + return iterable.isEmpty() ? defaultValue : iterable.getFirst(); + } + + public static T getLast(List iterable) { + return iterable.getLast(); + } + public static T getLast(List iterable, T defaultValue) { + return iterable.isEmpty() ? defaultValue : iterable.getLast(); + } + public static boolean isEmpty(Collection iterable) { + return iterable.isEmpty(); + } + + //TODO: Restore everything below + public static Iterable unmodifiableIterable(final Iterable iterable) { + return com.google.common.collect.Iterables.unmodifiableIterable(iterable); + } + + public static int size(Iterable iterable) { + return com.google.common.collect.Iterables.size(iterable); + } + + public static boolean contains(Iterable iterable, Object element) { + return com.google.common.collect.Iterables.contains(iterable, element); + } + + public static boolean addAll_withReturn(Collection collection, Iterable toAdd) { + return com.google.common.collect.Iterables.addAll(collection, toAdd); + } + + public static Iterable concat(Iterable a, Iterable b) { + return com.google.common.collect.Iterables.concat(a, b); + } + public static Iterable concat(Iterable> inputs) { + return com.google.common.collect.Iterables.concat(inputs); + } + + public static T get(Iterable iterable, int position) { + return com.google.common.collect.Iterables.get(iterable, position); + } + + public static T getFirst(Iterable iterable, T defaultValue) { + return com.google.common.collect.Iterables.getFirst(iterable, defaultValue); + } + + public static T getLast(Iterable iterable) { + return com.google.common.collect.Iterables.getLast(iterable); + } + public static T getLast(Iterable iterable, T defaultValue) { + return com.google.common.collect.Iterables.getLast(iterable, defaultValue); + } + + public static Iterable limit(final Iterable iterable, final int limitSize) { + return com.google.common.collect.Iterables.limit(iterable, limitSize); + } + + public static boolean isEmpty(Iterable iterable) { + return com.google.common.collect.Iterables.isEmpty(iterable); + } + + + //TODO: Delete everything below. + public static Iterable filter(Iterable iterable, com.google.common.base.Predicate filter) { + return com.google.common.collect.Iterables.filter(iterable, filter); + } + public static boolean any(Iterable iterable, com.google.common.base.Predicate filter) { + return com.google.common.collect.Iterables.any(iterable, filter); + } + public static boolean all(Iterable iterable, com.google.common.base.Predicate filter) { + return com.google.common.collect.Iterables.any(iterable, filter); + } + public static boolean removeIf(Iterable iterable, com.google.common.base.Predicate test) { + return com.google.common.collect.Iterables.removeIf(iterable, test); + } + public static T find(Iterable iterable, com.google.common.base.Predicate predicate) { + return com.google.common.collect.Iterables.find(iterable, predicate); + } + public static T find(Iterable iterable, com.google.common.base.Predicate predicate, T defaultValue) { + return com.google.common.collect.Iterables.find(iterable, predicate, defaultValue); + } + public static com.google.common.base.Optional tryFind(Iterable iterable, com.google.common.base.Predicate predicate) { + return com.google.common.collect.Iterables.tryFind(iterable, predicate); + } + + public static int indexOf(Iterable iterable, com.google.common.base.Predicate predicate) { + return com.google.common.collect.Iterables.indexOf(iterable, predicate); + } + + public static Iterable transform(Iterable iterable, com.google.common.base.Function function) { + return com.google.common.collect.Iterables.transform(iterable, function); + } +} diff --git a/forge-core/src/main/java/forge/util/Predicates.java b/forge-core/src/main/java/forge/util/Predicates.java new file mode 100644 index 00000000000..b44d50088b1 --- /dev/null +++ b/forge-core/src/main/java/forge/util/Predicates.java @@ -0,0 +1,115 @@ +package forge.util; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Objects; +import java.util.function.Function; +import java.util.function.Predicate; + +public class Predicates { + private Predicates(){} + + //TODO: Migrate everything below. + public static Predicate and(Iterable> components) { + //TODO: Should be able to clean up the casting here. + return x -> Iterables.all(components, (Predicate>) i -> i.test(x)); + } + public static Predicate and(Predicate... components) { + //TODO: Switch to iterables all once it stops being confused and the others are inlined. + //Or just switch this to chained "and"s by hand. + return x -> { + for(Predicate predicate : components) { + if(!predicate.test(x)) + return false; + } + return true; + }; + } + public static Predicate or(Iterable> components) { + //TODO: Should be able to clean up the casting here. + return x -> Iterables.any(components, (Predicate>) i -> i.test(x)); + } + public static Predicate or(Predicate... components) { + //TODO: Faster implementation. Or just do this one by hand. + return or(Arrays.asList(components)); + } + + public static Predicate compose(Predicate predicate, Function function) { + return x -> predicate.test(function.apply(x)); + } + + + //TODO: Inline everything below. + public static Predicate alwaysTrue() { + return x -> true; + } + public static Predicate not(Predicate predicate) { + return predicate.negate(); + } + + public static Predicate and(Predicate first, Predicate second) { + //TODO: remove casting? + return ((Predicate) first).and(second); + } + + public static Predicate or(Predicate first, Predicate second) { + //TODO: remove casting? + return ((Predicate) first).or(second); + } + + //TODO: Uncomment all when switching off Guava. Then Inline. + + //TODO: This one probably needs case by case; nullable targets need a safe test, whereas nonnull targets can be simplified further. +// public static Predicate equalTo(T target) { +// return x -> Objects.equals(target, x); +// } + +// public static Predicate instanceOf(Class clazz) { +// return clazz::isInstance; +// } +// public static Predicate in(Collection target) { +// return target::contains; +// } + + + + //TODO: Delete everything below. + public static com.google.common.base.Predicate not(com.google.common.base.Predicate predicate) { + return com.google.common.base.Predicates.not(predicate); + } + + public static com.google.common.base.Predicate and(Iterable> components) { + return com.google.common.base.Predicates.and(components); + } + public static com.google.common.base.Predicate and(com.google.common.base.Predicate... components) { + return com.google.common.base.Predicates.and(components); + } + public static com.google.common.base.Predicate and(com.google.common.base.Predicate first, com.google.common.base.Predicate second) { + return com.google.common.base.Predicates.and(first, second); + } + public static com.google.common.base.Predicate or(Iterable> components) { + return com.google.common.base.Predicates.or(components); + } + public static com.google.common.base.Predicate or(com.google.common.base.Predicate... components) { + return com.google.common.base.Predicates.or(components); + } + public static com.google.common.base.Predicate or(com.google.common.base.Predicate first, com.google.common.base.Predicate second) { + return com.google.common.base.Predicates.or(first, second); + } + + public static com.google.common.base.Predicate equalTo(T target) { + return com.google.common.base.Predicates.equalTo(target); + } + public static com.google.common.base.Predicate instanceOf(Class clazz) { + return com.google.common.base.Predicates.instanceOf(clazz); + } + public static com.google.common.base.Predicate in(Collection target) { + return com.google.common.base.Predicates.in(target); + } + + public static com.google.common.base.Predicate compose( + com.google.common.base.Predicate predicate, + com.google.common.base.Function function) { + return com.google.common.base.Predicates.compose(predicate, function); + } +} From fb16a4638904a623b677542fb0d891fa335b4fea Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 12:29:50 -0400 Subject: [PATCH 03/68] Guava migration - Remove `Functions` dependency --- .../src/main/java/forge/util/Aggregates.java | 36 ++++++++++++++++--- .../java/forge/game/ability/AbilityUtils.java | 9 +++-- .../ability/effects/CountersRemoveEffect.java | 3 +- .../trigger/TriggerCounterPlayerAddedAll.java | 4 +-- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/forge-core/src/main/java/forge/util/Aggregates.java b/forge-core/src/main/java/forge/util/Aggregates.java index 65ebcbedcdb..d4d707410e2 100644 --- a/forge-core/src/main/java/forge/util/Aggregates.java +++ b/forge-core/src/main/java/forge/util/Aggregates.java @@ -1,10 +1,6 @@ package forge.util; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; import com.google.common.base.Function; @@ -29,6 +25,16 @@ public static final Integer max(final Iterable source, final Function source) { + if (source == null) return null; + int max = Integer.MIN_VALUE; + for (int value : source) { + if (value > max) + max = value; + } + return max; + } + public static final Integer min(final Iterable source, final Function valueAccessor) { if (source == null) { return null; } int max = Integer.MAX_VALUE; @@ -41,6 +47,16 @@ public static final Integer min(final Iterable source, final Function source) { + if (source == null) return null; + int min = Integer.MAX_VALUE; + for (int value : source) { + if (value < min) + min = value; + } + return min; + } + public static final T itemWithMax(final Iterable source, final Function valueAccessor) { if (source == null) { return null; } int max = Integer.MIN_VALUE; @@ -83,6 +99,16 @@ public static final int sum(final Iterable source, final Function source) { + int result = 0; + if(source != null) { + for(final Integer value : source) { + result += value; + } + } + return result; + } + public static final T random(final T[] source) { if (source == null) { return null; } diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index 036fff0cd28..a7ba87565c5 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -1,6 +1,5 @@ package forge.game.ability; -import com.google.common.base.Functions; import com.google.common.collect.*; import forge.card.CardStateName; import forge.card.CardType; @@ -674,9 +673,9 @@ else if (calcX[0].startsWith("TriggerCount")) { @SuppressWarnings("unchecked") Iterable numbers = (Iterable) to; if (calcX[0].endsWith("Max")) { - count = Aggregates.max(numbers, Functions.identity()); + count = Aggregates.max(numbers); } else { - count = Aggregates.sum(numbers, Functions.identity()); + count = Aggregates.sum(numbers); } } else { count = (Integer) to; @@ -2390,7 +2389,7 @@ public static int xCount(Card c, final String s, final CardTraitBase ctb) { } else if (sq[0].startsWith("Num")) { num = dmgInstances.size(); } else { - num = Aggregates.sum(dmgInstances, Functions.identity()); + num = Aggregates.sum(dmgInstances); } return doXMath(num, expr, c, ctb); } @@ -3528,7 +3527,7 @@ public static int playerXProperty(final Player player, final String s, final Car if (value.contains("Counters")) { int count = 0; if (sq[1].equals("ALL")) { - count = Aggregates.sum(player.getCounters().values(), Functions.identity()); + count = Aggregates.sum(player.getCounters().values()); } else { count = player.getCounters(CounterType.getType(sq[1])); } diff --git a/forge-game/src/main/java/forge/game/ability/effects/CountersRemoveEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CountersRemoveEffect.java index d2baf42e9e3..4843b7439a6 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CountersRemoveEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CountersRemoveEffect.java @@ -5,7 +5,6 @@ import forge.game.card.*; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -233,7 +232,7 @@ protected int removeAnyType(GameEntity entity, int cntToRemove, SpellAbility sa) int max = Math.min(cntToRemove, tgtCounters.get(chosenType)); // remove selection so player can't cheat additional trigger by choosing the same type multiple times tgtCounters.remove(chosenType); - int remaining = Aggregates.sum(tgtCounters.values(), Functions.identity()); + int remaining = Aggregates.sum(tgtCounters.values()); // player must choose enough so he can still reach the amount with other types int min = sa.hasParam("UpTo") ? 0 : Math.max(1, max - remaining); prompt = Localizer.getInstance().getMessage("lblSelectRemoveCountersNumberOfTarget", chosenType.getName()); diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerCounterPlayerAddedAll.java b/forge-game/src/main/java/forge/game/trigger/TriggerCounterPlayerAddedAll.java index b8891816b9e..26d4e200348 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerCounterPlayerAddedAll.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerCounterPlayerAddedAll.java @@ -2,8 +2,6 @@ import java.util.Map; -import com.google.common.base.Functions; - import forge.game.ability.AbilityKey; import forge.game.card.Card; import forge.game.card.CounterType; @@ -38,7 +36,7 @@ public boolean performTest(Map runParams) { @Override public void setTriggeringObjects(SpellAbility sa, Map runParams) { sa.setTriggeringObjectsFrom(runParams, AbilityKey.Source, AbilityKey.Object, AbilityKey.CounterMap); - sa.setTriggeringObject(AbilityKey.Amount, Aggregates.sum(((Map) runParams.get(AbilityKey.CounterMap)).values(), Functions.identity())); + sa.setTriggeringObject(AbilityKey.Amount, Aggregates.sum(((Map) runParams.get(AbilityKey.CounterMap)).values())); } @Override From 4d6292802fba4772e6b53d7c3120354d07ef2925 Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 14:52:42 -0400 Subject: [PATCH 04/68] Guava migration - Migrate static libraries --- .../main/java/forge/ai/AiAttackController.java | 6 +----- .../src/main/java/forge/ai/AiBlockController.java | 2 +- forge-ai/src/main/java/forge/ai/AiController.java | 7 +------ .../src/main/java/forge/ai/AiCostDecision.java | 2 +- forge-ai/src/main/java/forge/ai/ComputerUtil.java | 10 +++++----- .../src/main/java/forge/ai/ComputerUtilCard.java | 7 +------ .../main/java/forge/ai/ComputerUtilCombat.java | 2 +- .../src/main/java/forge/ai/ComputerUtilCost.java | 4 ++-- .../src/main/java/forge/ai/ComputerUtilMana.java | 9 +++++++-- .../main/java/forge/ai/PlayerControllerAi.java | 10 +++++----- .../src/main/java/forge/ai/SpecialAiLogic.java | 2 +- .../src/main/java/forge/ai/SpecialCardAi.java | 6 +----- .../src/main/java/forge/ai/SpellAbilityAi.java | 2 +- .../src/main/java/forge/ai/ability/AmassAi.java | 2 +- .../src/main/java/forge/ai/ability/AnimateAi.java | 2 +- .../main/java/forge/ai/ability/AssignGroupAi.java | 3 +-- .../src/main/java/forge/ai/ability/AttachAi.java | 2 +- .../main/java/forge/ai/ability/ChangeZoneAi.java | 4 ++-- .../java/forge/ai/ability/ChangeZoneAllAi.java | 3 +-- .../main/java/forge/ai/ability/ChooseCardAi.java | 5 ++--- .../java/forge/ai/ability/ChooseCardNameAi.java | 2 +- .../java/forge/ai/ability/ChooseGenericAi.java | 2 +- .../java/forge/ai/ability/ChoosePlayerAi.java | 2 +- .../java/forge/ai/ability/ChooseSourceAi.java | 5 ++--- .../main/java/forge/ai/ability/ChooseTypeAi.java | 2 +- .../src/main/java/forge/ai/ability/ClashAi.java | 3 +-- .../src/main/java/forge/ai/ability/CloneAi.java | 3 +-- .../main/java/forge/ai/ability/ControlGainAi.java | 2 +- .../forge/ai/ability/ControlGainVariantAi.java | 5 ++--- .../java/forge/ai/ability/CopyPermanentAi.java | 5 ++--- .../main/java/forge/ai/ability/CountersAi.java | 3 +-- .../java/forge/ai/ability/CountersMoveAi.java | 3 +-- .../java/forge/ai/ability/CountersMultiplyAi.java | 4 ++-- .../forge/ai/ability/CountersProliferateAi.java | 2 +- .../main/java/forge/ai/ability/CountersPutAi.java | 4 ++-- .../forge/ai/ability/CountersPutOrRemoveAi.java | 2 +- .../java/forge/ai/ability/CountersRemoveAi.java | 4 ++-- .../main/java/forge/ai/ability/DamageDealAi.java | 2 +- .../src/main/java/forge/ai/ability/DebuffAi.java | 2 +- .../src/main/java/forge/ai/ability/DestroyAi.java | 2 +- .../main/java/forge/ai/ability/DestroyAllAi.java | 2 +- .../src/main/java/forge/ai/ability/DigAi.java | 3 +-- .../src/main/java/forge/ai/ability/EffectAi.java | 4 ++-- .../java/forge/ai/ability/LegendaryRuleAi.java | 3 +-- .../main/java/forge/ai/ability/LifeGainAi.java | 3 +-- .../main/java/forge/ai/ability/LifeLoseAi.java | 3 +-- .../src/main/java/forge/ai/ability/LifeSetAi.java | 3 +-- .../src/main/java/forge/ai/ability/ManaAi.java | 5 ++--- .../java/forge/ai/ability/ManifestBaseAi.java | 3 +-- .../src/main/java/forge/ai/ability/MeldAi.java | 5 ++--- .../main/java/forge/ai/ability/MustBlockAi.java | 3 +-- .../src/main/java/forge/ai/ability/MutateAi.java | 3 +-- .../main/java/forge/ai/ability/PermanentAi.java | 4 ++-- .../src/main/java/forge/ai/ability/PhasesAi.java | 2 +- .../src/main/java/forge/ai/ability/PlayAi.java | 2 +- .../src/main/java/forge/ai/ability/PumpAi.java | 4 ++-- .../main/java/forge/ai/ability/PumpAiBase.java | 4 ++-- .../src/main/java/forge/ai/ability/PumpAllAi.java | 3 +-- .../src/main/java/forge/ai/ability/RepeatAi.java | 2 +- .../src/main/java/forge/ai/ability/RevealAi.java | 3 +-- .../src/main/java/forge/ai/ability/ScryAi.java | 3 +-- .../src/main/java/forge/ai/ability/TapAiBase.java | 2 +- .../src/main/java/forge/ai/ability/TapAllAi.java | 3 +-- .../main/java/forge/ai/ability/TimeTravelAi.java | 3 +-- .../src/main/java/forge/ai/ability/TokenAi.java | 3 +-- .../src/main/java/forge/ai/ability/UntapAi.java | 4 ++-- .../main/java/forge/ai/ability/UntapAllAi.java | 3 +-- forge-core/src/main/java/forge/card/CardDb.java | 10 +++++----- .../src/main/java/forge/card/CardEdition.java | 3 ++- .../src/main/java/forge/card/CardRules.java | 2 +- .../main/java/forge/card/CardRulesPredicates.java | 9 ++------- forge-core/src/main/java/forge/card/CardType.java | 8 ++++---- .../src/main/java/forge/card/DeckHints.java | 4 ++-- .../src/main/java/forge/deck/DeckFormat.java | 4 ++-- .../java/forge/deck/generation/DeckGenPool.java | 4 ++-- .../forge/deck/generation/DeckGeneratorBase.java | 7 +------ .../src/main/java/forge/item/IPaperCard.java | 6 +++--- .../src/main/java/forge/item/ItemPredicate.java | 2 +- .../src/main/java/forge/item/SealedProduct.java | 4 ++-- .../forge/item/generation/BoosterGenerator.java | 6 +----- .../forge/item/generation/UnOpenedProduct.java | 2 +- .../src/main/java/forge/util/Iterables.java | 15 +++++++++++++++ forge-core/src/main/java/forge/util/Lang.java | 1 - .../main/java/forge/util/collect/FCollection.java | 2 +- .../main/java/forge/util/storage/StorageBase.java | 2 +- .../src/main/java/forge/game/ForgeScript.java | 3 +-- forge-game/src/main/java/forge/game/Game.java | 12 +++++++----- .../src/main/java/forge/game/GameAction.java | 1 + .../src/main/java/forge/game/GameEntity.java | 2 +- .../src/main/java/forge/game/GameEntityView.java | 3 +-- .../src/main/java/forge/game/GameFormat.java | 2 +- .../main/java/forge/game/GameLogFormatter.java | 6 +----- forge-game/src/main/java/forge/game/GameView.java | 3 +-- forge-game/src/main/java/forge/game/Match.java | 8 +++++++- .../src/main/java/forge/game/StaticEffects.java | 2 +- .../java/forge/game/ability/AbilityUtils.java | 1 + .../forge/game/ability/SpellAbilityEffect.java | 6 +----- .../forge/game/ability/effects/AmassEffect.java | 2 +- .../forge/game/ability/effects/AttachEffect.java | 2 +- .../forge/game/ability/effects/BidLifeEffect.java | 3 +-- .../game/ability/effects/ChangeTargetsEffect.java | 2 +- .../game/ability/effects/ChangeZoneAllEffect.java | 3 +-- .../game/ability/effects/ChangeZoneEffect.java | 2 -- .../ability/effects/ChooseCardNameEffect.java | 6 +----- .../game/ability/effects/ChooseGenericEffect.java | 2 +- .../forge/game/ability/effects/CloneEffect.java | 2 +- .../game/ability/effects/ControlSpellEffect.java | 3 +-- .../game/ability/effects/CopyPermanentEffect.java | 7 +------ .../ability/effects/CopySpellAbilityEffect.java | 2 +- .../game/ability/effects/CountersPutEffect.java | 6 +----- .../game/ability/effects/DamageDealEffect.java | 2 +- .../ability/effects/DelayedTriggerEffect.java | 2 +- .../forge/game/ability/effects/DiscardEffect.java | 6 +----- .../forge/game/ability/effects/EffectEffect.java | 2 +- .../ability/effects/InternalRadiationEffect.java | 2 +- .../game/ability/effects/MakeCardEffect.java | 2 +- .../game/ability/effects/ManifestBaseEffect.java | 3 +-- .../game/ability/effects/MultiplePilesEffect.java | 2 +- .../forge/game/ability/effects/PlayEffect.java | 7 +------ .../ability/effects/PlayLandVariantEffect.java | 4 ++-- .../forge/game/ability/effects/PumpAllEffect.java | 2 +- .../forge/game/ability/effects/PumpEffect.java | 6 +----- .../effects/RearrangeTopOfLibraryEffect.java | 3 +-- .../game/ability/effects/RepeatEachEffect.java | 2 +- .../game/ability/effects/TokenEffectBase.java | 2 +- .../forge/game/ability/effects/VentureEffect.java | 3 +-- .../src/main/java/forge/game/card/Card.java | 3 +-- .../main/java/forge/game/card/CardDamageMap.java | 2 +- .../java/forge/game/card/CardFactoryUtil.java | 10 +++++----- .../src/main/java/forge/game/card/CardLists.java | 4 ++-- .../main/java/forge/game/card/CardPredicates.java | 2 +- .../main/java/forge/game/card/CardProperty.java | 2 +- .../src/main/java/forge/game/card/CardState.java | 2 +- .../src/main/java/forge/game/card/CardUtil.java | 2 +- .../src/main/java/forge/game/card/CardView.java | 6 +----- .../main/java/forge/game/card/CardZoneTable.java | 6 ++++-- .../java/forge/game/card/TokenCreateTable.java | 2 +- .../java/forge/game/card/token/TokenInfo.java | 2 +- .../java/forge/game/combat/AttackConstraints.java | 4 ++-- .../java/forge/game/combat/AttackRestriction.java | 3 +-- .../forge/game/combat/AttackRestrictionType.java | 2 +- .../src/main/java/forge/game/combat/Combat.java | 8 +++++++- .../main/java/forge/game/combat/CombatUtil.java | 2 +- .../main/java/forge/game/cost/CostSacrifice.java | 2 +- .../game/event/GameEventCardStatsChanged.java | 3 +-- .../game/event/GameEventPlayerStatsChanged.java | 3 +-- .../java/forge/game/mana/ManaCostBeingPaid.java | 2 +- .../main/java/forge/game/phase/PhaseHandler.java | 6 +++++- .../src/main/java/forge/game/phase/Untap.java | 4 ++-- .../src/main/java/forge/game/player/Player.java | 2 +- .../java/forge/game/player/PlayerCollection.java | 2 +- .../java/forge/game/player/PlayerPredicates.java | 2 +- .../java/forge/game/player/PlayerProperty.java | 2 +- .../main/java/forge/game/player/PlayerView.java | 2 +- .../java/forge/game/player/RegisteredPlayer.java | 2 +- .../forge/game/spellability/SpellAbility.java | 15 ++++++++------- .../game/spellability/SpellAbilityCondition.java | 2 +- .../spellability/SpellAbilityRestriction.java | 2 +- .../forge/game/spellability/TargetChoices.java | 4 ++-- .../StaticAbilityCantAttackBlock.java | 3 +-- .../staticability/StaticAbilityContinuous.java | 2 +- .../StaticAbilityDisableTriggers.java | 2 +- .../staticability/StaticAbilityPanharmonicon.java | 4 ++-- .../src/main/java/forge/game/trigger/Trigger.java | 2 +- .../game/trigger/TriggerAbilityTriggered.java | 2 +- .../game/trigger/TriggerAttackerBlocked.java | 3 +-- .../game/trigger/TriggerAttackersDeclared.java | 2 +- .../forge/game/trigger/TriggerChangesZone.java | 4 ++-- .../forge/game/trigger/TriggerChangesZoneAll.java | 3 +-- .../java/forge/game/trigger/TriggerHandler.java | 2 +- .../forge/game/trigger/TriggerPhaseOutAll.java | 2 +- .../java/forge/game/trigger/TriggerTapAll.java | 2 +- .../game/trigger/TriggerTokenCreatedOnce.java | 3 +-- .../src/main/java/forge/game/zone/MagicStack.java | 6 +++++- .../src/main/java/forge/game/zone/PlayerZone.java | 2 +- .../src/main/java/forge/game/zone/Zone.java | 2 +- .../main/java/forge/gui/ImportSourceAnalyzer.java | 2 +- .../main/java/forge/itemmanager/CardManager.java | 2 +- .../main/java/forge/itemmanager/ItemManager.java | 7 +------ .../itemmanager/filters/AdvancedSearchFilter.java | 2 +- .../forge/itemmanager/filters/CardCMCFilter.java | 2 +- .../itemmanager/filters/CardCMCRangeFilter.java | 2 +- .../itemmanager/filters/CardPowerFilter.java | 2 +- .../itemmanager/filters/CardToughnessFilter.java | 2 +- .../forge/itemmanager/filters/CardTypeFilter.java | 2 +- .../forge/itemmanager/filters/StatTypeFilter.java | 3 +-- .../itemmanager/filters/TextSearchFilter.java | 2 +- .../main/java/forge/screens/bazaar/CBazaarUI.java | 3 +-- .../screens/deckeditor/AddBasicLandsDialog.java | 2 +- .../deckeditor/controllers/ACEditorBase.java | 3 +-- .../screens/deckeditor/controllers/CDeckgen.java | 4 ++-- .../deckeditor/controllers/CEditorCommander.java | 2 +- .../deckeditor/controllers/CEditorQuest.java | 2 +- .../deckeditor/controllers/CEditorVariant.java | 2 +- .../deckeditor/controllers/CStatistics.java | 2 +- .../controllers/CStatisticsImporter.java | 2 +- .../src/main/java/forge/screens/home/CLobby.java | 3 +-- .../src/main/java/forge/screens/home/VLobby.java | 6 +----- .../forge/screens/match/controllers/CCombat.java | 3 +-- .../screens/workshop/views/VWorkshopCatalog.java | 3 +-- .../src/test/java/forge/card/LegacyCardDb.java | 6 +----- .../util/PlayerControllerForTests.java | 2 +- .../util/SpecificationHandler.java | 3 +-- .../src/test/java/forge/item/DeckHintsTest.java | 2 +- .../PlanarConquestCommanderGeneraterGA.java | 4 ++-- .../PlanarConquestGeneraterGA.java | 6 +----- .../PlanarConquestTribalGeneraterGA.java | 4 ++-- .../forge/adventure/character/EnemySprite.java | 2 +- .../forge/adventure/data/AdventureEventData.java | 2 +- .../src/forge/adventure/data/RewardData.java | 2 +- .../src/forge/adventure/util/CardUtil.java | 4 ++-- .../src/forge/deck/AddBasicLandsDialog.java | 2 +- forge-gui-mobile/src/forge/deck/FDeckEditor.java | 1 - .../src/forge/itemmanager/ItemManager.java | 4 ++-- .../itemmanager/filters/AdvancedSearchFilter.java | 2 +- .../forge/itemmanager/filters/CardCMCFilter.java | 2 +- .../filters/CardColorlessCostFilter.java | 2 +- .../itemmanager/filters/CardFormatFilter.java | 2 +- .../itemmanager/filters/CardPowerFilter.java | 2 +- .../itemmanager/filters/CardToughnessFilter.java | 2 +- .../forge/itemmanager/filters/CardTypeFilter.java | 2 +- .../itemmanager/filters/DeckFormatFilter.java | 2 +- .../itemmanager/filters/TextSearchFilter.java | 2 +- .../forge/screens/constructed/LobbyScreen.java | 2 +- .../src/forge/screens/match/MatchController.java | 2 +- .../src/forge/screens/match/views/VReveal.java | 2 +- .../planarconquest/ConquestAEtherScreen.java | 7 +------ .../planarconquest/ConquestPlaneSelector.java | 2 +- .../screens/planarconquest/NewConquestScreen.java | 3 +-- forge-gui-mobile/src/forge/toolbox/GuiChoose.java | 2 +- .../src/forge/toolbox/ListChooser.java | 4 ++-- .../forge/deck/CardRelationMatrixGenerator.java | 4 ++-- .../java/forge/deck/CommanderDeckGenerator.java | 4 ++-- forge-gui/src/main/java/forge/deck/DeckProxy.java | 4 ++-- .../src/main/java/forge/deck/DeckgenUtil.java | 6 +----- .../main/java/forge/deck/RandomDeckGenerator.java | 3 +-- .../forge/gamemodes/limited/BoosterDraft.java | 6 +----- .../java/forge/gamemodes/limited/CardRanker.java | 2 +- .../limited/CardThemedCommanderDeckBuilder.java | 4 ++-- .../limited/CardThemedConquestDeckBuilder.java | 4 ++-- .../gamemodes/limited/CardThemedDeckBuilder.java | 4 ++-- .../gamemodes/limited/LimitedDeckBuilder.java | 4 ++-- .../forge/gamemodes/limited/LimitedPlayer.java | 2 +- .../forge/gamemodes/limited/LimitedPlayerAI.java | 4 ++-- .../gamemodes/limited/SealedDeckBuilder.java | 3 +-- .../forge/gamemodes/limited/WinstonDraft.java | 4 ++-- .../forge/gamemodes/match/AbstractGuiGame.java | 2 +- .../match/input/InputSelectManyBase.java | 3 +-- .../gamemodes/match/input/InputSelectTargets.java | 1 - .../gamemodes/net/server/FServerManager.java | 4 ++-- .../gamemodes/planarconquest/ConquestRegion.java | 2 +- .../gamemodes/planarconquest/ConquestUtil.java | 2 +- .../java/forge/gamemodes/quest/BoosterUtils.java | 4 ++-- .../forge/gamemodes/quest/QuestRewardCard.java | 2 +- .../gamemodes/quest/QuestRewardCardChooser.java | 2 +- .../gamemodes/quest/QuestRewardCardFiltered.java | 2 +- .../forge/gamemodes/quest/QuestUtilCards.java | 6 +----- .../gamemodes/quest/QuestUtilUnlockSets.java | 2 +- .../java/forge/gui/card/CardScriptParser.java | 2 +- .../gui/download/GuiDownloadSetPicturesLQ.java | 3 +-- .../src/main/java/forge/gui/util/SGuiChoose.java | 2 +- .../java/forge/itemmanager/AdvancedSearch.java | 2 +- .../java/forge/itemmanager/BooleanExpression.java | 2 +- .../main/java/forge/itemmanager/ColumnDef.java | 2 +- .../main/java/forge/itemmanager/SFilterUtil.java | 2 +- .../achievements/AgainstAllOdds.java | 5 ++--- forge-gui/src/main/java/forge/model/FModel.java | 1 - .../main/java/forge/player/HumanCostDecision.java | 2 -- .../src/main/java/forge/player/HumanPlay.java | 3 +-- .../java/forge/player/HumanPlaySpellAbility.java | 3 +-- .../java/forge/player/PlayerControllerHuman.java | 1 + .../main/java/forge/player/TargetSelection.java | 2 +- .../main/java/forge/lda/LDAModelGenetrator.java | 4 ++-- 273 files changed, 392 insertions(+), 514 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiAttackController.java b/forge-ai/src/main/java/forge/ai/AiAttackController.java index 3c5f26bb602..509c86c0f59 100644 --- a/forge-ai/src/main/java/forge/ai/AiAttackController.java +++ b/forge-ai/src/main/java/forge/ai/AiAttackController.java @@ -18,8 +18,6 @@ package forge.ai; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.ability.AnimateAi; import forge.game.GameEntity; @@ -42,9 +40,7 @@ import forge.game.trigger.Trigger; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; -import forge.util.Aggregates; -import forge.util.Expressions; -import forge.util.MyRandom; +import forge.util.*; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; import org.apache.commons.lang3.tuple.Pair; diff --git a/forge-ai/src/main/java/forge/ai/AiBlockController.java b/forge-ai/src/main/java/forge/ai/AiBlockController.java index 324f8b0554b..d8e1727a4de 100644 --- a/forge-ai/src/main/java/forge/ai/AiBlockController.java +++ b/forge-ai/src/main/java/forge/ai/AiBlockController.java @@ -20,7 +20,6 @@ import java.util.*; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardStateName; import forge.game.GameEntity; @@ -46,6 +45,7 @@ import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; import forge.util.MyRandom; +import forge.util.Predicates; import forge.util.collect.FCollectionView; diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index e2bf5ae96e7..5e5480051f7 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -19,8 +19,6 @@ import com.esotericsoftware.minlog.Log; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.ability.ChangeZoneAi; import forge.ai.ability.LearnAi; @@ -60,10 +58,7 @@ import forge.game.trigger.WrappedAbility; import forge.game.zone.ZoneType; import forge.item.PaperCard; -import forge.util.Aggregates; -import forge.util.ComparatorUtil; -import forge.util.Expressions; -import forge.util.MyRandom; +import forge.util.*; import io.sentry.Breadcrumb; import io.sentry.Sentry; diff --git a/forge-ai/src/main/java/forge/ai/AiCostDecision.java b/forge-ai/src/main/java/forge/ai/AiCostDecision.java index 0da8034e52f..9c963e53726 100644 --- a/forge-ai/src/main/java/forge/ai/AiCostDecision.java +++ b/forge-ai/src/main/java/forge/ai/AiCostDecision.java @@ -1,6 +1,5 @@ package forge.ai; -import com.google.common.base.Predicates; import com.google.common.collect.Lists; import forge.card.CardType; import forge.card.MagicColor; @@ -15,6 +14,7 @@ import forge.game.spellability.SpellAbilityStackInstance; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.Predicates; import forge.util.TextUtil; import forge.util.collect.FCollectionView; import org.apache.commons.lang3.ObjectUtils; diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index 46b7d0b2498..55ed7d61b27 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -19,13 +19,16 @@ import java.util.*; -import com.google.common.collect.*; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.collect.Multimap; +import com.google.common.collect.Sets; import forge.game.card.*; import forge.game.cost.*; +import forge.util.*; import org.apache.commons.lang3.StringUtils; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.ai.AiCardMemory.MemorySet; import forge.ai.ability.ProtectAi; @@ -66,9 +69,6 @@ import forge.game.trigger.WrappedAbility; import forge.game.zone.Zone; import forge.game.zone.ZoneType; -import forge.util.Aggregates; -import forge.util.MyRandom; -import forge.util.TextUtil; import forge.util.collect.FCollection; diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index 4f80defc430..4460d808f65 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -7,13 +7,12 @@ import forge.ai.simulation.GameStateEvaluator; import forge.card.mana.ManaCost; import forge.game.card.*; +import forge.util.*; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.MutablePair; import org.apache.commons.lang3.tuple.Pair; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -49,10 +48,6 @@ import forge.game.zone.MagicStack; import forge.game.zone.ZoneType; import forge.item.PaperCard; -import forge.util.Aggregates; -import forge.util.Expressions; -import forge.util.MyRandom; -import forge.util.TextUtil; public class ComputerUtilCard { public static Card getMostExpensivePermanentAI(final CardCollectionView list, final SpellAbility spell, final boolean targeted) { diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java index ff9583fd7c6..64b9d762e51 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java @@ -17,7 +17,6 @@ */ package forge.ai; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import forge.game.Game; @@ -43,6 +42,7 @@ import forge.game.trigger.Trigger; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.MyRandom; import forge.util.TextUtil; import forge.util.collect.FCollection; diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java index bfee0f90eb7..7da2db7aa8d 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java @@ -1,7 +1,5 @@ package forge.ai; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import forge.ai.AiCardMemory.MemorySet; @@ -23,7 +21,9 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetChoices; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.MyRandom; +import forge.util.Predicates; import forge.util.TextUtil; import forge.util.collect.FCollectionView; import org.apache.commons.lang3.ObjectUtils; diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index b23d4d6b250..3b97e292d47 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -1,7 +1,10 @@ package forge.ai; -import com.google.common.base.Predicates; -import com.google.common.collect.*; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; import forge.ai.AiCardMemory.MemorySet; import forge.ai.ability.AnimateAi; import forge.card.ColorSet; @@ -38,7 +41,9 @@ import forge.game.trigger.TriggerType; import forge.game.zone.Zone; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.MyRandom; +import forge.util.Predicates; import forge.util.TextUtil; import org.apache.commons.lang3.StringUtils; diff --git a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java index b1a282a20b8..48e32404372 100644 --- a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java +++ b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java @@ -1,8 +1,10 @@ package forge.ai; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.*; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; import forge.LobbyPlayer; import forge.ai.ability.ProtectAi; import forge.card.CardStateName; @@ -39,9 +41,7 @@ import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; import forge.item.PaperCard; -import forge.util.Aggregates; -import forge.util.ITriggerEvent; -import forge.util.MyRandom; +import forge.util.*; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; import org.apache.commons.lang3.StringUtils; diff --git a/forge-ai/src/main/java/forge/ai/SpecialAiLogic.java b/forge-ai/src/main/java/forge/ai/SpecialAiLogic.java index 0bb9c6f0dae..77ddf327c18 100644 --- a/forge-ai/src/main/java/forge/ai/SpecialAiLogic.java +++ b/forge-ai/src/main/java/forge/ai/SpecialAiLogic.java @@ -1,6 +1,5 @@ package forge.ai; -import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import forge.ai.ability.TokenAi; @@ -17,6 +16,7 @@ import forge.game.zone.ZoneType; import forge.util.Aggregates; import forge.util.Expressions; +import forge.util.Iterables; import java.util.List; diff --git a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java index 7731c20bf9e..74818e0f4fd 100644 --- a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java +++ b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java @@ -17,8 +17,6 @@ */ package forge.ai; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.ability.AnimateAi; import forge.ai.ability.FightAi; @@ -46,9 +44,7 @@ import forge.game.staticability.StaticAbility; import forge.game.trigger.Trigger; import forge.game.zone.ZoneType; -import forge.util.Aggregates; -import forge.util.MyRandom; -import forge.util.TextUtil; +import forge.util.*; import forge.util.maps.LinkedHashMapToAmount; import forge.util.maps.MapToAmount; import org.apache.commons.lang3.tuple.Pair; diff --git a/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java b/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java index 1acee5072ee..95742d46631 100644 --- a/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java +++ b/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java @@ -1,6 +1,5 @@ package forge.ai; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.card.CardStateName; import forge.card.ICardFace; @@ -20,6 +19,7 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbilityCondition; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.MyRandom; import java.util.Collection; diff --git a/forge-ai/src/main/java/forge/ai/ability/AmassAi.java b/forge-ai/src/main/java/forge/ai/ability/AmassAi.java index 60eefabbae4..f3ae9b2447d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AmassAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AmassAi.java @@ -2,7 +2,6 @@ import java.util.Map; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -21,6 +20,7 @@ import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; public class AmassAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java b/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java index 3bd5d854d59..88e4ed97dd4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java @@ -1,6 +1,5 @@ package forge.ai.ability; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import forge.ai.*; @@ -24,6 +23,7 @@ import forge.game.staticability.StaticAbilityLayer; import forge.game.zone.ZoneType; import forge.util.FileSection; +import forge.util.Iterables; import java.util.Arrays; import java.util.List; diff --git a/forge-ai/src/main/java/forge/ai/ability/AssignGroupAi.java b/forge-ai/src/main/java/forge/ai/ability/AssignGroupAi.java index 691a21904ce..d97cbda5aab 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AssignGroupAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AssignGroupAi.java @@ -3,11 +3,10 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.Iterables; - import forge.ai.SpellAbilityAi; import forge.game.player.Player; import forge.game.spellability.SpellAbility; +import forge.util.Iterables; public class AssignGroupAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java index 043f493005d..972ea28cecf 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java @@ -3,9 +3,9 @@ import java.util.*; import forge.game.card.*; +import forge.util.Predicates; import org.apache.commons.lang3.ObjectUtils; -import com.google.common.base.Predicates; import com.google.common.collect.Lists; import com.google.common.collect.Sets; diff --git a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java index 22b754f3dc3..3c3c5bb9118 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import forge.ai.*; @@ -29,7 +27,9 @@ import forge.game.staticability.StaticAbilityMustTarget; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.Iterables; import forge.util.MyRandom; +import forge.util.Predicates; import org.apache.commons.lang3.StringUtils; import java.util.*; diff --git a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java index 43c320fef21..dc2aa48d65a 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java @@ -3,8 +3,6 @@ import java.util.Collections; import java.util.Map; -import com.google.common.collect.Iterables; - import forge.ai.AiController; import forge.ai.AiPlayerPredicates; import forge.ai.AiProps; @@ -31,6 +29,7 @@ import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.MyRandom; public class ChangeZoneAllAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java index 10c50ac98e2..370d73864ef 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java @@ -4,9 +4,6 @@ import java.util.List; import java.util.Map; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; - import forge.ai.AiAttackController; import forge.ai.ComputerUtilAbility; import forge.ai.ComputerUtilCard; @@ -29,6 +26,8 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.Iterables; +import forge.util.Predicates; public class ChooseCardAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseCardNameAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseCardNameAi.java index 6f16595eedb..affe9aeaaba 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCardNameAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCardNameAi.java @@ -3,7 +3,6 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.StaticData; @@ -26,6 +25,7 @@ import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; import forge.item.PaperCard; +import forge.util.Iterables; import forge.util.MyRandom; public class ChooseCardNameAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseGenericAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseGenericAi.java index cbfbcb29678..29b47d497a8 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseGenericAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseGenericAi.java @@ -1,6 +1,5 @@ package forge.ai.ability; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.*; import forge.card.MagicColor; @@ -14,6 +13,7 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.Iterables; import forge.util.collect.FCollection; import java.util.List; diff --git a/forge-ai/src/main/java/forge/ai/ability/ChoosePlayerAi.java b/forge-ai/src/main/java/forge/ai/ability/ChoosePlayerAi.java index d2e1aed14a1..a8a03436699 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChoosePlayerAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChoosePlayerAi.java @@ -3,7 +3,6 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.ComputerUtil; @@ -13,6 +12,7 @@ import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; public class ChoosePlayerAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java index 3cfe82c05ae..00e3897a962 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java @@ -3,9 +3,6 @@ import java.util.List; import java.util.Map; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; - import forge.ai.AiAttackController; import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCombat; @@ -26,6 +23,8 @@ import forge.game.spellability.SpellAbilityStackInstance; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.Iterables; +import forge.util.Predicates; public class ChooseSourceAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java index aebe9dfb3f3..02b5163050b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java @@ -5,7 +5,6 @@ import java.util.List; import java.util.Set; -import com.google.common.collect.Iterables; import forge.ai.AiCardMemory; import forge.ai.ComputerUtilAbility; import forge.ai.ComputerUtilCard; @@ -26,6 +25,7 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.Iterables; public class ChooseTypeAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/ClashAi.java b/forge-ai/src/main/java/forge/ai/ability/ClashAi.java index e360b6863da..3c533a65a9f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ClashAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ClashAi.java @@ -3,8 +3,6 @@ import java.util.Map; -import com.google.common.collect.Iterables; - import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; import forge.game.card.Card; @@ -16,6 +14,7 @@ import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; public class ClashAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/CloneAi.java b/forge-ai/src/main/java/forge/ai/ability/CloneAi.java index 05a411a3299..b2ef3bdd0f4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CloneAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CloneAi.java @@ -3,8 +3,6 @@ import java.util.List; import java.util.Map; -import com.google.common.base.Predicates; - import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; import forge.game.Game; @@ -20,6 +18,7 @@ import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Predicates; public class CloneAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java b/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java index 7f7c70bd8fb..a84edee7d00 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java @@ -20,7 +20,6 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.ComputerUtil; @@ -43,6 +42,7 @@ import forge.game.staticability.StaticAbilityMustTarget; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.Iterables; //AB:GainControl|ValidTgts$Creature|TgtPrompt$Select target legendary creature|LoseControl$Untap,LoseControl|SpellDescription$Gain control of target xxxxxxx diff --git a/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java b/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java index e1614e460bf..75aa62d6f08 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java @@ -20,9 +20,6 @@ import java.util.List; import java.util.Map; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; - import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; import forge.game.card.Card; @@ -31,6 +28,8 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; +import forge.util.Predicates; /** diff --git a/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java b/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java index 9403bd0033f..95437b65d63 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java @@ -4,9 +4,6 @@ import java.util.List; import java.util.Map; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; - import forge.ai.AiPlayDecision; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilAbility; @@ -33,6 +30,8 @@ import forge.game.player.PlayerCollection; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; +import forge.util.Predicates; public class CopyPermanentAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersAi.java index 1b62032a221..e64920d17d4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersAi.java @@ -19,8 +19,6 @@ import java.util.List; -import com.google.common.collect.Iterables; - import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; import forge.game.card.Card; @@ -34,6 +32,7 @@ import forge.game.player.Player; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.Iterables; /** diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java index 84853b15bd1..77fe4368de7 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java @@ -3,8 +3,6 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.Iterables; - import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; @@ -17,6 +15,7 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.MyRandom; import forge.util.collect.FCollection; diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java index a6adb284d3c..ab1fe95a2a6 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java @@ -4,8 +4,6 @@ import java.util.List; import java.util.Map; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.ComputerUtil; @@ -25,6 +23,8 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; +import forge.util.Predicates; public class CountersMultiplyAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersProliferateAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersProliferateAi.java index aa5e232b9fa..aa10b2ddf05 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersProliferateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersProliferateAi.java @@ -4,7 +4,6 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.AiProps; @@ -17,6 +16,7 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; public class CountersProliferateAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java index 479a5e6cf77..67c8f44960d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.*; import forge.game.Game; @@ -26,7 +24,9 @@ import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.Iterables; import forge.util.MyRandom; +import forge.util.Predicates; import java.util.Collections; import java.util.List; diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java index 8fde651c09c..b1d2cf734c0 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java @@ -21,7 +21,6 @@ import java.util.Map; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; @@ -41,6 +40,7 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; +import forge.util.Iterables; /** *

diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java index 6a307d80773..627ce556ec4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java @@ -4,8 +4,6 @@ import java.util.Map; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; @@ -28,6 +26,8 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; +import forge.util.Iterables; +import forge.util.Predicates; public class CountersRemoveAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java index 3b6ee61a44c..5061ce21dba 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java @@ -1,6 +1,5 @@ package forge.ai.ability; -import com.google.common.base.Predicates; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import forge.ai.*; @@ -29,6 +28,7 @@ import forge.game.zone.ZoneType; import forge.util.Aggregates; import forge.util.MyRandom; +import forge.util.Predicates; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; diff --git a/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java b/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java index a3bcf73aeb3..35d3b2d5307 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java @@ -4,7 +4,6 @@ import java.util.Arrays; import java.util.List; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.AiAttackController; @@ -24,6 +23,7 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; +import forge.util.Iterables; public class DebuffAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java b/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java index 33fbacfe074..d9828d298fd 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java @@ -1,6 +1,5 @@ package forge.ai.ability; -import com.google.common.base.Predicates; import forge.ai.*; import forge.game.ability.AbilityUtils; import forge.game.ability.ApiType; @@ -15,6 +14,7 @@ import forge.game.spellability.SpellAbility; import forge.game.staticability.StaticAbilityMustTarget; import forge.game.zone.ZoneType; +import forge.util.Predicates; public class DestroyAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java index 81a2e17303c..e63aa2441e6 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java @@ -1,7 +1,6 @@ package forge.ai.ability; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.ai.*; import forge.card.MagicColor; import forge.game.card.Card; @@ -16,6 +15,7 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Predicates; public class DestroyAllAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/DigAi.java b/forge-ai/src/main/java/forge/ai/ability/DigAi.java index ef23477cf72..9e8ce50009f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DigAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DigAi.java @@ -2,8 +2,6 @@ import java.util.Map; -import com.google.common.collect.Iterables; - import forge.ai.AiAttackController; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilAbility; @@ -26,6 +24,7 @@ import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.TextUtil; diff --git a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java index c07ea08607f..3346c5a4759 100644 --- a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import forge.ai.*; import forge.game.CardTraitPredicates; import forge.game.Game; @@ -26,7 +24,9 @@ import forge.game.spellability.TargetRestrictions; import forge.game.zone.MagicStack; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.MyRandom; +import forge.util.Predicates; import forge.util.TextUtil; import java.util.ArrayList; diff --git a/forge-ai/src/main/java/forge/ai/ability/LegendaryRuleAi.java b/forge-ai/src/main/java/forge/ai/ability/LegendaryRuleAi.java index 7ac6840c602..e6ffd0c60a4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LegendaryRuleAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LegendaryRuleAi.java @@ -2,8 +2,6 @@ import java.util.Map; -import com.google.common.collect.Iterables; - import forge.ai.ComputerUtil; import forge.ai.SpellAbilityAi; import forge.game.card.Card; @@ -11,6 +9,7 @@ import forge.game.card.CounterEnumType; import forge.game.player.Player; import forge.game.spellability.SpellAbility; +import forge.util.Iterables; /** * TODO: Write javadoc for this type. diff --git a/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java b/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java index 1185df31edd..1907f315e98 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import com.google.common.collect.Iterables; - import forge.ai.ComputerUtil; import forge.ai.ComputerUtilAbility; import forge.ai.ComputerUtilCombat; @@ -20,6 +18,7 @@ import forge.game.player.PlayerPredicates; import forge.game.spellability.AbilitySub; import forge.game.spellability.SpellAbility; +import forge.util.Iterables; import forge.util.MyRandom; public class LifeGainAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java b/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java index b261a2fcf02..7a2a2b6fd11 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java @@ -2,8 +2,6 @@ import java.util.List; -import com.google.common.base.Predicates; - import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCost; import forge.ai.SpellAbilityAi; @@ -16,6 +14,7 @@ import forge.game.player.PlayerCollection; import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; +import forge.util.Predicates; import forge.util.collect.FCollection; public class LifeLoseAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/LifeSetAi.java b/forge-ai/src/main/java/forge/ai/ability/LifeSetAi.java index 4fa80b029d2..544743a2f28 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LifeSetAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LifeSetAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import com.google.common.collect.Iterables; - import forge.ai.ComputerUtilAbility; import forge.ai.ComputerUtilCost; import forge.ai.SpellAbilityAi; @@ -16,6 +14,7 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.MyRandom; public class LifeSetAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/ManaAi.java b/forge-ai/src/main/java/forge/ai/ability/ManaAi.java index 0602f25134b..ead353848df 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ManaAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ManaAi.java @@ -3,9 +3,6 @@ import java.util.Arrays; import java.util.List; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; - import forge.ai.*; import forge.card.ColorSet; import forge.card.MagicColor; @@ -32,6 +29,8 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.Iterables; +import forge.util.Predicates; public class ManaAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/ManifestBaseAi.java b/forge-ai/src/main/java/forge/ai/ability/ManifestBaseAi.java index 7cf5d187f94..85a35809895 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ManifestBaseAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ManifestBaseAi.java @@ -2,8 +2,6 @@ import java.util.Map; -import com.google.common.collect.Iterables; - import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCost; @@ -19,6 +17,7 @@ import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.MyRandom; /** diff --git a/forge-ai/src/main/java/forge/ai/ability/MeldAi.java b/forge-ai/src/main/java/forge/ai/ability/MeldAi.java index c8c84844226..bf33791404e 100644 --- a/forge-ai/src/main/java/forge/ai/ability/MeldAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/MeldAi.java @@ -1,14 +1,13 @@ package forge.ai.ability; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; - import forge.ai.SpellAbilityAi; import forge.game.card.CardCollectionView; import forge.game.card.CardPredicates; import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; +import forge.util.Predicates; public class MeldAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/MustBlockAi.java b/forge-ai/src/main/java/forge/ai/ability/MustBlockAi.java index 1d8bc7ef22f..0be815470e0 100644 --- a/forge-ai/src/main/java/forge/ai/ability/MustBlockAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/MustBlockAi.java @@ -3,8 +3,6 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.Iterables; - import forge.ai.AiCardMemory; import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCombat; @@ -19,6 +17,7 @@ import forge.game.phase.PhaseType; import forge.game.player.Player; import forge.game.spellability.SpellAbility; +import forge.util.Iterables; public class MustBlockAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/MutateAi.java b/forge-ai/src/main/java/forge/ai/ability/MutateAi.java index c0583b99cb7..2c1abf84698 100644 --- a/forge-ai/src/main/java/forge/ai/ability/MutateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/MutateAi.java @@ -2,8 +2,6 @@ import java.util.Map; -import com.google.common.base.Predicates; - import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; @@ -15,6 +13,7 @@ import forge.game.player.Player; import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; +import forge.util.Predicates; public class MutateAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java b/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java index d922a86e17e..fcf1160301c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCost; import forge.ai.ComputerUtilMana; @@ -19,6 +17,8 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; +import forge.util.Predicates; import org.apache.commons.lang3.StringUtils; public class PermanentAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/PhasesAi.java b/forge-ai/src/main/java/forge/ai/ability/PhasesAi.java index 499e43d10f6..37a676dd423 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PhasesAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PhasesAi.java @@ -1,6 +1,5 @@ package forge.ai.ability; -import com.google.common.base.Predicates; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; @@ -16,6 +15,7 @@ import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; import forge.util.MyRandom; +import forge.util.Predicates; import java.util.Collection; import java.util.List; diff --git a/forge-ai/src/main/java/forge/ai/ability/PlayAi.java b/forge-ai/src/main/java/forge/ai/ability/PlayAi.java index 5e7e9c482ff..0fce9f4ced4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PlayAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PlayAi.java @@ -1,6 +1,5 @@ package forge.ai.ability; -import com.google.common.collect.Iterables; import forge.ai.*; import forge.card.CardStateName; import forge.card.CardTypeView; @@ -14,6 +13,7 @@ import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.*; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.MyRandom; import java.util.Iterator; diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAi.java b/forge-ai/src/main/java/forge/ai/ability/PumpAi.java index 34486c7f2e7..4991906e776 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -21,6 +19,8 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; +import forge.util.Iterables; +import forge.util.Predicates; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java b/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java index 8c9891ac567..6ef7ade01cd 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java @@ -3,8 +3,6 @@ import java.util.List; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import forge.ai.AiAttackController; import forge.ai.ComputerUtil; @@ -29,6 +27,8 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; +import forge.util.Predicates; public abstract class PumpAiBase extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java b/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java index 26ccd6cc30f..51bbbd0cf0b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java @@ -4,8 +4,6 @@ import java.util.Arrays; import java.util.List; -import com.google.common.collect.Iterables; - import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCombat; @@ -24,6 +22,7 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; public class PumpAllAi extends PumpAiBase { diff --git a/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java b/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java index c9f25f8a456..96b7aeac972 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java @@ -3,7 +3,6 @@ import java.util.Map; -import com.google.common.collect.Iterables; import forge.ai.*; import forge.game.card.Card; import forge.game.card.CardPredicates; @@ -13,6 +12,7 @@ import forge.game.player.PlayerCollection; import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; +import forge.util.Iterables; public class RepeatAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/RevealAi.java b/forge-ai/src/main/java/forge/ai/ability/RevealAi.java index 0cb1870a97e..7bb856b3b5a 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RevealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RevealAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import com.google.common.collect.Iterables; - import forge.ai.AiPlayDecision; import forge.ai.PlayerControllerAi; import forge.game.ability.AbilityUtils; @@ -10,6 +8,7 @@ import forge.game.player.Player; import forge.game.spellability.Spell; import forge.game.spellability.SpellAbility; +import forge.util.Iterables; import forge.util.MyRandom; public class RevealAi extends RevealAiBase { diff --git a/forge-ai/src/main/java/forge/ai/ability/ScryAi.java b/forge-ai/src/main/java/forge/ai/ability/ScryAi.java index 0c14cd7c3e0..6cdc0c56337 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ScryAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ScryAi.java @@ -2,8 +2,6 @@ import java.util.Map; -import com.google.common.base.Predicates; - import forge.ai.ComputerUtilMana; import forge.ai.SpecialCardAi; import forge.ai.SpellAbilityAi; @@ -18,6 +16,7 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.MyRandom; +import forge.util.Predicates; public class ScryAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java b/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java index d56d2fcfc25..bb10b8df2a6 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java +++ b/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java @@ -3,7 +3,6 @@ import java.util.List; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import forge.ai.AiAttackController; import forge.ai.ComputerUtil; @@ -24,6 +23,7 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; public abstract class TapAiBase extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java b/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java index 8189f4ff4c2..bafaa3b4e34 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java @@ -2,8 +2,6 @@ import java.util.List; -import com.google.common.collect.Iterables; - import forge.ai.ComputerUtilCombat; import forge.ai.SpellAbilityAi; import forge.game.Game; @@ -19,6 +17,7 @@ import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.MyRandom; public class TapAllAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java b/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java index 1fbda3e0273..cb45493a0e6 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; - -import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.SpellAbilityAi; import forge.game.card.*; @@ -10,6 +8,7 @@ import forge.game.player.PlayerController; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; import java.util.Map; diff --git a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java index d23dc472e6e..dc1b5624698 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java @@ -3,8 +3,6 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.Iterables; - import forge.ai.AiController; import forge.ai.AiProps; import forge.ai.ComputerUtil; @@ -41,6 +39,7 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.MyRandom; /** diff --git a/forge-ai/src/main/java/forge/ai/ability/UntapAi.java b/forge-ai/src/main/java/forge/ai/ability/UntapAi.java index a3f2edb5199..c83d3e7598f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/UntapAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/UntapAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import forge.ai.*; import forge.card.mana.ManaCostShard; import forge.game.Game; @@ -24,6 +22,8 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; +import forge.util.Iterables; +import forge.util.Predicates; import java.util.List; import java.util.Map; diff --git a/forge-ai/src/main/java/forge/ai/ability/UntapAllAi.java b/forge-ai/src/main/java/forge/ai/ability/UntapAllAi.java index 5fd2889c3ac..47cb882ae38 100644 --- a/forge-ai/src/main/java/forge/ai/ability/UntapAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/UntapAllAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import com.google.common.collect.Iterables; - import forge.ai.SpellAbilityAi; import forge.game.ability.ApiType; import forge.game.card.Card; @@ -13,6 +11,7 @@ import forge.game.spellability.AbilitySub; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; public class UntapAllAi extends SpellAbilityAi { @Override diff --git a/forge-core/src/main/java/forge/card/CardDb.java b/forge-core/src/main/java/forge/card/CardDb.java index a3e05f60feb..84383d86adf 100644 --- a/forge-core/src/main/java/forge/card/CardDb.java +++ b/forge-core/src/main/java/forge/card/CardDb.java @@ -18,8 +18,10 @@ package forge.card; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.*; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimaps; import forge.StaticData; import forge.card.CardEdition.CardInSet; @@ -27,9 +29,7 @@ import forge.deck.generation.IDeckGenPool; import forge.item.IPaperCard; import forge.item.PaperCard; -import forge.util.CollectionSuppliers; -import forge.util.Lang; -import forge.util.TextUtil; +import forge.util.*; import forge.util.lang.LangEnglish; import org.apache.commons.lang3.StringUtils; diff --git a/forge-core/src/main/java/forge/card/CardEdition.java b/forge-core/src/main/java/forge/card/CardEdition.java index e431a8ada7f..2188ca55e1e 100644 --- a/forge-core/src/main/java/forge/card/CardEdition.java +++ b/forge-core/src/main/java/forge/card/CardEdition.java @@ -27,6 +27,7 @@ import forge.item.SealedTemplate; import forge.item.SealedTemplateWithSlots; import forge.util.*; +import forge.util.Iterables; import forge.util.storage.StorageBase; import forge.util.storage.StorageReaderBase; import forge.util.storage.StorageReaderFolder; @@ -903,7 +904,7 @@ public static CardEdition getPreferredArtEditionWithAllBasicLands() { CardDb.CardArtPreference artPreference = StaticData.instance().getCardArtPreference(); Iterable editionsWithBasicLands = Iterables.filter( StaticData.instance().getEditions().getOrderedEditions(), - com.google.common.base.Predicates.and(hasBasicLands, artPreference::accept)); + forge.util.Predicates.and(hasBasicLands, artPreference::accept)); Iterator editionsIterator = editionsWithBasicLands.iterator(); List selectedEditions = new ArrayList(); while (editionsIterator.hasNext()) diff --git a/forge-core/src/main/java/forge/card/CardRules.java b/forge-core/src/main/java/forge/card/CardRules.java index e20382c6ea5..691734bb135 100644 --- a/forge-core/src/main/java/forge/card/CardRules.java +++ b/forge-core/src/main/java/forge/card/CardRules.java @@ -20,9 +20,9 @@ import java.util.*; import com.google.common.collect.Lists; +import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import forge.card.mana.IParserManaCost; diff --git a/forge-core/src/main/java/forge/card/CardRulesPredicates.java b/forge-core/src/main/java/forge/card/CardRulesPredicates.java index 4f581532dc6..6404d3ed0ae 100644 --- a/forge-core/src/main/java/forge/card/CardRulesPredicates.java +++ b/forge-core/src/main/java/forge/card/CardRulesPredicates.java @@ -2,15 +2,10 @@ import java.util.*; +import forge.util.*; import org.apache.commons.lang3.StringUtils; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; - -import forge.util.CardTranslation; -import forge.util.ComparableOp; -import forge.util.PredicateString; /** * Filtering conditions specific for CardRules class, defined here along with @@ -590,7 +585,7 @@ public static class Presets { Predicates.or(Presets.IS_CREATURE, Presets.IS_PLANESWALKER)); /** The Constant IS_NON_CREATURE_SPELL. **/ - public static final Predicate IS_NON_CREATURE_SPELL = com.google.common.base.Predicates + public static final Predicate IS_NON_CREATURE_SPELL = Predicates .or(Presets.IS_SORCERY, Presets.IS_INSTANT, Presets.IS_PLANESWALKER, Presets.IS_ENCHANTMENT, Predicates.and(Presets.IS_ARTIFACT, Predicates.not(Presets.IS_CREATURE))); diff --git a/forge-core/src/main/java/forge/card/CardType.java b/forge-core/src/main/java/forge/card/CardType.java index e870ebfafb9..9adb0fb9c47 100644 --- a/forge-core/src/main/java/forge/card/CardType.java +++ b/forge-core/src/main/java/forge/card/CardType.java @@ -19,6 +19,7 @@ import java.util.*; +import forge.util.Iterables; import org.apache.commons.lang3.EnumUtils; import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.StringUtils; @@ -28,7 +29,6 @@ import com.google.common.collect.HashBiMap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -196,9 +196,9 @@ public boolean addAll(final CardType type) { } public boolean addAll(final CardTypeView type) { boolean changed = false; - if (Iterables.addAll(coreTypes, type.getCoreTypes())) { changed = true; } - if (Iterables.addAll(supertypes, type.getSupertypes())) { changed = true; } - if (Iterables.addAll(subtypes, type.getSubtypes())) { changed = true; } + if (Iterables.addAll_withReturn(coreTypes, type.getCoreTypes())) { changed = true; } + if (Iterables.addAll_withReturn(supertypes, type.getSupertypes())) { changed = true; } + if (Iterables.addAll_withReturn(subtypes, type.getSubtypes())) { changed = true; } sanisfySubtypes(); return changed; } diff --git a/forge-core/src/main/java/forge/card/DeckHints.java b/forge-core/src/main/java/forge/card/DeckHints.java index 7cc175e2d92..67b75e9b8ea 100644 --- a/forge-core/src/main/java/forge/card/DeckHints.java +++ b/forge-core/src/main/java/forge/card/DeckHints.java @@ -5,12 +5,12 @@ import java.util.List; import java.util.Map; +import forge.util.Iterables; +import forge.util.Predicates; import org.apache.commons.lang3.tuple.Pair; import com.google.common.base.Function; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import forge.StaticData; import forge.item.PaperCard; diff --git a/forge-core/src/main/java/forge/deck/DeckFormat.java b/forge-core/src/main/java/forge/deck/DeckFormat.java index 7abbfefc159..ddd54ae90da 100644 --- a/forge-core/src/main/java/forge/deck/DeckFormat.java +++ b/forge-core/src/main/java/forge/deck/DeckFormat.java @@ -18,9 +18,7 @@ package forge.deck; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; import forge.StaticData; import forge.card.CardRules; import forge.card.CardRulesPredicates; @@ -33,6 +31,8 @@ import forge.item.IPaperCard; import forge.item.PaperCard; import forge.util.Aggregates; +import forge.util.Iterables; +import forge.util.Predicates; import forge.util.TextUtil; import org.apache.commons.lang3.Range; import org.apache.commons.lang3.tuple.ImmutablePair; diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java b/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java index 3bdd0619e7f..1e64d70d1f6 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java @@ -4,11 +4,11 @@ import java.util.Map; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import forge.item.IPaperCard; import forge.item.PaperCard; +import forge.util.Iterables; +import forge.util.Predicates; public class DeckGenPool implements IDeckGenPool { private final Map cards = new HashMap<>(); diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index 38da378588e..d36b4f8338b 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -18,8 +18,6 @@ package forge.deck.generation; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.StaticData; import forge.card.*; @@ -28,10 +26,7 @@ import forge.deck.DeckFormat; import forge.item.IPaperCard; import forge.item.PaperCard; -import forge.util.Aggregates; -import forge.util.DebugTrace; -import forge.util.ItemPool; -import forge.util.MyRandom; +import forge.util.*; import org.apache.commons.lang3.tuple.ImmutablePair; import java.util.*; diff --git a/forge-core/src/main/java/forge/item/IPaperCard.java b/forge-core/src/main/java/forge/item/IPaperCard.java index 5ed0d681219..99780f5bb6d 100644 --- a/forge-core/src/main/java/forge/item/IPaperCard.java +++ b/forge-core/src/main/java/forge/item/IPaperCard.java @@ -43,14 +43,14 @@ public static Predicate printedInSets(final String[] sets) { public static Predicate printedInSets(final List value, final boolean shouldContain) { if ((value == null) || value.isEmpty()) { - return com.google.common.base.Predicates.alwaysTrue(); + return forge.util.Predicates.alwaysTrue(); } return new PredicateSets(value, shouldContain); } public static Predicate printedInSet(final String value) { if (StringUtils.isEmpty(value)) { - return com.google.common.base.Predicates.alwaysTrue(); + return forge.util.Predicates.alwaysTrue(); } return new PredicateSets(Lists.newArrayList(value), true); } @@ -209,7 +209,7 @@ public abstract static class Presets { public static final Predicate IS_MYTHIC_RARE = Predicates.rarity(true, CardRarity.MythicRare); /** The Constant isRareOrMythic. */ - public static final Predicate IS_RARE_OR_MYTHIC = com.google.common.base.Predicates.or(Presets.IS_RARE, + public static final Predicate IS_RARE_OR_MYTHIC = forge.util.Predicates.or(Presets.IS_RARE, Presets.IS_MYTHIC_RARE); /** The Constant isSpecial. */ diff --git a/forge-core/src/main/java/forge/item/ItemPredicate.java b/forge-core/src/main/java/forge/item/ItemPredicate.java index 69fc7b045ac..1c33a387025 100644 --- a/forge-core/src/main/java/forge/item/ItemPredicate.java +++ b/forge-core/src/main/java/forge/item/ItemPredicate.java @@ -1,7 +1,7 @@ package forge.item; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; +import forge.util.Predicates; /** * Filtering conditions for miscellaneous InventoryItems. diff --git a/forge-core/src/main/java/forge/item/SealedProduct.java b/forge-core/src/main/java/forge/item/SealedProduct.java index fac7607f05a..f6eb186c50a 100644 --- a/forge-core/src/main/java/forge/item/SealedProduct.java +++ b/forge-core/src/main/java/forge/item/SealedProduct.java @@ -19,12 +19,12 @@ package forge.item; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import forge.StaticData; import forge.card.CardRulesPredicates; import forge.item.generation.BoosterGenerator; import forge.util.Aggregates; +import forge.util.Iterables; +import forge.util.Predicates; import java.util.ArrayList; import java.util.List; diff --git a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java index 2aa083abd37..6a22065e421 100644 --- a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java +++ b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java @@ -18,8 +18,6 @@ package forge.item.generation; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import forge.StaticData; @@ -27,9 +25,7 @@ import forge.card.CardEdition.FoilType; import forge.item.*; import forge.item.IPaperCard.Predicates.Presets; -import forge.util.Aggregates; -import forge.util.MyRandom; -import forge.util.TextUtil; +import forge.util.*; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; diff --git a/forge-core/src/main/java/forge/item/generation/UnOpenedProduct.java b/forge-core/src/main/java/forge/item/generation/UnOpenedProduct.java index 3195dc733b0..5444bb011ab 100644 --- a/forge-core/src/main/java/forge/item/generation/UnOpenedProduct.java +++ b/forge-core/src/main/java/forge/item/generation/UnOpenedProduct.java @@ -1,12 +1,12 @@ package forge.item.generation; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import forge.StaticData; import forge.card.PrintSheet; import forge.item.PaperCard; import forge.item.SealedTemplate; import forge.util.ItemPool; +import forge.util.Iterables; import org.apache.commons.lang3.tuple.Pair; import java.util.ArrayList; diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index 8516f8cea95..c00a71ea200 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -56,6 +56,7 @@ public static int indexOf(Iterable iterable, Predicate predica } public static Iterable transform(final Iterable iterable, final Function function) { + //TODO: Collection input variant. Some usages use Lists.newArrayList on output which could be made part of the stream. return () -> StreamSupport.stream(iterable.spliterator(), false).map(function).iterator(); } @@ -82,6 +83,10 @@ public static boolean removeIf(Iterable iterable, Predicate test) { return ((Collection) iterable).removeIf(test); } + public static boolean removeAll(Collection removeFrom, Collection toRemove) { + return removeFrom.removeAll(toRemove); + } + public static int size(Collection collection) { return collection.size(); } @@ -135,6 +140,16 @@ public static Iterable concat(Iterable a, Iterable Iterable concat(Iterable> inputs) { return com.google.common.collect.Iterables.concat(inputs); } + public static Iterable concat(Iterable a, Iterable b, Iterable c) { + return com.google.common.collect.Iterables.concat(a, b, c); + } + public static Iterable concat(Iterable a, Iterable b, Iterable c, Iterable d) { + return com.google.common.collect.Iterables.concat(a, b, c, d); + } + + public static int frequency(Iterable iterable, Object element) { + return com.google.common.collect.Iterables.frequency(iterable, element); + } public static T get(Iterable iterable, int position) { return com.google.common.collect.Iterables.get(iterable, position); diff --git a/forge-core/src/main/java/forge/util/Lang.java b/forge-core/src/main/java/forge/util/Lang.java index 740d0cc9c09..1e0dbb0e82c 100644 --- a/forge-core/src/main/java/forge/util/Lang.java +++ b/forge-core/src/main/java/forge/util/Lang.java @@ -7,7 +7,6 @@ import org.apache.commons.lang3.StringUtils; import com.google.common.base.Function; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.util.lang.LangChinese; 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 d54fe2adb24..68ce4d0b8c3 100644 --- a/forge-core/src/main/java/forge/util/collect/FCollection.java +++ b/forge-core/src/main/java/forge/util/collect/FCollection.java @@ -13,10 +13,10 @@ import java.util.Set; import java.util.function.Predicate; +import forge.util.Iterables; import org.apache.commons.lang3.ArrayUtils; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Ordering; import com.google.common.collect.Sets; diff --git a/forge-core/src/main/java/forge/util/storage/StorageBase.java b/forge-core/src/main/java/forge/util/storage/StorageBase.java index a4f3b075028..4dcc5fdc201 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageBase.java +++ b/forge-core/src/main/java/forge/util/storage/StorageBase.java @@ -18,8 +18,8 @@ package forge.util.storage; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import forge.util.IItemReader; +import forge.util.Iterables; import java.io.File; import java.io.FilenameFilter; diff --git a/forge-game/src/main/java/forge/game/ForgeScript.java b/forge-game/src/main/java/forge/game/ForgeScript.java index 77d107709ff..efe199c8b62 100644 --- a/forge-game/src/main/java/forge/game/ForgeScript.java +++ b/forge-game/src/main/java/forge/game/ForgeScript.java @@ -1,7 +1,5 @@ package forge.game; -import com.google.common.collect.Iterables; - import forge.card.ColorSet; import forge.card.MagicColor; import forge.card.mana.ManaAtom; @@ -23,6 +21,7 @@ import forge.game.trigger.Trigger; import forge.game.zone.ZoneType; import forge.util.Expressions; +import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; diff --git a/forge-game/src/main/java/forge/game/Game.java b/forge-game/src/main/java/forge/game/Game.java index 0ed7bf86576..fac5f4bcc33 100644 --- a/forge-game/src/main/java/forge/game/Game.java +++ b/forge-game/src/main/java/forge/game/Game.java @@ -18,8 +18,12 @@ package forge.game; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.*; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; +import com.google.common.collect.Table; import com.google.common.eventbus.EventBus; import forge.GameCommand; import forge.card.CardRarity; @@ -46,9 +50,7 @@ import forge.game.zone.Zone; import forge.game.zone.ZoneType; import forge.trackable.Tracker; -import forge.util.Aggregates; -import forge.util.MyRandom; -import forge.util.Visitor; +import forge.util.*; import forge.util.collect.FCollection; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.tuple.Pair; diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index 9fa74479bba..126f9fa12f9 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -53,6 +53,7 @@ import forge.game.zone.ZoneType; import forge.item.PaperCard; import forge.util.*; +import forge.util.Iterables; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; import org.apache.commons.lang3.tuple.ImmutablePair; diff --git a/forge-game/src/main/java/forge/game/GameEntity.java b/forge-game/src/main/java/forge/game/GameEntity.java index 285514b2189..e7b839253eb 100644 --- a/forge-game/src/main/java/forge/game/GameEntity.java +++ b/forge-game/src/main/java/forge/game/GameEntity.java @@ -20,9 +20,9 @@ import java.util.List; import java.util.Map; +import forge.util.Iterables; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; diff --git a/forge-game/src/main/java/forge/game/GameEntityView.java b/forge-game/src/main/java/forge/game/GameEntityView.java index 81b02a64c33..64ade841f4e 100644 --- a/forge-game/src/main/java/forge/game/GameEntityView.java +++ b/forge-game/src/main/java/forge/game/GameEntityView.java @@ -1,12 +1,11 @@ package forge.game; -import com.google.common.collect.Iterables; - import forge.game.card.CardView; import forge.trackable.TrackableCollection; import forge.trackable.TrackableObject; import forge.trackable.TrackableProperty; import forge.trackable.Tracker; +import forge.util.Iterables; public abstract class GameEntityView extends TrackableObject { private static final long serialVersionUID = -5129089945124455670L; diff --git a/forge-game/src/main/java/forge/game/GameFormat.java b/forge-game/src/main/java/forge/game/GameFormat.java index bde08906dbc..91f96576927 100644 --- a/forge-game/src/main/java/forge/game/GameFormat.java +++ b/forge-game/src/main/java/forge/game/GameFormat.java @@ -18,7 +18,6 @@ package forge.game; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.collect.Lists; import forge.StaticData; import forge.card.CardDb; @@ -31,6 +30,7 @@ import forge.item.PaperCard; import forge.util.FileSection; import forge.util.FileUtil; +import forge.util.Predicates; import forge.util.storage.StorageBase; import forge.util.storage.StorageReaderRecursiveFolderWithUserFolder; diff --git a/forge-game/src/main/java/forge/game/GameLogFormatter.java b/forge-game/src/main/java/forge/game/GameLogFormatter.java index 9027a6d3bbb..4f67bb4b74e 100644 --- a/forge-game/src/main/java/forge/game/GameLogFormatter.java +++ b/forge-game/src/main/java/forge/game/GameLogFormatter.java @@ -4,7 +4,6 @@ import java.util.HashMap; import java.util.Map.Entry; -import com.google.common.collect.Iterables; import com.google.common.eventbus.Subscribe; import forge.LobbyPlayer; @@ -16,10 +15,7 @@ import forge.game.player.RegisteredPlayer; import forge.game.spellability.TargetChoices; import forge.game.zone.ZoneType; -import forge.util.CardTranslation; -import forge.util.Lang; -import forge.util.Localizer; -import forge.util.TextUtil; +import forge.util.*; import forge.util.maps.MapOfLists; public class GameLogFormatter extends IGameEventVisitor.Base { diff --git a/forge-game/src/main/java/forge/game/GameView.java b/forge-game/src/main/java/forge/game/GameView.java index 521c022c91d..476d94cb721 100644 --- a/forge-game/src/main/java/forge/game/GameView.java +++ b/forge-game/src/main/java/forge/game/GameView.java @@ -2,8 +2,6 @@ import java.util.List; -import com.google.common.collect.Iterables; - import forge.LobbyPlayer; import forge.deck.Deck; import forge.game.GameOutcome.AnteResult; @@ -21,6 +19,7 @@ import forge.trackable.TrackableCollection; import forge.trackable.TrackableObject; import forge.trackable.TrackableProperty; +import forge.util.Iterables; import forge.util.collect.FCollectionView; public class GameView extends TrackableObject { diff --git a/forge-game/src/main/java/forge/game/Match.java b/forge-game/src/main/java/forge/game/Match.java index 2c5b7e3605e..109e6c2da53 100644 --- a/forge-game/src/main/java/forge/game/Match.java +++ b/forge-game/src/main/java/forge/game/Match.java @@ -1,6 +1,11 @@ package forge.game; -import com.google.common.collect.*; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; +import com.google.common.collect.Multiset; import com.google.common.eventbus.EventBus; import forge.LobbyPlayer; import forge.deck.CardPool; @@ -20,6 +25,7 @@ import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; import forge.item.PaperCard; +import forge.util.Iterables; import forge.util.Localizer; import forge.util.MyRandom; import forge.util.collect.FCollectionView; diff --git a/forge-game/src/main/java/forge/game/StaticEffects.java b/forge-game/src/main/java/forge/game/StaticEffects.java index 0b56db9cfbe..287a9193914 100644 --- a/forge-game/src/main/java/forge/game/StaticEffects.java +++ b/forge-game/src/main/java/forge/game/StaticEffects.java @@ -20,11 +20,11 @@ import java.util.Map; import java.util.Set; -import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import forge.game.card.Card; import forge.game.staticability.StaticAbility; +import forge.util.Iterables; /** *

diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index a7ba87565c5..735a1817f3d 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -28,6 +28,7 @@ import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; import forge.util.*; +import forge.util.Iterables; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; import io.sentry.Breadcrumb; diff --git a/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java b/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java index 463467db6f8..b9ee94018ff 100644 --- a/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java +++ b/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java @@ -1,6 +1,5 @@ package forge.game.ability; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Table; @@ -24,10 +23,7 @@ import forge.game.trigger.TriggerHandler; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; -import forge.util.CardTranslation; -import forge.util.Lang; -import forge.util.Localizer; -import forge.util.TextUtil; +import forge.util.*; import forge.util.collect.FCollection; import org.apache.commons.lang3.StringUtils; diff --git a/forge-game/src/main/java/forge/game/ability/effects/AmassEffect.java b/forge-game/src/main/java/forge/game/ability/effects/AmassEffect.java index c55c6d84a89..80ea03a2cf8 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/AmassEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/AmassEffect.java @@ -3,9 +3,9 @@ import java.util.EnumSet; import java.util.Map; +import forge.util.Iterables; import org.apache.commons.lang3.mutable.MutableBoolean; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; diff --git a/forge-game/src/main/java/forge/game/ability/effects/AttachEffect.java b/forge-game/src/main/java/forge/game/ability/effects/AttachEffect.java index 30c1f255fa0..014d3433e0b 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/AttachEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/AttachEffect.java @@ -21,11 +21,11 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.CardTranslation; +import forge.util.Iterables; import forge.util.Lang; import forge.util.Localizer; import forge.util.collect.FCollection; -import com.google.common.collect.Iterables; import com.google.common.collect.Maps; public class AttachEffect extends SpellAbilityEffect { diff --git a/forge-game/src/main/java/forge/game/ability/effects/BidLifeEffect.java b/forge-game/src/main/java/forge/game/ability/effects/BidLifeEffect.java index 0eba85ba70f..39490a706a0 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/BidLifeEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/BidLifeEffect.java @@ -1,13 +1,12 @@ package forge.game.ability.effects; -import com.google.common.collect.Iterables; - import forge.game.ability.AbilityUtils; import forge.game.ability.SpellAbilityEffect; import forge.game.card.Card; import forge.game.player.Player; import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; +import forge.util.Iterables; import forge.util.Localizer; import forge.util.collect.FCollection; diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java index 4dbd9842895..6f3aaf8953a 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java @@ -3,11 +3,11 @@ import java.util.ArrayList; import java.util.List; +import forge.util.Iterables; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import forge.game.GameEntity; import forge.game.GameObject; diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneAllEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneAllEffect.java index e56fa33f7bd..9686580fbfd 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneAllEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneAllEffect.java @@ -3,8 +3,6 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.Iterables; - import forge.game.Game; import forge.game.GameActionUtil; import forge.game.GameEntityCounterTable; @@ -17,6 +15,7 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.Zone; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.Lang; import forge.util.Localizer; import forge.util.TextUtil; diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java index be89e9d11c5..ec0cea46178 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java @@ -1,7 +1,5 @@ package forge.game.ability.effects; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java index 6129b170bdc..424422c06cf 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java @@ -3,9 +3,7 @@ import java.util.*; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import forge.StaticData; import forge.card.CardFacePredicates; import forge.card.CardRules; @@ -18,9 +16,7 @@ import forge.game.card.CardLists; import forge.game.player.Player; import forge.game.spellability.SpellAbility; -import forge.util.Aggregates; -import forge.util.Lang; -import forge.util.Localizer; +import forge.util.*; import org.apache.commons.lang3.StringUtils; public class ChooseCardNameEffect extends SpellAbilityEffect { diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChooseGenericEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChooseGenericEffect.java index 8a331d77a9f..52b3f725a7b 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChooseGenericEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChooseGenericEffect.java @@ -3,7 +3,6 @@ import java.util.List; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.game.ability.AbilityUtils; @@ -18,6 +17,7 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.util.Aggregates; +import forge.util.Iterables; import forge.util.Lang; import forge.util.Localizer; diff --git a/forge-game/src/main/java/forge/game/ability/effects/CloneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CloneEffect.java index dcf15da41da..b771f5ff556 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CloneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CloneEffect.java @@ -1,6 +1,5 @@ package forge.game.ability.effects; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.GameCommand; import forge.StaticData; @@ -13,6 +12,7 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.CardTranslation; +import forge.util.Iterables; import forge.util.Localizer; import forge.util.collect.FCollection; diff --git a/forge-game/src/main/java/forge/game/ability/effects/ControlSpellEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ControlSpellEffect.java index 700fc0fd86c..232342da635 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ControlSpellEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ControlSpellEffect.java @@ -2,8 +2,6 @@ import java.util.List; -import com.google.common.collect.Iterables; - import forge.game.Game; import forge.game.GameObject; import forge.game.ability.SpellAbilityEffect; @@ -11,6 +9,7 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbilityStackInstance; +import forge.util.Iterables; public class ControlSpellEffect extends SpellAbilityEffect { /* (non-Javadoc) diff --git a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java index 2e3aff67e86..9da59ae5868 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java @@ -4,13 +4,11 @@ import java.util.List; import forge.card.GamePieceType; -import forge.util.Lang; +import forge.util.*; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.mutable.MutableBoolean; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ImageKeys; @@ -33,10 +31,7 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.item.PaperCard; -import forge.util.Aggregates; -import forge.util.Localizer; import forge.util.PredicateString.StringOp; -import forge.util.TextUtil; public class CopyPermanentEffect extends TokenEffectBase { diff --git a/forge-game/src/main/java/forge/game/ability/effects/CopySpellAbilityEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CopySpellAbilityEffect.java index 955c698247e..645f64f3174 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CopySpellAbilityEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CopySpellAbilityEffect.java @@ -1,7 +1,6 @@ package forge.game.ability.effects; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.game.Game; import forge.game.GameEntity; @@ -17,6 +16,7 @@ import forge.game.staticability.StaticAbilityCantBeCopied; import forge.game.zone.ZoneType; import forge.util.CardTranslation; +import forge.util.Iterables; import forge.util.Lang; import forge.util.Localizer; import forge.util.collect.FCollection; diff --git a/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java index c3f3d970542..d260e5b03b8 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java @@ -3,7 +3,6 @@ import java.util.*; import java.util.Map.Entry; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -28,10 +27,7 @@ import forge.game.trigger.TriggerHandler; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; -import forge.util.Aggregates; -import forge.util.CardTranslation; -import forge.util.Lang; -import forge.util.Localizer; +import forge.util.*; public class CountersPutEffect extends SpellAbilityEffect { @Override diff --git a/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java b/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java index 928610c50f3..df40509773f 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java @@ -4,7 +4,6 @@ import java.util.Map; import java.util.Map.Entry; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.game.Game; @@ -24,6 +23,7 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.Iterables; import forge.util.Lang; import forge.util.Localizer; import forge.util.collect.FCollection; diff --git a/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java b/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java index f75f623a420..49090d00e98 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java @@ -2,7 +2,6 @@ import java.util.Map; -import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import forge.GameCommand; @@ -16,6 +15,7 @@ import forge.game.spellability.SpellAbility; import forge.game.trigger.Trigger; import forge.game.trigger.TriggerHandler; +import forge.util.Iterables; public class DelayedTriggerEffect extends SpellAbilityEffect { diff --git a/forge-game/src/main/java/forge/game/ability/effects/DiscardEffect.java b/forge-game/src/main/java/forge/game/ability/effects/DiscardEffect.java index 99fffc7b143..aba04ddf64c 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/DiscardEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/DiscardEffect.java @@ -3,7 +3,6 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -23,10 +22,7 @@ import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Aggregates; -import forge.util.Lang; -import forge.util.Localizer; -import forge.util.TextUtil; +import forge.util.*; public class DiscardEffect extends SpellAbilityEffect { diff --git a/forge-game/src/main/java/forge/game/ability/effects/EffectEffect.java b/forge-game/src/main/java/forge/game/ability/effects/EffectEffect.java index 38d61b3a4ed..ef993b52cd3 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/EffectEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/EffectEffect.java @@ -5,7 +5,6 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ImageKeys; @@ -26,6 +25,7 @@ import forge.game.trigger.Trigger; import forge.game.trigger.TriggerHandler; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.TextUtil; import forge.util.collect.FCollection; diff --git a/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java b/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java index 4d20ed979c3..3903e6e25b8 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java @@ -2,7 +2,6 @@ import java.util.Map; -import com.google.common.base.Predicates; import com.google.common.collect.Maps; import forge.game.Game; @@ -19,6 +18,7 @@ import forge.game.staticability.StaticAbilityGainLifeRadiation; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; +import forge.util.Predicates; public class InternalRadiationEffect extends SpellAbilityEffect { diff --git a/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java b/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java index 470d4688502..3ae63fd89c6 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java @@ -1,6 +1,5 @@ package forge.game.ability.effects; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.StaticData; import forge.card.ICardFace; @@ -21,6 +20,7 @@ import forge.item.SealedTemplate; import forge.util.Aggregates; import forge.util.CardTranslation; +import forge.util.Iterables; import forge.util.Localizer; import java.util.ArrayList; diff --git a/forge-game/src/main/java/forge/game/ability/effects/ManifestBaseEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ManifestBaseEffect.java index 275d62956b4..0f841d92e9b 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ManifestBaseEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ManifestBaseEffect.java @@ -2,8 +2,6 @@ import java.util.Map; -import com.google.common.collect.Iterables; - import forge.game.Game; import forge.game.ability.AbilityKey; import forge.game.ability.AbilityUtils; @@ -17,6 +15,7 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; public abstract class ManifestBaseEffect extends SpellAbilityEffect { @Override diff --git a/forge-game/src/main/java/forge/game/ability/effects/MultiplePilesEffect.java b/forge-game/src/main/java/forge/game/ability/effects/MultiplePilesEffect.java index 6fdbbb0c984..aaf74f1dcc4 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/MultiplePilesEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/MultiplePilesEffect.java @@ -4,7 +4,6 @@ import java.util.Map; import java.util.Map.Entry; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -18,6 +17,7 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.Iterables; import forge.util.Lang; import forge.util.Localizer; diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java index 70f41014817..248524a7b0e 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java @@ -8,12 +8,11 @@ import forge.card.CardStateName; import forge.card.GamePieceType; +import forge.util.*; import org.apache.commons.lang3.StringUtils; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.StaticData; @@ -45,10 +44,6 @@ import forge.game.zone.Zone; import forge.game.zone.ZoneType; import forge.item.PaperCard; -import forge.util.Aggregates; -import forge.util.CardTranslation; -import forge.util.Lang; -import forge.util.Localizer; public class PlayEffect extends SpellAbilityEffect { @Override diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java index 6361442621f..bf386ad2bf1 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java @@ -3,8 +3,6 @@ import java.util.List; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.StaticData; @@ -19,6 +17,8 @@ import forge.game.spellability.SpellAbility; import forge.item.PaperCard; import forge.util.Aggregates; +import forge.util.Iterables; +import forge.util.Predicates; public class PlayLandVariantEffect extends SpellAbilityEffect { diff --git a/forge-game/src/main/java/forge/game/ability/effects/PumpAllEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PumpAllEffect.java index 46a029edeaf..3515f274df3 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PumpAllEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PumpAllEffect.java @@ -5,7 +5,6 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.GameCommand; @@ -19,6 +18,7 @@ import forge.game.player.PlayerCollection; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; public class PumpAllEffect extends SpellAbilityEffect { diff --git a/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java index 2e305e87dec..964850c9df8 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java @@ -5,10 +5,10 @@ import java.util.List; import java.util.Map; +import forge.util.*; import org.apache.commons.lang3.StringUtils; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.GameCommand; @@ -27,10 +27,6 @@ import forge.game.spellability.AbilitySub; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Aggregates; -import forge.util.Lang; -import forge.util.Localizer; -import forge.util.TextUtil; public class PumpEffect extends SpellAbilityEffect { diff --git a/forge-game/src/main/java/forge/game/ability/effects/RearrangeTopOfLibraryEffect.java b/forge-game/src/main/java/forge/game/ability/effects/RearrangeTopOfLibraryEffect.java index 2010e06e64e..c1e4110fd92 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/RearrangeTopOfLibraryEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/RearrangeTopOfLibraryEffect.java @@ -2,8 +2,6 @@ import java.util.List; -import com.google.common.collect.Iterables; - import forge.game.ability.AbilityUtils; import forge.game.ability.SpellAbilityEffect; import forge.game.card.Card; @@ -12,6 +10,7 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.Lang; import forge.util.Localizer; diff --git a/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java b/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java index fbc6867964e..657e5827abf 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java @@ -2,7 +2,6 @@ import java.util.*; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -22,6 +21,7 @@ import forge.game.trigger.TriggerType; import forge.game.trigger.WrappedAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.collect.FCollection; public class RepeatEachEffect extends SpellAbilityEffect { diff --git a/forge-game/src/main/java/forge/game/ability/effects/TokenEffectBase.java b/forge-game/src/main/java/forge/game/ability/effects/TokenEffectBase.java index 71cf31a43d9..8c72b3c5168 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/TokenEffectBase.java +++ b/forge-game/src/main/java/forge/game/ability/effects/TokenEffectBase.java @@ -7,9 +7,9 @@ import forge.card.GamePieceType; import forge.game.card.*; +import forge.util.Iterables; import org.apache.commons.lang3.mutable.MutableBoolean; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.collect.Table; diff --git a/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java b/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java index 4c0214d0410..f8f3503e301 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java @@ -4,8 +4,6 @@ import java.util.List; import java.util.Map; -import com.google.common.base.Predicates; - import forge.StaticData; import forge.card.CardRulesPredicates; import forge.game.Game; @@ -25,6 +23,7 @@ import forge.item.PaperCard; import forge.util.Localizer; import forge.util.PredicateString.StringOp; +import forge.util.Predicates; public class VentureEffect extends SpellAbilityEffect { diff --git a/forge-game/src/main/java/forge/game/card/Card.java b/forge-game/src/main/java/forge/game/card/Card.java index cf0beabb337..54015c98e45 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -19,9 +19,7 @@ import com.esotericsoftware.minlog.Log; import com.google.common.base.Optional; -import com.google.common.base.Predicates; import com.google.common.collect.*; -import com.google.common.collect.Iterables; import forge.GameCommand; import forge.StaticData; import forge.card.*; @@ -54,6 +52,7 @@ import forge.trackable.TrackableProperty; import forge.trackable.Tracker; import forge.util.*; +import forge.util.Iterables; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; import io.sentry.Breadcrumb; diff --git a/forge-game/src/main/java/forge/game/card/CardDamageMap.java b/forge-game/src/main/java/forge/game/card/CardDamageMap.java index d612ec9626c..00e86fad8d7 100644 --- a/forge-game/src/main/java/forge/game/card/CardDamageMap.java +++ b/forge-game/src/main/java/forge/game/card/CardDamageMap.java @@ -9,7 +9,6 @@ import com.google.common.collect.ForwardingTable; import com.google.common.collect.HashBasedTable; -import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.common.collect.Table; @@ -24,6 +23,7 @@ import forge.game.player.PlayerCollection; import forge.game.spellability.SpellAbility; import forge.game.trigger.TriggerType; +import forge.util.Iterables; public class CardDamageMap extends ForwardingTable { private Table dataMap = HashBasedTable.create(); diff --git a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java index fe76d4adcd2..514dbf02d00 100644 --- a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java +++ b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java @@ -18,8 +18,10 @@ package forge.game.card; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.*; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import forge.GameCommand; import forge.card.*; import forge.card.mana.ManaCost; @@ -46,9 +48,7 @@ import forge.game.trigger.Trigger; import forge.game.trigger.TriggerHandler; import forge.game.zone.ZoneType; -import forge.util.Lang; -import forge.util.Localizer; -import forge.util.TextUtil; +import forge.util.*; import io.sentry.Breadcrumb; import io.sentry.Sentry; import org.apache.commons.lang3.StringUtils; diff --git a/forge-game/src/main/java/forge/game/card/CardLists.java b/forge-game/src/main/java/forge/game/card/CardLists.java index 152e349c092..b15185644d1 100644 --- a/forge-game/src/main/java/forge/game/card/CardLists.java +++ b/forge-game/src/main/java/forge/game/card/CardLists.java @@ -22,8 +22,6 @@ import java.util.List; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.game.CardTraitBase; @@ -32,7 +30,9 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.game.staticability.StaticAbilityCrewValue; +import forge.util.Iterables; import forge.util.MyRandom; +import forge.util.Predicates; import forge.util.collect.FCollectionView; /** diff --git a/forge-game/src/main/java/forge/game/card/CardPredicates.java b/forge-game/src/main/java/forge/game/card/CardPredicates.java index 5e2289da035..a290776ea96 100644 --- a/forge-game/src/main/java/forge/game/card/CardPredicates.java +++ b/forge-game/src/main/java/forge/game/card/CardPredicates.java @@ -20,7 +20,6 @@ import java.util.Comparator; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import forge.game.CardTraitBase; import forge.game.GameEntity; @@ -31,6 +30,7 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.Zone; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.PredicateString; import forge.util.collect.FCollectionView; diff --git a/forge-game/src/main/java/forge/game/card/CardProperty.java b/forge-game/src/main/java/forge/game/card/CardProperty.java index d2afcf70fb1..a49a851280c 100644 --- a/forge-game/src/main/java/forge/game/card/CardProperty.java +++ b/forge-game/src/main/java/forge/game/card/CardProperty.java @@ -1,6 +1,5 @@ package forge.game.card; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import forge.StaticData; @@ -29,6 +28,7 @@ import forge.game.zone.ZoneType; import forge.item.PaperCard; import forge.util.Expressions; +import forge.util.Iterables; import forge.util.TextUtil; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; diff --git a/forge-game/src/main/java/forge/game/card/CardState.java b/forge-game/src/main/java/forge/game/card/CardState.java index 2e5e206b514..ab3bd85180e 100644 --- a/forge-game/src/main/java/forge/game/card/CardState.java +++ b/forge-game/src/main/java/forge/game/card/CardState.java @@ -22,7 +22,6 @@ import java.util.Set; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import forge.card.CardEdition; @@ -47,6 +46,7 @@ import forge.game.spellability.SpellAbilityPredicates; import forge.game.staticability.StaticAbility; import forge.game.trigger.Trigger; +import forge.util.Iterables; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; import io.sentry.Breadcrumb; diff --git a/forge-game/src/main/java/forge/game/card/CardUtil.java b/forge-game/src/main/java/forge/game/card/CardUtil.java index 3a9f4ee4314..b91f1d70660 100644 --- a/forge-game/src/main/java/forge/game/card/CardUtil.java +++ b/forge-game/src/main/java/forge/game/card/CardUtil.java @@ -21,7 +21,6 @@ import java.util.Set; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -40,6 +39,7 @@ import forge.game.spellability.SpellAbilityPredicates; import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.TextUtil; import forge.util.collect.FCollection; diff --git a/forge-game/src/main/java/forge/game/card/CardView.java b/forge-game/src/main/java/forge/game/card/CardView.java index 336759b930a..b2a7d5f85a6 100644 --- a/forge-game/src/main/java/forge/game/card/CardView.java +++ b/forge-game/src/main/java/forge/game/card/CardView.java @@ -1,6 +1,5 @@ package forge.game.card; -import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import forge.ImageKeys; import forge.StaticData; @@ -22,10 +21,7 @@ import forge.trackable.TrackableObject; import forge.trackable.TrackableProperty; import forge.trackable.Tracker; -import forge.util.CardTranslation; -import forge.util.Lang; -import forge.util.Localizer; -import forge.util.TextUtil; +import forge.util.*; import forge.util.collect.FCollectionView; import org.apache.commons.lang3.StringUtils; diff --git a/forge-game/src/main/java/forge/game/card/CardZoneTable.java b/forge-game/src/main/java/forge/game/card/CardZoneTable.java index 5d78852277d..324e6e40dff 100644 --- a/forge-game/src/main/java/forge/game/card/CardZoneTable.java +++ b/forge-game/src/main/java/forge/game/card/CardZoneTable.java @@ -5,8 +5,9 @@ import java.util.Map; -import com.google.common.collect.*; - +import com.google.common.collect.ForwardingTable; +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Table; import forge.game.CardTraitBase; import forge.game.Game; import forge.game.GameAction; @@ -16,6 +17,7 @@ import forge.game.spellability.SpellAbility; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; +import forge.util.Iterables; public class CardZoneTable extends ForwardingTable { // TODO use EnumBasedTable if exist diff --git a/forge-game/src/main/java/forge/game/card/TokenCreateTable.java b/forge-game/src/main/java/forge/game/card/TokenCreateTable.java index 537e512a492..c138a398346 100644 --- a/forge-game/src/main/java/forge/game/card/TokenCreateTable.java +++ b/forge-game/src/main/java/forge/game/card/TokenCreateTable.java @@ -3,11 +3,11 @@ import java.util.List; import java.util.Map; +import forge.util.Iterables; import org.apache.commons.lang3.ObjectUtils; import com.google.common.collect.ForwardingTable; import com.google.common.collect.HashBasedTable; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Table; diff --git a/forge-game/src/main/java/forge/game/card/token/TokenInfo.java b/forge-game/src/main/java/forge/game/card/token/TokenInfo.java index 578c9c89b02..09391459716 100644 --- a/forge-game/src/main/java/forge/game/card/token/TokenInfo.java +++ b/forge-game/src/main/java/forge/game/card/token/TokenInfo.java @@ -4,11 +4,11 @@ import java.util.Map; import forge.card.GamePieceType; +import forge.util.Iterables; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import com.google.common.base.Joiner; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ImageKeys; 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 4298e098824..30591bde1c3 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackConstraints.java +++ b/forge-game/src/main/java/forge/game/combat/AttackConstraints.java @@ -8,13 +8,13 @@ import java.util.Map.Entry; import java.util.Set; +import forge.util.Iterables; +import forge.util.Predicates; import org.apache.commons.lang3.tuple.Pair; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; diff --git a/forge-game/src/main/java/forge/game/combat/AttackRestriction.java b/forge-game/src/main/java/forge/game/combat/AttackRestriction.java index 12cefd32050..10a73cdf7e2 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackRestriction.java +++ b/forge-game/src/main/java/forge/game/combat/AttackRestriction.java @@ -5,10 +5,9 @@ import java.util.Map; import java.util.Set; -import com.google.common.collect.Iterables; - import forge.game.GameEntity; import forge.game.card.Card; +import forge.util.Iterables; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; diff --git a/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java b/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java index 0956a885107..7826ace1114 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java +++ b/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java @@ -1,11 +1,11 @@ package forge.game.combat; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.MagicColor; import forge.game.card.Card; import forge.game.card.CardPredicates; +import forge.util.Predicates; public enum AttackRestrictionType { 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 ed2a2f466d9..0d2a9299787 100644 --- a/forge-game/src/main/java/forge/game/combat/Combat.java +++ b/forge-game/src/main/java/forge/game/combat/Combat.java @@ -17,7 +17,12 @@ */ package forge.game.combat; -import com.google.common.collect.*; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; +import com.google.common.collect.Multimaps; +import com.google.common.collect.Table; import forge.game.*; import forge.game.ability.AbilityKey; import forge.game.ability.ApiType; @@ -32,6 +37,7 @@ import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; import forge.util.CardTranslation; +import forge.util.Iterables; import forge.util.Localizer; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; diff --git a/forge-game/src/main/java/forge/game/combat/CombatUtil.java b/forge-game/src/main/java/forge/game/combat/CombatUtil.java index 8e2de5dfe03..03013e36dde 100644 --- a/forge-game/src/main/java/forge/game/combat/CombatUtil.java +++ b/forge-game/src/main/java/forge/game/combat/CombatUtil.java @@ -18,7 +18,6 @@ package forge.game.combat; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.card.mana.ManaCost; import forge.game.Game; @@ -39,6 +38,7 @@ import forge.game.staticability.StaticAbilityMustBlock; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.TextUtil; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; diff --git a/forge-game/src/main/java/forge/game/cost/CostSacrifice.java b/forge-game/src/main/java/forge/game/cost/CostSacrifice.java index c890a7a6854..b0bdb664550 100644 --- a/forge-game/src/main/java/forge/game/cost/CostSacrifice.java +++ b/forge-game/src/main/java/forge/game/cost/CostSacrifice.java @@ -22,7 +22,6 @@ import java.util.Map; import java.util.Set; -import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import forge.game.Game; @@ -34,6 +33,7 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.Lang; /** diff --git a/forge-game/src/main/java/forge/game/event/GameEventCardStatsChanged.java b/forge-game/src/main/java/forge/game/event/GameEventCardStatsChanged.java index f4bdcd33184..13470f7a40c 100644 --- a/forge-game/src/main/java/forge/game/event/GameEventCardStatsChanged.java +++ b/forge-game/src/main/java/forge/game/event/GameEventCardStatsChanged.java @@ -3,10 +3,9 @@ import java.util.Arrays; import java.util.Collection; +import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.Iterables; - import forge.game.card.Card; /** diff --git a/forge-game/src/main/java/forge/game/event/GameEventPlayerStatsChanged.java b/forge-game/src/main/java/forge/game/event/GameEventPlayerStatsChanged.java index c942ad2f76b..de03c752a2c 100644 --- a/forge-game/src/main/java/forge/game/event/GameEventPlayerStatsChanged.java +++ b/forge-game/src/main/java/forge/game/event/GameEventPlayerStatsChanged.java @@ -3,9 +3,8 @@ import java.util.Arrays; import java.util.Collection; -import com.google.common.collect.Iterables; - import forge.game.player.Player; +import forge.util.Iterables; import forge.util.Lang; import forge.util.TextUtil; diff --git a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java index 1b2933d00f0..2dd5f2265ec 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java +++ b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java @@ -24,10 +24,10 @@ import java.util.Map; import java.util.Map.Entry; +import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; diff --git a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java index dd00c35e796..83a6245cead 100644 --- a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java +++ b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java @@ -17,7 +17,10 @@ */ package forge.game.phase; -import com.google.common.collect.*; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; import forge.game.*; import forge.game.ability.AbilityKey; import forge.game.ability.effects.AddTurnEffect; @@ -39,6 +42,7 @@ import forge.game.zone.Zone; import forge.game.zone.ZoneType; import forge.util.CollectionSuppliers; +import forge.util.Iterables; import forge.util.TextUtil; import forge.util.maps.HashMapOfLists; import forge.util.maps.MapOfLists; diff --git a/forge-game/src/main/java/forge/game/phase/Untap.java b/forge-game/src/main/java/forge/game/phase/Untap.java index 481724cd22d..6f3ac9b69ea 100644 --- a/forge-game/src/main/java/forge/game/phase/Untap.java +++ b/forge-game/src/main/java/forge/game/phase/Untap.java @@ -23,8 +23,6 @@ import java.util.Map.Entry; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -46,6 +44,8 @@ import forge.game.staticability.StaticAbilityCantPhase; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; +import forge.util.Iterables; +import forge.util.Predicates; /** *

diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index f51e1eab79c..070d6328040 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -17,7 +17,6 @@ */ package forge.game.player; -import com.google.common.base.Predicates; import com.google.common.collect.*; import forge.ImageKeys; import forge.LobbyPlayer; @@ -56,6 +55,7 @@ import forge.item.IPaperCard; import forge.item.PaperCard; import forge.util.*; +import forge.util.Iterables; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; import org.apache.commons.lang3.tuple.ImmutablePair; diff --git a/forge-game/src/main/java/forge/game/player/PlayerCollection.java b/forge-game/src/main/java/forge/game/player/PlayerCollection.java index 37034edde38..f2331b9ed42 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerCollection.java +++ b/forge-game/src/main/java/forge/game/player/PlayerCollection.java @@ -5,11 +5,11 @@ import com.google.common.base.Function; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import forge.game.card.CardCollection; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.Iterables; import forge.util.collect.FCollection; public class PlayerCollection extends FCollection { diff --git a/forge-game/src/main/java/forge/game/player/PlayerPredicates.java b/forge-game/src/main/java/forge/game/player/PlayerPredicates.java index 28d6fbdc27f..a852411bf1c 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerPredicates.java +++ b/forge-game/src/main/java/forge/game/player/PlayerPredicates.java @@ -3,7 +3,6 @@ import java.util.Comparator; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.game.CardTraitBase; import forge.game.GameEntity; @@ -13,6 +12,7 @@ import forge.game.card.CounterType; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Predicates; public final class PlayerPredicates { diff --git a/forge-game/src/main/java/forge/game/player/PlayerProperty.java b/forge-game/src/main/java/forge/game/player/PlayerProperty.java index aaf3db80bee..e6c24337f47 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerProperty.java +++ b/forge-game/src/main/java/forge/game/player/PlayerProperty.java @@ -1,6 +1,5 @@ package forge.game.player; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.game.CardTraitBase; import forge.game.Game; @@ -11,6 +10,7 @@ import forge.game.card.CardPredicates; import forge.game.zone.ZoneType; import forge.util.Expressions; +import forge.util.Iterables; import forge.util.TextUtil; import java.util.ArrayList; diff --git a/forge-game/src/main/java/forge/game/player/PlayerView.java b/forge-game/src/main/java/forge/game/player/PlayerView.java index d7c78cf1ab9..d2ab87a88c0 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerView.java +++ b/forge-game/src/main/java/forge/game/player/PlayerView.java @@ -2,7 +2,6 @@ import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableMultiset; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import forge.LobbyPlayer; @@ -20,6 +19,7 @@ import forge.trackable.TrackableProperty; import forge.trackable.Tracker; import forge.util.CardTranslation; +import forge.util.Iterables; import forge.util.Lang; import forge.util.Localizer; import forge.util.collect.FCollection; diff --git a/forge-game/src/main/java/forge/game/player/RegisteredPlayer.java b/forge-game/src/main/java/forge/game/player/RegisteredPlayer.java index 226be9ce173..5619cd45401 100644 --- a/forge-game/src/main/java/forge/game/player/RegisteredPlayer.java +++ b/forge-game/src/main/java/forge/game/player/RegisteredPlayer.java @@ -1,6 +1,5 @@ package forge.game.player; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.LobbyPlayer; import forge.deck.CardPool; @@ -9,6 +8,7 @@ import forge.game.GameType; import forge.item.IPaperCard; import forge.item.PaperCard; +import forge.util.Iterables; import java.util.ArrayList; import java.util.Collections; diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java index aa6bfafb962..88bae9d92e2 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java @@ -19,13 +19,19 @@ import java.util.*; +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Table; +import com.google.common.collect.TreeBasedTable; + import forge.game.cost.CostSacrifice; +import forge.util.*; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.collect.*; - import forge.GameCommand; import forge.card.CardStateName; import forge.card.ColorSet; @@ -68,11 +74,6 @@ import forge.game.trigger.Trigger; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; -import forge.util.Aggregates; -import forge.util.CardTranslation; -import forge.util.Lang; -import forge.util.Localizer; -import forge.util.TextUtil; //only SpellAbility can go on the stack //override any methods as needed diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java index f7d9ebe9207..3858120d826 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java @@ -17,7 +17,6 @@ */ package forge.game.spellability; -import com.google.common.collect.Iterables; import forge.card.ColorSet; import forge.game.Game; import forge.game.GameObject; @@ -30,6 +29,7 @@ import forge.game.player.Player; import forge.game.zone.ZoneType; import forge.util.Expressions; +import forge.util.Iterables; import forge.util.collect.FCollection; import org.apache.commons.lang3.StringUtils; diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java index 277d5756161..387bde38681 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java @@ -21,7 +21,6 @@ import java.util.Map; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import forge.game.Game; @@ -39,6 +38,7 @@ import forge.game.zone.Zone; import forge.game.zone.ZoneType; import forge.util.Expressions; +import forge.util.Iterables; import forge.util.collect.FCollection; /** diff --git a/forge-game/src/main/java/forge/game/spellability/TargetChoices.java b/forge-game/src/main/java/forge/game/spellability/TargetChoices.java index 0b70ea741f9..470f89ad06d 100644 --- a/forge-game/src/main/java/forge/game/spellability/TargetChoices.java +++ b/forge-game/src/main/java/forge/game/spellability/TargetChoices.java @@ -21,9 +21,7 @@ import java.util.List; import java.util.Map; -import com.google.common.base.Predicates; import com.google.common.collect.ForwardingList; -import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import forge.game.GameEntity; @@ -32,6 +30,8 @@ import forge.game.card.CardCollection; import forge.game.card.CardCollectionView; import forge.game.player.Player; +import forge.util.Iterables; +import forge.util.Predicates; import forge.util.collect.FCollection; /** diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantAttackBlock.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantAttackBlock.java index a4c50dc00ae..393d33619ff 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantAttackBlock.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantAttackBlock.java @@ -17,11 +17,10 @@ */ package forge.game.staticability; +import forge.util.Iterables; import org.apache.commons.lang3.tuple.MutablePair; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.collect.Iterables; - import forge.game.Game; import forge.game.GameEntity; import forge.game.ability.AbilityUtils; diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java index a1f48b9f3dd..c7cd4308637 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java @@ -18,7 +18,6 @@ package forge.game.staticability; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import forge.GameCommand; @@ -39,6 +38,7 @@ import forge.game.spellability.SpellAbility; import forge.game.trigger.Trigger; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.TextUtil; import org.apache.commons.lang3.StringUtils; diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityDisableTriggers.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityDisableTriggers.java index e23c99d374c..617ef2a228a 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityDisableTriggers.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityDisableTriggers.java @@ -1,6 +1,5 @@ package forge.game.staticability; -import com.google.common.base.Predicates; import com.google.common.collect.Table.Cell; import forge.game.Game; @@ -9,6 +8,7 @@ import forge.game.trigger.Trigger; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; +import forge.util.Predicates; import org.apache.commons.lang3.ArrayUtils; import java.util.Map; diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityPanharmonicon.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityPanharmonicon.java index 0d9066955b2..d38fc162a4d 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityPanharmonicon.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityPanharmonicon.java @@ -1,8 +1,6 @@ package forge.game.staticability; -import com.google.common.base.Predicates; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import forge.game.Game; import forge.game.GameEntity; @@ -22,6 +20,8 @@ import java.util.List; import java.util.Map; +import forge.util.Iterables; +import forge.util.Predicates; import org.apache.commons.lang3.ArrayUtils; public class StaticAbilityPanharmonicon { diff --git a/forge-game/src/main/java/forge/game/trigger/Trigger.java b/forge-game/src/main/java/forge/game/trigger/Trigger.java index 0e012e7d4bc..ee02e814adc 100644 --- a/forge-game/src/main/java/forge/game/trigger/Trigger.java +++ b/forge-game/src/main/java/forge/game/trigger/Trigger.java @@ -17,7 +17,6 @@ */ package forge.game.trigger; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import forge.game.*; @@ -36,6 +35,7 @@ import forge.game.zone.CostPaymentStack; import forge.game.zone.ZoneType; import forge.util.CardTranslation; +import forge.util.Iterables; import forge.util.Lang; import forge.util.TextUtil; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAbilityTriggered.java b/forge-game/src/main/java/forge/game/trigger/TriggerAbilityTriggered.java index e17b405baf6..1f8de3bb69c 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAbilityTriggered.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAbilityTriggered.java @@ -18,12 +18,12 @@ package forge.game.trigger; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import forge.game.ability.AbilityKey; import forge.game.card.Card; import forge.game.card.CardZoneTable; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import forge.util.Iterables; import forge.util.Localizer; import forge.util.TextUtil; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java index 152d184f683..9a0ba429d09 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java @@ -19,12 +19,11 @@ import java.util.Map; -import com.google.common.collect.Iterables; - import forge.game.ability.AbilityKey; import forge.game.card.Card; import forge.game.card.CardLists; import forge.game.spellability.SpellAbility; +import forge.util.Iterables; import forge.util.Localizer; /** diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java index 5e1fc6e96af..eab5c6e8933 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java @@ -19,7 +19,6 @@ import java.util.*; -import com.google.common.collect.Iterables; import forge.game.GameEntity; import forge.game.GameObjectPredicates; import forge.game.ability.AbilityKey; @@ -29,6 +28,7 @@ import forge.game.card.CardLists; import forge.game.spellability.SpellAbility; import forge.util.Expressions; +import forge.util.Iterables; import forge.util.Localizer; import forge.util.collect.FCollection; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java b/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java index 617cc838992..ee25671db5f 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java @@ -21,10 +21,10 @@ import java.util.List; import java.util.Map; +import forge.util.Iterables; +import forge.util.Predicates; import org.apache.commons.lang3.ArrayUtils; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import forge.game.ability.AbilityKey; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerChangesZoneAll.java b/forge-game/src/main/java/forge/game/trigger/TriggerChangesZoneAll.java index a71f12f2bdb..3809370f86d 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerChangesZoneAll.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerChangesZoneAll.java @@ -3,8 +3,6 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.Iterables; - import forge.game.ability.AbilityKey; import forge.game.ability.AbilityUtils; import forge.game.card.Card; @@ -14,6 +12,7 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Expressions; +import forge.util.Iterables; import forge.util.Localizer; public class TriggerChangesZoneAll extends Trigger { diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java b/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java index fabd8c74c07..8e5951a0d44 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java @@ -20,7 +20,6 @@ import java.util.*; import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Iterables; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimaps; @@ -41,6 +40,7 @@ import forge.game.zone.Zone; import forge.game.zone.ZoneType; import forge.util.FileSection; +import forge.util.Iterables; import forge.util.Visitor; import io.sentry.Breadcrumb; import io.sentry.Sentry; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOutAll.java b/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOutAll.java index 192f2b01347..4934ec5a5ba 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOutAll.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOutAll.java @@ -1,10 +1,10 @@ package forge.game.trigger; -import com.google.common.collect.Iterables; import forge.game.ability.AbilityKey; import forge.game.card.Card; import forge.game.card.CardPredicates; import forge.game.spellability.SpellAbility; +import forge.util.Iterables; import forge.util.Localizer; import java.util.Map; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerTapAll.java b/forge-game/src/main/java/forge/game/trigger/TriggerTapAll.java index 19a75312825..e5e5f3893fe 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerTapAll.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerTapAll.java @@ -1,10 +1,10 @@ package forge.game.trigger; -import com.google.common.collect.Iterables; import forge.game.ability.AbilityKey; import forge.game.card.Card; import forge.game.card.CardPredicates; import forge.game.spellability.SpellAbility; +import forge.util.Iterables; import forge.util.Localizer; import java.util.Map; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerTokenCreatedOnce.java b/forge-game/src/main/java/forge/game/trigger/TriggerTokenCreatedOnce.java index d6f6cfd606f..270beea9bc6 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerTokenCreatedOnce.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerTokenCreatedOnce.java @@ -20,14 +20,13 @@ import java.util.Collections; import java.util.Map; -import com.google.common.collect.Iterables; - import forge.game.ability.AbilityKey; import forge.game.ability.AbilityUtils; import forge.game.card.Card; import forge.game.card.CardPredicates; import forge.game.player.PlayerCollection; import forge.game.spellability.SpellAbility; +import forge.util.Iterables; public class TriggerTokenCreatedOnce extends Trigger { diff --git a/forge-game/src/main/java/forge/game/zone/MagicStack.java b/forge-game/src/main/java/forge/game/zone/MagicStack.java index 7f91e4f21a3..576d928286d 100644 --- a/forge-game/src/main/java/forge/game/zone/MagicStack.java +++ b/forge-game/src/main/java/forge/game/zone/MagicStack.java @@ -19,7 +19,10 @@ import com.esotericsoftware.minlog.Log; import com.google.common.base.Predicate; -import com.google.common.collect.*; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import forge.GameCommand; import forge.game.*; import forge.game.ability.AbilityKey; @@ -40,6 +43,7 @@ import forge.game.spellability.TargetChoices; import forge.game.trigger.Trigger; import forge.game.trigger.TriggerType; +import forge.util.Iterables; import forge.util.TextUtil; import java.util.*; diff --git a/forge-game/src/main/java/forge/game/zone/PlayerZone.java b/forge-game/src/main/java/forge/game/zone/PlayerZone.java index fb042063e29..b8eee507842 100644 --- a/forge-game/src/main/java/forge/game/zone/PlayerZone.java +++ b/forge-game/src/main/java/forge/game/zone/PlayerZone.java @@ -18,7 +18,6 @@ package forge.game.zone; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import forge.card.CardStateName; import forge.game.card.Card; @@ -26,6 +25,7 @@ import forge.game.keyword.Keyword; import forge.game.player.Player; import forge.game.spellability.SpellAbility; +import forge.util.Iterables; import forge.util.Lang; /** diff --git a/forge-game/src/main/java/forge/game/zone/Zone.java b/forge-game/src/main/java/forge/game/zone/Zone.java index 641e33103dd..ca6d1e21a52 100644 --- a/forge-game/src/main/java/forge/game/zone/Zone.java +++ b/forge-game/src/main/java/forge/game/zone/Zone.java @@ -26,7 +26,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.game.Game; @@ -36,6 +35,7 @@ import forge.game.event.GameEventZone; import forge.game.player.Player; import forge.util.CollectionSuppliers; +import forge.util.Iterables; import forge.util.MyRandom; import forge.util.maps.EnumMapOfLists; import forge.util.maps.MapOfLists; diff --git a/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java b/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java index a7ca708d647..e320af070a2 100644 --- a/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java +++ b/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java @@ -23,11 +23,11 @@ import java.util.Map; import java.util.TreeMap; +import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import forge.card.CardEdition; import forge.item.IPaperCard; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/CardManager.java b/forge-gui-desktop/src/main/java/forge/itemmanager/CardManager.java index 756dfe195fb..85cedb2def0 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/CardManager.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/CardManager.java @@ -1,6 +1,5 @@ package forge.itemmanager; -import com.google.common.collect.Iterables; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimaps; @@ -18,6 +17,7 @@ import forge.screens.home.quest.DialogChooseSets; import forge.screens.match.controllers.CDetailPicture; import forge.util.CollectionSuppliers; +import forge.util.Iterables; import forge.util.Localizer; import javax.swing.*; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java b/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java index 5896e573ca1..b6138f20acb 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java @@ -18,8 +18,6 @@ package forge.itemmanager; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.gui.GuiUtils; import forge.gui.UiCommand; @@ -37,10 +35,7 @@ import forge.toolbox.FSkin.Colors; import forge.toolbox.FSkin.SkinIcon; import forge.toolbox.FSkin.SkinnedPanel; -import forge.util.Aggregates; -import forge.util.ItemPool; -import forge.util.Localizer; -import forge.util.ReflectionUtil; +import forge.util.*; import net.miginfocom.swing.MigLayout; import javax.swing.*; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/AdvancedSearchFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/AdvancedSearchFilter.java index 35d67639d01..4281c93f569 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/AdvancedSearchFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/AdvancedSearchFilter.java @@ -11,11 +11,11 @@ import javax.swing.ScrollPaneConstants; import javax.swing.SwingConstants; +import forge.util.Iterables; import org.apache.commons.lang3.ArrayUtils; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import forge.gui.GuiUtils; import forge.gui.UiCommand; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java index 2d3567f8427..8bd8580db51 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java @@ -6,13 +6,13 @@ import javax.swing.JPanel; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardRules; import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.itemmanager.SItemManagerUtil.StatTypes; import forge.itemmanager.SpellShopManager; +import forge.util.Predicates; /** * TODO: Write javadoc for this type. diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java index e7bfbbc4631..e13dead6667 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java @@ -1,12 +1,12 @@ package forge.itemmanager.filters; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; import forge.itemmanager.ItemManager; +import forge.util.Predicates; /** * TODO: Write javadoc for this type. diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java index 7e061b35f76..bcf4a1409d6 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java @@ -1,12 +1,12 @@ package forge.itemmanager.filters; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; import forge.itemmanager.ItemManager; +import forge.util.Predicates; /** * TODO: Write javadoc for this type. diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java index 8a3309c7db3..09130be0dfd 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java @@ -1,12 +1,12 @@ package forge.itemmanager.filters; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; import forge.itemmanager.ItemManager; +import forge.util.Predicates; /** * TODO: Write javadoc for this type. diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java index 276f49b9b1a..3be55d74743 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java @@ -6,13 +6,13 @@ import javax.swing.JPanel; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardRules; import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.itemmanager.SItemManagerUtil.StatTypes; import forge.itemmanager.SpellShopManager; +import forge.util.Predicates; public class CardTypeFilter extends StatTypeFilter { diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java index 828d8cf23cf..6a16370a7e0 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java @@ -5,8 +5,6 @@ import javax.swing.JPanel; -import com.google.common.base.Predicates; - import forge.gui.GuiBase; import forge.gui.UiCommand; import forge.item.InventoryItem; @@ -19,6 +17,7 @@ import forge.toolbox.FSkin; import forge.util.ItemPool; import forge.util.Localizer; +import forge.util.Predicates; public abstract class StatTypeFilter extends ToggleButtonsFilter { protected final Map buttonMap; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TextSearchFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TextSearchFilter.java index cb4b6e9e087..b6c1009859d 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TextSearchFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TextSearchFilter.java @@ -8,7 +8,6 @@ import javax.swing.Timer; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.item.InventoryItem; import forge.itemmanager.ItemManager; @@ -16,6 +15,7 @@ import forge.toolbox.FTextField; import forge.toolbox.LayoutHelper; import forge.util.Localizer; +import forge.util.Predicates; public class TextSearchFilter extends ItemFilter { diff --git a/forge-gui-desktop/src/main/java/forge/screens/bazaar/CBazaarUI.java b/forge-gui-desktop/src/main/java/forge/screens/bazaar/CBazaarUI.java index 5fedd2cd00c..e74181e78e0 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/bazaar/CBazaarUI.java +++ b/forge-gui-desktop/src/main/java/forge/screens/bazaar/CBazaarUI.java @@ -2,11 +2,10 @@ import javax.swing.SwingUtilities; -import com.google.common.collect.Iterables; - import forge.gamemodes.quest.bazaar.QuestBazaarManager; import forge.gui.framework.ICDoc; import forge.toolbox.FLabel; +import forge.util.Iterables; public enum CBazaarUI implements ICDoc { SINGLETON_INSTANCE; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/AddBasicLandsDialog.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/AddBasicLandsDialog.java index 9c43c75fd29..a377bc72071 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/AddBasicLandsDialog.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/AddBasicLandsDialog.java @@ -30,7 +30,6 @@ import javax.swing.SwingConstants; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import forge.ImageCache; import forge.StaticData; @@ -55,6 +54,7 @@ import forge.toolbox.FSkin; import forge.toolbox.FSkin.SkinnedPanel; import forge.toolbox.FTextField; +import forge.util.Iterables; import forge.util.Localizer; import forge.util.MyRandom; import forge.view.arcane.CardPanel; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/ACEditorBase.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/ACEditorBase.java index 6c5dbc3dc0d..2759dec2275 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/ACEditorBase.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/ACEditorBase.java @@ -28,8 +28,6 @@ import javax.swing.KeyStroke; import javax.swing.SwingUtilities; -import com.google.common.collect.Iterables; - import forge.deck.CardPool; import forge.deck.Deck; import forge.deck.DeckBase; @@ -65,6 +63,7 @@ import forge.toolbox.FSkin; import forge.util.Aggregates; import forge.util.ItemPool; +import forge.util.Iterables; import forge.util.Localizer; import forge.view.FView; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java index 94487993125..92635c38616 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java @@ -1,8 +1,6 @@ package forge.screens.deckeditor.controllers; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import forge.Singletons; import forge.card.CardDb; @@ -26,6 +24,8 @@ import forge.screens.deckeditor.SEditorIO; import forge.screens.deckeditor.views.VDeckgen; import forge.util.Aggregates; +import forge.util.Iterables; +import forge.util.Predicates; /** diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java index cce01b0f987..6f1bf6f5e8d 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java @@ -18,7 +18,6 @@ package forge.screens.deckeditor.controllers; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.base.Supplier; import forge.card.CardDb; import forge.card.CardRules; @@ -41,6 +40,7 @@ import forge.screens.match.controllers.CDetailPicture; import forge.toolbox.FComboBox; import forge.util.ItemPool; +import forge.util.Predicates; import java.util.ArrayList; import java.util.List; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java index 32a78647adb..ebc41081770 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java @@ -27,7 +27,6 @@ import com.google.common.base.Function; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.base.Supplier; import forge.card.CardRules; @@ -61,6 +60,7 @@ import forge.screens.match.controllers.CDetailPicture; import forge.toolbox.FComboBox; import forge.util.ItemPool; +import forge.util.Predicates; /** * Child controller for quest deck editor UI. diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java index 502a2c0a1a7..f1f92a48471 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java @@ -19,7 +19,6 @@ import com.google.common.base.Predicate; import com.google.common.base.Supplier; -import com.google.common.collect.Iterables; import forge.deck.Deck; import forge.deck.DeckSection; import forge.game.GameType; @@ -36,6 +35,7 @@ import forge.screens.deckeditor.views.VDeckgen; import forge.screens.match.controllers.CDetailPicture; import forge.util.ItemPool; +import forge.util.Iterables; import forge.util.Localizer; import forge.util.storage.IStorage; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java index 3ff6355f6bb..214a1e34c49 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java @@ -5,7 +5,6 @@ import javax.swing.JLabel; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardRules; import forge.card.CardRulesPredicates; @@ -19,6 +18,7 @@ import forge.screens.deckeditor.views.VStatistics; import forge.util.ItemPool; import forge.util.Localizer; +import forge.util.Predicates; /** * Controls the "analysis" panel in the deck editor UI. diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java index 18752305a78..32116e8bccf 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java @@ -1,7 +1,6 @@ package forge.screens.deckeditor.controllers; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.card.MagicColor; @@ -13,6 +12,7 @@ import forge.screens.deckeditor.views.VStatisticsImporter; import forge.util.ItemPool; import forge.util.Localizer; +import forge.util.Predicates; import javax.swing.*; import java.util.AbstractMap; diff --git a/forge-gui-desktop/src/main/java/forge/screens/home/CLobby.java b/forge-gui-desktop/src/main/java/forge/screens/home/CLobby.java index efc7d8793b6..e584792d408 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/home/CLobby.java +++ b/forge-gui-desktop/src/main/java/forge/screens/home/CLobby.java @@ -5,13 +5,12 @@ import javax.swing.SwingUtilities; -import com.google.common.collect.Iterables; - import forge.deck.DeckProxy; import forge.localinstance.properties.ForgePreferences; import forge.localinstance.properties.ForgePreferences.FPref; import forge.model.FModel; import forge.toolbox.FList; +import forge.util.Iterables; public class CLobby { diff --git a/forge-gui-desktop/src/main/java/forge/screens/home/VLobby.java b/forge-gui-desktop/src/main/java/forge/screens/home/VLobby.java index 8bdeae8f401..80b6125bc37 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/home/VLobby.java +++ b/forge-gui-desktop/src/main/java/forge/screens/home/VLobby.java @@ -14,7 +14,6 @@ import javax.swing.event.ListSelectionListener; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.AIOption; @@ -51,10 +50,7 @@ import forge.toolbox.FSkin; import forge.toolbox.FSkin.SkinImage; import forge.toolbox.FTextField; -import forge.util.Aggregates; -import forge.util.Lang; -import forge.util.Localizer; -import forge.util.NameGenerator; +import forge.util.*; import net.miginfocom.swing.MigLayout; /** diff --git a/forge-gui-desktop/src/main/java/forge/screens/match/controllers/CCombat.java b/forge-gui-desktop/src/main/java/forge/screens/match/controllers/CCombat.java index 442de8b3021..c460771c1f8 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/match/controllers/CCombat.java +++ b/forge-gui-desktop/src/main/java/forge/screens/match/controllers/CCombat.java @@ -1,9 +1,8 @@ package forge.screens.match.controllers; +import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.Iterables; - import forge.game.GameEntityView; import forge.game.card.CardView; import forge.game.card.CardView.CardStateView; diff --git a/forge-gui-desktop/src/main/java/forge/screens/workshop/views/VWorkshopCatalog.java b/forge-gui-desktop/src/main/java/forge/screens/workshop/views/VWorkshopCatalog.java index 6489bbd5366..cea2223a981 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/workshop/views/VWorkshopCatalog.java +++ b/forge-gui-desktop/src/main/java/forge/screens/workshop/views/VWorkshopCatalog.java @@ -2,8 +2,6 @@ import javax.swing.JPanel; -import com.google.common.collect.Iterables; - import forge.gui.framework.DragCell; import forge.gui.framework.DragTab; import forge.gui.framework.EDocID; @@ -16,6 +14,7 @@ import forge.screens.workshop.controllers.CCardScript; import forge.screens.workshop.controllers.CWorkshopCatalog; import forge.util.ItemPool; +import forge.util.Iterables; import forge.util.Localizer; import net.miginfocom.swing.MigLayout; diff --git a/forge-gui-desktop/src/test/java/forge/card/LegacyCardDb.java b/forge-gui-desktop/src/test/java/forge/card/LegacyCardDb.java index 697d7296366..645e633cc67 100644 --- a/forge-gui-desktop/src/test/java/forge/card/LegacyCardDb.java +++ b/forge-gui-desktop/src/test/java/forge/card/LegacyCardDb.java @@ -6,18 +6,14 @@ import java.util.List; import java.util.TreeMap; +import forge.util.*; import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.Iterables; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimaps; import forge.item.PaperCard; -import forge.util.Aggregates; -import forge.util.CollectionSuppliers; -import forge.util.MyRandom; -import forge.util.TextUtil; /** * Test Class (only for test purposes) to compare previous method diff --git a/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/PlayerControllerForTests.java b/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/PlayerControllerForTests.java index eb44cca1733..37bb983b37e 100644 --- a/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/PlayerControllerForTests.java +++ b/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/PlayerControllerForTests.java @@ -1,7 +1,6 @@ package forge.gamesimulationtests.util; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; @@ -49,6 +48,7 @@ import forge.player.HumanPlay; import forge.util.Aggregates; import forge.util.ITriggerEvent; +import forge.util.Iterables; import forge.util.MyRandom; import forge.util.collect.FCollectionView; import org.apache.commons.lang3.tuple.ImmutablePair; diff --git a/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/SpecificationHandler.java b/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/SpecificationHandler.java index 63bb3a93b54..1d9ab87a536 100644 --- a/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/SpecificationHandler.java +++ b/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/SpecificationHandler.java @@ -3,10 +3,9 @@ import java.util.ArrayList; import java.util.List; +import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.Iterables; - public abstract class SpecificationHandler> { public final TYPE find(Iterable items, final SPECIFICATION specification) { return find(items, specification, IntegerConstraint.ONE); diff --git a/forge-gui-desktop/src/test/java/forge/item/DeckHintsTest.java b/forge-gui-desktop/src/test/java/forge/item/DeckHintsTest.java index b82e3aee81e..3cad6f8a551 100644 --- a/forge-gui-desktop/src/test/java/forge/item/DeckHintsTest.java +++ b/forge-gui-desktop/src/test/java/forge/item/DeckHintsTest.java @@ -1,6 +1,5 @@ package forge.item; -import com.google.common.collect.Iterables; import forge.GuiDesktop; import forge.card.CardRarity; import forge.card.CardRules; @@ -8,6 +7,7 @@ import forge.gui.GuiBase; import forge.localinstance.properties.ForgeConstants; import forge.util.FileUtil; +import forge.util.Iterables; import junit.framework.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java index d5ca8586c66..9d126931fc5 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java @@ -4,8 +4,6 @@ import java.util.ArrayList; import java.util.List; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.GuiDesktop; @@ -25,6 +23,8 @@ import forge.localinstance.properties.ForgeConstants; import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; +import forge.util.Iterables; +import forge.util.Predicates; public class PlanarConquestCommanderGeneraterGA extends PlanarConquestGeneraterGA { diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java index c0d17bfea84..23efc3e1bf2 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java @@ -5,10 +5,9 @@ import java.util.List; import java.util.Map; +import forge.util.*; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.GuiDesktop; @@ -37,9 +36,6 @@ import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; import forge.player.GamePlayerUtil; -import forge.util.AbstractGeneticAlgorithm; -import forge.util.MyRandom; -import forge.util.TextUtil; import forge.view.SimulateMatch; public class PlanarConquestGeneraterGA extends AbstractGeneticAlgorithm { diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java index 03bf2a64e23..522006db748 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java @@ -4,8 +4,6 @@ import java.util.ArrayList; import java.util.List; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.GuiDesktop; @@ -24,6 +22,8 @@ import forge.localinstance.properties.ForgeConstants; import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; +import forge.util.Iterables; +import forge.util.Predicates; public class PlanarConquestTribalGeneraterGA extends PlanarConquestGeneraterGA { diff --git a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java index a4652e3ca8f..7300b6cf638 100644 --- a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java +++ b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java @@ -13,7 +13,6 @@ import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.utils.Array; -import com.google.common.base.Predicates; import forge.Forge; import forge.adventure.data.DialogData; import forge.adventure.data.EffectData; @@ -33,6 +32,7 @@ import forge.item.PaperCard; import forge.util.Aggregates; import forge.util.MyRandom; +import forge.util.Predicates; import java.util.ArrayList; import java.util.LinkedList; diff --git a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java index 21fecb0dca1..f2b985c448a 100644 --- a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java +++ b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java @@ -3,7 +3,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.utils.Array; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.Forge; import forge.adventure.character.EnemySprite; import forge.adventure.pointofintrest.PointOfInterestChanges; @@ -22,6 +21,7 @@ import forge.model.FModel; import forge.util.Aggregates; import forge.util.MyRandom; +import forge.util.Predicates; import org.apache.commons.lang3.tuple.Pair; import java.io.Serializable; diff --git a/forge-gui-mobile/src/forge/adventure/data/RewardData.java b/forge-gui-mobile/src/forge/adventure/data/RewardData.java index 3b7fcef20dd..3e4089df6b0 100644 --- a/forge-gui-mobile/src/forge/adventure/data/RewardData.java +++ b/forge-gui-mobile/src/forge/adventure/data/RewardData.java @@ -1,7 +1,6 @@ package forge.adventure.data; import com.badlogic.gdx.utils.Array; -import com.google.common.collect.Iterables; import forge.StaticData; import forge.adventure.util.CardUtil; import forge.adventure.util.Config; @@ -10,6 +9,7 @@ import forge.adventure.world.WorldSave; import forge.deck.Deck; import forge.item.PaperCard; +import forge.util.Iterables; import java.io.Serializable; import java.util.*; diff --git a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java index e348784c563..ef526770d51 100644 --- a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java +++ b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java @@ -3,8 +3,6 @@ import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.utils.Json; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.StaticData; import forge.adventure.data.ConfigData; @@ -24,6 +22,8 @@ import forge.item.generation.UnOpenedProduct; import forge.model.FModel; import forge.util.Aggregates; +import forge.util.Iterables; +import forge.util.Predicates; import java.text.SimpleDateFormat; import java.util.*; diff --git a/forge-gui-mobile/src/forge/deck/AddBasicLandsDialog.java b/forge-gui-mobile/src/forge/deck/AddBasicLandsDialog.java index 23c51101b68..c5634d40c04 100644 --- a/forge-gui-mobile/src/forge/deck/AddBasicLandsDialog.java +++ b/forge-gui-mobile/src/forge/deck/AddBasicLandsDialog.java @@ -23,7 +23,6 @@ import java.util.Map.Entry; import com.badlogic.gdx.utils.Align; -import com.google.common.collect.Iterables; import forge.Forge; import forge.Graphics; @@ -48,6 +47,7 @@ import forge.toolbox.FScrollPane; import forge.toolbox.FTextArea; import forge.util.Callback; +import forge.util.Iterables; import forge.util.MyRandom; import forge.util.Utils; diff --git a/forge-gui-mobile/src/forge/deck/FDeckEditor.java b/forge-gui-mobile/src/forge/deck/FDeckEditor.java index 12b13f46516..6378151d4bb 100644 --- a/forge-gui-mobile/src/forge/deck/FDeckEditor.java +++ b/forge-gui-mobile/src/forge/deck/FDeckEditor.java @@ -4,7 +4,6 @@ import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Align; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import forge.Forge; diff --git a/forge-gui-mobile/src/forge/itemmanager/ItemManager.java b/forge-gui-mobile/src/forge/itemmanager/ItemManager.java index d1bfa7b27ad..ce36cfbaa25 100644 --- a/forge-gui-mobile/src/forge/itemmanager/ItemManager.java +++ b/forge-gui-mobile/src/forge/itemmanager/ItemManager.java @@ -25,8 +25,6 @@ import com.badlogic.gdx.utils.Align; import com.google.common.base.Function; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import forge.Forge; import forge.Graphics; @@ -55,7 +53,9 @@ import forge.toolbox.FList; import forge.toolbox.FList.CompactModeHandler; import forge.util.ItemPool; +import forge.util.Iterables; import forge.util.LayoutHelper; +import forge.util.Predicates; public abstract class ItemManager extends FContainer implements IItemManager, ActivateHandler { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/AdvancedSearchFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/AdvancedSearchFilter.java index 264abe729c0..48db74da569 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/AdvancedSearchFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/AdvancedSearchFilter.java @@ -2,7 +2,6 @@ import com.badlogic.gdx.utils.Align; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import forge.Forge; import forge.assets.FSkinImage; @@ -26,6 +25,7 @@ import forge.toolbox.FScrollPane; import forge.toolbox.FTextField; import forge.util.Callback; +import forge.util.Iterables; public class AdvancedSearchFilter extends ItemFilter { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java index 5b989265f30..ccc4f561e23 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java @@ -1,12 +1,12 @@ package forge.itemmanager.filters; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; import forge.itemmanager.ItemManager; +import forge.util.Predicates; public class CardCMCFilter extends ValueRangeFilter { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java index b59ad8c46ef..a5a8d027977 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java @@ -1,12 +1,12 @@ package forge.itemmanager.filters; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; import forge.itemmanager.ItemManager; +import forge.util.Predicates; public class CardColorlessCostFilter extends ValueRangeFilter { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardFormatFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardFormatFilter.java index 3d8942d2f77..e94dc2287ea 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardFormatFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardFormatFilter.java @@ -1,10 +1,10 @@ package forge.itemmanager.filters; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.item.PaperCard; import forge.itemmanager.ItemManager; +import forge.util.Predicates; public class CardFormatFilter extends FormatFilter { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java index 3221f0a0f1a..8ed5cddd1eb 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java @@ -1,12 +1,12 @@ package forge.itemmanager.filters; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; import forge.itemmanager.ItemManager; +import forge.util.Predicates; public class CardPowerFilter extends ValueRangeFilter { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java index 0d06e8af088..e02c492cd96 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java @@ -1,12 +1,12 @@ package forge.itemmanager.filters; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; import forge.itemmanager.ItemManager; +import forge.util.Predicates; public class CardToughnessFilter extends ValueRangeFilter { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java index c97e5821ccd..622f25bf19b 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java @@ -4,12 +4,12 @@ import java.util.List; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardRules; import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.itemmanager.SItemManagerUtil.StatTypes; +import forge.util.Predicates; public class CardTypeFilter extends StatTypeFilter { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/DeckFormatFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/DeckFormatFilter.java index 1d23de06fc8..4c7648a00aa 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/DeckFormatFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/DeckFormatFilter.java @@ -1,10 +1,10 @@ package forge.itemmanager.filters; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.deck.DeckProxy; import forge.itemmanager.ItemManager; +import forge.util.Predicates; public class DeckFormatFilter extends FormatFilter { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/TextSearchFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/TextSearchFilter.java index 0ff4a5dbff0..475b25a028a 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/TextSearchFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/TextSearchFilter.java @@ -2,7 +2,6 @@ import com.badlogic.gdx.utils.Align; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.Forge; import forge.Graphics; @@ -12,6 +11,7 @@ import forge.itemmanager.SFilterUtil; import forge.toolbox.FDisplayObject; import forge.toolbox.FTextField; +import forge.util.Predicates; public class TextSearchFilter extends ItemFilter { diff --git a/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java b/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java index 58cc3c0008f..4bb268079b1 100644 --- a/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java +++ b/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java @@ -7,11 +7,11 @@ import java.util.Set; import forge.player.GamePlayerUtil; +import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.utils.Align; -import com.google.common.collect.Iterables; import forge.Forge; import forge.Graphics; diff --git a/forge-gui-mobile/src/forge/screens/match/MatchController.java b/forge-gui-mobile/src/forge/screens/match/MatchController.java index f1af40a93b2..d8fe73d5ab8 100644 --- a/forge-gui-mobile/src/forge/screens/match/MatchController.java +++ b/forge-gui-mobile/src/forge/screens/match/MatchController.java @@ -11,12 +11,12 @@ import forge.deck.Deck; import forge.game.player.Player; import forge.item.IPaperCard; +import forge.util.Iterables; import forge.util.collect.FCollection; import org.apache.commons.lang3.StringUtils; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import forge.Forge; diff --git a/forge-gui-mobile/src/forge/screens/match/views/VReveal.java b/forge-gui-mobile/src/forge/screens/match/views/VReveal.java index ae0a15d99ca..f162ca4d215 100644 --- a/forge-gui-mobile/src/forge/screens/match/views/VReveal.java +++ b/forge-gui-mobile/src/forge/screens/match/views/VReveal.java @@ -1,7 +1,6 @@ package forge.screens.match.views; import com.badlogic.gdx.utils.Align; -import com.google.common.collect.Iterables; import forge.Forge; import forge.Graphics; import forge.assets.FImage; @@ -18,6 +17,7 @@ import forge.toolbox.FLabel; import forge.util.CardTranslation; import forge.util.ImageUtil; +import forge.util.Iterables; import forge.util.Utils; import java.util.ArrayList; diff --git a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java index 8399943562e..9d7957549f1 100644 --- a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java +++ b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java @@ -8,9 +8,7 @@ import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.utils.Align; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import forge.Forge; import forge.Graphics; @@ -40,10 +38,7 @@ import forge.toolbox.FDisplayObject; import forge.toolbox.FLabel; import forge.toolbox.GuiChoose; -import forge.util.Aggregates; -import forge.util.Callback; -import forge.util.MyRandom; -import forge.util.Utils; +import forge.util.*; public class ConquestAEtherScreen extends FScreen { public static final Color FILTER_BUTTON_COLOR = ConquestMultiverseScreen.LOCATION_BAR_COLOR; diff --git a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestPlaneSelector.java b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestPlaneSelector.java index 72916fcb860..bb4969fa017 100644 --- a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestPlaneSelector.java +++ b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestPlaneSelector.java @@ -6,7 +6,6 @@ import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.utils.Align; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import forge.Forge; import forge.Graphics; @@ -23,6 +22,7 @@ import forge.toolbox.FOptionPane; import forge.toolbox.FTimer; import forge.toolbox.GuiDialog; +import forge.util.Iterables; import forge.util.Utils; import forge.util.collect.FCollectionView; diff --git a/forge-gui-mobile/src/forge/screens/planarconquest/NewConquestScreen.java b/forge-gui-mobile/src/forge/screens/planarconquest/NewConquestScreen.java index eabb5240586..f6cb6a9490d 100644 --- a/forge-gui-mobile/src/forge/screens/planarconquest/NewConquestScreen.java +++ b/forge-gui-mobile/src/forge/screens/planarconquest/NewConquestScreen.java @@ -1,7 +1,5 @@ package forge.screens.planarconquest; -import com.google.common.collect.Iterables; - import forge.Forge; import forge.assets.FImage; import forge.card.CardImage; @@ -20,6 +18,7 @@ import forge.screens.planarconquest.ConquestMenu.LaunchReason; import forge.toolbox.FChoiceList; import forge.toolbox.FOptionPane; +import forge.util.Iterables; import forge.util.ThreadUtil; public class NewConquestScreen extends MultiStepWizardScreen { diff --git a/forge-gui-mobile/src/forge/toolbox/GuiChoose.java b/forge-gui-mobile/src/forge/toolbox/GuiChoose.java index ff65795ff0d..a1805aac4af 100644 --- a/forge-gui-mobile/src/forge/toolbox/GuiChoose.java +++ b/forge-gui-mobile/src/forge/toolbox/GuiChoose.java @@ -7,10 +7,10 @@ import java.util.List; import forge.Forge; +import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import com.google.common.base.Function; -import com.google.common.collect.Iterables; import forge.game.card.CardView; import forge.util.Callback; diff --git a/forge-gui-mobile/src/forge/toolbox/ListChooser.java b/forge-gui-mobile/src/forge/toolbox/ListChooser.java index 9925d5bb77a..32ca730fdf1 100644 --- a/forge-gui-mobile/src/forge/toolbox/ListChooser.java +++ b/forge-gui-mobile/src/forge/toolbox/ListChooser.java @@ -25,9 +25,7 @@ import com.badlogic.gdx.Input; import com.google.common.base.Function; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import forge.Forge; import forge.Graphics; @@ -41,6 +39,8 @@ import forge.menu.FMenuItem; import forge.menu.FPopupMenu; import forge.util.Callback; +import forge.util.Iterables; +import forge.util.Predicates; import forge.util.Utils; /** diff --git a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java index f84244d4887..69e76e03d3e 100644 --- a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java @@ -10,10 +10,10 @@ import java.util.List; import java.util.Map; +import forge.util.Iterables; +import forge.util.Predicates; import org.apache.commons.lang3.ArrayUtils; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.card.CardRulesPredicates; diff --git a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java index 9903a52b6b4..7e2c4f3b882 100644 --- a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java @@ -5,8 +5,6 @@ import java.util.List; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import forge.card.CardEdition; import forge.card.CardRules; @@ -15,6 +13,8 @@ import forge.item.PaperCard; import forge.model.FModel; import forge.util.ItemPool; +import forge.util.Iterables; +import forge.util.Predicates; /** * Created by maustin on 09/05/2017. diff --git a/forge-gui/src/main/java/forge/deck/DeckProxy.java b/forge-gui/src/main/java/forge/deck/DeckProxy.java index 38813463449..4654d9b295d 100644 --- a/forge-gui/src/main/java/forge/deck/DeckProxy.java +++ b/forge-gui/src/main/java/forge/deck/DeckProxy.java @@ -1,8 +1,6 @@ package forge.deck; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import forge.StaticData; import forge.card.*; import forge.card.mana.ManaCostShard; @@ -20,6 +18,8 @@ import forge.model.FModel; import forge.util.BinaryUtil; import forge.util.IHasName; +import forge.util.Iterables; +import forge.util.Predicates; import forge.util.storage.IStorage; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; diff --git a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java index d5afbe7aba2..c3092b7fb7e 100644 --- a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java +++ b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java @@ -9,11 +9,10 @@ import java.util.Map; import java.util.Set; +import forge.util.*; import org.apache.commons.lang3.tuple.Pair; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.StaticData; @@ -45,9 +44,6 @@ import forge.itemmanager.IItemManager; import forge.localinstance.properties.ForgePreferences.FPref; import forge.model.FModel; -import forge.util.Aggregates; -import forge.util.Lang; -import forge.util.MyRandom; import forge.util.storage.IStorage; /** diff --git a/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java b/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java index d4bad4ac7b9..75c3bee1ed5 100644 --- a/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java @@ -3,14 +3,13 @@ import java.util.ArrayList; import java.util.List; -import com.google.common.collect.Iterables; - import forge.game.GameFormat; import forge.game.GameType; import forge.game.IHasGameType; import forge.gamemodes.quest.QuestController; import forge.model.FModel; import forge.util.Aggregates; +import forge.util.Iterables; public class RandomDeckGenerator extends DeckProxy implements Comparable { private enum RandomDeckType { diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java b/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java index a7e3260ea2f..58f63f2055f 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java @@ -19,7 +19,6 @@ import com.google.common.base.Predicate; import com.google.common.base.Supplier; -import com.google.common.collect.Iterables; import forge.StaticData; import forge.card.CardEdition; import forge.deck.CardPool; @@ -36,10 +35,7 @@ import forge.localinstance.properties.ForgePreferences; import forge.model.CardBlock; import forge.model.FModel; -import forge.util.FileUtil; -import forge.util.ItemPool; -import forge.util.Localizer; -import forge.util.TextUtil; +import forge.util.*; import forge.util.storage.IStorage; import org.apache.commons.lang3.ArrayUtils; diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardRanker.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardRanker.java index 21660e5abc4..32ca4f394c9 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardRanker.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardRanker.java @@ -1,12 +1,12 @@ package forge.gamemodes.limited; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.card.ColorSet; import forge.card.DeckHints; import forge.card.MagicColor; import forge.item.PaperCard; +import forge.util.Iterables; import org.apache.commons.lang3.tuple.Pair; import java.util.ArrayList; diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java index 47b3f5ae06f..6a87ec1c0b5 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java @@ -2,8 +2,6 @@ import java.util.List; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.card.CardRulesPredicates; @@ -12,6 +10,8 @@ import forge.deck.generation.DeckGenPool; import forge.item.PaperCard; import forge.model.FModel; +import forge.util.Iterables; +import forge.util.Predicates; /** * Created by maustin on 28/02/2018. diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java index 615374e22ea..07fd70d6db3 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java @@ -2,8 +2,6 @@ import java.util.List; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.card.CardRulesPredicates; @@ -13,6 +11,8 @@ import forge.game.GameFormat; import forge.item.PaperCard; import forge.model.FModel; +import forge.util.Iterables; +import forge.util.Predicates; /** * Created by maustin on 28/02/2018. diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java index a7bb88aee3e..de544051f75 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java @@ -10,8 +10,6 @@ import java.util.Set; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.StaticData; @@ -34,7 +32,9 @@ import forge.item.PaperCard; import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; +import forge.util.Iterables; import forge.util.MyRandom; +import forge.util.Predicates; /** * Limited format deck. diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java index 3acd1e486fe..14a98e28773 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java @@ -9,8 +9,6 @@ import java.util.Set; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.card.CardAiHints; @@ -29,7 +27,9 @@ import forge.item.IPaperCard; import forge.item.PaperCard; import forge.model.FModel; +import forge.util.Iterables; import forge.util.MyRandom; +import forge.util.Predicates; /** * Limited format deck. diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayer.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayer.java index 1a9bae2da9c..3043e2ff9df 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayer.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayer.java @@ -1,6 +1,5 @@ package forge.gamemodes.limited; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import forge.card.CardEdition; @@ -11,6 +10,7 @@ import forge.gui.util.SGuiChoose; import forge.item.PaperCard; import forge.model.FModel; +import forge.util.Iterables; import forge.util.TextUtil; import java.util.*; diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java index 21da70a76e5..ed65e38fc1f 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java @@ -1,7 +1,5 @@ package forge.gamemodes.limited; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import forge.card.CardEdition; import forge.card.ColorSet; import forge.deck.CardPool; @@ -10,7 +8,9 @@ import forge.deck.generation.DeckGeneratorBase; import forge.item.PaperCard; import forge.localinstance.properties.ForgePreferences; +import forge.util.Iterables; import forge.util.MyRandom; +import forge.util.Predicates; import org.apache.commons.lang3.tuple.Pair; import java.util.Collections; diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java index ea56f8b1017..3e1e1c8c987 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java @@ -4,13 +4,12 @@ import java.util.Arrays; import java.util.List; -import com.google.common.collect.Iterables; - import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.card.ColorSet; import forge.card.MagicColor; import forge.item.PaperCard; +import forge.util.Iterables; import forge.util.MyRandom; /** diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java b/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java index 613aa3a1828..50d9fc79951 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java @@ -5,14 +5,14 @@ import java.util.List; import java.util.Stack; -import com.google.common.base.Predicates; import com.google.common.base.Supplier; -import com.google.common.collect.Iterables; import forge.deck.CardPool; import forge.deck.Deck; import forge.item.PaperCard; +import forge.util.Iterables; import forge.util.MyRandom; +import forge.util.Predicates; public class WinstonDraft extends BoosterDraft { private WinstonDraftAI draftAI = null; diff --git a/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java b/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java index bc3312e68bd..41a2d055d82 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java @@ -11,10 +11,10 @@ import forge.gui.control.PlaybackSpeed; import forge.trackable.TrackableCollection; +import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectManyBase.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectManyBase.java index 401ff362fc6..adc75fa0ac1 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectManyBase.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectManyBase.java @@ -2,8 +2,6 @@ import java.util.Collection; -import com.google.common.collect.Iterables; - import forge.game.GameEntity; import forge.game.card.Card; import forge.game.card.CardView; @@ -13,6 +11,7 @@ import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; import forge.player.PlayerControllerHuman; +import forge.util.Iterables; public abstract class InputSelectManyBase extends InputSyncronizedBase { private static final long serialVersionUID = -2305549394512889450L; diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java index fcc13f5cd34..2e2803b8381 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java @@ -9,7 +9,6 @@ import org.apache.commons.lang3.ObjectUtils; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java b/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java index cca255d57c8..683b6a5d2d9 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java @@ -1,7 +1,5 @@ package forge.gamemodes.net.server; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import forge.gamemodes.match.LobbySlot; import forge.gamemodes.match.LobbySlotType; @@ -12,6 +10,8 @@ import forge.gui.interfaces.IGuiGame; import forge.interfaces.IGameController; import forge.interfaces.ILobbyListener; +import forge.util.Iterables; +import forge.util.Predicates; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.*; import io.netty.channel.nio.NioEventLoopGroup; diff --git a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java index f6d2612eacb..e37b88dd893 100644 --- a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java +++ b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java @@ -6,7 +6,6 @@ import java.util.Set; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardRulesPredicates; import forge.card.ColorSet; @@ -16,6 +15,7 @@ import forge.item.PaperCard; import forge.localinstance.skin.ISkinImage; import forge.model.FModel; +import forge.util.Predicates; import forge.util.collect.FCollection; import forge.util.collect.FCollectionReader; import forge.util.collect.FCollectionView; diff --git a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java index c10ab5fd05b..49ea9dad364 100644 --- a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java +++ b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java @@ -7,7 +7,6 @@ import java.util.Set; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -38,6 +37,7 @@ import forge.localinstance.skin.IHasSkinProp; import forge.model.FModel; import forge.util.FileUtil; +import forge.util.Iterables; import forge.util.Localizer; import forge.util.MyRandom; diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java index 063ab710f10..1a0cb656a1b 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java @@ -24,11 +24,11 @@ import java.util.Comparator; import java.util.List; +import forge.util.Iterables; +import forge.util.Predicates; import org.apache.commons.lang3.StringUtils; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.card.CardEdition; diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java index ff63695f6bf..544a317ec3b 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java @@ -4,12 +4,12 @@ import java.util.List; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardRules; import forge.item.IPaperCard; import forge.item.PaperCard; import forge.model.FModel; +import forge.util.Predicates; public abstract class QuestRewardCard implements IQuestRewardCard { diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardChooser.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardChooser.java index ae4343d47bc..34b21fd6718 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardChooser.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardChooser.java @@ -6,11 +6,11 @@ import java.util.Map; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import forge.item.PaperCard; import forge.model.FModel; import forge.util.ItemPool; +import forge.util.Iterables; /** * Resolves a card chooser InventoryItem into a CardPrinted. diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardFiltered.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardFiltered.java index 109bc718377..ae617368f6a 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardFiltered.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardFiltered.java @@ -5,10 +5,10 @@ import java.util.List; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import forge.item.PaperCard; import forge.model.FModel; +import forge.util.Iterables; /** * Allows the player to choose a card from a predicate-filtered list of cards. diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java index 063cb5d0e36..f83257c843b 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java @@ -19,9 +19,7 @@ import com.google.common.base.Function; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.card.CardEdition; import forge.card.CardRarity; @@ -41,9 +39,7 @@ import forge.item.generation.UnOpenedProduct; import forge.localinstance.properties.ForgePreferences.FPref; import forge.model.FModel; -import forge.util.Aggregates; -import forge.util.ItemPool; -import forge.util.MyRandom; +import forge.util.*; import org.apache.commons.lang3.tuple.Pair; import java.util.ArrayList; diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java index 7e24021c3d4..f06dc93c3e5 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java @@ -24,7 +24,6 @@ import java.util.Map; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.card.CardEdition; import forge.gamemodes.quest.data.QuestPreferences.QPref; @@ -36,6 +35,7 @@ import forge.item.SealedTemplate; import forge.item.generation.UnOpenedProduct; import forge.model.FModel; +import forge.util.Iterables; import forge.util.TextUtil; import forge.util.storage.IStorage; import org.apache.commons.lang3.tuple.ImmutablePair; diff --git a/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java b/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java index 7257637fb3b..a482d13c89b 100644 --- a/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java +++ b/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java @@ -4,11 +4,11 @@ import java.util.Map; import java.util.Set; +import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSortedSet; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; diff --git a/forge-gui/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java b/forge-gui/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java index 4a66e114fcb..76a87677526 100644 --- a/forge-gui/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java +++ b/forge-gui/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java @@ -23,10 +23,9 @@ import java.util.Map; import java.util.TreeMap; +import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.Iterables; - import forge.StaticData; import forge.card.CardEdition; import forge.item.PaperCard; diff --git a/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java b/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java index 469a75bc205..54393930cc1 100644 --- a/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java +++ b/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java @@ -5,10 +5,10 @@ import java.util.Collection; import java.util.List; +import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import com.google.common.base.Function; -import com.google.common.collect.Iterables; import forge.gui.GuiBase; diff --git a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java index 1e3a5b5307c..75b7beb6e3e 100644 --- a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java +++ b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java @@ -14,7 +14,6 @@ import com.google.common.base.Function; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; @@ -49,6 +48,7 @@ import forge.model.FModel; import forge.util.CardTranslation; import forge.util.Localizer; +import forge.util.Predicates; public class AdvancedSearch { public enum FilterOption { diff --git a/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java b/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java index 039f789ef31..8bbafde8c29 100644 --- a/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java +++ b/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java @@ -6,11 +6,11 @@ import java.util.Stack; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.util.PredicateString.StringOp; +import forge.util.Predicates; public class BooleanExpression { private Stack operators = new Stack<>(); diff --git a/forge-gui/src/main/java/forge/itemmanager/ColumnDef.java b/forge-gui/src/main/java/forge/itemmanager/ColumnDef.java index 68750c3dd6b..50de4b41fbb 100644 --- a/forge-gui/src/main/java/forge/itemmanager/ColumnDef.java +++ b/forge-gui/src/main/java/forge/itemmanager/ColumnDef.java @@ -18,7 +18,6 @@ package forge.itemmanager; import com.google.common.base.Function; -import com.google.common.collect.Iterables; import forge.card.*; import forge.card.mana.ManaCost; import forge.deck.DeckProxy; @@ -33,6 +32,7 @@ import forge.itemmanager.ItemColumnConfig.SortState; import forge.model.FModel; import forge.util.CardTranslation; +import forge.util.Iterables; import forge.util.Localizer; import forge.util.TextUtil; diff --git a/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java b/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java index dfa0291984a..fbacb231907 100644 --- a/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java +++ b/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java @@ -7,7 +7,6 @@ import java.util.Set; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import forge.StaticData; import forge.card.CardEdition; @@ -26,6 +25,7 @@ import forge.model.FModel; import forge.util.BinaryUtil; import forge.util.PredicateString.StringOp; +import forge.util.Predicates; /** * Static factory; holds blocks of form elements and predicates diff --git a/forge-gui/src/main/java/forge/localinstance/achievements/AgainstAllOdds.java b/forge-gui/src/main/java/forge/localinstance/achievements/AgainstAllOdds.java index d71ce064061..430faaf2872 100644 --- a/forge-gui/src/main/java/forge/localinstance/achievements/AgainstAllOdds.java +++ b/forge-gui/src/main/java/forge/localinstance/achievements/AgainstAllOdds.java @@ -1,13 +1,12 @@ package forge.localinstance.achievements; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; - import forge.game.Game; import forge.game.player.Player; import forge.game.player.PlayerCollection; import forge.game.player.PlayerPredicates; +import forge.util.Iterables; import forge.util.Localizer; +import forge.util.Predicates; public class AgainstAllOdds extends Achievement { public AgainstAllOdds() { diff --git a/forge-gui/src/main/java/forge/model/FModel.java b/forge-gui/src/main/java/forge/model/FModel.java index 02d352fb8ef..eb341aad3d4 100644 --- a/forge-gui/src/main/java/forge/model/FModel.java +++ b/forge-gui/src/main/java/forge/model/FModel.java @@ -18,7 +18,6 @@ package forge.model; import com.google.common.base.Function; -import com.google.common.base.Predicates; import com.google.common.collect.Maps; import forge.CardStorageReader; import forge.CardStorageReader.ProgressObserver; diff --git a/forge-gui/src/main/java/forge/player/HumanCostDecision.java b/forge-gui/src/main/java/forge/player/HumanCostDecision.java index 6f8437163dc..51b4d823977 100644 --- a/forge-gui/src/main/java/forge/player/HumanCostDecision.java +++ b/forge-gui/src/main/java/forge/player/HumanCostDecision.java @@ -1,7 +1,5 @@ package forge.player; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.card.CardType; import forge.card.MagicColor; diff --git a/forge-gui/src/main/java/forge/player/HumanPlay.java b/forge-gui/src/main/java/forge/player/HumanPlay.java index 1d9323108a3..048dddef377 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlay.java +++ b/forge-gui/src/main/java/forge/player/HumanPlay.java @@ -8,8 +8,6 @@ import forge.game.ability.AbilityKey; import forge.game.cost.*; -import com.google.common.collect.Iterables; - import forge.card.CardStateName; import forge.card.mana.ManaCost; import forge.game.Game; @@ -44,6 +42,7 @@ import forge.gui.FThreads; import forge.gui.util.SGuiChoose; import forge.util.Aggregates; +import forge.util.Iterables; import forge.util.Localizer; import forge.util.TextUtil; import forge.util.collect.FCollectionView; diff --git a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java index f9b2b1b3306..51ca400a829 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java +++ b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java @@ -19,10 +19,9 @@ import java.util.Collections; +import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.Iterables; - import forge.card.CardType; import forge.card.MagicColor; import forge.game.Game; diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index 96ef58f2b35..27e537d3b0c 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -64,6 +64,7 @@ import forge.model.FModel; import forge.trackable.TrackableCollection; import forge.util.*; +import forge.util.Iterables; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; import io.sentry.Sentry; diff --git a/forge-gui/src/main/java/forge/player/TargetSelection.java b/forge-gui/src/main/java/forge/player/TargetSelection.java index 036eda2bdf1..4bd5af4d015 100644 --- a/forge-gui/src/main/java/forge/player/TargetSelection.java +++ b/forge-gui/src/main/java/forge/player/TargetSelection.java @@ -24,7 +24,6 @@ import java.util.Map; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -48,6 +47,7 @@ import forge.game.zone.ZoneType; import forge.gamemodes.match.input.InputSelectTargets; import forge.util.Aggregates; +import forge.util.Iterables; import forge.util.TextUtil; /** diff --git a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java index 8a83ae5725e..899fa4acf01 100644 --- a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java +++ b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java @@ -1,7 +1,5 @@ package forge.lda; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.GuiDesktop; @@ -20,6 +18,8 @@ import forge.localinstance.properties.ForgeConstants; import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; +import forge.util.Iterables; +import forge.util.Predicates; import forge.util.storage.IStorage; import forge.util.storage.StorageImmediatelySerialized; import org.apache.commons.lang3.ArrayUtils; From 976527916626948af25577c9f8fa45d6104988e3 Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 17:08:25 -0400 Subject: [PATCH 05/68] Guava migration - Migrate Predicates --- .../java/forge/ai/AiAttackController.java | 2 +- .../main/java/forge/ai/AiBlockController.java | 3 +-- .../src/main/java/forge/ai/AiController.java | 2 +- .../src/main/java/forge/ai/ComputerUtil.java | 3 +-- .../main/java/forge/ai/ComputerUtilCard.java | 2 +- .../java/forge/ai/PlayerControllerAi.java | 2 +- .../ai/ability/CountersPutOrRemoveAi.java | 3 +-- .../forge/ai/ability/CountersRemoveAi.java | 3 +-- .../java/forge/ai/ability/DamageAllAi.java | 4 +-- .../java/forge/ai/ability/DestroyAllAi.java | 3 ++- .../java/forge/ai/ability/PumpAiBase.java | 3 +-- .../main/java/forge/ai/ability/TapAiBase.java | 3 +-- .../src/main/java/forge/StaticData.java | 2 +- .../src/main/java/forge/card/CardDb.java | 8 +++--- .../src/main/java/forge/card/CardEdition.java | 10 +++---- .../java/forge/card/CardFacePredicates.java | 10 +++---- .../java/forge/card/CardRulesPredicates.java | 15 +++++------ .../src/main/java/forge/card/CardType.java | 2 +- .../src/main/java/forge/card/DeckHints.java | 6 ++--- .../main/java/forge/card/ICardDatabase.java | 2 +- .../src/main/java/forge/deck/CardPool.java | 6 ++--- .../src/main/java/forge/deck/DeckFormat.java | 26 +++++++++---------- .../forge/deck/generation/DeckGenPool.java | 3 +-- .../deck/generation/DeckGenerator2Color.java | 2 +- .../deck/generation/DeckGenerator3Color.java | 2 +- .../deck/generation/DeckGenerator4Color.java | 2 +- .../deck/generation/DeckGenerator5Color.java | 2 +- .../deck/generation/DeckGeneratorBase.java | 6 ++--- .../generation/DeckGeneratorMonoColor.java | 2 +- .../forge/deck/generation/IDeckGenPool.java | 4 +-- .../src/main/java/forge/item/IPaperCard.java | 14 +++++----- .../main/java/forge/item/ItemPredicate.java | 3 ++- .../main/java/forge/item/SealedProduct.java | 2 +- .../item/generation/BoosterGenerator.java | 4 +-- .../item/generation/UnOpenedProduct.java | 2 +- .../main/java/forge/token/ITokenDatabase.java | 2 +- .../src/main/java/forge/token/TokenDb.java | 2 +- .../src/main/java/forge/util/ItemPool.java | 7 +++-- .../main/java/forge/util/PredicateCard.java | 7 +++-- .../main/java/forge/util/PredicateString.java | 8 +++--- .../java/forge/util/storage/IStorage.java | 3 +-- .../java/forge/util/storage/StorageBase.java | 4 +-- .../java/forge/game/CardTraitPredicates.java | 4 +-- forge-game/src/main/java/forge/game/Game.java | 2 +- .../src/main/java/forge/game/GameFormat.java | 6 ++--- .../java/forge/game/GameObjectPredicates.java | 4 +-- .../ability/effects/ChangeTargetsEffect.java | 3 +-- .../ability/effects/ChooseCardNameEffect.java | 3 +-- .../ability/effects/CopyPermanentEffect.java | 2 +- .../game/ability/effects/PlayEffect.java | 2 +- .../effects/PlayLandVariantEffect.java | 2 +- .../java/forge/game/card/CardFactoryUtil.java | 2 +- .../main/java/forge/game/card/CardLists.java | 4 +-- .../java/forge/game/card/CardPredicates.java | 5 ++-- .../forge/game/combat/AttackConstraints.java | 4 +-- .../game/combat/AttackRestrictionType.java | 4 +-- .../forge/game/mana/ManaCostBeingPaid.java | 2 +- .../src/main/java/forge/game/phase/Untap.java | 2 +- .../forge/game/player/PlayerCollection.java | 2 +- .../forge/game/player/PlayerController.java | 2 +- .../forge/game/player/PlayerPredicates.java | 3 +-- .../spellability/SpellAbilityPredicates.java | 4 +-- .../spellability/SpellAbilityRestriction.java | 2 +- .../main/java/forge/game/zone/MagicStack.java | 6 ++--- .../main/java/forge/game/zone/PlayerZone.java | 6 ++--- .../src/main/java/forge/game/zone/Zone.java | 2 +- .../java/forge/deckchooser/FDeckChooser.java | 2 +- .../java/forge/gui/ImportSourceAnalyzer.java | 3 +-- .../java/forge/itemmanager/ItemManager.java | 2 +- .../filters/AdvancedSearchFilter.java | 2 +- .../itemmanager/filters/CardCMCFilter.java | 3 +-- .../filters/CardCMCRangeFilter.java | 4 +-- .../itemmanager/filters/CardColorFilter.java | 4 +-- .../itemmanager/filters/CardFoilFilter.java | 4 +-- .../itemmanager/filters/CardFormatFilter.java | 3 +-- .../itemmanager/filters/CardPowerFilter.java | 4 +-- .../itemmanager/filters/CardRatingFilter.java | 4 +-- .../itemmanager/filters/CardSearchFilter.java | 6 ++--- .../filters/CardToughnessFilter.java | 4 +-- .../itemmanager/filters/CardTypeFilter.java | 3 +-- .../itemmanager/filters/DeckColorFilter.java | 4 +-- .../itemmanager/filters/DeckFolderFilter.java | 3 +-- .../itemmanager/filters/DeckFormatFilter.java | 4 +-- .../itemmanager/filters/DeckSetFilter.java | 2 +- .../forge/itemmanager/filters/ItemFilter.java | 5 ++-- .../itemmanager/filters/TextSearchFilter.java | 3 +-- .../filters/TokenSearchFilter.java | 6 ++--- .../itemmanager/filters/ValueRangeFilter.java | 3 +-- .../deckeditor/controllers/CDeckgen.java | 4 +-- .../controllers/CEditorCommander.java | 2 +- .../deckeditor/controllers/CEditorQuest.java | 4 +-- .../controllers/CEditorVariant.java | 2 +- .../deckeditor/controllers/CStatistics.java | 3 +-- .../controllers/CStatisticsImporter.java | 2 +- .../java/forge/screens/home/PlayerPanel.java | 2 +- .../forge/card/CardDbCardMockTestCase.java | 3 +-- .../util/PlayerControllerForTests.java | 2 +- .../adventure/data/AdventureEventData.java | 4 +-- .../src/forge/adventure/util/CardUtil.java | 6 ++--- .../src/forge/deck/FDeckEditor.java | 4 +-- .../src/forge/itemmanager/ItemManager.java | 2 +- .../filters/AdvancedSearchFilter.java | 3 ++- .../itemmanager/filters/CardCMCFilter.java | 4 +-- .../itemmanager/filters/CardColorFilter.java | 4 +-- .../filters/CardColorlessCostFilter.java | 4 +-- .../itemmanager/filters/CardFormatFilter.java | 4 +-- .../itemmanager/filters/CardPowerFilter.java | 4 +-- .../itemmanager/filters/CardRarityFilter.java | 4 +-- .../itemmanager/filters/CardSearchFilter.java | 6 ++--- .../filters/CardToughnessFilter.java | 4 +-- .../itemmanager/filters/CardTypeFilter.java | 3 +-- .../itemmanager/filters/DeckColorFilter.java | 4 +-- .../itemmanager/filters/DeckFolderFilter.java | 3 +-- .../itemmanager/filters/DeckFormatFilter.java | 4 +-- .../forge/itemmanager/filters/ItemFilter.java | 6 ++--- .../itemmanager/filters/TextSearchFilter.java | 3 ++- .../itemmanager/filters/ValueRangeFilter.java | 3 ++- .../planarconquest/ConquestAEtherScreen.java | 4 +-- .../ConquestCollectionScreen.java | 2 +- .../ConquestCommandersScreen.java | 6 ++--- .../src/forge/toolbox/ListChooser.java | 2 +- .../java/forge/deck/ColorDeckGenerator.java | 3 +-- .../forge/deck/CommanderDeckGenerator.java | 3 +-- .../src/main/java/forge/deck/DeckProxy.java | 6 ++--- .../src/main/java/forge/deck/DeckgenUtil.java | 2 +- .../forge/gamemodes/limited/BoosterDraft.java | 2 +- .../limited/CardThemedDeckBuilder.java | 8 +++--- .../gamemodes/limited/LimitedDeckBuilder.java | 4 +-- .../gamemodes/limited/ThemedChaosDraft.java | 7 +++-- .../match/input/InputSelectTargets.java | 4 +-- .../planarconquest/ConquestRegion.java | 5 ++-- .../planarconquest/ConquestUtil.java | 10 +++---- .../forge/gamemodes/quest/BoosterUtils.java | 2 +- .../quest/QuestChallengeGenerator.java | 5 ++-- .../gamemodes/quest/QuestRewardCard.java | 3 +-- .../quest/QuestRewardCardChooser.java | 3 +-- .../quest/QuestRewardCardFiltered.java | 3 +-- .../forge/gamemodes/quest/QuestUtilCards.java | 6 ++--- .../gamemodes/quest/data/GameFormatQuest.java | 4 +-- .../java/forge/gui/card/CardScriptParser.java | 2 +- .../forge/itemmanager/AdvancedSearch.java | 2 +- .../forge/itemmanager/BooleanExpression.java | 3 +-- .../java/forge/itemmanager/SFilterUtil.java | 5 ++-- .../forge/itemmanager/SItemManagerUtil.java | 3 +-- .../src/main/java/forge/model/CardBlock.java | 3 +-- .../src/main/java/forge/model/MetaSet.java | 2 +- .../forge/player/PlayerControllerHuman.java | 2 +- .../java/forge/player/TargetSelection.java | 2 +- 148 files changed, 272 insertions(+), 306 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiAttackController.java b/forge-ai/src/main/java/forge/ai/AiAttackController.java index 509c86c0f59..44cb8791eae 100644 --- a/forge-ai/src/main/java/forge/ai/AiAttackController.java +++ b/forge-ai/src/main/java/forge/ai/AiAttackController.java @@ -17,7 +17,6 @@ */ package forge.ai; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.ai.ability.AnimateAi; import forge.game.GameEntity; @@ -46,6 +45,7 @@ import org.apache.commons.lang3.tuple.Pair; import java.util.*; +import java.util.function.Predicate; /** diff --git a/forge-ai/src/main/java/forge/ai/AiBlockController.java b/forge-ai/src/main/java/forge/ai/AiBlockController.java index d8e1727a4de..47cddedd69a 100644 --- a/forge-ai/src/main/java/forge/ai/AiBlockController.java +++ b/forge-ai/src/main/java/forge/ai/AiBlockController.java @@ -18,8 +18,7 @@ package forge.ai; import java.util.*; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.card.CardStateName; import forge.game.GameEntity; diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index 5e5480051f7..f2b27f612ce 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -18,7 +18,6 @@ package forge.ai; import com.esotericsoftware.minlog.Log; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.ai.ability.ChangeZoneAi; import forge.ai.ability.LearnAi; @@ -63,6 +62,7 @@ import io.sentry.Sentry; import java.util.*; +import java.util.function.Predicate; /** *

diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index 55ed7d61b27..bba4fd5265e 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -18,6 +18,7 @@ package forge.ai; import java.util.*; +import java.util.function.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; @@ -28,8 +29,6 @@ import forge.util.*; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Predicate; - import forge.ai.AiCardMemory.MemorySet; import forge.ai.ability.ProtectAi; import forge.ai.ability.TokenAi; diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index 4460d808f65..cf4b579281d 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -2,6 +2,7 @@ import java.util.*; import java.util.Map.Entry; +import java.util.function.Predicate; import com.google.common.base.Function; import forge.ai.simulation.GameStateEvaluator; @@ -12,7 +13,6 @@ import org.apache.commons.lang3.tuple.MutablePair; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import com.google.common.collect.Maps; diff --git a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java index 48e32404372..9a8fc19f67b 100644 --- a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java +++ b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java @@ -1,6 +1,5 @@ package forge.ai; -import com.google.common.base.Predicate; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -50,6 +49,7 @@ import java.security.InvalidParameterException; import java.util.*; +import java.util.function.Predicate; /** diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java index b1d2cf734c0..c13850399cb 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java @@ -19,8 +19,7 @@ import java.util.List; import java.util.Map; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java index 627ce556ec4..3d0beff19a4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java @@ -2,8 +2,7 @@ import java.util.List; import java.util.Map; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java index bb47c8f0c8e..51948face98 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import com.google.common.base.Predicate; - import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCombat; import forge.ai.ComputerUtilCost; @@ -19,6 +17,8 @@ import forge.game.zone.ZoneType; import forge.util.MyRandom; +import java.util.function.Predicate; + public class DamageAllAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player ai, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java index e63aa2441e6..c685c5fb6d0 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java @@ -1,6 +1,5 @@ package forge.ai.ability; -import com.google.common.base.Predicate; import forge.ai.*; import forge.card.MagicColor; import forge.game.card.Card; @@ -17,6 +16,8 @@ import forge.game.zone.ZoneType; import forge.util.Predicates; +import java.util.function.Predicate; + public class DestroyAllAi extends SpellAbilityAi { private static final Predicate predicate = c -> !(c.hasKeyword(Keyword.INDESTRUCTIBLE) || c.getCounters(CounterEnumType.SHIELD) > 0 || c.hasSVar("SacMe")); diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java b/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java index 6ef7ade01cd..e45d692b43b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java @@ -1,8 +1,7 @@ package forge.ai.ability; import java.util.List; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.ai.AiAttackController; import forge.ai.ComputerUtil; diff --git a/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java b/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java index bb10b8df2a6..e742e62ee09 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java +++ b/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java @@ -1,8 +1,7 @@ package forge.ai.ability; import java.util.List; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.ai.AiAttackController; import forge.ai.ComputerUtil; diff --git a/forge-core/src/main/java/forge/StaticData.java b/forge-core/src/main/java/forge/StaticData.java index adfa2544cc5..97dff8e0ab5 100644 --- a/forge-core/src/main/java/forge/StaticData.java +++ b/forge-core/src/main/java/forge/StaticData.java @@ -1,6 +1,5 @@ package forge; -import com.google.common.base.Predicate; import forge.card.CardDb; import forge.card.CardEdition; import forge.card.CardRules; @@ -16,6 +15,7 @@ import java.io.File; import java.util.*; +import java.util.function.Predicate; /** diff --git a/forge-core/src/main/java/forge/card/CardDb.java b/forge-core/src/main/java/forge/card/CardDb.java index 84383d86adf..b04f7bc9268 100644 --- a/forge-core/src/main/java/forge/card/CardDb.java +++ b/forge-core/src/main/java/forge/card/CardDb.java @@ -17,7 +17,6 @@ */ package forge.card; -import com.google.common.base.Predicate; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -37,6 +36,7 @@ import java.util.*; import java.util.Map.Entry; +import java.util.function.Predicate; import java.util.stream.Collectors; public final class CardDb implements ICardDatabase, IDeckGenPool { @@ -1062,7 +1062,7 @@ public PredicateExistsInSets(final List wantSets) { } @Override - public boolean apply(final PaperCard subject) { + public boolean test(final PaperCard subject) { for (PaperCard c : getAllCards(subject.getName())) { if (sets.contains(c.getEdition())) { return true; @@ -1085,7 +1085,7 @@ public PredicateLegalInSets(final List allowedSets){ this.sets.addAll(allowedSets); } @Override - public boolean apply(final PaperCard card){ + public boolean test(final PaperCard card){ if (card == null) return false; return this.sets.contains(card.getEdition()); } @@ -1110,7 +1110,7 @@ public PredicatePrintedAtRarity(CardRarity rarity) { } @Override - public boolean apply(final PaperCard subject) { + public boolean test(final PaperCard subject) { return matchingCards.contains(subject.getName()); } } diff --git a/forge-core/src/main/java/forge/card/CardEdition.java b/forge-core/src/main/java/forge/card/CardEdition.java index 2188ca55e1e..55bf06333ab 100644 --- a/forge-core/src/main/java/forge/card/CardEdition.java +++ b/forge-core/src/main/java/forge/card/CardEdition.java @@ -17,7 +17,6 @@ */ package forge.card; -import com.google.common.base.Predicate; import com.google.common.collect.*; import forge.StaticData; import forge.card.CardDb.CardArtPreference; @@ -38,6 +37,7 @@ import java.text.SimpleDateFormat; import java.util.*; import java.util.Map.Entry; +import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -891,7 +891,7 @@ public static class Predicates { private static class CanMakeBooster implements Predicate { @Override - public boolean apply(final CardEdition subject) { + public boolean test(final CardEdition subject) { return subject.hasBoosterTemplate(); } } @@ -919,7 +919,7 @@ public static CardEdition getPreferredArtEditionWithAllBasicLands() { public static final Predicate HAS_TOURNAMENT_PACK = new CanMakeStarter(); private static class CanMakeStarter implements Predicate { @Override - public boolean apply(final CardEdition subject) { + public boolean test(final CardEdition subject) { return StaticData.instance().getTournamentPacks().contains(subject.getCode()); } } @@ -927,7 +927,7 @@ public boolean apply(final CardEdition subject) { public static final Predicate HAS_FAT_PACK = new CanMakeFatPack(); private static class CanMakeFatPack implements Predicate { @Override - public boolean apply(final CardEdition subject) { + public boolean test(final CardEdition subject) { return subject.getFatPackCount() > 0; } } @@ -935,7 +935,7 @@ public boolean apply(final CardEdition subject) { public static final Predicate HAS_BOOSTER_BOX = new CanMakeBoosterBox(); private static class CanMakeBoosterBox implements Predicate { @Override - public boolean apply(final CardEdition subject) { + public boolean test(final CardEdition subject) { return subject.getBoosterBoxCount() > 0; } } diff --git a/forge-core/src/main/java/forge/card/CardFacePredicates.java b/forge-core/src/main/java/forge/card/CardFacePredicates.java index f612a8e7088..a23339ca33d 100644 --- a/forge-core/src/main/java/forge/card/CardFacePredicates.java +++ b/forge-core/src/main/java/forge/card/CardFacePredicates.java @@ -1,9 +1,9 @@ package forge.card; -import com.google.common.base.Predicate; - import forge.card.mana.ManaCost; +import java.util.function.Predicate; + public final class CardFacePredicates { @@ -12,7 +12,7 @@ private static class PredicateCoreType implements Predicate { private final boolean shouldBeEqual; @Override - public boolean apply(final ICardFace face) { + public boolean test(final ICardFace face) { if (null == face) { return false; } @@ -30,7 +30,7 @@ private static class PredicateSuperType implements Predicate { private final boolean shouldBeEqual; @Override - public boolean apply(final ICardFace face) { + public boolean test(final ICardFace face) { return this.shouldBeEqual == face.getType().hasSupertype(this.operand); } @@ -81,7 +81,7 @@ public ValidPredicate(final String valid) { } @Override - public boolean apply(ICardFace input) { + public boolean test(ICardFace input) { String[] k = valid.split("\\.", 2); if ("Card".equals(k[0])) { diff --git a/forge-core/src/main/java/forge/card/CardRulesPredicates.java b/forge-core/src/main/java/forge/card/CardRulesPredicates.java index 6404d3ed0ae..7492ba47fd0 100644 --- a/forge-core/src/main/java/forge/card/CardRulesPredicates.java +++ b/forge-core/src/main/java/forge/card/CardRulesPredicates.java @@ -1,12 +1,11 @@ package forge.card; import java.util.*; +import java.util.function.Predicate; import forge.util.*; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Predicate; - /** * Filtering conditions specific for CardRules class, defined here along with * some presets. @@ -342,7 +341,7 @@ protected boolean checkType(ICardFace face) { } @Override - public boolean apply(final CardRules card) { + public boolean test(final CardRules card) { boolean shouldContain; switch (this.field) { case NAME: @@ -402,7 +401,7 @@ public LeafColor(final LeafColor.ColorOperator operator, final byte thatColor) { } @Override - public boolean apply(final CardRules subject) { + public boolean test(final CardRules subject) { if (null == subject) { return false; } @@ -441,7 +440,7 @@ public LeafNumber(final LeafNumber.CardField field, final ComparableOp op, final } @Override - public boolean apply(final CardRules card) { + public boolean test(final CardRules card) { int value; switch (this.field) { case CMC: @@ -484,7 +483,7 @@ private static class PredicateCoreType implements Predicate { private final boolean shouldBeEqual; @Override - public boolean apply(final CardRules card) { + public boolean test(final CardRules card) { if (null == card) { return false; } @@ -502,7 +501,7 @@ private static class PredicateSuperType implements Predicate { private final boolean shouldBeEqual; @Override - public boolean apply(final CardRules card) { + public boolean test(final CardRules card) { return this.shouldBeEqual == card.getType().hasSupertype(this.operand); } @@ -520,7 +519,7 @@ public PredicateSplitType(final CardSplitType type) { } @Override - public boolean apply(final CardRules subject) { + public boolean test(final CardRules subject) { return subject.getSplitType() == cst; } } diff --git a/forge-core/src/main/java/forge/card/CardType.java b/forge-core/src/main/java/forge/card/CardType.java index 9adb0fb9c47..9c4f30b23b6 100644 --- a/forge-core/src/main/java/forge/card/CardType.java +++ b/forge-core/src/main/java/forge/card/CardType.java @@ -18,13 +18,13 @@ package forge.card; import java.util.*; +import java.util.function.Predicate; import forge.util.Iterables; import org.apache.commons.lang3.EnumUtils; import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Predicate; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.google.common.collect.ImmutableList; diff --git a/forge-core/src/main/java/forge/card/DeckHints.java b/forge-core/src/main/java/forge/card/DeckHints.java index 67b75e9b8ea..50d39c533be 100644 --- a/forge-core/src/main/java/forge/card/DeckHints.java +++ b/forge-core/src/main/java/forge/card/DeckHints.java @@ -4,13 +4,13 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Predicate; import forge.util.Iterables; import forge.util.Predicates; import org.apache.commons.lang3.tuple.Pair; import com.google.common.base.Function; -import com.google.common.base.Predicate; import forge.StaticData; import forge.item.PaperCard; @@ -218,11 +218,11 @@ public static Predicate rulesWithTokens(final Predicate pr tdb = null; } return card -> { - if (predicate.apply(card)) { + if (predicate.test(card)) { return true; } for (String tok : card.getTokens()) { - if (tdb != null && tdb.containsRule(tok) && predicate.apply(tdb.getToken(tok).getRules())) { + if (tdb != null && tdb.containsRule(tok) && predicate.test(tdb.getToken(tok).getRules())) { return true; } } diff --git a/forge-core/src/main/java/forge/card/ICardDatabase.java b/forge-core/src/main/java/forge/card/ICardDatabase.java index 4618e78f83f..52b86868627 100644 --- a/forge-core/src/main/java/forge/card/ICardDatabase.java +++ b/forge-core/src/main/java/forge/card/ICardDatabase.java @@ -1,12 +1,12 @@ package forge.card; -import com.google.common.base.Predicate; import forge.card.CardDb.CardArtPreference; import forge.item.PaperCard; import java.util.Collection; import java.util.Date; import java.util.List; +import java.util.function.Predicate; public interface ICardDatabase extends Iterable { /** diff --git a/forge-core/src/main/java/forge/deck/CardPool.java b/forge-core/src/main/java/forge/deck/CardPool.java index 0846ae7ed49..01772016527 100644 --- a/forge-core/src/main/java/forge/deck/CardPool.java +++ b/forge-core/src/main/java/forge/deck/CardPool.java @@ -17,7 +17,6 @@ */ package forge.deck; -import com.google.common.base.Predicate; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimaps; @@ -35,6 +34,7 @@ import java.util.*; import java.util.Map.Entry; +import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -459,7 +459,7 @@ public String toCardList(String separator) { public CardPool getFilteredPool(Predicate predicate) { CardPool filteredPool = new CardPool(); for (PaperCard c : this.items.keySet()) { - if (predicate.apply(c)) + if (predicate.test(c)) filteredPool.add(c, this.items.get(c)); } return filteredPool; @@ -475,7 +475,7 @@ public CardPool getFilteredPoolWithCardsCount(Predicate predicate) { for (Entry entry : this.items.entrySet()) { PaperCard pc = entry.getKey(); int count = entry.getValue(); - if (predicate.apply(pc)) + if (predicate.test(pc)) filteredPool.add(pc, count); } return filteredPool; diff --git a/forge-core/src/main/java/forge/deck/DeckFormat.java b/forge-core/src/main/java/forge/deck/DeckFormat.java index ddd54ae90da..89fab648d00 100644 --- a/forge-core/src/main/java/forge/deck/DeckFormat.java +++ b/forge-core/src/main/java/forge/deck/DeckFormat.java @@ -17,7 +17,6 @@ */ package forge.deck; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; import forge.StaticData; import forge.card.CardRules; @@ -42,6 +41,7 @@ import java.util.List; import java.util.Map.Entry; import java.util.Set; +import java.util.function.Predicate; /** * GameType is an enum to determine the type of current game. :) @@ -60,14 +60,14 @@ public String getAttractionDeckConformanceProblem(Deck deck) { } }, Commander ( Range.is(99), Range.between(0, 10), 1, null, - card -> StaticData.instance().getCommanderPredicate().apply(card) + card -> StaticData.instance().getCommanderPredicate().test(card) ), Oathbreaker ( Range.is(58), Range.between(0, 10), 1, null, - card -> StaticData.instance().getOathbreakerPredicate().apply(card) + card -> StaticData.instance().getOathbreakerPredicate().test(card) ), Pauper ( Range.is(60), Range.between(0, 10), 1), Brawl ( Range.is(59), Range.between(0, 15), 1, null, - card -> StaticData.instance().getBrawlPredicate().apply(card) + card -> StaticData.instance().getBrawlPredicate().test(card) ), TinyLeaders ( Range.is(49), Range.between(0, 10), 1, new Predicate() { private final Set bannedCards = ImmutableSet.of( @@ -77,7 +77,7 @@ public String getAttractionDeckConformanceProblem(Deck deck) { "Timmerian Fiends", "Tolarian Academy", "Umezawa's Jitte", "Vampiric Tutor", "Wheel of Fortune", "Yawgmoth's Will"); @Override - public boolean apply(CardRules rules) { + public boolean test(CardRules rules) { // Check for split cards explicitly, as using rules.getManaCost().getCMC() // will return the sum of the costs, which is not what we want. if (rules.getMainPart().getManaCost().getCMC() > 3) { @@ -314,7 +314,7 @@ public String getDeckConformanceProblem(Deck deck) { if (cardPoolFilter != null) { final List erroneousCI = new ArrayList<>(); for (final Entry cp : deck.getAllCardsInASinglePool()) { - if (!cardPoolFilter.apply(cp.getKey().getRules())) { + if (!cardPoolFilter.test(cp.getKey().getRules())) { erroneousCI.add(cp.getKey()); } } @@ -446,7 +446,7 @@ public IDeckGenPool getCardPool(IDeckGenPool basePool) { } DeckGenPool filteredPool = new DeckGenPool(); for (PaperCard pc : basePool.getAllCards()) { - if (paperCardPoolFilter.apply(pc)) { + if (paperCardPoolFilter.test(pc)) { filteredPool.add(pc); } } @@ -454,7 +454,7 @@ public IDeckGenPool getCardPool(IDeckGenPool basePool) { } DeckGenPool filteredPool = new DeckGenPool(); for (PaperCard pc : basePool.getAllCards()) { - if (cardPoolFilter.apply(pc.getRules())) { + if (cardPoolFilter.test(pc.getRules())) { filteredPool.add(pc); } } @@ -470,13 +470,13 @@ public boolean isLegalCard(PaperCard pc) { if (paperCardPoolFilter == null) { return true; } - return paperCardPoolFilter.apply(pc); + return paperCardPoolFilter.test(pc); } - return cardPoolFilter.apply(pc.getRules()); + return cardPoolFilter.test(pc.getRules()); } public boolean isLegalCommander(CardRules rules) { - if (cardPoolFilter != null && !cardPoolFilter.apply(rules)) { + if (cardPoolFilter != null && !cardPoolFilter.test(rules)) { return false; } if (this.equals(DeckFormat.Oathbreaker)) { @@ -501,14 +501,14 @@ public Predicate hasLegalCardsPredicate(boolean enforceDeckLegality) { return true; if (cardPoolFilter != null) { for (final Entry cp : deck.getAllCardsInASinglePool()) { - if (!cardPoolFilter.apply(cp.getKey().getRules())) { + if (!cardPoolFilter.test(cp.getKey().getRules())) { return false; } } } if (paperCardPoolFilter != null) { for (final Entry cp : deck.getAllCardsInASinglePool()) { - if (!paperCardPoolFilter.apply(cp.getKey())) { + if (!paperCardPoolFilter.test(cp.getKey())) { System.err.println( "Excluding deck: '" + deck.toString() + "' Reason: '" + cp.getKey() + "' is not legal." diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java b/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java index 1e64d70d1f6..e45fa4efb00 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java @@ -2,8 +2,7 @@ import java.util.HashMap; import java.util.Map; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.item.IPaperCard; import forge.item.PaperCard; diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGenerator2Color.java b/forge-core/src/main/java/forge/deck/generation/DeckGenerator2Color.java index 26841e098d5..70270043f18 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGenerator2Color.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGenerator2Color.java @@ -19,10 +19,10 @@ import java.util.Arrays; import java.util.List; +import java.util.function.Predicate; import org.apache.commons.lang3.tuple.ImmutablePair; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.card.ColorSet; diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGenerator3Color.java b/forge-core/src/main/java/forge/deck/generation/DeckGenerator3Color.java index 1f295f8b8ae..cf7d0facc01 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGenerator3Color.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGenerator3Color.java @@ -18,10 +18,10 @@ package forge.deck.generation; import java.util.List; +import java.util.function.Predicate; import org.apache.commons.lang3.tuple.ImmutablePair; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.card.ColorSet; diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGenerator4Color.java b/forge-core/src/main/java/forge/deck/generation/DeckGenerator4Color.java index efa8b9f22a0..99e2c964540 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGenerator4Color.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGenerator4Color.java @@ -18,10 +18,10 @@ package forge.deck.generation; import java.util.List; +import java.util.function.Predicate; import org.apache.commons.lang3.tuple.ImmutablePair; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.card.ColorSet; diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGenerator5Color.java b/forge-core/src/main/java/forge/deck/generation/DeckGenerator5Color.java index 505d31f4e88..7c3c10a83b9 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGenerator5Color.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGenerator5Color.java @@ -18,10 +18,10 @@ package forge.deck.generation; import java.util.List; +import java.util.function.Predicate; import org.apache.commons.lang3.tuple.ImmutablePair; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.card.ColorSet; diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index d36b4f8338b..3b8fd8cab97 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -17,7 +17,6 @@ */ package forge.deck.generation; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.StaticData; import forge.card.*; @@ -31,6 +30,7 @@ import java.util.*; import java.util.Map.Entry; +import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -342,7 +342,7 @@ public MatchColorIdentity(ColorSet color) { } @Override - public boolean apply(CardRules subject) { + public boolean test(CardRules subject) { ManaCost mc = subject.getManaCost(); return !mc.isPureGeneric() && allowedColor.containsAllColorsFrom(subject.getColorIdentity().getColor()); //return mc.canBePaidWithAvaliable(allowedColor); @@ -360,7 +360,7 @@ public FilterCMC(int from, int to) { } @Override - public boolean apply(CardRules c) { + public boolean test(CardRules c) { ManaCost mc = c.getManaCost(); int cmc = mc.getCMC(); return cmc >= min && cmc <= max && !mc.isNoCost(); diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorMonoColor.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorMonoColor.java index 4abc1aa9dde..fa5be73b7f1 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorMonoColor.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorMonoColor.java @@ -18,10 +18,10 @@ package forge.deck.generation; import java.util.List; +import java.util.function.Predicate; import org.apache.commons.lang3.tuple.ImmutablePair; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.card.ColorSet; diff --git a/forge-core/src/main/java/forge/deck/generation/IDeckGenPool.java b/forge-core/src/main/java/forge/deck/generation/IDeckGenPool.java index cf1d3b3cef7..ab35517b45e 100644 --- a/forge-core/src/main/java/forge/deck/generation/IDeckGenPool.java +++ b/forge-core/src/main/java/forge/deck/generation/IDeckGenPool.java @@ -1,9 +1,9 @@ package forge.deck.generation; -import com.google.common.base.Predicate; - import forge.item.PaperCard; +import java.util.function.Predicate; + public interface IDeckGenPool { PaperCard getCard(String name); PaperCard getCard(String name, String edition); diff --git a/forge-core/src/main/java/forge/item/IPaperCard.java b/forge-core/src/main/java/forge/item/IPaperCard.java index 99780f5bb6d..c8dc407f148 100644 --- a/forge-core/src/main/java/forge/item/IPaperCard.java +++ b/forge-core/src/main/java/forge/item/IPaperCard.java @@ -1,6 +1,5 @@ package forge.item; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.card.CardRarity; import forge.card.CardRules; @@ -15,6 +14,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.function.Predicate; public interface IPaperCard extends InventoryItem, Serializable { @@ -82,7 +82,7 @@ private PredicateColor(final byte color, final boolean noColor, final boolean wa } @Override - public boolean apply(final PaperCard card) { + public boolean test(final PaperCard card) { boolean colorFound = false; if (noColor) { return card.getRules().getColor().isColorless() == shouldBeEqual; @@ -111,7 +111,7 @@ private static final class PredicateRarity implements Predicate { private final boolean shouldBeEqual; @Override - public boolean apply(final PaperCard card) { + public boolean test(final PaperCard card) { return (card.getRarity() == this.operand) == this.shouldBeEqual; } @@ -126,7 +126,7 @@ private static final class PredicateSets implements Predicate { private final boolean mustContain; @Override - public boolean apply(final PaperCard card) { + public boolean test(final PaperCard card) { return this.sets.contains(card.getEdition()) == this.mustContain; } @@ -140,7 +140,7 @@ private static final class PredicateName extends PredicateString { private final String operand; @Override - public boolean apply(final PaperCard card) { + public boolean test(final PaperCard card) { return this.op(card.getName(), this.operand); } @@ -154,7 +154,7 @@ private static final class PredicateNames extends PredicateString { private final List operand; @Override - public boolean apply(final PaperCard card) { + public boolean test(final PaperCard card) { final String cardName = card.getName(); for (final String element : this.operand) { if (this.op(cardName, element)) { @@ -174,7 +174,7 @@ private static final class PredicateCards extends PredicateCard { private final List operand; @Override - public boolean apply(final PaperCard card) { + public boolean test(final PaperCard card) { for (final PaperCard element : this.operand) { if (this.op(card, element)) { return true; diff --git a/forge-core/src/main/java/forge/item/ItemPredicate.java b/forge-core/src/main/java/forge/item/ItemPredicate.java index 1c33a387025..29169cbfd24 100644 --- a/forge-core/src/main/java/forge/item/ItemPredicate.java +++ b/forge-core/src/main/java/forge/item/ItemPredicate.java @@ -1,8 +1,9 @@ package forge.item; -import com.google.common.base.Predicate; import forge.util.Predicates; +import java.util.function.Predicate; + /** * Filtering conditions for miscellaneous InventoryItems. */ diff --git a/forge-core/src/main/java/forge/item/SealedProduct.java b/forge-core/src/main/java/forge/item/SealedProduct.java index f6eb186c50a..c63c97cf3dc 100644 --- a/forge-core/src/main/java/forge/item/SealedProduct.java +++ b/forge-core/src/main/java/forge/item/SealedProduct.java @@ -18,7 +18,6 @@ package forge.item; -import com.google.common.base.Predicate; import forge.StaticData; import forge.card.CardRulesPredicates; import forge.item.generation.BoosterGenerator; @@ -28,6 +27,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.function.Predicate; public abstract class SealedProduct implements InventoryItemFromSet { diff --git a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java index 6a22065e421..3f8d3fa1e48 100644 --- a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java +++ b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java @@ -17,7 +17,6 @@ */ package forge.item.generation; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import forge.StaticData; @@ -30,6 +29,7 @@ import org.apache.commons.lang3.tuple.Pair; import java.util.*; +import java.util.function.Predicate; /** *

@@ -529,7 +529,7 @@ public static void replaceCard(List booster, PaperCard toAdd) { PaperCard toReplace = null; // Find first card in booster that matches the rarity for (PaperCard card : booster) { - if (rarityPredicate.apply(card)) { + if (rarityPredicate.test(card)) { toReplace = card; break; } diff --git a/forge-core/src/main/java/forge/item/generation/UnOpenedProduct.java b/forge-core/src/main/java/forge/item/generation/UnOpenedProduct.java index 5444bb011ab..f7062a8b3da 100644 --- a/forge-core/src/main/java/forge/item/generation/UnOpenedProduct.java +++ b/forge-core/src/main/java/forge/item/generation/UnOpenedProduct.java @@ -1,6 +1,5 @@ package forge.item.generation; -import com.google.common.base.Predicate; import forge.StaticData; import forge.card.PrintSheet; import forge.item.PaperCard; @@ -13,6 +12,7 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +import java.util.function.Predicate; public class UnOpenedProduct implements IUnOpenedProduct { diff --git a/forge-core/src/main/java/forge/token/ITokenDatabase.java b/forge-core/src/main/java/forge/token/ITokenDatabase.java index 3973250f24f..41422bb5497 100644 --- a/forge-core/src/main/java/forge/token/ITokenDatabase.java +++ b/forge-core/src/main/java/forge/token/ITokenDatabase.java @@ -1,12 +1,12 @@ package forge.token; -import com.google.common.base.Predicate; import forge.card.CardDb; import forge.item.PaperToken; import java.util.Collection; import java.util.Date; import java.util.List; +import java.util.function.Predicate; public interface ITokenDatabase extends Iterable { PaperToken getToken(String tokenName); diff --git a/forge-core/src/main/java/forge/token/TokenDb.java b/forge-core/src/main/java/forge/token/TokenDb.java index 176d720e40c..0ca8b826fc0 100644 --- a/forge-core/src/main/java/forge/token/TokenDb.java +++ b/forge-core/src/main/java/forge/token/TokenDb.java @@ -1,6 +1,5 @@ package forge.token; -import com.google.common.base.Predicate; import com.google.common.collect.Maps; import forge.card.CardDb; import forge.card.CardEdition; @@ -8,6 +7,7 @@ import forge.item.PaperToken; import java.util.*; +import java.util.function.Predicate; public class TokenDb implements ITokenDatabase { // Expected naming convention of scripts diff --git a/forge-core/src/main/java/forge/util/ItemPool.java b/forge-core/src/main/java/forge/util/ItemPool.java index ca60cfb0d89..669663ad053 100644 --- a/forge-core/src/main/java/forge/util/ItemPool.java +++ b/forge-core/src/main/java/forge/util/ItemPool.java @@ -26,8 +26,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import com.google.common.collect.Maps; import forge.item.InventoryItem; @@ -117,7 +116,7 @@ public final int countAll() { public int countAll(Predicate condition){ int count = 0; - for (Integer v : Maps.filterKeys(this.items, condition).values()) + for (Integer v : Maps.filterKeys(this.items, condition::test).values()) count += v; return count; @@ -126,7 +125,7 @@ public int countAll(Predicate condition){ @SuppressWarnings("unchecked") public final int countAll(Predicate condition, Class cls) { int count = 0; - Map matchingKeys = Maps.filterKeys(this.items, item -> cls.isInstance(item) && (condition.apply((U)item))); + Map matchingKeys = Maps.filterKeys(this.items, item -> cls.isInstance(item) && (condition.test((U)item))); for (Integer i : matchingKeys.values()) { count += i; } diff --git a/forge-core/src/main/java/forge/util/PredicateCard.java b/forge-core/src/main/java/forge/util/PredicateCard.java index f7ba508165c..611e091abbd 100644 --- a/forge-core/src/main/java/forge/util/PredicateCard.java +++ b/forge-core/src/main/java/forge/util/PredicateCard.java @@ -17,10 +17,10 @@ */ package forge.util; -import com.google.common.base.Predicate; - import forge.item.PaperCard; +import java.util.function.Predicate; + /** * Special predicate class to perform string operations. * @@ -74,8 +74,7 @@ public StringOp getOperator() { public static PredicateCard equals(final PaperCard what) { return new PredicateCard(StringOp.EQUALS) { - @Override - public boolean apply(PaperCard subject) { + public boolean test(PaperCard subject) { return op(subject, what); } }; diff --git a/forge-core/src/main/java/forge/util/PredicateString.java b/forge-core/src/main/java/forge/util/PredicateString.java index bb2dc5d67c6..79779932c58 100644 --- a/forge-core/src/main/java/forge/util/PredicateString.java +++ b/forge-core/src/main/java/forge/util/PredicateString.java @@ -19,7 +19,7 @@ import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Predicate; +import java.util.function.Predicate; /** * Special predicate class to perform string operations. @@ -87,7 +87,7 @@ public StringOp getOperator() { public static PredicateString contains(final String what) { return new PredicateString(StringOp.CONTAINS) { @Override - public boolean apply(String subject) { + public boolean test(String subject) { return op(subject, what); } }; @@ -95,7 +95,7 @@ public boolean apply(String subject) { public static PredicateString containsIgnoreCase(final String what) { return new PredicateString(StringOp.CONTAINS_IC) { @Override - public boolean apply(String subject) { + public boolean test(String subject) { return op(subject, what); } }; @@ -103,7 +103,7 @@ public boolean apply(String subject) { public static PredicateString equals(final String what) { return new PredicateString(StringOp.EQUALS) { @Override - public boolean apply(String subject) { + public boolean test(String subject) { return op(subject, what); } }; diff --git a/forge-core/src/main/java/forge/util/storage/IStorage.java b/forge-core/src/main/java/forge/util/storage/IStorage.java index 2c50144dbb3..3818c8edfbb 100644 --- a/forge-core/src/main/java/forge/util/storage/IStorage.java +++ b/forge-core/src/main/java/forge/util/storage/IStorage.java @@ -18,8 +18,7 @@ package forge.util.storage; import java.util.Collection; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.util.IHasName; diff --git a/forge-core/src/main/java/forge/util/storage/StorageBase.java b/forge-core/src/main/java/forge/util/storage/StorageBase.java index 4dcc5fdc201..7de2ca73ccc 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageBase.java +++ b/forge-core/src/main/java/forge/util/storage/StorageBase.java @@ -17,13 +17,13 @@ */ package forge.util.storage; -import com.google.common.base.Predicate; import forge.util.IItemReader; import forge.util.Iterables; import java.io.File; import java.io.FilenameFilter; import java.util.*; +import java.util.function.Predicate; /** *

@@ -77,7 +77,7 @@ public int size() { @Override public T find(Predicate condition) { - return Iterables.tryFind(map.values(), condition).orNull(); + return Iterables.tryFind(map.values(), condition).orElse(null); } @Override diff --git a/forge-game/src/main/java/forge/game/CardTraitPredicates.java b/forge-game/src/main/java/forge/game/CardTraitPredicates.java index 48f100c0634..ed49109655e 100644 --- a/forge-game/src/main/java/forge/game/CardTraitPredicates.java +++ b/forge-game/src/main/java/forge/game/CardTraitPredicates.java @@ -1,10 +1,10 @@ package forge.game; -import com.google.common.base.Predicate; - import forge.game.card.Card; import forge.game.keyword.Keyword; +import java.util.function.Predicate; + public class CardTraitPredicates { public static final Predicate isHostCard(final Card host) { diff --git a/forge-game/src/main/java/forge/game/Game.java b/forge-game/src/main/java/forge/game/Game.java index fac5f4bcc33..17069ca8a7e 100644 --- a/forge-game/src/main/java/forge/game/Game.java +++ b/forge-game/src/main/java/forge/game/Game.java @@ -17,7 +17,6 @@ */ package forge.game; -import com.google.common.base.Predicate; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Lists; @@ -56,6 +55,7 @@ import org.apache.commons.lang3.tuple.Pair; import java.util.*; +import java.util.function.Predicate; /** * Represents the state of a single game, a new instance is created for each game. diff --git a/forge-game/src/main/java/forge/game/GameFormat.java b/forge-game/src/main/java/forge/game/GameFormat.java index 91f96576927..573b3fadb3e 100644 --- a/forge-game/src/main/java/forge/game/GameFormat.java +++ b/forge-game/src/main/java/forge/game/GameFormat.java @@ -17,7 +17,6 @@ */ package forge.game; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.StaticData; import forge.card.CardDb; @@ -40,6 +39,7 @@ import java.text.SimpleDateFormat; import java.util.*; import java.util.Map.Entry; +import java.util.function.Predicate; public class GameFormat implements Comparable { @@ -264,7 +264,7 @@ private String getPoolLegalityProblem(final CardPool allCards) { { final List erroneousCI = new ArrayList<>(); for (Entry poolEntry : allCards) { - if (!getFilterRules().apply(poolEntry.getKey())) { + if (!getFilterRules().test(poolEntry.getKey())) { erroneousCI.add(poolEntry.getKey()); } } @@ -612,7 +612,7 @@ public GameFormat getFormatOfDeck(Deck deck) { public Set getAllFormatsOfCard(PaperCard card) { Set result = new HashSet<>(); for (GameFormat gf : naturallyOrdered) { - if (gf.getFilterRules().apply(card)) { + if (gf.getFilterRules().test(card)) { result.add(gf); } } diff --git a/forge-game/src/main/java/forge/game/GameObjectPredicates.java b/forge-game/src/main/java/forge/game/GameObjectPredicates.java index d8ff6ef9426..5f56d993a1d 100644 --- a/forge-game/src/main/java/forge/game/GameObjectPredicates.java +++ b/forge-game/src/main/java/forge/game/GameObjectPredicates.java @@ -17,11 +17,11 @@ */ package forge.game; -import com.google.common.base.Predicate; - import forge.game.card.Card; import forge.game.player.Player; +import java.util.function.Predicate; + /** *

diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java index 6f3aaf8953a..d8a202fd944 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java @@ -2,13 +2,12 @@ import java.util.ArrayList; import java.util.List; +import java.util.function.Predicate; import forge.util.Iterables; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.base.Predicate; - import forge.game.GameEntity; import forge.game.GameObject; import forge.game.GameObjectPredicates; diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java index 424422c06cf..8151c8f05a4 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java @@ -1,8 +1,7 @@ package forge.game.ability.effects; import java.util.*; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.StaticData; import forge.card.CardFacePredicates; diff --git a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java index 9da59ae5868..7bc5d7ca722 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java @@ -2,13 +2,13 @@ import java.util.Arrays; import java.util.List; +import java.util.function.Predicate; import forge.card.GamePieceType; import forge.util.*; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.mutable.MutableBoolean; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.ImageKeys; diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java index 248524a7b0e..0d3e0c3b5a6 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java @@ -5,13 +5,13 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.function.Predicate; import forge.card.CardStateName; import forge.card.GamePieceType; import forge.util.*; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java index bf386ad2bf1..dbf3f8b3cb9 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java @@ -1,8 +1,8 @@ package forge.game.ability.effects; import java.util.List; +import java.util.function.Predicate; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.StaticData; diff --git a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java index 514dbf02d00..b595ef7ae2e 100644 --- a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java +++ b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java @@ -17,7 +17,6 @@ */ package forge.game.card; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -55,6 +54,7 @@ import java.util.*; import java.util.Map.Entry; +import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.IntStream; diff --git a/forge-game/src/main/java/forge/game/card/CardLists.java b/forge-game/src/main/java/forge/game/card/CardLists.java index b15185644d1..4c610b5daec 100644 --- a/forge-game/src/main/java/forge/game/card/CardLists.java +++ b/forge-game/src/main/java/forge/game/card/CardLists.java @@ -20,8 +20,8 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.function.Predicate; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.game.CardTraitBase; @@ -349,7 +349,7 @@ public static int count(Iterable cardList, Predicate filt) { int count = 0; for (Card c : cardList) { - if (filt.apply(c)) { + if (filt.test(c)) { count++; } } diff --git a/forge-game/src/main/java/forge/game/card/CardPredicates.java b/forge-game/src/main/java/forge/game/card/CardPredicates.java index a290776ea96..f8f202ffa64 100644 --- a/forge-game/src/main/java/forge/game/card/CardPredicates.java +++ b/forge-game/src/main/java/forge/game/card/CardPredicates.java @@ -18,8 +18,7 @@ package forge.game.card; import java.util.Comparator; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.game.CardTraitBase; import forge.game.GameEntity; @@ -288,7 +287,7 @@ public static Predicate castSA(final Predicate predSA) { if (c.getCastSA() == null) { return false; } - return predSA.apply(c.getCastSA()); + return predSA.test(c.getCastSA()); }; } 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 30591bde1c3..d9b8ca5a6b9 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackConstraints.java +++ b/forge-game/src/main/java/forge/game/combat/AttackConstraints.java @@ -7,12 +7,12 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.function.Predicate; import forge.util.Iterables; import forge.util.Predicates; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; @@ -392,7 +392,7 @@ private static List deepClone(final List original) { } private static Attack findFirst(final List reqs, final Predicate predicate) { for (final Attack req : reqs) { - if (predicate.apply(req.attacker)) { + if (predicate.test(req.attacker)) { return req; } } diff --git a/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java b/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java index 7826ace1114..9d85781054e 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java +++ b/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java @@ -1,12 +1,12 @@ package forge.game.combat; -import com.google.common.base.Predicate; - import forge.card.MagicColor; import forge.game.card.Card; import forge.game.card.CardPredicates; import forge.util.Predicates; +import java.util.function.Predicate; + public enum AttackRestrictionType { ONLY_ALONE, diff --git a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java index 2dd5f2265ec..4fddebd1e7b 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java +++ b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java @@ -23,11 +23,11 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.function.Predicate; import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import com.google.common.collect.Maps; diff --git a/forge-game/src/main/java/forge/game/phase/Untap.java b/forge-game/src/main/java/forge/game/phase/Untap.java index 6f3ac9b69ea..f8808f9ba1b 100644 --- a/forge-game/src/main/java/forge/game/phase/Untap.java +++ b/forge-game/src/main/java/forge/game/phase/Untap.java @@ -21,8 +21,8 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.function.Predicate; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import com.google.common.collect.Maps; diff --git a/forge-game/src/main/java/forge/game/player/PlayerCollection.java b/forge-game/src/main/java/forge/game/player/PlayerCollection.java index f2331b9ed42..9bf5da78ba4 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerCollection.java +++ b/forge-game/src/main/java/forge/game/player/PlayerCollection.java @@ -2,9 +2,9 @@ import java.util.Collections; import java.util.Comparator; +import java.util.function.Predicate; import com.google.common.base.Function; -import com.google.common.base.Predicate; import forge.game.card.CardCollection; import forge.game.zone.ZoneType; diff --git a/forge-game/src/main/java/forge/game/player/PlayerController.java b/forge-game/src/main/java/forge/game/player/PlayerController.java index 4be2feb911b..a8211374e20 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerController.java +++ b/forge-game/src/main/java/forge/game/player/PlayerController.java @@ -1,6 +1,5 @@ package forge.game.player; -import com.google.common.base.Predicate; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; @@ -38,6 +37,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.function.Predicate; /** * A prototype for player controller class diff --git a/forge-game/src/main/java/forge/game/player/PlayerPredicates.java b/forge-game/src/main/java/forge/game/player/PlayerPredicates.java index a852411bf1c..abf6e305c48 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerPredicates.java +++ b/forge-game/src/main/java/forge/game/player/PlayerPredicates.java @@ -1,8 +1,7 @@ package forge.game.player; import java.util.Comparator; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.game.CardTraitBase; import forge.game.GameEntity; diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityPredicates.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityPredicates.java index 7bf5d26e051..15dbbcdae5e 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityPredicates.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityPredicates.java @@ -1,13 +1,13 @@ package forge.game.spellability; -import com.google.common.base.Predicate; - import forge.game.CardTraitBase; import forge.game.CardTraitPredicates; import forge.game.ability.ApiType; import forge.game.card.Card; import forge.game.player.Player; +import java.util.function.Predicate; + public final class SpellAbilityPredicates extends CardTraitPredicates { public static Predicate isApi(final ApiType type) { return sa -> type.equals(sa.getApi()); diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java index 387bde38681..5078738ea84 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java @@ -19,8 +19,8 @@ import java.util.List; import java.util.Map; +import java.util.function.Predicate; -import com.google.common.base.Predicate; import com.google.common.collect.Sets; import forge.game.Game; diff --git a/forge-game/src/main/java/forge/game/zone/MagicStack.java b/forge-game/src/main/java/forge/game/zone/MagicStack.java index 576d928286d..ab1e6b65bed 100644 --- a/forge-game/src/main/java/forge/game/zone/MagicStack.java +++ b/forge-game/src/main/java/forge/game/zone/MagicStack.java @@ -18,7 +18,6 @@ package forge.game.zone; import com.esotericsoftware.minlog.Log; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -49,6 +48,7 @@ import java.util.*; import java.util.Map.Entry; import java.util.concurrent.LinkedBlockingDeque; +import java.util.function.Predicate; /** *

@@ -980,14 +980,14 @@ public final boolean hasSourceOnStack(final Card source, final Predicate * DefaultPlayerZone class. @@ -46,7 +46,7 @@ private static Predicate alienCardsActivationFilter(final Player who) { private final class OwnCardsActivationFilter implements Predicate { @Override - public boolean apply(final Card c) { + public boolean test(final Card c) { if (c.mayPlayerLook(c.getController())) { return true; } diff --git a/forge-game/src/main/java/forge/game/zone/Zone.java b/forge-game/src/main/java/forge/game/zone/Zone.java index ca6d1e21a52..1c3a0e0064a 100644 --- a/forge-game/src/main/java/forge/game/zone/Zone.java +++ b/forge-game/src/main/java/forge/game/zone/Zone.java @@ -23,8 +23,8 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.function.Predicate; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; diff --git a/forge-gui-desktop/src/main/java/forge/deckchooser/FDeckChooser.java b/forge-gui-desktop/src/main/java/forge/deckchooser/FDeckChooser.java index 1ae5b9de9c4..fb391dee463 100644 --- a/forge-gui-desktop/src/main/java/forge/deckchooser/FDeckChooser.java +++ b/forge-gui-desktop/src/main/java/forge/deckchooser/FDeckChooser.java @@ -1,6 +1,5 @@ package forge.deckchooser; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import forge.deck.*; import forge.game.GameFormat; @@ -31,6 +30,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.function.Predicate; @SuppressWarnings("serial") public class FDeckChooser extends JPanel implements IDecksComboBoxListener { diff --git a/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java b/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java index e320af070a2..441d634e0b1 100644 --- a/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java +++ b/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java @@ -22,13 +22,12 @@ import java.util.Locale; import java.util.Map; import java.util.TreeMap; +import java.util.function.Predicate; import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.base.Predicate; - import forge.card.CardEdition; import forge.item.IPaperCard; import forge.item.PaperCard; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java b/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java index b6138f20acb..666549e3ab2 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java @@ -17,7 +17,6 @@ */ package forge.itemmanager; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.gui.GuiUtils; import forge.gui.UiCommand; @@ -49,6 +48,7 @@ import java.util.List; import java.util.*; import java.util.Map.Entry; +import java.util.function.Predicate; /** * ItemManager. diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/AdvancedSearchFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/AdvancedSearchFilter.java index 4281c93f569..7133acabc92 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/AdvancedSearchFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/AdvancedSearchFilter.java @@ -5,6 +5,7 @@ import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.MouseEvent; +import java.util.function.Predicate; import javax.swing.JPanel; import javax.swing.JPopupMenu; @@ -14,7 +15,6 @@ import forge.util.Iterables; import org.apache.commons.lang3.ArrayUtils; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import forge.gui.GuiUtils; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java index 8bd8580db51..b00f1a27a28 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java @@ -2,11 +2,10 @@ import java.util.ArrayList; import java.util.List; +import java.util.function.Predicate; import javax.swing.JPanel; -import com.google.common.base.Predicate; - import forge.card.CardRules; import forge.item.PaperCard; import forge.itemmanager.ItemManager; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java index e13dead6667..7a6d01cfc09 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java @@ -1,13 +1,13 @@ package forge.itemmanager.filters; -import com.google.common.base.Predicate; - import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.util.Predicates; +import java.util.function.Predicate; + /** * TODO: Write javadoc for this type. * diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardColorFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardColorFilter.java index 526f71b5699..6026352a7f1 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardColorFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardColorFilter.java @@ -2,14 +2,14 @@ import javax.swing.JPanel; -import com.google.common.base.Predicate; - import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.itemmanager.SFilterUtil; import forge.itemmanager.SItemManagerUtil.StatTypes; import forge.itemmanager.SpellShopManager; +import java.util.function.Predicate; + public class CardColorFilter extends StatTypeFilter { public CardColorFilter(ItemManager itemManager0) { diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardFoilFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardFoilFilter.java index d37fc657918..a1bdb22201f 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardFoilFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardFoilFilter.java @@ -2,13 +2,13 @@ import javax.swing.JPanel; -import com.google.common.base.Predicate; - import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.itemmanager.SFilterUtil; import forge.itemmanager.SItemManagerUtil.StatTypes; +import java.util.function.Predicate; + public class CardFoilFilter extends StatTypeFilter { public CardFoilFilter(ItemManager itemManager0) { diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardFormatFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardFormatFilter.java index bbc48c1421b..a10499ca825 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardFormatFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardFormatFilter.java @@ -1,8 +1,7 @@ package forge.itemmanager.filters; import java.util.List; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.game.GameFormat; import forge.item.PaperCard; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java index bcf4a1409d6..8a2ed8c7f87 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java @@ -1,13 +1,13 @@ package forge.itemmanager.filters; -import com.google.common.base.Predicate; - import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.util.Predicates; +import java.util.function.Predicate; + /** * TODO: Write javadoc for this type. * diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardRatingFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardRatingFilter.java index cea3aa270bc..3dd0dff5de3 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardRatingFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardRatingFilter.java @@ -2,14 +2,14 @@ import javax.swing.JPanel; -import com.google.common.base.Predicate; - import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.itemmanager.SFilterUtil; import forge.itemmanager.SItemManagerUtil.StatTypes; import forge.model.FModel; +import java.util.function.Predicate; + public class CardRatingFilter extends StatTypeFilter { public CardRatingFilter(ItemManager itemManager0) { super(itemManager0); diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardSearchFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardSearchFilter.java index 2ad5fa36666..834867af2de 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardSearchFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardSearchFilter.java @@ -2,8 +2,6 @@ import javax.swing.JPanel; -import com.google.common.base.Predicate; - import forge.gui.UiCommand; import forge.item.InventoryItem; import forge.item.PaperCard; @@ -14,6 +12,8 @@ import forge.toolbox.FTextField; import forge.toolbox.LayoutHelper; +import java.util.function.Predicate; + public class CardSearchFilter extends TextSearchFilter { private FComboBoxWrapper cbSearchMode; @@ -106,7 +106,7 @@ protected Predicate buildPredicate() { @Override protected boolean showUnsupportedItem(U item) { //fallback to regular item text filter if item not PaperCard - boolean result = btnName.isSelected() && SFilterUtil.buildItemTextFilter(txtSearch.getText()).apply(item); + boolean result = btnName.isSelected() && SFilterUtil.buildItemTextFilter(txtSearch.getText()).test(item); if (cbSearchMode.getSelectedIndex() != 0) { //invert result if needed result = !result; } diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java index 09130be0dfd..5d10dc1760b 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java @@ -1,13 +1,13 @@ package forge.itemmanager.filters; -import com.google.common.base.Predicate; - import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.util.Predicates; +import java.util.function.Predicate; + /** * TODO: Write javadoc for this type. * diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java index 3be55d74743..28f0bff1c2b 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java @@ -2,11 +2,10 @@ import java.util.ArrayList; import java.util.List; +import java.util.function.Predicate; import javax.swing.JPanel; -import com.google.common.base.Predicate; - import forge.card.CardRules; import forge.item.PaperCard; import forge.itemmanager.ItemManager; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckColorFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckColorFilter.java index d455498efef..049136a52f4 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckColorFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckColorFilter.java @@ -2,14 +2,14 @@ import javax.swing.JPanel; -import com.google.common.base.Predicate; - import forge.deck.DeckProxy; import forge.itemmanager.ItemManager; import forge.itemmanager.SFilterUtil; import forge.itemmanager.SItemManagerUtil.StatTypes; import forge.util.ItemPool; +import java.util.function.Predicate; + public class DeckColorFilter extends StatTypeFilter { public DeckColorFilter(ItemManager itemManager0) { diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckFolderFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckFolderFilter.java index f05e9d3945d..62bb83de546 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckFolderFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckFolderFilter.java @@ -2,8 +2,7 @@ import java.util.HashSet; import java.util.Set; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.deck.DeckProxy; import forge.itemmanager.ItemManager; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckFormatFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckFormatFilter.java index 540ed04dac0..9e01c821918 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckFormatFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckFormatFilter.java @@ -1,13 +1,13 @@ package forge.itemmanager.filters; -import com.google.common.base.Predicate; - import forge.deck.DeckProxy; import forge.game.GameFormat; import forge.itemmanager.ItemManager; import forge.itemmanager.SFilterUtil; import forge.screens.home.quest.DialogChooseFormats; +import java.util.function.Predicate; + public class DeckFormatFilter extends FormatFilter { public DeckFormatFilter(ItemManager itemManager0) { diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckSetFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckSetFilter.java index 101bac06785..132c901766f 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckSetFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckSetFilter.java @@ -3,8 +3,8 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; +import java.util.function.Predicate; -import com.google.common.base.Predicate; import forge.deck.DeckProxy; import forge.game.GameFormat; import forge.itemmanager.ItemManager; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/ItemFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/ItemFilter.java index 6de51fcd65f..54f57fad500 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/ItemFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/ItemFilter.java @@ -8,13 +8,12 @@ import java.awt.RenderingHints; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.util.function.Predicate; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingUtilities; -import com.google.common.base.Predicate; - import forge.gui.framework.ILocalRepaint; import forge.item.InventoryItem; import forge.itemmanager.ItemManager; @@ -119,7 +118,7 @@ public final Predicate buildPredicate(Class gene return item -> { try { //noinspection unchecked - return predicate.apply((T)item); + return predicate.test((T)item); } catch (Exception ex) { return showUnsupportedItem(item); //if can't cast U to T, filter item out unless derived class can handle it diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TextSearchFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TextSearchFilter.java index b6c1009859d..ab536d9e2ec 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TextSearchFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TextSearchFilter.java @@ -3,12 +3,11 @@ import java.awt.Component; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; +import java.util.function.Predicate; import javax.swing.JPanel; import javax.swing.Timer; -import com.google.common.base.Predicate; - import forge.item.InventoryItem; import forge.itemmanager.ItemManager; import forge.itemmanager.SFilterUtil; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TokenSearchFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TokenSearchFilter.java index c0138883ca8..a8ffabff21e 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TokenSearchFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TokenSearchFilter.java @@ -2,8 +2,6 @@ import javax.swing.JPanel; -import com.google.common.base.Predicate; - import forge.gui.UiCommand; import forge.item.InventoryItem; import forge.item.PaperToken; @@ -14,6 +12,8 @@ import forge.toolbox.FTextField; import forge.toolbox.LayoutHelper; +import java.util.function.Predicate; + public class TokenSearchFilter extends TextSearchFilter { private FComboBoxWrapper cbSearchMode; @@ -101,7 +101,7 @@ protected Predicate buildPredicate() { @Override protected boolean showUnsupportedItem(U item) { //fallback to regular item text filter if item not PaperCard - boolean result = btnName.isSelected() && SFilterUtil.buildItemTextFilter(txtSearch.getText()).apply(item); + boolean result = btnName.isSelected() && SFilterUtil.buildItemTextFilter(txtSearch.getText()).test(item); if (cbSearchMode.getSelectedIndex() != 0) { //invert result if needed result = !result; } diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/ValueRangeFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/ValueRangeFilter.java index 71ebf7007a3..d643a6a5c43 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/ValueRangeFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/ValueRangeFilter.java @@ -1,12 +1,11 @@ package forge.itemmanager.filters; import java.awt.Component; +import java.util.function.Predicate; import javax.swing.JPanel; import javax.swing.JSpinner; -import com.google.common.base.Predicate; - import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.InventoryItem; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java index 92635c38616..c832a727955 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java @@ -1,7 +1,5 @@ package forge.screens.deckeditor.controllers; -import com.google.common.base.Predicate; - import forge.Singletons; import forge.card.CardDb; import forge.card.CardRulesPredicates; @@ -27,6 +25,8 @@ import forge.util.Iterables; import forge.util.Predicates; +import java.util.function.Predicate; + /** * Controls the "analysis" panel in the deck editor UI. diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java index 6f1bf6f5e8d..737fe567692 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java @@ -17,7 +17,6 @@ */ package forge.screens.deckeditor.controllers; -import com.google.common.base.Predicate; import com.google.common.base.Supplier; import forge.card.CardDb; import forge.card.CardRules; @@ -45,6 +44,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; +import java.util.function.Predicate; /** * Child controller for constructed deck editor UI. diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java index ebc41081770..c04ce187f76 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java @@ -22,11 +22,11 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.function.Predicate; import javax.swing.KeyStroke; import com.google.common.base.Function; -import com.google.common.base.Predicate; import com.google.common.base.Supplier; import forge.card.CardRules; @@ -303,7 +303,7 @@ public MatchCommanderColorIdentity(ColorSet color) { } @Override - public boolean apply(PaperCard subject) { + public boolean test(PaperCard subject) { CardRules cr = subject.getRules(); ManaCost mc = cr.getManaCost(); return allowedColor.containsAllColorsFrom(cr.getColorIdentity().getColor()); diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java index f1f92a48471..413c90a67d1 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java @@ -17,7 +17,6 @@ */ package forge.screens.deckeditor.controllers; -import com.google.common.base.Predicate; import com.google.common.base.Supplier; import forge.deck.Deck; import forge.deck.DeckSection; @@ -40,6 +39,7 @@ import forge.util.storage.IStorage; import java.util.Map.Entry; +import java.util.function.Predicate; /** * Child controller for constructed deck editor UI. diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java index 214a1e34c49..25f20ae4cf1 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java @@ -1,11 +1,10 @@ package forge.screens.deckeditor.controllers; import java.util.Map.Entry; +import java.util.function.Predicate; import javax.swing.JLabel; -import com.google.common.base.Predicate; - import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.card.MagicColor; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java index 32116e8bccf..7fe9be51257 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java @@ -1,6 +1,5 @@ package forge.screens.deckeditor.controllers; -import com.google.common.base.Predicate; import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.card.MagicColor; @@ -19,6 +18,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.function.Predicate; public class CStatisticsImporter { diff --git a/forge-gui-desktop/src/main/java/forge/screens/home/PlayerPanel.java b/forge-gui-desktop/src/main/java/forge/screens/home/PlayerPanel.java index fb519d0f19b..11ca4ddf386 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/home/PlayerPanel.java +++ b/forge-gui-desktop/src/main/java/forge/screens/home/PlayerPanel.java @@ -10,6 +10,7 @@ import java.util.Collections; import java.util.List; import java.util.Set; +import java.util.function.Predicate; import javax.swing.ButtonGroup; import javax.swing.JCheckBoxMenuItem; @@ -17,7 +18,6 @@ import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; import forge.Singletons; diff --git a/forge-gui-desktop/src/test/java/forge/card/CardDbCardMockTestCase.java b/forge-gui-desktop/src/test/java/forge/card/CardDbCardMockTestCase.java index 791c2e5d867..20aeb4b1856 100644 --- a/forge-gui-desktop/src/test/java/forge/card/CardDbCardMockTestCase.java +++ b/forge-gui-desktop/src/test/java/forge/card/CardDbCardMockTestCase.java @@ -14,12 +14,11 @@ import java.util.Arrays; import java.util.Date; import java.util.List; +import java.util.function.Predicate; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.google.common.base.Predicate; - import forge.StaticData; import forge.item.IPaperCard; import forge.item.PaperCard; diff --git a/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/PlayerControllerForTests.java b/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/PlayerControllerForTests.java index 37bb983b37e..612cac56293 100644 --- a/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/PlayerControllerForTests.java +++ b/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/PlayerControllerForTests.java @@ -1,6 +1,5 @@ package forge.gamesimulationtests.util; -import com.google.common.base.Predicate; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; @@ -58,6 +57,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Predicate; /** * Default harmless implementation for tests. diff --git a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java index f2b985c448a..3cb810b12c3 100644 --- a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java +++ b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java @@ -2,7 +2,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.utils.Array; -import com.google.common.base.Predicate; import forge.Forge; import forge.adventure.character.EnemySprite; import forge.adventure.pointofintrest.PointOfInterestChanges; @@ -26,6 +25,7 @@ import java.io.Serializable; import java.util.*; +import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.StreamSupport; @@ -321,7 +321,7 @@ private CardBlock pickWeightedCardBlock() { Iterable src = FModel.getBlocks(); //all blocks Predicate filter = Predicates.and(CardEdition.Predicates.CAN_MAKE_BOOSTER, selectSetPool()); List allEditions = new ArrayList<>(); - StreamSupport.stream(editions.spliterator(), false).filter(filter::apply).filter(CardEdition::hasBoosterTemplate).collect(Collectors.toList()).iterator().forEachRemaining(allEditions::add); + StreamSupport.stream(editions.spliterator(), false).filter(filter).filter(CardEdition::hasBoosterTemplate).collect(Collectors.toList()).iterator().forEachRemaining(allEditions::add); //Temporary restriction until rewards are more diverse - don't want to award restricted cards so these editions need different rewards added. List restrictedDrafts = new ArrayList<>(); diff --git a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java index ef526770d51..2920d4f3a00 100644 --- a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java +++ b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java @@ -2,7 +2,6 @@ import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.utils.Json; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.StaticData; import forge.adventure.data.ConfigData; @@ -27,6 +26,7 @@ import java.text.SimpleDateFormat; import java.util.*; +import java.util.function.Predicate; import java.util.regex.Pattern; import static forge.adventure.data.RewardData.generateAllCards; @@ -71,7 +71,7 @@ private static Date parseDate(String date) { } @Override - public boolean apply(final PaperCard card) { + public boolean test(final PaperCard card) { if(!this.rarities.isEmpty()&&!this.rarities.contains(card.getRarity())) return !this.shouldBeEqual; if(!this.editions.isEmpty()&&!this.editions.contains(card.getEdition())) { @@ -340,7 +340,7 @@ public static List getPredicateResult(Iterable cards,final for (final PaperCard item : cards) { - if(pre.apply(item)) + if(pre.test(item)) result.add(item); } return result; diff --git a/forge-gui-mobile/src/forge/deck/FDeckEditor.java b/forge-gui-mobile/src/forge/deck/FDeckEditor.java index 6378151d4bb..b128cdfac57 100644 --- a/forge-gui-mobile/src/forge/deck/FDeckEditor.java +++ b/forge-gui-mobile/src/forge/deck/FDeckEditor.java @@ -3,7 +3,6 @@ import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Align; -import com.google.common.base.Predicate; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import forge.Forge; @@ -40,6 +39,7 @@ import java.util.*; import java.util.Map.Entry; +import java.util.function.Predicate; import java.util.stream.Collectors; public class FDeckEditor extends TabPageScreen { @@ -98,7 +98,7 @@ else if (additionalFilter != null) { ItemPool filteredPool = new ItemPool<>(PaperCard.class); for (Entry entry : cardPool) { - if (filter.apply(entry.getKey())) { + if (filter.test(entry.getKey())) { filteredPool.add(entry.getKey(), entry.getValue()); } } diff --git a/forge-gui-mobile/src/forge/itemmanager/ItemManager.java b/forge-gui-mobile/src/forge/itemmanager/ItemManager.java index ce36cfbaa25..4e6e059dafb 100644 --- a/forge-gui-mobile/src/forge/itemmanager/ItemManager.java +++ b/forge-gui-mobile/src/forge/itemmanager/ItemManager.java @@ -19,12 +19,12 @@ import java.util.*; import java.util.Map.Entry; +import java.util.function.Predicate; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.utils.Align; import com.google.common.base.Function; -import com.google.common.base.Predicate; import forge.Forge; import forge.Graphics; diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/AdvancedSearchFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/AdvancedSearchFilter.java index 48db74da569..39aaee29eef 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/AdvancedSearchFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/AdvancedSearchFilter.java @@ -1,7 +1,6 @@ package forge.itemmanager.filters; import com.badlogic.gdx.utils.Align; -import com.google.common.base.Predicate; import forge.Forge; import forge.assets.FSkinImage; @@ -27,6 +26,8 @@ import forge.util.Callback; import forge.util.Iterables; +import java.util.function.Predicate; + public class AdvancedSearchFilter extends ItemFilter { private final AdvancedSearch.Model model; diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java index ccc4f561e23..8ecdb69d97b 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java @@ -1,13 +1,13 @@ package forge.itemmanager.filters; -import com.google.common.base.Predicate; - import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.util.Predicates; +import java.util.function.Predicate; + public class CardCMCFilter extends ValueRangeFilter { public CardCMCFilter(ItemManager itemManager0) { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardColorFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardColorFilter.java index b3bc12c091b..98c27179873 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardColorFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardColorFilter.java @@ -1,12 +1,12 @@ package forge.itemmanager.filters; -import com.google.common.base.Predicate; - import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.itemmanager.SFilterUtil; import forge.itemmanager.SItemManagerUtil.StatTypes; +import java.util.function.Predicate; + public class CardColorFilter extends StatTypeFilter { public CardColorFilter(ItemManager itemManager0) { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java index a5a8d027977..5ff7ac2897b 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java @@ -1,13 +1,13 @@ package forge.itemmanager.filters; -import com.google.common.base.Predicate; - import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.util.Predicates; +import java.util.function.Predicate; + public class CardColorlessCostFilter extends ValueRangeFilter { public CardColorlessCostFilter(ItemManager itemManager0) { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardFormatFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardFormatFilter.java index e94dc2287ea..36abb625625 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardFormatFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardFormatFilter.java @@ -1,11 +1,11 @@ package forge.itemmanager.filters; -import com.google.common.base.Predicate; - import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.util.Predicates; +import java.util.function.Predicate; + public class CardFormatFilter extends FormatFilter { public CardFormatFilter(ItemManager itemManager0) { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java index 8ed5cddd1eb..c23a7d3fe9e 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java @@ -1,13 +1,13 @@ package forge.itemmanager.filters; -import com.google.common.base.Predicate; - import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.util.Predicates; +import java.util.function.Predicate; + public class CardPowerFilter extends ValueRangeFilter { public CardPowerFilter(ItemManager itemManager0) { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardRarityFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardRarityFilter.java index 3e6b9e529ca..0e29022b935 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardRarityFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardRarityFilter.java @@ -1,11 +1,11 @@ package forge.itemmanager.filters; -import com.google.common.base.Predicate; - import forge.card.CardRarity; import forge.item.PaperCard; import forge.itemmanager.ItemManager; +import java.util.function.Predicate; + public class CardRarityFilter extends ComboBoxFilter { public CardRarityFilter(ItemManager itemManager0) { super("Any Rarity", CardRarity.FILTER_OPTIONS, itemManager0); diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardSearchFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardSearchFilter.java index 35fa8ec8633..4ea7a7be250 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardSearchFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardSearchFilter.java @@ -1,12 +1,12 @@ package forge.itemmanager.filters; -import com.google.common.base.Predicate; - import forge.item.InventoryItem; import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.itemmanager.SFilterUtil; +import java.util.function.Predicate; + public class CardSearchFilter extends TextSearchFilter { private final boolean inName, inType, inText, inCost; @@ -45,6 +45,6 @@ protected Predicate buildPredicate() { @Override protected boolean showUnsupportedItem(U item) { //fallback to regular item text filter if item not PaperCard - return SFilterUtil.buildItemTextFilter(txtSearch.getText()).apply(item); + return SFilterUtil.buildItemTextFilter(txtSearch.getText()).test(item); } } diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java index e02c492cd96..59d205164cf 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java @@ -1,13 +1,13 @@ package forge.itemmanager.filters; -import com.google.common.base.Predicate; - import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; import forge.itemmanager.ItemManager; import forge.util.Predicates; +import java.util.function.Predicate; + public class CardToughnessFilter extends ValueRangeFilter { public CardToughnessFilter(ItemManager itemManager0) { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java index 622f25bf19b..1a9bbce096f 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java @@ -2,8 +2,7 @@ import java.util.ArrayList; import java.util.List; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.card.CardRules; import forge.item.PaperCard; diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/DeckColorFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/DeckColorFilter.java index 52cc7b4b593..5f794396abc 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/DeckColorFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/DeckColorFilter.java @@ -1,12 +1,12 @@ package forge.itemmanager.filters; -import com.google.common.base.Predicate; - import forge.deck.DeckProxy; import forge.itemmanager.ItemManager; import forge.itemmanager.SFilterUtil; import forge.itemmanager.SItemManagerUtil.StatTypes; +import java.util.function.Predicate; + public class DeckColorFilter extends StatTypeFilter { public DeckColorFilter(ItemManager itemManager0) { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/DeckFolderFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/DeckFolderFilter.java index fb502d1b172..4fd0ff0e72d 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/DeckFolderFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/DeckFolderFilter.java @@ -2,8 +2,7 @@ import java.util.HashSet; import java.util.Set; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.deck.DeckProxy; import forge.itemmanager.ItemManager; diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/DeckFormatFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/DeckFormatFilter.java index 4c7648a00aa..1e4b7ee55f0 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/DeckFormatFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/DeckFormatFilter.java @@ -1,11 +1,11 @@ package forge.itemmanager.filters; -import com.google.common.base.Predicate; - import forge.deck.DeckProxy; import forge.itemmanager.ItemManager; import forge.util.Predicates; +import java.util.function.Predicate; + public class DeckFormatFilter extends FormatFilter { public DeckFormatFilter(ItemManager itemManager0) { diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/ItemFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/ItemFilter.java index d05cf816038..37906952f7f 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/ItemFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/ItemFilter.java @@ -1,7 +1,5 @@ package forge.itemmanager.filters; -import com.google.common.base.Predicate; - import forge.assets.FSkinFont; import forge.item.InventoryItem; import forge.itemmanager.ItemManager; @@ -9,6 +7,8 @@ import forge.toolbox.FDisplayObject; import forge.util.Utils; +import java.util.function.Predicate; + public abstract class ItemFilter { public static final float PADDING = Utils.scale(3); @@ -48,7 +48,7 @@ public final Predicate buildPredicate(Class gene return item -> { try { //noinspection unchecked - return predicate.apply((T)item); + return predicate.test((T)item); } catch (Exception ex) { return showUnsupportedItem(item); //if can't cast U to T, filter item out unless derived class can handle it diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/TextSearchFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/TextSearchFilter.java index 475b25a028a..d2d7b658d62 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/TextSearchFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/TextSearchFilter.java @@ -1,7 +1,6 @@ package forge.itemmanager.filters; import com.badlogic.gdx.utils.Align; -import com.google.common.base.Predicate; import forge.Forge; import forge.Graphics; @@ -13,6 +12,8 @@ import forge.toolbox.FTextField; import forge.util.Predicates; +import java.util.function.Predicate; + public class TextSearchFilter extends ItemFilter { private static final FSkinFont FONT = FSkinFont.get(12); diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/ValueRangeFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/ValueRangeFilter.java index 1166e0e5add..b719a8a76f4 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/ValueRangeFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/ValueRangeFilter.java @@ -1,7 +1,6 @@ package forge.itemmanager.filters; import com.badlogic.gdx.utils.Align; -import com.google.common.base.Predicate; import forge.card.CardRules; import forge.card.CardRulesPredicates; @@ -13,6 +12,8 @@ import forge.toolbox.FSpinner; import forge.util.ComparableOp; +import java.util.function.Predicate; + public abstract class ValueRangeFilter extends ItemFilter { private FLabel label; diff --git a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java index 9d7957549f1..e0c8e65349b 100644 --- a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java +++ b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java @@ -3,11 +3,11 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.function.Predicate; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.utils.Align; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import forge.Forge; @@ -109,7 +109,7 @@ private void updateFilteredPool() { filteredPool.clear(); strictPool.clear(); for (PaperCard card : pool) { - if (predicate == null || predicate.apply(card)) { + if (predicate == null || predicate.test(card)) { filteredPool.add(card); if (selectedRarity == card.getRarity()) { strictPool.add(card); diff --git a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestCollectionScreen.java b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestCollectionScreen.java index 4e456c329a9..cbbac3bfe11 100644 --- a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestCollectionScreen.java +++ b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestCollectionScreen.java @@ -2,8 +2,8 @@ import java.util.Collection; import java.util.Map.Entry; +import java.util.function.Predicate; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import forge.Forge; diff --git a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestCommandersScreen.java b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestCommandersScreen.java index d2fa2f62667..394be675bd0 100644 --- a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestCommandersScreen.java +++ b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestCommandersScreen.java @@ -1,9 +1,9 @@ package forge.screens.planarconquest; import java.util.Map.Entry; +import java.util.function.Predicate; import com.badlogic.gdx.utils.Align; -import com.google.common.base.Predicate; import forge.Forge; import forge.Graphics; @@ -266,8 +266,8 @@ protected final Predicate buildPredicate() { private final Predicate pred = SFilterUtil.buildColorFilter(buttonMap); @Override - public boolean apply(ConquestCommander input) { - return pred.apply(input.getCard()); + public boolean test(ConquestCommander input) { + return pred.test(input.getCard()); } }; } diff --git a/forge-gui-mobile/src/forge/toolbox/ListChooser.java b/forge-gui-mobile/src/forge/toolbox/ListChooser.java index 32ca730fdf1..be3c84e5ab2 100644 --- a/forge-gui-mobile/src/forge/toolbox/ListChooser.java +++ b/forge-gui-mobile/src/forge/toolbox/ListChooser.java @@ -21,10 +21,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.function.Predicate; import com.badlogic.gdx.Input; import com.google.common.base.Function; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import forge.Forge; diff --git a/forge-gui/src/main/java/forge/deck/ColorDeckGenerator.java b/forge-gui/src/main/java/forge/deck/ColorDeckGenerator.java index a57391db59e..655609306d1 100644 --- a/forge-gui/src/main/java/forge/deck/ColorDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/ColorDeckGenerator.java @@ -2,8 +2,7 @@ import java.util.ArrayList; import java.util.List; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.card.CardEdition; import forge.item.PaperCard; diff --git a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java index 7e2c4f3b882..ac757f56d01 100644 --- a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java @@ -3,8 +3,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.card.CardEdition; import forge.card.CardRules; diff --git a/forge-gui/src/main/java/forge/deck/DeckProxy.java b/forge-gui/src/main/java/forge/deck/DeckProxy.java index 4654d9b295d..537457558f4 100644 --- a/forge-gui/src/main/java/forge/deck/DeckProxy.java +++ b/forge-gui/src/main/java/forge/deck/DeckProxy.java @@ -1,6 +1,5 @@ package forge.deck; -import com.google.common.base.Predicate; import forge.StaticData; import forge.card.*; import forge.card.mana.ManaCostShard; @@ -28,6 +27,7 @@ import java.util.*; import java.util.Map.Entry; import java.util.function.Function; +import java.util.function.Predicate; // Adding a generic to this class creates compile problems in ItemManager (that I can not fix) public class DeckProxy implements InventoryItem { @@ -518,7 +518,7 @@ private static void addDecksRecursivelly(final String deckType, final GameType g } for (final Deck d : folder) { - if (filter == null || filter.apply(d)) { + if (filter == null || filter.test(d)) { list.add(new DeckProxy(d, deckType, gameType, path, folder, null)); } } @@ -533,7 +533,7 @@ public static final Predicate createPredicate(final Predicate poolEntry : deckEntry.getValue()) { - if (!cardPredicate.apply(poolEntry.getKey())) { + if (!cardPredicate.test(poolEntry.getKey())) { return false; //all cards in deck must pass card predicate to pass deck predicate } } diff --git a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java index c3092b7fb7e..34befebff7f 100644 --- a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java +++ b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java @@ -8,11 +8,11 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Predicate; import forge.util.*; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.StaticData; diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java b/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java index 58f63f2055f..c9b826452e1 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java @@ -17,7 +17,6 @@ */ package forge.gamemodes.limited; -import com.google.common.base.Predicate; import com.google.common.base.Supplier; import forge.StaticData; import forge.card.CardEdition; @@ -41,6 +40,7 @@ import java.io.File; import java.util.*; +import java.util.function.Predicate; /** * Booster Draft Format. diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java index de544051f75..7a9d9505d26 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java @@ -8,8 +8,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Predicate; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.StaticData; @@ -436,7 +436,7 @@ public MatchColorIdentity(ColorSet color) { } @Override - public boolean apply(CardRules subject) { + public boolean test(CardRules subject) { return allowedColor.containsAllColorsFrom(subject.getColorIdentity().getColor()); } } @@ -610,7 +610,7 @@ private void fixDeckSize() { Predicate possibleFromFullPool = new Predicate() { final Set deckListNames = getDeckListNames(); @Override - public boolean apply(PaperCard card) { + public boolean test(PaperCard card) { return format.isLegalCard(card) && card.getRules().getColorIdentity().hasNoColorsExcept(colors) && !deckListNames.contains(card.getName()) @@ -649,7 +649,7 @@ protected void findBasicLandSets() { final Set sets = new HashSet<>(); for (final PaperCard cp : aiPlayables) { final CardEdition ee = FModel.getMagicDb().getEditions().get(cp.getEdition()); - if( !sets.contains(cp.getEdition()) && CardEdition.Predicates.hasBasicLands.apply(ee)) { + if( !sets.contains(cp.getEdition()) && CardEdition.Predicates.hasBasicLands.test(ee)) { sets.add(cp.getEdition()); } } diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java index 14a98e28773..0daa90453e0 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java @@ -7,8 +7,8 @@ import java.util.ListIterator; import java.util.Map; import java.util.Set; +import java.util.function.Predicate; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.card.CardAiHints; @@ -322,7 +322,7 @@ private void findBasicLandSets() { final Set sets = new HashSet<>(); for (final PaperCard cp : aiPlayables) { final CardEdition ee = FModel.getMagicDb().getEditions().get(cp.getEdition()); - if( !sets.contains(cp.getEdition()) && CardEdition.Predicates.hasBasicLands.apply(ee)) { + if( !sets.contains(cp.getEdition()) && CardEdition.Predicates.hasBasicLands.test(ee)) { sets.add(cp.getEdition()); } } diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/ThemedChaosDraft.java b/forge-gui/src/main/java/forge/gamemodes/limited/ThemedChaosDraft.java index 3760a2246ac..7747950c8a8 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/ThemedChaosDraft.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/ThemedChaosDraft.java @@ -1,11 +1,10 @@ package forge.gamemodes.limited; import java.util.List; +import java.util.function.Predicate; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.base.Predicate; - import forge.card.CardEdition; import forge.game.GameFormat; import forge.model.FModel; @@ -72,7 +71,7 @@ public Predicate getEditionFilter() { */ private final Predicate themedFilter = new Predicate() { @Override - public boolean apply(final CardEdition cardEdition) { + public boolean test(final CardEdition cardEdition) { String[] themes = cardEdition.getChaosDraftThemes(); for (String theme : themes) { if (tag.equals(theme)) return true; @@ -99,7 +98,7 @@ private Predicate getFormatFilter(String formatName) { default: format = formats.getStandard(); } - return cardEdition -> DEFAULT_FILTER.apply(cardEdition) && format.isSetLegal(cardEdition.getCode()); + return cardEdition -> DEFAULT_FILTER.test(cardEdition) && format.isSetLegal(cardEdition.getCode()); } /** diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java index 2e2803b8381..a06a84b66bc 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java @@ -5,10 +5,10 @@ import java.util.List; import java.util.Set; +import java.util.function.Predicate; import org.apache.commons.lang3.ObjectUtils; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -328,7 +328,7 @@ protected void onPlayerSelected(final Player player, final ITriggerEvent trigger showMessage(sa.getHostCard() + " - Cannot target this player (Hexproof? Protection? Restrictions?)."); return; } - if (filter != null && !filter.apply(player)) { + if (filter != null && !filter.test(player)) { showMessage(sa.getHostCard() + " - Cannot target this player (Hexproof? Protection? Restrictions?)."); return; } diff --git a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java index e37b88dd893..b1c8ff0c0e4 100644 --- a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java +++ b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java @@ -4,8 +4,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.card.CardRulesPredicates; import forge.card.ColorSet; @@ -159,7 +158,7 @@ protected ConquestRegion read(String line) { static void addCard(PaperCard pc, Iterable regions) { boolean foundRegion = false; for (ConquestRegion region : regions) { - if (region.pred.apply(pc)) { + if (region.pred.test(pc)) { region.cardPool.add(pc); foundRegion = true; } diff --git a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java index 49ea9dad364..881255a3316 100644 --- a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java +++ b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java @@ -5,8 +5,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.function.Predicate; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -429,7 +429,7 @@ private ColorFilter(int colorMask0) { } @Override - public boolean apply(PaperCard card) { + public boolean test(PaperCard card) { return card.getRules().getColorIdentity().hasNoColorsExcept(color); } } @@ -449,7 +449,7 @@ private TypeFilter(Iterable types0, Iterable nonTypes0) { } @Override - public boolean apply(PaperCard card) { + public boolean test(PaperCard card) { CardType cardType = card.getRules().getType(); if (nonTypes != null) { for (CoreType nonType : nonTypes) { @@ -511,7 +511,7 @@ private String updateOdds(Map oddsLookup) { } @Override - public boolean apply(PaperCard card) { + public boolean test(PaperCard card) { return rarityOdds.containsKey(card.getRarity()); } } @@ -525,7 +525,7 @@ private CMCFilter(int cmcMin0, int cmcMax0) { } @Override - public boolean apply(PaperCard card) { + public boolean test(PaperCard card) { int cardCmc = card.getRules().getManaCost().getCMC(); if (cardCmc < cmcMin) { return false; } return cmcMax == -1 || cardCmc <= cmcMax; diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java index 1a0cb656a1b..c41f4311df7 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java @@ -23,12 +23,12 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.function.Predicate; import forge.util.Iterables; import forge.util.Predicates; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import forge.card.CardEdition; diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestChallengeGenerator.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestChallengeGenerator.java index 7c59d18a569..9c6f3d1cf3a 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestChallengeGenerator.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestChallengeGenerator.java @@ -6,8 +6,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.deck.DeckgenUtil; import forge.game.GameFormat; @@ -157,7 +156,7 @@ public QuestEventChallenge get(String id) { @Override public QuestEventChallenge find(Predicate condition) { for(QuestEventChallenge challenge:challenges.values()){ - if(condition.apply(challenge)){ + if(condition.test(challenge)){ return challenge; } } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java index 544a317ec3b..32d1be5c14c 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java @@ -2,8 +2,7 @@ import java.util.ArrayList; import java.util.List; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.card.CardRules; import forge.item.IPaperCard; diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardChooser.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardChooser.java index 34b21fd6718..29cb0ff13b1 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardChooser.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardChooser.java @@ -4,8 +4,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.item.PaperCard; import forge.model.FModel; diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardFiltered.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardFiltered.java index ae617368f6a..d14fe24078f 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardFiltered.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardFiltered.java @@ -3,8 +3,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.item.PaperCard; import forge.model.FModel; diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java index f83257c843b..461a867f00e 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java @@ -18,7 +18,6 @@ package forge.gamemodes.quest; import com.google.common.base.Function; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import forge.card.CardEdition; @@ -47,6 +46,7 @@ import java.util.Collections; import java.util.List; import java.util.Map.Entry; +import java.util.function.Predicate; /** * This is a helper class to execute operations on QuestData. It has been @@ -93,7 +93,7 @@ public static ItemPool generateBasicLands(final int nBasic, final int for (String edCode : availableEditions) { CardEdition ed = FModel.getMagicDb().getEditions().get(edCode); // Duel decks might have only 2 types of basic lands - if (CardEdition.Predicates.hasBasicLands.apply(ed)) { + if (CardEdition.Predicates.hasBasicLands.test(ed)) { landCodes.add(edCode); } } @@ -613,7 +613,7 @@ private static int getRandomCardFromBooster(final List cards, final P List temp = new ArrayList<>(); for (PaperCard card : cards) { - if (predicate.apply(card)) { + if (predicate.test(card)) { temp.add(card); } } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/data/GameFormatQuest.java b/forge-gui/src/main/java/forge/gamemodes/quest/data/GameFormatQuest.java index 54030ccd2c8..083d53f3f7d 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/data/GameFormatQuest.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/data/GameFormatQuest.java @@ -19,8 +19,8 @@ import java.util.ArrayList; import java.util.List; +import java.util.function.Predicate; -import com.google.common.base.Predicate; import forge.card.CardEdition; import forge.game.GameFormat; import forge.gamemodes.quest.setrotation.ISetRotation; @@ -181,7 +181,7 @@ private LegalInFormatQuest(final GameFormatQuest fmt) { } @Override - public boolean apply(final CardEdition subject) { + public boolean test(final CardEdition subject) { return this.qFormat.isSetLegal(subject.getCode()); } } diff --git a/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java b/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java index a482d13c89b..e7bda942ca7 100644 --- a/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java +++ b/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java @@ -3,11 +3,11 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Predicate; import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Lists; import com.google.common.collect.Maps; diff --git a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java index 75b7beb6e3e..960fecbcb6e 100644 --- a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java +++ b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java @@ -10,10 +10,10 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.function.Predicate; import java.util.stream.Collectors; import com.google.common.base.Function; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; diff --git a/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java b/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java index 8bbafde8c29..fe6c057040f 100644 --- a/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java +++ b/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java @@ -4,8 +4,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Stack; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.card.CardRules; import forge.card.CardRulesPredicates; diff --git a/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java b/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java index fbacb231907..388fec5d5af 100644 --- a/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java +++ b/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java @@ -5,8 +5,7 @@ import java.util.List; import java.util.Map; import java.util.Set; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.StaticData; import forge.card.CardEdition; @@ -132,7 +131,7 @@ private ItemTextPredicate(String text) { } @Override - public boolean apply(T input) { + public boolean test(T input) { String name = input.getName().toLowerCase(); for (String s : splitText) { if (name.contains(s)) { diff --git a/forge-gui/src/main/java/forge/itemmanager/SItemManagerUtil.java b/forge-gui/src/main/java/forge/itemmanager/SItemManagerUtil.java index da2e6a364ef..0ff5d6c84b9 100644 --- a/forge-gui/src/main/java/forge/itemmanager/SItemManagerUtil.java +++ b/forge-gui/src/main/java/forge/itemmanager/SItemManagerUtil.java @@ -4,8 +4,7 @@ import java.util.Comparator; import java.util.List; import java.util.Map.Entry; - -import com.google.common.base.Predicate; +import java.util.function.Predicate; import forge.card.CardRules; import forge.card.CardRulesPredicates; diff --git a/forge-gui/src/main/java/forge/model/CardBlock.java b/forge-gui/src/main/java/forge/model/CardBlock.java index 435c016d4df..b2aa31841df 100644 --- a/forge-gui/src/main/java/forge/model/CardBlock.java +++ b/forge-gui/src/main/java/forge/model/CardBlock.java @@ -21,11 +21,10 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +import java.util.function.Predicate; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Predicate; - import forge.card.CardEdition; import forge.item.IPaperCard; import forge.item.PaperCard; diff --git a/forge-gui/src/main/java/forge/model/MetaSet.java b/forge-gui/src/main/java/forge/model/MetaSet.java index 1bd97c90073..25d779e1542 100644 --- a/forge-gui/src/main/java/forge/model/MetaSet.java +++ b/forge-gui/src/main/java/forge/model/MetaSet.java @@ -18,7 +18,6 @@ package forge.model; -import com.google.common.base.Predicate; import forge.gamemodes.limited.CustomLimited; import forge.gamemodes.limited.SealedCardPoolGenerator; import forge.item.IPaperCard; @@ -31,6 +30,7 @@ import java.io.File; import java.util.List; +import java.util.function.Predicate; /** * The class MetaSet. This class is used to define 'special' diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index 27e537d3b0c..8fad25844d8 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -1,7 +1,6 @@ package forge.player; import com.google.common.base.Function; -import com.google.common.base.Predicate; import com.google.common.collect.*; import forge.LobbyPlayer; import forge.StaticData; @@ -77,6 +76,7 @@ import java.io.*; import java.util.*; import java.util.Map.Entry; +import java.util.function.Predicate; import java.util.stream.Collectors; /** diff --git a/forge-gui/src/main/java/forge/player/TargetSelection.java b/forge-gui/src/main/java/forge/player/TargetSelection.java index 4bd5af4d015..52a7e2f3a8e 100644 --- a/forge-gui/src/main/java/forge/player/TargetSelection.java +++ b/forge-gui/src/main/java/forge/player/TargetSelection.java @@ -22,8 +22,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Predicate; -import com.google.common.base.Predicate; import com.google.common.collect.Lists; import com.google.common.collect.Maps; From 8702e299cd69ef0835be1c6e656460ff38b16a77 Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 17:38:28 -0400 Subject: [PATCH 06/68] Guava migration - Migrate Functions --- forge-ai/src/main/java/forge/ai/ComputerUtilCard.java | 2 +- forge-ai/src/main/java/forge/ai/CreatureEvaluator.java | 3 +-- forge-core/src/main/java/forge/card/DeckHints.java | 3 +-- forge-core/src/main/java/forge/item/SealedTemplate.java | 2 +- forge-core/src/main/java/forge/util/Aggregates.java | 2 +- forge-core/src/main/java/forge/util/ItemPoolSorter.java | 3 +-- forge-core/src/main/java/forge/util/Lang.java | 2 +- .../java/forge/util/storage/StorageImmediatelySerialized.java | 3 +-- .../src/main/java/forge/util/storage/StorageNestedFolders.java | 3 +-- .../src/main/java/forge/util/storage/StorageReaderBase.java | 2 +- .../src/main/java/forge/util/storage/StorageReaderFile.java | 3 +-- .../java/forge/util/storage/StorageReaderFileSections.java | 3 +-- .../src/main/java/forge/util/storage/StorageReaderFolder.java | 3 +-- .../storage/StorageReaderRecursiveFolderWithUserFolder.java | 3 +-- forge-game/src/main/java/forge/game/GameType.java | 2 +- .../src/main/java/forge/game/player/PlayerCollection.java | 3 +-- forge-gui-desktop/src/main/java/forge/GuiDesktop.java | 3 +-- forge-gui-desktop/src/main/java/forge/gui/GuiChoose.java | 3 +-- forge-gui-desktop/src/main/java/forge/gui/ListChooser.java | 2 +- .../src/main/java/forge/itemmanager/views/ItemTableColumn.java | 3 +-- .../forge/screens/deckeditor/controllers/CEditorQuest.java | 2 +- .../screens/deckeditor/controllers/CEditorQuestLimited.java | 2 +- .../src/main/java/forge/screens/match/CMatchUI.java | 2 +- .../src/main/java/forge/screens/match/controllers/CField.java | 3 +-- .../main/java/forge/toolbox/special/PlayerDetailsPanel.java | 3 +-- forge-gui-mobile/src/forge/GuiMobile.java | 2 +- .../src/forge/adventure/scene/AdventureDeckEditor.java | 2 +- forge-gui-mobile/src/forge/itemmanager/ItemManager.java | 2 +- forge-gui-mobile/src/forge/itemmanager/SpellShopManager.java | 2 +- forge-gui-mobile/src/forge/screens/match/MatchController.java | 2 +- forge-gui-mobile/src/forge/toolbox/GuiChoose.java | 3 +-- forge-gui-mobile/src/forge/toolbox/ListChooser.java | 2 +- .../src/main/java/forge/gamemodes/net/ProtocolMethod.java | 3 +-- .../src/main/java/forge/gamemodes/net/server/NetGuiGame.java | 3 +-- .../main/java/forge/gamemodes/planarconquest/ConquestData.java | 3 +-- .../src/main/java/forge/gamemodes/quest/QuestSpellShop.java | 3 +-- .../src/main/java/forge/gamemodes/quest/QuestUtilCards.java | 2 +- forge-gui/src/main/java/forge/gui/interfaces/IGuiBase.java | 3 +-- forge-gui/src/main/java/forge/gui/interfaces/IGuiGame.java | 3 +-- forge-gui/src/main/java/forge/gui/util/SGuiChoose.java | 3 +-- forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java | 2 +- forge-gui/src/main/java/forge/itemmanager/ColumnDef.java | 2 +- forge-gui/src/main/java/forge/itemmanager/GroupDef.java | 2 +- forge-gui/src/main/java/forge/itemmanager/ItemColumn.java | 3 +-- .../src/main/java/forge/itemmanager/ItemColumnConfig.java | 3 +-- forge-gui/src/main/java/forge/model/FModel.java | 2 +- .../src/main/java/forge/player/PlayerControllerHuman.java | 2 +- 47 files changed, 47 insertions(+), 72 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index cf4b579281d..3ac13df9815 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -2,9 +2,9 @@ import java.util.*; import java.util.Map.Entry; +import java.util.function.Function; import java.util.function.Predicate; -import com.google.common.base.Function; import forge.ai.simulation.GameStateEvaluator; import forge.card.mana.ManaCost; import forge.game.card.*; diff --git a/forge-ai/src/main/java/forge/ai/CreatureEvaluator.java b/forge-ai/src/main/java/forge/ai/CreatureEvaluator.java index f35c873f368..f69bb8d5d49 100644 --- a/forge-ai/src/main/java/forge/ai/CreatureEvaluator.java +++ b/forge-ai/src/main/java/forge/ai/CreatureEvaluator.java @@ -1,7 +1,5 @@ package forge.ai; -import com.google.common.base.Function; - import forge.game.GameEntity; import forge.game.ability.AbilityUtils; import forge.game.ability.ApiType; @@ -15,6 +13,7 @@ import forge.game.staticability.StaticAbilityMustAttack; import java.util.List; +import java.util.function.Function; public class CreatureEvaluator implements Function { @Override diff --git a/forge-core/src/main/java/forge/card/DeckHints.java b/forge-core/src/main/java/forge/card/DeckHints.java index 50d39c533be..a422313f480 100644 --- a/forge-core/src/main/java/forge/card/DeckHints.java +++ b/forge-core/src/main/java/forge/card/DeckHints.java @@ -4,14 +4,13 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Function; import java.util.function.Predicate; import forge.util.Iterables; import forge.util.Predicates; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.base.Function; - import forge.StaticData; import forge.item.PaperCard; import forge.token.TokenDb; diff --git a/forge-core/src/main/java/forge/item/SealedTemplate.java b/forge-core/src/main/java/forge/item/SealedTemplate.java index 9633ca3be55..bf2dceaaac3 100644 --- a/forge-core/src/main/java/forge/item/SealedTemplate.java +++ b/forge-core/src/main/java/forge/item/SealedTemplate.java @@ -1,6 +1,5 @@ package forge.item; -import com.google.common.base.Function; import com.google.common.collect.Lists; import forge.item.generation.BoosterSlots; import forge.util.TextUtil; @@ -11,6 +10,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.function.Function; public class SealedTemplate { diff --git a/forge-core/src/main/java/forge/util/Aggregates.java b/forge-core/src/main/java/forge/util/Aggregates.java index d4d707410e2..9a81d1f6309 100644 --- a/forge-core/src/main/java/forge/util/Aggregates.java +++ b/forge-core/src/main/java/forge/util/Aggregates.java @@ -2,8 +2,8 @@ import java.util.*; import java.util.Map.Entry; +import java.util.function.Function; -import com.google.common.base.Function; import com.google.common.collect.Lists; /** diff --git a/forge-core/src/main/java/forge/util/ItemPoolSorter.java b/forge-core/src/main/java/forge/util/ItemPoolSorter.java index 49aa6441055..f0a9212df9a 100644 --- a/forge-core/src/main/java/forge/util/ItemPoolSorter.java +++ b/forge-core/src/main/java/forge/util/ItemPoolSorter.java @@ -19,8 +19,7 @@ import java.util.Comparator; import java.util.Map.Entry; - -import com.google.common.base.Function; +import java.util.function.Function; import forge.item.PaperCard; diff --git a/forge-core/src/main/java/forge/util/Lang.java b/forge-core/src/main/java/forge/util/Lang.java index 1e0dbb0e82c..cfd0053b4e2 100644 --- a/forge-core/src/main/java/forge/util/Lang.java +++ b/forge-core/src/main/java/forge/util/Lang.java @@ -2,11 +2,11 @@ import java.util.Collection; import java.util.List; +import java.util.function.Function; import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Function; import com.google.common.collect.Lists; import forge.util.lang.LangChinese; diff --git a/forge-core/src/main/java/forge/util/storage/StorageImmediatelySerialized.java b/forge-core/src/main/java/forge/util/storage/StorageImmediatelySerialized.java index 0956b307b96..02bb126e038 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageImmediatelySerialized.java +++ b/forge-core/src/main/java/forge/util/storage/StorageImmediatelySerialized.java @@ -18,8 +18,7 @@ package forge.util.storage; import java.io.File; - -import com.google.common.base.Function; +import java.util.function.Function; import forge.util.IItemSerializer; import forge.util.TextUtil; diff --git a/forge-core/src/main/java/forge/util/storage/StorageNestedFolders.java b/forge-core/src/main/java/forge/util/storage/StorageNestedFolders.java index 7746ce16cb6..97005b23b2e 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageNestedFolders.java +++ b/forge-core/src/main/java/forge/util/storage/StorageNestedFolders.java @@ -2,8 +2,7 @@ import java.io.File; import java.util.HashMap; - -import com.google.common.base.Function; +import java.util.function.Function; public class StorageNestedFolders extends StorageBase> { private final File thisFolder; diff --git a/forge-core/src/main/java/forge/util/storage/StorageReaderBase.java b/forge-core/src/main/java/forge/util/storage/StorageReaderBase.java index 27f2296498c..6f602c6aafc 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageReaderBase.java +++ b/forge-core/src/main/java/forge/util/storage/StorageReaderBase.java @@ -3,8 +3,8 @@ import java.io.File; import java.util.Map; import java.util.TreeMap; +import java.util.function.Function; -import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import forge.util.IItemReader; diff --git a/forge-core/src/main/java/forge/util/storage/StorageReaderFile.java b/forge-core/src/main/java/forge/util/storage/StorageReaderFile.java index 44ca561d31c..10f8ce9493e 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageReaderFile.java +++ b/forge-core/src/main/java/forge/util/storage/StorageReaderFile.java @@ -19,11 +19,10 @@ import java.io.File; import java.util.Map; +import java.util.function.Function; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Function; - import forge.util.FileUtil; /** diff --git a/forge-core/src/main/java/forge/util/storage/StorageReaderFileSections.java b/forge-core/src/main/java/forge/util/storage/StorageReaderFileSections.java index 6e90d54e6ef..b20a8006548 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageReaderFileSections.java +++ b/forge-core/src/main/java/forge/util/storage/StorageReaderFileSections.java @@ -21,11 +21,10 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.function.Function; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Function; - import forge.util.FileUtil; /** diff --git a/forge-core/src/main/java/forge/util/storage/StorageReaderFolder.java b/forge-core/src/main/java/forge/util/storage/StorageReaderFolder.java index 0128ed734af..9eb5db24ff3 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageReaderFolder.java +++ b/forge-core/src/main/java/forge/util/storage/StorageReaderFolder.java @@ -25,8 +25,7 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; - -import com.google.common.base.Function; +import java.util.function.Function; import forge.util.TextUtil; diff --git a/forge-core/src/main/java/forge/util/storage/StorageReaderRecursiveFolderWithUserFolder.java b/forge-core/src/main/java/forge/util/storage/StorageReaderRecursiveFolderWithUserFolder.java index af9d9e1d59a..12d22fc43e0 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageReaderRecursiveFolderWithUserFolder.java +++ b/forge-core/src/main/java/forge/util/storage/StorageReaderRecursiveFolderWithUserFolder.java @@ -28,8 +28,7 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; - -import com.google.common.base.Function; +import java.util.function.Function; import forge.util.TextUtil; diff --git a/forge-game/src/main/java/forge/game/GameType.java b/forge-game/src/main/java/forge/game/GameType.java index 87aebe39cc7..73522612ed1 100644 --- a/forge-game/src/main/java/forge/game/GameType.java +++ b/forge-game/src/main/java/forge/game/GameType.java @@ -2,9 +2,9 @@ import java.util.EnumSet; import java.util.Set; +import java.util.function.Function; import com.google.common.base.Enums; -import com.google.common.base.Function; import forge.StaticData; import forge.deck.CardPool; diff --git a/forge-game/src/main/java/forge/game/player/PlayerCollection.java b/forge-game/src/main/java/forge/game/player/PlayerCollection.java index 9bf5da78ba4..adbd323760d 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerCollection.java +++ b/forge-game/src/main/java/forge/game/player/PlayerCollection.java @@ -2,10 +2,9 @@ import java.util.Collections; import java.util.Comparator; +import java.util.function.Function; import java.util.function.Predicate; -import com.google.common.base.Function; - import forge.game.card.CardCollection; import forge.game.zone.ZoneType; import forge.util.Aggregates; diff --git a/forge-gui-desktop/src/main/java/forge/GuiDesktop.java b/forge-gui-desktop/src/main/java/forge/GuiDesktop.java index aa014356e91..11a3a2d86c2 100644 --- a/forge-gui-desktop/src/main/java/forge/GuiDesktop.java +++ b/forge-gui-desktop/src/main/java/forge/GuiDesktop.java @@ -15,6 +15,7 @@ import java.net.URISyntaxException; import java.util.Collection; import java.util.List; +import java.util.function.Function; import javax.swing.ImageIcon; import javax.swing.JFileChooser; @@ -22,8 +23,6 @@ import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Function; - import forge.download.GuiDownloader; import forge.error.BugReportDialog; import forge.gamemodes.match.HostedMatch; diff --git a/forge-gui-desktop/src/main/java/forge/gui/GuiChoose.java b/forge-gui-desktop/src/main/java/forge/gui/GuiChoose.java index 243f33ff111..a23e06dc9a8 100644 --- a/forge-gui-desktop/src/main/java/forge/gui/GuiChoose.java +++ b/forge-gui-desktop/src/main/java/forge/gui/GuiChoose.java @@ -7,14 +7,13 @@ import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.FutureTask; +import java.util.function.Function; import javax.swing.JList; import javax.swing.WindowConstants; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Function; - import forge.card.CardStateName; import forge.card.ICardFace; import forge.game.card.Card; diff --git a/forge-gui-desktop/src/main/java/forge/gui/ListChooser.java b/forge-gui-desktop/src/main/java/forge/gui/ListChooser.java index b18e247897d..9a9c5c6fdf8 100644 --- a/forge-gui-desktop/src/main/java/forge/gui/ListChooser.java +++ b/forge-gui-desktop/src/main/java/forge/gui/ListChooser.java @@ -25,6 +25,7 @@ import java.awt.event.MouseEvent; import java.util.Collection; import java.util.List; +import java.util.function.Function; import javax.swing.AbstractListModel; import javax.swing.DefaultListCellRenderer; @@ -36,7 +37,6 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/views/ItemTableColumn.java b/forge-gui-desktop/src/main/java/forge/itemmanager/views/ItemTableColumn.java index 9e7dd780491..73fc2fdfcdd 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/views/ItemTableColumn.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/views/ItemTableColumn.java @@ -19,11 +19,10 @@ import java.util.Map; import java.util.Map.Entry; +import java.util.function.Function; import javax.swing.table.TableColumn; -import com.google.common.base.Function; - import forge.item.InventoryItem; import forge.itemmanager.ColumnDef; import forge.itemmanager.ItemColumn; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java index c04ce187f76..628e2f0ab2e 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java @@ -22,11 +22,11 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.function.Function; import java.util.function.Predicate; import javax.swing.KeyStroke; -import com.google.common.base.Function; import com.google.common.base.Supplier; import forge.card.CardRules; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuestLimited.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuestLimited.java index 5fcec2205d6..400f10274f5 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuestLimited.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuestLimited.java @@ -22,8 +22,8 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.function.Function; -import com.google.common.base.Function; import com.google.common.base.Supplier; import forge.deck.Deck; diff --git a/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java b/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java index 2702fa4ed7c..d086a053132 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java +++ b/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java @@ -29,6 +29,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Function; import javax.swing.JMenu; import javax.swing.JOptionPane; @@ -38,7 +39,6 @@ import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuListener; -import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; diff --git a/forge-gui-desktop/src/main/java/forge/screens/match/controllers/CField.java b/forge-gui-desktop/src/main/java/forge/screens/match/controllers/CField.java index de0fd786af8..2bb49c8c518 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/match/controllers/CField.java +++ b/forge-gui-desktop/src/main/java/forge/screens/match/controllers/CField.java @@ -20,8 +20,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; - -import com.google.common.base.Function; +import java.util.function.Function; import forge.game.player.PlayerView; import forge.game.zone.ZoneType; diff --git a/forge-gui-desktop/src/main/java/forge/toolbox/special/PlayerDetailsPanel.java b/forge-gui-desktop/src/main/java/forge/toolbox/special/PlayerDetailsPanel.java index b93c68cc303..61ca9821d8a 100644 --- a/forge-gui-desktop/src/main/java/forge/toolbox/special/PlayerDetailsPanel.java +++ b/forge-gui-desktop/src/main/java/forge/toolbox/special/PlayerDetailsPanel.java @@ -6,6 +6,7 @@ import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.List; +import java.util.function.Function; import javax.swing.JPanel; import javax.swing.SwingConstants; @@ -13,8 +14,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.base.Function; - import forge.card.mana.ManaAtom; import forge.game.player.PlayerView; import forge.localinstance.skin.FSkinProp; diff --git a/forge-gui-mobile/src/forge/GuiMobile.java b/forge-gui-mobile/src/forge/GuiMobile.java index ded55baea98..1b0ef7f1e70 100644 --- a/forge-gui-mobile/src/forge/GuiMobile.java +++ b/forge-gui-mobile/src/forge/GuiMobile.java @@ -3,7 +3,6 @@ import com.badlogic.gdx.Application.ApplicationType; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Texture; -import com.google.common.base.Function; import forge.adventure.stage.MapStage; import forge.assets.*; import forge.card.CardRenderer; @@ -32,6 +31,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.function.Function; public class GuiMobile implements IGuiBase { private final String assetsDir; diff --git a/forge-gui-mobile/src/forge/adventure/scene/AdventureDeckEditor.java b/forge-gui-mobile/src/forge/adventure/scene/AdventureDeckEditor.java index 528fc3a1fa3..5c30836fa13 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/AdventureDeckEditor.java +++ b/forge-gui-mobile/src/forge/adventure/scene/AdventureDeckEditor.java @@ -4,7 +4,6 @@ import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Align; -import com.google.common.base.Function; import forge.Forge; import forge.Graphics; import forge.adventure.data.AdventureEventData; @@ -40,6 +39,7 @@ import org.apache.commons.lang3.StringUtils; import java.util.*; +import java.util.function.Function; public class AdventureDeckEditor extends TabPageScreen { diff --git a/forge-gui-mobile/src/forge/itemmanager/ItemManager.java b/forge-gui-mobile/src/forge/itemmanager/ItemManager.java index 4e6e059dafb..e79add651a8 100644 --- a/forge-gui-mobile/src/forge/itemmanager/ItemManager.java +++ b/forge-gui-mobile/src/forge/itemmanager/ItemManager.java @@ -19,12 +19,12 @@ import java.util.*; import java.util.Map.Entry; +import java.util.function.Function; import java.util.function.Predicate; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.utils.Align; -import com.google.common.base.Function; import forge.Forge; import forge.Graphics; diff --git a/forge-gui-mobile/src/forge/itemmanager/SpellShopManager.java b/forge-gui-mobile/src/forge/itemmanager/SpellShopManager.java index 6202cff5591..20010bf7357 100644 --- a/forge-gui-mobile/src/forge/itemmanager/SpellShopManager.java +++ b/forge-gui-mobile/src/forge/itemmanager/SpellShopManager.java @@ -1,10 +1,10 @@ package forge.itemmanager; import java.util.Map.Entry; +import java.util.function.Function; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.utils.Align; -import com.google.common.base.Function; import forge.Forge; import forge.Graphics; diff --git a/forge-gui-mobile/src/forge/screens/match/MatchController.java b/forge-gui-mobile/src/forge/screens/match/MatchController.java index d8fe73d5ab8..ed63a73b1bb 100644 --- a/forge-gui-mobile/src/forge/screens/match/MatchController.java +++ b/forge-gui-mobile/src/forge/screens/match/MatchController.java @@ -4,6 +4,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.function.Function; import forge.adventure.scene.DuelScene; import forge.adventure.util.Config; @@ -15,7 +16,6 @@ import forge.util.collect.FCollection; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; diff --git a/forge-gui-mobile/src/forge/toolbox/GuiChoose.java b/forge-gui-mobile/src/forge/toolbox/GuiChoose.java index a1805aac4af..8f762fad64d 100644 --- a/forge-gui-mobile/src/forge/toolbox/GuiChoose.java +++ b/forge-gui-mobile/src/forge/toolbox/GuiChoose.java @@ -5,13 +5,12 @@ import java.util.Collection; import java.util.Comparator; import java.util.List; +import java.util.function.Function; import forge.Forge; import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Function; - import forge.game.card.CardView; import forge.util.Callback; diff --git a/forge-gui-mobile/src/forge/toolbox/ListChooser.java b/forge-gui-mobile/src/forge/toolbox/ListChooser.java index be3c84e5ab2..3c39bd4ee95 100644 --- a/forge-gui-mobile/src/forge/toolbox/ListChooser.java +++ b/forge-gui-mobile/src/forge/toolbox/ListChooser.java @@ -21,10 +21,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.function.Function; import java.util.function.Predicate; import com.badlogic.gdx.Input; -import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import forge.Forge; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/ProtocolMethod.java b/forge-gui/src/main/java/forge/gamemodes/net/ProtocolMethod.java index dc768de2cd8..b79ab45e7eb 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/ProtocolMethod.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/ProtocolMethod.java @@ -4,8 +4,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; - -import com.google.common.base.Function; +import java.util.function.Function; import forge.deck.CardPool; import forge.game.GameEntityView; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/server/NetGuiGame.java b/forge-gui/src/main/java/forge/gamemodes/net/server/NetGuiGame.java index 424a3345e36..4cfb1ffca80 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/server/NetGuiGame.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/server/NetGuiGame.java @@ -3,8 +3,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; - -import com.google.common.base.Function; +import java.util.function.Function; import forge.LobbyPlayer; import forge.ai.GameState; diff --git a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestData.java b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestData.java index ae7bee33b20..544a57e84db 100644 --- a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestData.java +++ b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestData.java @@ -26,8 +26,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; - -import com.google.common.base.Function; +import java.util.function.Function; import forge.card.CardDb; import forge.gamemodes.planarconquest.ConquestPreferences.CQPref; diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestSpellShop.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestSpellShop.java index 5f7c155944b..6d886fb7406 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestSpellShop.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestSpellShop.java @@ -5,11 +5,10 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.function.Function; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.base.Function; - import forge.deck.CardPool; import forge.deck.Deck; import forge.deck.DeckFormat; diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java index 461a867f00e..c25b131dc44 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java @@ -17,7 +17,6 @@ */ package forge.gamemodes.quest; -import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import forge.card.CardEdition; @@ -46,6 +45,7 @@ import java.util.Collections; import java.util.List; import java.util.Map.Entry; +import java.util.function.Function; import java.util.function.Predicate; /** diff --git a/forge-gui/src/main/java/forge/gui/interfaces/IGuiBase.java b/forge-gui/src/main/java/forge/gui/interfaces/IGuiBase.java index 98920318ef1..2d59447c630 100644 --- a/forge-gui/src/main/java/forge/gui/interfaces/IGuiBase.java +++ b/forge-gui/src/main/java/forge/gui/interfaces/IGuiBase.java @@ -5,8 +5,7 @@ import java.net.URISyntaxException; import java.util.Collection; import java.util.List; - -import com.google.common.base.Function; +import java.util.function.Function; import forge.gamemodes.match.HostedMatch; import forge.gui.download.GuiDownloadService; diff --git a/forge-gui/src/main/java/forge/gui/interfaces/IGuiGame.java b/forge-gui/src/main/java/forge/gui/interfaces/IGuiGame.java index bc435c703e1..935ec605a3d 100644 --- a/forge-gui/src/main/java/forge/gui/interfaces/IGuiGame.java +++ b/forge-gui/src/main/java/forge/gui/interfaces/IGuiGame.java @@ -3,8 +3,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; - -import com.google.common.base.Function; +import java.util.function.Function; import forge.LobbyPlayer; import forge.ai.GameState; diff --git a/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java b/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java index 54393930cc1..cbb78bfc42b 100644 --- a/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java +++ b/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java @@ -4,12 +4,11 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.function.Function; import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Function; - import forge.gui.GuiBase; public class SGuiChoose { diff --git a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java index 960fecbcb6e..43e4ab7ab2b 100644 --- a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java +++ b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java @@ -10,10 +10,10 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; -import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; diff --git a/forge-gui/src/main/java/forge/itemmanager/ColumnDef.java b/forge-gui/src/main/java/forge/itemmanager/ColumnDef.java index 50de4b41fbb..024717c3586 100644 --- a/forge-gui/src/main/java/forge/itemmanager/ColumnDef.java +++ b/forge-gui/src/main/java/forge/itemmanager/ColumnDef.java @@ -17,7 +17,6 @@ */ package forge.itemmanager; -import com.google.common.base.Function; import forge.card.*; import forge.card.mana.ManaCost; import forge.deck.DeckProxy; @@ -43,6 +42,7 @@ import java.util.HashSet; import java.util.Map.Entry; import java.util.Set; +import java.util.function.Function; public enum ColumnDef { /** diff --git a/forge-gui/src/main/java/forge/itemmanager/GroupDef.java b/forge-gui/src/main/java/forge/itemmanager/GroupDef.java index ba557ea993c..38a0ad87a24 100644 --- a/forge-gui/src/main/java/forge/itemmanager/GroupDef.java +++ b/forge-gui/src/main/java/forge/itemmanager/GroupDef.java @@ -4,8 +4,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Function; -import com.google.common.base.Function; import com.google.common.collect.Lists; import forge.card.CardEdition; diff --git a/forge-gui/src/main/java/forge/itemmanager/ItemColumn.java b/forge-gui/src/main/java/forge/itemmanager/ItemColumn.java index 1dc39740e31..3bb9a379ae9 100644 --- a/forge-gui/src/main/java/forge/itemmanager/ItemColumn.java +++ b/forge-gui/src/main/java/forge/itemmanager/ItemColumn.java @@ -19,8 +19,7 @@ import java.util.Map; import java.util.Map.Entry; - -import com.google.common.base.Function; +import java.util.function.Function; import forge.item.InventoryItem; import forge.itemmanager.ItemColumnConfig.SortState; diff --git a/forge-gui/src/main/java/forge/itemmanager/ItemColumnConfig.java b/forge-gui/src/main/java/forge/itemmanager/ItemColumnConfig.java index c4c8c550464..941d8cc0c8c 100644 --- a/forge-gui/src/main/java/forge/itemmanager/ItemColumnConfig.java +++ b/forge-gui/src/main/java/forge/itemmanager/ItemColumnConfig.java @@ -1,8 +1,7 @@ package forge.itemmanager; import java.util.Map.Entry; - -import com.google.common.base.Function; +import java.util.function.Function; import forge.item.InventoryItem; diff --git a/forge-gui/src/main/java/forge/model/FModel.java b/forge-gui/src/main/java/forge/model/FModel.java index eb341aad3d4..54a355fda21 100644 --- a/forge-gui/src/main/java/forge/model/FModel.java +++ b/forge-gui/src/main/java/forge/model/FModel.java @@ -17,7 +17,6 @@ */ package forge.model; -import com.google.common.base.Function; import com.google.common.collect.Maps; import forge.CardStorageReader; import forge.CardStorageReader.ProgressObserver; @@ -62,6 +61,7 @@ import java.io.File; import java.util.*; +import java.util.function.Function; /** * The default Model implementation for Forge. diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index 8fad25844d8..6b3542d9119 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -1,6 +1,5 @@ package forge.player; -import com.google.common.base.Function; import com.google.common.collect.*; import forge.LobbyPlayer; import forge.StaticData; @@ -76,6 +75,7 @@ import java.io.*; import java.util.*; import java.util.Map.Entry; +import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; From ecf25a8c00c90fcdee65b90eed8d0fa098057c77 Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 17:52:18 -0400 Subject: [PATCH 07/68] Guava migration - Migrate Optionals --- .../main/java/forge/game/GameEntityCounterTable.java | 10 +++++----- .../forge/game/ability/effects/CountersPutEffect.java | 1 - .../game/ability/effects/ReplaceCounterEffect.java | 8 ++++---- .../src/main/java/forge/game/card/ActivationTable.java | 6 +++--- forge-game/src/main/java/forge/game/card/Card.java | 1 - .../java/forge/game/cost/CostRemoveAnyCounter.java | 5 ++--- .../java/forge/game/replacement/ReplaceAddCounter.java | 5 ++--- .../forge/game/replacement/ReplacementHandler.java | 9 +-------- 8 files changed, 17 insertions(+), 28 deletions(-) diff --git a/forge-game/src/main/java/forge/game/GameEntityCounterTable.java b/forge-game/src/main/java/forge/game/GameEntityCounterTable.java index 5813dfa7675..c9525fcde5f 100644 --- a/forge-game/src/main/java/forge/game/GameEntityCounterTable.java +++ b/forge-game/src/main/java/forge/game/GameEntityCounterTable.java @@ -1,10 +1,10 @@ package forge.game; import java.util.Map; +import java.util.Optional; import org.apache.commons.lang3.ObjectUtils; -import com.google.common.base.Optional; import com.google.common.collect.ForwardingTable; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Maps; @@ -39,7 +39,7 @@ protected Table, GameEntity, Map> delegat } public Integer put(Player putter, GameEntity object, CounterType type, Integer value) { - Optional o = Optional.fromNullable(putter); + Optional o = Optional.ofNullable(putter); Map map = get(o, object); if (map == null) { map = Maps.newHashMap(); @@ -49,7 +49,7 @@ public Integer put(Player putter, GameEntity object, CounterType type, Integer v } public int get(Player putter, GameEntity object, CounterType type) { - Optional o = Optional.fromNullable(putter); + Optional o = Optional.ofNullable(putter); Map map = get(o, object); if (map == null || !map.containsKey(type)) { return 0; @@ -76,7 +76,7 @@ public Map filterToRemove(GameEntity ge) { result.putAll(ge.getCounters()); return result; } - Map alreadyRemoved = column(ge).get(Optional.absent()); + Map alreadyRemoved = column(ge).get(Optional.empty()); for (Map.Entry e : ge.getCounters().entrySet()) { int rest = e.getValue() - (alreadyRemoved.getOrDefault(e.getKey(), 0)); if (rest > 0) { @@ -176,7 +176,7 @@ public boolean replaceCounterEffect(final Game game, final SpellAbility cause, f if (cause != null && cause.hasParam("MaxFromEffect")) { value = Math.min(value, Integer.parseInt(cause.getParam("MaxFromEffect")) - gm.getKey().getCounters(ec.getKey())); } - gm.getKey().addCounterInternal(ec.getKey(), value, e.getKey().orNull(), true, result, runParams); + gm.getKey().addCounterInternal(ec.getKey(), value, e.getKey().orElse(null), true, result, runParams); if (remember && ec.getValue() >= 1) { cause.getHostCard().addRemembered(gm.getKey()); } diff --git a/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java index d260e5b03b8..c8e0dbc1898 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java @@ -6,7 +6,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import com.google.common.base.Optional; import forge.game.Game; import forge.game.GameEntity; diff --git a/forge-game/src/main/java/forge/game/ability/effects/ReplaceCounterEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ReplaceCounterEffect.java index af1684b8d9c..3c5f810020f 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ReplaceCounterEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ReplaceCounterEffect.java @@ -3,8 +3,8 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Optional; -import com.google.common.base.Optional; import com.google.common.collect.HashMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; @@ -46,14 +46,14 @@ public void resolve(SpellAbility sa) { Multimap playerMap = HashMultimap.create(); for (Map.Entry, Map> e : counterTable.entrySet()) { for (CounterType ct : e.getValue().keySet()) { - playerMap.put(ct, e.getKey().orNull()); + playerMap.put(ct, e.getKey().orElse(null)); } } // there shouldn't be a case where one of the players is null, and the other is not for (Map.Entry> e : playerMap.asMap().entrySet()) { - Optional p = Optional.fromNullable(chooser.getController().chooseSingleEntityForEffect(new PlayerCollection(e.getValue()), sa, "Choose Player for " + e.getKey().getName(), null)); + Optional p = Optional.ofNullable(chooser.getController().chooseSingleEntityForEffect(new PlayerCollection(e.getValue()), sa, "Choose Player for " + e.getKey().getName(), null)); sa.setReplacingObject(AbilityKey.CounterNum, counterTable.get(p).get(e.getKey())); int value = AbilityUtils.calculateAmount(card, sa.getParam("Amount"), sa); @@ -65,7 +65,7 @@ public void resolve(SpellAbility sa) { } } else { for (Map.Entry, Map> e : counterTable.entrySet()) { - if (!sa.matchesValidParam("ValidSource", e.getKey().orNull())) { + if (!sa.matchesValidParam("ValidSource", e.getKey().orElse(null))) { continue; } diff --git a/forge-game/src/main/java/forge/game/card/ActivationTable.java b/forge-game/src/main/java/forge/game/card/ActivationTable.java index e2e5951c07e..1dad7571d12 100644 --- a/forge-game/src/main/java/forge/game/card/ActivationTable.java +++ b/forge-game/src/main/java/forge/game/card/ActivationTable.java @@ -1,10 +1,10 @@ package forge.game.card; import java.util.List; +import java.util.Optional; import org.apache.commons.lang3.ObjectUtils; -import com.google.common.base.Optional; import com.google.common.collect.ForwardingTable; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Lists; @@ -40,7 +40,7 @@ public void add(SpellAbility sa) { SpellAbility original = getOriginal(sa); if (original != null) { - Optional st = Optional.fromNullable(root.getGrantorStatic()); + Optional st = Optional.ofNullable(root.getGrantorStatic()); List activators = get(original, st); if (activators == null) { @@ -58,7 +58,7 @@ public Integer get(SpellAbility sa) { public List getActivators(SpellAbility sa) { SpellAbility root = sa.getRootAbility(); SpellAbility original = getOriginal(sa); - Optional st = Optional.fromNullable(root.getGrantorStatic()); + Optional st = Optional.ofNullable(root.getGrantorStatic()); if (contains(original, st)) { return get(original, st); diff --git a/forge-game/src/main/java/forge/game/card/Card.java b/forge-game/src/main/java/forge/game/card/Card.java index 54015c98e45..d809913d244 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -18,7 +18,6 @@ package forge.game.card; import com.esotericsoftware.minlog.Log; -import com.google.common.base.Optional; import com.google.common.collect.*; import forge.GameCommand; import forge.StaticData; diff --git a/forge-game/src/main/java/forge/game/cost/CostRemoveAnyCounter.java b/forge-game/src/main/java/forge/game/cost/CostRemoveAnyCounter.java index 95818b6eff9..6ce057e4a98 100644 --- a/forge-game/src/main/java/forge/game/cost/CostRemoveAnyCounter.java +++ b/forge-game/src/main/java/forge/game/cost/CostRemoveAnyCounter.java @@ -19,8 +19,7 @@ import java.util.Map; import java.util.Map.Entry; - -import com.google.common.base.Optional; +import java.util.Optional; import forge.game.GameEntity; import forge.game.ability.AbilityUtils; @@ -119,7 +118,7 @@ public final String toString() { @Override public boolean payAsDecided(Player ai, PaymentDecision decision, SpellAbility ability, final boolean effect) { int removed = 0; - for (Entry> e : decision.counterTable.row(Optional.absent()).entrySet()) { + for (Entry> e : decision.counterTable.row(Optional.empty()).entrySet()) { for (Entry v : e.getValue().entrySet()) { removed += v.getValue(); e.getKey().subtractCounter(v.getKey(), v.getValue(), ai); diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceAddCounter.java b/forge-game/src/main/java/forge/game/replacement/ReplaceAddCounter.java index 875db95b822..9b600675aea 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceAddCounter.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceAddCounter.java @@ -1,11 +1,10 @@ package forge.game.replacement; import java.util.Map; +import java.util.Optional; import org.apache.commons.lang3.ObjectUtils; -import com.google.common.base.Optional; - import forge.game.ability.AbilityKey; import forge.game.card.Card; import forge.game.card.CounterType; @@ -85,7 +84,7 @@ public boolean hasAnyInCounterMap(Map runParams) { Map, Map> counterMap = (Map, Map>) runParams.get(AbilityKey.CounterMap); for (Map.Entry, Map> e : counterMap.entrySet()) { - if (!matchesValidParam("ValidSource", e.getKey().orNull())) { + if (!matchesValidParam("ValidSource", e.getKey().orElse(null))) { continue; } if (hasParam("ValidCounterType")) { diff --git a/forge-game/src/main/java/forge/game/replacement/ReplacementHandler.java b/forge-game/src/main/java/forge/game/replacement/ReplacementHandler.java index d01a1aed31c..e7dde774508 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplacementHandler.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplacementHandler.java @@ -17,19 +17,12 @@ */ package forge.game.replacement; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import forge.game.card.*; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; -import com.google.common.base.Optional; import com.google.common.collect.Lists; import com.google.common.collect.Sets; From 6a87768647b6d04986c32c4b82a60765b39871b7 Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 18:03:26 -0400 Subject: [PATCH 08/68] Guava migration - Migrate Suppliers --- .../src/main/java/forge/item/generation/IUnOpenedProduct.java | 3 +-- forge-core/src/main/java/forge/util/CollectionSuppliers.java | 2 +- forge-core/src/main/java/forge/util/maps/EnumMapOfLists.java | 3 +-- forge-core/src/main/java/forge/util/maps/HashMapOfLists.java | 3 +-- .../forge/screens/deckeditor/controllers/CEditorCommander.java | 2 +- .../screens/deckeditor/controllers/CEditorConstructed.java | 2 +- .../forge/screens/deckeditor/controllers/CEditorLimited.java | 3 +-- .../forge/screens/deckeditor/controllers/CEditorQuest.java | 3 +-- .../screens/deckeditor/controllers/CEditorQuestLimited.java | 3 +-- .../forge/screens/deckeditor/controllers/CEditorVariant.java | 2 +- .../forge/screens/deckeditor/controllers/DeckController.java | 2 +- forge-gui-mobile/src/forge/deck/FDeckEditor.java | 2 +- .../src/main/java/forge/gamemodes/limited/BoosterDraft.java | 2 +- .../src/main/java/forge/gamemodes/limited/WinstonDraft.java | 3 +-- 14 files changed, 14 insertions(+), 21 deletions(-) diff --git a/forge-core/src/main/java/forge/item/generation/IUnOpenedProduct.java b/forge-core/src/main/java/forge/item/generation/IUnOpenedProduct.java index d2bb054380f..e5bece9cbb5 100644 --- a/forge-core/src/main/java/forge/item/generation/IUnOpenedProduct.java +++ b/forge-core/src/main/java/forge/item/generation/IUnOpenedProduct.java @@ -1,8 +1,7 @@ package forge.item.generation; import java.util.List; - -import com.google.common.base.Supplier; +import java.util.function.Supplier; import forge.item.PaperCard; diff --git a/forge-core/src/main/java/forge/util/CollectionSuppliers.java b/forge-core/src/main/java/forge/util/CollectionSuppliers.java index 295b8439e20..f4ac83515e7 100644 --- a/forge-core/src/main/java/forge/util/CollectionSuppliers.java +++ b/forge-core/src/main/java/forge/util/CollectionSuppliers.java @@ -3,8 +3,8 @@ import java.util.List; import java.util.Set; import java.util.SortedSet; +import java.util.function.Supplier; -import com.google.common.base.Supplier; import com.google.common.collect.Lists; import com.google.common.collect.Sets; diff --git a/forge-core/src/main/java/forge/util/maps/EnumMapOfLists.java b/forge-core/src/main/java/forge/util/maps/EnumMapOfLists.java index 19b0293a506..59eb3cd3045 100644 --- a/forge-core/src/main/java/forge/util/maps/EnumMapOfLists.java +++ b/forge-core/src/main/java/forge/util/maps/EnumMapOfLists.java @@ -4,8 +4,7 @@ import java.util.EnumMap; import java.util.List; import java.util.Map; - -import com.google.common.base.Supplier; +import java.util.function.Supplier; public class EnumMapOfLists, V> extends EnumMap> implements MapOfLists { private final Supplier> factory; diff --git a/forge-core/src/main/java/forge/util/maps/HashMapOfLists.java b/forge-core/src/main/java/forge/util/maps/HashMapOfLists.java index 2e4fdf1b10e..d29d8a48079 100644 --- a/forge-core/src/main/java/forge/util/maps/HashMapOfLists.java +++ b/forge-core/src/main/java/forge/util/maps/HashMapOfLists.java @@ -4,8 +4,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - -import com.google.common.base.Supplier; +import java.util.function.Supplier; public class HashMapOfLists extends HashMap> implements MapOfLists { diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java index 737fe567692..1d8461e568e 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java @@ -17,7 +17,6 @@ */ package forge.screens.deckeditor.controllers; -import com.google.common.base.Supplier; import forge.card.CardDb; import forge.card.CardRules; import forge.card.CardRulesPredicates; @@ -45,6 +44,7 @@ import java.util.List; import java.util.Map.Entry; import java.util.function.Predicate; +import java.util.function.Supplier; /** * Child controller for constructed deck editor UI. diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorConstructed.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorConstructed.java index be000243440..a21837bf23e 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorConstructed.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorConstructed.java @@ -17,7 +17,6 @@ */ package forge.screens.deckeditor.controllers; -import com.google.common.base.Supplier; import forge.deck.CardPool; import forge.deck.Deck; import forge.deck.DeckSection; @@ -39,6 +38,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; +import java.util.function.Supplier; /** * Child controller for constructed deck editor UI. diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorLimited.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorLimited.java index 81cdbb05aa3..9ec74f4f94e 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorLimited.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorLimited.java @@ -22,8 +22,7 @@ import java.util.List; import java.util.Map.Entry; import java.util.Set; - -import com.google.common.base.Supplier; +import java.util.function.Supplier; import forge.card.CardEdition; import forge.deck.CardPool; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java index 628e2f0ab2e..74673727bd2 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java @@ -24,11 +24,10 @@ import java.util.Map.Entry; import java.util.function.Function; import java.util.function.Predicate; +import java.util.function.Supplier; import javax.swing.KeyStroke; -import com.google.common.base.Supplier; - import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.card.ColorSet; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuestLimited.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuestLimited.java index 400f10274f5..5f649ed3706 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuestLimited.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuestLimited.java @@ -23,8 +23,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.function.Function; - -import com.google.common.base.Supplier; +import java.util.function.Supplier; import forge.deck.Deck; import forge.deck.DeckGroup; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java index 413c90a67d1..228047427b5 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java @@ -17,7 +17,6 @@ */ package forge.screens.deckeditor.controllers; -import com.google.common.base.Supplier; import forge.deck.Deck; import forge.deck.DeckSection; import forge.game.GameType; @@ -40,6 +39,7 @@ import java.util.Map.Entry; import java.util.function.Predicate; +import java.util.function.Supplier; /** * Child controller for constructed deck editor UI. diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/DeckController.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/DeckController.java index 2e675b5afb5..402be59e46f 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/DeckController.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/DeckController.java @@ -17,7 +17,6 @@ */ package forge.screens.deckeditor.controllers; -import com.google.common.base.Supplier; import forge.StaticData; import forge.card.CardEdition; import forge.deck.*; @@ -38,6 +37,7 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.Map; +import java.util.function.Supplier; public class DeckController { private T model; diff --git a/forge-gui-mobile/src/forge/deck/FDeckEditor.java b/forge-gui-mobile/src/forge/deck/FDeckEditor.java index b128cdfac57..7687fa36bcb 100644 --- a/forge-gui-mobile/src/forge/deck/FDeckEditor.java +++ b/forge-gui-mobile/src/forge/deck/FDeckEditor.java @@ -3,7 +3,6 @@ import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Align; -import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import forge.Forge; import forge.Forge.KeyInputAdapter; @@ -40,6 +39,7 @@ import java.util.*; import java.util.Map.Entry; import java.util.function.Predicate; +import java.util.function.Supplier; import java.util.stream.Collectors; public class FDeckEditor extends TabPageScreen { diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java b/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java index c9b826452e1..66bf6d08410 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java @@ -17,7 +17,6 @@ */ package forge.gamemodes.limited; -import com.google.common.base.Supplier; import forge.StaticData; import forge.card.CardEdition; import forge.deck.CardPool; @@ -41,6 +40,7 @@ import java.io.File; import java.util.*; import java.util.function.Predicate; +import java.util.function.Supplier; /** * Booster Draft Format. diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java b/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java index 50d9fc79951..a4a26cecf06 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java @@ -4,8 +4,7 @@ import java.util.Collections; import java.util.List; import java.util.Stack; - -import com.google.common.base.Supplier; +import java.util.function.Supplier; import forge.deck.CardPool; import forge.deck.Deck; From 67f22c647dc77e8bd92797f422e0e5cb21941994 Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 18:16:25 -0400 Subject: [PATCH 09/68] Guava migration - Migrate `Lists.transform` --- .../java/forge/game/ability/AbilityFactory.java | 3 ++- .../java/forge/game/ability/effects/PumpEffect.java | 5 +++-- .../src/main/java/forge/game/card/CardFactory.java | 3 ++- .../game/staticability/StaticAbilityContinuous.java | 13 +++++++------ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ability/AbilityFactory.java b/forge-game/src/main/java/forge/game/ability/AbilityFactory.java index 74f19dc7535..38b75ef0066 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityFactory.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityFactory.java @@ -37,6 +37,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** *

@@ -285,7 +286,7 @@ else if (api == ApiType.PermanentCreature || api == ApiType.PermanentNoncreature final String key = "Choices"; if (mapParams.containsKey(key)) { List names = Lists.newArrayList(mapParams.get(key).split(",")); - spellAbility.setAdditionalAbilityList(key, Lists.transform(names, input -> getSubAbility(state, input, sVarHolder))); + spellAbility.setAdditionalAbilityList(key, names.stream().map(input -> getSubAbility(state, input, sVarHolder)).collect(Collectors.toList())); } } diff --git a/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java index 964850c9df8..3afd2a78682 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import forge.util.*; import org.apache.commons.lang3.StringUtils; @@ -479,7 +480,7 @@ public void resolve(final SpellAbility sa) { return false; }); - affectedKeywords = Lists.transform(affectedKeywords, input -> { + affectedKeywords = affectedKeywords.stream().map(input -> { if (input.contains("CardManaCost")) { input = input.replace("CardManaCost", tgtC.getManaCost().getShortString()); } else if (input.contains("ConvertedManaCost")) { @@ -487,7 +488,7 @@ public void resolve(final SpellAbility sa) { input = input.replace("ConvertedManaCost", costcmc); } return input; - }); + }).collect(Collectors.toList()); } if (sa.hasParam("NumAtt") && sa.getParam("NumAtt").equals("Double")) { diff --git a/forge-game/src/main/java/forge/game/card/CardFactory.java b/forge-game/src/main/java/forge/game/card/CardFactory.java index dbf3ab681e5..d3f7023543e 100644 --- a/forge-game/src/main/java/forge/game/card/CardFactory.java +++ b/forge-game/src/main/java/forge/game/card/CardFactory.java @@ -45,6 +45,7 @@ import java.util.*; import java.util.Map.Entry; +import java.util.stream.Collectors; /** *

@@ -442,7 +443,7 @@ public static void copySpellAbility(SpellAbility from, SpellAbility to, final Ca to.setAdditionalAbility(e.getKey(), e.getValue().copy(host, p, lki, keepTextChanges)); } for (Map.Entry> e : from.getAdditionalAbilityLists().entrySet()) { - to.setAdditionalAbilityList(e.getKey(), Lists.transform(e.getValue(), input -> (AbilitySub) input.copy(host, p, lki, keepTextChanges))); + to.setAdditionalAbilityList(e.getKey(), e.getValue().stream().map(input -> (AbilitySub) input.copy(host, p, lki, keepTextChanges)).collect(Collectors.toList())); } if (from.getRestrictions() != null) { to.setRestrictions((SpellAbilityRestriction) from.getRestrictions().copy()); diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java index c7cd4308637..78b0ce238e6 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java @@ -43,6 +43,7 @@ import org.apache.commons.lang3.StringUtils; import java.util.*; +import java.util.stream.Collectors; /** * The Class StaticAbility_Continuous. @@ -258,7 +259,7 @@ public static CardCollectionView applyContinuousAbility(final StaticAbility stAb addKeywords.addAll(newKeywords); - addKeywords = Lists.transform(addKeywords, input -> { + addKeywords = addKeywords.stream().map(input -> { if (hostCard.hasChosenColor()) { input = input.replaceAll("ChosenColor", StringUtils.capitalize(hostCard.getChosenColor())); input = input.replaceAll("chosenColor", hostCard.getChosenColor().toLowerCase()); @@ -287,7 +288,7 @@ public static CardCollectionView applyContinuousAbility(final StaticAbility stAb input = input.replace("N", String.valueOf(AbilityUtils.calculateAmount(hostCard, params.get("CalcKeywordN"), stAb))); } return input; - }); + }).collect(Collectors.toList()); if (params.containsKey("SharedKeywordsZone")) { List zones = ZoneType.listValueOf(params.get("SharedKeywordsZone")); @@ -398,7 +399,7 @@ public static CardCollectionView applyContinuousAbility(final StaticAbility stAb }); addTypes.addAll(newTypes); - addTypes = Lists.transform(addTypes, input -> { + addTypes = addTypes.stream().map(input -> { if (hostCard.hasChosenType2()) { input = input.replaceAll("ChosenType2", hostCard.getChosenType2()); } @@ -406,7 +407,7 @@ public static CardCollectionView applyContinuousAbility(final StaticAbility stAb input = input.replaceAll("ChosenType", hostCard.getChosenType()); } return input; - }); + }).collect(Collectors.toList()); } if (params.containsKey("RemoveType")) { @@ -740,7 +741,7 @@ public static CardCollectionView applyContinuousAbility(final StaticAbility stAb }); newKeywords.addAll(extraKeywords); - newKeywords = Lists.transform(newKeywords, input -> { + newKeywords = newKeywords.stream().map(input -> { if (input.contains("CardManaCost")) { input = input.replace("CardManaCost", affectedCard.getManaCost().getShortString()); } else if (input.contains("ConvertedManaCost")) { @@ -748,7 +749,7 @@ public static CardCollectionView applyContinuousAbility(final StaticAbility stAb input = input.replace("ConvertedManaCost", costcmc); } return input; - }); + }).collect(Collectors.toList()); } affectedCard.addChangedCardKeywords(newKeywords, removeKeywords, From a070feefb2e37af055d0e3bb1f9a3d1f61ba6c12 Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 18:19:04 -0400 Subject: [PATCH 10/68] Guava migration - Remove forwarding overloads --- .../src/main/java/forge/util/Iterables.java | 33 +----------- .../src/main/java/forge/util/Predicates.java | 54 +++---------------- 2 files changed, 7 insertions(+), 80 deletions(-) diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index c00a71ea200..8bc95859e66 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -57,6 +57,7 @@ public static int indexOf(Iterable iterable, Predicate predica public static Iterable transform(final Iterable iterable, final Function function) { //TODO: Collection input variant. Some usages use Lists.newArrayList on output which could be made part of the stream. + //Should probably also be ? extends T in the function type return () -> StreamSupport.stream(iterable.spliterator(), false).map(function).iterator(); } @@ -173,36 +174,4 @@ public static Iterable limit(final Iterable iterable, final int limitS public static boolean isEmpty(Iterable iterable) { return com.google.common.collect.Iterables.isEmpty(iterable); } - - - //TODO: Delete everything below. - public static Iterable filter(Iterable iterable, com.google.common.base.Predicate filter) { - return com.google.common.collect.Iterables.filter(iterable, filter); - } - public static boolean any(Iterable iterable, com.google.common.base.Predicate filter) { - return com.google.common.collect.Iterables.any(iterable, filter); - } - public static boolean all(Iterable iterable, com.google.common.base.Predicate filter) { - return com.google.common.collect.Iterables.any(iterable, filter); - } - public static boolean removeIf(Iterable iterable, com.google.common.base.Predicate test) { - return com.google.common.collect.Iterables.removeIf(iterable, test); - } - public static T find(Iterable iterable, com.google.common.base.Predicate predicate) { - return com.google.common.collect.Iterables.find(iterable, predicate); - } - public static T find(Iterable iterable, com.google.common.base.Predicate predicate, T defaultValue) { - return com.google.common.collect.Iterables.find(iterable, predicate, defaultValue); - } - public static com.google.common.base.Optional tryFind(Iterable iterable, com.google.common.base.Predicate predicate) { - return com.google.common.collect.Iterables.tryFind(iterable, predicate); - } - - public static int indexOf(Iterable iterable, com.google.common.base.Predicate predicate) { - return com.google.common.collect.Iterables.indexOf(iterable, predicate); - } - - public static Iterable transform(Iterable iterable, com.google.common.base.Function function) { - return com.google.common.collect.Iterables.transform(iterable, function); - } } diff --git a/forge-core/src/main/java/forge/util/Predicates.java b/forge-core/src/main/java/forge/util/Predicates.java index b44d50088b1..c69729fa1cf 100644 --- a/forge-core/src/main/java/forge/util/Predicates.java +++ b/forge-core/src/main/java/forge/util/Predicates.java @@ -60,56 +60,14 @@ public static Predicate or(Predicate first, Predicate Predicate equalTo(T target) { -// return x -> Objects.equals(target, x); -// } - -// public static Predicate instanceOf(Class clazz) { -// return clazz::isInstance; -// } -// public static Predicate in(Collection target) { -// return target::contains; -// } - - - - //TODO: Delete everything below. - public static com.google.common.base.Predicate not(com.google.common.base.Predicate predicate) { - return com.google.common.base.Predicates.not(predicate); - } - - public static com.google.common.base.Predicate and(Iterable> components) { - return com.google.common.base.Predicates.and(components); - } - public static com.google.common.base.Predicate and(com.google.common.base.Predicate... components) { - return com.google.common.base.Predicates.and(components); - } - public static com.google.common.base.Predicate and(com.google.common.base.Predicate first, com.google.common.base.Predicate second) { - return com.google.common.base.Predicates.and(first, second); - } - public static com.google.common.base.Predicate or(Iterable> components) { - return com.google.common.base.Predicates.or(components); - } - public static com.google.common.base.Predicate or(com.google.common.base.Predicate... components) { - return com.google.common.base.Predicates.or(components); - } - public static com.google.common.base.Predicate or(com.google.common.base.Predicate first, com.google.common.base.Predicate second) { - return com.google.common.base.Predicates.or(first, second); + public static Predicate equalTo(T target) { + return x -> Objects.equals(target, x); } - public static com.google.common.base.Predicate equalTo(T target) { - return com.google.common.base.Predicates.equalTo(target); + public static Predicate instanceOf(Class clazz) { + return clazz::isInstance; } - public static com.google.common.base.Predicate instanceOf(Class clazz) { - return com.google.common.base.Predicates.instanceOf(clazz); - } - public static com.google.common.base.Predicate in(Collection target) { - return com.google.common.base.Predicates.in(target); - } - - public static com.google.common.base.Predicate compose( - com.google.common.base.Predicate predicate, - com.google.common.base.Function function) { - return com.google.common.base.Predicates.compose(predicate, function); + public static Predicate in(Collection target) { + return target::contains; } } From 055dff71ce4e8d2df12a29ecb464e5795669a65b Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 19:36:39 -0400 Subject: [PATCH 11/68] Guava migration - Inline Predicate varargs methods --- .../java/forge/ai/AiAttackController.java | 8 ++++--- .../src/main/java/forge/ai/SpecialCardAi.java | 13 +++++++----- .../java/forge/ai/ability/ChooseSourceAi.java | 7 +++++-- .../java/forge/ai/ability/DamageDealAi.java | 8 +++++-- .../main/java/forge/ai/ability/MutateAi.java | 12 +++++------ .../java/forge/card/CardRulesPredicates.java | 9 +++++--- .../deck/generation/DeckGeneratorBase.java | 4 ++-- .../main/java/forge/item/ItemPredicate.java | 6 +++--- .../item/generation/BoosterGenerator.java | 21 +++++++++---------- .../src/main/java/forge/util/ItemPool.java | 2 +- .../src/main/java/forge/util/Predicates.java | 16 -------------- .../PlanarConquestCommanderGeneraterGA.java | 11 +++++----- .../PlanarConquestGeneraterGA.java | 9 ++++---- .../PlanarConquestTribalGeneraterGA.java | 11 +++++----- .../src/main/java/forge/deck/DeckgenUtil.java | 5 ++--- 15 files changed, 71 insertions(+), 71 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiAttackController.java b/forge-ai/src/main/java/forge/ai/AiAttackController.java index 44cb8791eae..6994fd30551 100644 --- a/forge-ai/src/main/java/forge/ai/AiAttackController.java +++ b/forge-ai/src/main/java/forge/ai/AiAttackController.java @@ -1390,9 +1390,11 @@ public final boolean shouldAttack(final Card attacker, final List defender boolean canTrampleOverDefenders = attacker.hasKeyword(Keyword.TRAMPLE) && attacker.getNetCombatDamage() > Aggregates.sum(validBlockers, Card::getNetToughness); // used to check that CanKillAllDangerous check makes sense in context where creatures with dangerous abilities are present - boolean dangerousBlockersPresent = Iterables.any(validBlockers, Predicates.or( - CardPredicates.hasKeyword(Keyword.WITHER), CardPredicates.hasKeyword(Keyword.INFECT), - CardPredicates.hasKeyword(Keyword.LIFELINK))); + boolean dangerousBlockersPresent = Iterables.any(validBlockers, + CardPredicates.hasKeyword(Keyword.WITHER) + .or(CardPredicates.hasKeyword(Keyword.INFECT)) + .or(CardPredicates.hasKeyword(Keyword.LIFELINK)) + ); // total power of the defending creatures, used in predicting whether a gang block can kill the attacker int defPower = CardLists.getTotalPower(validBlockers, true, false); diff --git a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java index 74818e0f4fd..e60d336706d 100644 --- a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java +++ b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java @@ -1442,11 +1442,14 @@ public static class SorinVengefulBloodlord { public static boolean consider(final Player ai, final SpellAbility sa) { int loyalty = sa.getHostCard().getCounters(CounterEnumType.LOYALTY); CardCollection creaturesToGet = CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), - Predicates.and(CardPredicates.Presets.CREATURES, CardPredicates.lessCMC(loyalty - 1), card -> { - final Card copy = CardCopyService.getLKICopy(card); - ComputerUtilCard.applyStaticContPT(ai.getGame(), copy, null); - return copy.getNetToughness() > 0; - })); + CardPredicates.Presets.CREATURES + .and(CardPredicates.lessCMC(loyalty - 1)) + .and(card -> { + final Card copy = CardCopyService.getLKICopy(card); + ComputerUtilCard.applyStaticContPT(ai.getGame(), copy, null); + return copy.getNetToughness() > 0; + }) + ); CardLists.sortByCmcDesc(creaturesToGet); if (creaturesToGet.isEmpty()) { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java index 00e3897a962..af422a05b0c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java @@ -136,8 +136,11 @@ public Card chooseSingleCard(final Player aiChoser, SpellAbility sa, Iterable oppCreatures = CardLists.filter(options, Predicates.and(CardPredicates.Presets.CREATURES, Predicates.not(CardPredicates.isOwner(aiChoser)))); - List aiNonCreatures = CardLists.filter(options, Predicates.and(Predicates.not(CardPredicates.Presets.CREATURES), - CardPredicates.Presets.PERMANENTS, CardPredicates.isOwner(aiChoser))); + List aiNonCreatures = CardLists.filter(options, + Predicates.not(CardPredicates.Presets.CREATURES) + .and(CardPredicates.Presets.PERMANENTS) + .and(CardPredicates.isOwner(aiChoser)) + ); if (!oppCreatures.isEmpty()) { return ComputerUtilCard.getBestCreatureAI(oppCreatures); diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java index 5061ce21dba..b75d7351c8c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java @@ -892,7 +892,11 @@ private boolean damageChooseRequiredTargets(final Player ai, final SpellAbility // See if there's an indestructible target that can be used CardCollection indestructible = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), - Predicates.and(CardPredicates.Presets.CREATURES, CardPredicates.Presets.PLANESWALKERS, CardPredicates.hasKeyword(Keyword.INDESTRUCTIBLE), CardPredicates.isTargetableBy(sa))); + CardPredicates.Presets.CREATURES + .and(CardPredicates.Presets.PLANESWALKERS) //TODO: Should this be "or" Planeswalkers? + .and(CardPredicates.hasKeyword(Keyword.INDESTRUCTIBLE)) + .and(CardPredicates.isTargetableBy(sa)) + ); if (!indestructible.isEmpty()) { Card c = ComputerUtilCard.getWorstPermanentAI(indestructible, false, false, false, false); @@ -905,7 +909,7 @@ private boolean damageChooseRequiredTargets(final Player ai, final SpellAbility } else if (tgt.canTgtPlaneswalker()) { // Second pass for planeswalkers: choose AI's worst planeswalker - final Card c = ComputerUtilCard.getWorstPlaneswalkerToDamage(CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Predicates.and(CardPredicates.Presets.PLANESWALKERS), CardPredicates.isTargetableBy(sa))); + final Card c = ComputerUtilCard.getWorstPlaneswalkerToDamage(CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANESWALKERS, CardPredicates.isTargetableBy(sa))); if (c != null) { sa.getTargets().add(c); if (divided) { diff --git a/forge-ai/src/main/java/forge/ai/ability/MutateAi.java b/forge-ai/src/main/java/forge/ai/ability/MutateAi.java index 2c1abf84698..c5086824cf3 100644 --- a/forge-ai/src/main/java/forge/ai/ability/MutateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/MutateAi.java @@ -23,12 +23,12 @@ protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { // Filter out some abilities that are useless // TODO: add other stuff useless for Mutate here - mutateTgts = CardLists.filter(mutateTgts, Predicates.not(Predicates.or( - CardPredicates.hasKeyword(Keyword.DEFENDER), - CardPredicates.hasKeyword("CARDNAME can't attack."), - CardPredicates.hasKeyword("CARDNAME can't block."), - card -> ComputerUtilCard.isUselessCreature(aiPlayer, card) - ))); + mutateTgts = CardLists.filter(mutateTgts, Predicates.not( + CardPredicates.hasKeyword(Keyword.DEFENDER) + .or(CardPredicates.hasKeyword("CARDNAME can't attack.")) + .or(CardPredicates.hasKeyword("CARDNAME can't block.")) + .or(card -> ComputerUtilCard.isUselessCreature(aiPlayer, card)) + )); if (mutateTgts.isEmpty()) { return false; diff --git a/forge-core/src/main/java/forge/card/CardRulesPredicates.java b/forge-core/src/main/java/forge/card/CardRulesPredicates.java index 7492ba47fd0..121e2b48502 100644 --- a/forge-core/src/main/java/forge/card/CardRulesPredicates.java +++ b/forge-core/src/main/java/forge/card/CardRulesPredicates.java @@ -584,9 +584,12 @@ public static class Presets { Predicates.or(Presets.IS_CREATURE, Presets.IS_PLANESWALKER)); /** The Constant IS_NON_CREATURE_SPELL. **/ - public static final Predicate IS_NON_CREATURE_SPELL = Predicates - .or(Presets.IS_SORCERY, Presets.IS_INSTANT, Presets.IS_PLANESWALKER, Presets.IS_ENCHANTMENT, - Predicates.and(Presets.IS_ARTIFACT, Predicates.not(Presets.IS_CREATURE))); + public static final Predicate IS_NON_CREATURE_SPELL = + Presets.IS_SORCERY + .or(Presets.IS_INSTANT) + .or(Presets.IS_PLANESWALKER) + .or(Presets.IS_ENCHANTMENT) //TODO: Battles? Is testing these one by one really the best way to check "non-creature"? + .or(Presets.IS_ARTIFACT.and(Presets.IS_CREATURE.negate())); /** The Constant isWhite. */ public static final Predicate IS_WHITE = CardRulesPredicates.isColor(MagicColor.WHITE); diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index 3b8fd8cab97..49175708333 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -291,7 +291,7 @@ protected Iterable selectCardsOfMatchingColorForPlayer(boolean forAi) if (useArtifacts) { hasColor = Predicates.or(hasColor, COLORLESS_CARDS); } - return Iterables.filter(pool.getAllCards(), Predicates.compose(Predicates.and(canPlay, hasColor, canUseInFormat), PaperCard::getRules)); + return Iterables.filter(pool.getAllCards(), Predicates.compose(canPlay.and(hasColor).and(canUseInFormat), PaperCard::getRules)); } protected static Map countLands(ItemPool outList) { @@ -390,7 +390,7 @@ protected List getDualLandList(Predicate canPlay) { Predicate dualLandFilter = CardRulesPredicates.coreType(true, CardType.CoreType.Land); Predicate exceptBasicLand = Predicates.not(CardRulesPredicates.Presets.IS_BASIC_LAND); - Iterable landCards = pool.getAllCards(Predicates.compose(Predicates.and(dualLandFilter, exceptBasicLand, canPlay), PaperCard::getRules)); + Iterable landCards = pool.getAllCards(Predicates.compose(dualLandFilter.and(exceptBasicLand).and(canPlay), PaperCard::getRules)); Iterable dualLandPatterns = Arrays.asList("Add \\{([WUBRG])\\} or \\{([WUBRG])\\}", "Add \\{([WUBRG])\\}, \\{([WUBRG])\\}, or \\{([WUBRG])\\}", "Add \\{([WUBRG])\\}\\{([WUBRG])\\}", diff --git a/forge-core/src/main/java/forge/item/ItemPredicate.java b/forge-core/src/main/java/forge/item/ItemPredicate.java index 29169cbfd24..bf6fd13f0cf 100644 --- a/forge-core/src/main/java/forge/item/ItemPredicate.java +++ b/forge-core/src/main/java/forge/item/ItemPredicate.java @@ -20,14 +20,14 @@ public abstract class ItemPredicate { * * @return the predicate */ - public static final Predicate IsTournamentPack = card -> card instanceof TournamentPack && !((TournamentPack) card).isStarterDeck(); + public static final Predicate IsTournamentPack = card -> card instanceof TournamentPack && !((TournamentPack) card).isStarterDeck(); /** * Checks that the inventory item is a Starter Deck. * * @return the predicate */ - public static final Predicate IsStarterDeck = card -> card instanceof TournamentPack && ((TournamentPack) card).isStarterDeck(); + public static final Predicate IsStarterDeck = card -> card instanceof TournamentPack && ((TournamentPack) card).isStarterDeck(); /** * Checks that the inventory item is a Prebuilt Deck. @@ -40,6 +40,6 @@ public abstract class ItemPredicate { */ public static class Presets { /** The Item IsPack. */ - public static final Predicate IS_PACK_OR_DECK = Predicates.or(IsBoosterPack, IsFatPack, IsTournamentPack, IsStarterDeck, IsPrebuiltDeck); + public static final Predicate IS_PACK_OR_DECK = IsBoosterPack.or(IsFatPack).or(IsTournamentPack).or(IsStarterDeck).or(IsPrebuiltDeck); } } diff --git a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java index 3f8d3fa1e48..4b49a0e2883 100644 --- a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java +++ b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java @@ -613,31 +613,31 @@ public static PrintSheet makeSheet(String sheetKey, Iterable src) { ps.addAll(Iterables.filter(src, predicate)); } else if (mainCode.equalsIgnoreCase(BoosterSlots.UNCOMMON_RARE)) { // for sets like ARN, where U1 cards are considered rare and U3 are uncommon - Predicate predicateRares = Predicates.and(setPred, IPaperCard.Predicates.Presets.IS_RARE, extraPred); + Predicate predicateRares = setPred.and(Presets.IS_RARE).and(extraPred); ps.addAll(Iterables.filter(src, predicateRares)); - Predicate predicateUncommon = Predicates.and( setPred, IPaperCard.Predicates.Presets.IS_UNCOMMON, extraPred); + Predicate predicateUncommon = setPred.and(Presets.IS_UNCOMMON).and(extraPred); ps.addAll(Iterables.filter(src, predicateUncommon), 3); } else if (mainCode.equalsIgnoreCase(BoosterSlots.RARE_MYTHIC)) { // Typical ratio of rares to mythics is 53:15, changing to 35:10 in smaller sets. // To achieve the desired 1:8 are all mythics are added once, and all rares added twice per print sheet. - Predicate predicateMythic = Predicates.and( setPred, IPaperCard.Predicates.Presets.IS_MYTHIC_RARE, extraPred); + Predicate predicateMythic = setPred.and(Presets.IS_MYTHIC_RARE).and(extraPred); ps.addAll(Iterables.filter(src, predicateMythic)); - Predicate predicateRare = Predicates.and( setPred, IPaperCard.Predicates.Presets.IS_RARE, extraPred); + Predicate predicateRare = setPred.and(Presets.IS_RARE).and(extraPred); ps.addAll(Iterables.filter(src, predicateRare), 2); } else if (mainCode.equalsIgnoreCase(BoosterSlots.UNCOMMON_RARE_MYTHIC)) { // Extended version of RARE_MYTHIC, used for Alchemy slots - Predicate predicateMythic = Predicates.and( setPred, IPaperCard.Predicates.Presets.IS_MYTHIC_RARE, extraPred); + Predicate predicateMythic = setPred.and(Presets.IS_MYTHIC_RARE).and(extraPred); ps.addAll(Iterables.filter(src, predicateMythic)); - Predicate predicateRare = Predicates.and( setPred, IPaperCard.Predicates.Presets.IS_RARE, extraPred); + Predicate predicateRare = setPred.and(Presets.IS_RARE).and(extraPred); ps.addAll(Iterables.filter(src, predicateRare), 2); - Predicate predicateUncommon = Predicates.and( setPred, IPaperCard.Predicates.Presets.IS_UNCOMMON, extraPred); + Predicate predicateUncommon = setPred.and(Presets.IS_UNCOMMON).and(extraPred); ps.addAll(Iterables.filter(src, predicateUncommon), 4); } else { throw new IllegalArgumentException("Booster generator: operator could not be parsed - " + mainCode); @@ -670,10 +670,9 @@ private static Predicate buildExtraPredicate(List operators) Predicate toAdd = null; if (operator.equalsIgnoreCase(BoosterSlots.DUAL_FACED_CARD)) { toAdd = Predicates.compose( - Predicates.or( - CardRulesPredicates.splitType(CardSplitType.Transform), - CardRulesPredicates.splitType(CardSplitType.Meld), - CardRulesPredicates.splitType(CardSplitType.Modal) + CardRulesPredicates.splitType(CardSplitType.Transform) + .or(CardRulesPredicates.splitType(CardSplitType.Meld)) + .or(CardRulesPredicates.splitType(CardSplitType.Modal) ), PaperCard::getRules); } else if (operator.equalsIgnoreCase(BoosterSlots.LAND)) { toAdd = Predicates.compose(CardRulesPredicates.Presets.IS_LAND, PaperCard::getRules); diff --git a/forge-core/src/main/java/forge/util/ItemPool.java b/forge-core/src/main/java/forge/util/ItemPool.java index 669663ad053..b3ab7cdae17 100644 --- a/forge-core/src/main/java/forge/util/ItemPool.java +++ b/forge-core/src/main/java/forge/util/ItemPool.java @@ -123,7 +123,7 @@ public int countAll(Predicate condition){ } @SuppressWarnings("unchecked") - public final int countAll(Predicate condition, Class cls) { + public final int countAll(Predicate condition, Class cls) { int count = 0; Map matchingKeys = Maps.filterKeys(this.items, item -> cls.isInstance(item) && (condition.test((U)item))); for (Integer i : matchingKeys.values()) { diff --git a/forge-core/src/main/java/forge/util/Predicates.java b/forge-core/src/main/java/forge/util/Predicates.java index c69729fa1cf..a737dff836b 100644 --- a/forge-core/src/main/java/forge/util/Predicates.java +++ b/forge-core/src/main/java/forge/util/Predicates.java @@ -1,6 +1,5 @@ package forge.util; -import java.util.Arrays; import java.util.Collection; import java.util.Objects; import java.util.function.Function; @@ -14,25 +13,10 @@ public static Predicate and(Iterable> comp //TODO: Should be able to clean up the casting here. return x -> Iterables.all(components, (Predicate>) i -> i.test(x)); } - public static Predicate and(Predicate... components) { - //TODO: Switch to iterables all once it stops being confused and the others are inlined. - //Or just switch this to chained "and"s by hand. - return x -> { - for(Predicate predicate : components) { - if(!predicate.test(x)) - return false; - } - return true; - }; - } public static Predicate or(Iterable> components) { //TODO: Should be able to clean up the casting here. return x -> Iterables.any(components, (Predicate>) i -> i.test(x)); } - public static Predicate or(Predicate... components) { - //TODO: Faster implementation. Or just do this one by hand. - return or(Arrays.asList(components)); - } public static Predicate compose(Predicate predicate, Function function) { return x -> predicate.test(function.apply(x)); diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java index 9d126931fc5..43f55d30bfd 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java @@ -75,11 +75,12 @@ protected void initializeCards(){ cards.add(StaticData.instance().getCommonCards().getUniqueByName(cardName)); } - Iterable filtered= Iterables.filter(cards, Predicates.and( - Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard::getRules), - Predicates.compose(CardRulesPredicates.Presets.IS_PLANESWALKER, PaperCard::getRules), - //Predicates.compose(CardRulesPredicates.Presets.IS_LEGENDARY, PaperCard.FN_GET_RULES), - gameFormat.getFilterPrinted())); + Iterable filtered= Iterables.filter(cards, + Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard::getRules) + .and(Predicates.compose(CardRulesPredicates.Presets.IS_PLANESWALKER, PaperCard::getRules)) + //.and(Predicates.compose(CardRulesPredicates.Presets.IS_LEGENDARY, PaperCard::getRules)) + .and(gameFormat.getFilterPrinted()) + ); List filteredList = Lists.newArrayList(filtered); rankedList = CardRanker.rankCardsInDeck(filteredList); diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java index 23efc3e1bf2..7a2534bfc25 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java @@ -105,10 +105,11 @@ protected void initializeCards(){ cards.add(StaticData.instance().getCommonCards().getUniqueByName(cardName)); } - Iterable filtered= Iterables.filter(cards, Predicates.and( - Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard::getRules), - Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard::getRules), - gameFormat.getFilterPrinted())); + Iterable filtered= Iterables.filter(cards, + Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard::getRules) + .and(Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard::getRules)) + .and(gameFormat.getFilterPrinted()) + ); List filteredList = Lists.newArrayList(filtered); setRankedList(CardRanker.rankCardsInDeck(filteredList)); diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java index 522006db748..59d110880b1 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java @@ -77,11 +77,12 @@ protected void initializeCards(){ cards.add(StaticData.instance().getCommonCards().getUniqueByName(cardName)); } - Iterable filteredTribe= Iterables.filter(cards, Predicates.and( - Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard::getRules), - Predicates.compose(CardRulesPredicates.hasCreatureType("Pirate"), PaperCard::getRules), - Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, PaperCard::getRules), - gameFormat.getFilterPrinted())); + Iterable filteredTribe= Iterables.filter(cards, + Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard::getRules) + .and(Predicates.compose(CardRulesPredicates.hasCreatureType("Pirate"), PaperCard::getRules)) + .and(Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, PaperCard::getRules)) + .and(gameFormat.getFilterPrinted()) + ); List filteredListTribe = Lists.newArrayList(filteredTribe); rankedList = CardRanker.rankCardsInDeck(filteredListTribe); diff --git a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java index 34befebff7f..4b8cf9a7a46 100644 --- a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java +++ b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java @@ -663,9 +663,8 @@ public static Deck generateCommanderDeck(boolean forAi, GameType gameType) { // Get random multicolor Legendary creature final DeckFormat format = gameType.getDeckFormat(); Predicate canPlay = forAi ? DeckGeneratorBase.AI_CAN_PLAY : CardRulesPredicates.IS_KEPT_IN_RANDOM_DECKS; - @SuppressWarnings("unchecked") - Iterable legends = cardDb.getAllCards(Predicates.and(format.isLegalCardPredicate(), format.isLegalCommanderPredicate(), - Predicates.compose(canPlay, PaperCard::getRules))); + Predicate legal = format.isLegalCardPredicate().and(format.isLegalCommanderPredicate()); + Iterable legends = cardDb.getAllCards(legal.and(Predicates.compose(canPlay, PaperCard::getRules))); commander = Aggregates.random(legends); return generateRandomCommanderDeck(commander, format, forAi, false); From 16c0fa10955fee42a62bb7d112df727a3c9aa454 Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 19:51:21 -0400 Subject: [PATCH 12/68] Guava migration - Fix lingering build errors --- forge-core/src/main/java/forge/card/CardDb.java | 2 +- forge-core/src/main/java/forge/card/CardEdition.java | 2 +- forge-core/src/main/java/forge/deck/CardPool.java | 3 +-- forge-core/src/main/java/forge/util/Iterables.java | 11 +++++------ .../src/main/java/forge/itemmanager/CardManager.java | 5 ++--- .../forge/itemmanager/filters/StatTypeFilter.java | 2 +- .../src/test/java/forge/card/LegacyCardDb.java | 2 +- .../src/forge/itemmanager/filters/StatTypeFilter.java | 2 +- .../main/java/forge/gamemodes/quest/QuestWorld.java | 2 +- .../src/main/java/forge/player/HumanCostDecision.java | 2 +- 10 files changed, 15 insertions(+), 18 deletions(-) diff --git a/forge-core/src/main/java/forge/card/CardDb.java b/forge-core/src/main/java/forge/card/CardDb.java index b04f7bc9268..b9722127833 100644 --- a/forge-core/src/main/java/forge/card/CardDb.java +++ b/forge-core/src/main/java/forge/card/CardDb.java @@ -46,7 +46,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool { private final String exlcudedCardSet = "DS0"; // need this to obtain cardReference by name+set+artindex - private final ListMultimap allCardsByName = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists()); + private final ListMultimap allCardsByName = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), Lists::newArrayList); private final Map uniqueCardsByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER); private final Map rulesByName; private final Map facesByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER); diff --git a/forge-core/src/main/java/forge/card/CardEdition.java b/forge-core/src/main/java/forge/card/CardEdition.java index 55bf06333ab..3126ea24a98 100644 --- a/forge-core/src/main/java/forge/card/CardEdition.java +++ b/forge-core/src/main/java/forge/card/CardEdition.java @@ -403,7 +403,7 @@ public List getAllCardsInSet() { public List getCardInSet(String cardName){ if (cardsInSetLookupMap == null) { // initialise - cardsInSetLookupMap = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists()); + cardsInSetLookupMap = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), Lists::newArrayList); List cardsInSet = this.getAllCardsInSet(); for (CardInSet cis : cardsInSet){ String key = cis.name; diff --git a/forge-core/src/main/java/forge/deck/CardPool.java b/forge-core/src/main/java/forge/deck/CardPool.java index 01772016527..698afc61771 100644 --- a/forge-core/src/main/java/forge/deck/CardPool.java +++ b/forge-core/src/main/java/forge/deck/CardPool.java @@ -25,7 +25,6 @@ import forge.card.CardEdition; import forge.item.IPaperCard; import forge.item.PaperCard; -import forge.util.CollectionSuppliers; import forge.util.ItemPool; import forge.util.ItemPoolSorter; import forge.util.MyRandom; @@ -205,7 +204,7 @@ public Map getCardEditionStatistics(boolean includeBasicLa */ public ListMultimap getCardEditionsGroupedByNumberOfCards(boolean includeBasicLands){ Map editionsFrequencyMap = this.getCardEditionStatistics(includeBasicLands); - ListMultimap reverseMap = Multimaps.newListMultimap(new HashMap<>(), CollectionSuppliers.arrayLists()); + ListMultimap reverseMap = Multimaps.newListMultimap(new HashMap<>(), Lists::newArrayList); for (Map.Entry entry : editionsFrequencyMap.entrySet()) reverseMap.put(entry.getValue(), entry.getKey()); return reverseMap; diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index 8bc95859e66..acc6fc365c7 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -79,9 +79,8 @@ public static T find(Collection iterable, Predicate predicate, return iterable.stream().filter(predicate).findFirst().orElse(defaultValue); } - public static boolean removeIf(Iterable iterable, Predicate test) { - //TODO: Convert parameter type - return ((Collection) iterable).removeIf(test); + public static boolean removeIf(Collection iterable, Predicate test) { + return iterable.removeIf(test); } public static boolean removeAll(Collection removeFrom, Collection toRemove) { @@ -105,14 +104,14 @@ public static void addAll(Collection collection, Iterable to } public static T getFirst(List iterable, T defaultValue) { - return iterable.isEmpty() ? defaultValue : iterable.getFirst(); + return iterable.isEmpty() ? defaultValue : iterable.get(0); } public static T getLast(List iterable) { - return iterable.getLast(); + return iterable.get(iterable.size() - 1); } public static T getLast(List iterable, T defaultValue) { - return iterable.isEmpty() ? defaultValue : iterable.getLast(); + return iterable.isEmpty() ? defaultValue : iterable.get(iterable.size() - 1); } public static boolean isEmpty(Collection iterable) { return iterable.isEmpty(); diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/CardManager.java b/forge-gui-desktop/src/main/java/forge/itemmanager/CardManager.java index 85cedb2def0..1b3f3100eb8 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/CardManager.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/CardManager.java @@ -16,7 +16,6 @@ import forge.screens.home.quest.DialogChooseFormats; import forge.screens.home.quest.DialogChooseSets; import forge.screens.match.controllers.CDetailPicture; -import forge.util.CollectionSuppliers; import forge.util.Iterables; import forge.util.Localizer; @@ -56,7 +55,7 @@ protected void buildAddFilterMenu(JMenu menu) { @Override protected Iterable> getUnique(Iterable> items) { ListMultimap> entriesByName = Multimaps.newListMultimap( - new TreeMap<>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists()); + new TreeMap<>(String.CASE_INSENSITIVE_ORDER), Lists::newArrayList); for (Entry item : items) { final String cardName = item.getKey().getName(); entriesByName.put(cardName, item); @@ -67,7 +66,7 @@ protected Iterable> getUnique(Iterable> entries = entriesByName.get(cardName); - ListMultimap> entriesByEdition = Multimaps.newListMultimap(new HashMap<>(), CollectionSuppliers.arrayLists()); + ListMultimap> entriesByEdition = Multimaps.newListMultimap(new HashMap<>(), Lists::newArrayList); for (Entry entry : entries) { CardEdition ed = StaticData.instance().getCardEdition(entry.getKey().getEdition()); if (ed != null) diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java index 6a16370a7e0..20a289ea65c 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java @@ -59,7 +59,7 @@ protected void addToggleButton(JPanel widget, final StatTypes st) { protected boolean showUnsupportedItem(U item) { FLabel btnPackOrDeck = buttonMap.get(StatTypes.PACK_OR_DECK); //support special pack/deck case if (btnPackOrDeck != null && btnPackOrDeck.isSelected()) { - return ItemPredicate.Presets.IS_PACK_OR_DECK.apply(item); + return ItemPredicate.Presets.IS_PACK_OR_DECK.test(item); } return false; } diff --git a/forge-gui-desktop/src/test/java/forge/card/LegacyCardDb.java b/forge-gui-desktop/src/test/java/forge/card/LegacyCardDb.java index 645e633cc67..ef33a9aa5b1 100644 --- a/forge-gui-desktop/src/test/java/forge/card/LegacyCardDb.java +++ b/forge-gui-desktop/src/test/java/forge/card/LegacyCardDb.java @@ -25,7 +25,7 @@ public class LegacyCardDb { public CardEdition.Collection editions; public ListMultimap allCardsByName = Multimaps - .newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists()); + .newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), Lists::newArrayList); public enum LegacySetPreference { Latest(false), LatestCoreExp(true), Earliest(false), EarliestCoreExp(true), Random(false); diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/StatTypeFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/StatTypeFilter.java index fe0d5715282..430f8f389e7 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/StatTypeFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/StatTypeFilter.java @@ -37,7 +37,7 @@ protected void addToggleButton(Widget widget, final StatTypes st) { protected boolean showUnsupportedItem(U item) { FLabel btnPackOrDeck = buttonMap.get(StatTypes.PACK_OR_DECK); //support special pack/deck case if (btnPackOrDeck != null && btnPackOrDeck.isSelected()) { - return ItemPredicate.Presets.IS_PACK_OR_DECK.apply(item); + return ItemPredicate.Presets.IS_PACK_OR_DECK.test(item); } return false; } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestWorld.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestWorld.java index fc49ea7bd9b..0d88191f078 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestWorld.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestWorld.java @@ -254,7 +254,7 @@ public static Set getAllQuestWorldsOfCard(PaperCard card) { if (format == null) { format = FModel.getQuest().getMainFormat(); } - if (format == null || format.getFilterRules().apply(card)) { + if (format == null || format.getFilterRules().test(card)) { result.add(qw); } } diff --git a/forge-gui/src/main/java/forge/player/HumanCostDecision.java b/forge-gui/src/main/java/forge/player/HumanCostDecision.java index 51b4d823977..150c6bbc379 100644 --- a/forge-gui/src/main/java/forge/player/HumanCostDecision.java +++ b/forge-gui/src/main/java/forge/player/HumanCostDecision.java @@ -896,7 +896,7 @@ public PaymentDecision visit(final CostReveal cost) { @Override protected boolean onCardSelected(final Card c, final List otherCardsToSelect, final ITriggerEvent triggerEvent) { final Card firstCard = Iterables.getFirst(this.selected, null); - if (firstCard != null && !CardPredicates.sharesColorWith(firstCard).apply(c)) { + if (firstCard != null && !CardPredicates.sharesColorWith(firstCard).test(c)) { return false; } return super.onCardSelected(c, otherCardsToSelect, triggerEvent); From 77ba9f1728652361e21e4bb17964f14d54ec6a5d Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 20:00:38 -0400 Subject: [PATCH 13/68] Guava migration - Inline `Predicates.alwaysTrue` --- .../src/main/java/forge/card/CardDb.java | 2 +- .../src/main/java/forge/item/IPaperCard.java | 4 ++-- .../item/generation/BoosterGenerator.java | 8 ++++---- .../src/main/java/forge/util/Predicates.java | 4 +--- .../ability/effects/ChooseCardNameEffect.java | 2 +- .../java/forge/game/card/CardFactoryUtil.java | 2 +- .../game/combat/AttackRestrictionType.java | 20 +++++++++---------- .../filters/CardCMCRangeFilter.java | 2 +- .../itemmanager/filters/CardPowerFilter.java | 2 +- .../filters/CardToughnessFilter.java | 2 +- .../itemmanager/filters/TextSearchFilter.java | 3 +-- .../itemmanager/filters/CardCMCFilter.java | 2 +- .../filters/CardColorlessCostFilter.java | 2 +- .../itemmanager/filters/CardFormatFilter.java | 3 +-- .../itemmanager/filters/CardPowerFilter.java | 2 +- .../filters/CardToughnessFilter.java | 2 +- .../itemmanager/filters/DeckFormatFilter.java | 3 +-- .../itemmanager/filters/TextSearchFilter.java | 3 +-- .../limited/CardThemedDeckBuilder.java | 2 +- .../planarconquest/ConquestRegion.java | 2 +- .../forge/gamemodes/quest/BoosterUtils.java | 2 +- .../forge/itemmanager/AdvancedSearch.java | 2 +- .../forge/itemmanager/BooleanExpression.java | 2 +- .../java/forge/itemmanager/SFilterUtil.java | 4 ++-- 24 files changed, 38 insertions(+), 44 deletions(-) diff --git a/forge-core/src/main/java/forge/card/CardDb.java b/forge-core/src/main/java/forge/card/CardDb.java index b9722127833..f4aaf1eb293 100644 --- a/forge-core/src/main/java/forge/card/CardDb.java +++ b/forge-core/src/main/java/forge/card/CardDb.java @@ -786,7 +786,7 @@ private PaperCard tryToGetCardFromEditions(String cardInfo, CardArtPreference ar List cards; Predicate cardQueryFilter; - filter = (filter != null) ? filter : Predicates.alwaysTrue(); + filter = filter != null ? filter : (x -> true); if (releaseDate != null) { cardQueryFilter = c -> { if (c.getArtIndex() != cr.artIndex) diff --git a/forge-core/src/main/java/forge/item/IPaperCard.java b/forge-core/src/main/java/forge/item/IPaperCard.java index c8dc407f148..cf544ff92f4 100644 --- a/forge-core/src/main/java/forge/item/IPaperCard.java +++ b/forge-core/src/main/java/forge/item/IPaperCard.java @@ -43,14 +43,14 @@ public static Predicate printedInSets(final String[] sets) { public static Predicate printedInSets(final List value, final boolean shouldContain) { if ((value == null) || value.isEmpty()) { - return forge.util.Predicates.alwaysTrue(); + return x -> true; } return new PredicateSets(value, shouldContain); } public static Predicate printedInSet(final String value) { if (StringUtils.isEmpty(value)) { - return forge.util.Predicates.alwaysTrue(); + return x -> true; } return new PredicateSets(Lists.newArrayList(value), true); } diff --git a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java index 4b49a0e2883..a9812e1cc83 100644 --- a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java +++ b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java @@ -568,7 +568,7 @@ public static void addCardsFromExtraSheet(List dest, String printShee public static PrintSheet makeSheet(String sheetKey, Iterable src) { PrintSheet ps = new PrintSheet(sheetKey); String[] sKey = TextUtil.splitWithParenthesis(sheetKey, ' ', 2); - Predicate setPred = (Predicate) (sKey.length > 1 ? IPaperCard.Predicates.printedInSets(sKey[1].split(" ")) : Predicates.alwaysTrue()); + Predicate setPred = sKey.length > 1 ? IPaperCard.Predicates.printedInSets(sKey[1].split(" ")) : x1 -> true; List operators = new LinkedList<>(Arrays.asList(TextUtil.splitWithParenthesis(sKey[0], ':'))); Predicate extraPred = buildExtraPredicate(operators); @@ -585,7 +585,7 @@ public static PrintSheet makeSheet(String sheetKey, Iterable src) { String sheetName = StringUtils.strip(mainCode.substring(10), "()\" "); System.out.println("Attempting to lookup: " + sheetName); src = StaticData.instance().getPrintSheets().get(sheetName).toFlatList(); - setPred = Predicates.alwaysTrue(); + setPred = x -> true; } else if (mainCode.startsWith("promo") || mainCode.startsWith("name")) { // get exactly the named cards, that's a tiny inlined print sheet String list = StringUtils.strip(mainCode.substring(5), "() "); @@ -597,7 +597,7 @@ public static PrintSheet makeSheet(String sheetKey, Iterable src) { } src = srcList; - setPred = Predicates.alwaysTrue(); + setPred = x -> true; } else { continue; } @@ -732,7 +732,7 @@ private static Predicate buildExtraPredicate(List operators) } if (conditions.isEmpty()) { - return Predicates.alwaysTrue(); + return x -> true; } return Predicates.and(conditions); diff --git a/forge-core/src/main/java/forge/util/Predicates.java b/forge-core/src/main/java/forge/util/Predicates.java index a737dff836b..829257b3a7a 100644 --- a/forge-core/src/main/java/forge/util/Predicates.java +++ b/forge-core/src/main/java/forge/util/Predicates.java @@ -24,9 +24,7 @@ public static Predicate compose(Predicate predicate, Function Predicate alwaysTrue() { - return x -> true; - } + public static Predicate not(Predicate predicate) { return predicate.negate(); } diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java index 8151c8f05a4..d8c34e1985a 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java @@ -112,7 +112,7 @@ public void resolve(SpellAbility sa) { } } else { // use CardFace because you might name a alternate names - Predicate cpp = Predicates.alwaysTrue(); + Predicate cpp = x -> true; if (sa.hasParam("ValidCards")) { //Calculating/replacing this must happen before running valid in CardFacePredicates if (valid.contains("cmcEQ") && !StringUtils.isNumeric(valid.split("cmcEQ")[1])) { diff --git a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java index b595ef7ae2e..61f6a3bddba 100644 --- a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java +++ b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java @@ -212,7 +212,7 @@ public static SpellAbility abilityTurnFaceUp(final CardState sourceCard, String public static boolean handleHiddenAgenda(Player player, Card card) { SpellAbility sa = new SpellAbility.EmptySa(card); sa.putParam("AILogic", card.getSVar("AgendaLogic")); - Predicate cpp = Predicates.alwaysTrue(); + Predicate cpp = x -> true; //Predicate pc = Predicates.in(player.getAllCards()); // TODO This would be better to send in the player's deck, not all cards String name = player.getController().chooseCardName(sa, cpp, "Card", diff --git a/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java b/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java index 9d85781054e..9cfd08e7ecf 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java +++ b/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java @@ -18,16 +18,16 @@ public enum AttackRestrictionType { public Predicate getPredicate(final Card attacker) { switch (this) { - case NEED_GREATER_POWER: - return CardPredicates.hasGreaterPowerThan(attacker.getNetPower()); - case NEED_BLACK_OR_GREEN: - return Predicates.and( - CardPredicates.isColor((byte) (MagicColor.BLACK | MagicColor.GREEN)), - // may explicitly not be black/green itself - Predicates.not(Predicates.equalTo(attacker))); - case NOT_ALONE: - return Predicates.alwaysTrue(); - default: + case NEED_GREATER_POWER: + return CardPredicates.hasGreaterPowerThan(attacker.getNetPower()); + case NEED_BLACK_OR_GREEN: + return Predicates.and( + CardPredicates.isColor((byte) (MagicColor.BLACK | MagicColor.GREEN)), + // may explicitly not be black/green itself + Predicates.not(Predicates.equalTo(attacker))); + case NOT_ALONE: + return x -> true; + default: } return null; } diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java index 7a6d01cfc09..3a69a6ee882 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java @@ -31,7 +31,7 @@ protected String getCaption() { protected Predicate buildPredicate() { Predicate predicate = getCardRulesFieldPredicate(CardRulesPredicates.LeafNumber.CardField.CMC); if (predicate == null) { - return Predicates.alwaysTrue(); + return x -> true; } return Predicates.compose(predicate, PaperCard::getRules); } diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java index 8a2ed8c7f87..e006b629b78 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java @@ -31,7 +31,7 @@ protected String getCaption() { protected Predicate buildPredicate() { Predicate predicate = getCardRulesFieldPredicate(CardRulesPredicates.LeafNumber.CardField.POWER); if (predicate == null) { - return Predicates.alwaysTrue(); + return x -> true; } predicate = Predicates.and(predicate, CardRulesPredicates.Presets.IS_CREATURE); return Predicates.compose(predicate, PaperCard::getRules); diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java index 5d10dc1760b..19bdd73cb3f 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java @@ -31,7 +31,7 @@ protected String getCaption() { protected Predicate buildPredicate() { Predicate predicate = getCardRulesFieldPredicate(CardRulesPredicates.LeafNumber.CardField.TOUGHNESS); if (predicate == null) { - return Predicates.alwaysTrue(); + return x -> true; } predicate = Predicates.and(predicate, CardRulesPredicates.Presets.IS_CREATURE); return Predicates.compose(predicate, PaperCard::getRules); diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TextSearchFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TextSearchFilter.java index ab536d9e2ec..c6973e10168 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TextSearchFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/TextSearchFilter.java @@ -14,7 +14,6 @@ import forge.toolbox.FTextField; import forge.toolbox.LayoutHelper; import forge.util.Localizer; -import forge.util.Predicates; public class TextSearchFilter extends ItemFilter { @@ -113,7 +112,7 @@ protected void applyChange() { protected Predicate buildPredicate() { String text = txtSearch.getText(); if (text.trim().isEmpty()) { - return Predicates.alwaysTrue(); + return x -> true; } return SFilterUtil.buildItemTextFilter(text); } diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java index 8ecdb69d97b..ee8116280c3 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java @@ -28,7 +28,7 @@ protected String getCaption() { protected Predicate buildPredicate() { Predicate predicate = getCardRulesFieldPredicate(CardRulesPredicates.LeafNumber.CardField.CMC); if (predicate == null) { - return Predicates.alwaysTrue(); + return x -> true; } return Predicates.compose(predicate, PaperCard::getRules); } diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java index 5ff7ac2897b..45add3f6db5 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java @@ -28,7 +28,7 @@ protected String getCaption() { protected Predicate buildPredicate() { Predicate predicate = getCardRulesFieldPredicate(CardRulesPredicates.LeafNumber.CardField.GENERIC_COST); if (predicate == null) { - return Predicates.alwaysTrue(); + return x -> true; } return Predicates.compose(predicate, PaperCard::getRules); } diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardFormatFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardFormatFilter.java index 36abb625625..3dfe6012ad3 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardFormatFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardFormatFilter.java @@ -2,7 +2,6 @@ import forge.item.PaperCard; import forge.itemmanager.ItemManager; -import forge.util.Predicates; import java.util.function.Predicate; @@ -22,7 +21,7 @@ public ItemFilter createCopy() { @Override protected final Predicate buildPredicate() { if (format == null) { - return Predicates.alwaysTrue(); + return x -> true; } if (format.getName() == null) { return format.getFilterPrinted(); //if format is collection of sets, don't show reprints in other sets diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java index c23a7d3fe9e..1f0b1b0cfb4 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java @@ -28,7 +28,7 @@ protected String getCaption() { protected Predicate buildPredicate() { Predicate predicate = getCardRulesFieldPredicate(CardRulesPredicates.LeafNumber.CardField.POWER); if (predicate == null) { - return Predicates.alwaysTrue(); + return x -> true; } predicate = Predicates.and(predicate, CardRulesPredicates.Presets.IS_CREATURE); return Predicates.compose(predicate, PaperCard::getRules); diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java index 59d205164cf..a12822a890b 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java @@ -28,7 +28,7 @@ protected String getCaption() { protected Predicate buildPredicate() { Predicate predicate = getCardRulesFieldPredicate(CardRulesPredicates.LeafNumber.CardField.TOUGHNESS); if (predicate == null) { - return Predicates.alwaysTrue(); + return x -> true; } predicate = Predicates.and(predicate, CardRulesPredicates.Presets.IS_CREATURE); return Predicates.compose(predicate, PaperCard::getRules); diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/DeckFormatFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/DeckFormatFilter.java index 1e4b7ee55f0..fc44a46fc2b 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/DeckFormatFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/DeckFormatFilter.java @@ -2,7 +2,6 @@ import forge.deck.DeckProxy; import forge.itemmanager.ItemManager; -import forge.util.Predicates; import java.util.function.Predicate; @@ -22,7 +21,7 @@ public ItemFilter createCopy() { @Override protected final Predicate buildPredicate() { if (format == null) { - return Predicates.alwaysTrue(); + return x -> true; } return input -> format.isDeckLegal(input.getDeck()); } diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/TextSearchFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/TextSearchFilter.java index d2d7b658d62..63bb93efa66 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/TextSearchFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/TextSearchFilter.java @@ -10,7 +10,6 @@ import forge.itemmanager.SFilterUtil; import forge.toolbox.FDisplayObject; import forge.toolbox.FTextField; -import forge.util.Predicates; import java.util.function.Predicate; @@ -63,7 +62,7 @@ protected void doWidgetLayout(float width, float height) { protected Predicate buildPredicate() { String text = txtSearch.getText(); if (text.trim().isEmpty()) { - return Predicates.alwaysTrue(); + return x -> true; } return SFilterUtil.buildItemTextFilter(text); } diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java index 7a9d9505d26..5cce5a4d3be 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java @@ -278,7 +278,7 @@ public Deck buildDeck() { addLandKeyCards(); // 8. Add non-basic lands - List duals = getDualLandList(isForAI ? CardRulesPredicates.IS_KEPT_IN_AI_DECKS : Predicates.alwaysTrue()); + List duals = getDualLandList(isForAI ? CardRulesPredicates.IS_KEPT_IN_AI_DECKS : x -> true); addNonBasicLands(); if (logToConsole) { System.out.println("Post Nonbasic lands : " + deckList.size()); diff --git a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java index b1c8ff0c0e4..22fa9d04ffe 100644 --- a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java +++ b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java @@ -106,7 +106,7 @@ protected ConquestRegion read(String line) { String name = null; String artCardName = null; ColorSet colorSet = ColorSet.ALL_COLORS; - Predicate pred = Predicates.alwaysTrue(); + Predicate pred = x -> true; String key, value; String[] pieces = line.split("\\|"); diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java index c41f4311df7..9f40533d9ff 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java @@ -126,7 +126,7 @@ public static List getQuestStarterDeck(final GameFormat formatStartin } - Predicate filter = Predicates.alwaysTrue(); + Predicate filter = x -> true; if (formatStartingPool != null) { filter = formatStartingPool.getFilterPrinted(); } diff --git a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java index 43e4ab7ab2b..792ed0a8ae4 100644 --- a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java +++ b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java @@ -1538,7 +1538,7 @@ public Model() { public Predicate getPredicate() { if (isEmpty()) { - return Predicates.alwaysTrue(); + return x -> true; } return getPredicatePiece(new ExpressionIterator()); } diff --git a/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java b/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java index fe6c057040f..b7ff9982213 100644 --- a/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java +++ b/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java @@ -162,7 +162,7 @@ private Predicate valueOf(final String value) { if (!predicates.isEmpty()) { return Predicates.or(predicates); } - return Predicates.alwaysTrue(); + return x -> true; } diff --git a/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java b/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java index 388fec5d5af..916d95a2566 100644 --- a/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java +++ b/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java @@ -41,7 +41,7 @@ public static Predicate buildTextFilter(String text, boolean invert, text = text.trim(); if (text.isEmpty()) { - return Predicates.alwaysTrue(); + return x -> true; } if (BooleanExpression.isExpression(text)) { @@ -117,7 +117,7 @@ private static List getSplitText(String text) { public static Predicate buildItemTextFilter(String text) { if (text.trim().isEmpty()) { - return Predicates.alwaysTrue(); + return x -> true; } return new ItemTextPredicate<>(text); From ef011d3f5144830b28a8bdaceac75627eb9eb956 Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 20:03:13 -0400 Subject: [PATCH 14/68] Guava migration - Inline `Predicates.instanceOf` --- forge-core/src/main/java/forge/item/ItemPredicate.java | 8 +++----- forge-core/src/main/java/forge/util/Predicates.java | 5 ----- .../main/java/forge/game/spellability/TargetChoices.java | 7 +++---- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/forge-core/src/main/java/forge/item/ItemPredicate.java b/forge-core/src/main/java/forge/item/ItemPredicate.java index bf6fd13f0cf..dc50933998a 100644 --- a/forge-core/src/main/java/forge/item/ItemPredicate.java +++ b/forge-core/src/main/java/forge/item/ItemPredicate.java @@ -1,7 +1,5 @@ package forge.item; -import forge.util.Predicates; - import java.util.function.Predicate; /** @@ -11,9 +9,9 @@ public abstract class ItemPredicate { // Static builder methods - they choose concrete implementation by themselves - public static final Predicate IsBoosterPack = Predicates.instanceOf(BoosterPack.class); - public static final Predicate IsPrebuiltDeck = Predicates.instanceOf(PreconDeck.class); - public static final Predicate IsFatPack = Predicates.instanceOf(FatPack.class); + public static final Predicate IsBoosterPack = BoosterPack.class::isInstance; + public static final Predicate IsPrebuiltDeck = PreconDeck.class::isInstance; + public static final Predicate IsFatPack = FatPack.class::isInstance; /** * Checks that the inventory item is a Tournament Pack. diff --git a/forge-core/src/main/java/forge/util/Predicates.java b/forge-core/src/main/java/forge/util/Predicates.java index 829257b3a7a..c7c1f4cb1a6 100644 --- a/forge-core/src/main/java/forge/util/Predicates.java +++ b/forge-core/src/main/java/forge/util/Predicates.java @@ -39,16 +39,11 @@ public static Predicate or(Predicate first, Predicate) first).or(second); } - //TODO: Uncomment all when switching off Guava. Then Inline. - //TODO: This one probably needs case by case; nullable targets need a safe test, whereas nonnull targets can be simplified further. public static Predicate equalTo(T target) { return x -> Objects.equals(target, x); } - public static Predicate instanceOf(Class clazz) { - return clazz::isInstance; - } public static Predicate in(Collection target) { return target::contains; } diff --git a/forge-game/src/main/java/forge/game/spellability/TargetChoices.java b/forge-game/src/main/java/forge/game/spellability/TargetChoices.java index 470f89ad06d..8bddc154f38 100644 --- a/forge-game/src/main/java/forge/game/spellability/TargetChoices.java +++ b/forge-game/src/main/java/forge/game/spellability/TargetChoices.java @@ -31,7 +31,6 @@ import forge.game.card.CardCollectionView; import forge.game.player.Player; import forge.util.Iterables; -import forge.util.Predicates; import forge.util.collect.FCollection; /** @@ -118,15 +117,15 @@ public final Iterable getTargetEntities() { } public final boolean isTargetingAnyCard() { - return Iterables.any(targets, Predicates.instanceOf(Card.class)); + return Iterables.any(targets, Card.class::isInstance); } public final boolean isTargetingAnyPlayer() { - return Iterables.any(targets, Predicates.instanceOf(Player.class)); + return Iterables.any(targets, Player.class::isInstance); } public final boolean isTargetingAnySpell() { - return Iterables.any(targets, Predicates.instanceOf(SpellAbility.class)); + return Iterables.any(targets, SpellAbility.class::isInstance); } public final Card getFirstTargetedCard() { From 4eb8fddfef811fbd3694ddd245f45c9de3b598f7 Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 2 Sep 2024 20:06:49 -0400 Subject: [PATCH 15/68] Guava migration - Inline `Predicates.in` --- forge-ai/src/main/java/forge/ai/ComputerUtil.java | 2 +- forge-ai/src/main/java/forge/ai/ComputerUtilCost.java | 2 +- forge-core/src/main/java/forge/util/Predicates.java | 4 ---- .../main/java/forge/gamemodes/net/server/FServerManager.java | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index bba4fd5265e..6f98328dc1c 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -2450,7 +2450,7 @@ public static CardCollection getCardsToDiscardFromOpponent(Player chooser, Playe // 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; } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java index 7da2db7aa8d..66316508a8d 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java @@ -924,7 +924,7 @@ public static int getMaxXValue(SpellAbility sa, Player ai, final boolean effect) public static CardCollection paymentChoicesWithoutTargets(Iterable 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); } diff --git a/forge-core/src/main/java/forge/util/Predicates.java b/forge-core/src/main/java/forge/util/Predicates.java index c7c1f4cb1a6..563d646e702 100644 --- a/forge-core/src/main/java/forge/util/Predicates.java +++ b/forge-core/src/main/java/forge/util/Predicates.java @@ -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 static Predicate equalTo(T target) { return x -> Objects.equals(target, x); } - public static Predicate in(Collection target) { - return target::contains; - } } diff --git a/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java b/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java index 683b6a5d2d9..6c559cb04ee 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java @@ -147,7 +147,7 @@ public void broadcastExcept(final NetEvent event, final RemoteClient notTo) { broadcastExcept(event, Collections.singleton(notTo)); } public void broadcastExcept(final NetEvent event, final Collection 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 to) { for (final RemoteClient client : to) { From 6b96bca83f7d4b3b5ce40316b9e3dece734d79f6 Mon Sep 17 00:00:00 2001 From: Jetz Date: Tue, 3 Sep 2024 08:54:18 -0400 Subject: [PATCH 16/68] Guava migration - Inline `Predicates.equalTo` --- forge-core/src/main/java/forge/util/Predicates.java | 6 ------ .../java/forge/game/ability/effects/ChangeZoneEffect.java | 2 +- .../src/main/java/forge/game/combat/AttackConstraints.java | 2 +- .../main/java/forge/game/combat/AttackRestrictionType.java | 2 +- .../main/java/forge/game/trigger/TriggerChangesZone.java | 5 +++-- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/forge-core/src/main/java/forge/util/Predicates.java b/forge-core/src/main/java/forge/util/Predicates.java index 563d646e702..3547e218b06 100644 --- a/forge-core/src/main/java/forge/util/Predicates.java +++ b/forge-core/src/main/java/forge/util/Predicates.java @@ -37,10 +37,4 @@ public static Predicate or(Predicate first, Predicate) first).or(second); } - - //TODO: This one probably needs case by case; nullable targets need a safe test, whereas nonnull targets can be simplified further. - public static Predicate equalTo(T target) { - return x -> Objects.equals(target, x); - } - } diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java index ec0cea46178..632eca87f21 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java @@ -1150,7 +1150,7 @@ else if (origin.contains(ZoneType.Hand) && player.isOpponentOf(decider)) { } if (sa.hasParam("DifferentPower")) { for (Card c : chosenCards) { - fetchList = CardLists.filter(fetchList, Predicates.not(Predicates.compose(Predicates.equalTo(c.getNetPower()), Card::getNetPower))); + fetchList = CardLists.filter(fetchList, Predicates.not(Predicates.compose(x -> x == c.getNetPower(), Card::getNetPower))); } } if (sa.hasParam("ShareLandType")) { 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 d9b8ca5a6b9..2f5e50d54cd 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackConstraints.java +++ b/forge-game/src/main/java/forge/game/combat/AttackConstraints.java @@ -399,7 +399,7 @@ private static Attack findFirst(final List reqs, final Predicate p return null; } private static Attack findFirst(final List reqs, final Card attacker) { - return findFirst(reqs, Predicates.equalTo(attacker)); + return findFirst(reqs, attacker::equals); } private static Collection findAll(final List reqs, final Card attacker) { return Collections2.filter(reqs, input -> input.attacker.equals(attacker)); diff --git a/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java b/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java index 9cfd08e7ecf..a06366f44c9 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java +++ b/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java @@ -24,7 +24,7 @@ public Predicate getPredicate(final Card attacker) { return Predicates.and( CardPredicates.isColor((byte) (MagicColor.BLACK | MagicColor.GREEN)), // may explicitly not be black/green itself - Predicates.not(Predicates.equalTo(attacker))); + Predicates.not(attacker::equals)); case NOT_ALONE: return x -> true; default: diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java b/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java index ee25671db5f..5322c90f8e0 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java @@ -20,9 +20,9 @@ import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Objects; import forge.util.Iterables; -import forge.util.Predicates; import org.apache.commons.lang3.ArrayUtils; import com.google.common.collect.Sets; @@ -185,7 +185,8 @@ public final boolean performTest(final Map runParams) { thisTurnCast = CardLists.filterControlledByAsList(thisTurnCast, getHostCard().getController()); // checks which card this spell was the castSA - int left = Iterables.indexOf(thisTurnCast, CardPredicates.castSA(Predicates.equalTo(getHostCard().getCastSA()))); + SpellAbility castSA = getHostCard().getCastSA(); + int left = Iterables.indexOf(thisTurnCast, CardPredicates.castSA(x -> Objects.equals(castSA, x))); int right = Integer.parseInt(compare.substring(2)); if (!Expressions.compare(left + 1, compare, right)) { return false; From 22e746521230f6ab464a563e259bfbcd82141ba7 Mon Sep 17 00:00:00 2001 From: Jetz Date: Tue, 3 Sep 2024 09:12:41 -0400 Subject: [PATCH 17/68] Guava migration - Swap in `Predicate.isEqual` --- .../java/forge/game/ability/effects/ChangeZoneEffect.java | 3 ++- .../src/main/java/forge/game/trigger/TriggerChangesZone.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java index 632eca87f21..345bfe732f2 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java @@ -26,6 +26,7 @@ import org.apache.commons.lang3.tuple.Pair; import java.util.*; +import java.util.function.Predicate; public class ChangeZoneEffect extends SpellAbilityEffect { @@ -1150,7 +1151,7 @@ else if (origin.contains(ZoneType.Hand) && player.isOpponentOf(decider)) { } if (sa.hasParam("DifferentPower")) { for (Card c : chosenCards) { - fetchList = CardLists.filter(fetchList, Predicates.not(Predicates.compose(x -> x == c.getNetPower(), Card::getNetPower))); + fetchList = CardLists.filter(fetchList, Predicates.compose(Predicate.isEqual(c.getNetPower()), Card::getNetPower).negate()); } } if (sa.hasParam("ShareLandType")) { diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java b/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java index 5322c90f8e0..4a434afe1bf 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java @@ -20,7 +20,7 @@ import java.util.EnumSet; import java.util.List; import java.util.Map; -import java.util.Objects; +import java.util.function.Predicate; import forge.util.Iterables; import org.apache.commons.lang3.ArrayUtils; @@ -186,7 +186,7 @@ public final boolean performTest(final Map runParams) { // checks which card this spell was the castSA SpellAbility castSA = getHostCard().getCastSA(); - int left = Iterables.indexOf(thisTurnCast, CardPredicates.castSA(x -> Objects.equals(castSA, x))); + int left = Iterables.indexOf(thisTurnCast, CardPredicates.castSA(Predicate.isEqual(castSA))); int right = Integer.parseInt(compare.substring(2)); if (!Expressions.compare(left + 1, compare, right)) { return false; From 78bc9fd04e8cd217ef3f231d5d1a5d783e62ff8b Mon Sep 17 00:00:00 2001 From: Jetz Date: Tue, 3 Sep 2024 09:41:07 -0400 Subject: [PATCH 18/68] Guava migration - Inline `Predicates.not` --- .../main/java/forge/ai/AiBlockController.java | 10 +++++----- .../src/main/java/forge/ai/AiController.java | 16 ++++++++-------- .../src/main/java/forge/ai/AiCostDecision.java | 5 ++--- .../src/main/java/forge/ai/ComputerUtil.java | 6 +++--- .../src/main/java/forge/ai/ComputerUtilCard.java | 2 +- .../src/main/java/forge/ai/ComputerUtilCost.java | 4 ++-- .../main/java/forge/ai/PlayerControllerAi.java | 6 +++--- .../src/main/java/forge/ai/SpecialCardAi.java | 14 +++++++------- .../src/main/java/forge/ai/ability/AttachAi.java | 7 ++++--- .../main/java/forge/ai/ability/ChangeZoneAi.java | 16 +++++++++------- .../main/java/forge/ai/ability/ChooseCardAi.java | 3 +-- .../java/forge/ai/ability/ChooseSourceAi.java | 4 ++-- .../src/main/java/forge/ai/ability/CloneAi.java | 3 +-- .../forge/ai/ability/ControlGainVariantAi.java | 3 +-- .../java/forge/ai/ability/CopyPermanentAi.java | 7 ++++--- .../forge/ai/ability/CountersMultiplyAi.java | 3 +-- .../java/forge/ai/ability/CountersPutAi.java | 5 +++-- .../main/java/forge/ai/ability/DestroyAi.java | 9 ++++++--- .../src/main/java/forge/ai/ability/EffectAi.java | 4 ++-- .../src/main/java/forge/ai/ability/MutateAi.java | 6 +++--- .../main/java/forge/ai/ability/PermanentAi.java | 6 +++--- .../src/main/java/forge/ai/ability/PhasesAi.java | 5 +++-- .../main/java/forge/ai/ability/PumpAiBase.java | 2 +- .../src/main/java/forge/ai/ability/ScryAi.java | 3 +-- .../src/main/java/forge/ai/ability/UntapAi.java | 6 ++---- .../forge/deck/generation/DeckGeneratorBase.java | 4 ++-- .../forge/item/generation/BoosterGenerator.java | 2 +- .../src/main/java/forge/util/Predicates.java | 5 ----- forge-game/src/main/java/forge/game/Game.java | 2 +- .../src/main/java/forge/game/GameFormat.java | 6 +++--- .../game/ability/effects/ChangeZoneEffect.java | 4 ++-- .../ability/effects/CopyPermanentEffect.java | 2 +- .../ability/effects/InternalRadiationEffect.java | 9 ++------- .../src/main/java/forge/game/card/Card.java | 2 +- .../src/main/java/forge/game/card/CardLists.java | 8 ++++---- .../forge/game/combat/AttackRestrictionType.java | 2 +- .../src/main/java/forge/game/player/Player.java | 2 +- .../java/forge/game/player/PlayerPredicates.java | 3 +-- .../StaticAbilityDisableTriggers.java | 5 +++-- .../screens/deckeditor/controllers/CDeckgen.java | 2 +- .../forge/adventure/character/EnemySprite.java | 2 +- .../forge/deck/CardRelationMatrixGenerator.java | 8 ++++---- .../forge/gamemodes/limited/LimitedPlayerAI.java | 2 +- .../forge/gamemodes/limited/WinstonDraft.java | 3 +-- .../gamemodes/net/server/FServerManager.java | 5 +++-- .../java/forge/gamemodes/quest/BoosterUtils.java | 6 +++--- .../java/forge/itemmanager/AdvancedSearch.java | 2 +- .../forge/itemmanager/BooleanExpression.java | 2 +- .../main/java/forge/itemmanager/SFilterUtil.java | 5 +++-- .../achievements/AgainstAllOdds.java | 3 +-- .../java/forge/player/HumanCostDecision.java | 4 ++-- .../main/java/forge/lda/LDAModelGenetrator.java | 4 ++-- 52 files changed, 125 insertions(+), 134 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiBlockController.java b/forge-ai/src/main/java/forge/ai/AiBlockController.java index 47cddedd69a..ad391abde2a 100644 --- a/forge-ai/src/main/java/forge/ai/AiBlockController.java +++ b/forge-ai/src/main/java/forge/ai/AiBlockController.java @@ -367,7 +367,7 @@ private Predicate changesPTWhenBlocked(final boolean onlyForDefVsTrample) * @param combat a {@link forge.game.combat.Combat} object. */ private void makeGangBlocks(final Combat combat) { - List currentAttackers = CardLists.filter(attackersLeft, Predicates.not(rampagesOrNeedsManyToBlock(combat))); + List currentAttackers = CardLists.filter(attackersLeft, rampagesOrNeedsManyToBlock(combat).negate()); List blockers; // Try to block an attacker without first strike with a gang of first strikers @@ -739,11 +739,11 @@ private void reinforceBlockersAgainstTrample(final Combat combat) { List chumpBlockers; List tramplingAttackers = CardLists.getKeyword(attackers, Keyword.TRAMPLE); - tramplingAttackers = CardLists.filter(tramplingAttackers, Predicates.not(rampagesOrNeedsManyToBlock(combat))); + tramplingAttackers = CardLists.filter(tramplingAttackers, rampagesOrNeedsManyToBlock(combat).negate()); // TODO - Instead of filtering out rampage-like and similar triggers, make the AI properly count P/T and // reinforce when actually possible without losing material. - tramplingAttackers = CardLists.filter(tramplingAttackers, Predicates.not(changesPTWhenBlocked(true))); + tramplingAttackers = CardLists.filter(tramplingAttackers, changesPTWhenBlocked(true).negate()); for (final Card attacker : tramplingAttackers) { if (CombatUtil.getMinNumBlockersForAttacker(attacker, combat.getDefenderPlayerByAttacker(attacker)) > combat.getBlockers(attacker).size()) { @@ -794,11 +794,11 @@ private void reinforceBlockersAgainstTrample(final Combat combat) { private void reinforceBlockersToKill(final Combat combat) { List safeBlockers; List blockers; - List targetAttackers = CardLists.filter(blockedButUnkilled, Predicates.not(rampagesOrNeedsManyToBlock(combat))); + List targetAttackers = CardLists.filter(blockedButUnkilled, rampagesOrNeedsManyToBlock(combat).negate()); // TODO - Instead of filtering out rampage-like and similar triggers, make the AI properly count P/T and // reinforce when actually possible without losing material. - targetAttackers = CardLists.filter(targetAttackers, Predicates.not(changesPTWhenBlocked(false))); + targetAttackers = CardLists.filter(targetAttackers, changesPTWhenBlocked(false).negate()); for (final Card attacker : targetAttackers) { blockers = getPossibleBlockers(combat, attacker, blockersLeft, false); diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index f2b27f612ce..9eb9bd2c8c0 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -404,7 +404,7 @@ private static List getPlayableCounters(final CardCollection l) { private CardCollection filterLandsToPlay(CardCollection landList) { final CardCollectionView hand = player.getCardsIn(ZoneType.Hand); - CardCollection nonLandList = CardLists.filter(hand, Predicates.not(CardPredicates.Presets.LANDS)); + CardCollection nonLandList = CardLists.filter(hand, Presets.LANDS.negate()); if (landList.size() == 1 && nonLandList.size() < 3) { CardCollectionView cardsInPlay = player.getCardsIn(ZoneType.Battlefield); CardCollection landsInPlay = CardLists.filter(cardsInPlay, Presets.LANDS); @@ -469,7 +469,7 @@ private Card chooseBestLandToPlay(CardCollection landList) { return null; } - CardCollection nonLandsInHand = CardLists.filter(player.getCardsIn(ZoneType.Hand), Predicates.not(CardPredicates.Presets.LANDS)); + CardCollection nonLandsInHand = CardLists.filter(player.getCardsIn(ZoneType.Hand), Presets.LANDS.negate()); // Some considerations for Momir/MoJhoSto boolean hasMomir = player.isCardInCommand("Momir Vig, Simic Visionary Avatar"); @@ -598,8 +598,8 @@ private Card chooseBestLandToPlay(CardCollection landList) { } // pick dual lands if available - if (Iterables.any(landList, Predicates.not(CardPredicates.Presets.BASIC_LANDS))) { - landList = CardLists.filter(landList, Predicates.not(CardPredicates.Presets.BASIC_LANDS)); + if (Iterables.any(landList, Presets.BASIC_LANDS.negate())) { + landList = CardLists.filter(landList, Presets.BASIC_LANDS.negate()); } } return ComputerUtilCard.getBestLandToPlayAI(landList); @@ -1397,12 +1397,11 @@ private boolean isSafeToHoldLandDropForMain2(Card landToPlay) { return false; } - CardCollection inHand = CardLists.filter(player.getCardsIn(ZoneType.Hand), - Predicates.not(CardPredicates.Presets.LANDS)); + CardCollection inHand = CardLists.filter(player.getCardsIn(ZoneType.Hand), Presets.LANDS.negate()); CardCollectionView otb = player.getCardsIn(ZoneType.Battlefield); if (getBooleanProperty(AiProps.HOLD_LAND_DROP_ONLY_IF_HAVE_OTHER_PERMS)) { - if (!Iterables.any(otb, Predicates.not(CardPredicates.Presets.LANDS))) { + if (!Iterables.any(otb, Presets.LANDS.negate())) { return false; } } @@ -1578,7 +1577,8 @@ private SpellAbility chooseSpellAbilityToPlayFromList(final List a if (sa.getHostCard().hasKeyword(Keyword.STORM) && sa.getApi() != ApiType.Counter // AI would suck at trying to deliberately proc a Storm counterspell - && player.getZone(ZoneType.Hand).contains(Predicates.not(Predicates.or(CardPredicates.Presets.LANDS, CardPredicates.hasKeyword("Storm"))))) { + && player.getZone(ZoneType.Hand).contains( + Predicates.or(Presets.LANDS, CardPredicates.hasKeyword("Storm")).negate())) { if (game.getView().getStormCount() < this.getIntProperty(AiProps.MIN_COUNT_FOR_STORM_SPELLS)) { // skip evaluating Storm unless we reached the minimum Storm count continue; diff --git a/forge-ai/src/main/java/forge/ai/AiCostDecision.java b/forge-ai/src/main/java/forge/ai/AiCostDecision.java index 9c963e53726..e405859bc91 100644 --- a/forge-ai/src/main/java/forge/ai/AiCostDecision.java +++ b/forge-ai/src/main/java/forge/ai/AiCostDecision.java @@ -14,7 +14,6 @@ import forge.game.spellability.SpellAbilityStackInstance; import forge.game.zone.ZoneType; import forge.util.Aggregates; -import forge.util.Predicates; import forge.util.TextUtil; import forge.util.collect.FCollectionView; import org.apache.commons.lang3.ObjectUtils; @@ -105,13 +104,13 @@ public PaymentDecision visit(CostDiscard cost) { Card chosen; if (!discardMe.isEmpty()) { chosen = Aggregates.random(discardMe); - discardMe = CardLists.filter(discardMe, Predicates.not(CardPredicates.sharesNameWith(chosen))); + discardMe = CardLists.filter(discardMe, CardPredicates.sharesNameWith(chosen).negate()); } else { final Card worst = ComputerUtilCard.getWorstAI(hand); chosen = worst != null ? worst : Aggregates.random(hand); } differentNames.add(chosen); - hand = CardLists.filter(hand, Predicates.not(CardPredicates.sharesNameWith(chosen))); + hand = CardLists.filter(hand, CardPredicates.sharesNameWith(chosen).negate()); c--; } return PaymentDecision.card(differentNames); diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index 6f98328dc1c..7a0c4baff16 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -639,7 +639,7 @@ public static CardCollection chooseSacrificeType(final Player ai, String type, f // if the source has "Casualty", don't sacrifice cards that may have granted the effect // TODO: is there a surefire way to determine which card added Casualty? if (source.hasKeyword(Keyword.CASUALTY)) { - typeList = CardLists.filter(typeList, Predicates.not(CardPredicates.hasSVar("AIDontSacToCasualty"))); + typeList = CardLists.filter(typeList, CardPredicates.hasSVar("AIDontSacToCasualty").negate()); } if (typeList.size() < amount) { @@ -1664,7 +1664,7 @@ public static int possibleNonCombatDamage(final Player ai, final Player enemy) { int damage = 0; final CardCollection all = new CardCollection(ai.getCardsIn(ZoneType.Battlefield)); all.addAll(ai.getCardsActivatableInExternalZones(true)); - all.addAll(CardLists.filter(ai.getCardsIn(ZoneType.Hand), Predicates.not(Presets.PERMANENTS))); + all.addAll(CardLists.filter(ai.getCardsIn(ZoneType.Hand), Presets.PERMANENTS.negate())); for (final Card c : all) { if (c.getZone().getPlayer() != null && c.getZone().getPlayer() != ai && c.mayPlay(ai).isEmpty()) { @@ -2450,7 +2450,7 @@ public static CardCollection getCardsToDiscardFromOpponent(Player chooser, Playe // 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(goodChoices::contains)), minDiff)); + goodChoices.addAll(Aggregates.random(CardLists.filter(validCards, ((Predicate) goodChoices::contains).negate()), minDiff)); return goodChoices; } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index 3ac13df9815..db58b45df54 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -206,7 +206,7 @@ public static Card getBestLandAI(final Iterable list) { } // prefer to target non basic lands - final List nbLand = CardLists.filter(land, Predicates.not(CardPredicates.Presets.BASIC_LANDS)); + final List nbLand = CardLists.filter(land, CardPredicates.Presets.BASIC_LANDS.negate()); if (!nbLand.isEmpty()) { // TODO - Improve ranking various non-basic lands depending on context diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java index 66316508a8d..e9a16f5dc20 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java @@ -633,7 +633,7 @@ public static boolean canPayCost(final SpellAbility sa, final Player player, fin if (part instanceof CostSacrifice) { CardCollection valid = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), part.getType().split(";"), sa.getActivatingPlayer(), sa.getHostCard(), sa); - valid = CardLists.filter(valid, Predicates.not(CardPredicates.hasSVar("AIDontSacToCasualty"))); + valid = CardLists.filter(valid, CardPredicates.hasSVar("AIDontSacToCasualty").negate()); if (valid.isEmpty()) { return false; } @@ -924,7 +924,7 @@ public static int getMaxXValue(SpellAbility sa, Player ai, final boolean effect) public static CardCollection paymentChoicesWithoutTargets(Iterable 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), targets::contains))); + choices = Iterables.filter(choices, Predicates.and(CardPredicates.isController(ai), targets::contains).negate()); } return new CardCollection(choices); } diff --git a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java index 9a8fc19f67b..f955b75e326 100644 --- a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java +++ b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java @@ -764,7 +764,7 @@ public CardCollectionView londonMulliganReturnCards(final Player mulliganingPlay // If we're flooding with lands, get rid of the worst land we have if (numLandsInHand > 0 && numLandsInHand > numLandsDesired) { CardCollection producingLands = CardLists.filter(landsInHand, Presets.LANDS_PRODUCING_MANA); - CardCollection nonProducingLands = CardLists.filter(landsInHand, Predicates.not(Presets.LANDS_PRODUCING_MANA)); + CardCollection nonProducingLands = CardLists.filter(landsInHand, Presets.LANDS_PRODUCING_MANA.negate()); Card worstLand = nonProducingLands.isEmpty() ? ComputerUtilCard.getWorstLand(producingLands) : ComputerUtilCard.getWorstLand(nonProducingLands); toReturn.add(worstLand); @@ -1436,7 +1436,7 @@ public String chooseCardName(SpellAbility sa, Predicate cpp, String v if (consp.getState(CardStateName.Original).hasIntrinsicKeyword("Hidden agenda")) { String chosenName = consp.getNamedCard(); if (!chosenName.isEmpty()) { - aiLibrary = CardLists.filter(aiLibrary, Predicates.not(CardPredicates.nameEquals(chosenName))); + aiLibrary = CardLists.filter(aiLibrary, CardPredicates.nameEquals(chosenName).negate()); } } } @@ -1469,7 +1469,7 @@ public String chooseCardName(SpellAbility sa, Predicate cpp, String v } } else { CardCollectionView list = CardLists.filterControlledBy(getGame().getCardsInGame(), player.getOpponents()); - list = CardLists.filter(list, Predicates.not(Presets.LANDS)); + list = CardLists.filter(list, Presets.LANDS.negate()); if (!list.isEmpty()) { return list.get(0).getName(); } diff --git a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java index e60d336706d..49f93723779 100644 --- a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java +++ b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java @@ -125,7 +125,7 @@ public static boolean consider(final Player ai, final SpellAbility sa, final Man int numManaSrcs = manaSources.size(); CardCollection allCards = CardLists.filter(ai.getAllCards(), Arrays.asList(CardPredicates.Presets.NON_TOKEN, - Predicates.not(CardPredicates.Presets.LANDS), CardPredicates.isOwner(ai))); + CardPredicates.Presets.LANDS.negate(), CardPredicates.isOwner(ai))); int numHighCMC = CardLists.count(allCards, CardPredicates.greaterCMC(5)); int numLowCMC = CardLists.count(allCards, CardPredicates.lessCMC(3)); @@ -206,7 +206,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { List AiLandsOnly = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.LANDS); List OppPerms = CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Battlefield), - Predicates.not(CardPredicates.Presets.CREATURES)); + CardPredicates.Presets.CREATURES.negate()); // TODO: improve this logic (currently the AI has difficulty evaluating non-creature permanents, // which it can only distinguish by their CMC, considering >CMC higher value). @@ -331,12 +331,12 @@ static public String chooseNonBattlefieldName() { public static class DeathgorgeScavenger { public static boolean consider(final Player ai, final SpellAbility sa) { Card worstCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES)); - Card worstNonCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Graveyard), Predicates.not(CardPredicates.Presets.CREATURES))); + Card worstNonCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES.negate())); if (worstCreat == null) { worstCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES)); } if (worstNonCreat == null) { - worstNonCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), Predicates.not(CardPredicates.Presets.CREATURES))); + worstNonCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES.negate())); } sa.resetTargets(); @@ -786,7 +786,7 @@ public static CardCollection considerMultiple(final Player ai, final SpellAbilit int changeNum = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParamOrDefault("ChangeNum", "1"), sa); CardCollection lib = CardLists.filter(ai.getCardsIn(ZoneType.Library), - Predicates.not(CardPredicates.nameEquals(sa.getHostCard().getName()))); + CardPredicates.nameEquals(sa.getHostCard().getName()).negate()); lib.sort(CardLists.CmcComparatorInv); // Additional cards which are difficult to auto-classify but which are generally good to Intuition for @@ -1316,7 +1316,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { return false; } - int aiLands = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Predicates.and(CardPredicates.Presets.LANDS, Predicates.not(CardPredicates.Presets.BASIC_LANDS))).size(); + int aiLands = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Predicates.and(CardPredicates.Presets.LANDS, CardPredicates.Presets.BASIC_LANDS.negate())).size(); boolean hasBridge = false; for (Card c : ai.getCardsIn(ZoneType.Battlefield)) { @@ -1334,7 +1334,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { } for (Player opp : ai.getOpponents()) { - int oppLands = CardLists.filter(opp.getCardsIn(ZoneType.Battlefield), Predicates.and(CardPredicates.Presets.LANDS, Predicates.not(CardPredicates.Presets.BASIC_LANDS))).size(); + int oppLands = CardLists.filter(opp.getCardsIn(ZoneType.Battlefield), Predicates.and(CardPredicates.Presets.LANDS, CardPredicates.Presets.BASIC_LANDS.negate())).size(); // Always if enemy would die and we don't! // TODO : predict actual damage instead of assuming it'll be 2*lands // Don't if we lose, unless we lose anyway to unblocked creatures next turn diff --git a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java index 972ea28cecf..965c88d47e3 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java @@ -1,6 +1,7 @@ package forge.ai.ability; import java.util.*; +import java.util.function.Predicate; import forge.game.card.*; import forge.util.Predicates; @@ -864,7 +865,7 @@ private static Card attachAICursePreference(final SpellAbility sa, final List list) { // } // pick dual lands if available - if (Iterables.any(result, Predicates.not(CardPredicates.Presets.BASIC_LANDS))) { - result = CardLists.filter(result, Predicates.not(CardPredicates.Presets.BASIC_LANDS)); + if (Iterables.any(result, Presets.BASIC_LANDS.negate())) { + result = CardLists.filter(result, Presets.BASIC_LANDS.negate()); } return result.get(0); @@ -906,7 +906,8 @@ private static boolean isPreferredTarget(final Player ai, final SpellAbility sa, } if (source.isInZone(ZoneType.Hand)) { - list = CardLists.filter(list, Predicates.not(CardPredicates.nameEquals(source.getName()))); // Don't get the same card back. + Predicate nameEquals = CardPredicates.nameEquals(source.getName()); + list = CardLists.filter(list, nameEquals.negate()); // Don't get the same card back. } if (sa.isSpell()) { list.remove(source); // spells can't target their own source, because it's actually in the stack zone @@ -1629,7 +1630,8 @@ public static Card chooseCardToHiddenOriginChangeZone(ZoneType destination, List } } else { // Don't fetch another tutor with the same name - CardCollection sameNamed = CardLists.filter(fetchList, Predicates.not(CardPredicates.nameEquals(ComputerUtilAbility.getAbilitySourceName(sa)))); + Predicate nameEquals = CardPredicates.nameEquals(ComputerUtilAbility.getAbilitySourceName(sa)); + CardCollection sameNamed = CardLists.filter(fetchList, nameEquals.negate()); if (origin.contains(ZoneType.Library) && !sameNamed.isEmpty()) { fetchList = sameNamed; } @@ -1961,7 +1963,7 @@ public static Card doExilePreferenceLogic(final Player aiPlayer, final SpellAbil } if (logic.contains("NonLand")) { - scanList = CardLists.filter(scanList, Predicates.not(Presets.LANDS)); + scanList = CardLists.filter(scanList, Presets.LANDS.negate()); } if (logic.contains("NonExiled")) { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java index 370d73864ef..3cb044578e8 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java @@ -27,7 +27,6 @@ import forge.game.zone.ZoneType; import forge.util.Aggregates; import forge.util.Iterables; -import forge.util.Predicates; public class ChooseCardAi extends SpellAbilityAi { @@ -271,7 +270,7 @@ public Card chooseSingleCard(final Player ai, final SpellAbility sa, Iterable oppCreatures = CardLists.filter(options, Predicates.and(CardPredicates.Presets.CREATURES, - Predicates.not(CardPredicates.isOwner(aiChoser)))); + CardPredicates.isOwner(aiChoser).negate())); List aiNonCreatures = CardLists.filter(options, - Predicates.not(CardPredicates.Presets.CREATURES) + CardPredicates.Presets.CREATURES.negate() .and(CardPredicates.Presets.PERMANENTS) .and(CardPredicates.isOwner(aiChoser)) ); diff --git a/forge-ai/src/main/java/forge/ai/ability/CloneAi.java b/forge-ai/src/main/java/forge/ai/ability/CloneAi.java index b2ef3bdd0f4..7479165a142 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CloneAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CloneAi.java @@ -18,7 +18,6 @@ import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Predicates; public class CloneAi extends SpellAbilityAi { @@ -210,7 +209,7 @@ protected Card chooseSingleCard(Player ai, SpellAbility sa, Iterable optio // prevent loop of choosing copy of same card if (isVesuva) { - options = CardLists.filter(options, Predicates.not(CardPredicates.sharesNameWith(host))); + options = CardLists.filter(options, CardPredicates.sharesNameWith(host).negate()); } Card choice = isOpp ? ComputerUtilCard.getWorstAI(options) : ComputerUtilCard.getBestAI(options); diff --git a/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java b/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java index 75aa62d6f08..b7ffe94c3b4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java @@ -29,7 +29,6 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Iterables; -import forge.util.Predicates; /** @@ -64,7 +63,7 @@ protected boolean canPlayAI(final Player ai, final SpellAbility sa) { @Override public Card chooseSingleCard(Player ai, SpellAbility sa, Iterable options, boolean isOptional, Player targetedPlayer, Map params) { - Iterable otherCtrl = CardLists.filter(options, Predicates.not(CardPredicates.isController(ai))); + Iterable otherCtrl = CardLists.filter(options, CardPredicates.isController(ai).negate()); if (Iterables.isEmpty(otherCtrl)) { return ComputerUtilCard.getWorstAI(options); } else { diff --git a/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java b/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java index 95437b65d63..a4ea818d1bd 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java @@ -3,6 +3,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.function.Predicate; import forge.ai.AiPlayDecision; import forge.ai.ComputerUtil; @@ -31,7 +32,6 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Iterables; -import forge.util.Predicates; public class CopyPermanentAi extends SpellAbilityAi { @Override @@ -135,7 +135,8 @@ protected boolean doTriggerAINoCost(final Player aiPlayer, SpellAbility sa, bool // TODO: possibly improve the check, currently only checks if the name is the same // Possibly also check if the card is threatened, and then allow to copy (this will, however, require a bit // of a rewrite in canPlayAI to allow a response form of CopyPermanentAi) - list = CardLists.filter(list, Predicates.not(CardPredicates.nameEquals(host.getName()))); + Predicate nameEquals = CardPredicates.nameEquals(host.getName()); + list = CardLists.filter(list, nameEquals.negate()); } //Nothing to target @@ -143,7 +144,7 @@ protected boolean doTriggerAINoCost(final Player aiPlayer, SpellAbility sa, bool return false; } - CardCollection betterList = CardLists.filter(list, Predicates.not(CardPredicates.isRemAIDeck())); + CardCollection betterList = CardLists.filter(list, CardPredicates.isRemAIDeck().negate()); if (betterList.isEmpty()) { if (!mandatory) { return false; diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java index ab1fe95a2a6..522590f4e13 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java @@ -24,7 +24,6 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Iterables; -import forge.util.Predicates; public class CountersMultiplyAi extends SpellAbilityAi { @@ -104,7 +103,7 @@ protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandator if (list.isEmpty()) { return false; } - Card safeMatch = Iterables.getFirst(Iterables.filter(list, Predicates.not(CardPredicates.hasCounters())), null); + Card safeMatch = Iterables.getFirst(Iterables.filter(list, CardPredicates.hasCounters().negate()), null); sa.getTargets().add(safeMatch == null ? list.getFirst() : safeMatch); return true; } diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java index 67c8f44960d..ee378b41134 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java @@ -26,11 +26,11 @@ import forge.util.Aggregates; import forge.util.Iterables; import forge.util.MyRandom; -import forge.util.Predicates; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.function.Predicate; public class CountersPutAi extends CountersAi { @@ -271,8 +271,9 @@ protected boolean checkApiLogic(Player ai, final SpellAbility sa) { return false; } + Predicate predicate = CardPredicates.hasCounter(CounterType.getType(type)); CardCollection oppCreats = CardLists.filter(ai.getOpponents().getCreaturesInPlay(), - Predicates.not(CardPredicates.hasCounter(CounterType.getType(type))), + predicate.negate(), CardPredicates.isTargetableBy(sa)); if (!oppCreats.isEmpty()) { diff --git a/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java b/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java index d9828d298fd..c94523c1643 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java @@ -14,7 +14,8 @@ import forge.game.spellability.SpellAbility; import forge.game.staticability.StaticAbilityMustTarget; import forge.game.zone.ZoneType; -import forge.util.Predicates; + +import java.util.function.Predicate; public class DestroyAi extends SpellAbilityAi { @Override @@ -167,7 +168,8 @@ protected boolean checkApiLogic(final Player ai, final SpellAbility sa) { list = ComputerUtilCard.prioritizeCreaturesWorthRemovingNow(ai, list, false); } if (!playReusable(ai, sa)) { - list = CardLists.filter(list, Predicates.not(CardPredicates.hasCounter(CounterEnumType.SHIELD, 1))); + Predicate hasCounter = CardPredicates.hasCounter(CounterEnumType.SHIELD, 1); + list = CardLists.filter(list, hasCounter.negate()); list = CardLists.filter(list, c -> { //Check for cards that can be sacrificed in response @@ -321,7 +323,8 @@ protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandator CardCollection preferred = CardLists.getNotKeyword(list, Keyword.INDESTRUCTIBLE); preferred = CardLists.filterControlledBy(preferred, ai.getOpponents()); - preferred = CardLists.filter(preferred, Predicates.not(CardPredicates.hasCounter(CounterEnumType.SHIELD, 1))); + Predicate hasCounter = CardPredicates.hasCounter(CounterEnumType.SHIELD, 1); + preferred = CardLists.filter(preferred, hasCounter.negate()); if (CardLists.getNotType(preferred, "Creature").isEmpty()) { preferred = ComputerUtilCard.prioritizeCreaturesWorthRemovingNow(ai, preferred, false); } diff --git a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java index 3346c5a4759..c74041c755d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java @@ -338,7 +338,7 @@ protected boolean canPlayAI(final Player ai,final SpellAbility sa) { runParams.put(AbilityKey.Regeneration, true); List repDestoryList = game.getReplacementHandler().getReplacementList(ReplacementType.Destroy, runParams, ReplacementLayer.Other); // no Destroy Replacement, or one non-Regeneration one like Totem-Armor - if (repDestoryList.isEmpty() || Iterables.any(repDestoryList, Predicates.not(CardTraitPredicates.hasParam("Regeneration")))) { + if (repDestoryList.isEmpty() || Iterables.any(repDestoryList, CardTraitPredicates.hasParam("Regeneration").negate())) { return false; } @@ -369,7 +369,7 @@ protected boolean canPlayAI(final Player ai,final SpellAbility sa) { runParams.put(AbilityKey.Regeneration, true); List repDestoryList = game.getReplacementHandler().getReplacementList(ReplacementType.Destroy, runParams, ReplacementLayer.Other); // no Destroy Replacement, or one non-Regeneration one like Totem-Armor - if (repDestoryList.isEmpty() || Iterables.any(repDestoryList, Predicates.not(CardTraitPredicates.hasParam("Regeneration")))) { + if (repDestoryList.isEmpty() || Iterables.any(repDestoryList, CardTraitPredicates.hasParam("Regeneration").negate())) { return false; } diff --git a/forge-ai/src/main/java/forge/ai/ability/MutateAi.java b/forge-ai/src/main/java/forge/ai/ability/MutateAi.java index c5086824cf3..61217e369db 100644 --- a/forge-ai/src/main/java/forge/ai/ability/MutateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/MutateAi.java @@ -13,7 +13,6 @@ import forge.game.player.Player; import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; -import forge.util.Predicates; public class MutateAi extends SpellAbilityAi { @Override @@ -23,12 +22,13 @@ protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { // Filter out some abilities that are useless // TODO: add other stuff useless for Mutate here - mutateTgts = CardLists.filter(mutateTgts, Predicates.not( + mutateTgts = CardLists.filter(mutateTgts, CardPredicates.hasKeyword(Keyword.DEFENDER) .or(CardPredicates.hasKeyword("CARDNAME can't attack.")) .or(CardPredicates.hasKeyword("CARDNAME can't block.")) .or(card -> ComputerUtilCard.isUselessCreature(aiPlayer, card)) - )); + .negate() + ); if (mutateTgts.isEmpty()) { return false; diff --git a/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java b/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java index fcf1160301c..eb612cf6b5a 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java @@ -141,10 +141,10 @@ protected boolean checkApiLogic(final Player ai, final SpellAbility sa) { && card.getState(CardStateName.Original).getManaCost() != null && card.getState(CardStateName.Original).getManaCost().getCMC() == manaValue); if (manaValue == 0) { - aiCards = CardLists.filter(aiCards, Predicates.not(CardPredicates.isType("Land"))); - oppCards = CardLists.filter(oppCards, Predicates.not(CardPredicates.isType("Land"))); + aiCards = CardLists.filter(aiCards, CardPredicates.isType("Land").negate()); + oppCards = CardLists.filter(oppCards, CardPredicates.isType("Land").negate()); // also filter out other Chalices in our own deck - aiCards = CardLists.filter(aiCards, Predicates.not(CardPredicates.nameEquals("Chalice of the Void"))); + aiCards = CardLists.filter(aiCards, CardPredicates.nameEquals("Chalice of the Void").negate()); } if (oppCards.size() > 3 && oppCards.size() >= aiCards.size() * 2) { sa.setXManaCostPaid(manaValue); diff --git a/forge-ai/src/main/java/forge/ai/ability/PhasesAi.java b/forge-ai/src/main/java/forge/ai/ability/PhasesAi.java index 37a676dd423..ea5cb13c3ed 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PhasesAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PhasesAi.java @@ -15,11 +15,11 @@ import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; import forge.util.MyRandom; -import forge.util.Predicates; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.function.Predicate; public class PhasesAi extends SpellAbilityAi { @Override @@ -117,7 +117,8 @@ private boolean phasesUnpreferredTargeting(final Game game, final SpellAbility s // in general, if it's our own creature, choose the weakest one, if it's the opponent's creature, // choose the strongest one if (!list.isEmpty()) { - CardCollectionView oppList = CardLists.filter(list, Predicates.not(CardPredicates.isController(source.getController()))); + Predicate isController = CardPredicates.isController(source.getController()); + CardCollectionView oppList = CardLists.filter(list, isController.negate()); sa.resetTargets(); sa.getTargets().add(!oppList.isEmpty() ? ComputerUtilCard.getBestAI(oppList) : ComputerUtilCard.getWorstAI(list)); return true; diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java b/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java index e45d692b43b..8be2c7fb00e 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java @@ -222,7 +222,7 @@ public boolean isUsefulPumpKeyword(final Player ai, final String keyword, final && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) && newPower > 0 && Iterables.any(CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), - Predicates.not(flyingOrReach)); + flyingOrReach.negate()); } else if (keyword.endsWith("Horsemanship")) { if (ph.isPlayerTurn(opp) && ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS) diff --git a/forge-ai/src/main/java/forge/ai/ability/ScryAi.java b/forge-ai/src/main/java/forge/ai/ability/ScryAi.java index 6cdc0c56337..2462d80a1a3 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ScryAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ScryAi.java @@ -16,7 +16,6 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.MyRandom; -import forge.util.Predicates; public class ScryAi extends SpellAbilityAi { @@ -100,7 +99,7 @@ protected boolean checkPhaseRestrictions(final Player ai, final SpellAbility sa, private boolean doBestOpportunityLogic(Player ai, SpellAbility sa, PhaseHandler ph) { // Check to see if there are any cards in hand that may be worth casting boolean hasSomethingElse = false; - for (Card c : CardLists.filter(ai.getCardsIn(ZoneType.Hand), Predicates.not(CardPredicates.Presets.LANDS))) { + for (Card c : CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.LANDS.negate())) { for (SpellAbility ab : c.getAllSpellAbilities()) { if (ab.getPayCosts().hasManaCost() && ComputerUtilMana.hasEnoughManaSourcesToCast(ab, ai)) { diff --git a/forge-ai/src/main/java/forge/ai/ability/UntapAi.java b/forge-ai/src/main/java/forge/ai/ability/UntapAi.java index c83d3e7598f..6c573cc50d9 100644 --- a/forge-ai/src/main/java/forge/ai/ability/UntapAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/UntapAi.java @@ -8,7 +8,6 @@ import forge.game.card.Card; import forge.game.card.CardCollection; import forge.game.card.CardLists; -import forge.game.card.CardPredicates; import forge.game.card.CardPredicates.Presets; import forge.game.combat.Combat; import forge.game.cost.Cost; @@ -23,7 +22,6 @@ import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; import forge.util.Iterables; -import forge.util.Predicates; import java.util.List; import java.util.Map; @@ -340,7 +338,7 @@ private static Card detectPriorityUntapTargets(final List untapList) { } // See if there's anything to untap that is tapped and that doesn't untap during the next untap step by itself - CardCollection noAutoUntap = CardLists.filter(untapList, Predicates.not(Untap.CANUNTAP)); + CardCollection noAutoUntap = CardLists.filter(untapList, Untap.CANUNTAP.negate()); if (!noAutoUntap.isEmpty()) { return ComputerUtilCard.getBestAI(noAutoUntap); } @@ -402,7 +400,7 @@ private boolean doPoolExtraManaLogic(final Player ai, final SpellAbility sa) { } // Check if something is playable if we untap for an additional mana with this, then proceed - CardCollection inHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), Predicates.not(CardPredicates.Presets.LANDS)); + CardCollection inHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), Presets.LANDS.negate()); // The AI is not very good at timing non-permanent spells this way, so filter them out // (it may actually be possible to enable this for sorceries, but that'll need some canPlay shenanigans) CardCollection playable = CardLists.filter(inHand, Presets.PERMANENTS); diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index 49175708333..82ece55a661 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -234,7 +234,7 @@ protected void adjustDeckSize(int targetSize) { addSome(targetSize - actualSize, tDeck.toFlatList()); } else if (actualSize > targetSize) { - Predicate exceptBasicLand = Predicates.not(Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules)); + Predicate exceptBasicLand = Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules).negate(); for (int i = 0; i < 3 && actualSize > targetSize; i++) { Iterable matchingCards = Iterables.filter(tDeck.toFlatList(), exceptBasicLand); @@ -388,7 +388,7 @@ protected List getDualLandList(Predicate canPlay) { //filter to provide all dual lands from pool matching 2 or 3 colors from current deck Predicate dualLandFilter = CardRulesPredicates.coreType(true, CardType.CoreType.Land); - Predicate exceptBasicLand = Predicates.not(CardRulesPredicates.Presets.IS_BASIC_LAND); + Predicate exceptBasicLand = CardRulesPredicates.Presets.IS_BASIC_LAND.negate(); Iterable landCards = pool.getAllCards(Predicates.compose(dualLandFilter.and(exceptBasicLand).and(canPlay), PaperCard::getRules)); Iterable dualLandPatterns = Arrays.asList("Add \\{([WUBRG])\\} or \\{([WUBRG])\\}", diff --git a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java index a9812e1cc83..4ae456c4d7b 100644 --- a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java +++ b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java @@ -726,7 +726,7 @@ private static Predicate buildExtraPredicate(List operators) itOp.remove(); if (invert) { - toAdd = Predicates.not(toAdd); + toAdd = toAdd.negate(); } conditions.add(toAdd); } diff --git a/forge-core/src/main/java/forge/util/Predicates.java b/forge-core/src/main/java/forge/util/Predicates.java index 3547e218b06..483878b031f 100644 --- a/forge-core/src/main/java/forge/util/Predicates.java +++ b/forge-core/src/main/java/forge/util/Predicates.java @@ -1,6 +1,5 @@ package forge.util; -import java.util.Objects; import java.util.function.Function; import java.util.function.Predicate; @@ -24,10 +23,6 @@ public static Predicate compose(Predicate predicate, Function Predicate not(Predicate predicate) { - return predicate.negate(); - } - public static Predicate and(Predicate first, Predicate second) { //TODO: remove casting? return ((Predicate) first).and(second); diff --git a/forge-game/src/main/java/forge/game/Game.java b/forge-game/src/main/java/forge/game/Game.java index 17069ca8a7e..55bdd34eedd 100644 --- a/forge-game/src/main/java/forge/game/Game.java +++ b/forge-game/src/main/java/forge/game/Game.java @@ -1099,7 +1099,7 @@ public Multimap chooseCardsForAnte(final boolean matchRarity) { private void chooseRandomCardsForAnte(final Player player, final Multimap anteed) { final CardCollectionView lib = player.getCardsIn(ZoneType.Library); - Predicate goodForAnte = Predicates.not(CardPredicates.Presets.BASIC_LANDS); + Predicate goodForAnte = CardPredicates.Presets.BASIC_LANDS.negate(); Card ante = Aggregates.random(Iterables.filter(lib, goodForAnte)); if (ante == null) { getGameLog().add(GameLogEntryType.ANTE, "Only basic lands found. Will ante one of them"); diff --git a/forge-game/src/main/java/forge/game/GameFormat.java b/forge-game/src/main/java/forge/game/GameFormat.java index 573b3fadb3e..ca7517c642f 100644 --- a/forge-game/src/main/java/forge/game/GameFormat.java +++ b/forge-game/src/main/java/forge/game/GameFormat.java @@ -138,12 +138,12 @@ public GameFormat(final String fName, final Date effectiveDate, final Iterable buildFilter(boolean printed) { - Predicate p = Predicates.not(IPaperCard.Predicates.names(this.getBannedCardNames())); + Predicate p = IPaperCard.Predicates.names(this.getBannedCardNames()).negate(); if (FormatSubType.ARENA.equals(this.getFormatSubType())) { - p = Predicates.and(p, Predicates.not(IPaperCard.Predicates.Presets.IS_UNREBALANCED)); + p = Predicates.and(p, IPaperCard.Predicates.Presets.IS_UNREBALANCED.negate()); } else { - p = Predicates.and(p, Predicates.not(IPaperCard.Predicates.Presets.IS_REBALANCED)); + p = Predicates.and(p, IPaperCard.Predicates.Presets.IS_REBALANCED.negate()); } if (!this.getAllowedSetCodes().isEmpty()) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java index 345bfe732f2..740fdeaaa51 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java @@ -1141,12 +1141,12 @@ else if (origin.contains(ZoneType.Hand) && player.isOpponentOf(decider)) { for (int i = 0; i < changeNum && destination != null; i++) { if (sa.hasParam("DifferentNames")) { for (Card c : chosenCards) { - fetchList = CardLists.filter(fetchList, Predicates.not(CardPredicates.sharesNameWith(c))); + fetchList = CardLists.filter(fetchList, CardPredicates.sharesNameWith(c).negate()); } } if (sa.hasParam("DifferentCMC")) { for (Card c : chosenCards) { - fetchList = CardLists.filter(fetchList, Predicates.not(CardPredicates.sharesCMCWith(c))); + fetchList = CardLists.filter(fetchList, CardPredicates.sharesCMCWith(c).negate()); } } if (sa.hasParam("DifferentPower")) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java index 7bc5d7ca722..36dcce6617f 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java @@ -219,7 +219,7 @@ public void resolve(final SpellAbility sa) { if (choosen != null) { tgtCards.add(choosen); - choices = CardLists.filter(choices, Predicates.not(CardPredicates.sharesNameWith(choosen))); + choices = CardLists.filter(choices, CardPredicates.sharesNameWith(choosen).negate()); } else if (chooser.getController().confirmAction(sa, PlayerActionConfirmMode.OptionalChoose, Localizer.getInstance().getMessage("lblCancelChooseConfirm"), null)) { break; } diff --git a/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java b/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java index 3903e6e25b8..659ed4cadfe 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java @@ -7,18 +7,13 @@ import forge.game.Game; import forge.game.ability.AbilityKey; import forge.game.ability.SpellAbilityEffect; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; -import forge.game.card.CardZoneTable; -import forge.game.card.CounterEnumType; +import forge.game.card.*; import forge.game.player.Player; import forge.game.player.PlayerCollection; import forge.game.spellability.SpellAbility; import forge.game.staticability.StaticAbilityGainLifeRadiation; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; -import forge.util.Predicates; public class InternalRadiationEffect extends SpellAbilityEffect { @@ -34,7 +29,7 @@ public void resolve(SpellAbility sa) { final CardCollectionView milled = game.getAction().mill(new PlayerCollection(p), numRad, ZoneType.Graveyard, sa, moveParams); table.triggerChangesZoneAll(game, sa); - int n = CardLists.count(milled, Predicates.not(CardPredicates.Presets.LANDS)); + int n = CardLists.count(milled, CardPredicates.Presets.LANDS.negate()); if (StaticAbilityGainLifeRadiation.gainLifeRadiation(p)) { p.gainLife(n, sa.getHostCard(), sa); diff --git a/forge-game/src/main/java/forge/game/card/Card.java b/forge-game/src/main/java/forge/game/card/Card.java index d809913d244..ec8888dbc9e 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -3372,7 +3372,7 @@ public void updateSpellAbilities(List list, CardState state, Boole // List only has nonMana if (null == mana) { List toRemove = Lists.newArrayList( - Iterables.filter(list, Predicates.not(SpellAbilityPredicates.isManaAbility()))); + Iterables.filter(list, SpellAbilityPredicates.isManaAbility().negate())); list.removeAll(toRemove); } else if (false == mana) { list.clear(); diff --git a/forge-game/src/main/java/forge/game/card/CardLists.java b/forge-game/src/main/java/forge/game/card/CardLists.java index 4c610b5daec..59a9ad34392 100644 --- a/forge-game/src/main/java/forge/game/card/CardLists.java +++ b/forge-game/src/main/java/forge/game/card/CardLists.java @@ -261,11 +261,11 @@ public static CardCollection getKeyword(Iterable cardList, final Keyword k } public static CardCollection getNotKeyword(Iterable cardList, String keyword) { - return CardLists.filter(cardList, Predicates.not(CardPredicates.hasKeyword(keyword))); + return CardLists.filter(cardList, CardPredicates.hasKeyword(keyword).negate()); } public static CardCollection getNotKeyword(Iterable cardList, final Keyword keyword) { - return CardLists.filter(cardList, Predicates.not(CardPredicates.hasKeyword(keyword))); + return CardLists.filter(cardList, CardPredicates.hasKeyword(keyword).negate()); } public static int getAmountOfKeyword(final Iterable cardList, final String keyword) { @@ -285,7 +285,7 @@ public static int getAmountOfKeyword(final Iterable cardList, final Keywor // cardType is like "Land" or "Goblin", returns a new CardCollection that is a // subset of current CardList public static CardCollection getNotType(Iterable cardList, String cardType) { - return CardLists.filter(cardList, Predicates.not(CardPredicates.isType(cardType))); + return CardLists.filter(cardList, CardPredicates.isType(cardType).negate()); } public static CardCollection getType(Iterable cardList, String cardType) { @@ -293,7 +293,7 @@ public static CardCollection getType(Iterable cardList, String cardType) { } public static CardCollection getNotColor(Iterable cardList, byte color) { - return CardLists.filter(cardList, Predicates.not(CardPredicates.isColor(color))); + return CardLists.filter(cardList, CardPredicates.isColor(color).negate()); } public static CardCollection getColor(Iterable cardList, byte color) { diff --git a/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java b/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java index a06366f44c9..c16d48b9d48 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java +++ b/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java @@ -24,7 +24,7 @@ public Predicate getPredicate(final Card attacker) { return Predicates.and( CardPredicates.isColor((byte) (MagicColor.BLACK | MagicColor.GREEN)), // may explicitly not be black/green itself - Predicates.not(attacker::equals)); + ((Predicate) attacker::equals).negate()); case NOT_ALONE: return x -> true; default: diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index 070d6328040..fb9f6215db0 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -353,7 +353,7 @@ public final int getOpponentsTotalPoisonCounters() { * Should keep player relations somewhere in the match structure */ public final PlayerCollection getAllies() { - return getAllOtherPlayers().filter(Predicates.not(PlayerPredicates.isOpponentOf(this))); + return getAllOtherPlayers().filter(PlayerPredicates.isOpponentOf(this).negate()); } public final PlayerCollection getTeamMates(final boolean inclThis) { diff --git a/forge-game/src/main/java/forge/game/player/PlayerPredicates.java b/forge-game/src/main/java/forge/game/player/PlayerPredicates.java index abf6e305c48..93942877ee9 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerPredicates.java +++ b/forge-game/src/main/java/forge/game/player/PlayerPredicates.java @@ -11,7 +11,6 @@ import forge.game.card.CounterType; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Predicates; public final class PlayerPredicates { @@ -36,7 +35,7 @@ public static Predicate isCardInPlay(final String cardName) { } public static Predicate isNotCardInPlay(final String cardName) { - return Predicates.not(isCardInPlay(cardName)); + return isCardInPlay(cardName).negate(); } public static Predicate hasCounters() { diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityDisableTriggers.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityDisableTriggers.java index 617ef2a228a..a4c3f144fa5 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityDisableTriggers.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityDisableTriggers.java @@ -8,10 +8,10 @@ import forge.game.trigger.Trigger; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; -import forge.util.Predicates; import org.apache.commons.lang3.ArrayUtils; import java.util.Map; +import java.util.function.Predicate; public class StaticAbilityDisableTriggers { @@ -108,7 +108,8 @@ public static boolean isDisabled(final StaticAbility stAb, final Trigger regtrig CardCollection changers = cell.getValue(); if ((origin == null || cell.getRowKey() == ZoneType.valueOf(origin)) && (destination == null || cell.getColumnKey() == ZoneType.valueOf(destination))) { - changers = CardLists.filter(changers, Predicates.not(CardPredicates.restriction(stAb.getParam("ValidCause").split(","), stAb.getHostCard().getController(), stAb.getHostCard(), stAb))); + Predicate validCause = CardPredicates.restriction(stAb.getParam("ValidCause").split(","), stAb.getHostCard().getController(), stAb.getHostCard(), stAb); + changers = CardLists.filter(changers, validCause.negate()); // static will match some of the causes if (changers.size() < cell.getValue().size()) { possiblyDisabled = true; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java index c832a727955..2aeda0a874a 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java @@ -70,7 +70,7 @@ private void newRandomCon final Deck randomDeck = new Deck(); - final Predicate notBasicLand = Predicates.not(Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules)); + final Predicate notBasicLand = Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules).negate(); final Iterable source = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards(), notBasicLand); randomDeck.getMain().addAllFlat(Aggregates.random(source, 15 * 5)); diff --git a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java index 7300b6cf638..a937d49e40a 100644 --- a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java +++ b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java @@ -481,7 +481,7 @@ public Array getRewards() { if(data.rewards != null) { //Collect standard rewards. Deck enemyDeck = Current.latestDeck(); // By popular demand, remove basic lands from the reward pool. - CardPool deckNoBasicLands = enemyDeck.getMain().getFilteredPool(Predicates.compose(Predicates.not(CardRulesPredicates.Presets.IS_BASIC_LAND), PaperCard::getRules)); + CardPool deckNoBasicLands = enemyDeck.getMain().getFilteredPool(Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND.negate(), PaperCard::getRules)); for (RewardData rdata : data.rewards) { ret.addAll(rdata.generate(false, enemyDeck == null ? null : deckNoBasicLands.toFlatList(),true )); diff --git a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java index 69e76e03d3e..9483ac0dc8f 100644 --- a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java @@ -74,7 +74,7 @@ public static HashMap>> initializeForma true); final Iterable cards = Iterables.filter(format.getAllCards() - , Predicates.compose(Predicates.not(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES), PaperCard::getRules)); + , Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES.negate(), PaperCard::getRules)); List cardList = Lists.newArrayList(cards); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); @@ -90,7 +90,7 @@ public static HashMap>> initializeForma for (Deck deck:decks){ if (deck.getMain().contains(card)){ for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(), - Predicates.compose(Predicates.not(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES), PaperCard::getRules))){ + Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES.negate(), PaperCard::getRules))){ if (!pairCard.getName().equals(card.getName())){ try { int old = matrix[cardIntegerMap.get(card.getName())][cardIntegerMap.get(pairCard.getName())]; @@ -143,7 +143,7 @@ public static HashMap>> initializeComma //get all cards final Iterable cards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards() - , Predicates.compose(Predicates.not(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES), PaperCard::getRules)); + , Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES.negate(), PaperCard::getRules)); List cardList = Lists.newArrayList(cards); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); @@ -200,7 +200,7 @@ public static HashMap>> initializeComma public static void updateLegendMatrix(Deck deck, PaperCard legend, Map cardIntegerMap, Map legendIntegerMap, int[][] matrix){ for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(), - Predicates.compose(Predicates.not(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES), PaperCard::getRules))){ + Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES.negate(), PaperCard::getRules))){ if (!pairCard.getName().equals(legend.getName())){ try { int old = matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(pairCard.getName())]; diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java index ed65e38fc1f..ea4c8251ce6 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java @@ -265,7 +265,7 @@ protected PaperCard chooseExchangeCard(PaperCard offer) { DeckGeneratorBase.MatchColorIdentity hasColor = new DeckGeneratorBase.MatchColorIdentity(colors); Iterable colorList = Iterables.filter(deckCards, - Predicates.not(Predicates.compose(hasColor, PaperCard::getRules))); + Predicates.compose(hasColor, PaperCard::getRules).negate()); PaperCard exchangeCard = null; diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java b/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java index a4a26cecf06..3b8df8b73ff 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java @@ -11,7 +11,6 @@ import forge.item.PaperCard; import forge.util.Iterables; import forge.util.MyRandom; -import forge.util.Predicates; public class WinstonDraft extends BoosterDraft { private WinstonDraftAI draftAI = null; @@ -41,7 +40,7 @@ private void initializeWinstonDraft() { for (final Supplier> supply : this.product) { for (int j = 0; j < NUM_PLAYERS; j++) { // Remove Basic Lands from draft for simplicity - for (final PaperCard paperCard : Iterables.filter(supply.get(), Predicates.not(PaperCard.Predicates.Presets.IS_BASIC_LAND))) { + for (final PaperCard paperCard : Iterables.filter(supply.get(), PaperCard.Predicates.Presets.IS_BASIC_LAND.negate())) { this.deck.add(paperCard); } } diff --git a/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java b/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java index 6c559cb04ee..4691c2c4d07 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java @@ -11,7 +11,6 @@ import forge.interfaces.IGameController; import forge.interfaces.ILobbyListener; import forge.util.Iterables; -import forge.util.Predicates; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.*; import io.netty.channel.nio.NioEventLoopGroup; @@ -33,6 +32,7 @@ import java.util.Collections; import java.util.Enumeration; import java.util.Map; +import java.util.function.Predicate; public final class FServerManager { private static FServerManager instance = null; @@ -147,7 +147,8 @@ public void broadcastExcept(final NetEvent event, final RemoteClient notTo) { broadcastExcept(event, Collections.singleton(notTo)); } public void broadcastExcept(final NetEvent event, final Collection notTo) { - broadcastTo(event, Iterables.filter(clients.values(), Predicates.not(notTo::contains))); + Predicate filter = ((Predicate) notTo::contains).negate(); + broadcastTo(event, Iterables.filter(clients.values(), filter)); } private void broadcastTo(final NetEvent event, final Iterable to) { for (final RemoteClient client : to) { diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java index 9f40533d9ff..e6c77014264 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java @@ -77,15 +77,15 @@ public final class BoosterUtils { private static final Predicate filterPioneerNotStandard = Predicates.and( CardEdition.Predicates.CAN_MAKE_BOOSTER, - Predicates.and(filterPioneer, Predicates.not(formats.getStandard().editionLegalPredicate))); + Predicates.and(filterPioneer, formats.getStandard().editionLegalPredicate.negate())); private static final Predicate filterModernNotPioneer = Predicates.and( CardEdition.Predicates.CAN_MAKE_BOOSTER, - Predicates.and(filterModern, Predicates.not(filterPioneer))); + Predicates.and(filterModern, filterPioneer.negate())); /** The filter not ext. */ private static final Predicate filterNotModern = Predicates.and(CardEdition.Predicates.CAN_MAKE_BOOSTER, - Predicates.not(filterModern)); + filterModern.negate()); /** * Gets the quest starter deck. diff --git a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java index 792ed0a8ae4..bef26e0a920 100644 --- a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java +++ b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java @@ -1574,7 +1574,7 @@ else if (piece.equals(Operator.NOT)) { predPiece = ((AdvancedSearch.Filter) piece).getPredicate(); } if (applyNot) { - predPiece = Predicates.not(predPiece); + predPiece = predPiece.negate(); applyNot = false; } if (pred == null) { diff --git a/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java b/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java index b7ff9982213..4cf79adfd06 100644 --- a/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java +++ b/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java @@ -133,7 +133,7 @@ private void resolve(final boolean alwaysPopOperator) { case NOT: operators.pop(); left = operands.pop(); - operands.push(Predicates.not(left)); + operands.push(left.negate()); break; default: if (alwaysPopOperator) { diff --git a/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java b/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java index 916d95a2566..80f031d57cc 100644 --- a/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java +++ b/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java @@ -50,7 +50,7 @@ public static Predicate buildTextFilter(String text, boolean invert, try { Predicate filter = expression.evaluate(); if (filter != null) { - return Predicates.compose(invert ? Predicates.not(filter) : filter, PaperCard::getRules); + return Predicates.compose(invert ? filter.negate() : filter, PaperCard::getRules); } } catch (Exception ignored) { @@ -71,7 +71,8 @@ public static Predicate buildTextFilter(String text, boolean invert, terms.add(Predicates.or(subands)); } - Predicate textFilter = invert ? Predicates.not(Predicates.or(terms)) : Predicates.and(terms); + Predicate textFilter; + textFilter = invert ? Predicates.or(terms).negate() : Predicates.and(terms); return Predicates.compose(textFilter, PaperCard::getRules); } diff --git a/forge-gui/src/main/java/forge/localinstance/achievements/AgainstAllOdds.java b/forge-gui/src/main/java/forge/localinstance/achievements/AgainstAllOdds.java index 430faaf2872..530602980b9 100644 --- a/forge-gui/src/main/java/forge/localinstance/achievements/AgainstAllOdds.java +++ b/forge-gui/src/main/java/forge/localinstance/achievements/AgainstAllOdds.java @@ -6,7 +6,6 @@ import forge.game.player.PlayerPredicates; import forge.util.Iterables; import forge.util.Localizer; -import forge.util.Predicates; public class AgainstAllOdds extends Achievement { public AgainstAllOdds() { @@ -28,7 +27,7 @@ protected int evaluate(Player player, Game game) { otherOpps.remove(opp); if (Iterables.all(otherOpps, PlayerPredicates.sameTeam(opp))) { teamNum++; - } else if (Iterables.all(otherOpps, Predicates.not(PlayerPredicates.sameTeam(opp)))) { + } else if (Iterables.all(otherOpps, PlayerPredicates.sameTeam(opp).negate())) { teamNum--; } } diff --git a/forge-gui/src/main/java/forge/player/HumanCostDecision.java b/forge-gui/src/main/java/forge/player/HumanCostDecision.java index 150c6bbc379..dee557e4bd8 100644 --- a/forge-gui/src/main/java/forge/player/HumanCostDecision.java +++ b/forge-gui/src/main/java/forge/player/HumanCostDecision.java @@ -123,7 +123,7 @@ public PaymentDecision visit(final CostDiscard cost) { } final Card first = inp.getFirstSelected(); discarded.add(first); - hand = CardLists.filter(hand, Predicates.not(CardPredicates.sharesNameWith(first))); + hand = CardLists.filter(hand, CardPredicates.sharesNameWith(first).negate()); c--; } return PaymentDecision.card(discarded); @@ -1182,7 +1182,7 @@ public PaymentDecision visit(final CostSacrifice cost) { } final Card first = inp.getFirstSelected(); chosen.add(first); - list = CardLists.filter(list, Predicates.not(CardPredicates.sharesNameWith(first))); + list = CardLists.filter(list, CardPredicates.sharesNameWith(first).negate()); c--; } return PaymentDecision.card(chosen); diff --git a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java index 899fa4acf01..8bbf1558960 100644 --- a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java +++ b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java @@ -291,7 +291,7 @@ public static HashMap>> initializeComma //get all cards final Iterable cards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards() - , Predicates.compose(Predicates.not(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES), PaperCard::getRules)); + , Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES.negate(), PaperCard::getRules)); List cardList = Lists.newArrayList(cards); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); @@ -350,7 +350,7 @@ public static HashMap>> initializeComma public static void updateLegendMatrix(Deck deck, PaperCard legend, Map cardIntegerMap, Map legendIntegerMap, int[][] matrix){ for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(), - Predicates.compose(Predicates.not(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES), PaperCard::getRules))){ + Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES.negate(), PaperCard::getRules))){ if (!pairCard.getName().equals(legend.getName())){ try { int old = matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(pairCard.getName())]; From b37f8725baac5c44d0747e90512c6cd610dcc708 Mon Sep 17 00:00:00 2001 From: Jetz Date: Tue, 3 Sep 2024 20:22:45 -0400 Subject: [PATCH 19/68] Guava migration - Inline `Predicates.and` --- .../java/forge/ai/AiAttackController.java | 2 +- .../main/java/forge/ai/ComputerUtilCard.java | 8 ++--- .../main/java/forge/ai/ComputerUtilCost.java | 3 +- .../main/java/forge/ai/ComputerUtilMana.java | 3 +- .../src/main/java/forge/ai/SpecialCardAi.java | 9 +++--- .../java/forge/ai/ability/ChooseSourceAi.java | 5 ++- .../forge/ai/ability/CountersRemoveAi.java | 5 ++- .../java/forge/ai/ability/DestroyAllAi.java | 5 ++- .../java/forge/ai/ability/LifeLoseAi.java | 3 +- .../main/java/forge/ai/ability/MeldAi.java | 11 +++---- .../src/main/java/forge/card/CardDb.java | 4 +-- .../src/main/java/forge/card/CardEdition.java | 2 +- .../java/forge/card/CardRulesPredicates.java | 11 +++---- .../forge/deck/generation/DeckGenPool.java | 3 +- .../deck/generation/DeckGeneratorBase.java | 6 ++-- .../main/java/forge/item/SealedProduct.java | 5 ++- .../item/generation/BoosterGenerator.java | 2 +- .../src/main/java/forge/util/Predicates.java | 6 +--- .../src/main/java/forge/game/GameFormat.java | 8 ++--- .../game/ability/effects/VentureEffect.java | 4 +-- .../main/java/forge/game/card/CardLists.java | 4 +-- .../game/combat/AttackRestrictionType.java | 6 ++-- .../src/main/java/forge/game/phase/Untap.java | 3 +- .../main/java/forge/game/player/Player.java | 7 ++-- .../StaticAbilityPanharmonicon.java | 16 ++++------ .../itemmanager/filters/CardPowerFilter.java | 2 +- .../filters/CardToughnessFilter.java | 2 +- .../controllers/CEditorCommander.java | 2 +- .../adventure/data/AdventureEventData.java | 3 +- .../src/forge/adventure/util/CardUtil.java | 3 +- .../src/forge/deck/FDeckEditor.java | 2 +- .../itemmanager/filters/CardPowerFilter.java | 2 +- .../filters/CardToughnessFilter.java | 2 +- .../planarconquest/ConquestAEtherScreen.java | 2 +- .../forge/deck/CommanderDeckGenerator.java | 10 +++--- .../src/main/java/forge/deck/DeckProxy.java | 5 ++- .../src/main/java/forge/deck/DeckgenUtil.java | 14 ++++---- .../limited/CardThemedDeckBuilder.java | 10 +++--- .../forge/gamemodes/quest/BoosterUtils.java | 32 ++++++++----------- .../gamemodes/quest/QuestRewardCard.java | 6 ++-- .../forge/gamemodes/quest/QuestUtilCards.java | 8 ++--- .../forge/itemmanager/AdvancedSearch.java | 2 +- .../forge/itemmanager/BooleanExpression.java | 2 +- .../java/forge/itemmanager/SFilterUtil.java | 2 +- .../src/main/java/forge/model/FModel.java | 9 ++++-- 45 files changed, 119 insertions(+), 142 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiAttackController.java b/forge-ai/src/main/java/forge/ai/AiAttackController.java index 6994fd30551..b53096ec245 100644 --- a/forge-ai/src/main/java/forge/ai/AiAttackController.java +++ b/forge-ai/src/main/java/forge/ai/AiAttackController.java @@ -613,7 +613,7 @@ private boolean doAssault() { // and do not predict the blocker limit (which is safer) if (Iterables.any(defendingOpponent.getLandsInPlay(), CardPredicates.Presets.UNTAPPED)) { maxBlockersAfterCrew += CardLists.count(CardLists.getNotType(defendingOpponent.getCardsIn(ZoneType.Battlefield), "Creature"), - Predicates.and(CardPredicates.isType("Vehicle"), CardPredicates.Presets.UNTAPPED)); + CardPredicates.isType("Vehicle").and(CardPredicates.Presets.UNTAPPED)); } } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index db58b45df54..4498d3d6803 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -504,10 +504,10 @@ public static Card getWorstPermanentAI(final Iterable list, final boolean } if (hasEnchantmants || hasArtifacts) { - final List ae = CardLists.filter(list, Predicates.and( - Predicates.or(CardPredicates.Presets.ARTIFACTS, CardPredicates.Presets.ENCHANTMENTS), - card -> !card.hasSVar("DoNotDiscardIfAble") - )); + final List ae = CardLists.filter(list, + Predicates.or(CardPredicates.Presets.ARTIFACTS, CardPredicates.Presets.ENCHANTMENTS) + .and(card -> !card.hasSVar("DoNotDiscardIfAble")) + ); return getCheapestPermanentAI(ae, null, false); } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java index e9a16f5dc20..93cd73d3a63 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java @@ -23,7 +23,6 @@ import forge.game.zone.ZoneType; import forge.util.Iterables; import forge.util.MyRandom; -import forge.util.Predicates; import forge.util.TextUtil; import forge.util.collect.FCollectionView; import org.apache.commons.lang3.ObjectUtils; @@ -924,7 +923,7 @@ public static int getMaxXValue(SpellAbility sa, Player ai, final boolean effect) public static CardCollection paymentChoicesWithoutTargets(Iterable choices, SpellAbility source, Player ai) { if (source.usesTargeting()) { final CardCollection targets = new CardCollection(source.getTargets().getTargetCards()); - choices = Iterables.filter(choices, Predicates.and(CardPredicates.isController(ai), targets::contains).negate()); + choices = Iterables.filter(choices, CardPredicates.isController(ai).and(targets::contains).negate()); } return new CardCollection(choices); } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index 3b97e292d47..66fc10d90d8 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -43,7 +43,6 @@ import forge.game.zone.ZoneType; import forge.util.Iterables; import forge.util.MyRandom; -import forge.util.Predicates; import forge.util.TextUtil; import org.apache.commons.lang3.StringUtils; @@ -314,7 +313,7 @@ public static SpellAbility chooseManaAbility(ManaCostBeingPaid cost, SpellAbilit // For cards like Genju of the Cedars, make sure we're not attaching to the same land that will // be tapped to pay its own cost if there's another untapped land like that available if (ma.getHostCard().equals(sa.getTargetCard())) { - if (CardLists.count(ai.getCardsIn(ZoneType.Battlefield), Predicates.and(CardPredicates.nameEquals(ma.getHostCard().getName()), CardPredicates.Presets.UNTAPPED)) > 1) { + if (CardLists.count(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals(ma.getHostCard().getName()).and(CardPredicates.Presets.UNTAPPED)) > 1) { continue; } } diff --git a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java index 49f93723779..73bac61e64e 100644 --- a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java +++ b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java @@ -52,6 +52,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.function.Predicate; /** * Special logic for individual cards @@ -359,7 +360,7 @@ public static class DesecrationDemon { public static boolean considerSacrificingCreature(final Player ai, final SpellAbility sa) { CardCollection flyingCreatures = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), - Predicates.and(CardPredicates.Presets.UNTAPPED, Predicates.or( + CardPredicates.Presets.UNTAPPED.and(Predicates.or( CardPredicates.hasKeyword(Keyword.FLYING), CardPredicates.hasKeyword(Keyword.REACH)))); boolean hasUsefulBlocker = false; @@ -1296,7 +1297,7 @@ public static boolean considerFirstTarget(final Player ai, final SpellAbility sa public static boolean considerSecondTarget(final Player ai, final SpellAbility sa) { Card firstTgt = sa.getParent().getTargetCard(); Iterable candidates = Iterables.filter(ai.getOpponents().getCardsIn(ZoneType.Battlefield), - Predicates.and(CardPredicates.sharesCardTypeWith(firstTgt), CardPredicates.isTargetableBy(sa))); + CardPredicates.sharesCardTypeWith(firstTgt).and(CardPredicates.isTargetableBy(sa))); Card secondTgt = Aggregates.random(candidates); if (secondTgt != null) { sa.resetTargets(); @@ -1316,7 +1317,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { return false; } - int aiLands = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Predicates.and(CardPredicates.Presets.LANDS, CardPredicates.Presets.BASIC_LANDS.negate())).size(); + int aiLands = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.LANDS.and(CardPredicates.Presets.BASIC_LANDS.negate())).size(); boolean hasBridge = false; for (Card c : ai.getCardsIn(ZoneType.Battlefield)) { @@ -1334,7 +1335,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { } for (Player opp : ai.getOpponents()) { - int oppLands = CardLists.filter(opp.getCardsIn(ZoneType.Battlefield), Predicates.and(CardPredicates.Presets.LANDS, CardPredicates.Presets.BASIC_LANDS.negate())).size(); + int oppLands = CardLists.filter(opp.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.LANDS.and(CardPredicates.Presets.BASIC_LANDS.negate())).size(); // Always if enemy would die and we don't! // TODO : predict actual damage instead of assuming it'll be 2*lands // Don't if we lose, unless we lose anyway to unblocked creatures next turn diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java index 71520a03379..08f9251a77a 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java @@ -24,7 +24,6 @@ import forge.game.zone.ZoneType; import forge.util.Aggregates; import forge.util.Iterables; -import forge.util.Predicates; public class ChooseSourceAi extends SpellAbilityAi { @@ -134,8 +133,8 @@ public Card chooseSingleCard(final Player aiChoser, SpellAbility sa, Iterable oppCreatures = CardLists.filter(options, Predicates.and(CardPredicates.Presets.CREATURES, - CardPredicates.isOwner(aiChoser).negate())); + List oppCreatures = CardLists.filter(options, + CardPredicates.Presets.CREATURES.and(CardPredicates.isOwner(aiChoser).negate())); List aiNonCreatures = CardLists.filter(options, CardPredicates.Presets.CREATURES.negate() .and(CardPredicates.Presets.PERMANENTS) diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java index 3d0beff19a4..20de084c414 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java @@ -26,7 +26,6 @@ import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; import forge.util.Iterables; -import forge.util.Predicates; public class CountersRemoveAi extends SpellAbilityAi { @@ -183,7 +182,7 @@ private boolean doTgt(Player ai, SpellAbility sa, boolean mandatory) { list = CardLists.filter(list, CardPredicates.isTargetableBy(sa)); CardCollection planeswalkerList = CardLists.filter(list, - Predicates.and(CardPredicates.Presets.PLANESWALKERS, CardPredicates.isControlledByAnyOf(ai.getOpponents())), + CardPredicates.Presets.PLANESWALKERS.and(CardPredicates.isControlledByAnyOf(ai.getOpponents())), CardPredicates.hasLessCounter(CounterEnumType.LOYALTY, amount)); if (!planeswalkerList.isEmpty()) { @@ -223,7 +222,7 @@ private boolean doTgt(Player ai, SpellAbility sa, boolean mandatory) { // remove P1P1 counters from opposing creatures CardCollection oppP1P1List = CardLists.filter(list, - Predicates.and(CardPredicates.Presets.CREATURES, CardPredicates.isControlledByAnyOf(ai.getOpponents())), + CardPredicates.Presets.CREATURES.and(CardPredicates.isControlledByAnyOf(ai.getOpponents())), CardPredicates.hasCounter(CounterEnumType.P1P1)); if (!oppP1P1List.isEmpty()) { sa.getTargets().add(ComputerUtilCard.getBestCreatureAI(oppP1P1List)); diff --git a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java index c685c5fb6d0..24d0d00ee01 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java @@ -14,7 +14,6 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Predicates; import java.util.function.Predicate; @@ -110,8 +109,8 @@ public static boolean doMassRemovalLogic(Player ai, SpellAbility sa) { // Special handling for Raiding Party if (logic.equals("RaidingParty")) { - int numAiCanSave = Math.min(CardLists.count(ai.getCreaturesInPlay(), Predicates.and(CardPredicates.isColor(MagicColor.WHITE), CardPredicates.Presets.UNTAPPED)) * 2, ailist.size()); - int numOppsCanSave = Math.min(CardLists.count(ai.getOpponents().getCreaturesInPlay(), Predicates.and(CardPredicates.isColor(MagicColor.WHITE), CardPredicates.Presets.UNTAPPED)) * 2, opplist.size()); + int numAiCanSave = Math.min(CardLists.count(ai.getCreaturesInPlay(), CardPredicates.isColor(MagicColor.WHITE).and(CardPredicates.Presets.UNTAPPED)) * 2, ailist.size()); + int numOppsCanSave = Math.min(CardLists.count(ai.getOpponents().getCreaturesInPlay(), CardPredicates.isColor(MagicColor.WHITE).and(CardPredicates.Presets.UNTAPPED)) * 2, opplist.size()); return numOppsCanSave < opplist.size() && (ailist.size() - numAiCanSave < opplist.size() - numOppsCanSave); } diff --git a/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java b/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java index 7a2a2b6fd11..f020dd25ca3 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java @@ -14,7 +14,6 @@ import forge.game.player.PlayerCollection; import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; -import forge.util.Predicates; import forge.util.collect.FCollection; public class LifeLoseAi extends SpellAbilityAi { @@ -128,7 +127,7 @@ protected boolean checkApiLogic(Player ai, SpellAbility sa) { final PlayerCollection tgtPlayers = getPlayers(ai, sa); // TODO: check against the amount we could obtain when multiple activations are possible PlayerCollection filteredPlayer = tgtPlayers - .filter(Predicates.and(PlayerPredicates.isOpponentOf(ai), PlayerPredicates.lifeLessOrEqualTo(amount))); + .filter(PlayerPredicates.isOpponentOf(ai).and(PlayerPredicates.lifeLessOrEqualTo(amount))); // killing opponents asap if (!filteredPlayer.isEmpty()) { return true; diff --git a/forge-ai/src/main/java/forge/ai/ability/MeldAi.java b/forge-ai/src/main/java/forge/ai/ability/MeldAi.java index bf33791404e..46ddf23c286 100644 --- a/forge-ai/src/main/java/forge/ai/ability/MeldAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/MeldAi.java @@ -7,7 +7,6 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Iterables; -import forge.util.Predicates; public class MeldAi extends SpellAbilityAi { @Override @@ -19,11 +18,11 @@ protected boolean checkApiLogic(Player aiPlayer, SpellAbility sa) { if (cardsOTB.isEmpty()) { return false; } - - boolean hasPrimaryMeld = Iterables.any(cardsOTB, Predicates.and( - CardPredicates.nameEquals(primaryMeld), CardPredicates.isOwner(aiPlayer))); - boolean hasSecondaryMeld = Iterables.any(cardsOTB, Predicates.and( - CardPredicates.nameEquals(secondaryMeld), CardPredicates.isOwner(aiPlayer))); + + boolean hasPrimaryMeld = Iterables.any(cardsOTB, + CardPredicates.nameEquals(primaryMeld).and(CardPredicates.isOwner(aiPlayer))); + boolean hasSecondaryMeld = Iterables.any(cardsOTB, + CardPredicates.nameEquals(secondaryMeld).and(CardPredicates.isOwner(aiPlayer))); return hasPrimaryMeld && hasSecondaryMeld && sa.getHostCard().getName().equals(primaryMeld); } diff --git a/forge-core/src/main/java/forge/card/CardDb.java b/forge-core/src/main/java/forge/card/CardDb.java index f4aaf1eb293..d0bd09571d5 100644 --- a/forge-core/src/main/java/forge/card/CardDb.java +++ b/forge-core/src/main/java/forge/card/CardDb.java @@ -800,7 +800,7 @@ private PaperCard tryToGetCardFromEditions(String cardInfo, CardArtPreference ar }; } else // filter candidates based on requested artIndex cardQueryFilter = card -> card.getArtIndex() == cr.artIndex; - cardQueryFilter = Predicates.and(cardQueryFilter, filter); + cardQueryFilter = cardQueryFilter.and(filter); cards = getAllCards(cr.cardName, cardQueryFilter); // Note: No need to check whether "cards" is empty; the next for loop will validate condition at L699 if (cards.size() == 1) // if only one candidate, there much else we should do @@ -879,7 +879,7 @@ public int getArtCount(String cardName, String setCode, String functionalVariant return 0; Predicate predicate = card -> card.getEdition().equalsIgnoreCase(setCode); if(functionalVariantName != null && !functionalVariantName.equals(IPaperCard.NO_FUNCTIONAL_VARIANT)) { - predicate = Predicates.and(predicate, card -> functionalVariantName.equals(card.getFunctionalVariant())); + predicate = predicate.and(card -> functionalVariantName.equals(card.getFunctionalVariant())); } Collection cardsInSet = getAllCards(cardName, predicate); return cardsInSet.size(); diff --git a/forge-core/src/main/java/forge/card/CardEdition.java b/forge-core/src/main/java/forge/card/CardEdition.java index 3126ea24a98..83673de5470 100644 --- a/forge-core/src/main/java/forge/card/CardEdition.java +++ b/forge-core/src/main/java/forge/card/CardEdition.java @@ -904,7 +904,7 @@ public static CardEdition getPreferredArtEditionWithAllBasicLands() { CardDb.CardArtPreference artPreference = StaticData.instance().getCardArtPreference(); Iterable editionsWithBasicLands = Iterables.filter( StaticData.instance().getEditions().getOrderedEditions(), - forge.util.Predicates.and(hasBasicLands, artPreference::accept)); + hasBasicLands.and(artPreference::accept)); Iterator editionsIterator = editionsWithBasicLands.iterator(); List selectedEditions = new ArrayList(); while (editionsIterator.hasNext()) diff --git a/forge-core/src/main/java/forge/card/CardRulesPredicates.java b/forge-core/src/main/java/forge/card/CardRulesPredicates.java index 121e2b48502..38865f2a441 100644 --- a/forge-core/src/main/java/forge/card/CardRulesPredicates.java +++ b/forge-core/src/main/java/forge/card/CardRulesPredicates.java @@ -574,14 +574,11 @@ public static class Presets { public static final Predicate IS_VANGUARD = CardRulesPredicates.coreType(true, CardType.CoreType.Vanguard); public static final Predicate IS_CONSPIRACY = CardRulesPredicates.coreType(true, CardType.CoreType.Conspiracy); public static final Predicate IS_DUNGEON = CardRulesPredicates.coreType(true, CardType.CoreType.Dungeon); - public static final Predicate IS_ATTRACTION = Predicates.and(Presets.IS_ARTIFACT, - CardRulesPredicates.subType("Attraction") - ); + public static final Predicate IS_ATTRACTION = Presets.IS_ARTIFACT.and(CardRulesPredicates.subType("Attraction")); + public static final Predicate IS_NON_LAND = CardRulesPredicates.coreType(false, CardType.CoreType.Land); - public static final Predicate CAN_BE_BRAWL_COMMANDER = Predicates.and(Presets.IS_LEGENDARY, - Predicates.or(Presets.IS_CREATURE, Presets.IS_PLANESWALKER)); - public static final Predicate CAN_BE_TINY_LEADERS_COMMANDER = Predicates.and(Presets.IS_LEGENDARY, - Predicates.or(Presets.IS_CREATURE, Presets.IS_PLANESWALKER)); + public static final Predicate CAN_BE_BRAWL_COMMANDER = Presets.IS_LEGENDARY.and(Predicates.or(Presets.IS_CREATURE, Presets.IS_PLANESWALKER)); + public static final Predicate CAN_BE_TINY_LEADERS_COMMANDER = Presets.IS_LEGENDARY.and(Predicates.or(Presets.IS_CREATURE, Presets.IS_PLANESWALKER)); /** The Constant IS_NON_CREATURE_SPELL. **/ public static final Predicate IS_NON_CREATURE_SPELL = diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java b/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java index e45fa4efb00..d395d108ce6 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java @@ -7,7 +7,6 @@ import forge.item.IPaperCard; import forge.item.PaperCard; import forge.util.Iterables; -import forge.util.Predicates; public class DeckGenPool implements IDeckGenPool { private final Map cards = new HashMap<>(); @@ -38,7 +37,7 @@ public PaperCard getCard(String name) { @Override public PaperCard getCard(String name, String edition) { - Predicate filter = Predicates.and(IPaperCard.Predicates.printedInSet(edition),IPaperCard.Predicates.name(name)); + Predicate filter = IPaperCard.Predicates.printedInSet(edition).and(IPaperCard.Predicates.name(name)); Iterable editionCards=Iterables.filter(cards.values(), filter); if (editionCards.iterator().hasNext()){ return editionCards.iterator().next(); diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index 82ece55a661..c3fc0d27493 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -108,8 +108,8 @@ public CardPool getDeck(final int size, final boolean forAi) { protected boolean setBasicLandPool(String edition){ Predicate isSetBasicLand; if (edition !=null){ - isSetBasicLand = Predicates.and(IPaperCard.Predicates.printedInSet(edition), - Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules)); + isSetBasicLand = IPaperCard.Predicates.printedInSet(edition) + .and(Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules)); }else{ isSetBasicLand = Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules); } @@ -327,7 +327,7 @@ protected static void increment(Map map, String key, int delta) map.put(key, boxed == null ? delta : boxed + delta); } - public static final Predicate AI_CAN_PLAY = Predicates.and(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, CardRulesPredicates.IS_KEPT_IN_RANDOM_DECKS); + public static final Predicate AI_CAN_PLAY = CardRulesPredicates.IS_KEPT_IN_AI_DECKS.and(CardRulesPredicates.IS_KEPT_IN_RANDOM_DECKS); public static final Predicate COLORLESS_CARDS = c -> { ManaCost mc = c.getManaCost(); diff --git a/forge-core/src/main/java/forge/item/SealedProduct.java b/forge-core/src/main/java/forge/item/SealedProduct.java index c63c97cf3dc..2c2f6c1e342 100644 --- a/forge-core/src/main/java/forge/item/SealedProduct.java +++ b/forge-core/src/main/java/forge/item/SealedProduct.java @@ -113,9 +113,8 @@ protected PaperCard getRandomBasicLand(final String setCode) { } protected List getRandomBasicLands(final String setCode, final int count) { - Predicate cardsRule = Predicates.and( - IPaperCard.Predicates.printedInSet(setCode), - Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules)); + Predicate cardsRule = IPaperCard.Predicates.printedInSet(setCode) + .and(Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules)); return Aggregates.random(Iterables.filter(StaticData.instance().getCommonCards().getAllCards(), cardsRule), count); } } diff --git a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java index 4ae456c4d7b..d95b056190d 100644 --- a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java +++ b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java @@ -609,7 +609,7 @@ public static PrintSheet makeSheet(String sheetKey, Iterable src) { String mainCode = operators.isEmpty() ? null : operators.get(0).trim(); if (null == mainCode || mainCode.equalsIgnoreCase(BoosterSlots.ANY)) { // no restriction on rarity - Predicate predicate = Predicates.and(setPred, extraPred); + Predicate predicate = setPred.and(extraPred); ps.addAll(Iterables.filter(src, predicate)); } else if (mainCode.equalsIgnoreCase(BoosterSlots.UNCOMMON_RARE)) { // for sets like ARN, where U1 cards are considered rare and U3 are uncommon diff --git a/forge-core/src/main/java/forge/util/Predicates.java b/forge-core/src/main/java/forge/util/Predicates.java index 483878b031f..1a773baea14 100644 --- a/forge-core/src/main/java/forge/util/Predicates.java +++ b/forge-core/src/main/java/forge/util/Predicates.java @@ -16,6 +16,7 @@ public static Predicate or(Iterable> compo return x -> Iterables.any(components, (Predicate>) i -> i.test(x)); } + //TODO: Most uses of this are with the function PaperCard::getRules. Maybe we should just have PaperCardPredicates? public static Predicate compose(Predicate predicate, Function function) { return x -> predicate.test(function.apply(x)); } @@ -23,11 +24,6 @@ public static Predicate compose(Predicate predicate, Function Predicate and(Predicate first, Predicate second) { - //TODO: remove casting? - return ((Predicate) first).and(second); - } - public static Predicate or(Predicate first, Predicate second) { //TODO: remove casting? return ((Predicate) first).or(second); diff --git a/forge-game/src/main/java/forge/game/GameFormat.java b/forge-game/src/main/java/forge/game/GameFormat.java index ca7517c642f..56f5ed939e5 100644 --- a/forge-game/src/main/java/forge/game/GameFormat.java +++ b/forge-game/src/main/java/forge/game/GameFormat.java @@ -141,13 +141,13 @@ protected Predicate buildFilter(boolean printed) { Predicate p = IPaperCard.Predicates.names(this.getBannedCardNames()).negate(); if (FormatSubType.ARENA.equals(this.getFormatSubType())) { - p = Predicates.and(p, IPaperCard.Predicates.Presets.IS_UNREBALANCED.negate()); + p = p.and(IPaperCard.Predicates.Presets.IS_UNREBALANCED.negate()); } else { - p = Predicates.and(p, IPaperCard.Predicates.Presets.IS_REBALANCED.negate()); + p = p.and(IPaperCard.Predicates.Presets.IS_REBALANCED.negate()); } if (!this.getAllowedSetCodes().isEmpty()) { - p = Predicates.and(p, printed ? + p = p.and(printed ? IPaperCard.Predicates.printedInSets(this.getAllowedSetCodes(), printed) : StaticData.instance().getCommonCards().wasPrintedInSets(this.getAllowedSetCodes())); } @@ -156,7 +156,7 @@ protected Predicate buildFilter(boolean printed) { for (CardRarity cr: this.getAllowedRarities()) { crp.add(StaticData.instance().getCommonCards().wasPrintedAtRarity(cr)); } - p = Predicates.and(p, Predicates.or(crp)); + p = p.and(Predicates.or(crp)); } if (!this.getAdditionalCards().isEmpty()) { p = Predicates.or(p, IPaperCard.Predicates.names(this.getAdditionalCards())); diff --git a/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java b/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java index f8f3503e301..c8ded7f8eed 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java @@ -46,8 +46,8 @@ private Card getDungeonCard(SpellAbility sa, Player player, Map cardList, Predicate fil } public static CardCollection filter(Iterable cardList, Predicate f1, Predicate f2) { - return new CardCollection(Iterables.filter(cardList, Predicates.and(f1, f2))); + return new CardCollection(Iterables.filter(cardList, f1.and(f2))); } public static CardCollection filter(Iterable cardList, Iterable> filt) { @@ -337,7 +337,7 @@ public static List filterAsList(Iterable cardList, Predicate f } public static List filterAsList(Iterable cardList, Predicate f1, Predicate f2) { - return Lists.newArrayList(Iterables.filter(cardList, Predicates.and(f1, f2))); + return Lists.newArrayList(Iterables.filter(cardList, f1.and(f2))); } public static List filterAsList(Iterable cardList, Iterable> filt) { diff --git a/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java b/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java index c16d48b9d48..71eadf7c134 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java +++ b/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java @@ -3,7 +3,6 @@ import forge.card.MagicColor; import forge.game.card.Card; import forge.game.card.CardPredicates; -import forge.util.Predicates; import java.util.function.Predicate; @@ -21,10 +20,9 @@ public Predicate getPredicate(final Card attacker) { case NEED_GREATER_POWER: return CardPredicates.hasGreaterPowerThan(attacker.getNetPower()); case NEED_BLACK_OR_GREEN: - return Predicates.and( - CardPredicates.isColor((byte) (MagicColor.BLACK | MagicColor.GREEN)), + return CardPredicates.isColor((byte) (MagicColor.BLACK | MagicColor.GREEN)) // may explicitly not be black/green itself - ((Predicate) attacker::equals).negate()); + .and(((Predicate) attacker::equals).negate()); case NOT_ALONE: return x -> true; default: diff --git a/forge-game/src/main/java/forge/game/phase/Untap.java b/forge-game/src/main/java/forge/game/phase/Untap.java index f8808f9ba1b..62ff222810c 100644 --- a/forge-game/src/main/java/forge/game/phase/Untap.java +++ b/forge-game/src/main/java/forge/game/phase/Untap.java @@ -45,7 +45,6 @@ import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; import forge.util.Iterables; -import forge.util.Predicates; /** *

@@ -114,7 +113,7 @@ public static boolean canUntap(final Card c) { */ private void doUntap() { final Player player = game.getPhaseHandler().getPlayerTurn(); - final Predicate tappedCanUntap = Predicates.and(Presets.TAPPED, CANUNTAP); + final Predicate tappedCanUntap = Presets.TAPPED.and(CANUNTAP); Map untapMap = Maps.newHashMap(); CardCollection list = new CardCollection(player.getCardsIn(ZoneType.Battlefield)); diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index fb9f6215db0..20428eb251b 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -63,6 +63,7 @@ import java.util.*; import java.util.Map.Entry; +import java.util.function.Predicate; /** *

@@ -3749,9 +3750,9 @@ public void addCycled(SpellAbility sp) { public boolean hasUrzaLands() { final CardCollectionView landsControlled = getCardsIn(ZoneType.Battlefield); - return Iterables.any(landsControlled, Predicates.and(CardPredicates.isType("Urza's"), CardPredicates.isType("Mine"))) - && Iterables.any(landsControlled, Predicates.and(CardPredicates.isType("Urza's"), CardPredicates.isType("Power-Plant"))) - && Iterables.any(landsControlled, Predicates.and(CardPredicates.isType("Urza's"), CardPredicates.isType("Tower"))); + return Iterables.any(landsControlled, CardPredicates.isType("Urza's").and(CardPredicates.isType("Mine"))) + && Iterables.any(landsControlled, CardPredicates.isType("Urza's").and(CardPredicates.isType("Power-Plant"))) + && Iterables.any(landsControlled, CardPredicates.isType("Urza's").and(CardPredicates.isType("Tower"))); } public void revealFaceDownCards() { diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityPanharmonicon.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityPanharmonicon.java index d38fc162a4d..651aa40dea8 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityPanharmonicon.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityPanharmonicon.java @@ -21,7 +21,6 @@ import java.util.Map; import forge.util.Iterables; -import forge.util.Predicates; import org.apache.commons.lang3.ArrayUtils; public class StaticAbilityPanharmonicon { @@ -178,10 +177,10 @@ public static boolean applyPanharmoniconAbility(final StaticAbility stAb, final Map dmgMap = (Map) runParams.get(AbilityKey.DamageMap); // 1. check it's valid cause for static // 2. and it must also be valid for trigger event - if (!Iterables.any(dmgMap.keySet(), Predicates.and( - GameObjectPredicates.matchesValidParam(stAb, "ValidSource"), - GameObjectPredicates.matchesValidParam(trigger, "ValidSource") - ))) { + if (!Iterables.any(dmgMap.keySet(), + GameObjectPredicates.matchesValidParam(stAb, "ValidSource") + .and(GameObjectPredicates.matchesValidParam(trigger, "ValidSource")) + )) { return false; } // DamageAmount$ can be ignored for now (its usage doesn't interact with ValidSource from either) @@ -191,10 +190,9 @@ public static boolean applyPanharmoniconAbility(final StaticAbility stAb, final return false; } Map dmgMap = (Map) runParams.get(AbilityKey.DamageMap); - if (!Iterables.any(dmgMap.keySet(), Predicates.and( - GameObjectPredicates.matchesValidParam(stAb, "ValidTarget"), - GameObjectPredicates.matchesValidParam(trigger, "ValidTarget") - ))) { + if (!Iterables.any(dmgMap.keySet(), GameObjectPredicates.matchesValidParam(stAb, "ValidTarget") + .and(GameObjectPredicates.matchesValidParam(trigger, "ValidTarget")) + )) { return false; } } diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java index e006b629b78..224ce72e726 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java @@ -33,7 +33,7 @@ protected Predicate buildPredicate() { if (predicate == null) { return x -> true; } - predicate = Predicates.and(predicate, CardRulesPredicates.Presets.IS_CREATURE); + predicate = predicate.and(CardRulesPredicates.Presets.IS_CREATURE); return Predicates.compose(predicate, PaperCard::getRules); } } diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java index 19bdd73cb3f..d6d186c07fc 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java @@ -33,7 +33,7 @@ protected Predicate buildPredicate() { if (predicate == null) { return x -> true; } - predicate = Predicates.and(predicate, CardRulesPredicates.Presets.IS_CREATURE); + predicate = predicate.and(CardRulesPredicates.Presets.IS_CREATURE); return Predicates.compose(predicate, PaperCard::getRules); } } diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java index 1d8461e568e..a0514c3df97 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java @@ -83,7 +83,7 @@ public CEditorCommander(final CDetailPicture cDetailPicture, GameType gameType0) if (gameType == GameType.Brawl){ GameFormat format = FModel.getFormats().get("Brawl"); Predicate commanderFilter = CardRulesPredicates.Presets.CAN_BE_BRAWL_COMMANDER; - commanderPool = ItemPool.createFrom(commonCards.getAllCardsNoAlt(Predicates.and(format.getFilterPrinted(), Predicates.compose(commanderFilter, PaperCard::getRules))), PaperCard.class); + commanderPool = ItemPool.createFrom(commonCards.getAllCardsNoAlt(format.getFilterPrinted().and(Predicates.compose(commanderFilter, PaperCard::getRules))), PaperCard.class); normalPool = ItemPool.createFrom(format.getAllCards(), PaperCard.class); } else { diff --git a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java index 3cb810b12c3..90e36c1c3a0 100644 --- a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java +++ b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java @@ -20,7 +20,6 @@ import forge.model.FModel; import forge.util.Aggregates; import forge.util.MyRandom; -import forge.util.Predicates; import org.apache.commons.lang3.tuple.Pair; import java.io.Serializable; @@ -319,7 +318,7 @@ public static Predicate selectSetPool() { private CardBlock pickWeightedCardBlock() { CardEdition.Collection editions = FModel.getMagicDb().getEditions(); Iterable src = FModel.getBlocks(); //all blocks - Predicate filter = Predicates.and(CardEdition.Predicates.CAN_MAKE_BOOSTER, selectSetPool()); + Predicate filter = CardEdition.Predicates.CAN_MAKE_BOOSTER.and(selectSetPool()); List allEditions = new ArrayList<>(); StreamSupport.stream(editions.spliterator(), false).filter(filter).filter(CardEdition::hasBoosterTemplate).collect(Collectors.toList()).iterator().forEachRemaining(allEditions::add); diff --git a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java index 2920d4f3a00..dfd2eabe7d0 100644 --- a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java +++ b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java @@ -22,7 +22,6 @@ import forge.model.FModel; import forge.util.Aggregates; import forge.util.Iterables; -import forge.util.Predicates; import java.text.SimpleDateFormat; import java.util.*; @@ -792,7 +791,7 @@ public static Deck generateBoosterPackAsDeck(CardEdition edition){ } public static Deck generateRandomBoosterPackAsDeck(final Predicate editionFilter) { - Predicate filter = Predicates.and(CardEdition.Predicates.CAN_MAKE_BOOSTER, editionFilter); + Predicate filter = CardEdition.Predicates.CAN_MAKE_BOOSTER.and(editionFilter); Iterable possibleEditions = Iterables.filter(FModel.getMagicDb().getEditions(), filter); if (!possibleEditions.iterator().hasNext()) { diff --git a/forge-gui-mobile/src/forge/deck/FDeckEditor.java b/forge-gui-mobile/src/forge/deck/FDeckEditor.java index 7687fa36bcb..66418274d6c 100644 --- a/forge-gui-mobile/src/forge/deck/FDeckEditor.java +++ b/forge-gui-mobile/src/forge/deck/FDeckEditor.java @@ -93,7 +93,7 @@ private ItemPool applyCardFilter(ItemPool cardPool, Predic } } else if (additionalFilter != null) { - filter = Predicates.and(filter, additionalFilter); + filter = filter.and(additionalFilter); } ItemPool filteredPool = new ItemPool<>(PaperCard.class); diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java index 1f0b1b0cfb4..7c9a21b6836 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java @@ -30,7 +30,7 @@ protected Predicate buildPredicate() { if (predicate == null) { return x -> true; } - predicate = Predicates.and(predicate, CardRulesPredicates.Presets.IS_CREATURE); + predicate = predicate.and(CardRulesPredicates.Presets.IS_CREATURE); return Predicates.compose(predicate, PaperCard::getRules); } } diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java index a12822a890b..70cac770f7e 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java @@ -30,7 +30,7 @@ protected Predicate buildPredicate() { if (predicate == null) { return x -> true; } - predicate = Predicates.and(predicate, CardRulesPredicates.Presets.IS_CREATURE); + predicate = predicate.and(CardRulesPredicates.Presets.IS_CREATURE); return Predicates.compose(predicate, PaperCard::getRules); } } diff --git a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java index e0c8e65349b..c07da345c23 100644 --- a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java +++ b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java @@ -389,7 +389,7 @@ private Predicate buildFilterPredicate(Predicate predicate if (predicate == null) { return selectedOption.getPredicate(); } - return Predicates.and(predicate, selectedOption.getPredicate()); + return predicate.and(selectedOption.getPredicate()); } @Override diff --git a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java index ac757f56d01..84aef7ff47a 100644 --- a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java @@ -40,8 +40,8 @@ public static List getCommanderDecks(final DeckFormat format, boolean } Predicate canPlay = isForAi ? DeckGeneratorBase.AI_CAN_PLAY : CardRulesPredicates.IS_KEPT_IN_RANDOM_DECKS; @SuppressWarnings("unchecked") - Iterable legends = Iterables.filter(uniqueCards.toFlatList(), Predicates.and(format.isLegalCommanderPredicate(), Predicates.compose( - canPlay, PaperCard::getRules))); + Iterable legends = Iterables.filter(uniqueCards.toFlatList(), format.isLegalCommanderPredicate() + .and(Predicates.compose(canPlay, PaperCard::getRules))); final List decks = new ArrayList<>(); for (PaperCard legend: legends) { decks.add(new CommanderDeckGenerator(legend, format, isForAi, isCardGen)); @@ -64,10 +64,8 @@ public static List getBrawlDecks(final DeckFormat format, boolean isF } Predicate canPlay = isForAi ? DeckGeneratorBase.AI_CAN_PLAY : CardRulesPredicates.IS_KEPT_IN_RANDOM_DECKS; @SuppressWarnings("unchecked") - Iterable legends = Iterables.filter(uniqueCards.toFlatList(), Predicates.and(format.isLegalCardPredicate(), - Predicates.compose(Predicates.and( - CardRulesPredicates.Presets.CAN_BE_BRAWL_COMMANDER, - canPlay), PaperCard::getRules))); + Iterable legends = Iterables.filter(uniqueCards.toFlatList(), format.isLegalCardPredicate() + .and(Predicates.compose(CardRulesPredicates.Presets.CAN_BE_BRAWL_COMMANDER.and(canPlay), PaperCard::getRules))); final List decks = new ArrayList<>(); for (PaperCard legend: legends) { decks.add(new CommanderDeckGenerator(legend, format, isForAi, isCardGen)); diff --git a/forge-gui/src/main/java/forge/deck/DeckProxy.java b/forge-gui/src/main/java/forge/deck/DeckProxy.java index 537457558f4..9d350b16962 100644 --- a/forge-gui/src/main/java/forge/deck/DeckProxy.java +++ b/forge-gui/src/main/java/forge/deck/DeckProxy.java @@ -18,7 +18,6 @@ import forge.util.BinaryUtil; import forge.util.IHasName; import forge.util.Iterables; -import forge.util.Predicates; import forge.util.storage.IStorage; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -473,7 +472,7 @@ public static Iterable getAllTinyLeadersDecks(Predicate filter) if (filter == null) { filter = DeckFormat.TinyLeaders.hasLegalCardsPredicate(FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)); } else { - filter = Predicates.and(DeckFormat.TinyLeaders.hasLegalCardsPredicate(FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)), filter); + filter = filter.and(DeckFormat.TinyLeaders.hasLegalCardsPredicate(FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY))); } addDecksRecursivelly("Tiny Leaders", GameType.TinyLeaders, result, "", FModel.getDecks().getTinyLeaders(), filter); return result; @@ -487,7 +486,7 @@ public static Iterable getAllBrawlDecks(Predicate filter) { if (filter == null) { filter = DeckFormat.Brawl.hasLegalCardsPredicate(FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)); } else { - filter = Predicates.and(DeckFormat.Brawl.hasLegalCardsPredicate(FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)), filter); + filter = filter.and(DeckFormat.Brawl.hasLegalCardsPredicate(FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY))); } addDecksRecursivelly("Brawl", GameType.Brawl, result, "", FModel.getDecks().getBrawl(), filter); return result; diff --git a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java index 4b8cf9a7a46..04ae6038a6e 100644 --- a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java +++ b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java @@ -61,7 +61,7 @@ public static Deck buildCardGenDeck(GameFormat format, boolean isForAI){ try { List keys = new ArrayList<>(CardArchetypeLDAGenerator.ldaPools.get(format.getName()).keySet()); String randomKey = keys.get( MyRandom.getRandom().nextInt(keys.size()) ); - Predicate cardFilter = Predicates.and(format.getFilterPrinted(),PaperCard.Predicates.name(randomKey)); + Predicate cardFilter = format.getFilterPrinted().and(PaperCard.Predicates.name(randomKey)); PaperCard keyCard = FModel.getMagicDb().getCommonCards().getAllCards(cardFilter).get(0); return buildCardGenDeck(keyCard,format,isForAI); @@ -73,7 +73,7 @@ public static Deck buildCardGenDeck(GameFormat format, boolean isForAI){ public static Deck buildCardGenDeck(String cardName, GameFormat format, boolean isForAI){ try { - Predicate cardFilter = Predicates.and(format.getFilterPrinted(),PaperCard.Predicates.name(cardName)); + Predicate cardFilter = format.getFilterPrinted().and(PaperCard.Predicates.name(cardName)); return buildCardGenDeck(FModel.getMagicDb().getCommonCards().getAllCards(cardFilter).get(0),format,isForAI); }catch (Exception e){ e.printStackTrace(); @@ -467,17 +467,19 @@ public static Deck getRandomOrPreconOrThemeDeck(String colors, boolean forAi, bo deck = Aggregates.random(geneticAI).getDeck(); } else { + Predicate sizePredicate = deckProxy -> deckProxy.getMainSize() <= 60; if (!selection.isEmpty() && selection.size() < 4) { - Predicate pred = Predicates.and(deckProxy -> deckProxy.getMainSize() <= 60, deckProxy -> deckProxy.getColorIdentity().hasAllColors(ColorSet.fromNames(colors.toCharArray()).getColor())); + Predicate colorPredicate = deckProxy -> deckProxy.getColorIdentity().hasAllColors(ColorSet.fromNames(colors.toCharArray()).getColor()); + Predicate pred = sizePredicate.and(colorPredicate); if (isTheme) deck = Aggregates.random(Iterables.filter(advThemes, pred)).getDeck(); else deck = Aggregates.random(Iterables.filter(advPrecons, pred)).getDeck(); } else { if (isTheme) - deck = Aggregates.random(Iterables.filter(advThemes, deckProxy -> deckProxy.getMainSize() <= 60)).getDeck(); + deck = Aggregates.random(Iterables.filter(advThemes, sizePredicate)).getDeck(); else - deck = Aggregates.random(Iterables.filter(advPrecons, deckProxy -> deckProxy.getMainSize() <= 60)).getDeck(); + deck = Aggregates.random(Iterables.filter(advPrecons, sizePredicate)).getDeck(); } } } catch (Exception e) { @@ -758,7 +760,7 @@ else if (commander.getRules().canBePartnerCommander()) { cardDb = FModel.getMagicDb().getCommonCards(); //shuffle first 400 random cards Iterable colorList = Iterables.filter(format.getCardPool(cardDb).getAllCards(), - Predicates.and(format.isLegalCardPredicate(),Predicates.compose(Predicates.or( + format.isLegalCardPredicate().and(Predicates.compose(Predicates.or( new CardThemedDeckBuilder.MatchColorIdentity(commander.getRules().getColorIdentity()), DeckGeneratorBase.COLORLESS_CARDS), PaperCard::getRules))); switch (format) { diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java index 5cce5a4d3be..91904b648af 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java @@ -319,8 +319,8 @@ public Deck buildDeck() { //Add remaining non-land colour matching cards to sideboard final CardPool cp = result.getOrCreate(DeckSection.Sideboard); Iterable potentialSideboard = Iterables.filter(aiPlayables, - Predicates.and(Predicates.compose(hasColor, PaperCard::getRules), - Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard::getRules))); + Predicates.compose(hasColor, PaperCard::getRules) + .and(Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard::getRules))); int i=0; while(i<15 && potentialSideboard.iterator().hasNext()){ PaperCard sbCard = potentialSideboard.iterator().next(); @@ -476,7 +476,7 @@ protected void addThirdColorCards(int num) { } } - hasColor = Predicates.and(CardRulesPredicates.Presets.IS_NON_LAND,Predicates.or(new MatchColorIdentity(colors), + hasColor = CardRulesPredicates.Presets.IS_NON_LAND.and(Predicates.or(new MatchColorIdentity(colors), DeckGeneratorBase.COLORLESS_CARDS)); final Iterable threeColorList = Iterables.filter(aiPlayables, Predicates.compose(hasColor, PaperCard::getRules)); @@ -521,8 +521,8 @@ protected void addLowCMCCard(){ protected boolean setBasicLandPool(String edition){ Predicate isSetBasicLand; if (edition !=null){ - isSetBasicLand = Predicates.and(IPaperCard.Predicates.printedInSet(edition), - Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules)); + isSetBasicLand = IPaperCard.Predicates.printedInSet(edition) + .and(Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules)); }else{ isSetBasicLand = Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules); } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java index e6c77014264..5d543587e8e 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java @@ -72,20 +72,18 @@ public final class BoosterUtils { private static final Predicate filterPioneer = formats.getPioneer().editionLegalPredicate; private static final Predicate filterModern= formats.getModern().editionLegalPredicate; - private static final Predicate filterStandard = Predicates.and(CardEdition.Predicates.CAN_MAKE_BOOSTER, - formats.getStandard().editionLegalPredicate); + private static final Predicate filterStandard = CardEdition.Predicates.CAN_MAKE_BOOSTER.and(formats.getStandard().editionLegalPredicate); - private static final Predicate filterPioneerNotStandard = Predicates.and( - CardEdition.Predicates.CAN_MAKE_BOOSTER, - Predicates.and(filterPioneer, formats.getStandard().editionLegalPredicate.negate())); + private static final Predicate filterPioneerNotStandard = CardEdition.Predicates.CAN_MAKE_BOOSTER + .and(filterPioneer + .and(formats.getStandard().editionLegalPredicate.negate())); - private static final Predicate filterModernNotPioneer = Predicates.and( - CardEdition.Predicates.CAN_MAKE_BOOSTER, - Predicates.and(filterModern, filterPioneer.negate())); + private static final Predicate filterModernNotPioneer = CardEdition.Predicates.CAN_MAKE_BOOSTER + .and(filterModern.and(filterPioneer.negate())); /** The filter not ext. */ - private static final Predicate filterNotModern = Predicates.and(CardEdition.Predicates.CAN_MAKE_BOOSTER, - filterModern.negate()); + private static final Predicate filterNotModern = CardEdition.Predicates.CAN_MAKE_BOOSTER + .and(filterModern.negate()); /** * Gets the quest starter deck. @@ -198,7 +196,7 @@ public static List generateRandomBoosterPacks(final int quantity, List output = new ArrayList<>(); - Predicate filter = Predicates.and(CardEdition.Predicates.CAN_MAKE_BOOSTER, editionFilter); + Predicate filter = CardEdition.Predicates.CAN_MAKE_BOOSTER.and(editionFilter); Iterable possibleEditions = Iterables.filter(FModel.getMagicDb().getEditions(), filter); if (!possibleEditions.iterator().hasNext()) { @@ -273,7 +271,7 @@ private static void populateRandomFilters(final List> color predicate = CardRulesPredicates.hasColor(color); } if (MyRandom.getRandom().nextDouble() < 0.1) { - predicate = Predicates.and(predicate, CardRulesPredicates.Presets.IS_MULTICOLOR); + predicate = predicate.and(CardRulesPredicates.Presets.IS_MULTICOLOR); } colorFilters.add(predicate); } @@ -329,10 +327,8 @@ private static void populateBalancedFilters(final List> col } //Try to get multicolored cards that fit into the preferred colors. - Predicate predicateRules = Predicates.and( - CardRulesPredicates.isColor(preferredColors.get(index)), - CardRulesPredicates.Presets.IS_MULTICOLOR - ); + Predicate predicateRules = CardRulesPredicates.isColor(preferredColors.get(index)) + .and(CardRulesPredicates.Presets.IS_MULTICOLOR); Predicate predicateCard = Predicates.compose(predicateRules, PaperCard::getRules); //Adjust for the number of multicolored possibilities. This prevents flooding of non-selected @@ -355,7 +351,7 @@ private static void populateBalancedFilters(final List> col for (Byte color : otherColors) { if (i % 6 == 0) { - colorFilters.add(Predicates.and(CardRulesPredicates.isColor(color), CardRulesPredicates.Presets.IS_MULTICOLOR)); + colorFilters.add(CardRulesPredicates.isColor(color).and(CardRulesPredicates.Presets.IS_MULTICOLOR)); } else { colorFilters.add(CardRulesPredicates.isMonoColor(color)); } @@ -411,7 +407,7 @@ private static List generateCards( do { if (color2 != null) { Predicate color2c = Predicates.compose(color2, PaperCard::getRules); - card = Aggregates.random(Iterables.filter(source, Predicates.and(filter, color2c))); + card = Aggregates.random(Iterables.filter(source, filter.and(color2c))); } } while (card == null && colorMisses++ < 10); } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java index 32d1be5c14c..b012a82507a 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java @@ -79,7 +79,7 @@ protected Predicate buildPredicates(final String [] input) { for (final String rule : ruleCodes) { final Predicate newRule = BoosterUtils.parseRulesLimitation(rule); if (newRule != null) { - filterRules = (filterRules == null ? newRule : Predicates.and(filterRules, newRule)); + filterRules = filterRules == null ? newRule : filterRules.and(newRule); } } } @@ -107,10 +107,10 @@ protected Predicate buildPredicates(final String [] input) { if (filterRules != null) { final Predicate rulesPrinted = Predicates.compose(filterRules, PaperCard::getRules); - filters = Predicates.and(filters, rulesPrinted); + filters = filters.and(rulesPrinted); } if (filterRarity != null) { - filters = Predicates.and(filters, filterRarity); + filters = filters.and(filterRarity); } return filters; } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java index c25b131dc44..c08917d3968 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java @@ -207,7 +207,7 @@ public void addSingleCard(final PaperCard card, int qty) { * @return the composite predicate. */ public Predicate applyFormatFilter(Predicate source) { - return questController.getFormat() == null ? source : Predicates.and(source, questController.getFormat().getFilterPrinted()); + return questController.getFormat() == null ? source : source.and(questController.getFormat().getFilterPrinted()); } /** @@ -636,7 +636,7 @@ private static int getRandomCardFromBooster(final List cards, final P private void generateTournamentsInShop(final int count) { Predicate formatFilter = CardEdition.Predicates.HAS_TOURNAMENT_PACK; if (questController.getFormat() != null) { - formatFilter = Predicates.and(formatFilter, isLegalInQuestFormat(questController.getFormat())); + formatFilter = formatFilter.and(isLegalInQuestFormat(questController.getFormat())); } Iterable rightEditions = Iterables.filter(FModel.getMagicDb().getEditions(), formatFilter); questAssets.getShopList().addAllOfTypeFlat(Aggregates.random(Iterables.transform(rightEditions, TournamentPack::fromSet), count)); @@ -651,7 +651,7 @@ private void generateTournamentsInShop(final int count) { private void generateFatPacksInShop(final int count) { Predicate formatFilter = CardEdition.Predicates.HAS_FAT_PACK; if (questController.getFormat() != null) { - formatFilter = Predicates.and(formatFilter, isLegalInQuestFormat(questController.getFormat())); + formatFilter = formatFilter.and(isLegalInQuestFormat(questController.getFormat())); } Iterable rightEditions = Iterables.filter(FModel.getMagicDb().getEditions(), formatFilter); questAssets.getShopList().addAllOfTypeFlat(Aggregates.random(Iterables.transform(rightEditions, FatPack::fromSet), count)); @@ -665,7 +665,7 @@ private void generateBoosterBoxesInShop(final int count) { Predicate formatFilter = CardEdition.Predicates.HAS_BOOSTER_BOX; if (questController.getFormat() != null) { - formatFilter = Predicates.and(formatFilter, isLegalInQuestFormat(questController.getFormat())); + formatFilter = formatFilter.and(isLegalInQuestFormat(questController.getFormat())); } Iterable rightEditions = Iterables.filter(FModel.getMagicDb().getEditions(), formatFilter); diff --git a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java index bef26e0a920..18300451f5b 100644 --- a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java +++ b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java @@ -1581,7 +1581,7 @@ else if (piece.equals(Operator.NOT)) { pred = predPiece; } else if (operator == Operator.AND) { - pred = Predicates.and(pred, predPiece); + pred = pred.and(predPiece); } else if (operator == Operator.OR) { pred = Predicates.or(pred, predPiece); diff --git a/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java b/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java index 4cf79adfd06..242ba2069db 100644 --- a/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java +++ b/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java @@ -122,7 +122,7 @@ private void resolve(final boolean alwaysPopOperator) { operators.pop(); right = operands.pop(); left = operands.pop(); - operands.push(Predicates.and(left, right)); + operands.push(left.and(right)); break; case OR: operators.pop(); diff --git a/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java b/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java index 80f031d57cc..ef4fb90081e 100644 --- a/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java +++ b/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java @@ -384,6 +384,6 @@ public static Predicate buildFormatFilter(Set formats, bo } public static Predicate optimizedAnd(Predicate p1, Predicate p2) { - return p1 == null ? p2 : (p2 == null ? p1 : Predicates.and(p1, p2)); + return p1 == null ? p2 : (p2 == null ? p1 : p1.and(p2)); } } diff --git a/forge-gui/src/main/java/forge/model/FModel.java b/forge-gui/src/main/java/forge/model/FModel.java index 54a355fda21..ca4c2a164fc 100644 --- a/forge-gui/src/main/java/forge/model/FModel.java +++ b/forge-gui/src/main/java/forge/model/FModel.java @@ -335,9 +335,12 @@ public static ItemPool getPlanechaseCards() { } public static ItemPool getBrawlCommander() { - if (brawlCommander == null) - return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(Predicates.and( - FModel.getFormats().get("Brawl").getFilterPrinted(), Predicates.compose(CardRulesPredicates.Presets.CAN_BE_BRAWL_COMMANDER, PaperCard::getRules))), PaperCard.class); + if (brawlCommander == null) { + return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt( + FModel.getFormats().get("Brawl").getFilterPrinted() + .and(Predicates.compose(CardRulesPredicates.Presets.CAN_BE_BRAWL_COMMANDER, PaperCard::getRules)) + ), PaperCard.class); + } return brawlCommander; } From 2d233f8ad52db5b2f08455fb1e94c670093e8f21 Mon Sep 17 00:00:00 2001 From: Jetz Date: Wed, 4 Sep 2024 00:23:58 -0400 Subject: [PATCH 20/68] Guava migration - Inline `Predicates.or` --- .../src/main/java/forge/ai/AiBlockController.java | 3 +-- forge-ai/src/main/java/forge/ai/AiController.java | 2 +- forge-ai/src/main/java/forge/ai/ComputerUtil.java | 3 +-- .../src/main/java/forge/ai/ComputerUtilCard.java | 4 ++-- .../src/main/java/forge/ai/SpecialCardAi.java | 15 +++++++-------- .../src/main/java/forge/ai/ability/AttachAi.java | 11 ++++------- .../src/main/java/forge/ai/ability/EffectAi.java | 3 +-- .../src/main/java/forge/ai/ability/ManaAi.java | 3 +-- .../main/java/forge/ai/ability/PermanentAi.java | 3 +-- .../src/main/java/forge/ai/ability/PumpAi.java | 5 ++--- .../main/java/forge/ai/ability/PumpAiBase.java | 3 +-- .../main/java/forge/card/CardRulesPredicates.java | 6 +++--- .../src/main/java/forge/deck/DeckFormat.java | 2 +- .../forge/deck/generation/DeckGeneratorBase.java | 2 +- .../src/main/java/forge/item/IPaperCard.java | 3 +-- .../src/main/java/forge/util/Predicates.java | 8 -------- .../src/main/java/forge/game/GameFormat.java | 2 +- .../deckeditor/controllers/CEditorCommander.java | 2 +- .../src/main/java/forge/deck/DeckgenUtil.java | 7 ++++--- .../gamemodes/limited/CardThemedDeckBuilder.java | 10 +++++----- .../gamemodes/limited/LimitedDeckBuilder.java | 5 ++--- .../forge/gamemodes/quest/QuestRewardCard.java | 8 ++++---- .../java/forge/itemmanager/AdvancedSearch.java | 3 +-- .../java/forge/itemmanager/BooleanExpression.java | 2 +- forge-gui/src/main/java/forge/model/FModel.java | 4 ++-- 25 files changed, 49 insertions(+), 70 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiBlockController.java b/forge-ai/src/main/java/forge/ai/AiBlockController.java index ad391abde2a..d884dd19ba5 100644 --- a/forge-ai/src/main/java/forge/ai/AiBlockController.java +++ b/forge-ai/src/main/java/forge/ai/AiBlockController.java @@ -44,7 +44,6 @@ import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; import forge.util.MyRandom; -import forge.util.Predicates; import forge.util.collect.FCollectionView; @@ -326,7 +325,7 @@ private void makeGoodBlocks(final Combat combat) { } private Predicate rampagesOrNeedsManyToBlock(final Combat combat) { - return Predicates.or(CardPredicates.hasKeyword(Keyword.RAMPAGE), input -> { + return CardPredicates.hasKeyword(Keyword.RAMPAGE).or(input -> { // select creature that has a max blocker return StaticAbilityCantAttackBlock.getMinMaxBlocker(input, combat.getDefenderPlayerByAttacker(input)).getRight() < Integer.MAX_VALUE; }); diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index 9eb9bd2c8c0..e48b00108cf 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -1578,7 +1578,7 @@ private SpellAbility chooseSpellAbilityToPlayFromList(final List a if (sa.getHostCard().hasKeyword(Keyword.STORM) && sa.getApi() != ApiType.Counter // AI would suck at trying to deliberately proc a Storm counterspell && player.getZone(ZoneType.Hand).contains( - Predicates.or(Presets.LANDS, CardPredicates.hasKeyword("Storm")).negate())) { + Presets.LANDS.or(CardPredicates.hasKeyword("Storm")).negate())) { if (game.getView().getStormCount() < this.getIntProperty(AiProps.MIN_COUNT_FOR_STORM_SPELLS)) { // skip evaluating Storm unless we reached the minimum Storm count continue; diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index 7a0c4baff16..fca36180720 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -2801,8 +2801,7 @@ public static Object vote(Player ai, List options, SpellAbility sa, Mult } // has cards with SacMe or Token - if (CardLists.count(aiCreatures, - Predicates.or(CardPredicates.hasSVar("SacMe"), CardPredicates.Presets.TOKEN)) >= numDeath) { + if (CardLists.count(aiCreatures, CardPredicates.hasSVar("SacMe").or(Presets.TOKEN)) >= numDeath) { return "Death"; } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index 4498d3d6803..efcec5f28be 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -505,7 +505,7 @@ public static Card getWorstPermanentAI(final Iterable list, final boolean if (hasEnchantmants || hasArtifacts) { final List ae = CardLists.filter(list, - Predicates.or(CardPredicates.Presets.ARTIFACTS, CardPredicates.Presets.ENCHANTMENTS) + (CardPredicates.Presets.ARTIFACTS.or(CardPredicates.Presets.ENCHANTMENTS)) .and(card -> !card.hasSVar("DoNotDiscardIfAble")) ); return getCheapestPermanentAI(ae, null, false); @@ -522,7 +522,7 @@ public static Card getWorstPermanentAI(final Iterable list, final boolean public static final Card getCheapestSpellAI(final Iterable list) { if (!Iterables.isEmpty(list)) { CardCollection cc = CardLists.filter(list, - Predicates.or(CardPredicates.isType("Instant"), CardPredicates.isType("Sorcery"))); + CardPredicates.isType("Instant").or(CardPredicates.isType("Sorcery"))); if (cc.isEmpty()) { return null; diff --git a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java index 73bac61e64e..918214ea495 100644 --- a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java +++ b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java @@ -52,7 +52,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.function.Predicate; /** * Special logic for individual cards @@ -156,8 +155,8 @@ public static boolean consider(final Player ai, final SpellAbility sa) { } int libsize = ai.getCardsIn(ZoneType.Library).size(); - final CardCollection hand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), Predicates.or( - CardPredicates.isType("Instant"), CardPredicates.isType("Sorcery"))); + final CardCollection hand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), + CardPredicates.isType("Instant").or(CardPredicates.isType("Sorcery"))); if (!hand.isEmpty()) { // has spell that can be cast in hand with put ability if (Iterables.any(hand, CardPredicates.hasCMC(counterNum + 1))) { @@ -169,8 +168,8 @@ public static boolean consider(final Player ai, final SpellAbility sa) { return true; } } - final CardCollection library = CardLists.filter(ai.getCardsIn(ZoneType.Library), Predicates.or( - CardPredicates.isType("Instant"), CardPredicates.isType("Sorcery"))); + final CardCollection library = CardLists.filter(ai.getCardsIn(ZoneType.Library), + CardPredicates.isType("Instant").or(CardPredicates.isType("Sorcery"))); if (!library.isEmpty()) { // get max cmc of instant or sorceries in the libary int maxCMC = 0; @@ -360,8 +359,8 @@ public static class DesecrationDemon { public static boolean considerSacrificingCreature(final Player ai, final SpellAbility sa) { CardCollection flyingCreatures = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), - CardPredicates.Presets.UNTAPPED.and(Predicates.or( - CardPredicates.hasKeyword(Keyword.FLYING), CardPredicates.hasKeyword(Keyword.REACH)))); + CardPredicates.Presets.UNTAPPED.and( + CardPredicates.hasKeyword(Keyword.FLYING).or(CardPredicates.hasKeyword(Keyword.REACH)))); boolean hasUsefulBlocker = false; for (Card c : flyingCreatures) { @@ -998,7 +997,7 @@ public static class MairsilThePretender { // Scan the fetch list for a card with at least one activated ability. // TODO: can be improved to a full consider(sa, ai) logic which would scan the graveyard first and hand last public static Card considerCardFromList(final CardCollection fetchList) { - for (Card c : CardLists.filter(fetchList, Predicates.or(CardPredicates.Presets.ARTIFACTS, CardPredicates.Presets.CREATURES))) { + for (Card c : CardLists.filter(fetchList, CardPredicates.Presets.ARTIFACTS.or(CardPredicates.Presets.CREATURES))) { for (SpellAbility ab : c.getSpellAbilities()) { if (ab.isActivatedAbility()) { Player controller = c.getController(); diff --git a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java index 965c88d47e3..0bc94e3e50e 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java @@ -1,10 +1,8 @@ package forge.ai.ability; import java.util.*; -import java.util.function.Predicate; import forge.game.card.*; -import forge.util.Predicates; import org.apache.commons.lang3.ObjectUtils; import com.google.common.collect.Lists; @@ -1144,9 +1142,8 @@ private static Card attachAIPumpPreference(final Player ai, final SpellAbility s //some auras/equipments aren't useful in multiples if (attachSource.hasSVar("NonStackingAttachEffect")) { - prefList = CardLists.filter(prefList, Predicates.or( - CardPredicates.isEquippedBy(attachSource.getName()), - CardPredicates.isEnchantedBy(attachSource.getName()) + prefList = CardLists.filter(prefList, CardPredicates.isEquippedBy(attachSource.getName()) + .or(CardPredicates.isEnchantedBy(attachSource.getName()) ).negate()); } @@ -1248,8 +1245,8 @@ private static Card attachToCardAIPreferences(final Player aiPlayer, final Spell // Is a SA that moves target attachment if ("MoveTgtAura".equals(sa.getParam("AILogic"))) { - CardCollection list = CardLists.filter(CardUtil.getValidCardsToTarget(sa), Predicates.or(CardPredicates.isControlledByAnyOf(aiPlayer.getOpponents()), - card -> ComputerUtilCard.isUselessCreature(aiPlayer, card.getAttachedTo()))); + CardCollection list = CardLists.filter(CardUtil.getValidCardsToTarget(sa), CardPredicates.isControlledByAnyOf(aiPlayer.getOpponents()) + .or(card -> ComputerUtilCard.isUselessCreature(aiPlayer, card.getAttachedTo()))); return !list.isEmpty() ? ComputerUtilCard.getBestAI(list) : null; } else if ("Unenchanted".equals(sa.getParam("AILogic"))) { diff --git a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java index c74041c755d..75b4b914d8e 100644 --- a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java @@ -26,7 +26,6 @@ import forge.game.zone.ZoneType; import forge.util.Iterables; import forge.util.MyRandom; -import forge.util.Predicates; import forge.util.TextUtil; import java.util.ArrayList; @@ -57,7 +56,7 @@ protected boolean canPlayAI(final Player ai,final SpellAbility sa) { for (Player opp : ai.getOpponents()) { boolean worthHolding = false; CardCollectionView oppCreatsLands = CardLists.filter(opp.getCardsIn(ZoneType.Battlefield), - Predicates.or(CardPredicates.Presets.LANDS, CardPredicates.Presets.CREATURES)); + Presets.LANDS.or(Presets.CREATURES)); CardCollectionView oppCreatsLandsTapped = CardLists.filter(oppCreatsLands, CardPredicates.Presets.TAPPED); if (oppCreatsLandsTapped.size() >= 3 || oppCreatsLands.size() == oppCreatsLandsTapped.size()) { diff --git a/forge-ai/src/main/java/forge/ai/ability/ManaAi.java b/forge-ai/src/main/java/forge/ai/ability/ManaAi.java index ead353848df..5545f502dda 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ManaAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ManaAi.java @@ -30,7 +30,6 @@ import forge.game.zone.ZoneType; import forge.util.Aggregates; import forge.util.Iterables; -import forge.util.Predicates; public class ManaAi extends SpellAbilityAi { @@ -239,7 +238,7 @@ public static boolean doManaRitualLogic(Player ai, SpellAbility sa, boolean from Arrays.asList( CardPredicates.restriction(restrictValid.split(","), ai, host, sa), CardPredicates.lessCMC(searchCMC), - Predicates.or(CardPredicates.isColorless(), CardPredicates.isColor(producedColor)))); + CardPredicates.isColorless().or(CardPredicates.isColor(producedColor)))); if (logic.startsWith("ManaRitualBattery")) { // Don't remove more counters than would be needed to cast the more expensive thing we want to cast, diff --git a/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java b/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java index eb612cf6b5a..3774c5b772b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java @@ -18,7 +18,6 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Iterables; -import forge.util.Predicates; import org.apache.commons.lang3.StringUtils; public class PermanentAi extends SpellAbilityAi { @@ -261,7 +260,7 @@ protected boolean checkApiLogic(final Player ai, final SpellAbility sa) { int extraMana = CardLists.count(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.LANDS) > 0 ? 1 : 0; if (source.getName().equals("Illusions of Grandeur")) { // TODO: this is currently hardcoded for specific Illusions-Donate cost reduction spells, need to make this generic. - extraMana += Math.min(3, CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Predicates.or(CardPredicates.nameEquals("Sapphire Medallion"), CardPredicates.nameEquals("Helm of Awakening"))).size()) * 2; // each cost-reduction spell accounts for {1} in both Illusions and Donate + extraMana += Math.min(3, CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Sapphire Medallion").or(CardPredicates.nameEquals("Helm of Awakening"))).size()) * 2; // each cost-reduction spell accounts for {1} in both Illusions and Donate } if (m.size() + extraMana < Integer.parseInt(value)) { dontCast = true; diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAi.java b/forge-ai/src/main/java/forge/ai/ability/PumpAi.java index 4991906e776..d6638be806f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAi.java @@ -20,7 +20,6 @@ import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; import forge.util.Iterables; -import forge.util.Predicates; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; @@ -450,7 +449,7 @@ private boolean pumpTgtAI(final Player ai, final SpellAbility sa, final int defe return false; } - List alliedTgts = CardLists.filter(tgts, Predicates.or(CardPredicates.isControlledByAnyOf(ai.getAllies()), CardPredicates.isController(ai))); + List alliedTgts = CardLists.filter(tgts, CardPredicates.isControlledByAnyOf(ai.getAllies()).or(CardPredicates.isController(ai))); List oppTgts = CardLists.filter(tgts, CardPredicates.isControlledByAnyOf(ai.getOpponents())); Card destroyTgt = null; @@ -512,7 +511,7 @@ private boolean pumpTgtAI(final Player ai, final SpellAbility sa, final int defe // Detain target nonland permanent: don't target noncreature permanents that don't have // any activated abilities. if ("DetainNonLand".equals(sa.getParam("AILogic"))) { - list = CardLists.filter(list, Predicates.or(CardPredicates.Presets.CREATURES, card -> { + list = CardLists.filter(list, Presets.CREATURES.or(card -> { for (SpellAbility sa1 : card.getSpellAbilities()) { if (sa1.isActivatedAbility()) { return true; diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java b/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java index 8be2c7fb00e..ac68e667644 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java @@ -27,7 +27,6 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Iterables; -import forge.util.Predicates; public abstract class PumpAiBase extends SpellAbilityAi { @@ -204,7 +203,7 @@ public boolean isUsefulPumpKeyword(final Player ai, final String keyword, final && ComputerUtilCombat.lifeInDanger(ai, game.getCombat())) { return true; } - Predicate flyingOrReach = Predicates.or(CardPredicates.hasKeyword(Keyword.FLYING), CardPredicates.hasKeyword(Keyword.REACH)); + Predicate flyingOrReach = CardPredicates.hasKeyword(Keyword.FLYING).or(CardPredicates.hasKeyword(Keyword.REACH)); if (ph.isPlayerTurn(opp) && combat != null && !attackingFlyer.isEmpty() && CombatUtil.canBlock(card)) { diff --git a/forge-core/src/main/java/forge/card/CardRulesPredicates.java b/forge-core/src/main/java/forge/card/CardRulesPredicates.java index 38865f2a441..272534b666d 100644 --- a/forge-core/src/main/java/forge/card/CardRulesPredicates.java +++ b/forge-core/src/main/java/forge/card/CardRulesPredicates.java @@ -569,7 +569,7 @@ public static class Presets { public static final Predicate IS_ENCHANTMENT = CardRulesPredicates.coreType(true, CardType.CoreType.Enchantment); public static final Predicate IS_PLANE = CardRulesPredicates.coreType(true, CardType.CoreType.Plane); public static final Predicate IS_PHENOMENON = CardRulesPredicates.coreType(true, CardType.CoreType.Phenomenon); - public static final Predicate IS_PLANE_OR_PHENOMENON = Predicates.or(IS_PLANE, IS_PHENOMENON); + public static final Predicate IS_PLANE_OR_PHENOMENON = IS_PLANE.or(IS_PHENOMENON); public static final Predicate IS_SCHEME = CardRulesPredicates.coreType(true, CardType.CoreType.Scheme); public static final Predicate IS_VANGUARD = CardRulesPredicates.coreType(true, CardType.CoreType.Vanguard); public static final Predicate IS_CONSPIRACY = CardRulesPredicates.coreType(true, CardType.CoreType.Conspiracy); @@ -577,8 +577,8 @@ public static class Presets { public static final Predicate IS_ATTRACTION = Presets.IS_ARTIFACT.and(CardRulesPredicates.subType("Attraction")); public static final Predicate IS_NON_LAND = CardRulesPredicates.coreType(false, CardType.CoreType.Land); - public static final Predicate CAN_BE_BRAWL_COMMANDER = Presets.IS_LEGENDARY.and(Predicates.or(Presets.IS_CREATURE, Presets.IS_PLANESWALKER)); - public static final Predicate CAN_BE_TINY_LEADERS_COMMANDER = Presets.IS_LEGENDARY.and(Predicates.or(Presets.IS_CREATURE, Presets.IS_PLANESWALKER)); + public static final Predicate CAN_BE_BRAWL_COMMANDER = Presets.IS_LEGENDARY.and(Presets.IS_CREATURE.or(Presets.IS_PLANESWALKER)); + public static final Predicate CAN_BE_TINY_LEADERS_COMMANDER = Presets.IS_LEGENDARY.and(Presets.IS_CREATURE.or(Presets.IS_PLANESWALKER)); /** The Constant IS_NON_CREATURE_SPELL. **/ public static final Predicate IS_NON_CREATURE_SPELL = diff --git a/forge-core/src/main/java/forge/deck/DeckFormat.java b/forge-core/src/main/java/forge/deck/DeckFormat.java index 89fab648d00..90d79967ea4 100644 --- a/forge-core/src/main/java/forge/deck/DeckFormat.java +++ b/forge-core/src/main/java/forge/deck/DeckFormat.java @@ -538,7 +538,7 @@ public Predicate isLegalCardForCommanderPredicate(List com if (commanders.size() == 1 && commanders.get(0).getRules().canBePartnerCommander()) { //also show available partners a commander can have a partner //702.124g If a legendary card has more than one partner ability, you may choose which one to use when designating your commander, but you can’t use both. //Notably, no partner ability or combination of partner abilities can ever let a player have more than two commanders. - predicate = Predicates.or(predicate, CardRulesPredicates.canBePartnerCommanderWith(commanders.get(0).getRules())); + predicate = predicate.or(CardRulesPredicates.canBePartnerCommanderWith(commanders.get(0).getRules())); } return Predicates.compose(predicate, PaperCard::getRules); } diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index c3fc0d27493..92a65b10f5e 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -289,7 +289,7 @@ protected Iterable selectCardsOfMatchingColorForPlayer(boolean forAi) }; if (useArtifacts) { - hasColor = Predicates.or(hasColor, COLORLESS_CARDS); + hasColor = hasColor.or(COLORLESS_CARDS); } return Iterables.filter(pool.getAllCards(), Predicates.compose(canPlay.and(hasColor).and(canUseInFormat), PaperCard::getRules)); } diff --git a/forge-core/src/main/java/forge/item/IPaperCard.java b/forge-core/src/main/java/forge/item/IPaperCard.java index cf544ff92f4..37b11ba8250 100644 --- a/forge-core/src/main/java/forge/item/IPaperCard.java +++ b/forge-core/src/main/java/forge/item/IPaperCard.java @@ -209,8 +209,7 @@ public abstract static class Presets { public static final Predicate IS_MYTHIC_RARE = Predicates.rarity(true, CardRarity.MythicRare); /** The Constant isRareOrMythic. */ - public static final Predicate IS_RARE_OR_MYTHIC = forge.util.Predicates.or(Presets.IS_RARE, - Presets.IS_MYTHIC_RARE); + public static final Predicate IS_RARE_OR_MYTHIC = Presets.IS_RARE.or(Presets.IS_MYTHIC_RARE); /** The Constant isSpecial. */ public static final Predicate IS_SPECIAL = Predicates.rarity(true, CardRarity.Special); diff --git a/forge-core/src/main/java/forge/util/Predicates.java b/forge-core/src/main/java/forge/util/Predicates.java index 1a773baea14..27e1cf9e6db 100644 --- a/forge-core/src/main/java/forge/util/Predicates.java +++ b/forge-core/src/main/java/forge/util/Predicates.java @@ -20,12 +20,4 @@ public static Predicate or(Iterable> compo public static Predicate compose(Predicate predicate, Function function) { return x -> predicate.test(function.apply(x)); } - - - //TODO: Inline everything below. - - public static Predicate or(Predicate first, Predicate second) { - //TODO: remove casting? - return ((Predicate) first).or(second); - } } diff --git a/forge-game/src/main/java/forge/game/GameFormat.java b/forge-game/src/main/java/forge/game/GameFormat.java index 56f5ed939e5..4e9110b0521 100644 --- a/forge-game/src/main/java/forge/game/GameFormat.java +++ b/forge-game/src/main/java/forge/game/GameFormat.java @@ -159,7 +159,7 @@ protected Predicate buildFilter(boolean printed) { p = p.and(Predicates.or(crp)); } if (!this.getAdditionalCards().isEmpty()) { - p = Predicates.or(p, IPaperCard.Predicates.names(this.getAdditionalCards())); + p = p.or(IPaperCard.Predicates.names(this.getAdditionalCards())); } return p; } diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java index a0514c3df97..114092f7fdb 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java @@ -88,7 +88,7 @@ public CEditorCommander(final CDetailPicture cDetailPicture, GameType gameType0) } else { Predicate commanderFilter = gameType == GameType.Oathbreaker - ? Predicates.or(CardRulesPredicates.Presets.CAN_BE_OATHBREAKER, CardRulesPredicates.Presets.CAN_BE_SIGNATURE_SPELL) + ? CardRulesPredicates.Presets.CAN_BE_OATHBREAKER.or(CardRulesPredicates.Presets.CAN_BE_SIGNATURE_SPELL) : CardRulesPredicates.Presets.CAN_BE_COMMANDER; commanderPool = ItemPool.createFrom(commonCards.getAllCardsNoAlt(Predicates.compose(commanderFilter, PaperCard::getRules)),PaperCard.class); normalPool = ItemPool.createFrom(commonCards.getAllCardsNoAlt(), PaperCard.class); diff --git a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java index 04ae6038a6e..ac47b4f4f4a 100644 --- a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java +++ b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java @@ -760,9 +760,10 @@ else if (commander.getRules().canBePartnerCommander()) { cardDb = FModel.getMagicDb().getCommonCards(); //shuffle first 400 random cards Iterable colorList = Iterables.filter(format.getCardPool(cardDb).getAllCards(), - format.isLegalCardPredicate().and(Predicates.compose(Predicates.or( - new CardThemedDeckBuilder.MatchColorIdentity(commander.getRules().getColorIdentity()), - DeckGeneratorBase.COLORLESS_CARDS), PaperCard::getRules))); + format.isLegalCardPredicate().and(Predicates.compose( + new CardThemedDeckBuilder.MatchColorIdentity(commander.getRules().getColorIdentity()) + .or(DeckGeneratorBase.COLORLESS_CARDS), + PaperCard::getRules))); switch (format) { case Brawl: //for Brawl - add additional filterprinted rule to remove old reprints for a consistent look colorList = Iterables.filter(colorList,FModel.getFormats().getStandard().getFilterPrinted()); diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java index 91904b648af..a2a6f57402f 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java @@ -183,7 +183,7 @@ protected void updateColors(){ */ public Deck buildDeck() { // 1. Prepare - hasColor = Predicates.or(new MatchColorIdentity(colors), COLORLESS_CARDS); + hasColor = new MatchColorIdentity(colors).or(COLORLESS_CARDS); if (logColorsToConsole) { System.out.println(keyCard.getName()); System.out.println("Colors: " + colors.toEnumSet().toString()); @@ -192,8 +192,8 @@ public Deck buildDeck() { Predicates.compose(hasColor, PaperCard::getRules)); rankedColorList = Lists.newArrayList(colorList); onColorCreaturesAndSpells = Iterables.filter(rankedColorList, - Predicates.compose(Predicates.or(CardRulesPredicates.Presets.IS_CREATURE, - CardRulesPredicates.Presets.IS_NON_CREATURE_SPELL), PaperCard::getRules)); + Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE + .or(CardRulesPredicates.Presets.IS_NON_CREATURE_SPELL), PaperCard::getRules)); // Guava iterables do not copy the collection contents, instead they act // as filters and iterate over _source_ collection each time. So even if @@ -476,8 +476,8 @@ protected void addThirdColorCards(int num) { } } - hasColor = CardRulesPredicates.Presets.IS_NON_LAND.and(Predicates.or(new MatchColorIdentity(colors), - DeckGeneratorBase.COLORLESS_CARDS)); + hasColor = CardRulesPredicates.Presets.IS_NON_LAND.and(new MatchColorIdentity(colors) + .or(DeckGeneratorBase.COLORLESS_CARDS)); final Iterable threeColorList = Iterables.filter(aiPlayables, Predicates.compose(hasColor, PaperCard::getRules)); for (final PaperCard card : threeColorList) { diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java index 0daa90453e0..bc74e36f859 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java @@ -134,7 +134,7 @@ public Deck buildDeck() { @SuppressWarnings("unused") public Deck buildDeck(final String landSetCode) { // 1. Prepare - hasColor = Predicates.or(new MatchColorIdentity(colors), COLORLESS_CARDS); + hasColor = new MatchColorIdentity(colors).or(COLORLESS_CARDS); Iterable colorList = Iterables.filter(aiPlayables, Predicates.compose(hasColor, PaperCard::getRules)); rankedColorList = CardRanker.rankCardsInDeck(colorList); @@ -497,8 +497,7 @@ private void addThirdColorCards(int num) { } } - hasColor = Predicates.or(new DeckGeneratorBase.MatchColorIdentity(colors), - DeckGeneratorBase.COLORLESS_CARDS); + hasColor = new MatchColorIdentity(colors).or(DeckGeneratorBase.COLORLESS_CARDS); final Iterable threeColorList = Iterables.filter(rankedOthers, Predicates.compose(hasColor, PaperCard::getRules)); for (final PaperCard card : threeColorList) { diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java index b012a82507a..5475c4af726 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java @@ -91,13 +91,13 @@ protected Predicate buildPredicates(final String [] input) { if (rarityCodes.length > 0) { for (final String rarity : rarityCodes) { if (rarity.startsWith("C") || rarity.startsWith("c")) { - filterRarity = (filterRarity == null ? IPaperCard.Predicates.Presets.IS_COMMON : Predicates.or(filterRarity, IPaperCard.Predicates.Presets.IS_COMMON)); + filterRarity = filterRarity == null ? IPaperCard.Predicates.Presets.IS_COMMON : filterRarity.or(IPaperCard.Predicates.Presets.IS_COMMON); } else if (rarity.startsWith("U") || rarity.startsWith("u")) { - filterRarity = (filterRarity == null ? IPaperCard.Predicates.Presets.IS_UNCOMMON : Predicates.or(filterRarity, IPaperCard.Predicates.Presets.IS_UNCOMMON)); + filterRarity = filterRarity == null ? IPaperCard.Predicates.Presets.IS_UNCOMMON : filterRarity.or(IPaperCard.Predicates.Presets.IS_UNCOMMON); } else if (rarity.startsWith("R") || rarity.startsWith("r")) { - filterRarity = (filterRarity == null ? IPaperCard.Predicates.Presets.IS_RARE : Predicates.or(filterRarity, IPaperCard.Predicates.Presets.IS_RARE)); + filterRarity = filterRarity == null ? IPaperCard.Predicates.Presets.IS_RARE : filterRarity.or(IPaperCard.Predicates.Presets.IS_RARE); } else if (rarity.startsWith("M") || rarity.startsWith("m")) { - filterRarity = (filterRarity == null ? IPaperCard.Predicates.Presets.IS_MYTHIC_RARE : Predicates.or(filterRarity, IPaperCard.Predicates.Presets.IS_MYTHIC_RARE)); + filterRarity = filterRarity == null ? IPaperCard.Predicates.Presets.IS_MYTHIC_RARE : filterRarity.or(IPaperCard.Predicates.Presets.IS_MYTHIC_RARE); } } } diff --git a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java index 18300451f5b..f08f5e21832 100644 --- a/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java +++ b/forge-gui/src/main/java/forge/itemmanager/AdvancedSearch.java @@ -48,7 +48,6 @@ import forge.model.FModel; import forge.util.CardTranslation; import forge.util.Localizer; -import forge.util.Predicates; public class AdvancedSearch { public enum FilterOption { @@ -1584,7 +1583,7 @@ else if (operator == Operator.AND) { pred = pred.and(predPiece); } else if (operator == Operator.OR) { - pred = Predicates.or(pred, predPiece); + pred = pred.or(predPiece); } operator = null; } diff --git a/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java b/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java index 242ba2069db..3c0e419b158 100644 --- a/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java +++ b/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java @@ -128,7 +128,7 @@ private void resolve(final boolean alwaysPopOperator) { operators.pop(); right = operands.pop(); left = operands.pop(); - operands.push(Predicates.or(left, right)); + operands.push(left.or(right)); break; case NOT: operators.pop(); diff --git a/forge-gui/src/main/java/forge/model/FModel.java b/forge-gui/src/main/java/forge/model/FModel.java index ca4c2a164fc..e7a317bd820 100644 --- a/forge-gui/src/main/java/forge/model/FModel.java +++ b/forge-gui/src/main/java/forge/model/FModel.java @@ -346,8 +346,8 @@ public static ItemPool getBrawlCommander() { public static ItemPool getOathbreakerCommander() { if (oathbreakerCommander == null) - return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(Predicates.compose(Predicates.or( - CardRulesPredicates.Presets.CAN_BE_OATHBREAKER, CardRulesPredicates.Presets.CAN_BE_SIGNATURE_SPELL), PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(Predicates.compose( + CardRulesPredicates.Presets.CAN_BE_OATHBREAKER.or(CardRulesPredicates.Presets.CAN_BE_SIGNATURE_SPELL), PaperCard::getRules)), PaperCard.class); return oathbreakerCommander; } From 0bf04c2fc8c769345b17fa9a3793ad5f579ff076 Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 6 Sep 2024 09:24:32 -0400 Subject: [PATCH 21/68] Guava migration - Add common helper predicates --- .../src/main/java/forge/ai/AiController.java | 12 ++++++------ .../src/main/java/forge/ai/ComputerUtil.java | 2 +- .../main/java/forge/ai/ComputerUtilCard.java | 5 ++--- .../main/java/forge/ai/PlayerControllerAi.java | 4 ++-- .../src/main/java/forge/ai/SpecialCardAi.java | 18 +++++++++--------- .../main/java/forge/ai/ability/AttachAi.java | 4 ++-- .../java/forge/ai/ability/ChangeZoneAi.java | 14 ++++++-------- .../java/forge/ai/ability/ChooseCardAi.java | 2 +- .../java/forge/ai/ability/ChooseSourceAi.java | 2 +- .../java/forge/ai/ability/CountersPutAi.java | 2 +- .../java/forge/ai/ability/PermanentAi.java | 6 +++--- .../src/main/java/forge/ai/ability/ScryAi.java | 2 +- .../main/java/forge/ai/ability/UntapAi.java | 2 +- .../java/forge/card/CardRulesPredicates.java | 5 ++++- .../deck/generation/DeckGeneratorBase.java | 4 ++-- .../effects/InternalRadiationEffect.java | 2 +- .../src/main/java/forge/game/card/Card.java | 1 + .../java/forge/game/card/CardPredicates.java | 9 ++++++++- .../main/java/forge/game/combat/Combat.java | 4 ++-- .../deckeditor/controllers/CDeckgen.java | 2 +- .../forge/adventure/character/EnemySprite.java | 2 +- .../deck/CardRelationMatrixGenerator.java | 8 ++++---- .../java/forge/lda/LDAModelGenetrator.java | 4 ++-- 23 files changed, 62 insertions(+), 54 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index e48b00108cf..f51e553d0c2 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -404,7 +404,7 @@ private static List getPlayableCounters(final CardCollection l) { private CardCollection filterLandsToPlay(CardCollection landList) { final CardCollectionView hand = player.getCardsIn(ZoneType.Hand); - CardCollection nonLandList = CardLists.filter(hand, Presets.LANDS.negate()); + CardCollection nonLandList = CardLists.filter(hand, Presets.NON_LANDS); if (landList.size() == 1 && nonLandList.size() < 3) { CardCollectionView cardsInPlay = player.getCardsIn(ZoneType.Battlefield); CardCollection landsInPlay = CardLists.filter(cardsInPlay, Presets.LANDS); @@ -469,7 +469,7 @@ private Card chooseBestLandToPlay(CardCollection landList) { return null; } - CardCollection nonLandsInHand = CardLists.filter(player.getCardsIn(ZoneType.Hand), Presets.LANDS.negate()); + CardCollection nonLandsInHand = CardLists.filter(player.getCardsIn(ZoneType.Hand), Presets.NON_LANDS); // Some considerations for Momir/MoJhoSto boolean hasMomir = player.isCardInCommand("Momir Vig, Simic Visionary Avatar"); @@ -598,8 +598,8 @@ private Card chooseBestLandToPlay(CardCollection landList) { } // pick dual lands if available - if (Iterables.any(landList, Presets.BASIC_LANDS.negate())) { - landList = CardLists.filter(landList, Presets.BASIC_LANDS.negate()); + if (Iterables.any(landList, Presets.NONBASIC_LANDS)) { + landList = CardLists.filter(landList, Presets.NONBASIC_LANDS); } } return ComputerUtilCard.getBestLandToPlayAI(landList); @@ -1397,11 +1397,11 @@ private boolean isSafeToHoldLandDropForMain2(Card landToPlay) { return false; } - CardCollection inHand = CardLists.filter(player.getCardsIn(ZoneType.Hand), Presets.LANDS.negate()); + CardCollection inHand = CardLists.filter(player.getCardsIn(ZoneType.Hand), Presets.NON_LANDS); CardCollectionView otb = player.getCardsIn(ZoneType.Battlefield); if (getBooleanProperty(AiProps.HOLD_LAND_DROP_ONLY_IF_HAVE_OTHER_PERMS)) { - if (!Iterables.any(otb, Presets.LANDS.negate())) { + if (!Iterables.any(otb, Presets.NON_LANDS)) { return false; } } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index fca36180720..0e3b8437a10 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -2218,7 +2218,7 @@ public static int scoreHand(CardCollectionView handList, Player ai, int cardsToR } CardCollectionView library = ai.getCardsIn(ZoneType.Library); - int landsInDeck = CardLists.count(library, CardPredicates.isType("Land")); + int landsInDeck = CardLists.count(library, Presets.LANDS); // no land deck, can't do anything better if (landsInDeck == 0) { diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index efcec5f28be..70466f6e223 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -206,7 +206,7 @@ public static Card getBestLandAI(final Iterable list) { } // prefer to target non basic lands - final List nbLand = CardLists.filter(land, CardPredicates.Presets.BASIC_LANDS.negate()); + final List nbLand = CardLists.filter(land, CardPredicates.Presets.NONBASIC_LANDS); if (!nbLand.isEmpty()) { // TODO - Improve ranking various non-basic lands depending on context @@ -521,8 +521,7 @@ public static Card getWorstPermanentAI(final Iterable list, final boolean public static final Card getCheapestSpellAI(final Iterable list) { if (!Iterables.isEmpty(list)) { - CardCollection cc = CardLists.filter(list, - CardPredicates.isType("Instant").or(CardPredicates.isType("Sorcery"))); + CardCollection cc = CardLists.filter(list, CardPredicates.Presets.INSTANTS_AND_SORCERIES); if (cc.isEmpty()) { return null; diff --git a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java index f955b75e326..685e11cfd54 100644 --- a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java +++ b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java @@ -1436,7 +1436,7 @@ public String chooseCardName(SpellAbility sa, Predicate cpp, String v if (consp.getState(CardStateName.Original).hasIntrinsicKeyword("Hidden agenda")) { String chosenName = consp.getNamedCard(); if (!chosenName.isEmpty()) { - aiLibrary = CardLists.filter(aiLibrary, CardPredicates.nameEquals(chosenName).negate()); + aiLibrary = CardLists.filter(aiLibrary, CardPredicates.nameNotEquals(chosenName)); } } } @@ -1469,7 +1469,7 @@ public String chooseCardName(SpellAbility sa, Predicate cpp, String v } } else { CardCollectionView list = CardLists.filterControlledBy(getGame().getCardsInGame(), player.getOpponents()); - list = CardLists.filter(list, Presets.LANDS.negate()); + list = CardLists.filter(list, Presets.NON_LANDS); if (!list.isEmpty()) { return list.get(0).getName(); } diff --git a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java index 918214ea495..485504495f4 100644 --- a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java +++ b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java @@ -125,7 +125,7 @@ public static boolean consider(final Player ai, final SpellAbility sa, final Man int numManaSrcs = manaSources.size(); CardCollection allCards = CardLists.filter(ai.getAllCards(), Arrays.asList(CardPredicates.Presets.NON_TOKEN, - CardPredicates.Presets.LANDS.negate(), CardPredicates.isOwner(ai))); + CardPredicates.Presets.NON_LANDS, CardPredicates.isOwner(ai))); int numHighCMC = CardLists.count(allCards, CardPredicates.greaterCMC(5)); int numLowCMC = CardLists.count(allCards, CardPredicates.lessCMC(3)); @@ -156,7 +156,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { int libsize = ai.getCardsIn(ZoneType.Library).size(); final CardCollection hand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), - CardPredicates.isType("Instant").or(CardPredicates.isType("Sorcery"))); + CardPredicates.Presets.INSTANTS_AND_SORCERIES); if (!hand.isEmpty()) { // has spell that can be cast in hand with put ability if (Iterables.any(hand, CardPredicates.hasCMC(counterNum + 1))) { @@ -169,7 +169,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { } } final CardCollection library = CardLists.filter(ai.getCardsIn(ZoneType.Library), - CardPredicates.isType("Instant").or(CardPredicates.isType("Sorcery"))); + CardPredicates.Presets.INSTANTS_AND_SORCERIES); if (!library.isEmpty()) { // get max cmc of instant or sorceries in the libary int maxCMC = 0; @@ -206,7 +206,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { List AiLandsOnly = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.LANDS); List OppPerms = CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Battlefield), - CardPredicates.Presets.CREATURES.negate()); + CardPredicates.Presets.NON_CREATURES); // TODO: improve this logic (currently the AI has difficulty evaluating non-creature permanents, // which it can only distinguish by their CMC, considering >CMC higher value). @@ -331,12 +331,12 @@ static public String chooseNonBattlefieldName() { public static class DeathgorgeScavenger { public static boolean consider(final Player ai, final SpellAbility sa) { Card worstCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES)); - Card worstNonCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES.negate())); + Card worstNonCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.NON_CREATURES)); if (worstCreat == null) { worstCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES)); } if (worstNonCreat == null) { - worstNonCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES.negate())); + worstNonCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.NON_CREATURES)); } sa.resetTargets(); @@ -786,7 +786,7 @@ public static CardCollection considerMultiple(final Player ai, final SpellAbilit int changeNum = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParamOrDefault("ChangeNum", "1"), sa); CardCollection lib = CardLists.filter(ai.getCardsIn(ZoneType.Library), - CardPredicates.nameEquals(sa.getHostCard().getName()).negate()); + CardPredicates.nameNotEquals(sa.getHostCard().getName())); lib.sort(CardLists.CmcComparatorInv); // Additional cards which are difficult to auto-classify but which are generally good to Intuition for @@ -1316,7 +1316,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { return false; } - int aiLands = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.LANDS.and(CardPredicates.Presets.BASIC_LANDS.negate())).size(); + int aiLands = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.NONBASIC_LANDS).size(); boolean hasBridge = false; for (Card c : ai.getCardsIn(ZoneType.Battlefield)) { @@ -1334,7 +1334,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { } for (Player opp : ai.getOpponents()) { - int oppLands = CardLists.filter(opp.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.LANDS.and(CardPredicates.Presets.BASIC_LANDS.negate())).size(); + int oppLands = CardLists.filter(opp.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.NONBASIC_LANDS).size(); // Always if enemy would die and we don't! // TODO : predict actual damage instead of assuming it'll be 2*lands // Don't if we lose, unless we lose anyway to unblocked creatures next turn diff --git a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java index 0bc94e3e50e..7a353b2c05c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java @@ -1143,8 +1143,8 @@ private static Card attachAIPumpPreference(final Player ai, final SpellAbility s //some auras/equipments aren't useful in multiples if (attachSource.hasSVar("NonStackingAttachEffect")) { prefList = CardLists.filter(prefList, CardPredicates.isEquippedBy(attachSource.getName()) - .or(CardPredicates.isEnchantedBy(attachSource.getName()) - ).negate()); + .or(CardPredicates.isEnchantedBy(attachSource.getName())).negate() + ); } // Don't pump cards that will die. diff --git a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java index 4ab7c9ec7de..63403bd4e6c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java @@ -614,8 +614,8 @@ private static Card basicManaFixing(final Player ai, final List list) { // } // pick dual lands if available - if (Iterables.any(result, Presets.BASIC_LANDS.negate())) { - result = CardLists.filter(result, Presets.BASIC_LANDS.negate()); + if (Iterables.any(result, Presets.NONBASIC_LANDS)) { + result = CardLists.filter(result, Presets.NONBASIC_LANDS); } return result.get(0); @@ -906,8 +906,7 @@ private static boolean isPreferredTarget(final Player ai, final SpellAbility sa, } if (source.isInZone(ZoneType.Hand)) { - Predicate nameEquals = CardPredicates.nameEquals(source.getName()); - list = CardLists.filter(list, nameEquals.negate()); // Don't get the same card back. + list = CardLists.filter(list, CardPredicates.nameNotEquals(source.getName())); // Don't get the same card back. } if (sa.isSpell()) { list.remove(source); // spells can't target their own source, because it's actually in the stack zone @@ -1014,7 +1013,7 @@ private static boolean isPreferredTarget(final Player ai, final SpellAbility sa, boolean saheeliFelidarCombo = ComputerUtilAbility.getAbilitySourceName(sa).equals("Felidar Guardian") && tobounce.getName().equals("Saheeli Rai") && CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Felidar Guardian")).size() < - CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Battlefield), CardPredicates.isType("Creature")).size() + ai.getOpponentsGreatestLifeTotal() + 10; + CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Battlefield), Presets.CREATURES).size() + ai.getOpponentsGreatestLifeTotal() + 10; // remember that the card was bounced already unless it's a special combo case if (!saheeliFelidarCombo) { @@ -1630,8 +1629,7 @@ public static Card chooseCardToHiddenOriginChangeZone(ZoneType destination, List } } else { // Don't fetch another tutor with the same name - Predicate nameEquals = CardPredicates.nameEquals(ComputerUtilAbility.getAbilitySourceName(sa)); - CardCollection sameNamed = CardLists.filter(fetchList, nameEquals.negate()); + CardCollection sameNamed = CardLists.filter(fetchList, CardPredicates.nameNotEquals(ComputerUtilAbility.getAbilitySourceName(sa))); if (origin.contains(ZoneType.Library) && !sameNamed.isEmpty()) { fetchList = sameNamed; } @@ -1963,7 +1961,7 @@ public static Card doExilePreferenceLogic(final Player aiPlayer, final SpellAbil } if (logic.contains("NonLand")) { - scanList = CardLists.filter(scanList, Presets.LANDS.negate()); + scanList = CardLists.filter(scanList, Presets.NON_LANDS); } if (logic.contains("NonExiled")) { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java index 3cb044578e8..b5a77496d57 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java @@ -270,7 +270,7 @@ public Card chooseSingleCard(final Player ai, final SpellAbility sa, Iterable oppCreatures = CardLists.filter(options, CardPredicates.Presets.CREATURES.and(CardPredicates.isOwner(aiChoser).negate())); List aiNonCreatures = CardLists.filter(options, - CardPredicates.Presets.CREATURES.negate() + CardPredicates.Presets.NON_CREATURES .and(CardPredicates.Presets.PERMANENTS) .and(CardPredicates.isOwner(aiChoser)) ); diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java index ee378b41134..95e41b8bb52 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java @@ -1193,7 +1193,7 @@ public int chooseNumber(Player player, SpellAbility sa, int min, int max, Map 3 && oppCards.size() >= aiCards.size() * 2) { sa.setXManaCostPaid(manaValue); diff --git a/forge-ai/src/main/java/forge/ai/ability/ScryAi.java b/forge-ai/src/main/java/forge/ai/ability/ScryAi.java index 2462d80a1a3..94a7cbbf85f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ScryAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ScryAi.java @@ -99,7 +99,7 @@ protected boolean checkPhaseRestrictions(final Player ai, final SpellAbility sa, private boolean doBestOpportunityLogic(Player ai, SpellAbility sa, PhaseHandler ph) { // Check to see if there are any cards in hand that may be worth casting boolean hasSomethingElse = false; - for (Card c : CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.LANDS.negate())) { + for (Card c : CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.NON_LANDS)) { for (SpellAbility ab : c.getAllSpellAbilities()) { if (ab.getPayCosts().hasManaCost() && ComputerUtilMana.hasEnoughManaSourcesToCast(ab, ai)) { diff --git a/forge-ai/src/main/java/forge/ai/ability/UntapAi.java b/forge-ai/src/main/java/forge/ai/ability/UntapAi.java index 6c573cc50d9..3d70acae32f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/UntapAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/UntapAi.java @@ -400,7 +400,7 @@ private boolean doPoolExtraManaLogic(final Player ai, final SpellAbility sa) { } // Check if something is playable if we untap for an additional mana with this, then proceed - CardCollection inHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), Presets.LANDS.negate()); + CardCollection inHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), Presets.NON_LANDS); // The AI is not very good at timing non-permanent spells this way, so filter them out // (it may actually be possible to enable this for sorceries, but that'll need some canPlay shenanigans) CardCollection playable = CardLists.filter(inHand, Presets.PERMANENTS); diff --git a/forge-core/src/main/java/forge/card/CardRulesPredicates.java b/forge-core/src/main/java/forge/card/CardRulesPredicates.java index 272534b666d..2e97b9ab6a6 100644 --- a/forge-core/src/main/java/forge/card/CardRulesPredicates.java +++ b/forge-core/src/main/java/forge/card/CardRulesPredicates.java @@ -549,9 +549,12 @@ public static class Presets { /** The Constant isBasicLand. */ public static final Predicate IS_BASIC_LAND = subject -> subject.getType().isBasicLand(); + public static final Predicate NOT_BASIC_LAND = subject -> !subject.getType().isBasicLand(); - /** The Constant isBasicLandNotWastes. */ + /** Matches only Plains, Island, Swamp, Mountain, or Forest. */ public static final Predicate IS_BASIC_LAND_NOT_WASTES = subject -> !subject.getName().equals("Wastes")&&subject.getType().isBasicLand(); + /** Matches any card except Plains, Island, Swamp, Mountain, or Forest. */ + public static final Predicate NOT_TRUE_BASIC_LAND = subject -> !subject.getType().isBasicLand() || subject.getName().equals("Wastes"); /** The Constant isNonBasicLand. */ public static final Predicate IS_NONBASIC_LAND = subject -> subject.getType().isLand() && !subject.getType().isBasicLand(); diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index 92a65b10f5e..b83fcc53154 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -234,7 +234,7 @@ protected void adjustDeckSize(int targetSize) { addSome(targetSize - actualSize, tDeck.toFlatList()); } else if (actualSize > targetSize) { - Predicate exceptBasicLand = Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules).negate(); + Predicate exceptBasicLand = Predicates.compose(CardRulesPredicates.Presets.NOT_BASIC_LAND, PaperCard::getRules); for (int i = 0; i < 3 && actualSize > targetSize; i++) { Iterable matchingCards = Iterables.filter(tDeck.toFlatList(), exceptBasicLand); @@ -388,7 +388,7 @@ protected List getDualLandList(Predicate canPlay) { //filter to provide all dual lands from pool matching 2 or 3 colors from current deck Predicate dualLandFilter = CardRulesPredicates.coreType(true, CardType.CoreType.Land); - Predicate exceptBasicLand = CardRulesPredicates.Presets.IS_BASIC_LAND.negate(); + Predicate exceptBasicLand = CardRulesPredicates.Presets.NOT_BASIC_LAND; Iterable landCards = pool.getAllCards(Predicates.compose(dualLandFilter.and(exceptBasicLand).and(canPlay), PaperCard::getRules)); Iterable dualLandPatterns = Arrays.asList("Add \\{([WUBRG])\\} or \\{([WUBRG])\\}", diff --git a/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java b/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java index 659ed4cadfe..fadd9dab249 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java @@ -29,7 +29,7 @@ public void resolve(SpellAbility sa) { final CardCollectionView milled = game.getAction().mill(new PlayerCollection(p), numRad, ZoneType.Graveyard, sa, moveParams); table.triggerChangesZoneAll(game, sa); - int n = CardLists.count(milled, CardPredicates.Presets.LANDS.negate()); + int n = CardLists.count(milled, CardPredicates.Presets.NON_LANDS); if (StaticAbilityGainLifeRadiation.gainLifeRadiation(p)) { p.gainLife(n, sa.getHostCard(), sa); diff --git a/forge-game/src/main/java/forge/game/card/Card.java b/forge-game/src/main/java/forge/game/card/Card.java index ec8888dbc9e..8e850a055f7 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -5532,6 +5532,7 @@ public final boolean isSpell() { public final boolean isKindred() { return getType().isKindred(); } public final boolean isSorcery() { return getType().isSorcery(); } public final boolean isInstant() { return getType().isInstant(); } + public final boolean isInstantOrSorcery() {return getType().isInstant() || getType().isSorcery();} public final boolean isCreature() { return getType().isCreature(); } public final boolean isArtifact() { return getType().isArtifact(); } diff --git a/forge-game/src/main/java/forge/game/card/CardPredicates.java b/forge-game/src/main/java/forge/game/card/CardPredicates.java index f8f202ffa64..62ac3ed4cb9 100644 --- a/forge-game/src/main/java/forge/game/card/CardPredicates.java +++ b/forge-game/src/main/java/forge/game/card/CardPredicates.java @@ -92,6 +92,9 @@ public static Predicate isTargetableBy(final SpellAbility source) { public static Predicate nameEquals(final String name) { return c -> c.getName().equals(name); } + public static Predicate nameNotEquals(final String name) { + return c -> !c.getName().equals(name); + } public static Predicate sharesNameWith(final Card name) { return c -> c.sharesNameWith(name); @@ -320,6 +323,7 @@ public static class Presets { * a Predicate to get all creatures. */ public static final Predicate CREATURES = Card::isCreature; + public static final Predicate NON_CREATURES = c -> !c.isCreature(); /** * a Predicate to get all enchantments. @@ -366,6 +370,7 @@ public static class Presets { // the isBasicLand() check here may be sufficient... return c.isLand() && c.isBasicLand(); }; + public static final Predicate NONBASIC_LANDS = c -> c.isLand() && !c.isBasicLand(); /** * a Predicate to get all artifacts. */ @@ -374,10 +379,12 @@ public static class Presets { * a Predicate to get all nonartifacts. */ public static final Predicate NON_ARTIFACTS = c -> !c.isArtifact(); + public static final Predicate INSTANTS_AND_SORCERIES = Card::isInstantOrSorcery; /** * a Predicate to get all lands. */ - public static final Predicate LANDS = c -> c.isLand(); + public static final Predicate LANDS = Card::isLand; + public static final Predicate NON_LANDS = c -> !c.isLand(); /** * a Predicate to get all mana-producing lands. */ 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 0d2a9299787..1c572a7c078 100644 --- a/forge-game/src/main/java/forge/game/combat/Combat.java +++ b/forge-game/src/main/java/forge/game/combat/Combat.java @@ -222,11 +222,11 @@ public final FCollectionView getDefendingPlayers() { } public final CardCollection getDefendingPlaneswalkers() { - return CardLists.filter(Iterables.filter(attackableEntries, Card.class), CardPredicates.isType("Planeswalker")); + return CardLists.filter(Iterables.filter(attackableEntries, Card.class), CardPredicates.Presets.PLANESWALKERS); } public final CardCollection getDefendingBattles() { - return CardLists.filter(Iterables.filter(attackableEntries, Card.class), CardPredicates.isType("Battle")); + return CardLists.filter(Iterables.filter(attackableEntries, Card.class), CardPredicates.Presets.BATTLES); } public final Map getAttackersAndDefenders() { diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java index 2aeda0a874a..638f70239b8 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java @@ -70,7 +70,7 @@ private void newRandomCon final Deck randomDeck = new Deck(); - final Predicate notBasicLand = Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules).negate(); + final Predicate notBasicLand = Predicates.compose(CardRulesPredicates.Presets.NOT_BASIC_LAND, PaperCard::getRules); final Iterable source = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards(), notBasicLand); randomDeck.getMain().addAllFlat(Aggregates.random(source, 15 * 5)); diff --git a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java index a937d49e40a..fffc91daedb 100644 --- a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java +++ b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java @@ -481,7 +481,7 @@ public Array getRewards() { if(data.rewards != null) { //Collect standard rewards. Deck enemyDeck = Current.latestDeck(); // By popular demand, remove basic lands from the reward pool. - CardPool deckNoBasicLands = enemyDeck.getMain().getFilteredPool(Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND.negate(), PaperCard::getRules)); + CardPool deckNoBasicLands = enemyDeck.getMain().getFilteredPool(Predicates.compose(CardRulesPredicates.Presets.NOT_BASIC_LAND, PaperCard::getRules)); for (RewardData rdata : data.rewards) { ret.addAll(rdata.generate(false, enemyDeck == null ? null : deckNoBasicLands.toFlatList(),true )); diff --git a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java index 9483ac0dc8f..9e5028a05ba 100644 --- a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java @@ -74,7 +74,7 @@ public static HashMap>> initializeForma true); final Iterable cards = Iterables.filter(format.getAllCards() - , Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES.negate(), PaperCard::getRules)); + , Predicates.compose(CardRulesPredicates.Presets.NOT_TRUE_BASIC_LAND, PaperCard::getRules)); List cardList = Lists.newArrayList(cards); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); @@ -90,7 +90,7 @@ public static HashMap>> initializeForma for (Deck deck:decks){ if (deck.getMain().contains(card)){ for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(), - Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES.negate(), PaperCard::getRules))){ + Predicates.compose(CardRulesPredicates.Presets.NOT_TRUE_BASIC_LAND, PaperCard::getRules))){ if (!pairCard.getName().equals(card.getName())){ try { int old = matrix[cardIntegerMap.get(card.getName())][cardIntegerMap.get(pairCard.getName())]; @@ -143,7 +143,7 @@ public static HashMap>> initializeComma //get all cards final Iterable cards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards() - , Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES.negate(), PaperCard::getRules)); + , Predicates.compose(CardRulesPredicates.Presets.NOT_TRUE_BASIC_LAND, PaperCard::getRules)); List cardList = Lists.newArrayList(cards); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); @@ -200,7 +200,7 @@ public static HashMap>> initializeComma public static void updateLegendMatrix(Deck deck, PaperCard legend, Map cardIntegerMap, Map legendIntegerMap, int[][] matrix){ for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(), - Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES.negate(), PaperCard::getRules))){ + Predicates.compose(CardRulesPredicates.Presets.NOT_TRUE_BASIC_LAND, PaperCard::getRules))){ if (!pairCard.getName().equals(legend.getName())){ try { int old = matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(pairCard.getName())]; diff --git a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java index 8bbf1558960..eac701ec667 100644 --- a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java +++ b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java @@ -291,7 +291,7 @@ public static HashMap>> initializeComma //get all cards final Iterable cards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards() - , Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES.negate(), PaperCard::getRules)); + , Predicates.compose(CardRulesPredicates.Presets.NOT_TRUE_BASIC_LAND, PaperCard::getRules)); List cardList = Lists.newArrayList(cards); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); @@ -350,7 +350,7 @@ public static HashMap>> initializeComma public static void updateLegendMatrix(Deck deck, PaperCard legend, Map cardIntegerMap, Map legendIntegerMap, int[][] matrix){ for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(), - Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES.negate(), PaperCard::getRules))){ + Predicates.compose(CardRulesPredicates.Presets.NOT_TRUE_BASIC_LAND, PaperCard::getRules))){ if (!pairCard.getName().equals(legend.getName())){ try { int old = matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(pairCard.getName())]; From 85f80bb5f1bdd5c0c6a3a9f306940e8880aea8b7 Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 6 Sep 2024 18:10:24 -0400 Subject: [PATCH 22/68] Guava migration - Explode Predicate "Presets" subclasses --- .../java/forge/ai/AiAttackController.java | 4 +- .../main/java/forge/ai/AiBlockController.java | 2 +- .../src/main/java/forge/ai/AiController.java | 33 ++- .../src/main/java/forge/ai/ComputerUtil.java | 31 ++- .../main/java/forge/ai/ComputerUtilCard.java | 56 ++--- .../main/java/forge/ai/ComputerUtilCost.java | 5 +- .../main/java/forge/ai/ComputerUtilMana.java | 2 +- .../java/forge/ai/PlayerControllerAi.java | 17 +- .../src/main/java/forge/ai/SpecialCardAi.java | 66 +++--- .../main/java/forge/ai/ability/AnimateAi.java | 2 +- .../main/java/forge/ai/ability/AttachAi.java | 2 +- .../main/java/forge/ai/ability/BalanceAi.java | 8 +- .../java/forge/ai/ability/ChangeZoneAi.java | 26 +-- .../forge/ai/ability/ChangeZoneAllAi.java | 6 +- .../java/forge/ai/ability/ChooseCardAi.java | 13 +- .../java/forge/ai/ability/ChooseColorAi.java | 2 +- .../forge/ai/ability/ChooseDirectionAi.java | 4 +- .../java/forge/ai/ability/ChooseSourceAi.java | 6 +- .../java/forge/ai/ability/ChooseTypeAi.java | 4 +- .../main/java/forge/ai/ability/ClashAi.java | 2 +- .../forge/ai/ability/CopyPermanentAi.java | 3 +- .../java/forge/ai/ability/CountersPutAi.java | 10 +- .../ai/ability/CountersPutOrRemoveAi.java | 2 +- .../forge/ai/ability/CountersRemoveAi.java | 6 +- .../java/forge/ai/ability/DamageDealAi.java | 9 +- .../forge/ai/ability/DamagePreventAi.java | 4 +- .../main/java/forge/ai/ability/DestroyAi.java | 4 +- .../java/forge/ai/ability/DestroyAllAi.java | 4 +- .../java/forge/ai/ability/DigUntilAi.java | 4 +- .../main/java/forge/ai/ability/DiscardAi.java | 2 +- .../main/java/forge/ai/ability/EffectAi.java | 9 +- .../main/java/forge/ai/ability/ExploreAi.java | 4 +- .../main/java/forge/ai/ability/HauntAi.java | 2 +- .../main/java/forge/ai/ability/MillAi.java | 2 +- .../java/forge/ai/ability/PermanentAi.java | 6 +- .../main/java/forge/ai/ability/PumpAi.java | 5 +- .../ai/ability/RearrangeTopOfLibraryAi.java | 2 +- .../java/forge/ai/ability/RegenerateAi.java | 4 +- .../java/forge/ai/ability/RepeatEachAi.java | 3 +- .../main/java/forge/ai/ability/ScryAi.java | 2 +- .../java/forge/ai/ability/SetStateAi.java | 2 +- .../main/java/forge/ai/ability/TapAiBase.java | 7 +- .../main/java/forge/ai/ability/TapAllAi.java | 4 +- .../main/java/forge/ai/ability/UntapAi.java | 14 +- .../java/forge/ai/ability/UntapAllAi.java | 4 +- .../java/forge/card/CardFacePredicates.java | 22 +- .../java/forge/card/CardRulesPredicates.java | 153 ++++--------- .../src/main/java/forge/card/DeckHints.java | 2 +- .../forge/deck/generation/DeckGenPool.java | 4 +- .../deck/generation/DeckGeneratorBase.java | 16 +- .../src/main/java/forge/item/IPaperCard.java | 205 ------------------ .../main/java/forge/item/ItemPredicate.java | 21 +- .../java/forge/item/PaperCardPredicates.java | 197 +++++++++++++++++ .../main/java/forge/item/SealedProduct.java | 4 +- .../item/generation/BoosterGenerator.java | 61 +++--- forge-game/src/main/java/forge/game/Game.java | 2 +- .../src/main/java/forge/game/GameAction.java | 6 +- .../src/main/java/forge/game/GameEntity.java | 4 +- .../src/main/java/forge/game/GameFormat.java | 12 +- .../java/forge/game/ability/AbilityUtils.java | 6 +- .../ability/effects/ChooseCardEffect.java | 3 +- .../ability/effects/ChooseCardNameEffect.java | 2 +- .../game/ability/effects/ConniveEffect.java | 2 +- .../ability/effects/CopyPermanentEffect.java | 4 +- .../ability/effects/DestroyAllEffect.java | 2 +- .../effects/InternalRadiationEffect.java | 2 +- .../game/ability/effects/MakeCardEffect.java | 7 +- .../game/ability/effects/PlayEffect.java | 4 +- .../effects/PlayLandVariantEffect.java | 2 +- .../game/ability/effects/UntapEffect.java | 9 +- .../game/ability/effects/VentureEffect.java | 4 +- .../src/main/java/forge/game/card/Card.java | 8 +- .../java/forge/game/card/CardPredicates.java | 142 ++++-------- .../java/forge/game/card/CardProperty.java | 15 +- .../main/java/forge/game/combat/Combat.java | 4 +- .../java/forge/game/combat/CombatUtil.java | 2 +- .../java/forge/game/cost/CostAdjustment.java | 6 +- .../java/forge/game/cost/CostTapType.java | 5 +- .../java/forge/game/cost/CostUntapType.java | 8 +- .../java/forge/game/phase/PhaseHandler.java | 5 +- .../src/main/java/forge/game/phase/Untap.java | 3 +- .../main/java/forge/game/player/Player.java | 18 +- .../java/forge/gui/ImportSourceAnalyzer.java | 4 +- .../itemmanager/filters/CardPowerFilter.java | 2 +- .../filters/CardToughnessFilter.java | 2 +- .../itemmanager/filters/StatTypeFilter.java | 4 +- .../deckeditor/controllers/CDeckgen.java | 2 +- .../controllers/CEditorCommander.java | 6 +- .../deckeditor/controllers/CEditorQuest.java | 2 +- .../deckeditor/controllers/CStatistics.java | 20 +- .../controllers/CStatisticsImporter.java | 20 +- .../PlanarConquestCommanderGeneraterGA.java | 4 +- .../PlanarConquestGeneraterGA.java | 2 +- .../PlanarConquestTribalGeneraterGA.java | 2 +- .../adventure/character/EnemySprite.java | 2 +- .../itemmanager/filters/CardPowerFilter.java | 2 +- .../filters/CardToughnessFilter.java | 2 +- .../itemmanager/filters/StatTypeFilter.java | 2 +- .../deck/CardRelationMatrixGenerator.java | 8 +- .../forge/deck/CommanderDeckGenerator.java | 2 +- .../src/main/java/forge/deck/DeckgenUtil.java | 15 +- .../limited/CardThemedDeckBuilder.java | 37 ++-- .../gamemodes/limited/LimitedDeckBuilder.java | 18 +- .../gamemodes/limited/SealedDeckBuilder.java | 10 +- .../forge/gamemodes/limited/WinstonDraft.java | 3 +- .../forge/gamemodes/quest/BoosterUtils.java | 57 +++-- .../gamemodes/quest/QuestRewardCard.java | 12 +- .../forge/gamemodes/quest/QuestUtilCards.java | 12 +- .../quest/QuestWinLoseController.java | 4 +- .../forge/itemmanager/SItemManagerUtil.java | 30 +-- .../src/main/java/forge/model/CardBlock.java | 4 +- .../src/main/java/forge/model/FModel.java | 20 +- .../src/main/java/forge/model/MetaSet.java | 4 +- .../java/forge/player/HumanCostDecision.java | 5 +- .../src/main/java/forge/player/HumanPlay.java | 3 +- .../forge/player/PlayerControllerHuman.java | 4 +- .../java/forge/lda/LDAModelGenetrator.java | 4 +- 117 files changed, 756 insertions(+), 955 deletions(-) create mode 100644 forge-core/src/main/java/forge/item/PaperCardPredicates.java diff --git a/forge-ai/src/main/java/forge/ai/AiAttackController.java b/forge-ai/src/main/java/forge/ai/AiAttackController.java index b53096ec245..dd37ab118f2 100644 --- a/forge-ai/src/main/java/forge/ai/AiAttackController.java +++ b/forge-ai/src/main/java/forge/ai/AiAttackController.java @@ -611,9 +611,9 @@ private boolean doAssault() { // TODO: the AI should ideally predict how many times it can activate // for now, unless the opponent is tapped out, break at this point // and do not predict the blocker limit (which is safer) - if (Iterables.any(defendingOpponent.getLandsInPlay(), CardPredicates.Presets.UNTAPPED)) { + if (Iterables.any(defendingOpponent.getLandsInPlay(), CardPredicates.UNTAPPED)) { maxBlockersAfterCrew += CardLists.count(CardLists.getNotType(defendingOpponent.getCardsIn(ZoneType.Battlefield), "Creature"), - CardPredicates.isType("Vehicle").and(CardPredicates.Presets.UNTAPPED)); + CardPredicates.isType("Vehicle").and(CardPredicates.UNTAPPED)); } } diff --git a/forge-ai/src/main/java/forge/ai/AiBlockController.java b/forge-ai/src/main/java/forge/ai/AiBlockController.java index d884dd19ba5..97bc20ca63c 100644 --- a/forge-ai/src/main/java/forge/ai/AiBlockController.java +++ b/forge-ai/src/main/java/forge/ai/AiBlockController.java @@ -1343,7 +1343,7 @@ private boolean wouldLikeToRandomlyTrade(Card attacker, Card blocker, Combat com boolean creatureParityOrAllowedDiff = aiCreatureCount + (randomTradeIfBehindOnBoard ? maxCreatDiff : 0) >= oppCreatureCount; boolean wantToTradeWithCreatInHand = !checkingOther && randomTradeIfCreatInHand - && ai.getZone(ZoneType.Hand).contains(CardPredicates.Presets.CREATURES) + && ai.getZone(ZoneType.Hand).contains(CardPredicates.CREATURES) && aiCreatureCount + maxCreatDiffWithRepl >= oppCreatureCount; boolean wantToSavePlaneswalker = MyRandom.percentTrue(chanceToSavePW) && combat.getDefenderByAttacker(attacker) instanceof Card diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index f51e553d0c2..4d49aa2520f 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -34,7 +34,6 @@ import forge.game.ability.ApiType; import forge.game.ability.SpellApiBased; import forge.game.card.*; -import forge.game.card.CardPredicates.Presets; import forge.game.combat.Combat; import forge.game.combat.CombatUtil; import forge.game.cost.*; @@ -404,10 +403,10 @@ private static List getPlayableCounters(final CardCollection l) { private CardCollection filterLandsToPlay(CardCollection landList) { final CardCollectionView hand = player.getCardsIn(ZoneType.Hand); - CardCollection nonLandList = CardLists.filter(hand, Presets.NON_LANDS); + CardCollection nonLandList = CardLists.filter(hand, CardPredicates.NON_LANDS); if (landList.size() == 1 && nonLandList.size() < 3) { CardCollectionView cardsInPlay = player.getCardsIn(ZoneType.Battlefield); - CardCollection landsInPlay = CardLists.filter(cardsInPlay, Presets.LANDS); + CardCollection landsInPlay = CardLists.filter(cardsInPlay, CardPredicates.LANDS); CardCollection allCards = new CardCollection(player.getCardsIn(ZoneType.Graveyard)); allCards.addAll(player.getCardsIn(ZoneType.Command)); allCards.addAll(cardsInPlay); @@ -445,7 +444,7 @@ private CardCollection filterLandsToPlay(CardCollection landList) { final CardCollectionView hand1 = player.getCardsIn(ZoneType.Hand); CardCollection lands = new CardCollection(battlefield); lands.addAll(hand1); - lands = CardLists.filter(lands, Presets.LANDS); + lands = CardLists.filter(lands, CardPredicates.LANDS); int maxCmcInHand = Aggregates.max(hand1, Card::getCMC); if (lands.size() >= Math.max(maxCmcInHand, 6)) { @@ -469,7 +468,7 @@ private Card chooseBestLandToPlay(CardCollection landList) { return null; } - CardCollection nonLandsInHand = CardLists.filter(player.getCardsIn(ZoneType.Hand), Presets.NON_LANDS); + CardCollection nonLandsInHand = CardLists.filter(player.getCardsIn(ZoneType.Hand), CardPredicates.NON_LANDS); // Some considerations for Momir/MoJhoSto boolean hasMomir = player.isCardInCommand("Momir Vig, Simic Visionary Avatar"); @@ -598,8 +597,8 @@ private Card chooseBestLandToPlay(CardCollection landList) { } // pick dual lands if available - if (Iterables.any(landList, Presets.NONBASIC_LANDS)) { - landList = CardLists.filter(landList, Presets.NONBASIC_LANDS); + if (Iterables.any(landList, CardPredicates.NONBASIC_LANDS)) { + landList = CardLists.filter(landList, CardPredicates.NONBASIC_LANDS); } } return ComputerUtilCard.getBestLandToPlayAI(landList); @@ -1061,7 +1060,7 @@ public CardCollection getCardsToDiscard(int min, final int max, final CardCollec if ("DiscardUncastableAndExcess".equals(sa.getParam("AILogic"))) { CardCollection discards = new CardCollection(); final CardCollectionView inHand = player.getCardsIn(ZoneType.Hand); - final int numLandsOTB = CardLists.count(inHand, CardPredicates.Presets.LANDS); + final int numLandsOTB = CardLists.count(inHand, CardPredicates.LANDS); int numOppInHand = 0; for (Player p : player.getGame().getPlayers()) { if (p.getCardsIn(ZoneType.Hand).size() > numOppInHand) { @@ -1119,8 +1118,8 @@ public CardCollection getCardsToDiscard(int min, final int max, final CardCollec if (validCards.isEmpty()) { continue; } - final int numLandsInPlay = CardLists.count(player.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.LANDS_PRODUCING_MANA); - final CardCollection landsInHand = CardLists.filter(validCards, CardPredicates.Presets.LANDS); + final int numLandsInPlay = CardLists.count(player.getCardsIn(ZoneType.Battlefield), CardPredicates.LANDS_PRODUCING_MANA); + final CardCollection landsInHand = CardLists.filter(validCards, CardPredicates.LANDS); final int numLandsInHand = landsInHand.size(); // Discard a land @@ -1397,11 +1396,11 @@ private boolean isSafeToHoldLandDropForMain2(Card landToPlay) { return false; } - CardCollection inHand = CardLists.filter(player.getCardsIn(ZoneType.Hand), Presets.NON_LANDS); + CardCollection inHand = CardLists.filter(player.getCardsIn(ZoneType.Hand), CardPredicates.NON_LANDS); CardCollectionView otb = player.getCardsIn(ZoneType.Battlefield); if (getBooleanProperty(AiProps.HOLD_LAND_DROP_ONLY_IF_HAVE_OTHER_PERMS)) { - if (!Iterables.any(otb, Presets.NON_LANDS)) { + if (!Iterables.any(otb, CardPredicates.NON_LANDS)) { return false; } } @@ -1578,7 +1577,7 @@ private SpellAbility chooseSpellAbilityToPlayFromList(final List a if (sa.getHostCard().hasKeyword(Keyword.STORM) && sa.getApi() != ApiType.Counter // AI would suck at trying to deliberately proc a Storm counterspell && player.getZone(ZoneType.Hand).contains( - Presets.LANDS.or(CardPredicates.hasKeyword("Storm")).negate())) { + CardPredicates.LANDS.or(CardPredicates.hasKeyword("Storm")).negate())) { if (game.getView().getStormCount() < this.getIntProperty(AiProps.MIN_COUNT_FOR_STORM_SPELLS)) { // skip evaluating Storm unless we reached the minimum Storm count continue; @@ -1601,7 +1600,7 @@ private SpellAbility chooseSpellAbilityToPlayFromList(final List a } else if (sa.getHostCard().hasKeyword(Keyword.CASCADE)) { if (isLifeInDanger) { //needs more tune up for certain conditions aiPlayDecision = player.getCreaturesInPlay().size() >= 4 ? AiPlayDecision.CantPlaySa : AiPlayDecision.WillPlay; - } else if (CardLists.filter(player.getZone(ZoneType.Graveyard).getCards(), CardPredicates.Presets.CREATURES).size() > 4) { + } else if (CardLists.filter(player.getZone(ZoneType.Graveyard).getCards(), CardPredicates.CREATURES).size() > 4) { if (player.getCreaturesInPlay().size() >= 4) // it's good minimum continue; else if (!sa.getHostCard().isPermanent() && sa.canCastTiming(player) && ComputerUtilCost.canPayCost(sa, player, sa.isTrigger())) @@ -1971,7 +1970,7 @@ public CardCollection chooseCardsForEffect(CardCollectionView pool, SpellAbility break; } } else { - CardCollectionView viableOptions = CardLists.filter(pool, CardPredicates.isControlledByAnyOf(sa.getActivatingPlayer().getOpponents()), CardPredicates.Presets.CAN_BE_DESTROYED); + CardCollectionView viableOptions = CardLists.filter(pool, CardPredicates.isControlledByAnyOf(sa.getActivatingPlayer().getOpponents()), CardPredicates.CAN_BE_DESTROYED); Card best = ComputerUtilCard.getBestAI(viableOptions); if (best != null) { result.add(best); @@ -2047,7 +2046,7 @@ public CardCollectionView cheatShuffle(CardCollectionView in) { CardLists.shuffle(library); // remove all land, keep non-basicland in there, shuffled - CardCollection land = CardLists.filter(library, CardPredicates.Presets.LANDS); + CardCollection land = CardLists.filter(library, CardPredicates.LANDS); for (Card c : land) { if (c.isLand()) { library.remove(c); @@ -2097,7 +2096,7 @@ public boolean chooseDirection(SpellAbility sa) { } } if ("Aminatou".equals(sa.getParam("AILogic")) && game.getPlayers().size() > 2) { - CardCollection all = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Presets.NONLAND_PERMANENTS); + CardCollection all = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.NONLAND_PERMANENTS); CardCollection left = CardLists.filterControlledBy(all, game.getNextPlayerAfter(player, Direction.Left)); CardCollection right = CardLists.filterControlledBy(all, game.getNextPlayerAfter(player, Direction.Right)); return Aggregates.sum(left, Card::getCMC) > Aggregates.sum(right, Card::getCMC); diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index 0e3b8437a10..c7add8c8347 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -48,7 +48,6 @@ import forge.game.ability.AbilityUtils; import forge.game.ability.ApiType; import forge.game.ability.effects.CharmEffect; -import forge.game.card.CardPredicates.Presets; import forge.game.combat.Combat; import forge.game.combat.CombatUtil; import forge.game.keyword.Keyword; @@ -528,7 +527,7 @@ else if (pref.contains("DiscardCost")) { // search for permanents with DiscardMe // Discard lands final CardCollection landsInHand = CardLists.getType(typeList, "Land"); if (!landsInHand.isEmpty()) { - final int numLandsInPlay = CardLists.count(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.LANDS_PRODUCING_MANA); + final int numLandsInPlay = CardLists.count(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.LANDS_PRODUCING_MANA); final CardCollection nonLandsInHand = CardLists.getNotType(ai.getCardsIn(ZoneType.Hand), "Land"); final int highestCMC = Math.max(6, Aggregates.max(nonLandsInHand, Card::getCMC)); if (numLandsInPlay >= highestCMC @@ -769,7 +768,7 @@ public static CardCollection chooseTapType(final Player ai, final String type, f all.removeAll(exclude); CardCollection typeList = CardLists.getValidCards(all, type.split(";"), activate.getController(), activate, sa); - typeList = CardLists.filter(typeList, Presets.CAN_TAP); + typeList = CardLists.filter(typeList, CardPredicates.CAN_TAP); if (tap) { typeList.remove(activate); @@ -799,7 +798,7 @@ public static CardCollection chooseTapTypeAccumulatePower(final Player ai, final all.removeAll(exclude); CardCollection typeList = CardLists.getValidCards(all, type.split(";"), activate.getController(), activate, sa); - typeList = CardLists.filter(typeList, sa.isCrew() ? Presets.CAN_CREW : Presets.CAN_TAP); + typeList = CardLists.filter(typeList, sa.isCrew() ? CardPredicates.CAN_CREW : CardPredicates.CAN_TAP); if (tap) { typeList.remove(activate); @@ -837,7 +836,7 @@ public static CardCollection chooseUntapType(final Player ai, final String type, CardCollection typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), activate.getController(), activate, sa); - typeList = CardLists.filter(typeList, Presets.TAPPED); + typeList = CardLists.filter(typeList, CardPredicates.TAPPED); if (untap) { typeList.remove(activate); @@ -1035,7 +1034,7 @@ private static Card chooseCardToSacrifice(final SpellAbility source, CardCollect c = ComputerUtilCard.getWorstCreatureAI(remaining); } else if (CardLists.getNotType(remaining, "Land").isEmpty()) { - c = ComputerUtilCard.getWorstLand(CardLists.filter(remaining, CardPredicates.Presets.LANDS)); + c = ComputerUtilCard.getWorstLand(CardLists.filter(remaining, CardPredicates.LANDS)); } else { c = ComputerUtilCard.getWorstPermanentAI(remaining, false, false, false, false); @@ -1344,8 +1343,8 @@ public static boolean isWorseThanDraw(final Player ai, Card discard) { } final Game game = ai.getGame(); - final CardCollection landsInPlay = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.LANDS_PRODUCING_MANA); - final CardCollection landsInHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.LANDS); + final CardCollection landsInPlay = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.LANDS_PRODUCING_MANA); + final CardCollection landsInHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.LANDS); final CardCollection nonLandsInHand = CardLists.getNotType(ai.getCardsIn(ZoneType.Hand), "Land"); final int highestCMC = Math.max(6, Aggregates.max(nonLandsInHand, Card::getCMC)); final int discardCMC = discard.getCMC(); @@ -1664,7 +1663,7 @@ public static int possibleNonCombatDamage(final Player ai, final Player enemy) { int damage = 0; final CardCollection all = new CardCollection(ai.getCardsIn(ZoneType.Battlefield)); all.addAll(ai.getCardsActivatableInExternalZones(true)); - all.addAll(CardLists.filter(ai.getCardsIn(ZoneType.Hand), Presets.PERMANENTS.negate())); + all.addAll(CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.PERMANENTS.negate())); for (final Card c : all) { if (c.getZone().getPlayer() != null && c.getZone().getPlayer() != ai && c.mayPlay(ai).isEmpty()) { @@ -2218,7 +2217,7 @@ public static int scoreHand(CardCollectionView handList, Player ai, int cardsToR } CardCollectionView library = ai.getCardsIn(ZoneType.Library); - int landsInDeck = CardLists.count(library, Presets.LANDS); + int landsInDeck = CardLists.count(library, CardPredicates.LANDS); // no land deck, can't do anything better if (landsInDeck == 0) { @@ -2363,14 +2362,14 @@ public static boolean scryWillMoveCardToBottomOfLibrary(Player player, Card c) { CardCollectionView cardsInHand = player.getCardsIn(ZoneType.Hand); CardCollectionView cardsOTB = player.getCardsIn(ZoneType.Battlefield); - CardCollection landsOTB = CardLists.filter(cardsOTB, CardPredicates.Presets.LANDS_PRODUCING_MANA); + CardCollection landsOTB = CardLists.filter(cardsOTB, CardPredicates.LANDS_PRODUCING_MANA); CardCollection thisLandOTB = CardLists.filter(cardsOTB, CardPredicates.nameEquals(c.getName())); - CardCollection landsInHand = CardLists.filter(cardsInHand, CardPredicates.Presets.LANDS_PRODUCING_MANA); + CardCollection landsInHand = CardLists.filter(cardsInHand, CardPredicates.LANDS_PRODUCING_MANA); // valuable mana-producing artifacts that may be equated to a land List manaArts = Arrays.asList("Mox Pearl", "Mox Sapphire", "Mox Jet", "Mox Ruby", "Mox Emerald"); // evaluate creatures available in deck - CardCollectionView allCreatures = CardLists.filter(allCards, CardPredicates.Presets.CREATURES, CardPredicates.isOwner(player)); + CardCollectionView allCreatures = CardLists.filter(allCards, CardPredicates.CREATURES, CardPredicates.isOwner(player)); int numCards = allCreatures.size(); if (landsOTB.size() < maxLandsToScryLandsToTop && landsInHand.isEmpty()) { @@ -2399,7 +2398,7 @@ public static boolean scryWillMoveCardToBottomOfLibrary(Player player, Card c) { } } } else if (c.isCreature()) { - CardCollection creaturesOTB = CardLists.filter(cardsOTB, CardPredicates.Presets.CREATURES); + CardCollection creaturesOTB = CardLists.filter(cardsOTB, CardPredicates.CREATURES); int avgCreatureValue = numCards != 0 ? ComputerUtilCard.evaluateCreatureList(allCreatures) / numCards : 0; int maxControlledCMC = Aggregates.max(creaturesOTB, Card::getCMC); @@ -2490,7 +2489,7 @@ public static String chooseSomeType(Player ai, String kindOfType, SpellAbility s double amount = 0; for (String type : CardType.getAllCardTypes()) { if (!invalidTypes.contains(type)) { - CardCollection list = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.isType(type), Presets.TAPPED); + CardCollection list = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.isType(type), CardPredicates.TAPPED); double i = type.equals("Creature") ? list.size() * 1.5 : list.size(); if (i > amount) { amount = i; @@ -2801,7 +2800,7 @@ public static Object vote(Player ai, List options, SpellAbility sa, Mult } // has cards with SacMe or Token - if (CardLists.count(aiCreatures, CardPredicates.hasSVar("SacMe").or(Presets.TOKEN)) >= numDeath) { + if (CardLists.count(aiCreatures, CardPredicates.hasSVar("SacMe").or(CardPredicates.TOKEN)) >= numDeath) { return "Death"; } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index 70466f6e223..7170d04894d 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -81,7 +81,7 @@ public static void sortByEvaluateCreature(final CardCollection list) { * @return a {@link forge.game.card.Card} object. */ public static Card getBestArtifactAI(final List list) { - List all = CardLists.filter(list, CardPredicates.Presets.ARTIFACTS); + List all = CardLists.filter(list, CardPredicates.ARTIFACTS); if (all.size() == 0) { return null; } @@ -96,7 +96,7 @@ public static Card getBestArtifactAI(final List list) { * @return best Planeswalker */ public static Card getBestPlaneswalkerAI(final List list) { - List all = CardLists.filter(list, CardPredicates.Presets.PLANESWALKERS); + List all = CardLists.filter(list, CardPredicates.PLANESWALKERS); if (all.isEmpty()) { return null; } @@ -111,7 +111,7 @@ public static Card getBestPlaneswalkerAI(final List list) { * @return best Planeswalker */ public static Card getWorstPlaneswalkerAI(final List list) { - List all = CardLists.filter(list, CardPredicates.Presets.PLANESWALKERS); + List all = CardLists.filter(list, CardPredicates.PLANESWALKERS); if (all.isEmpty()) { return null; } @@ -182,7 +182,7 @@ public static Card getWorstPlaneswalkerToDamage(final List pws) { * @return a {@link forge.game.card.Card} object. */ public static Card getBestEnchantmentAI(final List list, final SpellAbility spell, final boolean targeted) { - List all = CardLists.filter(list, CardPredicates.Presets.ENCHANTMENTS); + List all = CardLists.filter(list, CardPredicates.ENCHANTMENTS); if (targeted) { all = CardLists.filter(all, c -> c.canBeTargetedBy(spell)); } @@ -200,13 +200,13 @@ public static Card getBestEnchantmentAI(final List list, final SpellAbilit * @return a {@link forge.game.card.Card} object. */ public static Card getBestLandAI(final Iterable list) { - final List land = CardLists.filter(list, CardPredicates.Presets.LANDS); + final List land = CardLists.filter(list, CardPredicates.LANDS); if (land.isEmpty()) { return null; } // prefer to target non basic lands - final List nbLand = CardLists.filter(land, CardPredicates.Presets.NONBASIC_LANDS); + final List nbLand = CardLists.filter(land, CardPredicates.NONBASIC_LANDS); if (!nbLand.isEmpty()) { // TODO - Improve ranking various non-basic lands depending on context @@ -245,12 +245,12 @@ public static Card getBestLandAI(final Iterable list) { } if (iminBL == Integer.MAX_VALUE) { // All basic lands have no basic land type. Just return something - return Iterables.find(land, CardPredicates.Presets.UNTAPPED, land.get(0)); + return Iterables.find(land, CardPredicates.UNTAPPED, land.get(0)); } final List bLand = CardLists.getType(land, sminBL); - for (Card ut : Iterables.filter(bLand, CardPredicates.Presets.UNTAPPED)) { + for (Card ut : Iterables.filter(bLand, CardPredicates.UNTAPPED)) { return ut; } @@ -357,10 +357,10 @@ public static Card getCheapestPermanentAI(Iterable all, final SpellAbility */ public static Card getBestAI(final Iterable list) { // Get Best will filter by appropriate getBest list if ALL of the list is of that type - if (Iterables.all(list, CardPredicates.Presets.CREATURES)) { + if (Iterables.all(list, CardPredicates.CREATURES)) { return getBestCreatureAI(list); } - if (Iterables.all(list, CardPredicates.Presets.LANDS)) { + if (Iterables.all(list, CardPredicates.LANDS)) { return getBestLandAI(list); } // TODO - Once we get an EvaluatePermanent this should call getBestPermanent() @@ -377,7 +377,7 @@ public static Card getBestCreatureAI(final Iterable list) { if (Iterables.size(list) == 1) { return Iterables.get(list, 0); } - return Aggregates.itemWithMax(Iterables.filter(list, CardPredicates.Presets.CREATURES), ComputerUtilCard.creatureEvaluator); + return Aggregates.itemWithMax(Iterables.filter(list, CardPredicates.CREATURES), ComputerUtilCard.creatureEvaluator); } /** @@ -390,7 +390,7 @@ public static Card getBestLandToPlayAI(final Iterable list) { if (Iterables.size(list) == 1) { return Iterables.get(list, 0); } - return Aggregates.itemWithMax(Iterables.filter(list, CardPredicates.Presets.LANDS), ComputerUtilCard.landEvaluator); + return Aggregates.itemWithMax(Iterables.filter(list, CardPredicates.LANDS), ComputerUtilCard.landEvaluator); } /** @@ -405,7 +405,7 @@ public static Card getWorstCreatureAI(final Iterable list) { if (Iterables.size(list) == 1) { return Iterables.get(list, 0); } - return Aggregates.itemWithMin(Iterables.filter(list, CardPredicates.Presets.CREATURES), ComputerUtilCard.creatureEvaluator); + return Aggregates.itemWithMin(Iterables.filter(list, CardPredicates.CREATURES), ComputerUtilCard.creatureEvaluator); } // This selection rates tokens higher @@ -426,7 +426,7 @@ public static Card getBestCreatureToBounceAI(final Iterable list) { Card biggest = null; int biggestvalue = -1; - for (Card card : CardLists.filter(list, CardPredicates.Presets.CREATURES)) { + for (Card card : CardLists.filter(list, CardPredicates.CREATURES)) { int newvalue = evaluateCreature(card); newvalue += card.isToken() ? tokenBonus : 0; // raise the value of tokens @@ -479,40 +479,40 @@ public static Card getWorstPermanentAI(final Iterable list, final boolean return null; } - final boolean hasEnchantmants = Iterables.any(list, CardPredicates.Presets.ENCHANTMENTS); + final boolean hasEnchantmants = Iterables.any(list, CardPredicates.ENCHANTMENTS); if (biasEnch && hasEnchantmants) { - return getCheapestPermanentAI(CardLists.filter(list, CardPredicates.Presets.ENCHANTMENTS), null, false); + return getCheapestPermanentAI(CardLists.filter(list, CardPredicates.ENCHANTMENTS), null, false); } - final boolean hasArtifacts = Iterables.any(list, CardPredicates.Presets.ARTIFACTS); + final boolean hasArtifacts = Iterables.any(list, CardPredicates.ARTIFACTS); if (biasArt && hasArtifacts) { - return getCheapestPermanentAI(CardLists.filter(list, CardPredicates.Presets.ARTIFACTS), null, false); + return getCheapestPermanentAI(CardLists.filter(list, CardPredicates.ARTIFACTS), null, false); } - if (biasLand && Iterables.any(list, CardPredicates.Presets.LANDS)) { - return getWorstLand(CardLists.filter(list, CardPredicates.Presets.LANDS)); + if (biasLand && Iterables.any(list, CardPredicates.LANDS)) { + return getWorstLand(CardLists.filter(list, CardPredicates.LANDS)); } - final boolean hasCreatures = Iterables.any(list, CardPredicates.Presets.CREATURES); + final boolean hasCreatures = Iterables.any(list, CardPredicates.CREATURES); if (biasCreature && hasCreatures) { - return getWorstCreatureAI(CardLists.filter(list, CardPredicates.Presets.CREATURES)); + return getWorstCreatureAI(CardLists.filter(list, CardPredicates.CREATURES)); } - List lands = CardLists.filter(list, CardPredicates.Presets.LANDS); + List lands = CardLists.filter(list, CardPredicates.LANDS); if (lands.size() > 6) { return getWorstLand(lands); } if (hasEnchantmants || hasArtifacts) { final List ae = CardLists.filter(list, - (CardPredicates.Presets.ARTIFACTS.or(CardPredicates.Presets.ENCHANTMENTS)) + (CardPredicates.ARTIFACTS.or(CardPredicates.ENCHANTMENTS)) .and(card -> !card.hasSVar("DoNotDiscardIfAble")) ); return getCheapestPermanentAI(ae, null, false); } if (hasCreatures) { - return getWorstCreatureAI(CardLists.filter(list, CardPredicates.Presets.CREATURES)); + return getWorstCreatureAI(CardLists.filter(list, CardPredicates.CREATURES)); } // Planeswalkers fall through to here, lands will fall through if there aren't very many @@ -521,7 +521,7 @@ public static Card getWorstPermanentAI(final Iterable list, final boolean public static final Card getCheapestSpellAI(final Iterable list) { if (!Iterables.isEmpty(list)) { - CardCollection cc = CardLists.filter(list, CardPredicates.Presets.INSTANTS_AND_SORCERIES); + CardCollection cc = CardLists.filter(list, CardPredicates.INSTANTS_AND_SORCERIES); if (cc.isEmpty()) { return null; @@ -1001,7 +1001,7 @@ public static List chooseColor(SpellAbility sa, int min, int max, List= copy.getNetPower(); } else if ("Cultivator of Blades".equals(source.getName())) { // Cultivator does try to median with number of Creatures @@ -832,7 +831,7 @@ public static Set getAvailableManaColors(Player ai, Card additionalLand) return getAvailableManaColors(ai, Lists.newArrayList(additionalLand)); } public static Set getAvailableManaColors(Player ai, List additionalLands) { - CardCollection cardsToConsider = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Presets.UNTAPPED); + CardCollection cardsToConsider = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.UNTAPPED); Set colorsAvailable = Sets.newHashSet(); if (additionalLands != null) { diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index 66fc10d90d8..027fd436dfc 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -313,7 +313,7 @@ public static SpellAbility chooseManaAbility(ManaCostBeingPaid cost, SpellAbilit // For cards like Genju of the Cedars, make sure we're not attaching to the same land that will // be tapped to pay its own cost if there's another untapped land like that available if (ma.getHostCard().equals(sa.getTargetCard())) { - if (CardLists.count(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals(ma.getHostCard().getName()).and(CardPredicates.Presets.UNTAPPED)) > 1) { + if (CardLists.count(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals(ma.getHostCard().getName()).and(CardPredicates.UNTAPPED)) > 1) { continue; } } diff --git a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java index 685e11cfd54..99505d9ca51 100644 --- a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java +++ b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java @@ -19,7 +19,6 @@ import forge.game.ability.ApiType; import forge.game.ability.effects.CharmEffect; import forge.game.card.*; -import forge.game.card.CardPredicates.Presets; import forge.game.combat.Combat; import forge.game.cost.Cost; import forge.game.cost.CostEnlist; @@ -614,7 +613,7 @@ public CardCollectionView orderMoveToZoneList(CardCollectionView cards, ZoneType } } - int landsOTB = CardLists.count(p.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.LANDS_PRODUCING_MANA); + int landsOTB = CardLists.count(p.getCardsIn(ZoneType.Battlefield), CardPredicates.LANDS_PRODUCING_MANA); if (!p.isOpponentOf(player)) { if (landsOTB <= 2) { @@ -758,13 +757,13 @@ public CardCollectionView londonMulliganReturnCards(final Player mulliganingPlay for (int i = 0; i < cardsToReturn; i++) { hand.removeAll(toReturn); - CardCollection landsInHand = CardLists.filter(hand, Presets.LANDS); - int numLandsInHand = landsInHand.size() - CardLists.count(toReturn, Presets.LANDS); + CardCollection landsInHand = CardLists.filter(hand, CardPredicates.LANDS); + int numLandsInHand = landsInHand.size() - CardLists.count(toReturn, CardPredicates.LANDS); // If we're flooding with lands, get rid of the worst land we have if (numLandsInHand > 0 && numLandsInHand > numLandsDesired) { - CardCollection producingLands = CardLists.filter(landsInHand, Presets.LANDS_PRODUCING_MANA); - CardCollection nonProducingLands = CardLists.filter(landsInHand, Presets.LANDS_PRODUCING_MANA.negate()); + CardCollection producingLands = CardLists.filter(landsInHand, CardPredicates.LANDS_PRODUCING_MANA); + CardCollection nonProducingLands = CardLists.filter(landsInHand, CardPredicates.LANDS_PRODUCING_MANA.negate()); Card worstLand = nonProducingLands.isEmpty() ? ComputerUtilCard.getWorstLand(producingLands) : ComputerUtilCard.getWorstLand(nonProducingLands); toReturn.add(worstLand); @@ -1074,7 +1073,7 @@ public String chooseKeywordForPump(final List options, final SpellAbilit return Iterables.getFirst(options, null); } List possible = Lists.newArrayList(); - CardCollection oppUntappedCreatures = CardLists.filter(player.getOpponents().getCreaturesInPlay(), CardPredicates.Presets.UNTAPPED); + CardCollection oppUntappedCreatures = CardLists.filter(player.getOpponents().getCreaturesInPlay(), CardPredicates.UNTAPPED); if (tgtCard != null) { for (String kw : options) { if (tgtCard.hasKeyword(kw)) { @@ -1336,7 +1335,7 @@ public boolean chooseCardsPile(SpellAbility sa, CardCollectionView pile1, CardCo // Probably want to see if the face up pile has anything "worth it", then potentially take face down pile return pile1.size() >= pile2.size(); } else { - boolean allCreatures = Iterables.all(Iterables.concat(pile1, pile2), CardPredicates.Presets.CREATURES); + boolean allCreatures = Iterables.all(Iterables.concat(pile1, pile2), CardPredicates.CREATURES); int cmc1 = allCreatures ? ComputerUtilCard.evaluateCreatureList(pile1) : ComputerUtilCard.evaluatePermanentList(pile1); int cmc2 = allCreatures ? ComputerUtilCard.evaluateCreatureList(pile2) : ComputerUtilCard.evaluatePermanentList(pile2); @@ -1469,7 +1468,7 @@ public String chooseCardName(SpellAbility sa, Predicate cpp, String v } } else { CardCollectionView list = CardLists.filterControlledBy(getGame().getCardsInGame(), player.getOpponents()); - list = CardLists.filter(list, Presets.NON_LANDS); + list = CardLists.filter(list, CardPredicates.NON_LANDS); if (!list.isEmpty()) { return list.get(0).getName(); } diff --git a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java index 485504495f4..ca79e7df54b 100644 --- a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java +++ b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java @@ -124,8 +124,8 @@ public static boolean consider(final Player ai, final SpellAbility sa, final Man CardCollection manaSources = ComputerUtilMana.getAvailableManaSources(ai, true); int numManaSrcs = manaSources.size(); - CardCollection allCards = CardLists.filter(ai.getAllCards(), Arrays.asList(CardPredicates.Presets.NON_TOKEN, - CardPredicates.Presets.NON_LANDS, CardPredicates.isOwner(ai))); + CardCollection allCards = CardLists.filter(ai.getAllCards(), Arrays.asList(CardPredicates.NON_TOKEN, + CardPredicates.NON_LANDS, CardPredicates.isOwner(ai))); int numHighCMC = CardLists.count(allCards, CardPredicates.greaterCMC(5)); int numLowCMC = CardLists.count(allCards, CardPredicates.lessCMC(3)); @@ -156,7 +156,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { int libsize = ai.getCardsIn(ZoneType.Library).size(); final CardCollection hand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), - CardPredicates.Presets.INSTANTS_AND_SORCERIES); + CardPredicates.INSTANTS_AND_SORCERIES); if (!hand.isEmpty()) { // has spell that can be cast in hand with put ability if (Iterables.any(hand, CardPredicates.hasCMC(counterNum + 1))) { @@ -169,7 +169,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { } } final CardCollection library = CardLists.filter(ai.getCardsIn(ZoneType.Library), - CardPredicates.Presets.INSTANTS_AND_SORCERIES); + CardPredicates.INSTANTS_AND_SORCERIES); if (!library.isEmpty()) { // get max cmc of instant or sorceries in the libary int maxCMC = 0; @@ -204,9 +204,9 @@ public static boolean consider(final Player ai, final SpellAbility sa) { public static class ChainOfAcid { public static boolean consider(final Player ai, final SpellAbility sa) { List AiLandsOnly = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), - CardPredicates.Presets.LANDS); + CardPredicates.LANDS); List OppPerms = CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Battlefield), - CardPredicates.Presets.NON_CREATURES); + CardPredicates.NON_CREATURES); // TODO: improve this logic (currently the AI has difficulty evaluating non-creature permanents, // which it can only distinguish by their CMC, considering >CMC higher value). @@ -330,13 +330,13 @@ static public String chooseNonBattlefieldName() { // Deathgorge Scavenger public static class DeathgorgeScavenger { public static boolean consider(final Player ai, final SpellAbility sa) { - Card worstCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES)); - Card worstNonCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.NON_CREATURES)); + Card worstCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Graveyard), CardPredicates.CREATURES)); + Card worstNonCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Graveyard), CardPredicates.NON_CREATURES)); if (worstCreat == null) { - worstCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES)); + worstCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.CREATURES)); } if (worstNonCreat == null) { - worstNonCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.NON_CREATURES)); + worstNonCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.NON_CREATURES)); } sa.resetTargets(); @@ -359,7 +359,7 @@ public static class DesecrationDemon { public static boolean considerSacrificingCreature(final Player ai, final SpellAbility sa) { CardCollection flyingCreatures = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), - CardPredicates.Presets.UNTAPPED.and( + CardPredicates.UNTAPPED.and( CardPredicates.hasKeyword(Keyword.FLYING).or(CardPredicates.hasKeyword(Keyword.REACH)))); boolean hasUsefulBlocker = false; @@ -402,7 +402,7 @@ public static boolean considerTargetingOpponent(final Player ai, final SpellAbil // select player with less lands on the field (helpful for Illusions of Grandeur and probably Pacts too) Player opp = Collections.min(Lists.newArrayList(oppTarget), - PlayerPredicates.compareByZoneSize(ZoneType.Battlefield, CardPredicates.Presets.LANDS)); + PlayerPredicates.compareByZoneSize(ZoneType.Battlefield, CardPredicates.LANDS)); if (opp != null) { sa.resetTargets(); @@ -581,9 +581,9 @@ public static boolean consider(final Player ai, final SpellAbility sa) { Card bestBasic = null; Card bestBasicSelfOnly = null; - CardCollection aiLands = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.LANDS_PRODUCING_MANA); + CardCollection aiLands = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.LANDS_PRODUCING_MANA); CardCollection oppLands = CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Battlefield), - CardPredicates.Presets.LANDS_PRODUCING_MANA); + CardPredicates.LANDS_PRODUCING_MANA); int bestCount = 0; int bestSelfOnlyCount = 0; @@ -629,7 +629,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { } CardCollection oppList = CardLists.filter(ai.getGame().getCardsIn(ZoneType.Battlefield), - CardPredicates.Presets.CREATURES, CardPredicates.isControlledByAnyOf(ai.getOpponents())); + CardPredicates.CREATURES, CardPredicates.isControlledByAnyOf(ai.getOpponents())); oppList = CardLists.filterPower(oppList, lowest.getNetPower() + 1); if (ComputerUtilCard.evaluateCreatureList(oppList) > 200) { @@ -685,7 +685,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { // Goblin Polka Band public static class GoblinPolkaBand { public static boolean consider(final Player ai, final SpellAbility sa) { - int maxPotentialTgts = Lists.newArrayList(Iterables.filter(ai.getOpponents().getCreaturesInPlay(), CardPredicates.Presets.UNTAPPED)).size(); + int maxPotentialTgts = Lists.newArrayList(Iterables.filter(ai.getOpponents().getCreaturesInPlay(), CardPredicates.UNTAPPED)).size(); int maxPotentialPayment = ComputerUtilMana.determineLeftoverMana(sa, ai, "R", false); int numTgts = Math.min(maxPotentialPayment, maxPotentialTgts); @@ -921,7 +921,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { int aiBattlefieldPower = 0, aiGraveyardPower = 0; int threshold = 320; // approximately a 4/4 Flying creature worth of extra value - CardCollection aiCreaturesInGY = CardLists.filter(ai.getZone(ZoneType.Graveyard).getCards(), CardPredicates.Presets.CREATURES); + CardCollection aiCreaturesInGY = CardLists.filter(ai.getZone(ZoneType.Graveyard).getCards(), CardPredicates.CREATURES); if (aiCreaturesInGY.isEmpty()) { // nothing in graveyard, so cut short @@ -945,7 +945,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { for (Card c : p.getCreaturesInPlay()) { playerPower += ComputerUtilCard.evaluateCreature(c); } - for (Card c : CardLists.filter(p.getZone(ZoneType.Graveyard).getCards(), CardPredicates.Presets.CREATURES)) { + for (Card c : CardLists.filter(p.getZone(ZoneType.Graveyard).getCards(), CardPredicates.CREATURES)) { tempGraveyardPower += ComputerUtilCard.evaluateCreature(c); } if (playerPower > oppBattlefieldPower) { @@ -997,7 +997,7 @@ public static class MairsilThePretender { // Scan the fetch list for a card with at least one activated ability. // TODO: can be improved to a full consider(sa, ai) logic which would scan the graveyard first and hand last public static Card considerCardFromList(final CardCollection fetchList) { - for (Card c : CardLists.filter(fetchList, CardPredicates.Presets.ARTIFACTS.or(CardPredicates.Presets.CREATURES))) { + for (Card c : CardLists.filter(fetchList, CardPredicates.ARTIFACTS.or(CardPredicates.CREATURES))) { for (SpellAbility ab : c.getSpellAbilities()) { if (ab.isActivatedAbility()) { Player controller = c.getController(); @@ -1058,7 +1058,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { // In MoJhoSto, prefer Jhoira sorcery ability from time to time if (source.getGame().getRules().hasAppliedVariant(GameType.MoJhoSto) - && CardLists.filter(ai.getLandsInPlay(), CardPredicates.Presets.UNTAPPED).size() >= 3) { + && CardLists.filter(ai.getLandsInPlay(), CardPredicates.UNTAPPED).size() >= 3) { AiController aic = ((PlayerControllerAi)ai.getController()).getAi(); int chanceToPrefJhoira = aic.getIntProperty(AiProps.MOJHOSTO_CHANCE_TO_PREFER_JHOIRA_OVER_MOMIR); int numLandsForJhoira = aic.getIntProperty(AiProps.MOJHOSTO_NUM_LANDS_TO_ACTIVATE_JHOIRA); @@ -1219,7 +1219,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { final CardCollectionView cards = ai.getCardsIn(Arrays.asList(ZoneType.Hand, ZoneType.Battlefield, ZoneType.Command)); List all = ComputerUtilAbility.getSpellAbilities(cards, ai); - int numManaSrcs = CardLists.filter(ComputerUtilMana.getAvailableManaSources(ai, true), CardPredicates.Presets.UNTAPPED).size(); + int numManaSrcs = CardLists.filter(ComputerUtilMana.getAvailableManaSources(ai, true), CardPredicates.UNTAPPED).size(); for (final SpellAbility testSa : ComputerUtilAbility.getOriginalAndAltCostAbilities(all, ai)) { ManaCost cost = testSa.getPayCosts().getTotalMana(); @@ -1316,7 +1316,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { return false; } - int aiLands = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.NONBASIC_LANDS).size(); + int aiLands = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.NONBASIC_LANDS).size(); boolean hasBridge = false; for (Card c : ai.getCardsIn(ZoneType.Battlefield)) { @@ -1334,7 +1334,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { } for (Player opp : ai.getOpponents()) { - int oppLands = CardLists.filter(opp.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.NONBASIC_LANDS).size(); + int oppLands = CardLists.filter(opp.getCardsIn(ZoneType.Battlefield), CardPredicates.NONBASIC_LANDS).size(); // Always if enemy would die and we don't! // TODO : predict actual damage instead of assuming it'll be 2*lands // Don't if we lose, unless we lose anyway to unblocked creatures next turn @@ -1402,7 +1402,7 @@ public static class SaviorOfOllenbock { public static boolean consider(final Player ai, final SpellAbility sa) { CardCollection oppTargetables = CardLists.getTargetableCards(ai.getOpponents().getCreaturesInPlay(), sa); CardCollection threats = CardLists.filter(oppTargetables, card -> !ComputerUtilCard.isUselessCreature(card.getController(), card)); - CardCollection ownTgts = CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES); + CardCollection ownTgts = CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.CREATURES); // TODO: improve the conditions for when the AI is considered threatened (check the possibility of being attacked?) int lifeInDanger = (((PlayerControllerAi) ai.getController()).getAi().getIntProperty(AiProps.AI_IN_DANGER_THRESHOLD)); @@ -1442,7 +1442,7 @@ public static class SorinVengefulBloodlord { public static boolean consider(final Player ai, final SpellAbility sa) { int loyalty = sa.getHostCard().getCounters(CounterEnumType.LOYALTY); CardCollection creaturesToGet = CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), - CardPredicates.Presets.CREATURES + CardPredicates.CREATURES .and(CardPredicates.lessCMC(loyalty - 1)) .and(card -> { final Card copy = CardCopyService.getLKICopy(card); @@ -1484,9 +1484,9 @@ public static Card considerDiscardTarget(final Player ai) { // face down (on the battlefield or in exile). Might need some kind of an update to consider hidden information // like that properly (probably by adding all those cards to the evaluation mix so the AI doesn't "know" which // ones are already face down in play and which are still in the library) - CardCollectionView creatsInLib = CardLists.filter(ai.getCardsIn(ZoneType.Library), CardPredicates.Presets.CREATURES); - CardCollectionView creatsInHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.CREATURES); - CardCollectionView manaSrcsInHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.LANDS_PRODUCING_MANA); + CardCollectionView creatsInLib = CardLists.filter(ai.getCardsIn(ZoneType.Library), CardPredicates.CREATURES); + CardCollectionView creatsInHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.CREATURES); + CardCollectionView manaSrcsInHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.LANDS_PRODUCING_MANA); if (creatsInHand.isEmpty() || creatsInLib.isEmpty()) { return null; } @@ -1555,10 +1555,10 @@ public static Card considerDiscardTarget(final Player ai) { } public static Card considerCardToGet(final Player ai, final SpellAbility sa) { - CardCollectionView creatsInLib = CardLists.filter(ai.getCardsIn(ZoneType.Library), CardPredicates.Presets.CREATURES); + CardCollectionView creatsInLib = CardLists.filter(ai.getCardsIn(ZoneType.Library), CardPredicates.CREATURES); if (creatsInLib.isEmpty()) { return null; } - CardCollectionView manaSrcsInHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.LANDS_PRODUCING_MANA); + CardCollectionView manaSrcsInHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.LANDS_PRODUCING_MANA); int numManaSrcs = ComputerUtilMana.getAvailableManaEstimate(ai, false) + Math.min(1, manaSrcsInHand.size()); @@ -1602,8 +1602,8 @@ public static boolean consider(final Player ai, final SpellAbility sa) { // The Scarab God public static class TheScarabGod { public static boolean consider(final Player ai, final SpellAbility sa) { - Card bestOppCreat = ComputerUtilCard.getBestAI(CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES)); - Card worstOwnCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES)); + Card bestOppCreat = ComputerUtilCard.getBestAI(CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Graveyard), CardPredicates.CREATURES)); + Card worstOwnCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.CREATURES)); sa.resetTargets(); if (bestOppCreat != null) { @@ -1704,7 +1704,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { CardCollectionView aiGY = ai.getCardsIn(ZoneType.Graveyard); Card topGY = null; Card creatHand = ComputerUtilCard.getBestCreatureAI(ai.getCardsIn(ZoneType.Hand)); - int numCreatsInHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.CREATURES).size(); + int numCreatsInHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.CREATURES).size(); if (!aiGY.isEmpty()) { topGY = ai.getCardsIn(ZoneType.Graveyard).get(0); diff --git a/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java b/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java index 88e4ed97dd4..e9503149190 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java @@ -130,7 +130,7 @@ protected boolean checkPhaseRestrictions(final Player ai, final SpellAbility sa, && game.getPhaseHandler().getNextTurn() != ai && source.isPermanent(); if (ph.isPlayerTurn(ai) && ai.getLife() < 6 && opponent.getLife() > 6 - && opponent.getZone(ZoneType.Battlefield).contains(CardPredicates.Presets.CREATURES) + && opponent.getZone(ZoneType.Battlefield).contains(CardPredicates.CREATURES) && !sa.hasParam("AILogic") && !"Permanent".equals(sa.getParam("Duration")) && !activateAsPotentialBlocker) { return false; } diff --git a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java index 7a353b2c05c..1a64a02490a 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java @@ -509,7 +509,7 @@ private static Card attachAIAnimatePreference(final SpellAbility sa, final List< if (!evenBetterList.isEmpty()) { betterList = evenBetterList; } - evenBetterList = CardLists.filter(betterList, CardPredicates.Presets.UNTAPPED); + evenBetterList = CardLists.filter(betterList, CardPredicates.UNTAPPED); if (!evenBetterList.isEmpty()) { betterList = evenBetterList; } diff --git a/forge-ai/src/main/java/forge/ai/ability/BalanceAi.java b/forge-ai/src/main/java/forge/ai/ability/BalanceAi.java index 902741c6da3..9bd5d028cf0 100644 --- a/forge-ai/src/main/java/forge/ai/ability/BalanceAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/BalanceAi.java @@ -25,10 +25,10 @@ protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { if ("BalanceCreaturesAndLands".equals(logic)) { // TODO Copied over from hardcoded Balance. We should be checking value of the lands/creatures for each opponent, not just counting - diff += CardLists.filter(humPerms, CardPredicates.Presets.LANDS).size() - - CardLists.filter(compPerms, CardPredicates.Presets.LANDS).size(); - diff += 1.5 * (CardLists.filter(humPerms, CardPredicates.Presets.CREATURES).size() - - CardLists.filter(compPerms, CardPredicates.Presets.CREATURES).size()); + diff += CardLists.filter(humPerms, CardPredicates.LANDS).size() - + CardLists.filter(compPerms, CardPredicates.LANDS).size(); + diff += 1.5 * (CardLists.filter(humPerms, CardPredicates.CREATURES).size() - + CardLists.filter(compPerms, CardPredicates.CREATURES).size()); } else if ("BalancePermanents".equals(logic)) { // Don't cast if you have to sacrifice permanents diff --git a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java index 63403bd4e6c..3384e0dc4f5 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java @@ -12,7 +12,6 @@ import forge.game.ability.AbilityUtils; import forge.game.ability.ApiType; import forge.game.card.*; -import forge.game.card.CardPredicates.Presets; import forge.game.combat.Combat; import forge.game.cost.*; import forge.game.keyword.Keyword; @@ -32,7 +31,6 @@ import org.apache.commons.lang3.StringUtils; import java.util.*; -import java.util.function.Predicate; public class ChangeZoneAi extends SpellAbilityAi { /* @@ -614,8 +612,8 @@ private static Card basicManaFixing(final Player ai, final List list) { // } // pick dual lands if available - if (Iterables.any(result, Presets.NONBASIC_LANDS)) { - result = CardLists.filter(result, Presets.NONBASIC_LANDS); + if (Iterables.any(result, CardPredicates.NONBASIC_LANDS)) { + result = CardLists.filter(result, CardPredicates.NONBASIC_LANDS); } return result.get(0); @@ -1013,7 +1011,7 @@ private static boolean isPreferredTarget(final Player ai, final SpellAbility sa, boolean saheeliFelidarCombo = ComputerUtilAbility.getAbilitySourceName(sa).equals("Felidar Guardian") && tobounce.getName().equals("Saheeli Rai") && CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Felidar Guardian")).size() < - CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Battlefield), Presets.CREATURES).size() + ai.getOpponentsGreatestLifeTotal() + 10; + CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Battlefield), CardPredicates.CREATURES).size() + ai.getOpponentsGreatestLifeTotal() + 10; // remember that the card was bounced already unless it's a special combo case if (!saheeliFelidarCombo) { @@ -1197,7 +1195,7 @@ private static boolean isPreferredTarget(final Player ai, final SpellAbility sa, } else if (destination.equals(ZoneType.Hand) || destination.equals(ZoneType.Library)) { List nonLands = CardLists.getNotType(list, "Land"); // Prefer to pull a creature, generally more useful for AI. - choice = chooseCreature(ai, CardLists.filter(nonLands, CardPredicates.Presets.CREATURES)); + choice = chooseCreature(ai, CardLists.filter(nonLands, CardPredicates.CREATURES)); if (choice == null) { // Could not find a creature. if (ai.getLife() <= 5) { // Desperate? // Get something AI can cast soon. @@ -1309,7 +1307,7 @@ private static Card canBouncePermanent(final Player ai, SpellAbility sa, CardCol Game game = ai.getGame(); // filter out untargetables CardCollectionView aiPermanents = CardLists.filterControlledBy(list, ai); - CardCollection aiPlaneswalkers = CardLists.filter(aiPermanents, Presets.PLANESWALKERS); + CardCollection aiPlaneswalkers = CardLists.filter(aiPermanents, CardPredicates.PLANESWALKERS); // Felidar Guardian + Saheeli Rai combo support if (sa.getHostCard().getName().equals("Felidar Guardian")) { @@ -1335,7 +1333,7 @@ private static Card canBouncePermanent(final Player ai, SpellAbility sa, CardCol else if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)) { Combat combat = game.getCombat(); final CardCollection combatants = CardLists.filter(aiPermanents, - CardPredicates.Presets.CREATURES); + CardPredicates.CREATURES); ComputerUtilCard.sortByEvaluateCreature(combatants); for (final Card c : combatants) { @@ -1455,7 +1453,7 @@ private static boolean isUnpreferredTarget(final Player ai, final SpellAbility s } else if (destination.equals(ZoneType.Hand) || destination.equals(ZoneType.Library)) { List nonLands = CardLists.getNotType(list, "Land"); // Prefer to pull a creature, generally more useful for AI. - choice = chooseCreature(ai, CardLists.filter(nonLands, CardPredicates.Presets.CREATURES)); + choice = chooseCreature(ai, CardLists.filter(nonLands, CardPredicates.CREATURES)); if (choice == null) { // Could not find a creature. if (ai.getLife() <= 5) { // Desperate? // Get something AI can cast soon. @@ -1636,7 +1634,7 @@ public static Card chooseCardToHiddenOriginChangeZone(ZoneType destination, List // Does AI need a land? CardCollectionView hand = decider.getCardsIn(ZoneType.Hand); - if (!Iterables.any(hand, Presets.LANDS) && CardLists.count(decider.getCardsIn(ZoneType.Battlefield), Presets.LANDS) < 4) { + if (!Iterables.any(hand, CardPredicates.LANDS) && CardLists.count(decider.getCardsIn(ZoneType.Battlefield), CardPredicates.LANDS) < 4) { boolean canCastSomething = false; for (Card cardInHand : hand) { canCastSomething = canCastSomething || ComputerUtilMana.hasEnoughManaSourcesToCast(cardInHand.getFirstSpellAbility(), decider); @@ -1646,13 +1644,13 @@ public static Card chooseCardToHiddenOriginChangeZone(ZoneType destination, List } } if (c == null) { - if (Iterables.all(fetchList, Presets.LANDS)) { + if (Iterables.all(fetchList, CardPredicates.LANDS)) { // we're only choosing from lands, so get the best land c = ComputerUtilCard.getBestLandAI(fetchList); } else { fetchList = CardLists.getNotType(fetchList, "Land"); // Prefer to pull a creature, generally more useful for AI. - c = chooseCreature(decider, CardLists.filter(fetchList, CardPredicates.Presets.CREATURES)); + c = chooseCreature(decider, CardLists.filter(fetchList, CardPredicates.CREATURES)); } } if (c == null) { // Could not find a creature. @@ -1770,7 +1768,7 @@ private boolean doSacAndReturnFromGraveLogic(final Player ai, final SpellAbility CardCollection listToSac = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), definedSac, ai, source, sa); listToSac.sort(Collections.reverseOrder(CardLists.CmcComparatorInv)); - CardCollection listToRet = CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), Presets.CREATURES); + CardCollection listToRet = CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.CREATURES); listToRet.sort(CardLists.CmcComparatorInv); if (!listToSac.isEmpty() && !listToRet.isEmpty()) { @@ -1961,7 +1959,7 @@ public static Card doExilePreferenceLogic(final Player aiPlayer, final SpellAbil } if (logic.contains("NonLand")) { - scanList = CardLists.filter(scanList, Presets.NON_LANDS); + scanList = CardLists.filter(scanList, CardPredicates.NON_LANDS); } if (logic.contains("NonExiled")) { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java index dc2aa48d65a..a01557c3cd6 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java @@ -92,7 +92,7 @@ protected boolean canPlayAI(Player ai, SpellAbility sa) { } else if ("ExileGraveyards".equals(aiLogic)) { for (Player opp : ai.getOpponents()) { CardCollectionView cardsGY = opp.getCardsIn(ZoneType.Graveyard); - CardCollection creats = CardLists.filter(cardsGY, CardPredicates.Presets.CREATURES); + CardCollection creats = CardLists.filter(cardsGY, CardPredicates.CREATURES); if (opp.hasDelirium() || opp.hasThreshold() || creats.size() >= 5) { return true; @@ -107,7 +107,7 @@ protected boolean canPlayAI(Player ai, SpellAbility sa) { Player bestTgt = null; if (player.canBeTargetedBy(sa)) { int numGY = CardLists.count(player.getCardsIn(ZoneType.Graveyard), - CardPredicates.Presets.CREATURES); + CardPredicates.CREATURES); if (numGY > maxSize) { maxSize = numGY; bestTgt = player; @@ -353,7 +353,7 @@ protected boolean doTriggerAINoCost(Player ai, final SpellAbility sa, boolean ma // TODO: this is a stub to prevent the AI from crashing the game when, for instance, playing the opponent's // Profaner from exile without paying its mana cost. Otherwise the card is marked AI:RemoveDeck:All and // there is no specific AI to support playing it in a smarter way. Feel free to expand. - return Iterables.any(ai.getOpponents().getCardsIn(origin), CardPredicates.Presets.CREATURES); + return Iterables.any(ai.getOpponents().getCardsIn(origin), CardPredicates.CREATURES); } CardCollectionView humanType = ai.getOpponents().getCardsIn(origin); diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java index b5a77496d57..3efdce0e464 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java @@ -15,7 +15,6 @@ import forge.game.card.CardCollectionView; import forge.game.card.CardLists; import forge.game.card.CardPredicates; -import forge.game.card.CardPredicates.Presets; import forge.game.card.CounterEnumType; import forge.game.combat.Combat; import forge.game.keyword.Keyword; @@ -178,8 +177,8 @@ public Card chooseSingleCard(final Player ai, final SpellAbility sa, Iterable 0 && ph.is(PhaseType.MAIN2, ai); } diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseDirectionAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseDirectionAi.java index 17a74f21fe0..92a5d969980 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseDirectionAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseDirectionAi.java @@ -6,7 +6,7 @@ import forge.game.card.Card; import forge.game.card.CardCollection; import forge.game.card.CardLists; -import forge.game.card.CardPredicates.Presets; +import forge.game.card.CardPredicates; import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; @@ -25,7 +25,7 @@ protected boolean canPlayAI(Player ai, SpellAbility sa) { return false; } else { if ("Aminatou".equals(logic)) { - CardCollection all = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Presets.NONLAND_PERMANENTS); + CardCollection all = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.NONLAND_PERMANENTS); CardCollection aiPermanent = CardLists.filterControlledBy(all, ai); aiPermanent.remove(sa.getHostCard()); int aiValue = Aggregates.sum(aiPermanent, Card::getCMC); diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java index 25afc948935..43bbf5dc13b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java @@ -134,10 +134,10 @@ public Card chooseSingleCard(final Player aiChoser, SpellAbility sa, Iterable oppCreatures = CardLists.filter(options, - CardPredicates.Presets.CREATURES.and(CardPredicates.isOwner(aiChoser).negate())); + CardPredicates.CREATURES.and(CardPredicates.isOwner(aiChoser).negate())); List aiNonCreatures = CardLists.filter(options, - CardPredicates.Presets.NON_CREATURES - .and(CardPredicates.Presets.PERMANENTS) + CardPredicates.NON_CREATURES + .and(CardPredicates.PERMANENTS) .and(CardPredicates.isOwner(aiChoser)) ); diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java index 02b5163050b..b85501fe732 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java @@ -65,7 +65,7 @@ private boolean doMirrorEntityLogic(Player aiPlayer, SpellAbility sa) { int avgPower = 0; // predict the opposition - CardCollection oppCreatures = CardLists.filter(aiPlayer.getOpponents().getCreaturesInPlay(), CardPredicates.Presets.UNTAPPED); + CardCollection oppCreatures = CardLists.filter(aiPlayer.getOpponents().getCreaturesInPlay(), CardPredicates.UNTAPPED); int maxOppPower = 0; int maxOppToughness = 0; int oppUsefulCreatures = 0; @@ -85,7 +85,7 @@ private boolean doMirrorEntityLogic(Player aiPlayer, SpellAbility sa) { if (maxX > 1) { CardCollection cre = CardLists.filter(aiPlayer.getCardsIn(ZoneType.Battlefield), - CardPredicates.isType(chosenType), CardPredicates.Presets.UNTAPPED); + CardPredicates.isType(chosenType), CardPredicates.UNTAPPED); if (!cre.isEmpty()) { for (Card c: cre) { avgPower += c.getNetPower(); diff --git a/forge-ai/src/main/java/forge/ai/ability/ClashAi.java b/forge-ai/src/main/java/forge/ai/ability/ClashAi.java index 3c533a65a9f..4e4f4c5f77c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ClashAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ClashAi.java @@ -92,7 +92,7 @@ private boolean selectTarget(Player ai, SpellAbility sa) { // Springjack Knight // TODO: Whirlpool Whelm also uses creature targeting but it's trickier to support CardCollectionView aiCreats = ai.getCreaturesInPlay(); - CardCollectionView oppCreats = CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); + CardCollectionView oppCreats = CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Battlefield), CardPredicates.CREATURES); Card tgt = aiCreats.isEmpty() ? ComputerUtilCard.getWorstCreatureAI(oppCreats) : ComputerUtilCard.getBestCreatureAI(aiCreats); diff --git a/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java b/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java index a4ea818d1bd..fe801af02c5 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java @@ -22,7 +22,6 @@ import forge.game.card.CardCollectionView; import forge.game.card.CardLists; import forge.game.card.CardPredicates; -import forge.game.card.CardPredicates.Presets; import forge.game.card.CardUtil; import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; @@ -177,7 +176,7 @@ protected boolean doTriggerAINoCost(final Player aiPlayer, SpellAbility sa, bool list = CardLists.filter(list, c -> (!c.getType().isLegendary() || canCopyLegendary) || !c.getController().equals(aiPlayer)); Card choice; - if (Iterables.any(list, Presets.CREATURES)) { + if (Iterables.any(list, CardPredicates.CREATURES)) { if (sa.hasParam("TargetingPlayer")) { choice = ComputerUtilCard.getWorstCreatureAI(list); } else { diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java index 95e41b8bb52..467af4ae521 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java @@ -380,7 +380,7 @@ protected boolean checkApiLogic(Player ai, final SpellAbility sa) { sa.setXManaCostPaid(amount); } else if ("ExiledCreatureFromGraveCMC".equals(logic)) { // e.g. Necropolis - amount = Aggregates.max(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES), Card::getCMC); + amount = Aggregates.max(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.CREATURES), Card::getCMC); if (amount > 0 && ai.getGame().getPhaseHandler().is(PhaseType.END_OF_TURN)) { return true; } @@ -703,7 +703,7 @@ public boolean chkAIDrawback(final SpellAbility sa, Player ai) { if (sa.isCurse()) { choice = chooseCursedTarget(list, type, amount, ai); } else { - CardCollection lands = CardLists.filter(list, CardPredicates.Presets.LANDS); + CardCollection lands = CardLists.filter(list, CardPredicates.LANDS); SpellAbility animate = sa.findSubAbilityByType(ApiType.Animate); if (!lands.isEmpty() && animate != null) { choice = ComputerUtilCard.getWorstLand(lands); @@ -796,7 +796,7 @@ protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandator } // try to choose player with less creatures - Player choice = playerList.min(PlayerPredicates.compareByZoneSize(ZoneType.Battlefield, CardPredicates.Presets.CREATURES)); + Player choice = playerList.min(PlayerPredicates.compareByZoneSize(ZoneType.Battlefield, CardPredicates.CREATURES)); if (choice != null) { sa.getTargets().add(choice); @@ -1193,7 +1193,7 @@ public int chooseNumber(Player player, SpellAbility sa, int min, int max, Map hPlay = CardLists.filter(getTargetableCards(ai, sa, pl, tgt, activator, source, game), CardPredicates.Presets.PLANESWALKERS); + List hPlay = CardLists.filter(getTargetableCards(ai, sa, pl, tgt, activator, source, game), CardPredicates.PLANESWALKERS); CardCollection killables = CardLists.filter(hPlay, c -> c.getSVar("Targeting").equals("Dies") || (ComputerUtilCombat.getEnoughDamageToKill(c, d, source, false, noPrevention) <= d) @@ -892,8 +891,8 @@ private boolean damageChooseRequiredTargets(final Player ai, final SpellAbility // See if there's an indestructible target that can be used CardCollection indestructible = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), - CardPredicates.Presets.CREATURES - .and(CardPredicates.Presets.PLANESWALKERS) //TODO: Should this be "or" Planeswalkers? + CardPredicates.CREATURES + .and(CardPredicates.PLANESWALKERS) //TODO: Should this be "or" Planeswalkers? .and(CardPredicates.hasKeyword(Keyword.INDESTRUCTIBLE)) .and(CardPredicates.isTargetableBy(sa)) ); @@ -909,7 +908,7 @@ private boolean damageChooseRequiredTargets(final Player ai, final SpellAbility } else if (tgt.canTgtPlaneswalker()) { // Second pass for planeswalkers: choose AI's worst planeswalker - final Card c = ComputerUtilCard.getWorstPlaneswalkerToDamage(CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANESWALKERS, CardPredicates.isTargetableBy(sa))); + final Card c = ComputerUtilCard.getWorstPlaneswalkerToDamage(CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.PLANESWALKERS, CardPredicates.isTargetableBy(sa))); if (c != null) { sa.getTargets().add(c); if (divided) { diff --git a/forge-ai/src/main/java/forge/ai/ability/DamagePreventAi.java b/forge-ai/src/main/java/forge/ai/ability/DamagePreventAi.java index 7e95fdd2be3..89482adde62 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamagePreventAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamagePreventAi.java @@ -126,7 +126,7 @@ else if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)) { if (targetables.isEmpty()) { return false; } - final CardCollection combatants = CardLists.filter(targetables, CardPredicates.Presets.CREATURES); + final CardCollection combatants = CardLists.filter(targetables, CardPredicates.CREATURES); ComputerUtilCard.sortByEvaluateCreature(combatants); for (final Card c : combatants) { @@ -187,7 +187,7 @@ private boolean preventDamageMandatoryTarget(final Player ai, final SpellAbility } if (!compTargetables.isEmpty()) { - final CardCollection combatants = CardLists.filter(compTargetables, CardPredicates.Presets.CREATURES); + final CardCollection combatants = CardLists.filter(compTargetables, CardPredicates.CREATURES); ComputerUtilCard.sortByEvaluateCreature(combatants); if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)) { Combat combat = game.getCombat(); diff --git a/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java b/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java index c94523c1643..2fed685edb0 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DestroyAi.java @@ -425,8 +425,8 @@ public boolean doLandForLandRemovalLogic(SpellAbility sa, Player ai, Card tgtLan boolean nonBasicTgt = !tgtLand.isBasicLand(); // Try not to lose tempo too much and not to mana-screw yourself when considering this logic - int numLandsInHand = CardLists.count(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.LANDS_PRODUCING_MANA); - int numLandsOTB = CardLists.count(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.LANDS_PRODUCING_MANA); + int numLandsInHand = CardLists.count(ai.getCardsIn(ZoneType.Hand), CardPredicates.LANDS_PRODUCING_MANA); + int numLandsOTB = CardLists.count(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.LANDS_PRODUCING_MANA); // If the opponent skipped a land drop, consider not looking at having the extra land in hand if the profile allows it boolean isHighPriority = highPriorityIfNoLandDrop && oppSkippedLandDrop; diff --git a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java index 24d0d00ee01..96d2479cf26 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java @@ -109,8 +109,8 @@ public static boolean doMassRemovalLogic(Player ai, SpellAbility sa) { // Special handling for Raiding Party if (logic.equals("RaidingParty")) { - int numAiCanSave = Math.min(CardLists.count(ai.getCreaturesInPlay(), CardPredicates.isColor(MagicColor.WHITE).and(CardPredicates.Presets.UNTAPPED)) * 2, ailist.size()); - int numOppsCanSave = Math.min(CardLists.count(ai.getOpponents().getCreaturesInPlay(), CardPredicates.isColor(MagicColor.WHITE).and(CardPredicates.Presets.UNTAPPED)) * 2, opplist.size()); + int numAiCanSave = Math.min(CardLists.count(ai.getCreaturesInPlay(), CardPredicates.isColor(MagicColor.WHITE).and(CardPredicates.UNTAPPED)) * 2, ailist.size()); + int numOppsCanSave = Math.min(CardLists.count(ai.getOpponents().getCreaturesInPlay(), CardPredicates.isColor(MagicColor.WHITE).and(CardPredicates.UNTAPPED)) * 2, opplist.size()); return numOppsCanSave < opplist.size() && (ailist.size() - numAiCanSave < opplist.size() - numOppsCanSave); } diff --git a/forge-ai/src/main/java/forge/ai/ability/DigUntilAi.java b/forge-ai/src/main/java/forge/ai/ability/DigUntilAi.java index 2c4dabd9ee2..699ae42e7ee 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DigUntilAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DigUntilAi.java @@ -45,7 +45,7 @@ protected boolean canPlayAI(Player ai, SpellAbility sa) { return false; } if ("Land.Basic".equals(sa.getParam("Valid")) - && ai.getZone(ZoneType.Hand).contains(CardPredicates.Presets.LANDS_PRODUCING_MANA)) { + && ai.getZone(ZoneType.Hand).contains(CardPredicates.LANDS_PRODUCING_MANA)) { // We already have a mana-producing land in hand, so bail // until opponent's end of turn phase! // But we still want more (and want to fill grave) if nothing better to do then @@ -128,7 +128,7 @@ public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirm final String logic = sa.getParam("AILogic"); if ("OathOfDruids".equals(logic)) { final List creaturesInLibrary = - CardLists.filter(player.getCardsIn(ZoneType.Library), CardPredicates.Presets.CREATURES); + CardLists.filter(player.getCardsIn(ZoneType.Library), CardPredicates.CREATURES); final List creaturesInBattlefield = player.getCreaturesInPlay(); // if there are at least 3 creatures in library, // or none in play with one in library, oath diff --git a/forge-ai/src/main/java/forge/ai/ability/DiscardAi.java b/forge-ai/src/main/java/forge/ai/ability/DiscardAi.java index b8ac075c536..a09a9e91ceb 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DiscardAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DiscardAi.java @@ -94,7 +94,7 @@ protected boolean canPlayAI(Player ai, SpellAbility sa) { if (sa.hasParam("AnyNumber")) { if ("DiscardUncastableAndExcess".equals(aiLogic)) { final CardCollectionView inHand = ai.getCardsIn(ZoneType.Hand); - final int numLandsOTB = CardLists.count(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.LANDS); + final int numLandsOTB = CardLists.count(ai.getCardsIn(ZoneType.Hand), CardPredicates.LANDS); int numDiscard = 0; int numOppInHand = 0; for (Player p : ai.getGame().getPlayers()) { diff --git a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java index 75b4b914d8e..35f9e0e27c4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java @@ -8,7 +8,6 @@ import forge.game.ability.AbilityUtils; import forge.game.ability.ApiType; import forge.game.card.*; -import forge.game.card.CardPredicates.Presets; import forge.game.combat.Combat; import forge.game.combat.CombatUtil; import forge.game.keyword.Keyword; @@ -56,8 +55,8 @@ protected boolean canPlayAI(final Player ai,final SpellAbility sa) { for (Player opp : ai.getOpponents()) { boolean worthHolding = false; CardCollectionView oppCreatsLands = CardLists.filter(opp.getCardsIn(ZoneType.Battlefield), - Presets.LANDS.or(Presets.CREATURES)); - CardCollectionView oppCreatsLandsTapped = CardLists.filter(oppCreatsLands, CardPredicates.Presets.TAPPED); + CardPredicates.LANDS.or(CardPredicates.CREATURES)); + CardCollectionView oppCreatsLandsTapped = CardLists.filter(oppCreatsLands, CardPredicates.TAPPED); if (oppCreatsLandsTapped.size() >= 3 || oppCreatsLands.size() == oppCreatsLandsTapped.size()) { worthHolding = true; @@ -83,7 +82,7 @@ protected boolean canPlayAI(final Player ai,final SpellAbility sa) { Player opp = ai.getStrongestOpponent(); List possibleAttackers = ai.getCreaturesInPlay(); List possibleBlockers = opp.getCreaturesInPlay(); - possibleBlockers = CardLists.filter(possibleBlockers, Presets.UNTAPPED); + possibleBlockers = CardLists.filter(possibleBlockers, CardPredicates.UNTAPPED); final Combat combat = game.getCombat(); int oppLife = opp.getLife(); int potentialDmg = 0; @@ -332,7 +331,7 @@ protected boolean canPlayAI(final Player ai,final SpellAbility sa) { } else if (logic.equals("CantRegenerate")) { if (sa.usesTargeting()) { CardCollection list = CardLists.getTargetableCards(ai.getOpponents().getCardsIn(ZoneType.Battlefield), sa); - list = CardLists.filter(list, CardPredicates.Presets.CAN_BE_DESTROYED, input -> { + list = CardLists.filter(list, CardPredicates.CAN_BE_DESTROYED, input -> { Map runParams = AbilityKey.mapFromAffected(input); runParams.put(AbilityKey.Regeneration, true); List repDestoryList = game.getReplacementHandler().getReplacementList(ReplacementType.Destroy, runParams, ReplacementLayer.Other); diff --git a/forge-ai/src/main/java/forge/ai/ability/ExploreAi.java b/forge-ai/src/main/java/forge/ai/ability/ExploreAi.java index 9c28cd0b5c5..619918d763f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ExploreAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ExploreAi.java @@ -43,8 +43,8 @@ public static boolean shouldPutInGraveyard(Card topCard, Player ai) { int predictedMana = ComputerUtilMana.getAvailableManaSources(ai, false).size(); CardCollectionView cardsOTB = ai.getCardsIn(ZoneType.Battlefield); CardCollectionView cardsInHand = ai.getCardsIn(ZoneType.Hand); - CardCollection landsOTB = CardLists.filter(cardsOTB, CardPredicates.Presets.LANDS_PRODUCING_MANA); - CardCollection landsInHand = CardLists.filter(cardsInHand, CardPredicates.Presets.LANDS_PRODUCING_MANA); + CardCollection landsOTB = CardLists.filter(cardsOTB, CardPredicates.LANDS_PRODUCING_MANA); + CardCollection landsInHand = CardLists.filter(cardsInHand, CardPredicates.LANDS_PRODUCING_MANA); int maxCMCDiff = 1; int numLandsToStillNeedMore = 2; diff --git a/forge-ai/src/main/java/forge/ai/ability/HauntAi.java b/forge-ai/src/main/java/forge/ai/ability/HauntAi.java index 76d8c2005ea..26bb8d2ba81 100644 --- a/forge-ai/src/main/java/forge/ai/ability/HauntAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/HauntAi.java @@ -20,7 +20,7 @@ protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandator final Game game = ai.getGame(); if (sa.usesTargeting() && !card.isToken()) { final List creats = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), - CardPredicates.Presets.CREATURES); + CardPredicates.CREATURES); // nothing to haunt if (creats.isEmpty()) { diff --git a/forge-ai/src/main/java/forge/ai/ability/MillAi.java b/forge-ai/src/main/java/forge/ai/ability/MillAi.java index 4e28ba8764b..073df55136a 100644 --- a/forge-ai/src/main/java/forge/ai/ability/MillAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/MillAi.java @@ -37,7 +37,7 @@ protected boolean checkAiLogic(final Player ai, final SpellAbility sa, final Str return ph.is(PhaseType.END_OF_TURN) && ph.getNextTurn().equals(ai); } else if (aiLogic.equals("LilianaMill")) { // Only mill if a "Raise Dead" target is available, in case of control decks with few creatures - return CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES).size() >= 1; + return CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.CREATURES).size() >= 1; } return true; } diff --git a/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java b/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java index b85326c8f85..e2fb1da8563 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java @@ -140,8 +140,8 @@ protected boolean checkApiLogic(final Player ai, final SpellAbility sa) { && card.getState(CardStateName.Original).getManaCost() != null && card.getState(CardStateName.Original).getManaCost().getCMC() == manaValue); if (manaValue == 0) { - aiCards = CardLists.filter(aiCards, CardPredicates.Presets.NON_LANDS); - oppCards = CardLists.filter(oppCards, CardPredicates.Presets.NON_LANDS); + aiCards = CardLists.filter(aiCards, CardPredicates.NON_LANDS); + oppCards = CardLists.filter(oppCards, CardPredicates.NON_LANDS); // also filter out other Chalices in our own deck aiCards = CardLists.filter(aiCards, CardPredicates.nameNotEquals("Chalice of the Void")); } @@ -257,7 +257,7 @@ protected boolean checkApiLogic(final Player ai, final SpellAbility sa) { // Only cast if there are X or more mana sources controlled by the AI *or* // if there are X-1 mana sources in play but the AI has an extra land in hand CardCollection m = ComputerUtilMana.getAvailableManaSources(ai, true); - int extraMana = CardLists.count(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.LANDS) > 0 ? 1 : 0; + int extraMana = CardLists.count(ai.getCardsIn(ZoneType.Hand), CardPredicates.LANDS) > 0 ? 1 : 0; if (source.getName().equals("Illusions of Grandeur")) { // TODO: this is currently hardcoded for specific Illusions-Donate cost reduction spells, need to make this generic. extraMana += Math.min(3, CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Sapphire Medallion").or(CardPredicates.nameEquals("Helm of Awakening"))).size()) * 2; // each cost-reduction spell accounts for {1} in both Illusions and Donate diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAi.java b/forge-ai/src/main/java/forge/ai/ability/PumpAi.java index d6638be806f..e0918276957 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAi.java @@ -8,7 +8,6 @@ import forge.game.ability.AbilityUtils; import forge.game.ability.ApiType; import forge.game.card.*; -import forge.game.card.CardPredicates.Presets; import forge.game.cost.Cost; import forge.game.cost.CostTapType; import forge.game.keyword.Keyword; @@ -402,7 +401,7 @@ private boolean pumpTgtAI(final Player ai, final SpellAbility sa, final int defe CardCollection list; if (sa.hasParam("AILogic")) { if (sa.getParam("AILogic").equals("HighestPower") || sa.getParam("AILogic").equals("ContinuousBonus")) { - list = CardLists.getValidCards(CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Presets.CREATURES), tgt.getValidTgts(), ai, source, sa); + list = CardLists.getValidCards(CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.CREATURES), tgt.getValidTgts(), ai, source, sa); list = CardLists.getTargetableCards(list, sa); CardLists.sortByPowerDesc(list); @@ -511,7 +510,7 @@ private boolean pumpTgtAI(final Player ai, final SpellAbility sa, final int defe // Detain target nonland permanent: don't target noncreature permanents that don't have // any activated abilities. if ("DetainNonLand".equals(sa.getParam("AILogic"))) { - list = CardLists.filter(list, Presets.CREATURES.or(card -> { + list = CardLists.filter(list, CardPredicates.CREATURES.or(card -> { for (SpellAbility sa1 : card.getSpellAbilities()) { if (sa1.isActivatedAbility()) { return true; diff --git a/forge-ai/src/main/java/forge/ai/ability/RearrangeTopOfLibraryAi.java b/forge-ai/src/main/java/forge/ai/ability/RearrangeTopOfLibraryAi.java index 81da8244c57..aac480c5185 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RearrangeTopOfLibraryAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RearrangeTopOfLibraryAi.java @@ -115,7 +115,7 @@ public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirm uncastableCMCThreshold = aic.getIntProperty(AiProps.SCRY_IMMEDIATELY_UNCASTABLE_CMC_DIFF); } - int landsOTB = CardLists.count(p.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.LANDS_PRODUCING_MANA); + int landsOTB = CardLists.count(p.getCardsIn(ZoneType.Battlefield), CardPredicates.LANDS_PRODUCING_MANA); int cmc = top.isSplitCard() ? Math.min(top.getCMC(Card.SplitCMCMode.LeftSplitCMC), top.getCMC(Card.SplitCMCMode.RightSplitCMC)) : top.getCMC(); int maxCastable = ComputerUtilMana.getAvailableManaEstimate(p, false); diff --git a/forge-ai/src/main/java/forge/ai/ability/RegenerateAi.java b/forge-ai/src/main/java/forge/ai/ability/RegenerateAi.java index d199f15a17b..2b332347a7e 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RegenerateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RegenerateAi.java @@ -82,7 +82,7 @@ protected boolean checkApiLogic(final Player ai, final SpellAbility sa) { chance = true; } } else if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)) { - final CardCollection combatants = CardLists.filter(targetables, CardPredicates.Presets.CREATURES); + final CardCollection combatants = CardLists.filter(targetables, CardPredicates.CREATURES); ComputerUtilCard.sortByEvaluateCreature(combatants); for (final Card c : combatants) { @@ -156,7 +156,7 @@ private static boolean regenMandatoryTarget(final Player ai, final SpellAbility } if (compTargetables.size() > 0) { - final CardCollection combatants = CardLists.filter(compTargetables, CardPredicates.Presets.CREATURES); + final CardCollection combatants = CardLists.filter(compTargetables, CardPredicates.CREATURES); ComputerUtilCard.sortByEvaluateCreature(combatants); if (game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)) { Combat combat = game.getCombat(); diff --git a/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java b/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java index e7ed3a5dfa7..fe784006446 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java @@ -8,7 +8,6 @@ import forge.ai.SpellAbilityAi; import forge.game.ability.AbilityUtils; import forge.game.card.*; -import forge.game.card.CardPredicates.Presets; import forge.game.phase.PhaseType; import forge.game.player.Player; import forge.game.spellability.SpellAbility; @@ -30,7 +29,7 @@ protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { } else if ("Never".equals(logic)) { return false; } else if ("CloneAllTokens".equals(logic)) { - List humTokenCreats = CardLists.filter(aiPlayer.getOpponents().getCreaturesInPlay(), Presets.TOKEN); + List humTokenCreats = CardLists.filter(aiPlayer.getOpponents().getCreaturesInPlay(), CardPredicates.TOKEN); List compTokenCreats = aiPlayer.getTokensInPlay(); return compTokenCreats.size() > humTokenCreats.size(); diff --git a/forge-ai/src/main/java/forge/ai/ability/ScryAi.java b/forge-ai/src/main/java/forge/ai/ability/ScryAi.java index 94a7cbbf85f..8df58ec64e5 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ScryAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ScryAi.java @@ -99,7 +99,7 @@ protected boolean checkPhaseRestrictions(final Player ai, final SpellAbility sa, private boolean doBestOpportunityLogic(Player ai, SpellAbility sa, PhaseHandler ph) { // Check to see if there are any cards in hand that may be worth casting boolean hasSomethingElse = false; - for (Card c : CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.NON_LANDS)) { + for (Card c : CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.NON_LANDS)) { for (SpellAbility ab : c.getAllSpellAbilities()) { if (ab.getPayCosts().hasManaCost() && ComputerUtilMana.hasEnoughManaSourcesToCast(ab, ai)) { diff --git a/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java b/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java index da8dcfc2286..4dac2a7ea9f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java @@ -73,7 +73,7 @@ protected boolean checkPhaseRestrictions(Player ai, SpellAbility sa, PhaseHandle sa.resetTargets(); // select only the ones that can transform - CardCollection list = CardLists.filter(CardUtil.getValidCardsToTarget(sa), CardPredicates.Presets.CREATURES, c -> c.canTransform(sa)); + CardCollection list = CardLists.filter(CardUtil.getValidCardsToTarget(sa), CardPredicates.CREATURES, c -> c.canTransform(sa)); if (list.isEmpty()) { return false; diff --git a/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java b/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java index e742e62ee09..9f47bd2c3f6 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java +++ b/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java @@ -15,7 +15,6 @@ import forge.game.card.CardCollection; import forge.game.card.CardLists; import forge.game.card.CardPredicates; -import forge.game.card.CardPredicates.Presets; import forge.game.combat.CombatUtil; import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; @@ -107,7 +106,7 @@ private boolean tapTargetList(final Player ai, final SpellAbility sa, final Card protected boolean tapPrefTargeting(final Player ai, final Card source, final SpellAbility sa, final boolean mandatory) { final Game game = ai.getGame(); CardCollection tapList = CardLists.getTargetableCards(ai.getOpponents().getCardsIn(ZoneType.Battlefield), sa); - tapList = CardLists.filter(tapList, Presets.CAN_TAP); + tapList = CardLists.filter(tapList, CardPredicates.CAN_TAP); tapList = CardLists.filter(tapList, c -> { if (c.isCreature()) { return true; @@ -196,7 +195,7 @@ protected boolean tapPrefTargeting(final Player ai, final Card source, final Spe } else if (phase.isPlayerTurn(opp) && phase.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)) { // Tap creatures possible blockers before combat during AI's turn. - if (Iterables.any(tapList, CardPredicates.Presets.CREATURES)) { + if (Iterables.any(tapList, CardPredicates.CREATURES)) { List creatureList = CardLists.filter(tapList, c -> c.isCreature() && CombatUtil.canAttack(c, opp)); choice = ComputerUtilCard.getBestCreatureAI(creatureList); } else { // no creatures available @@ -264,7 +263,7 @@ protected boolean tapUnpreferredTargeting(final Player ai, final SpellAbility s } // try to just tap already tapped things - tapList = CardLists.filter(list, Presets.TAPPED); + tapList = CardLists.filter(list, CardPredicates.TAPPED); if (tapTargetList(ai, sa, tapList, mandatory)) { return true; diff --git a/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java b/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java index bafaa3b4e34..c7ea1207ff9 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java @@ -45,7 +45,7 @@ protected boolean canPlayAI(final Player ai, SpellAbility sa) { } validTappables = CardLists.getValidCards(validTappables, valid, source.getController(), source, sa); - validTappables = CardLists.filter(validTappables, CardPredicates.Presets.UNTAPPED); + validTappables = CardLists.filter(validTappables, CardPredicates.UNTAPPED); if (sa.hasParam("AILogic")) { String logic = sa.getParam("AILogic"); @@ -83,7 +83,7 @@ private CardCollectionView getTapAllTargets(final String valid, final Card sourc final Game game = source.getGame(); CardCollectionView tmpList = game.getCardsIn(ZoneType.Battlefield); tmpList = CardLists.getValidCards(tmpList, valid, source.getController(), source, sa); - tmpList = CardLists.filter(tmpList, CardPredicates.Presets.UNTAPPED); + tmpList = CardLists.filter(tmpList, CardPredicates.UNTAPPED); return tmpList; } diff --git a/forge-ai/src/main/java/forge/ai/ability/UntapAi.java b/forge-ai/src/main/java/forge/ai/ability/UntapAi.java index 3d70acae32f..6f98186da85 100644 --- a/forge-ai/src/main/java/forge/ai/ability/UntapAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/UntapAi.java @@ -8,7 +8,7 @@ import forge.game.card.Card; import forge.game.card.CardCollection; import forge.game.card.CardLists; -import forge.game.card.CardPredicates.Presets; +import forge.game.card.CardPredicates; import forge.game.combat.Combat; import forge.game.cost.Cost; import forge.game.cost.CostTap; @@ -155,7 +155,7 @@ private static boolean untapPrefTargeting(final Player ai, final SpellAbility sa } } - CardCollection untapList = targetUntapped ? list : CardLists.filter(list, Presets.TAPPED); + CardCollection untapList = targetUntapped ? list : CardLists.filter(list, CardPredicates.TAPPED); // filter out enchantments and planeswalkers, their tapped state doesn't matter. final String[] tappablePermanents = {"Creature", "Land", "Artifact"}; untapList = CardLists.getValidCards(untapList, tappablePermanents, source.getController(), source, sa); @@ -260,7 +260,7 @@ private boolean untapUnpreferredTargeting(final SpellAbility sa, final boolean m } // try to just tap already tapped things - tapList = CardLists.filter(list, Presets.UNTAPPED); + tapList = CardLists.filter(list, CardPredicates.UNTAPPED); if (untapTargetList(source, tgt, sa, mandatory, tapList)) { return true; @@ -400,10 +400,10 @@ private boolean doPoolExtraManaLogic(final Player ai, final SpellAbility sa) { } // Check if something is playable if we untap for an additional mana with this, then proceed - CardCollection inHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), Presets.NON_LANDS); + CardCollection inHand = CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.NON_LANDS); // The AI is not very good at timing non-permanent spells this way, so filter them out // (it may actually be possible to enable this for sorceries, but that'll need some canPlay shenanigans) - CardCollection playable = CardLists.filter(inHand, Presets.PERMANENTS); + CardCollection playable = CardLists.filter(inHand, CardPredicates.PERMANENTS); CardCollection untappingCards = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), card -> { boolean hasUntapLandLogic = false; @@ -427,7 +427,7 @@ private boolean doPoolExtraManaLogic(final Player ai, final SpellAbility sa) { reduced.decreaseShard(ManaCostShard.GENERIC, untappingCards.size()); if (ComputerUtilMana.canPayManaCost(reduced, ab, ai, false)) { CardCollection manaLandsTapped = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), - Presets.LANDS_PRODUCING_MANA, Presets.TAPPED); + CardPredicates.LANDS_PRODUCING_MANA, CardPredicates.TAPPED); manaLandsTapped = CardLists.getValidCards(manaLandsTapped, sa.getParam("ValidTgts"), ai, source, null); if (!manaLandsTapped.isEmpty()) { @@ -437,7 +437,7 @@ private boolean doPoolExtraManaLogic(final Player ai, final SpellAbility sa) { // pool one additional mana by tapping a land to try to ramp to something CardCollection manaLands = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), - Presets.LANDS_PRODUCING_MANA, Presets.CAN_TAP); + CardPredicates.LANDS_PRODUCING_MANA, CardPredicates.CAN_TAP); manaLands = CardLists.getValidCards(manaLands, sa.getParam("ValidTgts"), ai, source, null); if (manaLands.isEmpty()) { diff --git a/forge-ai/src/main/java/forge/ai/ability/UntapAllAi.java b/forge-ai/src/main/java/forge/ai/ability/UntapAllAi.java index 47cb882ae38..bb745813f32 100644 --- a/forge-ai/src/main/java/forge/ai/ability/UntapAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/UntapAllAi.java @@ -24,7 +24,7 @@ protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { && source.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_END)) { return false; } - CardCollectionView list = CardLists.filter(aiPlayer.getGame().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.TAPPED); + CardCollectionView list = CardLists.filter(aiPlayer.getGame().getCardsIn(ZoneType.Battlefield), CardPredicates.TAPPED); final String valid = sa.getParamOrDefault("ValidCards", ""); list = CardLists.getValidCards(list, valid, source.getController(), source, sa); // don't untap if only opponent benefits @@ -39,7 +39,7 @@ protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean ma if (sa.hasParam("ValidCards")) { String valid = sa.getParam("ValidCards"); - CardCollectionView list = CardLists.filter(aiPlayer.getGame().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.TAPPED); + CardCollectionView list = CardLists.filter(aiPlayer.getGame().getCardsIn(ZoneType.Battlefield), CardPredicates.TAPPED); list = CardLists.getValidCards(list, valid, source.getController(), source, sa); return mandatory || !list.isEmpty(); } diff --git a/forge-core/src/main/java/forge/card/CardFacePredicates.java b/forge-core/src/main/java/forge/card/CardFacePredicates.java index a23339ca33d..fb3126d3a84 100644 --- a/forge-core/src/main/java/forge/card/CardFacePredicates.java +++ b/forge-core/src/main/java/forge/card/CardFacePredicates.java @@ -133,21 +133,9 @@ public static Predicate valid(final String val) { return new ValidPredicate(val); } - public static class Presets { - /** The Constant isBasicLand. */ - public static final Predicate IS_BASIC_LAND = subject -> subject.getType().isBasicLand(); - - /** The Constant isNonBasicLand. */ - public static final Predicate IS_NONBASIC_LAND = subject -> subject.getType().isLand() && !subject.getType().isBasicLand(); - - /** The Constant isCreature. */ - public static final Predicate IS_CREATURE = CardFacePredicates - .coreType(true, CardType.CoreType.Creature); - - public static final Predicate IS_LEGENDARY = CardFacePredicates - .superType(true, CardType.Supertype.Legendary); - - public static final Predicate IS_NON_LAND = CardFacePredicates - .coreType(false, CardType.CoreType.Land); - } + public static final Predicate IS_BASIC_LAND = subject -> subject.getType().isBasicLand(); + public static final Predicate IS_NONBASIC_LAND = subject -> subject.getType().isLand() && !subject.getType().isBasicLand(); + public static final Predicate IS_CREATURE = CardFacePredicates.coreType(true, CardType.CoreType.Creature); + public static final Predicate IS_LEGENDARY = CardFacePredicates.superType(true, CardType.Supertype.Legendary); + public static final Predicate IS_NON_LAND = CardFacePredicates.coreType(false, CardType.CoreType.Land); } diff --git a/forge-core/src/main/java/forge/card/CardRulesPredicates.java b/forge-core/src/main/java/forge/card/CardRulesPredicates.java index 2e97b9ab6a6..70023b36766 100644 --- a/forge-core/src/main/java/forge/card/CardRulesPredicates.java +++ b/forge-core/src/main/java/forge/card/CardRulesPredicates.java @@ -12,13 +12,8 @@ */ public final class CardRulesPredicates { - /** The Constant isKeptInAiDecks. */ public static final Predicate IS_KEPT_IN_AI_DECKS = card -> !card.getAiHints().getRemAIDecks(); - - /** The Constant isKeptInAiLimitedDecks. */ public static final Predicate IS_KEPT_IN_AI_LIMITED_DECKS = card -> !card.getAiHints().getRemAIDecks() && !card.getAiHints().getRemNonCommanderDecks(); - - /** The Constant isKeptInRandomDecks. */ public static final Predicate IS_KEPT_IN_RANDOM_DECKS = card -> !card.getAiHints().getRemRandomDecks(); // Static builder methods - they choose concrete implementation by themselves @@ -524,106 +519,50 @@ public boolean test(final CardRules subject) { } } - /** - * The Class Presets. - */ - public static class Presets { - - /** The Constant isCreature. */ - public static final Predicate IS_CREATURE = CardRulesPredicates - .coreType(true, CardType.CoreType.Creature); - - public static final Predicate IS_LEGENDARY = CardRulesPredicates - .superType(true, CardType.Supertype.Legendary); - - /** The Constant isArtifact. */ - public static final Predicate IS_ARTIFACT = CardRulesPredicates - .coreType(true, CardType.CoreType.Artifact); - - /** The Constant isEquipment. */ - public static final Predicate IS_EQUIPMENT = CardRulesPredicates - .subType("Equipment"); - - /** The Constant isLand. */ - public static final Predicate IS_LAND = CardRulesPredicates.coreType(true, CardType.CoreType.Land); - - /** The Constant isBasicLand. */ - public static final Predicate IS_BASIC_LAND = subject -> subject.getType().isBasicLand(); - public static final Predicate NOT_BASIC_LAND = subject -> !subject.getType().isBasicLand(); - - /** Matches only Plains, Island, Swamp, Mountain, or Forest. */ - public static final Predicate IS_BASIC_LAND_NOT_WASTES = subject -> !subject.getName().equals("Wastes")&&subject.getType().isBasicLand(); - /** Matches any card except Plains, Island, Swamp, Mountain, or Forest. */ - public static final Predicate NOT_TRUE_BASIC_LAND = subject -> !subject.getType().isBasicLand() || subject.getName().equals("Wastes"); - - /** The Constant isNonBasicLand. */ - public static final Predicate IS_NONBASIC_LAND = subject -> subject.getType().isLand() && !subject.getType().isBasicLand(); - - public static final Predicate CAN_BE_COMMANDER = CardRules::canBeCommander; - public static final Predicate CAN_BE_PARTNER_COMMANDER = CardRules::canBePartnerCommander; - - public static final Predicate CAN_BE_OATHBREAKER = CardRules::canBeOathbreaker; - public static final Predicate CAN_BE_SIGNATURE_SPELL = CardRules::canBeSignatureSpell; - - public static final Predicate IS_PLANESWALKER = CardRulesPredicates.coreType(true, CardType.CoreType.Planeswalker); - public static final Predicate IS_BATTLE = CardRulesPredicates.coreType(true, CardType.CoreType.Battle); - public static final Predicate IS_INSTANT = CardRulesPredicates.coreType(true, CardType.CoreType.Instant); - public static final Predicate IS_SORCERY = CardRulesPredicates.coreType(true, CardType.CoreType.Sorcery); - public static final Predicate IS_ENCHANTMENT = CardRulesPredicates.coreType(true, CardType.CoreType.Enchantment); - public static final Predicate IS_PLANE = CardRulesPredicates.coreType(true, CardType.CoreType.Plane); - public static final Predicate IS_PHENOMENON = CardRulesPredicates.coreType(true, CardType.CoreType.Phenomenon); - public static final Predicate IS_PLANE_OR_PHENOMENON = IS_PLANE.or(IS_PHENOMENON); - public static final Predicate IS_SCHEME = CardRulesPredicates.coreType(true, CardType.CoreType.Scheme); - public static final Predicate IS_VANGUARD = CardRulesPredicates.coreType(true, CardType.CoreType.Vanguard); - public static final Predicate IS_CONSPIRACY = CardRulesPredicates.coreType(true, CardType.CoreType.Conspiracy); - public static final Predicate IS_DUNGEON = CardRulesPredicates.coreType(true, CardType.CoreType.Dungeon); - public static final Predicate IS_ATTRACTION = Presets.IS_ARTIFACT.and(CardRulesPredicates.subType("Attraction")); - - public static final Predicate IS_NON_LAND = CardRulesPredicates.coreType(false, CardType.CoreType.Land); - public static final Predicate CAN_BE_BRAWL_COMMANDER = Presets.IS_LEGENDARY.and(Presets.IS_CREATURE.or(Presets.IS_PLANESWALKER)); - public static final Predicate CAN_BE_TINY_LEADERS_COMMANDER = Presets.IS_LEGENDARY.and(Presets.IS_CREATURE.or(Presets.IS_PLANESWALKER)); - - /** The Constant IS_NON_CREATURE_SPELL. **/ - public static final Predicate IS_NON_CREATURE_SPELL = - Presets.IS_SORCERY - .or(Presets.IS_INSTANT) - .or(Presets.IS_PLANESWALKER) - .or(Presets.IS_ENCHANTMENT) //TODO: Battles? Is testing these one by one really the best way to check "non-creature"? - .or(Presets.IS_ARTIFACT.and(Presets.IS_CREATURE.negate())); - - /** The Constant isWhite. */ - public static final Predicate IS_WHITE = CardRulesPredicates.isColor(MagicColor.WHITE); - - /** The Constant isBlue. */ - public static final Predicate IS_BLUE = CardRulesPredicates.isColor(MagicColor.BLUE); - - /** The Constant isBlack. */ - public static final Predicate IS_BLACK = CardRulesPredicates.isColor(MagicColor.BLACK); - - /** The Constant isRed. */ - public static final Predicate IS_RED = CardRulesPredicates.isColor(MagicColor.RED); - - /** The Constant isGreen. */ - public static final Predicate IS_GREEN = CardRulesPredicates.isColor(MagicColor.GREEN); - - /** The Constant isColorless. */ - public static final Predicate IS_COLORLESS = CardRulesPredicates.hasCntColors((byte) 0); - - /** The Constant isMulticolor. */ - public static final Predicate IS_MULTICOLOR = CardRulesPredicates.hasAtLeastCntColors((byte) 2); - - /** The Constant isMonocolor. */ - public static final Predicate IS_MONOCOLOR = CardRulesPredicates.hasCntColors((byte) 1); - - /** The Constant colors. */ - public static final List> COLORS = new ArrayList<>(); - static { - Presets.COLORS.add(Presets.IS_WHITE); - Presets.COLORS.add(Presets.IS_BLUE); - Presets.COLORS.add(Presets.IS_BLACK); - Presets.COLORS.add(Presets.IS_RED); - Presets.COLORS.add(Presets.IS_GREEN); - Presets.COLORS.add(Presets.IS_COLORLESS); - } - } + public static final Predicate IS_CREATURE = CardRulesPredicates.coreType(true, CardType.CoreType.Creature); + public static final Predicate IS_LEGENDARY = CardRulesPredicates.superType(true, CardType.Supertype.Legendary); + public static final Predicate IS_ARTIFACT = CardRulesPredicates.coreType(true, CardType.CoreType.Artifact); + public static final Predicate IS_ATTRACTION = CardRulesPredicates.IS_ARTIFACT.and(CardRulesPredicates.subType("Attraction")); + public static final Predicate IS_EQUIPMENT = CardRulesPredicates.subType("Equipment"); + public static final Predicate IS_LAND = CardRulesPredicates.coreType(true, CardType.CoreType.Land); + public static final Predicate IS_BASIC_LAND = subject -> subject.getType().isBasicLand(); + public static final Predicate NOT_BASIC_LAND = subject -> !subject.getType().isBasicLand(); + /** Matches only Plains, Island, Swamp, Mountain, or Forest. */ + public static final Predicate IS_TRUE_BASIC_LAND = subject -> !subject.getName().equals("Wastes")&&subject.getType().isBasicLand(); + /** Matches any card except Plains, Island, Swamp, Mountain, or Forest. */ + public static final Predicate NOT_TRUE_BASIC_LAND = subject -> !subject.getType().isBasicLand() || subject.getName().equals("Wastes"); + public static final Predicate IS_NONBASIC_LAND = subject -> subject.getType().isLand() && !subject.getType().isBasicLand(); + public static final Predicate CAN_BE_COMMANDER = CardRules::canBeCommander; + public static final Predicate CAN_BE_PARTNER_COMMANDER = CardRules::canBePartnerCommander; + public static final Predicate CAN_BE_OATHBREAKER = CardRules::canBeOathbreaker; + public static final Predicate CAN_BE_SIGNATURE_SPELL = CardRules::canBeSignatureSpell; + public static final Predicate IS_PLANESWALKER = CardRulesPredicates.coreType(true, CardType.CoreType.Planeswalker); + public static final Predicate CAN_BE_TINY_LEADERS_COMMANDER = CardRulesPredicates.IS_LEGENDARY.and(CardRulesPredicates.IS_CREATURE.or(CardRulesPredicates.IS_PLANESWALKER)); + public static final Predicate CAN_BE_BRAWL_COMMANDER = CardRulesPredicates.IS_LEGENDARY.and(CardRulesPredicates.IS_CREATURE.or(CardRulesPredicates.IS_PLANESWALKER)); + public static final Predicate IS_BATTLE = CardRulesPredicates.coreType(true, CardType.CoreType.Battle); + public static final Predicate IS_INSTANT = CardRulesPredicates.coreType(true, CardType.CoreType.Instant); + public static final Predicate IS_SORCERY = CardRulesPredicates.coreType(true, CardType.CoreType.Sorcery); + public static final Predicate IS_ENCHANTMENT = CardRulesPredicates.coreType(true, CardType.CoreType.Enchantment); + public static final Predicate IS_NON_CREATURE_SPELL = + CardRulesPredicates.IS_SORCERY + .or(CardRulesPredicates.IS_INSTANT) + .or(CardRulesPredicates.IS_PLANESWALKER) + .or(CardRulesPredicates.IS_ENCHANTMENT) //TODO: Battles? Is testing these one by one really the best way to check "non-creature"? + .or(CardRulesPredicates.IS_ARTIFACT.and(CardRulesPredicates.IS_CREATURE.negate())); + public static final Predicate IS_PLANE = CardRulesPredicates.coreType(true, CardType.CoreType.Plane); + public static final Predicate IS_PHENOMENON = CardRulesPredicates.coreType(true, CardType.CoreType.Phenomenon); + public static final Predicate IS_PLANE_OR_PHENOMENON = IS_PLANE.or(IS_PHENOMENON); + public static final Predicate IS_SCHEME = CardRulesPredicates.coreType(true, CardType.CoreType.Scheme); + public static final Predicate IS_VANGUARD = CardRulesPredicates.coreType(true, CardType.CoreType.Vanguard); + public static final Predicate IS_CONSPIRACY = CardRulesPredicates.coreType(true, CardType.CoreType.Conspiracy); + public static final Predicate IS_DUNGEON = CardRulesPredicates.coreType(true, CardType.CoreType.Dungeon); + public static final Predicate IS_NON_LAND = CardRulesPredicates.coreType(false, CardType.CoreType.Land); + public static final Predicate IS_WHITE = CardRulesPredicates.isColor(MagicColor.WHITE); + public static final Predicate IS_BLUE = CardRulesPredicates.isColor(MagicColor.BLUE); + public static final Predicate IS_BLACK = CardRulesPredicates.isColor(MagicColor.BLACK); + public static final Predicate IS_RED = CardRulesPredicates.isColor(MagicColor.RED); + public static final Predicate IS_GREEN = CardRulesPredicates.isColor(MagicColor.GREEN); + public static final Predicate IS_COLORLESS = CardRulesPredicates.hasCntColors((byte) 0); + public static final Predicate IS_MULTICOLOR = CardRulesPredicates.hasAtLeastCntColors((byte) 2); + public static final Predicate IS_MONOCOLOR = CardRulesPredicates.hasCntColors((byte) 1); } diff --git a/forge-core/src/main/java/forge/card/DeckHints.java b/forge-core/src/main/java/forge/card/DeckHints.java index a422313f480..ba013dcc1f6 100644 --- a/forge-core/src/main/java/forge/card/DeckHints.java +++ b/forge-core/src/main/java/forge/card/DeckHints.java @@ -181,7 +181,7 @@ private List getCardsForFilter(Iterable cardList, Type typ case COLOR: ColorSet cc = ColorSet.fromNames(p); if (cc.isColorless()) { - Iterables.addAll(cards, getMatchingItems(cardList, CardRulesPredicates.Presets.IS_COLORLESS, PaperCard::getRules)); + Iterables.addAll(cards, getMatchingItems(cardList, CardRulesPredicates.IS_COLORLESS, PaperCard::getRules)); } else { Iterables.addAll(cards, getMatchingItems(cardList, CardRulesPredicates.isColor(cc.getColor()), PaperCard::getRules)); } diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java b/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java index d395d108ce6..dd3b313f7eb 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java @@ -4,8 +4,8 @@ import java.util.Map; import java.util.function.Predicate; -import forge.item.IPaperCard; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.util.Iterables; public class DeckGenPool implements IDeckGenPool { @@ -37,7 +37,7 @@ public PaperCard getCard(String name) { @Override public PaperCard getCard(String name, String edition) { - Predicate filter = IPaperCard.Predicates.printedInSet(edition).and(IPaperCard.Predicates.name(name)); + Predicate filter = PaperCardPredicates.printedInSet(edition).and(PaperCardPredicates.name(name)); Iterable editionCards=Iterables.filter(cards.values(), filter); if (editionCards.iterator().hasNext()){ return editionCards.iterator().next(); diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index b83fcc53154..d38eb114cb5 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -23,8 +23,8 @@ import forge.card.mana.ManaCost; import forge.deck.CardPool; import forge.deck.DeckFormat; -import forge.item.IPaperCard; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.util.*; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -87,12 +87,12 @@ protected void addCreaturesAndSpells(int size, List cards = selectCardsOfMatchingColorForPlayer(forAi); // build subsets based on type - final Iterable creatures = Iterables.filter(cards, Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, PaperCard::getRules)); + final Iterable creatures = Iterables.filter(cards, Predicates.compose(CardRulesPredicates.IS_CREATURE, PaperCard::getRules)); final int creatCnt = (int) Math.ceil(getCreaturePercentage() * size); trace.append("Creatures to add:").append(creatCnt).append("\n"); addCmcAdjusted(creatures, creatCnt, cmcLevels); - Predicate preSpells = Predicates.compose(CardRulesPredicates.Presets.IS_NON_CREATURE_SPELL, PaperCard::getRules); + Predicate preSpells = Predicates.compose(CardRulesPredicates.IS_NON_CREATURE_SPELL, PaperCard::getRules); final Iterable spells = Iterables.filter(cards, preSpells); final int spellCnt = (int) Math.ceil(getSpellPercentage() * size); trace.append("Spells to add:").append(spellCnt).append("\n"); @@ -108,10 +108,10 @@ public CardPool getDeck(final int size, final boolean forAi) { protected boolean setBasicLandPool(String edition){ Predicate isSetBasicLand; if (edition !=null){ - isSetBasicLand = IPaperCard.Predicates.printedInSet(edition) - .and(Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules)); + isSetBasicLand = PaperCardPredicates.printedInSet(edition) + .and(Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules)); }else{ - isSetBasicLand = Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules); + isSetBasicLand = Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules); } landPool = new DeckGenPool(StaticData.instance().getCommonCards().getAllCards(isSetBasicLand)); @@ -234,7 +234,7 @@ protected void adjustDeckSize(int targetSize) { addSome(targetSize - actualSize, tDeck.toFlatList()); } else if (actualSize > targetSize) { - Predicate exceptBasicLand = Predicates.compose(CardRulesPredicates.Presets.NOT_BASIC_LAND, PaperCard::getRules); + Predicate exceptBasicLand = Predicates.compose(CardRulesPredicates.NOT_BASIC_LAND, PaperCard::getRules); for (int i = 0; i < 3 && actualSize > targetSize; i++) { Iterable matchingCards = Iterables.filter(tDeck.toFlatList(), exceptBasicLand); @@ -388,7 +388,7 @@ protected List getDualLandList(Predicate canPlay) { //filter to provide all dual lands from pool matching 2 or 3 colors from current deck Predicate dualLandFilter = CardRulesPredicates.coreType(true, CardType.CoreType.Land); - Predicate exceptBasicLand = CardRulesPredicates.Presets.NOT_BASIC_LAND; + Predicate exceptBasicLand = CardRulesPredicates.NOT_BASIC_LAND; Iterable landCards = pool.getAllCards(Predicates.compose(dualLandFilter.and(exceptBasicLand).and(canPlay), PaperCard::getRules)); Iterable dualLandPatterns = Arrays.asList("Add \\{([WUBRG])\\} or \\{([WUBRG])\\}", diff --git a/forge-core/src/main/java/forge/item/IPaperCard.java b/forge-core/src/main/java/forge/item/IPaperCard.java index 37b11ba8250..762186dd2f6 100644 --- a/forge-core/src/main/java/forge/item/IPaperCard.java +++ b/forge-core/src/main/java/forge/item/IPaperCard.java @@ -24,211 +24,6 @@ public interface IPaperCard extends InventoryItem, Serializable { String NO_ARTIST_NAME = ""; String NO_FUNCTIONAL_VARIANT = ""; - /** - * Number of filters based on CardPrinted values. - */ - abstract class Predicates { - - public static Predicate rarity(final boolean isEqual, final CardRarity value) { - return new PredicateRarity(value, isEqual); - } - - public static Predicate color(final boolean isEqual, final boolean noColor, final byte value) { - return new PredicateColor(value, noColor, isEqual); - } - - public static Predicate printedInSets(final String[] sets) { - return printedInSets(Lists.newArrayList(sets), true); - } - - public static Predicate printedInSets(final List value, final boolean shouldContain) { - if ((value == null) || value.isEmpty()) { - return x -> true; - } - return new PredicateSets(value, shouldContain); - } - - public static Predicate printedInSet(final String value) { - if (StringUtils.isEmpty(value)) { - return x -> true; - } - return new PredicateSets(Lists.newArrayList(value), true); - } - - public static Predicate name(final String what) { - return new PredicateName(PredicateString.StringOp.EQUALS_IC, what); - } - - public static Predicate name(final PredicateString.StringOp op, final String what) { - return new PredicateName(op, what); - } - - public static Predicate names(final List what) { - return new PredicateNames(what); - } - - public static PredicateCards cards(final List what) { return new PredicateCards(what); } - - private static final class PredicateColor implements Predicate { - - private final byte operand; - private final boolean noColor; - private final boolean shouldBeEqual; - - private PredicateColor(final byte color, final boolean noColor, final boolean wantEqual) { - this.operand = color; - this.noColor = noColor; - this.shouldBeEqual = wantEqual; - } - - @Override - public boolean test(final PaperCard card) { - boolean colorFound = false; - if (noColor) { - return card.getRules().getColor().isColorless() == shouldBeEqual; - } - for (final byte color : card.getRules().getColor()) { - if (color == operand) { - colorFound = true; - break; - } - } - if (card.getRules().getType().hasType(CoreType.Land)) { - for (final byte color : card.getRules().getColorIdentity()) { - if (color == operand) { - colorFound = true; - break; - } - } - } - return colorFound == shouldBeEqual; - } - - } - - private static final class PredicateRarity implements Predicate { - private final CardRarity operand; - private final boolean shouldBeEqual; - - @Override - public boolean test(final PaperCard card) { - return (card.getRarity() == this.operand) == this.shouldBeEqual; - } - - private PredicateRarity(final CardRarity type, final boolean wantEqual) { - this.operand = type; - this.shouldBeEqual = wantEqual; - } - } - - private static final class PredicateSets implements Predicate { - private final Set sets; - private final boolean mustContain; - - @Override - public boolean test(final PaperCard card) { - return this.sets.contains(card.getEdition()) == this.mustContain; - } - - private PredicateSets(final List wantSets, final boolean shouldContain) { - this.sets = new HashSet<>(wantSets); - this.mustContain = shouldContain; - } - } - - private static final class PredicateName extends PredicateString { - private final String operand; - - @Override - public boolean test(final PaperCard card) { - return this.op(card.getName(), this.operand); - } - - private PredicateName(final PredicateString.StringOp operator, final String operand) { - super(operator); - this.operand = operand; - } - } - - private static final class PredicateNames extends PredicateString { - private final List operand; - - @Override - public boolean test(final PaperCard card) { - final String cardName = card.getName(); - for (final String element : this.operand) { - if (this.op(cardName, element)) { - return true; - } - } - return false; - } - - private PredicateNames(final List operand) { - super(StringOp.EQUALS); - this.operand = operand; - } - } - - private static final class PredicateCards extends PredicateCard { - private final List operand; - - @Override - public boolean test(final PaperCard card) { - for (final PaperCard element : this.operand) { - if (this.op(card, element)) { - return true; - } - } - return false; - } - - private PredicateCards(final List operand) { - super(StringOp.EQUALS); - this.operand = operand; - } - } - - /** - * Pre-built predicates are stored here to allow their re-usage and - * easier access from code. - */ - public abstract static class Presets { - // Think twice before using these, since rarity is a prop of printed - // card. - /** The Constant isCommon. */ - public static final Predicate IS_COMMON = Predicates.rarity(true, CardRarity.Common); - - /** The Constant isUncommon. */ - public static final Predicate IS_UNCOMMON = Predicates.rarity(true, CardRarity.Uncommon); - - /** The Constant isRare. */ - public static final Predicate IS_RARE = Predicates.rarity(true, CardRarity.Rare); - - /** The Constant isMythicRare. */ - public static final Predicate IS_MYTHIC_RARE = Predicates.rarity(true, CardRarity.MythicRare); - - /** The Constant isRareOrMythic. */ - public static final Predicate IS_RARE_OR_MYTHIC = Presets.IS_RARE.or(Presets.IS_MYTHIC_RARE); - - /** The Constant isSpecial. */ - public static final Predicate IS_SPECIAL = Predicates.rarity(true, CardRarity.Special); - - /** The Constant exceptLands. */ - public static final Predicate IS_BASIC_LAND = Predicates.rarity(true, CardRarity.BasicLand); - - public static final Predicate IS_BLACK = Predicates.color(true, false, MagicColor.BLACK); - public static final Predicate IS_BLUE = Predicates.color(true, false, MagicColor.BLUE); - public static final Predicate IS_GREEN = Predicates.color(true, false, MagicColor.GREEN); - public static final Predicate IS_RED = Predicates.color(true, false, MagicColor.RED); - public static final Predicate IS_WHITE = Predicates.color(true, false, MagicColor.WHITE); - public static final Predicate IS_COLORLESS = Predicates.color(true, true, MagicColor.COLORLESS); - - public static final Predicate IS_UNREBALANCED = PaperCard::isUnRebalanced; - public static final Predicate IS_REBALANCED = PaperCard::isRebalanced; - } - } - String getName(); String getEdition(); diff --git a/forge-core/src/main/java/forge/item/ItemPredicate.java b/forge-core/src/main/java/forge/item/ItemPredicate.java index dc50933998a..502bef226b1 100644 --- a/forge-core/src/main/java/forge/item/ItemPredicate.java +++ b/forge-core/src/main/java/forge/item/ItemPredicate.java @@ -10,34 +10,21 @@ public abstract class ItemPredicate { // Static builder methods - they choose concrete implementation by themselves public static final Predicate IsBoosterPack = BoosterPack.class::isInstance; + /** + * Checks that the inventory item is a Prebuilt Deck. + */ public static final Predicate IsPrebuiltDeck = PreconDeck.class::isInstance; public static final Predicate IsFatPack = FatPack.class::isInstance; /** * Checks that the inventory item is a Tournament Pack. - * - * @return the predicate */ public static final Predicate IsTournamentPack = card -> card instanceof TournamentPack && !((TournamentPack) card).isStarterDeck(); /** * Checks that the inventory item is a Starter Deck. - * - * @return the predicate */ public static final Predicate IsStarterDeck = card -> card instanceof TournamentPack && ((TournamentPack) card).isStarterDeck(); - /** - * Checks that the inventory item is a Prebuilt Deck. - * - * @return the predicate - */ - - /** - * The Class Presets. - */ - public static class Presets { - /** The Item IsPack. */ - public static final Predicate IS_PACK_OR_DECK = IsBoosterPack.or(IsFatPack).or(IsTournamentPack).or(IsStarterDeck).or(IsPrebuiltDeck); - } + public static final Predicate IS_PACK_OR_DECK = IsBoosterPack.or(IsFatPack).or(IsTournamentPack).or(IsStarterDeck).or(IsPrebuiltDeck); } diff --git a/forge-core/src/main/java/forge/item/PaperCardPredicates.java b/forge-core/src/main/java/forge/item/PaperCardPredicates.java new file mode 100644 index 00000000000..f7dbdc28d5d --- /dev/null +++ b/forge-core/src/main/java/forge/item/PaperCardPredicates.java @@ -0,0 +1,197 @@ +package forge.item; + +import com.google.common.collect.Lists; +import forge.card.CardRarity; +import forge.card.CardType; +import forge.card.MagicColor; +import forge.util.PredicateCard; +import forge.util.PredicateString; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Predicate; + +/** + * Filters based on PaperCard values. + */ +public abstract class PaperCardPredicates { + public static Predicate rarity(final boolean isEqual, final CardRarity value) { + return new PredicateRarity(value, isEqual); + } + + public static Predicate color(final boolean isEqual, final boolean noColor, final byte value) { + return new PredicateColor(value, noColor, isEqual); + } + + public static Predicate printedInSets(final String[] sets) { + return printedInSets(Lists.newArrayList(sets), true); + } + + public static Predicate printedInSets(final List value, final boolean shouldContain) { + if ((value == null) || value.isEmpty()) { + return x -> true; + } + return new PredicateSets(value, shouldContain); + } + + public static Predicate printedInSet(final String value) { + if (StringUtils.isEmpty(value)) { + return x -> true; + } + return new PredicateSets(Lists.newArrayList(value), true); + } + + public static Predicate name(final String what) { + return new PredicateName(PredicateString.StringOp.EQUALS_IC, what); + } + + public static Predicate name(final PredicateString.StringOp op, final String what) { + return new PredicateName(op, what); + } + + public static Predicate names(final List what) { + return new PredicateNames(what); + } + + public static Predicate cards(final List what) { + return new PredicateCards(what); + } + + private static final class PredicateColor implements Predicate { + + private final byte operand; + private final boolean noColor; + private final boolean shouldBeEqual; + + private PredicateColor(final byte color, final boolean noColor, final boolean wantEqual) { + this.operand = color; + this.noColor = noColor; + this.shouldBeEqual = wantEqual; + } + + @Override + public boolean test(final PaperCard card) { + boolean colorFound = false; + if (noColor) { + return card.getRules().getColor().isColorless() == shouldBeEqual; + } + for (final byte color : card.getRules().getColor()) { + if (color == operand) { + colorFound = true; + break; + } + } + if (card.getRules().getType().hasType(CardType.CoreType.Land)) { + for (final byte color : card.getRules().getColorIdentity()) { + if (color == operand) { + colorFound = true; + break; + } + } + } + return colorFound == shouldBeEqual; + } + + } + + private static final class PredicateRarity implements Predicate { + private final CardRarity operand; + private final boolean shouldBeEqual; + + @Override + public boolean test(final PaperCard card) { + return (card.getRarity() == this.operand) == this.shouldBeEqual; + } + + private PredicateRarity(final CardRarity type, final boolean wantEqual) { + this.operand = type; + this.shouldBeEqual = wantEqual; + } + } + + private static final class PredicateSets implements Predicate { + private final Set sets; + private final boolean mustContain; + + @Override + public boolean test(final PaperCard card) { + return this.sets.contains(card.getEdition()) == this.mustContain; + } + + private PredicateSets(final List wantSets, final boolean shouldContain) { + this.sets = new HashSet<>(wantSets); + this.mustContain = shouldContain; + } + } + + private static final class PredicateName extends PredicateString { + private final String operand; + + @Override + public boolean test(final PaperCard card) { + return this.op(card.getName(), this.operand); + } + + private PredicateName(final StringOp operator, final String operand) { + super(operator); + this.operand = operand; + } + } + + private static final class PredicateNames extends PredicateString { + private final List operand; + + @Override + public boolean test(final PaperCard card) { + final String cardName = card.getName(); + for (final String element : this.operand) { + if (this.op(cardName, element)) { + return true; + } + } + return false; + } + + private PredicateNames(final List operand) { + super(StringOp.EQUALS); + this.operand = operand; + } + } + + private static final class PredicateCards extends PredicateCard { + private final List operand; + + @Override + public boolean test(final PaperCard card) { + for (final PaperCard element : this.operand) { + if (this.op(card, element)) { + return true; + } + } + return false; + } + + private PredicateCards(final List operand) { + super(StringOp.EQUALS); + this.operand = operand; + } + } + + public static final Predicate IS_COMMON = PaperCardPredicates.rarity(true, CardRarity.Common); + public static final Predicate IS_UNCOMMON = PaperCardPredicates.rarity(true, CardRarity.Uncommon); + public static final Predicate IS_RARE = PaperCardPredicates.rarity(true, CardRarity.Rare); + public static final Predicate IS_MYTHIC_RARE = PaperCardPredicates.rarity(true, CardRarity.MythicRare); + public static final Predicate IS_RARE_OR_MYTHIC = PaperCardPredicates.IS_RARE.or(PaperCardPredicates.IS_MYTHIC_RARE); + public static final Predicate IS_SPECIAL = PaperCardPredicates.rarity(true, CardRarity.Special); + public static final Predicate IS_BASIC_LAND = PaperCardPredicates.rarity(true, CardRarity.BasicLand); + public static final Predicate IS_BLACK = PaperCardPredicates.color(true, false, MagicColor.BLACK); + public static final Predicate IS_BLUE = PaperCardPredicates.color(true, false, MagicColor.BLUE); + public static final Predicate IS_GREEN = PaperCardPredicates.color(true, false, MagicColor.GREEN); + public static final Predicate IS_RED = PaperCardPredicates.color(true, false, MagicColor.RED); + public static final Predicate IS_WHITE = PaperCardPredicates.color(true, false, MagicColor.WHITE); + public static final Predicate IS_COLORLESS = PaperCardPredicates.color(true, true, MagicColor.COLORLESS); + public static final Predicate IS_UNREBALANCED = PaperCard::isUnRebalanced; + public static final Predicate IS_REBALANCED = PaperCard::isRebalanced; +} diff --git a/forge-core/src/main/java/forge/item/SealedProduct.java b/forge-core/src/main/java/forge/item/SealedProduct.java index 2c2f6c1e342..1049a14bb78 100644 --- a/forge-core/src/main/java/forge/item/SealedProduct.java +++ b/forge-core/src/main/java/forge/item/SealedProduct.java @@ -113,8 +113,8 @@ protected PaperCard getRandomBasicLand(final String setCode) { } protected List getRandomBasicLands(final String setCode, final int count) { - Predicate cardsRule = IPaperCard.Predicates.printedInSet(setCode) - .and(Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules)); + Predicate cardsRule = PaperCardPredicates.printedInSet(setCode) + .and(Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules)); return Aggregates.random(Iterables.filter(StaticData.instance().getCommonCards().getAllCards(), cardsRule), count); } } diff --git a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java index d95b056190d..2b2d6220025 100644 --- a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java +++ b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java @@ -23,7 +23,6 @@ import forge.card.*; import forge.card.CardEdition.FoilType; import forge.item.*; -import forge.item.IPaperCard.Predicates.Presets; import forge.util.*; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; @@ -510,20 +509,20 @@ public static void replaceCard(List booster, PaperCard toAdd) { Predicate rarityPredicate = null; switch (toAdd.getRarity()) { case BasicLand: - rarityPredicate = Presets.IS_BASIC_LAND; + rarityPredicate = PaperCardPredicates.IS_BASIC_LAND; break; case Common: - rarityPredicate = Presets.IS_COMMON; + rarityPredicate = PaperCardPredicates.IS_COMMON; break; case Uncommon: - rarityPredicate = Presets.IS_UNCOMMON; + rarityPredicate = PaperCardPredicates.IS_UNCOMMON; break; case Rare: case MythicRare: - rarityPredicate = Presets.IS_RARE_OR_MYTHIC; + rarityPredicate = PaperCardPredicates.IS_RARE_OR_MYTHIC; break; default: - rarityPredicate = Presets.IS_SPECIAL; + rarityPredicate = PaperCardPredicates.IS_SPECIAL; } PaperCard toReplace = null; @@ -568,7 +567,7 @@ public static void addCardsFromExtraSheet(List dest, String printShee public static PrintSheet makeSheet(String sheetKey, Iterable src) { PrintSheet ps = new PrintSheet(sheetKey); String[] sKey = TextUtil.splitWithParenthesis(sheetKey, ' ', 2); - Predicate setPred = sKey.length > 1 ? IPaperCard.Predicates.printedInSets(sKey[1].split(" ")) : x1 -> true; + Predicate setPred = sKey.length > 1 ? PaperCardPredicates.printedInSets(sKey[1].split(" ")) : x1 -> true; List operators = new LinkedList<>(Arrays.asList(TextUtil.splitWithParenthesis(sKey[0], ':'))); Predicate extraPred = buildExtraPredicate(operators); @@ -613,31 +612,31 @@ public static PrintSheet makeSheet(String sheetKey, Iterable src) { ps.addAll(Iterables.filter(src, predicate)); } else if (mainCode.equalsIgnoreCase(BoosterSlots.UNCOMMON_RARE)) { // for sets like ARN, where U1 cards are considered rare and U3 are uncommon - Predicate predicateRares = setPred.and(Presets.IS_RARE).and(extraPred); + Predicate predicateRares = setPred.and(PaperCardPredicates.IS_RARE).and(extraPred); ps.addAll(Iterables.filter(src, predicateRares)); - Predicate predicateUncommon = setPred.and(Presets.IS_UNCOMMON).and(extraPred); + Predicate predicateUncommon = setPred.and(PaperCardPredicates.IS_UNCOMMON).and(extraPred); ps.addAll(Iterables.filter(src, predicateUncommon), 3); } else if (mainCode.equalsIgnoreCase(BoosterSlots.RARE_MYTHIC)) { // Typical ratio of rares to mythics is 53:15, changing to 35:10 in smaller sets. // To achieve the desired 1:8 are all mythics are added once, and all rares added twice per print sheet. - Predicate predicateMythic = setPred.and(Presets.IS_MYTHIC_RARE).and(extraPred); + Predicate predicateMythic = setPred.and(PaperCardPredicates.IS_MYTHIC_RARE).and(extraPred); ps.addAll(Iterables.filter(src, predicateMythic)); - Predicate predicateRare = setPred.and(Presets.IS_RARE).and(extraPred); + Predicate predicateRare = setPred.and(PaperCardPredicates.IS_RARE).and(extraPred); ps.addAll(Iterables.filter(src, predicateRare), 2); } else if (mainCode.equalsIgnoreCase(BoosterSlots.UNCOMMON_RARE_MYTHIC)) { // Extended version of RARE_MYTHIC, used for Alchemy slots - Predicate predicateMythic = setPred.and(Presets.IS_MYTHIC_RARE).and(extraPred); + Predicate predicateMythic = setPred.and(PaperCardPredicates.IS_MYTHIC_RARE).and(extraPred); ps.addAll(Iterables.filter(src, predicateMythic)); - Predicate predicateRare = setPred.and(Presets.IS_RARE).and(extraPred); + Predicate predicateRare = setPred.and(PaperCardPredicates.IS_RARE).and(extraPred); ps.addAll(Iterables.filter(src, predicateRare), 2); - Predicate predicateUncommon = setPred.and(Presets.IS_UNCOMMON).and(extraPred); + Predicate predicateUncommon = setPred.and(PaperCardPredicates.IS_UNCOMMON).and(extraPred); ps.addAll(Iterables.filter(src, predicateUncommon), 4); } else { throw new IllegalArgumentException("Booster generator: operator could not be parsed - " + mainCode); @@ -675,48 +674,48 @@ private static Predicate buildExtraPredicate(List operators) .or(CardRulesPredicates.splitType(CardSplitType.Modal) ), PaperCard::getRules); - } else if (operator.equalsIgnoreCase(BoosterSlots.LAND)) { toAdd = Predicates.compose(CardRulesPredicates.Presets.IS_LAND, PaperCard::getRules); - } else if (operator.equalsIgnoreCase(BoosterSlots.BASIC_LAND)) { toAdd = IPaperCard.Predicates.Presets.IS_BASIC_LAND; - } else if (operator.equalsIgnoreCase(BoosterSlots.TIME_SHIFTED)) { toAdd = IPaperCard.Predicates.Presets.IS_SPECIAL; - } else if (operator.equalsIgnoreCase(BoosterSlots.SPECIAL)) { toAdd = IPaperCard.Predicates.Presets.IS_SPECIAL; - } else if (operator.equalsIgnoreCase(BoosterSlots.MYTHIC)) { toAdd = IPaperCard.Predicates.Presets.IS_MYTHIC_RARE; - } else if (operator.equalsIgnoreCase(BoosterSlots.RARE)) { toAdd = IPaperCard.Predicates.Presets.IS_RARE; - } else if (operator.equalsIgnoreCase(BoosterSlots.UNCOMMON)) { toAdd = IPaperCard.Predicates.Presets.IS_UNCOMMON; - } else if (operator.equalsIgnoreCase(BoosterSlots.COMMON)) { toAdd = IPaperCard.Predicates.Presets.IS_COMMON; + } else if (operator.equalsIgnoreCase(BoosterSlots.LAND)) { toAdd = Predicates.compose(CardRulesPredicates.IS_LAND, PaperCard::getRules); + } else if (operator.equalsIgnoreCase(BoosterSlots.BASIC_LAND)) { toAdd = PaperCardPredicates.IS_BASIC_LAND; + } else if (operator.equalsIgnoreCase(BoosterSlots.TIME_SHIFTED)) { toAdd = PaperCardPredicates.IS_SPECIAL; + } else if (operator.equalsIgnoreCase(BoosterSlots.SPECIAL)) { toAdd = PaperCardPredicates.IS_SPECIAL; + } else if (operator.equalsIgnoreCase(BoosterSlots.MYTHIC)) { toAdd = PaperCardPredicates.IS_MYTHIC_RARE; + } else if (operator.equalsIgnoreCase(BoosterSlots.RARE)) { toAdd = PaperCardPredicates.IS_RARE; + } else if (operator.equalsIgnoreCase(BoosterSlots.UNCOMMON)) { toAdd = PaperCardPredicates.IS_UNCOMMON; + } else if (operator.equalsIgnoreCase(BoosterSlots.COMMON)) { toAdd = PaperCardPredicates.IS_COMMON; } else if (operator.startsWith("name(")) { operator = StringUtils.strip(operator.substring(4), "() "); String[] cardNames = TextUtil.splitWithParenthesis(operator, ',', '"', '"'); - toAdd = IPaperCard.Predicates.names(Lists.newArrayList(cardNames)); + toAdd = PaperCardPredicates.names(Lists.newArrayList(cardNames)); } else if (operator.startsWith("color(")) { operator = StringUtils.strip(operator.substring("color(".length() + 1), "()\" "); switch (operator.toLowerCase()) { case "black": - toAdd = Presets.IS_BLACK; + toAdd = PaperCardPredicates.IS_BLACK; break; case "blue": - toAdd = Presets.IS_BLUE; + toAdd = PaperCardPredicates.IS_BLUE; break; case "green": - toAdd = Presets.IS_GREEN; + toAdd = PaperCardPredicates.IS_GREEN; break; case "red": - toAdd = Presets.IS_RED; + toAdd = PaperCardPredicates.IS_RED; break; case "white": - toAdd = Presets.IS_WHITE; + toAdd = PaperCardPredicates.IS_WHITE; break; case "colorless": - toAdd = Presets.IS_COLORLESS; + toAdd = PaperCardPredicates.IS_COLORLESS; break; } } else if (operator.startsWith("fromSets(")) { operator = StringUtils.strip(operator.substring("fromSets(".length() + 1), "()\" "); String[] sets = operator.split(","); - toAdd = IPaperCard.Predicates.printedInSets(sets); + toAdd = PaperCardPredicates.printedInSets(sets); } else if (operator.startsWith("fromSheet(") && invert) { String sheetName = StringUtils.strip(operator.substring(9), "()\" "); Iterable cards = StaticData.instance().getPrintSheets().get(sheetName).toFlatList(); - toAdd = IPaperCard.Predicates.cards(Lists.newArrayList(cards)); + toAdd = PaperCardPredicates.cards(Lists.newArrayList(cards)); } if (toAdd == null) { diff --git a/forge-game/src/main/java/forge/game/Game.java b/forge-game/src/main/java/forge/game/Game.java index 55bdd34eedd..278f697beed 100644 --- a/forge-game/src/main/java/forge/game/Game.java +++ b/forge-game/src/main/java/forge/game/Game.java @@ -1099,7 +1099,7 @@ public Multimap chooseCardsForAnte(final boolean matchRarity) { private void chooseRandomCardsForAnte(final Player player, final Multimap anteed) { final CardCollectionView lib = player.getCardsIn(ZoneType.Library); - Predicate goodForAnte = CardPredicates.Presets.BASIC_LANDS.negate(); + Predicate goodForAnte = CardPredicates.BASIC_LANDS.negate(); Card ante = Aggregates.random(Iterables.filter(lib, goodForAnte)); if (ante == null) { getGameLog().add(GameLogEntryType.ANTE, "Only basic lands found. Will ante one of them"); diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index 126f9fa12f9..ad3653e9e86 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -817,14 +817,14 @@ private Card moveTo(final Zone zoneTo, Card c, Integer position, SpellAbility ca if (!stAb.hasParam("ValidAttacker") || (stAb.hasParam("ValidBlocker") && stAb.getParam("ValidBlocker").equals("Creature.Self"))) { continue; } - for (Card creature : Iterables.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES)) { + for (Card creature : Iterables.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.CREATURES)) { if (stAb.matchesValidParam("ValidAttacker", creature)) { creature.updateAbilityTextForView(); } } } if (stAb.checkMode(StaticAbilityCantAttackBlock.MinMaxBlockerMode)) { - for (Card creature : Iterables.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES)) { + for (Card creature : Iterables.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.CREATURES)) { if (stAb.matchesValidParam("ValidCard", creature)) { creature.updateAbilityTextForView(); } @@ -1431,7 +1431,7 @@ else if (c.hasBeenDealtDeathtouchDamage() || (c.getDamage() > 0 && c.getLethal() if (desCreats != null) { if (desCreats.size() > 1 && !orderedDesCreats) { - desCreats = CardLists.filter(desCreats, CardPredicates.Presets.CAN_BE_DESTROYED); + desCreats = CardLists.filter(desCreats, CardPredicates.CAN_BE_DESTROYED); if (!desCreats.isEmpty()) { desCreats = (CardCollection) GameActionUtil.orderCardsByTheirOwners(game, desCreats, ZoneType.Graveyard, null); } diff --git a/forge-game/src/main/java/forge/game/GameEntity.java b/forge-game/src/main/java/forge/game/GameEntity.java index e7b839253eb..efbd2ab7fb0 100644 --- a/forge-game/src/main/java/forge/game/GameEntity.java +++ b/forge-game/src/main/java/forge/game/GameEntity.java @@ -144,7 +144,7 @@ public int getPreventNextDamageTotalShields() { public final CardCollectionView getEnchantedBy() { // enchanted means attached by Aura - return CardLists.filter(getAttachedCards(), CardPredicates.Presets.AURA); + return CardLists.filter(getAttachedCards(), CardPredicates.AURA); } // doesn't include phased out cards @@ -176,7 +176,7 @@ public final boolean hasCardAttachments() { public final boolean isEnchanted() { // enchanted means attached by Aura - return Iterables.any(getAttachedCards(), CardPredicates.Presets.AURA); + return Iterables.any(getAttachedCards(), CardPredicates.AURA); } public final boolean hasCardAttachment(Card c) { diff --git a/forge-game/src/main/java/forge/game/GameFormat.java b/forge-game/src/main/java/forge/game/GameFormat.java index 4e9110b0521..10298834f56 100644 --- a/forge-game/src/main/java/forge/game/GameFormat.java +++ b/forge-game/src/main/java/forge/game/GameFormat.java @@ -25,8 +25,8 @@ import forge.card.CardRarity; import forge.deck.CardPool; import forge.deck.Deck; -import forge.item.IPaperCard; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.util.FileSection; import forge.util.FileUtil; import forge.util.Predicates; @@ -138,17 +138,17 @@ public GameFormat(final String fName, final Date effectiveDate, final Iterable buildFilter(boolean printed) { - Predicate p = IPaperCard.Predicates.names(this.getBannedCardNames()).negate(); + Predicate p = PaperCardPredicates.names(this.getBannedCardNames()).negate(); if (FormatSubType.ARENA.equals(this.getFormatSubType())) { - p = p.and(IPaperCard.Predicates.Presets.IS_UNREBALANCED.negate()); + p = p.and(PaperCardPredicates.IS_UNREBALANCED.negate()); } else { - p = p.and(IPaperCard.Predicates.Presets.IS_REBALANCED.negate()); + p = p.and(PaperCardPredicates.IS_REBALANCED.negate()); } if (!this.getAllowedSetCodes().isEmpty()) { p = p.and(printed ? - IPaperCard.Predicates.printedInSets(this.getAllowedSetCodes(), printed) : + PaperCardPredicates.printedInSets(this.getAllowedSetCodes(), printed) : StaticData.instance().getCommonCards().wasPrintedInSets(this.getAllowedSetCodes())); } if (!this.getAllowedRarities().isEmpty()) { @@ -159,7 +159,7 @@ protected Predicate buildFilter(boolean printed) { p = p.and(Predicates.or(crp)); } if (!this.getAdditionalCards().isEmpty()) { - p = p.or(IPaperCard.Predicates.names(this.getAdditionalCards())); + p = p.or(PaperCardPredicates.names(this.getAdditionalCards())); } return p; } diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index 735a1817f3d..a4e2b9b397c 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -2225,7 +2225,7 @@ public static int xCount(Card c, final String s, final CardTraitBase ctb) { if (sq[0].equals("EnchantedControllerCreatures")) { // maybe refactor into a Valid with ControlledBy int v = 0; if (c.getEnchantingCard() != null) { - v = CardLists.count(c.getEnchantingCard().getController().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); + v = CardLists.count(c.getEnchantingCard().getController().getCardsIn(ZoneType.Battlefield), CardPredicates.CREATURES); } return doXMath(v, expr, c, ctb); } @@ -3877,9 +3877,9 @@ private static CardCollectionView getCardListForXCount(final Card c, final Playe // Refined qualities // "Untapped Lands" - Count$UntappedTypeYouCtrl.Land - // if (sq[0].contains("Untapped")) { someCards = CardLists.filter(someCards, Presets.UNTAPPED); } + // if (sq[0].contains("Untapped")) { someCards = CardLists.filter(someCards, CardPredicates.UNTAPPED); } - // if (sq[0].contains("Tapped")) { someCards = CardLists.filter(someCards, Presets.TAPPED); } + // if (sq[0].contains("Tapped")) { someCards = CardLists.filter(someCards, CardPredicates.TAPPED); } // String sq0 = sq[0].toLowerCase(); // for (String color : MagicColor.Constant.ONLY_COLORS) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardEffect.java index 5136dbb9051..5bb6fbc1001 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardEffect.java @@ -17,7 +17,6 @@ import forge.game.card.CardCollectionView; import forge.game.card.CardLists; import forge.game.card.CardPredicates; -import forge.game.card.CardPredicates.Presets; import forge.game.player.Player; import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; @@ -119,7 +118,7 @@ public void resolve(SpellAbility sa) { boolean dontRevealToOwner = true; if (sa.hasParam("EachBasicType")) { // Get all lands, - List land = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Presets.LANDS); + List land = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.LANDS); String eachBasic = sa.getParam("EachBasicType"); if (eachBasic.equals("Controlled")) { land = CardLists.filterControlledBy(land, p); diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java index d8c34e1985a..f47ef140fd7 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java @@ -70,7 +70,7 @@ public void resolve(SpellAbility sa) { // Momir needs PaperCard //Collection cards = StaticData.instance().getCommonCards().getUniqueCards(); //Predicate cpp = Predicates.and( - // Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, PaperCard.FN_GET_RULES), + // Predicates.compose(CardRulesPredicates.IS_CREATURE, PaperCard.FN_GET_RULES), // Predicates.compose(CardRulesPredicates.cmc(ComparableOp.EQUALS, validAmount), PaperCard.FN_GET_RULES)); //cards = Lists.newArrayList(Iterables.filter(cards, cpp)); //if (!cards.isEmpty()) { chosen = Aggregates.random(cards).getName(); diff --git a/forge-game/src/main/java/forge/game/ability/effects/ConniveEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ConniveEffect.java index 58bd46a43a5..793d80adb54 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ConniveEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ConniveEffect.java @@ -78,7 +78,7 @@ public void resolve(SpellAbility sa) { p.drawCards(num, sa, moveParams); - CardCollection validDiscards = CardLists.filter(p.getCardsIn(ZoneType.Hand), CardPredicates.Presets.NON_TOKEN); + CardCollection validDiscards = CardLists.filter(p.getCardsIn(ZoneType.Hand), CardPredicates.NON_TOKEN); if (validDiscards.isEmpty() || !p.canDiscardBy(sa, true)) { // hand being empty unlikely, just to be safe continue; } diff --git a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java index 36dcce6617f..74f520a2704 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java @@ -156,11 +156,11 @@ public void resolve(final SpellAbility sa) { "X", Integer.toString(AbilityUtils.calculateAmount(host, "X", sa))); } if (StringUtils.containsIgnoreCase(valid, "creature")) { - Predicate cpp = Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, PaperCard::getRules); + Predicate cpp = Predicates.compose(CardRulesPredicates.IS_CREATURE, PaperCard::getRules); cards = Lists.newArrayList(Iterables.filter(cards, cpp)); } if (StringUtils.containsIgnoreCase(valid, "equipment")) { - Predicate cpp = Predicates.compose(CardRulesPredicates.Presets.IS_EQUIPMENT, PaperCard::getRules); + Predicate cpp = Predicates.compose(CardRulesPredicates.IS_EQUIPMENT, PaperCard::getRules); cards = Lists.newArrayList(Iterables.filter(cards, cpp)); } if (sa.hasParam("RandomCopied")) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/DestroyAllEffect.java b/forge-game/src/main/java/forge/game/ability/effects/DestroyAllEffect.java index 7e5795aadec..56ceaeb5980 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/DestroyAllEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/DestroyAllEffect.java @@ -82,7 +82,7 @@ public void resolve(SpellAbility sa) { return; } // exclude cards that can't be destroyed at this moment - list = CardLists.filter(list, CardPredicates.Presets.CAN_BE_DESTROYED); + list = CardLists.filter(list, CardPredicates.CAN_BE_DESTROYED); list = GameActionUtil.orderCardsByTheirOwners(game, list, ZoneType.Graveyard, sa); diff --git a/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java b/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java index fadd9dab249..1b6f8ddf9cf 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/InternalRadiationEffect.java @@ -29,7 +29,7 @@ public void resolve(SpellAbility sa) { final CardCollectionView milled = game.getAction().mill(new PlayerCollection(p), numRad, ZoneType.Graveyard, sa, moveParams); table.triggerChangesZoneAll(game, sa); - int n = CardLists.count(milled, CardPredicates.Presets.NON_LANDS); + int n = CardLists.count(milled, CardPredicates.NON_LANDS); if (StaticAbilityGainLifeRadiation.gainLifeRadiation(p)) { p.gainLife(n, sa.getHostCard(), sa); diff --git a/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java b/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java index 3ae63fd89c6..7bb160975e5 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java @@ -14,10 +14,7 @@ import forge.game.spellability.SpellAbility; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; -import forge.item.BoosterPack; -import forge.item.IPaperCard; -import forge.item.PaperCard; -import forge.item.SealedTemplate; +import forge.item.*; import forge.util.Aggregates; import forge.util.CardTranslation; import forge.util.Iterables; @@ -153,7 +150,7 @@ public void resolve(SpellAbility sa) { while (toMake > 0) { PaperCard pc; if (pack != null) { - pc = Iterables.getLast(Iterables.filter(pack, IPaperCard.Predicates.name(name))); + pc = Iterables.getLast(Iterables.filter(pack, PaperCardPredicates.name(name))); } else { pc = StaticData.instance().getCommonCards().getUniqueByName(name); } diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java index 0d3e0c3b5a6..543f76ffc7d 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java @@ -121,11 +121,11 @@ public void resolve(final SpellAbility sa) { } } else if (valid.equalsIgnoreCase("sorcery")) { cards = Lists.newArrayList(StaticData.instance().getCommonCards().getUniqueCards()); - final Predicate cpp = Predicates.compose(CardRulesPredicates.Presets.IS_SORCERY, PaperCard::getRules); + final Predicate cpp = Predicates.compose(CardRulesPredicates.IS_SORCERY, PaperCard::getRules); cards = Lists.newArrayList(Iterables.filter(cards, cpp)); } else if (valid.equalsIgnoreCase("instant")) { cards = Lists.newArrayList(StaticData.instance().getCommonCards().getUniqueCards()); - final Predicate cpp = Predicates.compose(CardRulesPredicates.Presets.IS_INSTANT, PaperCard::getRules); + final Predicate cpp = Predicates.compose(CardRulesPredicates.IS_INSTANT, PaperCard::getRules); cards = Lists.newArrayList(Iterables.filter(cards, cpp)); } if (sa.hasParam("RandomCopied")) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java index dbf3f8b3cb9..3feb0f4cc2e 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java @@ -30,7 +30,7 @@ public void resolve(final SpellAbility sa) { final String landType = sa.getParam("Clone"); List cards = Lists.newArrayList(StaticData.instance().getCommonCards().getUniqueCards()); if ("BasicLand".equals(landType)) { - final Predicate cpp = Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules); + final Predicate cpp = Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules); cards = Lists.newArrayList(Iterables.filter(cards, cpp)); } // current color of source card diff --git a/forge-game/src/main/java/forge/game/ability/effects/UntapEffect.java b/forge-game/src/main/java/forge/game/ability/effects/UntapEffect.java index 1a9485cdd91..03e180265e5 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/UntapEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/UntapEffect.java @@ -4,12 +4,7 @@ import forge.game.ability.AbilityKey; import forge.game.ability.AbilityUtils; import forge.game.ability.SpellAbilityEffect; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardUtil; -import forge.game.card.CardPredicates.Presets; +import forge.game.card.*; import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.trigger.TriggerType; @@ -102,7 +97,7 @@ private static void untapChoose(final SpellAbility sa, final boolean mandatory) valid, sa.getActivatingPlayer(), sa.getHostCard(), sa); // the few mandatory are handled differently if (!mandatory) { - list = CardLists.filter(list, Presets.TAPPED); + list = CardLists.filter(list, CardPredicates.TAPPED); } final CardCollectionView selected = p.getController().chooseCardsForEffect(list, sa, Localizer.getInstance().getMessage("lblSelectCardToUntap"), mandatory ? num : 0, num, !mandatory, null); diff --git a/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java b/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java index c8ded7f8eed..f731d60e56c 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java @@ -46,13 +46,13 @@ private Card getDungeonCard(SpellAbility sa, Player player, Map !c.getRules().isEnterableDungeon()); } String message = Localizer.getInstance().getMessage("lblChooseDungeon"); diff --git a/forge-game/src/main/java/forge/game/card/Card.java b/forge-game/src/main/java/forge/game/card/Card.java index 8e850a055f7..f87840afb71 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -3862,11 +3862,11 @@ public void resetMayPlayTurn() { } public final CardCollectionView getEquippedBy() { - return CardLists.filter(getAttachedCards(), CardPredicates.Presets.EQUIPMENT); + return CardLists.filter(getAttachedCards(), CardPredicates.EQUIPMENT); } public final boolean isEquipped() { - return Iterables.any(getAttachedCards(), CardPredicates.Presets.EQUIPMENT); + return Iterables.any(getAttachedCards(), CardPredicates.EQUIPMENT); } public final boolean isEquippedBy(Card c) { return this.hasCardAttachment(c); @@ -3876,11 +3876,11 @@ public final boolean isEquippedBy(final String cardName) { } public final CardCollectionView getFortifiedBy() { - return CardLists.filter(getAttachedCards(), CardPredicates.Presets.FORTIFICATION); + return CardLists.filter(getAttachedCards(), CardPredicates.FORTIFICATION); } public final boolean isFortified() { - return Iterables.any(getAttachedCards(), CardPredicates.Presets.FORTIFICATION); + return Iterables.any(getAttachedCards(), CardPredicates.FORTIFICATION); } public final boolean isFortifiedBy(Card c) { // 301.5e + 301.6 diff --git a/forge-game/src/main/java/forge/game/card/CardPredicates.java b/forge-game/src/main/java/forge/game/card/CardPredicates.java index 62ac3ed4cb9..f1c2b62168a 100644 --- a/forge-game/src/main/java/forge/game/card/CardPredicates.java +++ b/forge-game/src/main/java/forge/game/card/CardPredicates.java @@ -302,109 +302,41 @@ public static Predicate isAttractionWithLight(int light) { return c -> c.isAttraction() && c.getAttractionLights().contains(light); } - public static class Presets { - - /** - * a Predicate to get all cards that are tapped. - */ - public static final Predicate TAPPED = Card::isTapped; - - public static final Predicate FACE_DOWN = Card::isFaceDown; - - /** - * a Predicate to get all cards that are untapped. - */ - public static final Predicate UNTAPPED = Card::isUntapped; - - public static final Predicate CAN_TAP = Card::canTap; - - public static final Predicate CAN_CREW = Card::canCrew; - /** - * a Predicate to get all creatures. - */ - public static final Predicate CREATURES = Card::isCreature; - public static final Predicate NON_CREATURES = c -> !c.isCreature(); - - /** - * a Predicate to get all enchantments. - */ - public static final Predicate ENCHANTMENTS = Card::isEnchantment; - /** - * a Predicate to get all aura. - */ - public static final Predicate AURA = Card::isAura; - /** - * a Predicate to get all equipment. - */ - public static final Predicate EQUIPMENT = Card::isEquipment; - /** - * a Predicate to get all fortification. - */ - public static final Predicate FORTIFICATION = Card::isFortification; - - /** - * a Predicate to get all curse. - */ - public static final Predicate CURSE = Card::isCurse; - - /** - * a Predicate to get all unenchanted cards in a list. - */ - public static final Predicate UNENCHANTED = c -> !c.isEnchanted(); - /** - * a Predicate to get all enchanted cards in a list. - */ - public static final Predicate ENCHANTED = GameEntity::isEnchanted; - /** - * a Predicate to get all nontoken cards. - */ - public static final Predicate NON_TOKEN = c -> !(c.isToken() || c.isTokenCard()); - /** - * a Predicate to get all token cards. - */ - public static final Predicate TOKEN = c -> c.isToken() || c.isTokenCard(); - /** - * a Predicate to get all basicLands. - */ - public static final Predicate BASIC_LANDS = c -> { - // the isBasicLand() check here may be sufficient... - return c.isLand() && c.isBasicLand(); - }; - public static final Predicate NONBASIC_LANDS = c -> c.isLand() && !c.isBasicLand(); - /** - * a Predicate to get all artifacts. - */ - public static final Predicate ARTIFACTS = Card::isArtifact; - /** - * a Predicate to get all nonartifacts. - */ - public static final Predicate NON_ARTIFACTS = c -> !c.isArtifact(); - public static final Predicate INSTANTS_AND_SORCERIES = Card::isInstantOrSorcery; - /** - * a Predicate to get all lands. - */ - public static final Predicate LANDS = Card::isLand; - public static final Predicate NON_LANDS = c -> !c.isLand(); - /** - * a Predicate to get all mana-producing lands. - */ - public static final Predicate LANDS_PRODUCING_MANA = c -> c.isBasicLand() || (c.isLand() && !c.getManaAbilities().isEmpty()); - /** - * a Predicate to get all permanents. - */ - public static final Predicate PERMANENTS = Card::isPermanent; - /** - * a Predicate to get all nonland permanents. - */ - public static final Predicate NONLAND_PERMANENTS = c -> c.isPermanent() && !c.isLand(); - - public static final Predicate hasFirstStrike = c -> c.isCreature() && (c.hasFirstStrike() || c.hasDoubleStrike()); - public static final Predicate hasSecondStrike = c -> c.isCreature() && (!c.hasFirstStrike() || c.hasDoubleStrike()); - public static final Predicate SNOW_LANDS = c -> c.isLand() && c.isSnow(); - public static final Predicate PLANESWALKERS = Card::isPlaneswalker; - public static final Predicate BATTLES = Card::isBattle; - public static final Predicate CAN_BE_DESTROYED = Card::canBeDestroyed; - public static final Predicate ATTRACTIONS = Card::isAttraction; - } - + public static final Predicate TAPPED = Card::isTapped; + public static final Predicate FACE_DOWN = Card::isFaceDown; + public static final Predicate UNTAPPED = Card::isUntapped; + public static final Predicate CAN_TAP = Card::canTap; + public static final Predicate CAN_CREW = Card::canCrew; + public static final Predicate CREATURES = Card::isCreature; + public static final Predicate NON_CREATURES = c -> !c.isCreature(); + public static final Predicate ENCHANTMENTS = Card::isEnchantment; + public static final Predicate AURA = Card::isAura; + public static final Predicate EQUIPMENT = Card::isEquipment; + public static final Predicate FORTIFICATION = Card::isFortification; + public static final Predicate CURSE = Card::isCurse; + public static final Predicate UNENCHANTED = c -> !c.isEnchanted(); + public static final Predicate ENCHANTED = GameEntity::isEnchanted; + public static final Predicate NON_TOKEN = c -> !(c.isToken() || c.isTokenCard()); + public static final Predicate TOKEN = c -> c.isToken() || c.isTokenCard(); + public static final Predicate BASIC_LANDS = c -> { + // the isBasicLand() check here may be sufficient... + return c.isLand() && c.isBasicLand(); + }; + public static final Predicate NONBASIC_LANDS = c -> c.isLand() && !c.isBasicLand(); + + public static final Predicate ARTIFACTS = Card::isArtifact; + public static final Predicate INSTANTS_AND_SORCERIES = Card::isInstantOrSorcery; + + public static final Predicate LANDS = Card::isLand; + public static final Predicate NON_LANDS = c -> !c.isLand(); + public static final Predicate LANDS_PRODUCING_MANA = c -> c.isBasicLand() || (c.isLand() && !c.getManaAbilities().isEmpty()); + public static final Predicate PERMANENTS = Card::isPermanent; + public static final Predicate NONLAND_PERMANENTS = c -> c.isPermanent() && !c.isLand(); + public static final Predicate hasFirstStrike = c -> c.isCreature() && (c.hasFirstStrike() || c.hasDoubleStrike()); + public static final Predicate hasSecondStrike = c -> c.isCreature() && (!c.hasFirstStrike() || c.hasDoubleStrike()); + public static final Predicate SNOW_LANDS = c -> c.isLand() && c.isSnow(); + public static final Predicate PLANESWALKERS = Card::isPlaneswalker; + public static final Predicate BATTLES = Card::isBattle; + public static final Predicate CAN_BE_DESTROYED = Card::canBeDestroyed; + public static final Predicate ATTRACTIONS = Card::isAttraction; } diff --git a/forge-game/src/main/java/forge/game/card/CardProperty.java b/forge-game/src/main/java/forge/game/card/CardProperty.java index a49a851280c..e1f99498f7c 100644 --- a/forge-game/src/main/java/forge/game/card/CardProperty.java +++ b/forge-game/src/main/java/forge/game/card/CardProperty.java @@ -14,7 +14,6 @@ import forge.game.GameEntity; import forge.game.ability.AbilityKey; import forge.game.ability.AbilityUtils; -import forge.game.card.CardPredicates.Presets; import forge.game.combat.AttackRequirement; import forge.game.combat.AttackingBand; import forge.game.combat.Combat; @@ -646,7 +645,7 @@ public static boolean cardHasProperty(Card card, String property, Player sourceC return false; } } else if (property.startsWith("TopGraveyardCreature")) { - CardCollection cards = CardLists.filter(card.getOwner().getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES); + CardCollection cards = CardLists.filter(card.getOwner().getCardsIn(ZoneType.Graveyard), CardPredicates.CREATURES); Collections.reverse(cards); if (cards.isEmpty() || !card.equals(cards.get(0))) { return false; @@ -931,7 +930,7 @@ public static boolean cardHasProperty(Card card, String property, Player sourceC return false; } else if (restriction.equals("NonToken")) { return !CardLists.filter(game.getCardsIn(ZoneType.Battlefield), - Presets.NON_TOKEN, CardPredicates.sharesNameWith(card)).isEmpty(); + CardPredicates.NON_TOKEN, CardPredicates.sharesNameWith(card)).isEmpty(); } else if (restriction.equals("TriggeredCard")) { if (!(spellAbility instanceof SpellAbility)) { System.out.println("Looking at TriggeredCard but no SA?"); @@ -1305,7 +1304,7 @@ else if (prop.isEmpty() && dmgSource.equalsWithGameTimestamp(source)) { return false; } } else if (property.startsWith("greatestPower")) { - CardCollectionView cards = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Presets.CREATURES); + CardCollectionView cards = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.CREATURES); if (property.contains("ControlledBy")) { FCollectionView p = AbilityUtils.getDefinedPlayers(source, property.split("ControlledBy")[1], spellAbility); cards = CardLists.filterControlledBy(cards, p); @@ -1319,14 +1318,14 @@ else if (prop.isEmpty() && dmgSource.equalsWithGameTimestamp(source)) { } } } else if (property.startsWith("yardGreatestPower")) { - final CardCollectionView cards = CardLists.filter(sourceController.getCardsIn(ZoneType.Graveyard), Presets.CREATURES); + final CardCollectionView cards = CardLists.filter(sourceController.getCardsIn(ZoneType.Graveyard), CardPredicates.CREATURES); for (final Card crd : cards) { if (crd.getNetPower() > card.getNetPower()) { return false; } } } else if (property.startsWith("leastPower")) { - CardCollectionView cards = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Presets.CREATURES); + CardCollectionView cards = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.CREATURES); if (property.contains("ControlledBy")) { FCollectionView p = AbilityUtils.getDefinedPlayers(source, property.split("ControlledBy")[1], spellAbility); cards = CardLists.filterControlledBy(cards, p); @@ -1340,7 +1339,7 @@ else if (prop.isEmpty() && dmgSource.equalsWithGameTimestamp(source)) { } } } else if (property.startsWith("leastToughness")) { - CardCollectionView cards = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Presets.CREATURES); + CardCollectionView cards = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.CREATURES); if (property.contains("ControlledBy")) { // 4/25/2023 only used for adventure mode Death Ring FCollectionView p = AbilityUtils.getDefinedPlayers(source, property.split("ControlledBy")[1], spellAbility); cards = CardLists.filterControlledBy(cards, p); @@ -1363,7 +1362,7 @@ else if (prop.isEmpty() && dmgSource.equalsWithGameTimestamp(source)) { } if ("NonLandPermanent".equals(prop)) { - cards = CardLists.filter(cards, CardPredicates.Presets.NONLAND_PERMANENTS); + cards = CardLists.filter(cards, CardPredicates.NONLAND_PERMANENTS); } else { cards = CardLists.getType(cards, prop); } 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 1c572a7c078..204aa54a42a 100644 --- a/forge-game/src/main/java/forge/game/combat/Combat.java +++ b/forge-game/src/main/java/forge/game/combat/Combat.java @@ -222,11 +222,11 @@ public final FCollectionView getDefendingPlayers() { } public final CardCollection getDefendingPlaneswalkers() { - return CardLists.filter(Iterables.filter(attackableEntries, Card.class), CardPredicates.Presets.PLANESWALKERS); + return CardLists.filter(Iterables.filter(attackableEntries, Card.class), CardPredicates.PLANESWALKERS); } public final CardCollection getDefendingBattles() { - return CardLists.filter(Iterables.filter(attackableEntries, Card.class), CardPredicates.Presets.BATTLES); + return CardLists.filter(Iterables.filter(attackableEntries, Card.class), CardPredicates.BATTLES); } public final Map getAttackersAndDefenders() { diff --git a/forge-game/src/main/java/forge/game/combat/CombatUtil.java b/forge-game/src/main/java/forge/game/combat/CombatUtil.java index 03013e36dde..aacc6d84af2 100644 --- a/forge-game/src/main/java/forge/game/combat/CombatUtil.java +++ b/forge-game/src/main/java/forge/game/combat/CombatUtil.java @@ -70,7 +70,7 @@ public static FCollectionView getAllPossibleDefenders(final Player p // Relevant battles (protected by the attacking player's opponents) final Game game = playerWhoAttacks.getGame(); - final CardCollection battles = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.BATTLES); + final CardCollection battles = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.BATTLES); for (Card battle : battles) { if (battle.getType().hasSubtype("Siege") && battle.getProtectingPlayer().isOpponentOf(playerWhoAttacks)) { defenders.add(battle); diff --git a/forge-game/src/main/java/forge/game/cost/CostAdjustment.java b/forge-game/src/main/java/forge/game/cost/CostAdjustment.java index aa8133afe2f..7542f2fdc52 100644 --- a/forge-game/src/main/java/forge/game/cost/CostAdjustment.java +++ b/forge-game/src/main/java/forge/game/cost/CostAdjustment.java @@ -338,11 +338,11 @@ private static void adjustCostByConvokeOrImprovise(ManaCostBeingPaid cost, final final Player activator = sa.getActivatingPlayer(); CardCollectionView untappedCards = CardLists.filter(activator.getCardsIn(ZoneType.Battlefield), - CardPredicates.Presets.CAN_TAP); + CardPredicates.CAN_TAP); if (improvise) { - untappedCards = CardLists.filter(untappedCards, CardPredicates.Presets.ARTIFACTS); + untappedCards = CardLists.filter(untappedCards, CardPredicates.ARTIFACTS); } else { - untappedCards = CardLists.filter(untappedCards, CardPredicates.Presets.CREATURES); + untappedCards = CardLists.filter(untappedCards, CardPredicates.CREATURES); } Map convokedCards = activator.getController().chooseCardsForConvokeOrImprovise(sa, diff --git a/forge-game/src/main/java/forge/game/cost/CostTapType.java b/forge-game/src/main/java/forge/game/cost/CostTapType.java index 509f402adf0..277c96b1706 100644 --- a/forge-game/src/main/java/forge/game/cost/CostTapType.java +++ b/forge-game/src/main/java/forge/game/cost/CostTapType.java @@ -20,7 +20,6 @@ import forge.card.CardType; import forge.game.ability.AbilityKey; import forge.game.card.*; -import forge.game.card.CardPredicates.Presets; import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.trigger.TriggerType; @@ -67,7 +66,7 @@ public Integer getMaxAmountX(SpellAbility ability, Player payer, final boolean e if (!canTapSource) { typeList.remove(source); } - typeList = CardLists.filter(typeList, ability.isCrew() ? Presets.CAN_CREW : Presets.CAN_TAP); + typeList = CardLists.filter(typeList, ability.isCrew() ? CardPredicates.CAN_CREW : CardPredicates.CAN_TAP); return typeList.size(); } @@ -165,7 +164,7 @@ public final boolean canPay(final SpellAbility ability, final Player payer, fina if (!canTapSource) { typeList.remove(source); } - typeList = CardLists.filter(typeList, ability.isCrew() ? Presets.CAN_CREW : Presets.CAN_TAP); + typeList = CardLists.filter(typeList, ability.isCrew() ? CardPredicates.CAN_CREW : CardPredicates.CAN_TAP); if (sameType) { for (final Card card : typeList) { diff --git a/forge-game/src/main/java/forge/game/cost/CostUntapType.java b/forge-game/src/main/java/forge/game/cost/CostUntapType.java index 4fc1cbd34bc..1966b4e6463 100644 --- a/forge-game/src/main/java/forge/game/cost/CostUntapType.java +++ b/forge-game/src/main/java/forge/game/cost/CostUntapType.java @@ -19,11 +19,7 @@ import com.google.common.collect.Maps; import forge.game.ability.AbilityKey; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates.Presets; +import forge.game.card.*; import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.trigger.TriggerType; @@ -90,7 +86,7 @@ public final boolean canPay(final SpellAbility ability, final Player payer, fina if (!canUntapSource) { typeList.remove(source); } - typeList = CardLists.filter(typeList, Presets.TAPPED); + typeList = CardLists.filter(typeList, CardPredicates.TAPPED); final int amount = this.getAbilityAmount(ability); return (typeList.size() != 0) && (typeList.size() >= amount); diff --git a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java index 83a6245cead..a84b3ff50a4 100644 --- a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java +++ b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java @@ -26,7 +26,6 @@ import forge.game.ability.effects.AddTurnEffect; import forge.game.ability.effects.SkipPhaseEffect; import forge.game.card.*; -import forge.game.card.CardPredicates.Presets; import forge.game.combat.Combat; import forge.game.combat.CombatUtil; import forge.game.cost.CostEnlist; @@ -185,7 +184,7 @@ private void advanceToNextPhase() { game.getAction().resetActivationsPerTurn(); - final int lands = CardLists.count(playerTurn.getLandsInPlay(), Presets.UNTAPPED); + final int lands = CardLists.count(playerTurn.getLandsInPlay(), CardPredicates.UNTAPPED); playerTurn.setNumPowerSurgeLands(lands); } //update tokens @@ -287,7 +286,7 @@ private void onPhaseBegin() { } } // roll for attractions if we have any - if (Iterables.any(playerTurn.getCardsIn(ZoneType.Battlefield), Presets.ATTRACTIONS)) { + if (Iterables.any(playerTurn.getCardsIn(ZoneType.Battlefield), CardPredicates.ATTRACTIONS)) { playerTurn.rollToVisitAttractions(); } table.replaceCounterEffect(game, null, false); diff --git a/forge-game/src/main/java/forge/game/phase/Untap.java b/forge-game/src/main/java/forge/game/phase/Untap.java index 62ff222810c..b1a000dd657 100644 --- a/forge-game/src/main/java/forge/game/phase/Untap.java +++ b/forge-game/src/main/java/forge/game/phase/Untap.java @@ -34,7 +34,6 @@ import forge.game.card.CardCollection; import forge.game.card.CardLists; import forge.game.card.CardPredicates; -import forge.game.card.CardPredicates.Presets; import forge.game.card.CardZoneTable; import forge.game.keyword.Keyword; import forge.game.keyword.KeywordInterface; @@ -113,7 +112,7 @@ public static boolean canUntap(final Card c) { */ private void doUntap() { final Player player = game.getPhaseHandler().getPlayerTurn(); - final Predicate tappedCanUntap = Presets.TAPPED.and(CANUNTAP); + final Predicate tappedCanUntap = CardPredicates.TAPPED.and(CANUNTAP); Map untapMap = Maps.newHashMap(); CardCollection list = new CardCollection(player.getCardsIn(ZoneType.Battlefield)); diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index 20428eb251b..4d0927210bb 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -30,7 +30,6 @@ import forge.game.ability.effects.DetachedCardEffect; import forge.game.ability.effects.RollDiceEffect; import forge.game.card.*; -import forge.game.card.CardPredicates.Presets; import forge.game.event.*; import forge.game.keyword.*; import forge.game.keyword.KeywordCollection.KeywordCollectionView; @@ -63,7 +62,6 @@ import java.util.*; import java.util.Map.Entry; -import java.util.function.Predicate; /** *

@@ -2084,7 +2082,7 @@ public final boolean isInGame() { } public final boolean hasMetalcraft() { - return CardLists.count(getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.ARTIFACTS) >= 3; + return CardLists.count(getCardsIn(ZoneType.Battlefield), CardPredicates.ARTIFACTS) >= 3; } public final boolean hasDesert() { @@ -2123,7 +2121,7 @@ public final boolean hasDelirium() { } public final boolean hasLandfall() { - return Iterables.any(getZone(ZoneType.Battlefield).getCardsAddedThisTurn(null), CardPredicates.Presets.LANDS); + return Iterables.any(getZone(ZoneType.Battlefield).getCardsAddedThisTurn(null), CardPredicates.LANDS); } public boolean hasFerocious() { @@ -2436,29 +2434,29 @@ public void onGameOver() { * use to get a list of creatures in play for a given player. */ public CardCollection getCreaturesInPlay() { - return CardLists.filter(getCardsIn(ZoneType.Battlefield), Presets.CREATURES); + return CardLists.filter(getCardsIn(ZoneType.Battlefield), CardPredicates.CREATURES); } public CardCollection getPlaneswalkersInPlay() { - return CardLists.filter(getCardsIn(ZoneType.Battlefield), Presets.PLANESWALKERS); + return CardLists.filter(getCardsIn(ZoneType.Battlefield), CardPredicates.PLANESWALKERS); } public CardCollection getBattlesInPlay() { - return CardLists.filter(getCardsIn(ZoneType.Battlefield), Presets.BATTLES); + return CardLists.filter(getCardsIn(ZoneType.Battlefield), CardPredicates.BATTLES); } /** * use to get a list of tokens in play for a given player. */ public CardCollection getTokensInPlay() { - return CardLists.filter(getCardsIn(ZoneType.Battlefield), Presets.TOKEN); + return CardLists.filter(getCardsIn(ZoneType.Battlefield), CardPredicates.TOKEN); } /** * use to get a list of all lands a given player has on the battlefield. */ public CardCollection getLandsInPlay() { - return CardLists.filter(getCardsIn(ZoneType.Battlefield), Presets.LANDS); + return CardLists.filter(getCardsIn(ZoneType.Battlefield), CardPredicates.LANDS); } public boolean isCardInPlay(final String cardName) { @@ -3596,7 +3594,7 @@ public final int countExaltedBonus() { } public final boolean isCursed() { - return CardLists.count(getAttachedCards(), CardPredicates.Presets.CURSE) > 0; + return CardLists.count(getAttachedCards(), CardPredicates.CURSE) > 0; } public boolean canDiscardBy(SpellAbility sa, final boolean effect) { diff --git a/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java b/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java index 441d634e0b1..5831a95215b 100644 --- a/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java +++ b/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java @@ -24,12 +24,12 @@ import java.util.TreeMap; import java.util.function.Predicate; +import forge.item.PaperCardPredicates; import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; import forge.card.CardEdition; -import forge.item.IPaperCard; import forge.item.PaperCard; import forge.localinstance.properties.ForgeConstants; import forge.model.FModel; @@ -374,7 +374,7 @@ private void analyzeCardPicsSetDir(final File root) { cardFileNamesBySet = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); for (final CardEdition ce : FModel.getMagicDb().getEditions()) { final Map cardFileNames = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); - final Predicate filter = IPaperCard.Predicates.printedInSet(ce.getCode()); + final Predicate filter = PaperCardPredicates.printedInSet(ce.getCode()); addSetCards(cardFileNames, FModel.getMagicDb().getCommonCards().getAllCards(), filter); addSetCards(cardFileNames, FModel.getMagicDb().getVariantCards().getAllCards(), filter); cardFileNamesBySet.put(ce.getCode2(), cardFileNames); diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java index 224ce72e726..ffd3399bb6f 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java @@ -33,7 +33,7 @@ protected Predicate buildPredicate() { if (predicate == null) { return x -> true; } - predicate = predicate.and(CardRulesPredicates.Presets.IS_CREATURE); + predicate = predicate.and(CardRulesPredicates.IS_CREATURE); return Predicates.compose(predicate, PaperCard::getRules); } } diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java index d6d186c07fc..6296314e184 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java @@ -33,7 +33,7 @@ protected Predicate buildPredicate() { if (predicate == null) { return x -> true; } - predicate = predicate.and(CardRulesPredicates.Presets.IS_CREATURE); + predicate = predicate.and(CardRulesPredicates.IS_CREATURE); return Predicates.compose(predicate, PaperCard::getRules); } } diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java index 20a289ea65c..240866dda5c 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java @@ -59,7 +59,7 @@ protected void addToggleButton(JPanel widget, final StatTypes st) { protected boolean showUnsupportedItem(U item) { FLabel btnPackOrDeck = buttonMap.get(StatTypes.PACK_OR_DECK); //support special pack/deck case if (btnPackOrDeck != null && btnPackOrDeck.isSelected()) { - return ItemPredicate.Presets.IS_PACK_OR_DECK.test(item); + return ItemPredicate.IS_PACK_OR_DECK.test(item); } return false; } @@ -70,7 +70,7 @@ public void afterFiltersApplied() { FLabel btnPackOrDeck = buttonMap.get(StatTypes.PACK_OR_DECK); if (btnPackOrDeck != null) { //support special pack/deck case - int count = items.countAll(ItemPredicate.Presets.IS_PACK_OR_DECK, InventoryItem.class); + int count = items.countAll(ItemPredicate.IS_PACK_OR_DECK, InventoryItem.class); btnPackOrDeck.setText(String.valueOf(count)); } diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java index 638f70239b8..cd2b71af8c7 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java @@ -70,7 +70,7 @@ private void newRandomCon final Deck randomDeck = new Deck(); - final Predicate notBasicLand = Predicates.compose(CardRulesPredicates.Presets.NOT_BASIC_LAND, PaperCard::getRules); + final Predicate notBasicLand = Predicates.compose(CardRulesPredicates.NOT_BASIC_LAND, PaperCard::getRules); final Iterable source = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards(), notBasicLand); randomDeck.getMain().addAllFlat(Aggregates.random(source, 15 * 5)); diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java index 114092f7fdb..39fda0ed516 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java @@ -82,14 +82,14 @@ public CEditorCommander(final CDetailPicture cDetailPicture, GameType gameType0) CardDb commonCards = FModel.getMagicDb().getCommonCards(); if (gameType == GameType.Brawl){ GameFormat format = FModel.getFormats().get("Brawl"); - Predicate commanderFilter = CardRulesPredicates.Presets.CAN_BE_BRAWL_COMMANDER; + Predicate commanderFilter = CardRulesPredicates.CAN_BE_BRAWL_COMMANDER; commanderPool = ItemPool.createFrom(commonCards.getAllCardsNoAlt(format.getFilterPrinted().and(Predicates.compose(commanderFilter, PaperCard::getRules))), PaperCard.class); normalPool = ItemPool.createFrom(format.getAllCards(), PaperCard.class); } else { Predicate commanderFilter = gameType == GameType.Oathbreaker - ? CardRulesPredicates.Presets.CAN_BE_OATHBREAKER.or(CardRulesPredicates.Presets.CAN_BE_SIGNATURE_SPELL) - : CardRulesPredicates.Presets.CAN_BE_COMMANDER; + ? CardRulesPredicates.CAN_BE_OATHBREAKER.or(CardRulesPredicates.CAN_BE_SIGNATURE_SPELL) + : CardRulesPredicates.CAN_BE_COMMANDER; commanderPool = ItemPool.createFrom(commonCards.getAllCardsNoAlt(Predicates.compose(commanderFilter, PaperCard::getRules)),PaperCard.class); normalPool = ItemPool.createFrom(commonCards.getAllCardsNoAlt(), PaperCard.class); } diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java index 74673727bd2..a9f3d572acf 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java @@ -346,7 +346,7 @@ private Deck getDeck(){ } private ItemPool getCommanderCardPool(){ - Predicate commanderPredicate = Predicates.compose(CardRulesPredicates.Presets.CAN_BE_COMMANDER, PaperCard::getRules); + Predicate commanderPredicate = Predicates.compose(CardRulesPredicates.CAN_BE_COMMANDER, PaperCard::getRules); return getRemainingCardPool().getFilteredPool(commanderPredicate); } diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java index 25f20ae4cf1..b57bed33111 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java @@ -76,16 +76,16 @@ private void analyze() { // Hack-ish: avoid /0 cases, but still populate labels :) if (total == 0) { total = 1; } - setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblCreature(), deck, CardRulesPredicates.Presets.IS_CREATURE, total); - setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblLand(), deck, CardRulesPredicates.Presets.IS_LAND, total); - setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblEnchantment(), deck, CardRulesPredicates.Presets.IS_ENCHANTMENT, total); - setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblArtifact(), deck, CardRulesPredicates.Presets.IS_ARTIFACT, total); - setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblInstant(), deck, CardRulesPredicates.Presets.IS_INSTANT, total); - setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblSorcery(), deck, CardRulesPredicates.Presets.IS_SORCERY, total); - setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblPlaneswalker(), deck, CardRulesPredicates.Presets.IS_PLANESWALKER, total); - - setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblMulti(), deck, CardRulesPredicates.Presets.IS_MULTICOLOR, total); - setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblColorless(), deck, CardRulesPredicates.Presets.IS_COLORLESS, total); + setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblCreature(), deck, CardRulesPredicates.IS_CREATURE, total); + setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblLand(), deck, CardRulesPredicates.IS_LAND, total); + setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblEnchantment(), deck, CardRulesPredicates.IS_ENCHANTMENT, total); + setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblArtifact(), deck, CardRulesPredicates.IS_ARTIFACT, total); + setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblInstant(), deck, CardRulesPredicates.IS_INSTANT, total); + setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblSorcery(), deck, CardRulesPredicates.IS_SORCERY, total); + setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblPlaneswalker(), deck, CardRulesPredicates.IS_PLANESWALKER, total); + + setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblMulti(), deck, CardRulesPredicates.IS_MULTICOLOR, total); + setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblColorless(), deck, CardRulesPredicates.IS_COLORLESS, total); setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblBlack(), deck, CardRulesPredicates.isMonoColor(MagicColor.BLACK), total); setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblBlue(), deck, CardRulesPredicates.isMonoColor(MagicColor.BLUE), total); setLabelValue(VStatistics.SINGLETON_INSTANCE.getLblGreen(), deck, CardRulesPredicates.isMonoColor(MagicColor.GREEN), total); diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java index 7fe9be51257..7d54cecf340 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java @@ -57,16 +57,16 @@ else if (token.getTokenSection() == DeckSection.Commander) // Hack-ish: avoid /0 cases, but still populate labels :) if (total == 0) { total = 1; } - setLabelValue(this.view.getLblCreature(), deck, CardRulesPredicates.Presets.IS_CREATURE, total); - setLabelValue(this.view.getLblLand(), deck, CardRulesPredicates.Presets.IS_LAND, total); - setLabelValue(this.view.getLblEnchantment(), deck, CardRulesPredicates.Presets.IS_ENCHANTMENT, total); - setLabelValue(this.view.getLblArtifact(), deck, CardRulesPredicates.Presets.IS_ARTIFACT, total); - setLabelValue(this.view.getLblInstant(), deck, CardRulesPredicates.Presets.IS_INSTANT, total); - setLabelValue(this.view.getLblSorcery(), deck, CardRulesPredicates.Presets.IS_SORCERY, total); - setLabelValue(this.view.getLblPlaneswalker(), deck, CardRulesPredicates.Presets.IS_PLANESWALKER, total); - - setLabelValue(this.view.getLblMulti(), deck, CardRulesPredicates.Presets.IS_MULTICOLOR, total); - setLabelValue(this.view.getLblColorless(), deck, CardRulesPredicates.Presets.IS_COLORLESS, total); + setLabelValue(this.view.getLblCreature(), deck, CardRulesPredicates.IS_CREATURE, total); + setLabelValue(this.view.getLblLand(), deck, CardRulesPredicates.IS_LAND, total); + setLabelValue(this.view.getLblEnchantment(), deck, CardRulesPredicates.IS_ENCHANTMENT, total); + setLabelValue(this.view.getLblArtifact(), deck, CardRulesPredicates.IS_ARTIFACT, total); + setLabelValue(this.view.getLblInstant(), deck, CardRulesPredicates.IS_INSTANT, total); + setLabelValue(this.view.getLblSorcery(), deck, CardRulesPredicates.IS_SORCERY, total); + setLabelValue(this.view.getLblPlaneswalker(), deck, CardRulesPredicates.IS_PLANESWALKER, total); + + setLabelValue(this.view.getLblMulti(), deck, CardRulesPredicates.IS_MULTICOLOR, total); + setLabelValue(this.view.getLblColorless(), deck, CardRulesPredicates.IS_COLORLESS, total); setLabelValue(this.view.getLblBlack(), deck, CardRulesPredicates.isMonoColor(MagicColor.BLACK), total); setLabelValue(this.view.getLblBlue(), deck, CardRulesPredicates.isMonoColor(MagicColor.BLUE), total); setLabelValue(this.view.getLblGreen(), deck, CardRulesPredicates.isMonoColor(MagicColor.GREEN), total); diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java index 43f55d30bfd..763c8f9388f 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java @@ -77,8 +77,8 @@ protected void initializeCards(){ Iterable filtered= Iterables.filter(cards, Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard::getRules) - .and(Predicates.compose(CardRulesPredicates.Presets.IS_PLANESWALKER, PaperCard::getRules)) - //.and(Predicates.compose(CardRulesPredicates.Presets.IS_LEGENDARY, PaperCard::getRules)) + .and(Predicates.compose(CardRulesPredicates.IS_PLANESWALKER, PaperCard::getRules)) + //.and(Predicates.compose(CardRulesPredicates.IS_LEGENDARY, PaperCard::getRules)) .and(gameFormat.getFilterPrinted()) ); diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java index 7a2534bfc25..8ec054c963b 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java @@ -107,7 +107,7 @@ protected void initializeCards(){ Iterable filtered= Iterables.filter(cards, Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard::getRules) - .and(Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard::getRules)) + .and(Predicates.compose(CardRulesPredicates.IS_NON_LAND, PaperCard::getRules)) .and(gameFormat.getFilterPrinted()) ); diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java index 59d110880b1..9c90a7ca876 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java @@ -80,7 +80,7 @@ protected void initializeCards(){ Iterable filteredTribe= Iterables.filter(cards, Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard::getRules) .and(Predicates.compose(CardRulesPredicates.hasCreatureType("Pirate"), PaperCard::getRules)) - .and(Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, PaperCard::getRules)) + .and(Predicates.compose(CardRulesPredicates.IS_CREATURE, PaperCard::getRules)) .and(gameFormat.getFilterPrinted()) ); diff --git a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java index fffc91daedb..af16285b3cd 100644 --- a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java +++ b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java @@ -481,7 +481,7 @@ public Array getRewards() { if(data.rewards != null) { //Collect standard rewards. Deck enemyDeck = Current.latestDeck(); // By popular demand, remove basic lands from the reward pool. - CardPool deckNoBasicLands = enemyDeck.getMain().getFilteredPool(Predicates.compose(CardRulesPredicates.Presets.NOT_BASIC_LAND, PaperCard::getRules)); + CardPool deckNoBasicLands = enemyDeck.getMain().getFilteredPool(Predicates.compose(CardRulesPredicates.NOT_BASIC_LAND, PaperCard::getRules)); for (RewardData rdata : data.rewards) { ret.addAll(rdata.generate(false, enemyDeck == null ? null : deckNoBasicLands.toFlatList(),true )); diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java index 7c9a21b6836..cab9fd8ba73 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java @@ -30,7 +30,7 @@ protected Predicate buildPredicate() { if (predicate == null) { return x -> true; } - predicate = predicate.and(CardRulesPredicates.Presets.IS_CREATURE); + predicate = predicate.and(CardRulesPredicates.IS_CREATURE); return Predicates.compose(predicate, PaperCard::getRules); } } diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java index 70cac770f7e..421cdbead0f 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java @@ -30,7 +30,7 @@ protected Predicate buildPredicate() { if (predicate == null) { return x -> true; } - predicate = predicate.and(CardRulesPredicates.Presets.IS_CREATURE); + predicate = predicate.and(CardRulesPredicates.IS_CREATURE); return Predicates.compose(predicate, PaperCard::getRules); } } diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/StatTypeFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/StatTypeFilter.java index 430f8f389e7..0966ed1e010 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/StatTypeFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/StatTypeFilter.java @@ -37,7 +37,7 @@ protected void addToggleButton(Widget widget, final StatTypes st) { protected boolean showUnsupportedItem(U item) { FLabel btnPackOrDeck = buttonMap.get(StatTypes.PACK_OR_DECK); //support special pack/deck case if (btnPackOrDeck != null && btnPackOrDeck.isSelected()) { - return ItemPredicate.Presets.IS_PACK_OR_DECK.test(item); + return ItemPredicate.IS_PACK_OR_DECK.test(item); } return false; } diff --git a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java index 9e5028a05ba..0dff136bd7a 100644 --- a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java @@ -74,7 +74,7 @@ public static HashMap>> initializeForma true); final Iterable cards = Iterables.filter(format.getAllCards() - , Predicates.compose(CardRulesPredicates.Presets.NOT_TRUE_BASIC_LAND, PaperCard::getRules)); + , Predicates.compose(CardRulesPredicates.NOT_TRUE_BASIC_LAND, PaperCard::getRules)); List cardList = Lists.newArrayList(cards); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); @@ -90,7 +90,7 @@ public static HashMap>> initializeForma for (Deck deck:decks){ if (deck.getMain().contains(card)){ for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(), - Predicates.compose(CardRulesPredicates.Presets.NOT_TRUE_BASIC_LAND, PaperCard::getRules))){ + Predicates.compose(CardRulesPredicates.NOT_TRUE_BASIC_LAND, PaperCard::getRules))){ if (!pairCard.getName().equals(card.getName())){ try { int old = matrix[cardIntegerMap.get(card.getName())][cardIntegerMap.get(pairCard.getName())]; @@ -143,7 +143,7 @@ public static HashMap>> initializeComma //get all cards final Iterable cards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards() - , Predicates.compose(CardRulesPredicates.Presets.NOT_TRUE_BASIC_LAND, PaperCard::getRules)); + , Predicates.compose(CardRulesPredicates.NOT_TRUE_BASIC_LAND, PaperCard::getRules)); List cardList = Lists.newArrayList(cards); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); @@ -200,7 +200,7 @@ public static HashMap>> initializeComma public static void updateLegendMatrix(Deck deck, PaperCard legend, Map cardIntegerMap, Map legendIntegerMap, int[][] matrix){ for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(), - Predicates.compose(CardRulesPredicates.Presets.NOT_TRUE_BASIC_LAND, PaperCard::getRules))){ + Predicates.compose(CardRulesPredicates.NOT_TRUE_BASIC_LAND, PaperCard::getRules))){ if (!pairCard.getName().equals(legend.getName())){ try { int old = matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(pairCard.getName())]; diff --git a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java index 84aef7ff47a..64861c96cf8 100644 --- a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java @@ -65,7 +65,7 @@ public static List getBrawlDecks(final DeckFormat format, boolean isF Predicate canPlay = isForAi ? DeckGeneratorBase.AI_CAN_PLAY : CardRulesPredicates.IS_KEPT_IN_RANDOM_DECKS; @SuppressWarnings("unchecked") Iterable legends = Iterables.filter(uniqueCards.toFlatList(), format.isLegalCardPredicate() - .and(Predicates.compose(CardRulesPredicates.Presets.CAN_BE_BRAWL_COMMANDER.and(canPlay), PaperCard::getRules))); + .and(Predicates.compose(CardRulesPredicates.CAN_BE_BRAWL_COMMANDER.and(canPlay), PaperCard::getRules))); final List decks = new ArrayList<>(); for (PaperCard legend: legends) { decks.add(new CommanderDeckGenerator(legend, format, isForAi, isCardGen)); diff --git a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java index ac47b4f4f4a..24f9795babc 100644 --- a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java +++ b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java @@ -10,6 +10,7 @@ import java.util.Set; import java.util.function.Predicate; +import forge.item.PaperCardPredicates; import forge.util.*; import org.apache.commons.lang3.tuple.Pair; @@ -61,7 +62,7 @@ public static Deck buildCardGenDeck(GameFormat format, boolean isForAI){ try { List keys = new ArrayList<>(CardArchetypeLDAGenerator.ldaPools.get(format.getName()).keySet()); String randomKey = keys.get( MyRandom.getRandom().nextInt(keys.size()) ); - Predicate cardFilter = format.getFilterPrinted().and(PaperCard.Predicates.name(randomKey)); + Predicate cardFilter = format.getFilterPrinted().and(PaperCardPredicates.name(randomKey)); PaperCard keyCard = FModel.getMagicDb().getCommonCards().getAllCards(cardFilter).get(0); return buildCardGenDeck(keyCard,format,isForAI); @@ -73,7 +74,7 @@ public static Deck buildCardGenDeck(GameFormat format, boolean isForAI){ public static Deck buildCardGenDeck(String cardName, GameFormat format, boolean isForAI){ try { - Predicate cardFilter = format.getFilterPrinted().and(PaperCard.Predicates.name(cardName)); + Predicate cardFilter = format.getFilterPrinted().and(PaperCardPredicates.name(cardName)); return buildCardGenDeck(FModel.getMagicDb().getCommonCards().getAllCards(cardFilter).get(0),format,isForAI); }catch (Exception e){ e.printStackTrace(); @@ -214,8 +215,8 @@ public static Deck buildLDACardGenDeck(PaperCard card,GameFormat format, boolean System.out.println("Wrong card count "+deck.getMain().countAll()); deck=buildLDACArchetypeDeck(format,isForAI); } - if(deck.getMain().countAll(Predicates.compose(CardRulesPredicates.Presets.IS_LAND, PaperCard::getRules))>27){ - System.out.println("Too many lands "+deck.getMain().countAll(Predicates.compose(CardRulesPredicates.Presets.IS_LAND, PaperCard::getRules))); + if(deck.getMain().countAll(Predicates.compose(CardRulesPredicates.IS_LAND, PaperCard::getRules))>27){ + System.out.println("Too many lands "+deck.getMain().countAll(Predicates.compose(CardRulesPredicates.IS_LAND, PaperCard::getRules))); deck=buildLDACArchetypeDeck(format,isForAI); } while(deck.get(DeckSection.Sideboard).countAll()>15){ @@ -313,8 +314,8 @@ public static Deck buildLDACArchetypeDeck(Archetype archetype, GameFormat format System.out.println("Wrong card count "+deck.getMain().countAll()); deck=buildLDACArchetypeDeck(format,isForAI); } - if(deck.getMain().countAll(Predicates.compose(CardRulesPredicates.Presets.IS_LAND, PaperCard::getRules))>27){ - System.out.println("Too many lands "+deck.getMain().countAll(Predicates.compose(CardRulesPredicates.Presets.IS_LAND, PaperCard::getRules))); + if(deck.getMain().countAll(Predicates.compose(CardRulesPredicates.IS_LAND, PaperCard::getRules))>27){ + System.out.println("Too many lands "+deck.getMain().countAll(Predicates.compose(CardRulesPredicates.IS_LAND, PaperCard::getRules))); deck=buildLDACArchetypeDeck(format,isForAI); } while(deck.get(DeckSection.Sideboard).countAll()>15){ @@ -841,7 +842,7 @@ public static Map suggestBasicLandCount(Deck d) { // determine how many additional lands we need, but don't take lands already in deck into consideration, // or we risk incorrectly determining the target deck size - int numLands = Iterables.size(Iterables.filter(cards, Predicates.compose(CardRulesPredicates.Presets.IS_LAND, PaperCard::getRules))); + int numLands = Iterables.size(Iterables.filter(cards, Predicates.compose(CardRulesPredicates.IS_LAND, PaperCard::getRules))); int sizeNoLands = cards.size() - numLands; // attempt to determine if building for sealed, constructed or EDH diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java index a2a6f57402f..20a56efed60 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java @@ -30,6 +30,7 @@ import forge.game.GameFormat; import forge.item.IPaperCard; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; import forge.util.Iterables; @@ -192,8 +193,8 @@ public Deck buildDeck() { Predicates.compose(hasColor, PaperCard::getRules)); rankedColorList = Lists.newArrayList(colorList); onColorCreaturesAndSpells = Iterables.filter(rankedColorList, - Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE - .or(CardRulesPredicates.Presets.IS_NON_CREATURE_SPELL), PaperCard::getRules)); + Predicates.compose(CardRulesPredicates.IS_CREATURE + .or(CardRulesPredicates.IS_NON_CREATURE_SPELL), PaperCard::getRules)); // Guava iterables do not copy the collection contents, instead they act // as filters and iterate over _source_ collection each time. So even if @@ -320,7 +321,7 @@ public Deck buildDeck() { final CardPool cp = result.getOrCreate(DeckSection.Sideboard); Iterable potentialSideboard = Iterables.filter(aiPlayables, Predicates.compose(hasColor, PaperCard::getRules) - .and(Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard::getRules))); + .and(Predicates.compose(CardRulesPredicates.IS_NON_LAND, PaperCard::getRules))); int i=0; while(i<15 && potentialSideboard.iterator().hasNext()){ PaperCard sbCard = potentialSideboard.iterator().next(); @@ -391,7 +392,7 @@ private int sumMapValues(Map integerMap){ protected void addKeyCards(){ // Add the first keycard if not land if(!keyCard.getRules().getMainPart().getType().isLand()) { - keyCards = Iterables.filter(aiPlayables,PaperCard.Predicates.name(keyCard.getName())); + keyCards = Iterables.filter(aiPlayables, PaperCardPredicates.name(keyCard.getName())); final List keyCardList = Lists.newArrayList(keyCards); deckList.addAll(keyCardList); aiPlayables.removeAll(keyCardList); @@ -399,7 +400,7 @@ protected void addKeyCards(){ } // Add the second keycard if not land if(secondKeyCard!=null && !secondKeyCard.getRules().getMainPart().getType().isLand()) { - Iterable secondKeyCards = Iterables.filter(aiPlayables,PaperCard.Predicates.name(secondKeyCard.getName())); + Iterable secondKeyCards = Iterables.filter(aiPlayables, PaperCardPredicates.name(secondKeyCard.getName())); final List keyCardList = Lists.newArrayList(secondKeyCards); deckList.addAll(keyCardList); aiPlayables.removeAll(keyCardList); @@ -410,7 +411,7 @@ protected void addKeyCards(){ protected void addLandKeyCards(){ // Add the deck card if(keyCard.getRules().getMainPart().getType().isLand()) { - keyCards = Iterables.filter(aiPlayables,PaperCard.Predicates.name(keyCard.getName())); + keyCards = Iterables.filter(aiPlayables, PaperCardPredicates.name(keyCard.getName())); final List keyCardList = Lists.newArrayList(keyCards); deckList.addAll(keyCardList); aiPlayables.removeAll(keyCardList); @@ -419,7 +420,7 @@ protected void addLandKeyCards(){ } // Add the deck card if(secondKeyCard!=null && secondKeyCard.getRules().getMainPart().getType().isLand()) { - Iterable secondKeyCards = Iterables.filter(aiPlayables,PaperCard.Predicates.name(secondKeyCard.getName())); + Iterable secondKeyCards = Iterables.filter(aiPlayables, PaperCardPredicates.name(secondKeyCard.getName())); final List keyCardList = Lists.newArrayList(secondKeyCards); deckList.addAll(keyCardList); aiPlayables.removeAll(keyCardList); @@ -445,7 +446,7 @@ public boolean test(CardRules subject) { * If evolving wilds is in the deck and there are fewer than 4 spaces for basic lands - remove evolving wilds */ protected void checkEvolvingWilds(){ - List evolvingWilds = Lists.newArrayList(Iterables.filter(deckList,PaperCard.Predicates.name("Evolving Wilds"))); + List evolvingWilds = Lists.newArrayList(Iterables.filter(deckList, PaperCardPredicates.name("Evolving Wilds"))); if((evolvingWilds.size()>0 && landsNeeded<4 ) || colors.countColors()<2){ deckList.removeAll(evolvingWilds); landsNeeded=landsNeeded+evolvingWilds.size(); @@ -462,7 +463,7 @@ protected void checkEvolvingWilds(){ protected void addThirdColorCards(int num) { if (num > 0) { final Iterable others = Iterables.filter(aiPlayables, - Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard::getRules)); + Predicates.compose(CardRulesPredicates.IS_NON_LAND, PaperCard::getRules)); // We haven't yet ranked the off-color cards. // Compare them to the cards already in the deckList. //List rankedOthers = CardRanker.rankCardsInPack(others, deckList, colors, true); @@ -476,7 +477,7 @@ protected void addThirdColorCards(int num) { } } - hasColor = CardRulesPredicates.Presets.IS_NON_LAND.and(new MatchColorIdentity(colors) + hasColor = CardRulesPredicates.IS_NON_LAND.and(new MatchColorIdentity(colors) .or(DeckGeneratorBase.COLORLESS_CARDS)); final Iterable threeColorList = Iterables.filter(aiPlayables, Predicates.compose(hasColor, PaperCard::getRules)); @@ -499,7 +500,7 @@ protected void addThirdColorCards(int num) { protected void addLowCMCCard(){ final Iterable nonLands = Iterables.filter(rankedColorList, - Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard::getRules)); + Predicates.compose(CardRulesPredicates.IS_NON_LAND, PaperCard::getRules)); final PaperCard card = Iterables.getFirst(nonLands, null); if (card != null) { deckList.add(card); @@ -521,10 +522,10 @@ protected void addLowCMCCard(){ protected boolean setBasicLandPool(String edition){ Predicate isSetBasicLand; if (edition !=null){ - isSetBasicLand = IPaperCard.Predicates.printedInSet(edition) - .and(Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules)); + isSetBasicLand = PaperCardPredicates.printedInSet(edition) + .and(Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules)); }else{ - isSetBasicLand = Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules); + isSetBasicLand = Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules); } landPool = new DeckGenPool(format.getCardPool(fullCardDB).getAllCards(isSetBasicLand)); @@ -667,7 +668,7 @@ protected void findBasicLandSets() { */ private void addLands(final int[] clrCnts) { // basic lands that are available in the deck - final Iterable basicLands = Iterables.filter(aiPlayables, Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules)); + final Iterable basicLands = Iterables.filter(aiPlayables, Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules)); // total of all ClrCnts int totalColor = 0; @@ -809,7 +810,7 @@ private boolean containsTronLands(Iterable cards){ */ private void addNonBasicLands() { Iterable lands = Iterables.filter(aiPlayables, - Predicates.compose(CardRulesPredicates.Presets.IS_NONBASIC_LAND, PaperCard::getRules)); + Predicates.compose(CardRulesPredicates.IS_NONBASIC_LAND, PaperCard::getRules)); List landsToAdd = new ArrayList<>(); int minBasics;//Keep a minimum number of basics to ensure playable decks if(colors.isColorless()) { @@ -823,7 +824,7 @@ private void addNonBasicLands() { } lands = Iterables.filter(aiPlayables, - Predicates.compose(CardRulesPredicates.Presets.IS_NONBASIC_LAND, PaperCard::getRules)); + Predicates.compose(CardRulesPredicates.IS_NONBASIC_LAND, PaperCard::getRules)); for (final PaperCard card : lands) { if (landsNeeded > minBasics) { @@ -923,7 +924,7 @@ private void addManaCurveCards(final Iterable creatures, int num, Str for (int i = 1; i < 7; i++) { creatureCosts.put(i, 0); } - final Predicate filter = Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, + final Predicate filter = Predicates.compose(CardRulesPredicates.IS_CREATURE, PaperCard::getRules); for (final IPaperCard creature : Iterables.filter(deckList, filter)) { int cmc = creature.getRules().getManaCost().getCMC(); diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java index bc74e36f859..3c5ecd08330 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java @@ -139,16 +139,16 @@ public Deck buildDeck(final String landSetCode) { Predicates.compose(hasColor, PaperCard::getRules)); rankedColorList = CardRanker.rankCardsInDeck(colorList); onColorCreatures = Iterables.filter(rankedColorList, - Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, PaperCard::getRules)); + Predicates.compose(CardRulesPredicates.IS_CREATURE, PaperCard::getRules)); onColorNonCreatures = Iterables.filter(rankedColorList, - Predicates.compose(CardRulesPredicates.Presets.IS_NON_CREATURE_SPELL, PaperCard::getRules)); + Predicates.compose(CardRulesPredicates.IS_NON_CREATURE_SPELL, PaperCard::getRules)); // Guava iterables do not copy the collection contents, instead they act // as filters and iterate over _source_ collection each time. So even if // aiPlayable has changed, there is no need to create a new iterable. // 2. Add any planeswalkers final Iterable onColorWalkers = Iterables.filter(colorList, - Predicates.compose(CardRulesPredicates.Presets.IS_PLANESWALKER, PaperCard::getRules)); + Predicates.compose(CardRulesPredicates.IS_PLANESWALKER, PaperCard::getRules)); final List walkers = Lists.newArrayList(onColorWalkers); deckList.addAll(walkers); aiPlayables.removeAll(walkers); @@ -171,7 +171,7 @@ public Deck buildDeck(final String landSetCode) { // an extra. if (deckList.size() == numSpellsNeeded && getAverageCMC(deckList) < 4) { final Iterable nonLands = Iterables.filter(rankedColorList, - Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard::getRules)); + Predicates.compose(CardRulesPredicates.IS_NON_LAND, PaperCard::getRules)); final PaperCard card = Iterables.getFirst(nonLands, null); if (card != null) { deckList.add(card); @@ -342,7 +342,7 @@ private void findBasicLandSets() { */ private void addLands(final int[] clrCnts, final String landSetCode) { // basic lands that are available in the deck - final Iterable basicLands = Iterables.filter(aiPlayables, Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules)); + final Iterable basicLands = Iterables.filter(aiPlayables, Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules)); final Set snowLands = new HashSet<>(); // total of all ClrCnts @@ -455,7 +455,7 @@ private int[] calculateLandNeeds() { */ private void addNonBasicLands() { final Iterable lands = Iterables.filter(aiPlayables, - Predicates.compose(CardRulesPredicates.Presets.IS_NONBASIC_LAND, PaperCard::getRules)); + Predicates.compose(CardRulesPredicates.IS_NONBASIC_LAND, PaperCard::getRules)); List landsToAdd = new ArrayList<>(); for (final PaperCard card : lands) { if (landsNeeded > 0) { @@ -483,7 +483,7 @@ private void addNonBasicLands() { private void addThirdColorCards(int num) { if (num > 0) { final Iterable others = Iterables.filter(aiPlayables, - Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard::getRules)); + Predicates.compose(CardRulesPredicates.IS_NON_LAND, PaperCard::getRules)); // We haven't yet ranked the off-color cards. // Compare them to the cards already in the deckList. List rankedOthers = CardRanker.rankCardsInPack(others, deckList, colors, true); @@ -526,7 +526,7 @@ private void addThirdColorCards(int num) { */ private void addRandomCards(int num) { final Iterable others = Iterables.filter(aiPlayables, - Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard::getRules)); + Predicates.compose(CardRulesPredicates.IS_NON_LAND, PaperCard::getRules)); List toAdd = new ArrayList<>(); for (final PaperCard card : others) { if (num > 0) { @@ -669,7 +669,7 @@ private void addManaCurveCreatures(final Iterable creatures, int num) for (int i = 1; i < 7; i++) { creatureCosts.put(i, 0); } - final Predicate filter = Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, + final Predicate filter = Predicates.compose(CardRulesPredicates.IS_CREATURE, PaperCard::getRules); for (final IPaperCard creature : Iterables.filter(deckList, filter)) { int cmc = creature.getRules().getManaCost().getCMC(); diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java index 3e1e1c8c987..346f6a7ec83 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java @@ -43,11 +43,11 @@ private ColorSet chooseColors() { Iterable rules = Iterables.transform(colorChooserList, PaperCard::getRules); - int white = Iterables.size(Iterables.filter(rules, CardRulesPredicates.Presets.IS_WHITE)); - int blue = Iterables.size(Iterables.filter(rules, CardRulesPredicates.Presets.IS_BLUE)); - int black = Iterables.size(Iterables.filter(rules, CardRulesPredicates.Presets.IS_BLACK)); - int red = Iterables.size(Iterables.filter(rules, CardRulesPredicates.Presets.IS_RED)); - int green = Iterables.size(Iterables.filter(rules, CardRulesPredicates.Presets.IS_GREEN)); + int white = Iterables.size(Iterables.filter(rules, CardRulesPredicates.IS_WHITE)); + int blue = Iterables.size(Iterables.filter(rules, CardRulesPredicates.IS_BLUE)); + int black = Iterables.size(Iterables.filter(rules, CardRulesPredicates.IS_BLACK)); + int red = Iterables.size(Iterables.filter(rules, CardRulesPredicates.IS_RED)); + int green = Iterables.size(Iterables.filter(rules, CardRulesPredicates.IS_GREEN)); final int[] colorCounts = { white, blue, black, red, green }; int[] countsCopy = Arrays.copyOf(colorCounts, 5); diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java b/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java index 3b8df8b73ff..ec0439ce7b2 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java @@ -9,6 +9,7 @@ import forge.deck.CardPool; import forge.deck.Deck; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.util.Iterables; import forge.util.MyRandom; @@ -40,7 +41,7 @@ private void initializeWinstonDraft() { for (final Supplier> supply : this.product) { for (int j = 0; j < NUM_PLAYERS; j++) { // Remove Basic Lands from draft for simplicity - for (final PaperCard paperCard : Iterables.filter(supply.get(), PaperCard.Predicates.Presets.IS_BASIC_LAND.negate())) { + for (final PaperCard paperCard : Iterables.filter(supply.get(), PaperCardPredicates.IS_BASIC_LAND.negate())) { this.deck.add(paperCard); } } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java index 5d543587e8e..f5888cb9d93 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java @@ -25,6 +25,7 @@ import java.util.List; import java.util.function.Predicate; +import forge.item.*; import forge.util.Iterables; import forge.util.Predicates; import org.apache.commons.lang3.StringUtils; @@ -38,12 +39,6 @@ import forge.card.PrintSheet; import forge.game.GameFormat; import forge.gamemodes.quest.data.QuestPreferences.QPref; -import forge.item.BoosterPack; -import forge.item.IPaperCard; -import forge.item.IPaperCard.Predicates.Presets; -import forge.item.InventoryItem; -import forge.item.PaperCard; -import forge.item.TournamentPack; import forge.model.FModel; import forge.util.Aggregates; import forge.util.MyRandom; @@ -142,18 +137,18 @@ public static List getQuestStarterDeck(final GameFormat formatStartin } final boolean allowDuplicates = userPrefs != null && userPrefs.allowDuplicates(); - final boolean mythicsAvailable = Iterables.any(cardPool, Presets.IS_MYTHIC_RARE); + final boolean mythicsAvailable = Iterables.any(cardPool, PaperCardPredicates.IS_MYTHIC_RARE); final int numMythics = mythicsAvailable ? numRares / RARES_PER_MYTHIC : 0; final int adjustedRares = numRares - numMythics; final List> colorFilters = getColorFilters(userPrefs, cardPool); - cards.addAll(BoosterUtils.generateCards(cardPool, Presets.IS_COMMON, numCommons, colorFilters, allowDuplicates)); - cards.addAll(BoosterUtils.generateCards(cardPool, Presets.IS_UNCOMMON, numUncommons, colorFilters, allowDuplicates)); - cards.addAll(BoosterUtils.generateCards(cardPool, Presets.IS_RARE, adjustedRares, colorFilters, allowDuplicates)); + cards.addAll(BoosterUtils.generateCards(cardPool, PaperCardPredicates.IS_COMMON, numCommons, colorFilters, allowDuplicates)); + cards.addAll(BoosterUtils.generateCards(cardPool, PaperCardPredicates.IS_UNCOMMON, numUncommons, colorFilters, allowDuplicates)); + cards.addAll(BoosterUtils.generateCards(cardPool, PaperCardPredicates.IS_RARE, adjustedRares, colorFilters, allowDuplicates)); if (numMythics > 0) { - cards.addAll(BoosterUtils.generateCards(cardPool, Presets.IS_MYTHIC_RARE, numMythics, colorFilters, allowDuplicates)); + cards.addAll(BoosterUtils.generateCards(cardPool, PaperCardPredicates.IS_MYTHIC_RARE, numMythics, colorFilters, allowDuplicates)); } return cards; @@ -271,7 +266,7 @@ private static void populateRandomFilters(final List> color predicate = CardRulesPredicates.hasColor(color); } if (MyRandom.getRandom().nextDouble() < 0.1) { - predicate = predicate.and(CardRulesPredicates.Presets.IS_MULTICOLOR); + predicate = predicate.and(CardRulesPredicates.IS_MULTICOLOR); } colorFilters.add(predicate); } @@ -303,7 +298,7 @@ private static void populateBalancedFilters(final List> col //Add artifacts here if there's no colorless selection if (i % 8 == 0 && !preferredColors.contains(MagicColor.COLORLESS) && includeArtifacts) { - colorFilters.add(CardRulesPredicates.Presets.IS_ARTIFACT); + colorFilters.add(CardRulesPredicates.IS_ARTIFACT); } else if (i % 5 == 0) { //If colorless is the only color selected, add a small chance to get Phyrexian mana cost cards. @@ -328,7 +323,7 @@ private static void populateBalancedFilters(final List> col //Try to get multicolored cards that fit into the preferred colors. Predicate predicateRules = CardRulesPredicates.isColor(preferredColors.get(index)) - .and(CardRulesPredicates.Presets.IS_MULTICOLOR); + .and(CardRulesPredicates.IS_MULTICOLOR); Predicate predicateCard = Predicates.compose(predicateRules, PaperCard::getRules); //Adjust for the number of multicolored possibilities. This prevents flooding of non-selected @@ -351,7 +346,7 @@ private static void populateBalancedFilters(final List> col for (Byte color : otherColors) { if (i % 6 == 0) { - colorFilters.add(CardRulesPredicates.isColor(color).and(CardRulesPredicates.Presets.IS_MULTICOLOR)); + colorFilters.add(CardRulesPredicates.isColor(color).and(CardRulesPredicates.IS_MULTICOLOR)); } else { colorFilters.add(CardRulesPredicates.isMonoColor(color)); } @@ -448,21 +443,21 @@ public static Predicate parseRulesLimitation(final String input) { return null; } - if (input.equalsIgnoreCase("black")) return CardRulesPredicates.Presets.IS_BLACK; - if (input.equalsIgnoreCase("blue")) return CardRulesPredicates.Presets.IS_BLUE; - if (input.equalsIgnoreCase("green")) return CardRulesPredicates.Presets.IS_GREEN; - if (input.equalsIgnoreCase("red")) return CardRulesPredicates.Presets.IS_RED; - if (input.equalsIgnoreCase("white")) return CardRulesPredicates.Presets.IS_WHITE; - if (input.equalsIgnoreCase("colorless")) return CardRulesPredicates.Presets.IS_COLORLESS; - if (input.equalsIgnoreCase("multicolor")) return CardRulesPredicates.Presets.IS_MULTICOLOR; - - if (input.equalsIgnoreCase("land")) return CardRulesPredicates.Presets.IS_LAND; - if (input.equalsIgnoreCase("creature")) return CardRulesPredicates.Presets.IS_CREATURE; - if (input.equalsIgnoreCase("artifact")) return CardRulesPredicates.Presets.IS_ARTIFACT; - if (input.equalsIgnoreCase("planeswalker")) return CardRulesPredicates.Presets.IS_PLANESWALKER; - if (input.equalsIgnoreCase("instant")) return CardRulesPredicates.Presets.IS_INSTANT; - if (input.equalsIgnoreCase("sorcery")) return CardRulesPredicates.Presets.IS_SORCERY; - if (input.equalsIgnoreCase("enchantment")) return CardRulesPredicates.Presets.IS_ENCHANTMENT; + if (input.equalsIgnoreCase("black")) return CardRulesPredicates.IS_BLACK; + if (input.equalsIgnoreCase("blue")) return CardRulesPredicates.IS_BLUE; + if (input.equalsIgnoreCase("green")) return CardRulesPredicates.IS_GREEN; + if (input.equalsIgnoreCase("red")) return CardRulesPredicates.IS_RED; + if (input.equalsIgnoreCase("white")) return CardRulesPredicates.IS_WHITE; + if (input.equalsIgnoreCase("colorless")) return CardRulesPredicates.IS_COLORLESS; + if (input.equalsIgnoreCase("multicolor")) return CardRulesPredicates.IS_MULTICOLOR; + + if (input.equalsIgnoreCase("land")) return CardRulesPredicates.IS_LAND; + if (input.equalsIgnoreCase("creature")) return CardRulesPredicates.IS_CREATURE; + if (input.equalsIgnoreCase("artifact")) return CardRulesPredicates.IS_ARTIFACT; + if (input.equalsIgnoreCase("planeswalker")) return CardRulesPredicates.IS_PLANESWALKER; + if (input.equalsIgnoreCase("instant")) return CardRulesPredicates.IS_INSTANT; + if (input.equalsIgnoreCase("sorcery")) return CardRulesPredicates.IS_SORCERY; + if (input.equalsIgnoreCase("enchantment")) return CardRulesPredicates.IS_ENCHANTMENT; throw new IllegalArgumentException("No CardRules limitations could be parsed from: " + input); } @@ -483,7 +478,7 @@ private static List parseReward(final String s) { final int qty = Integer.parseInt(temp[0]); List> preds = new ArrayList<>(); - preds.add(IPaperCard.Predicates.Presets.IS_RARE_OR_MYTHIC); // Determine rarity + preds.add(PaperCardPredicates.IS_RARE_OR_MYTHIC); // Determine rarity if (temp.length > 2) { Predicate cr = parseRulesLimitation(temp[1]); diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java index 5475c4af726..37e0f34913d 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java @@ -5,8 +5,8 @@ import java.util.function.Predicate; import forge.card.CardRules; -import forge.item.IPaperCard; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.model.FModel; import forge.util.Predicates; @@ -67,7 +67,7 @@ protected Predicate buildPredicates(final String [] input) { // else { System.out.println("Unknown set code " + code); } } if (sets.size() > 0) { - filters = IPaperCard.Predicates.printedInSets(sets, true); + filters = PaperCardPredicates.printedInSets(sets, true); } } } @@ -91,13 +91,13 @@ protected Predicate buildPredicates(final String [] input) { if (rarityCodes.length > 0) { for (final String rarity : rarityCodes) { if (rarity.startsWith("C") || rarity.startsWith("c")) { - filterRarity = filterRarity == null ? IPaperCard.Predicates.Presets.IS_COMMON : filterRarity.or(IPaperCard.Predicates.Presets.IS_COMMON); + filterRarity = filterRarity == null ? PaperCardPredicates.IS_COMMON : filterRarity.or(PaperCardPredicates.IS_COMMON); } else if (rarity.startsWith("U") || rarity.startsWith("u")) { - filterRarity = filterRarity == null ? IPaperCard.Predicates.Presets.IS_UNCOMMON : filterRarity.or(IPaperCard.Predicates.Presets.IS_UNCOMMON); + filterRarity = filterRarity == null ? PaperCardPredicates.IS_UNCOMMON : filterRarity.or(PaperCardPredicates.IS_UNCOMMON); } else if (rarity.startsWith("R") || rarity.startsWith("r")) { - filterRarity = filterRarity == null ? IPaperCard.Predicates.Presets.IS_RARE : filterRarity.or(IPaperCard.Predicates.Presets.IS_RARE); + filterRarity = filterRarity == null ? PaperCardPredicates.IS_RARE : filterRarity.or(PaperCardPredicates.IS_RARE); } else if (rarity.startsWith("M") || rarity.startsWith("m")) { - filterRarity = filterRarity == null ? IPaperCard.Predicates.Presets.IS_MYTHIC_RARE : filterRarity.or(IPaperCard.Predicates.Presets.IS_MYTHIC_RARE); + filterRarity = filterRarity == null ? PaperCardPredicates.IS_MYTHIC_RARE : filterRarity.or(PaperCardPredicates.IS_MYTHIC_RARE); } } } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java index c08917d3968..f948eb26b79 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java @@ -54,11 +54,11 @@ */ public final class QuestUtilCards { - private static final Predicate COMMON_PREDICATE = IPaperCard.Predicates.Presets.IS_COMMON; - private static final Predicate UNCOMMON_PREDICATE = IPaperCard.Predicates.Presets.IS_UNCOMMON; - private static final Predicate RARE_PREDICATE = IPaperCard.Predicates.Presets.IS_RARE_OR_MYTHIC; - private static final Predicate ONLY_RARE_PREDICATE = IPaperCard.Predicates.Presets.IS_RARE; - private static final Predicate MYTHIC_PREDICATE = IPaperCard.Predicates.Presets.IS_MYTHIC_RARE; + private static final Predicate COMMON_PREDICATE = PaperCardPredicates.IS_COMMON; + private static final Predicate UNCOMMON_PREDICATE = PaperCardPredicates.IS_UNCOMMON; + private static final Predicate RARE_PREDICATE = PaperCardPredicates.IS_RARE_OR_MYTHIC; + private static final Predicate ONLY_RARE_PREDICATE = PaperCardPredicates.IS_RARE; + private static final Predicate MYTHIC_PREDICATE = PaperCardPredicates.IS_MYTHIC_RARE; private final QuestController questController; private final QuestPreferences questPreferences; @@ -870,7 +870,7 @@ public int getCompletionPercent(String edition) { } // get all cards in the specified edition - Predicate filter = IPaperCard.Predicates.printedInSet(edition); + Predicate filter = PaperCardPredicates.printedInSet(edition); Iterable editionCards = Iterables.filter(FModel.getMagicDb().getCommonCards().getAllCards(), filter); ItemPool ownedCards = questAssets.getCardPool(); diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestWinLoseController.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestWinLoseController.java index 28e170b6d40..3cc2a52c06a 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestWinLoseController.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestWinLoseController.java @@ -18,7 +18,7 @@ import forge.gui.interfaces.IWinLoseView; import forge.gui.util.SGuiChoose; import forge.item.*; -import forge.item.IPaperCard.Predicates; +import forge.item.PaperCardPredicates; import forge.item.generation.BoosterSlots; import forge.item.generation.IUnOpenedProduct; import forge.item.generation.UnOpenedProduct; @@ -575,7 +575,7 @@ private void awardBooster() { final CardEdition chooseEd = SGuiChoose.one(Localizer.getInstance().getMessage("lblChooseBonusBoosterSet"), options); if (customBooster) { - List cards = FModel.getMagicDb().getCommonCards().getAllCards(Predicates.printedInSet(chooseEd.getCode())); + List cards = FModel.getMagicDb().getCommonCards().getAllCards(PaperCardPredicates.printedInSet(chooseEd.getCode())); final IUnOpenedProduct product = new UnOpenedProduct(getBoosterTemplate(), cards); cardsWon = product.get(); } else { diff --git a/forge-gui/src/main/java/forge/itemmanager/SItemManagerUtil.java b/forge-gui/src/main/java/forge/itemmanager/SItemManagerUtil.java index 0ff5d6c84b9..1e338c281cd 100644 --- a/forge-gui/src/main/java/forge/itemmanager/SItemManagerUtil.java +++ b/forge-gui/src/main/java/forge/itemmanager/SItemManagerUtil.java @@ -29,24 +29,24 @@ public final class SItemManagerUtil { /** An enum to encapsulate metadata for the stats/filter objects. */ public enum StatTypes implements IHasSkinProp { - WHITE (FSkinProp.IMG_MANA_W, CardRulesPredicates.Presets.IS_WHITE, "lblWhitecards"), - BLUE (FSkinProp.IMG_MANA_U, CardRulesPredicates.Presets.IS_BLUE, "lblBluecards"), - BLACK (FSkinProp.IMG_MANA_B, CardRulesPredicates.Presets.IS_BLACK, "lblBlackcards"), - RED (FSkinProp.IMG_MANA_R, CardRulesPredicates.Presets.IS_RED, "lblRedcards"), - GREEN (FSkinProp.IMG_MANA_G, CardRulesPredicates.Presets.IS_GREEN, "lblGreencards"), - COLORLESS (FSkinProp.IMG_MANA_COLORLESS, CardRulesPredicates.Presets.IS_COLORLESS, "lblColorlesscards"), + WHITE (FSkinProp.IMG_MANA_W, CardRulesPredicates.IS_WHITE, "lblWhitecards"), + BLUE (FSkinProp.IMG_MANA_U, CardRulesPredicates.IS_BLUE, "lblBluecards"), + BLACK (FSkinProp.IMG_MANA_B, CardRulesPredicates.IS_BLACK, "lblBlackcards"), + RED (FSkinProp.IMG_MANA_R, CardRulesPredicates.IS_RED, "lblRedcards"), + GREEN (FSkinProp.IMG_MANA_G, CardRulesPredicates.IS_GREEN, "lblGreencards"), + COLORLESS (FSkinProp.IMG_MANA_COLORLESS, CardRulesPredicates.IS_COLORLESS, "lblColorlesscards"), MULTICOLOR (GuiBase.getInterface().isLibgdxPort() ? FSkinProp.IMG_HDMULTI : - FSkinProp.IMG_MULTI, CardRulesPredicates.Presets.IS_MULTICOLOR, "lblMulticolorcards"), + FSkinProp.IMG_MULTI, CardRulesPredicates.IS_MULTICOLOR, "lblMulticolorcards"), PACK_OR_DECK (FSkinProp.IMG_PACK, null, "lblPackordeck"), - LAND (FSkinProp.IMG_LAND, CardRulesPredicates.Presets.IS_LAND, "lblLands"), - ARTIFACT (FSkinProp.IMG_ARTIFACT, CardRulesPredicates.Presets.IS_ARTIFACT, "lblArtifacts"), - CREATURE (FSkinProp.IMG_CREATURE, CardRulesPredicates.Presets.IS_CREATURE, "lblCreatures"), - ENCHANTMENT (FSkinProp.IMG_ENCHANTMENT, CardRulesPredicates.Presets.IS_ENCHANTMENT, "lblEnchantments"), - PLANESWALKER (FSkinProp.IMG_PLANESWALKER, CardRulesPredicates.Presets.IS_PLANESWALKER, "lblPlaneswalkers"), - INSTANT (FSkinProp.IMG_INSTANT, CardRulesPredicates.Presets.IS_INSTANT, "lblInstants"), - SORCERY (FSkinProp.IMG_SORCERY, CardRulesPredicates.Presets.IS_SORCERY, "lblSorceries"), - BATTLE (FSkinProp.IMG_BATTLE, CardRulesPredicates.Presets.IS_BATTLE, "lblBattles"), + LAND (FSkinProp.IMG_LAND, CardRulesPredicates.IS_LAND, "lblLands"), + ARTIFACT (FSkinProp.IMG_ARTIFACT, CardRulesPredicates.IS_ARTIFACT, "lblArtifacts"), + CREATURE (FSkinProp.IMG_CREATURE, CardRulesPredicates.IS_CREATURE, "lblCreatures"), + ENCHANTMENT (FSkinProp.IMG_ENCHANTMENT, CardRulesPredicates.IS_ENCHANTMENT, "lblEnchantments"), + PLANESWALKER (FSkinProp.IMG_PLANESWALKER, CardRulesPredicates.IS_PLANESWALKER, "lblPlaneswalkers"), + INSTANT (FSkinProp.IMG_INSTANT, CardRulesPredicates.IS_INSTANT, "lblInstants"), + SORCERY (FSkinProp.IMG_SORCERY, CardRulesPredicates.IS_SORCERY, "lblSorceries"), + BATTLE (FSkinProp.IMG_BATTLE, CardRulesPredicates.IS_BATTLE, "lblBattles"), CMC_0 (FSkinProp.IMG_MANA_0, new CardRulesPredicates.LeafNumber(CardRulesPredicates.LeafNumber.CardField.CMC, ComparableOp.EQUALS, 0), "lblCCMC0"), CMC_1 (FSkinProp.IMG_MANA_1, new CardRulesPredicates.LeafNumber(CardRulesPredicates.LeafNumber.CardField.CMC, ComparableOp.EQUALS, 1), "lblCCMC1"), diff --git a/forge-gui/src/main/java/forge/model/CardBlock.java b/forge-gui/src/main/java/forge/model/CardBlock.java index b2aa31841df..7fc4f6ca5ff 100644 --- a/forge-gui/src/main/java/forge/model/CardBlock.java +++ b/forge-gui/src/main/java/forge/model/CardBlock.java @@ -23,10 +23,10 @@ import java.util.TreeMap; import java.util.function.Predicate; +import forge.item.PaperCardPredicates; import org.apache.commons.lang3.StringUtils; import forge.card.CardEdition; -import forge.item.IPaperCard; import forge.item.PaperCard; import forge.item.generation.IUnOpenedProduct; import forge.item.generation.UnOpenedProduct; @@ -141,7 +141,7 @@ private Predicate buildFilter() { for (final CardEdition set : this.sets) { setCodes.add(set.getCode()); } - return IPaperCard.Predicates.printedInSets(setCodes, true); + return PaperCardPredicates.printedInSets(setCodes, true); } /* diff --git a/forge-gui/src/main/java/forge/model/FModel.java b/forge-gui/src/main/java/forge/model/FModel.java index e7a317bd820..fb2361ff127 100644 --- a/forge-gui/src/main/java/forge/model/FModel.java +++ b/forge-gui/src/main/java/forge/model/FModel.java @@ -324,13 +324,13 @@ public static ItemPool getAllCardsNoAlt() { public static ItemPool getArchenemyCards() { if (archenemyCards == null) - return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_SCHEME, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.IS_SCHEME, PaperCard::getRules)), PaperCard.class); return archenemyCards; } public static ItemPool getPlanechaseCards() { if (planechaseCards == null) - return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_PLANE_OR_PHENOMENON, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.IS_PLANE_OR_PHENOMENON, PaperCard::getRules)), PaperCard.class); return planechaseCards; } @@ -338,7 +338,7 @@ public static ItemPool getBrawlCommander() { if (brawlCommander == null) { return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt( FModel.getFormats().get("Brawl").getFilterPrinted() - .and(Predicates.compose(CardRulesPredicates.Presets.CAN_BE_BRAWL_COMMANDER, PaperCard::getRules)) + .and(Predicates.compose(CardRulesPredicates.CAN_BE_BRAWL_COMMANDER, PaperCard::getRules)) ), PaperCard.class); } return brawlCommander; @@ -347,43 +347,43 @@ public static ItemPool getBrawlCommander() { public static ItemPool getOathbreakerCommander() { if (oathbreakerCommander == null) return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(Predicates.compose( - CardRulesPredicates.Presets.CAN_BE_OATHBREAKER.or(CardRulesPredicates.Presets.CAN_BE_SIGNATURE_SPELL), PaperCard::getRules)), PaperCard.class); + CardRulesPredicates.CAN_BE_OATHBREAKER.or(CardRulesPredicates.CAN_BE_SIGNATURE_SPELL), PaperCard::getRules)), PaperCard.class); return oathbreakerCommander; } public static ItemPool getTinyLeadersCommander() { if (tinyLeadersCommander == null) - return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(Predicates.compose(CardRulesPredicates.Presets.CAN_BE_TINY_LEADERS_COMMANDER, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(Predicates.compose(CardRulesPredicates.CAN_BE_TINY_LEADERS_COMMANDER, PaperCard::getRules)), PaperCard.class); return tinyLeadersCommander; } public static ItemPool getCommanderPool() { if (commanderPool == null) - return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(Predicates.compose(CardRulesPredicates.Presets.CAN_BE_COMMANDER, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(Predicates.compose(CardRulesPredicates.CAN_BE_COMMANDER, PaperCard::getRules)), PaperCard.class); return commanderPool; } public static ItemPool getAvatarPool() { if (avatarPool == null) - return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_VANGUARD, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.IS_VANGUARD, PaperCard::getRules)), PaperCard.class); return avatarPool; } public static ItemPool getConspiracyPool() { if (conspiracyPool == null) - return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_CONSPIRACY, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.IS_CONSPIRACY, PaperCard::getRules)), PaperCard.class); return conspiracyPool; } public static ItemPool getDungeonPool() { if (dungeonPool == null) - return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_DUNGEON, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.IS_DUNGEON, PaperCard::getRules)), PaperCard.class); return dungeonPool; } public static ItemPool getAttractionPool() { if (attractionPool == null) - return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_ATTRACTION, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.IS_ATTRACTION, PaperCard::getRules)), PaperCard.class); return attractionPool; } private static boolean keywordsLoaded = false; diff --git a/forge-gui/src/main/java/forge/model/MetaSet.java b/forge-gui/src/main/java/forge/model/MetaSet.java index 25d779e1542..5c0ab8e8b20 100644 --- a/forge-gui/src/main/java/forge/model/MetaSet.java +++ b/forge-gui/src/main/java/forge/model/MetaSet.java @@ -20,8 +20,8 @@ import forge.gamemodes.limited.CustomLimited; import forge.gamemodes.limited.SealedCardPoolGenerator; -import forge.item.IPaperCard; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.item.SealedTemplate; import forge.item.generation.IUnOpenedProduct; import forge.item.generation.UnOpenedProduct; @@ -177,7 +177,7 @@ public IUnOpenedProduct getBooster() { return new UnOpenedProduct(FModel.getMagicDb().getTournamentPacks().get(data)); case JoinedSet: - Predicate predicate = IPaperCard.Predicates.printedInSets(data.split(" ")); + Predicate predicate = PaperCardPredicates.printedInSets(data.split(" ")); return new UnOpenedProduct(SealedTemplate.genericDraftBooster, predicate); case Choose: return UnOpenedMeta.choose(data); diff --git a/forge-gui/src/main/java/forge/player/HumanCostDecision.java b/forge-gui/src/main/java/forge/player/HumanCostDecision.java index dee557e4bd8..29f8e48abc5 100644 --- a/forge-gui/src/main/java/forge/player/HumanCostDecision.java +++ b/forge-gui/src/main/java/forge/player/HumanCostDecision.java @@ -6,7 +6,6 @@ import forge.game.*; import forge.game.ability.AbilityUtils; import forge.game.card.*; -import forge.game.card.CardPredicates.Presets; import forge.game.cost.*; import forge.game.player.Player; import forge.game.player.PlayerCollection; @@ -1232,7 +1231,7 @@ public PaymentDecision visit(final CostTapType cost) { CardCollection typeList = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), type.split(";"), player, source, ability); - typeList = CardLists.filter(typeList, ability.isCrew() ? Presets.CAN_CREW : Presets.CAN_TAP); + typeList = CardLists.filter(typeList, ability.isCrew() ? CardPredicates.CAN_CREW : CardPredicates.CAN_TAP); Integer c = null; if (!amount.equals("Any")) { @@ -1306,7 +1305,7 @@ public PaymentDecision visit(final CostTapType cost) { public PaymentDecision visit(final CostUntapType cost) { CardCollection typeList = CardLists.getValidCards(player.getGame().getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), player, source, ability); - typeList = CardLists.filter(typeList, Presets.TAPPED); + typeList = CardLists.filter(typeList, CardPredicates.TAPPED); if (!cost.canUntapSource) { typeList.remove(source); } diff --git a/forge-gui/src/main/java/forge/player/HumanPlay.java b/forge-gui/src/main/java/forge/player/HumanPlay.java index 048dddef377..f32dca1faef 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlay.java +++ b/forge-gui/src/main/java/forge/player/HumanPlay.java @@ -20,7 +20,6 @@ import forge.game.card.CardCollectionView; import forge.game.card.CardLists; import forge.game.card.CardPredicates; -import forge.game.card.CardPredicates.Presets; import forge.game.card.CardView; import forge.game.card.CardZoneTable; import forge.game.card.CounterEnumType; @@ -427,7 +426,7 @@ else if (part instanceof CostReveal) { } else if (part instanceof CostTapType) { CardCollectionView list = CardLists.getValidCards(p.getCardsIn(ZoneType.Battlefield), part.getType().split(";"), p, source, sourceAbility); - list = CardLists.filter(list, Presets.CAN_TAP); + list = CardLists.filter(list, CardPredicates.CAN_TAP); int amount = part.getAbilityAmount(sourceAbility); boolean hasPaid = payCostPart(controller, p, sourceAbility, hcd.isEffect(), (CostPartWithList)part, amount, list, Localizer.getInstance().getMessage("lblTap") + orString); if (!hasPaid) { return false; } diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index 6b3542d9119..525dd6dd4d8 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -2618,7 +2618,7 @@ public void modifyCountersOnPermanent(boolean subtract) { public void tapPermanents() { getGame().getAction().invoke(() -> { final CardCollectionView untapped = CardLists.filter(getGame().getCardsIn(ZoneType.Battlefield), - CardPredicates.Presets.UNTAPPED); + CardPredicates.UNTAPPED); final InputSelectCardsFromList inp = new InputSelectCardsFromList(PlayerControllerHuman.this, 0, Integer.MAX_VALUE, untapped); inp.setCancelAllowed(true); @@ -2647,7 +2647,7 @@ public void tapPermanents() { public void untapPermanents() { getGame().getAction().invoke(() -> { final CardCollectionView tapped = CardLists.filter(getGame().getCardsIn(ZoneType.Battlefield), - CardPredicates.Presets.TAPPED); + CardPredicates.TAPPED); final InputSelectCardsFromList inp = new InputSelectCardsFromList(PlayerControllerHuman.this, 0, Integer.MAX_VALUE, tapped); inp.setCancelAllowed(true); diff --git a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java index eac701ec667..6806ee794fb 100644 --- a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java +++ b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java @@ -291,7 +291,7 @@ public static HashMap>> initializeComma //get all cards final Iterable cards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards() - , Predicates.compose(CardRulesPredicates.Presets.NOT_TRUE_BASIC_LAND, PaperCard::getRules)); + , Predicates.compose(CardRulesPredicates.NOT_TRUE_BASIC_LAND, PaperCard::getRules)); List cardList = Lists.newArrayList(cards); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); @@ -350,7 +350,7 @@ public static HashMap>> initializeComma public static void updateLegendMatrix(Deck deck, PaperCard legend, Map cardIntegerMap, Map legendIntegerMap, int[][] matrix){ for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(), - Predicates.compose(CardRulesPredicates.Presets.NOT_TRUE_BASIC_LAND, PaperCard::getRules))){ + Predicates.compose(CardRulesPredicates.NOT_TRUE_BASIC_LAND, PaperCard::getRules))){ if (!pairCard.getName().equals(legend.getName())){ try { int old = matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(pairCard.getName())]; From 734bcec8bf51ec49dc7fc6e5c0ed164f5360041e Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 6 Sep 2024 19:17:28 -0400 Subject: [PATCH 23/68] Guava migration - Helper method for composing CardRules into PaperCards --- .../src/main/java/forge/card/DeckHints.java | 1 + .../src/main/java/forge/deck/DeckFormat.java | 3 +- .../deck/generation/DeckGeneratorBase.java | 20 ++++++------ .../java/forge/item/PaperCardPredicates.java | 9 ++++-- .../main/java/forge/item/SealedProduct.java | 2 +- .../item/generation/BoosterGenerator.java | 7 ++-- .../ability/effects/CopyPermanentEffect.java | 7 ++-- .../game/ability/effects/PlayEffect.java | 5 +-- .../effects/PlayLandVariantEffect.java | 3 +- .../game/ability/effects/VentureEffect.java | 14 ++++---- .../itemmanager/filters/CardCMCFilter.java | 3 +- .../filters/CardCMCRangeFilter.java | 3 +- .../itemmanager/filters/CardPowerFilter.java | 3 +- .../filters/CardToughnessFilter.java | 3 +- .../itemmanager/filters/CardTypeFilter.java | 3 +- .../itemmanager/filters/StatTypeFilter.java | 3 +- .../deckeditor/controllers/CDeckgen.java | 3 +- .../controllers/CEditorCommander.java | 5 +-- .../deckeditor/controllers/CEditorQuest.java | 3 +- .../deckeditor/controllers/CStatistics.java | 3 +- .../controllers/CStatisticsImporter.java | 3 +- .../PlanarConquestCommanderGeneraterGA.java | 9 +++--- .../PlanarConquestGeneraterGA.java | 7 ++-- .../PlanarConquestTribalGeneraterGA.java | 9 +++--- .../adventure/character/EnemySprite.java | 3 +- .../itemmanager/filters/CardCMCFilter.java | 3 +- .../filters/CardColorlessCostFilter.java | 3 +- .../itemmanager/filters/CardPowerFilter.java | 3 +- .../filters/CardToughnessFilter.java | 3 +- .../itemmanager/filters/CardTypeFilter.java | 3 +- .../deck/CardRelationMatrixGenerator.java | 13 ++++---- .../forge/deck/CommanderDeckGenerator.java | 5 +-- .../src/main/java/forge/deck/DeckgenUtil.java | 17 +++++----- .../CardThemedCommanderDeckBuilder.java | 3 +- .../CardThemedConquestDeckBuilder.java | 3 +- .../limited/CardThemedDeckBuilder.java | 32 +++++++++---------- .../gamemodes/limited/LimitedDeckBuilder.java | 29 +++++++++-------- .../gamemodes/limited/LimitedPlayerAI.java | 3 +- .../planarconquest/ConquestRegion.java | 3 +- .../forge/gamemodes/quest/BoosterUtils.java | 8 ++--- .../gamemodes/quest/QuestRewardCard.java | 2 +- .../java/forge/itemmanager/SFilterUtil.java | 5 +-- .../src/main/java/forge/model/FModel.java | 29 ++++++++++------- .../java/forge/lda/LDAModelGenetrator.java | 13 ++++---- 44 files changed, 178 insertions(+), 136 deletions(-) diff --git a/forge-core/src/main/java/forge/card/DeckHints.java b/forge-core/src/main/java/forge/card/DeckHints.java index ba013dcc1f6..cf3c3fb3968 100644 --- a/forge-core/src/main/java/forge/card/DeckHints.java +++ b/forge-core/src/main/java/forge/card/DeckHints.java @@ -205,6 +205,7 @@ private List getCardsForFilter(Iterable cardList, Type typ private Iterable getMatchingItems(Iterable source, Predicate predicate, Function fn) { // TODO should token generators be counted differently for their potential? + // And would there ever be a circumstance where `fn` should be anything but PaperCard::getRules? return Iterables.filter(source, Predicates.compose(tokens ? rulesWithTokens(predicate) : predicate, fn)); } diff --git a/forge-core/src/main/java/forge/deck/DeckFormat.java b/forge-core/src/main/java/forge/deck/DeckFormat.java index 90d79967ea4..1ce0957a6b0 100644 --- a/forge-core/src/main/java/forge/deck/DeckFormat.java +++ b/forge-core/src/main/java/forge/deck/DeckFormat.java @@ -29,6 +29,7 @@ import forge.deck.generation.IDeckGenPool; import forge.item.IPaperCard; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.util.Aggregates; import forge.util.Iterables; import forge.util.Predicates; @@ -540,6 +541,6 @@ public Predicate isLegalCardForCommanderPredicate(List com //Notably, no partner ability or combination of partner abilities can ever let a player have more than two commanders. predicate = predicate.or(CardRulesPredicates.canBePartnerCommanderWith(commanders.get(0).getRules())); } - return Predicates.compose(predicate, PaperCard::getRules); + return PaperCardPredicates.fromRules(predicate); } } diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index d38eb114cb5..15a056da475 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -87,12 +87,12 @@ protected void addCreaturesAndSpells(int size, List cards = selectCardsOfMatchingColorForPlayer(forAi); // build subsets based on type - final Iterable creatures = Iterables.filter(cards, Predicates.compose(CardRulesPredicates.IS_CREATURE, PaperCard::getRules)); + final Iterable creatures = Iterables.filter(cards, PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE)); final int creatCnt = (int) Math.ceil(getCreaturePercentage() * size); trace.append("Creatures to add:").append(creatCnt).append("\n"); addCmcAdjusted(creatures, creatCnt, cmcLevels); - Predicate preSpells = Predicates.compose(CardRulesPredicates.IS_NON_CREATURE_SPELL, PaperCard::getRules); + Predicate preSpells = PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_CREATURE_SPELL); final Iterable spells = Iterables.filter(cards, preSpells); final int spellCnt = (int) Math.ceil(getSpellPercentage() * size); trace.append("Spells to add:").append(spellCnt).append("\n"); @@ -107,11 +107,11 @@ public CardPool getDeck(final int size, final boolean forAi) { protected boolean setBasicLandPool(String edition){ Predicate isSetBasicLand; - if (edition !=null){ + if (edition != null){ isSetBasicLand = PaperCardPredicates.printedInSet(edition) - .and(Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules)); - }else{ - isSetBasicLand = Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules); + .and(PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND)); + } else { + isSetBasicLand = PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND); } landPool = new DeckGenPool(StaticData.instance().getCommonCards().getAllCards(isSetBasicLand)); @@ -234,7 +234,7 @@ protected void adjustDeckSize(int targetSize) { addSome(targetSize - actualSize, tDeck.toFlatList()); } else if (actualSize > targetSize) { - Predicate exceptBasicLand = Predicates.compose(CardRulesPredicates.NOT_BASIC_LAND, PaperCard::getRules); + Predicate exceptBasicLand = PaperCardPredicates.fromRules(CardRulesPredicates.NOT_BASIC_LAND); for (int i = 0; i < 3 && actualSize > targetSize; i++) { Iterable matchingCards = Iterables.filter(tDeck.toFlatList(), exceptBasicLand); @@ -261,7 +261,7 @@ protected void addCmcAdjusted(Iterable source, int cnt, List pair : cmcLevels) { - Iterable matchingCards = Iterables.filter(source, Predicates.compose(pair.getLeft(), PaperCard::getRules)); + Iterable matchingCards = Iterables.filter(source, PaperCardPredicates.fromRules(pair.getLeft())); int cmcCountForPool = (int) Math.ceil(pair.getRight() * desiredOverTotal); int addOfThisCmc = Math.round(pair.getRight() * requestedOverTotal); @@ -291,7 +291,7 @@ protected Iterable selectCardsOfMatchingColorForPlayer(boolean forAi) if (useArtifacts) { hasColor = hasColor.or(COLORLESS_CARDS); } - return Iterables.filter(pool.getAllCards(), Predicates.compose(canPlay.and(hasColor).and(canUseInFormat), PaperCard::getRules)); + return Iterables.filter(pool.getAllCards(), PaperCardPredicates.fromRules(canPlay.and(hasColor).and(canUseInFormat))); } protected static Map countLands(ItemPool outList) { @@ -390,7 +390,7 @@ protected List getDualLandList(Predicate canPlay) { Predicate dualLandFilter = CardRulesPredicates.coreType(true, CardType.CoreType.Land); Predicate exceptBasicLand = CardRulesPredicates.NOT_BASIC_LAND; - Iterable landCards = pool.getAllCards(Predicates.compose(dualLandFilter.and(exceptBasicLand).and(canPlay), PaperCard::getRules)); + Iterable landCards = pool.getAllCards(PaperCardPredicates.fromRules(dualLandFilter.and(exceptBasicLand).and(canPlay))); Iterable dualLandPatterns = Arrays.asList("Add \\{([WUBRG])\\} or \\{([WUBRG])\\}", "Add \\{([WUBRG])\\}, \\{([WUBRG])\\}, or \\{([WUBRG])\\}", "Add \\{([WUBRG])\\}\\{([WUBRG])\\}", diff --git a/forge-core/src/main/java/forge/item/PaperCardPredicates.java b/forge-core/src/main/java/forge/item/PaperCardPredicates.java index f7dbdc28d5d..804864aff7e 100644 --- a/forge-core/src/main/java/forge/item/PaperCardPredicates.java +++ b/forge-core/src/main/java/forge/item/PaperCardPredicates.java @@ -1,9 +1,7 @@ package forge.item; import com.google.common.collect.Lists; -import forge.card.CardRarity; -import forge.card.CardType; -import forge.card.MagicColor; +import forge.card.*; import forge.util.PredicateCard; import forge.util.PredicateString; import org.apache.commons.lang3.StringUtils; @@ -179,6 +177,11 @@ private PredicateCards(final List operand) { } } + //TODO: Remove + public static Predicate fromRules(Predicate cardRulesPredicate) { + return paperCard -> cardRulesPredicate.test(paperCard.getRules()); + } + public static final Predicate IS_COMMON = PaperCardPredicates.rarity(true, CardRarity.Common); public static final Predicate IS_UNCOMMON = PaperCardPredicates.rarity(true, CardRarity.Uncommon); public static final Predicate IS_RARE = PaperCardPredicates.rarity(true, CardRarity.Rare); diff --git a/forge-core/src/main/java/forge/item/SealedProduct.java b/forge-core/src/main/java/forge/item/SealedProduct.java index 1049a14bb78..3cb69e379c1 100644 --- a/forge-core/src/main/java/forge/item/SealedProduct.java +++ b/forge-core/src/main/java/forge/item/SealedProduct.java @@ -114,7 +114,7 @@ protected PaperCard getRandomBasicLand(final String setCode) { protected List getRandomBasicLands(final String setCode, final int count) { Predicate cardsRule = PaperCardPredicates.printedInSet(setCode) - .and(Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules)); + .and(PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND)); return Aggregates.random(Iterables.filter(StaticData.instance().getCommonCards().getAllCards(), cardsRule), count); } } diff --git a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java index 2b2d6220025..679a2f6eea4 100644 --- a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java +++ b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java @@ -668,13 +668,12 @@ private static Predicate buildExtraPredicate(List operators) Predicate toAdd = null; if (operator.equalsIgnoreCase(BoosterSlots.DUAL_FACED_CARD)) { - toAdd = Predicates.compose( + toAdd = PaperCardPredicates.fromRules( CardRulesPredicates.splitType(CardSplitType.Transform) .or(CardRulesPredicates.splitType(CardSplitType.Meld)) .or(CardRulesPredicates.splitType(CardSplitType.Modal) - ), - PaperCard::getRules); - } else if (operator.equalsIgnoreCase(BoosterSlots.LAND)) { toAdd = Predicates.compose(CardRulesPredicates.IS_LAND, PaperCard::getRules); + )); + } else if (operator.equalsIgnoreCase(BoosterSlots.LAND)) { toAdd = PaperCardPredicates.fromRules(CardRulesPredicates.IS_LAND); } else if (operator.equalsIgnoreCase(BoosterSlots.BASIC_LAND)) { toAdd = PaperCardPredicates.IS_BASIC_LAND; } else if (operator.equalsIgnoreCase(BoosterSlots.TIME_SHIFTED)) { toAdd = PaperCardPredicates.IS_SPECIAL; } else if (operator.equalsIgnoreCase(BoosterSlots.SPECIAL)) { toAdd = PaperCardPredicates.IS_SPECIAL; diff --git a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java index 74f520a2704..89ffe7e6f6d 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java @@ -5,6 +5,7 @@ import java.util.function.Predicate; import forge.card.GamePieceType; +import forge.item.PaperCardPredicates; import forge.util.*; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.mutable.MutableBoolean; @@ -156,11 +157,11 @@ public void resolve(final SpellAbility sa) { "X", Integer.toString(AbilityUtils.calculateAmount(host, "X", sa))); } if (StringUtils.containsIgnoreCase(valid, "creature")) { - Predicate cpp = Predicates.compose(CardRulesPredicates.IS_CREATURE, PaperCard::getRules); + Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE); cards = Lists.newArrayList(Iterables.filter(cards, cpp)); } if (StringUtils.containsIgnoreCase(valid, "equipment")) { - Predicate cpp = Predicates.compose(CardRulesPredicates.IS_EQUIPMENT, PaperCard::getRules); + Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.IS_EQUIPMENT); cards = Lists.newArrayList(Iterables.filter(cards, cpp)); } if (sa.hasParam("RandomCopied")) { @@ -193,7 +194,7 @@ public void resolve(final SpellAbility sa) { } } - Predicate cpp = Predicates.compose(CardRulesPredicates.name(StringOp.EQUALS, name), PaperCard::getRules); + Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.name(StringOp.EQUALS, name)); cards = Lists.newArrayList(Iterables.filter(cards, cpp)); if (!cards.isEmpty()) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java index 543f76ffc7d..c82cb1a93fb 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java @@ -9,6 +9,7 @@ import forge.card.CardStateName; import forge.card.GamePieceType; +import forge.item.PaperCardPredicates; import forge.util.*; import org.apache.commons.lang3.StringUtils; @@ -121,11 +122,11 @@ public void resolve(final SpellAbility sa) { } } else if (valid.equalsIgnoreCase("sorcery")) { cards = Lists.newArrayList(StaticData.instance().getCommonCards().getUniqueCards()); - final Predicate cpp = Predicates.compose(CardRulesPredicates.IS_SORCERY, PaperCard::getRules); + final Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.IS_SORCERY); cards = Lists.newArrayList(Iterables.filter(cards, cpp)); } else if (valid.equalsIgnoreCase("instant")) { cards = Lists.newArrayList(StaticData.instance().getCommonCards().getUniqueCards()); - final Predicate cpp = Predicates.compose(CardRulesPredicates.IS_INSTANT, PaperCard::getRules); + final Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.IS_INSTANT); cards = Lists.newArrayList(Iterables.filter(cards, cpp)); } if (sa.hasParam("RandomCopied")) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java index 3feb0f4cc2e..32e8dd47282 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java @@ -16,6 +16,7 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.util.Aggregates; import forge.util.Iterables; import forge.util.Predicates; @@ -30,7 +31,7 @@ public void resolve(final SpellAbility sa) { final String landType = sa.getParam("Clone"); List cards = Lists.newArrayList(StaticData.instance().getCommonCards().getUniqueCards()); if ("BasicLand".equals(landType)) { - final Predicate cpp = Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules); + final Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND); cards = Lists.newArrayList(Iterables.filter(cards, cpp)); } // current color of source card diff --git a/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java b/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java index f731d60e56c..6bd22dc454e 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java @@ -3,8 +3,10 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.function.Predicate; import forge.StaticData; +import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.game.Game; import forge.game.ability.AbilityKey; @@ -21,6 +23,7 @@ import forge.game.trigger.WrappedAbility; import forge.game.zone.ZoneType; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.util.Localizer; import forge.util.PredicateString.StringOp; import forge.util.Predicates; @@ -44,15 +47,14 @@ private Card getDungeonCard(SpellAbility sa, Player player, Map dungeonCards = null; if (sa.hasParam("Dungeon")) { - dungeonCards = StaticData.instance().getVariantCards() - .getAllCards(Predicates.compose( - CardRulesPredicates.IS_DUNGEON - .and(CardRulesPredicates.subType(StringOp.EQUALS, sa.getParam("Dungeon"))), - PaperCard::getRules)); + String dungeonType = sa.getParam("Dungeon"); + Predicate rulesPredicate = CardRulesPredicates.IS_DUNGEON.and(CardRulesPredicates.subType(StringOp.EQUALS, dungeonType)); + dungeonCards = StaticData.instance().getVariantCards().getAllCards( + PaperCardPredicates.fromRules(rulesPredicate)); } else { // Create a new dungeon card chosen by player in command zone. dungeonCards = StaticData.instance().getVariantCards().getAllCards( - Predicates.compose(CardRulesPredicates.IS_DUNGEON, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_DUNGEON)); dungeonCards.removeIf(c -> !c.getRules().isEnterableDungeon()); } String message = Localizer.getInstance().getMessage("lblChooseDungeon"); diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java index b00f1a27a28..650e10b0cc0 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java @@ -8,6 +8,7 @@ import forge.card.CardRules; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; import forge.itemmanager.SItemManagerUtil.StatTypes; import forge.itemmanager.SpellShopManager; @@ -55,6 +56,6 @@ protected final Predicate buildPredicate() { //use custom return true delegate to validate the item is a card return card -> true; } - return Predicates.compose(Predicates.or(cmcs), PaperCard::getRules); + return PaperCardPredicates.fromRules(Predicates.or(cmcs)); } } diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java index 3a69a6ee882..c06c56995cc 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java @@ -3,6 +3,7 @@ import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; import forge.util.Predicates; @@ -33,6 +34,6 @@ protected Predicate buildPredicate() { if (predicate == null) { return x -> true; } - return Predicates.compose(predicate, PaperCard::getRules); + return PaperCardPredicates.fromRules(predicate); } } diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java index ffd3399bb6f..5ace0d2a6e8 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java @@ -3,6 +3,7 @@ import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; import forge.util.Predicates; @@ -34,6 +35,6 @@ protected Predicate buildPredicate() { return x -> true; } predicate = predicate.and(CardRulesPredicates.IS_CREATURE); - return Predicates.compose(predicate, PaperCard::getRules); + return PaperCardPredicates.fromRules(predicate); } } diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java index 6296314e184..1986379fb13 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java @@ -3,6 +3,7 @@ import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; import forge.util.Predicates; @@ -34,6 +35,6 @@ protected Predicate buildPredicate() { return x -> true; } predicate = predicate.and(CardRulesPredicates.IS_CREATURE); - return Predicates.compose(predicate, PaperCard::getRules); + return PaperCardPredicates.fromRules(predicate); } } diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java index 28f0bff1c2b..72116738054 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java @@ -8,6 +8,7 @@ import forge.card.CardRules; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; import forge.itemmanager.SItemManagerUtil.StatTypes; import forge.itemmanager.SpellShopManager; @@ -53,6 +54,6 @@ protected final Predicate buildPredicate() { //use custom return true delegate to validate the item is a card return card -> true; } - return Predicates.compose(Predicates.or(types), PaperCard::getRules); + return PaperCardPredicates.fromRules(Predicates.or(types)); } } diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java index 240866dda5c..b857f2875d9 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java @@ -10,6 +10,7 @@ import forge.item.InventoryItem; import forge.item.ItemPredicate; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; import forge.itemmanager.SFilterUtil; import forge.itemmanager.SItemManagerUtil.StatTypes; @@ -76,7 +77,7 @@ public void afterFiltersApplied() { for (StatTypes statTypes : buttonMap.keySet()) { if (statTypes.predicate != null) { - int count = items.countAll(Predicates.compose(statTypes.predicate, PaperCard::getRules), PaperCard.class); + int count = items.countAll(PaperCardPredicates.fromRules(statTypes.predicate), PaperCard.class); buttonMap.get(statTypes).setText(String.valueOf(count)); } } diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java index cd2b71af8c7..1e18eebcfca 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java @@ -16,6 +16,7 @@ import forge.gui.framework.ICDoc; import forge.item.InventoryItem; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.localinstance.properties.ForgePreferences.FPref; import forge.model.FModel; import forge.screens.deckeditor.CDeckEditorUI; @@ -70,7 +71,7 @@ private void newRandomCon final Deck randomDeck = new Deck(); - final Predicate notBasicLand = Predicates.compose(CardRulesPredicates.NOT_BASIC_LAND, PaperCard::getRules); + final Predicate notBasicLand = PaperCardPredicates.fromRules(CardRulesPredicates.NOT_BASIC_LAND); final Iterable source = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards(), notBasicLand); randomDeck.getMain().addAllFlat(Aggregates.random(source, 15 * 5)); diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java index 39fda0ed516..35182542874 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java @@ -28,6 +28,7 @@ import forge.gui.framework.DragCell; import forge.gui.framework.FScreen; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.CardManager; import forge.itemmanager.ItemManagerConfig; import forge.model.CardCollections; @@ -83,14 +84,14 @@ public CEditorCommander(final CDetailPicture cDetailPicture, GameType gameType0) if (gameType == GameType.Brawl){ GameFormat format = FModel.getFormats().get("Brawl"); Predicate commanderFilter = CardRulesPredicates.CAN_BE_BRAWL_COMMANDER; - commanderPool = ItemPool.createFrom(commonCards.getAllCardsNoAlt(format.getFilterPrinted().and(Predicates.compose(commanderFilter, PaperCard::getRules))), PaperCard.class); + commanderPool = ItemPool.createFrom(commonCards.getAllCardsNoAlt(format.getFilterPrinted().and(PaperCardPredicates.fromRules(commanderFilter))), PaperCard.class); normalPool = ItemPool.createFrom(format.getAllCards(), PaperCard.class); } else { Predicate commanderFilter = gameType == GameType.Oathbreaker ? CardRulesPredicates.CAN_BE_OATHBREAKER.or(CardRulesPredicates.CAN_BE_SIGNATURE_SPELL) : CardRulesPredicates.CAN_BE_COMMANDER; - commanderPool = ItemPool.createFrom(commonCards.getAllCardsNoAlt(Predicates.compose(commanderFilter, PaperCard::getRules)),PaperCard.class); + commanderPool = ItemPool.createFrom(commonCards.getAllCardsNoAlt(PaperCardPredicates.fromRules(commanderFilter)),PaperCard.class); normalPool = ItemPool.createFrom(commonCards.getAllCardsNoAlt(), PaperCard.class); } diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java index a9f3d572acf..f466923466a 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java @@ -44,6 +44,7 @@ import forge.gui.framework.FScreen; import forge.item.InventoryItem; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.CardManager; import forge.itemmanager.ColumnDef; import forge.itemmanager.ItemManagerConfig; @@ -346,7 +347,7 @@ private Deck getDeck(){ } private ItemPool getCommanderCardPool(){ - Predicate commanderPredicate = Predicates.compose(CardRulesPredicates.CAN_BE_COMMANDER, PaperCard::getRules); + Predicate commanderPredicate = PaperCardPredicates.fromRules(CardRulesPredicates.CAN_BE_COMMANDER); return getRemainingCardPool().getFilteredPool(commanderPredicate); } diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java index b57bed33111..a4284504642 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java @@ -12,6 +12,7 @@ import forge.gui.framework.ICDoc; import forge.item.InventoryItem; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.SItemManagerUtil.StatTypes; import forge.screens.deckeditor.CDeckEditorUI; import forge.screens.deckeditor.views.VStatistics; @@ -51,7 +52,7 @@ public void update() { } private void setLabelValue(final JLabel label, final ItemPool deck, final Predicate predicate, final int total) { - final int tmp = deck.countAll(Predicates.compose(predicate, PaperCard::getRules)); + final int tmp = deck.countAll(PaperCardPredicates.fromRules(predicate)); label.setText(tmp + " (" + calculatePercentage(tmp, total) + "%)"); } diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java index 7d54cecf340..085b138dcb7 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java @@ -7,6 +7,7 @@ import forge.deck.DeckRecognizer; import forge.deck.DeckSection; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.SItemManagerUtil; import forge.screens.deckeditor.views.VStatisticsImporter; import forge.util.ItemPool; @@ -100,7 +101,7 @@ else if (token.getTokenSection() == DeckSection.Commander) } private void setLabelValue(final JLabel label, final ItemPool deck, final Predicate predicate, final int total) { - final int tmp = deck.countAll(Predicates.compose(predicate, PaperCard::getRules)); + final int tmp = deck.countAll(PaperCardPredicates.fromRules(predicate)); label.setText(tmp + " (" + calculatePercentage(tmp, total) + "%)"); } diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java index 763c8f9388f..76f5a818c68 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java @@ -20,6 +20,7 @@ import forge.gamemodes.limited.CardRanker; import forge.gui.GuiBase; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.localinstance.properties.ForgeConstants; import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; @@ -76,10 +77,10 @@ protected void initializeCards(){ } Iterable filtered= Iterables.filter(cards, - Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard::getRules) - .and(Predicates.compose(CardRulesPredicates.IS_PLANESWALKER, PaperCard::getRules)) - //.and(Predicates.compose(CardRulesPredicates.IS_LEGENDARY, PaperCard::getRules)) - .and(gameFormat.getFilterPrinted()) + PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS + .and(CardRulesPredicates.IS_PLANESWALKER) + //.and(CardRulesPredicates.IS_LEGENDARY) + ).and(gameFormat.getFilterPrinted()) ); List filteredList = Lists.newArrayList(filtered); diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java index 8ec054c963b..1a452f70acf 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; +import forge.item.PaperCardPredicates; import forge.util.*; import org.apache.commons.lang3.tuple.Pair; @@ -106,9 +107,9 @@ protected void initializeCards(){ } Iterable filtered= Iterables.filter(cards, - Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard::getRules) - .and(Predicates.compose(CardRulesPredicates.IS_NON_LAND, PaperCard::getRules)) - .and(gameFormat.getFilterPrinted()) + PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS + .and(CardRulesPredicates.IS_NON_LAND) + ).and(gameFormat.getFilterPrinted()) ); List filteredList = Lists.newArrayList(filtered); diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java index 9c90a7ca876..5b52f66fffa 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java @@ -19,6 +19,7 @@ import forge.gamemodes.limited.CardRanker; import forge.gui.GuiBase; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.localinstance.properties.ForgeConstants; import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; @@ -78,10 +79,10 @@ protected void initializeCards(){ } Iterable filteredTribe= Iterables.filter(cards, - Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard::getRules) - .and(Predicates.compose(CardRulesPredicates.hasCreatureType("Pirate"), PaperCard::getRules)) - .and(Predicates.compose(CardRulesPredicates.IS_CREATURE, PaperCard::getRules)) - .and(gameFormat.getFilterPrinted()) + PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS + .and(CardRulesPredicates.hasCreatureType("Pirate")) + .and(CardRulesPredicates.IS_CREATURE) + ).and(gameFormat.getFilterPrinted()) ); List filteredListTribe = Lists.newArrayList(filteredTribe); diff --git a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java index af16285b3cd..7e23935c7d2 100644 --- a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java +++ b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java @@ -30,6 +30,7 @@ import forge.deck.CardPool; import forge.deck.Deck; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.util.Aggregates; import forge.util.MyRandom; import forge.util.Predicates; @@ -481,7 +482,7 @@ public Array getRewards() { if(data.rewards != null) { //Collect standard rewards. Deck enemyDeck = Current.latestDeck(); // By popular demand, remove basic lands from the reward pool. - CardPool deckNoBasicLands = enemyDeck.getMain().getFilteredPool(Predicates.compose(CardRulesPredicates.NOT_BASIC_LAND, PaperCard::getRules)); + CardPool deckNoBasicLands = enemyDeck.getMain().getFilteredPool(PaperCardPredicates.fromRules(CardRulesPredicates.NOT_BASIC_LAND)); for (RewardData rdata : data.rewards) { ret.addAll(rdata.generate(false, enemyDeck == null ? null : deckNoBasicLands.toFlatList(),true )); diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java index ee8116280c3..67c84b3d7bc 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java @@ -3,6 +3,7 @@ import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; import forge.util.Predicates; @@ -30,6 +31,6 @@ protected Predicate buildPredicate() { if (predicate == null) { return x -> true; } - return Predicates.compose(predicate, PaperCard::getRules); + return PaperCardPredicates.fromRules(predicate); } } diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java index 45add3f6db5..13990b86ffe 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java @@ -3,6 +3,7 @@ import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; import forge.util.Predicates; @@ -30,6 +31,6 @@ protected Predicate buildPredicate() { if (predicate == null) { return x -> true; } - return Predicates.compose(predicate, PaperCard::getRules); + return PaperCardPredicates.fromRules(predicate); } } diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java index cab9fd8ba73..42328d7beb0 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java @@ -3,6 +3,7 @@ import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; import forge.util.Predicates; @@ -31,6 +32,6 @@ protected Predicate buildPredicate() { return x -> true; } predicate = predicate.and(CardRulesPredicates.IS_CREATURE); - return Predicates.compose(predicate, PaperCard::getRules); + return PaperCardPredicates.fromRules(predicate); } } diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java index 421cdbead0f..5722707c899 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java @@ -3,6 +3,7 @@ import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; import forge.util.Predicates; @@ -31,6 +32,6 @@ protected Predicate buildPredicate() { return x -> true; } predicate = predicate.and(CardRulesPredicates.IS_CREATURE); - return Predicates.compose(predicate, PaperCard::getRules); + return PaperCardPredicates.fromRules(predicate); } } diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java index 1a9bbce096f..f631ee8ef12 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java @@ -6,6 +6,7 @@ import forge.card.CardRules; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; import forge.itemmanager.SItemManagerUtil.StatTypes; import forge.util.Predicates; @@ -50,6 +51,6 @@ protected final Predicate buildPredicate() { //use custom return true delegate to validate the item is a card return card -> true; } - return Predicates.compose(Predicates.or(types), PaperCard::getRules); + return PaperCardPredicates.fromRules(Predicates.or(types)); } } diff --git a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java index 0dff136bd7a..1834057e410 100644 --- a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Map; +import forge.item.PaperCardPredicates; import forge.util.Iterables; import forge.util.Predicates; import org.apache.commons.lang3.ArrayUtils; @@ -73,8 +74,8 @@ public static HashMap>> initializeForma ForgeConstants.DECK_GEN_DIR, false), true); - final Iterable cards = Iterables.filter(format.getAllCards() - , Predicates.compose(CardRulesPredicates.NOT_TRUE_BASIC_LAND, PaperCard::getRules)); + final Iterable cards = Iterables.filter(format.getAllCards(), + PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)); List cardList = Lists.newArrayList(cards); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); @@ -90,7 +91,7 @@ public static HashMap>> initializeForma for (Deck deck:decks){ if (deck.getMain().contains(card)){ for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(), - Predicates.compose(CardRulesPredicates.NOT_TRUE_BASIC_LAND, PaperCard::getRules))){ + PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND))){ if (!pairCard.getName().equals(card.getName())){ try { int old = matrix[cardIntegerMap.get(card.getName())][cardIntegerMap.get(pairCard.getName())]; @@ -142,8 +143,8 @@ public static HashMap>> initializeComma true); //get all cards - final Iterable cards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards() - , Predicates.compose(CardRulesPredicates.NOT_TRUE_BASIC_LAND, PaperCard::getRules)); + final Iterable cards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards(), + PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)); List cardList = Lists.newArrayList(cards); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); @@ -200,7 +201,7 @@ public static HashMap>> initializeComma public static void updateLegendMatrix(Deck deck, PaperCard legend, Map cardIntegerMap, Map legendIntegerMap, int[][] matrix){ for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(), - Predicates.compose(CardRulesPredicates.NOT_TRUE_BASIC_LAND, PaperCard::getRules))){ + PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND))){ if (!pairCard.getName().equals(legend.getName())){ try { int old = matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(pairCard.getName())]; diff --git a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java index 64861c96cf8..ea55de9b273 100644 --- a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java @@ -10,6 +10,7 @@ import forge.card.CardRulesPredicates; import forge.deck.generation.DeckGeneratorBase; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.model.FModel; import forge.util.ItemPool; import forge.util.Iterables; @@ -41,7 +42,7 @@ public static List getCommanderDecks(final DeckFormat format, boolean Predicate canPlay = isForAi ? DeckGeneratorBase.AI_CAN_PLAY : CardRulesPredicates.IS_KEPT_IN_RANDOM_DECKS; @SuppressWarnings("unchecked") Iterable legends = Iterables.filter(uniqueCards.toFlatList(), format.isLegalCommanderPredicate() - .and(Predicates.compose(canPlay, PaperCard::getRules))); + .and(PaperCardPredicates.fromRules(canPlay))); final List decks = new ArrayList<>(); for (PaperCard legend: legends) { decks.add(new CommanderDeckGenerator(legend, format, isForAi, isCardGen)); @@ -65,7 +66,7 @@ public static List getBrawlDecks(final DeckFormat format, boolean isF Predicate canPlay = isForAi ? DeckGeneratorBase.AI_CAN_PLAY : CardRulesPredicates.IS_KEPT_IN_RANDOM_DECKS; @SuppressWarnings("unchecked") Iterable legends = Iterables.filter(uniqueCards.toFlatList(), format.isLegalCardPredicate() - .and(Predicates.compose(CardRulesPredicates.CAN_BE_BRAWL_COMMANDER.and(canPlay), PaperCard::getRules))); + .and(PaperCardPredicates.fromRules(CardRulesPredicates.CAN_BE_BRAWL_COMMANDER.and(canPlay)))); final List decks = new ArrayList<>(); for (PaperCard legend: legends) { decks.add(new CommanderDeckGenerator(legend, format, isForAi, isCardGen)); diff --git a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java index 24f9795babc..39e9e6e47b0 100644 --- a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java +++ b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java @@ -215,8 +215,8 @@ public static Deck buildLDACardGenDeck(PaperCard card,GameFormat format, boolean System.out.println("Wrong card count "+deck.getMain().countAll()); deck=buildLDACArchetypeDeck(format,isForAI); } - if(deck.getMain().countAll(Predicates.compose(CardRulesPredicates.IS_LAND, PaperCard::getRules))>27){ - System.out.println("Too many lands "+deck.getMain().countAll(Predicates.compose(CardRulesPredicates.IS_LAND, PaperCard::getRules))); + if(deck.getMain().countAll(PaperCardPredicates.fromRules(CardRulesPredicates.IS_LAND))>27){ + System.out.println("Too many lands "+deck.getMain().countAll(PaperCardPredicates.fromRules(CardRulesPredicates.IS_LAND))); deck=buildLDACArchetypeDeck(format,isForAI); } while(deck.get(DeckSection.Sideboard).countAll()>15){ @@ -314,8 +314,8 @@ public static Deck buildLDACArchetypeDeck(Archetype archetype, GameFormat format System.out.println("Wrong card count "+deck.getMain().countAll()); deck=buildLDACArchetypeDeck(format,isForAI); } - if(deck.getMain().countAll(Predicates.compose(CardRulesPredicates.IS_LAND, PaperCard::getRules))>27){ - System.out.println("Too many lands "+deck.getMain().countAll(Predicates.compose(CardRulesPredicates.IS_LAND, PaperCard::getRules))); + if(deck.getMain().countAll(PaperCardPredicates.fromRules(CardRulesPredicates.IS_LAND))>27){ + System.out.println("Too many lands "+deck.getMain().countAll(PaperCardPredicates.fromRules(CardRulesPredicates.IS_LAND))); deck=buildLDACArchetypeDeck(format,isForAI); } while(deck.get(DeckSection.Sideboard).countAll()>15){ @@ -667,7 +667,7 @@ public static Deck generateCommanderDeck(boolean forAi, GameType gameType) { final DeckFormat format = gameType.getDeckFormat(); Predicate canPlay = forAi ? DeckGeneratorBase.AI_CAN_PLAY : CardRulesPredicates.IS_KEPT_IN_RANDOM_DECKS; Predicate legal = format.isLegalCardPredicate().and(format.isLegalCommanderPredicate()); - Iterable legends = cardDb.getAllCards(legal.and(Predicates.compose(canPlay, PaperCard::getRules))); + Iterable legends = cardDb.getAllCards(legal.and(PaperCardPredicates.fromRules(canPlay))); commander = Aggregates.random(legends); return generateRandomCommanderDeck(commander, format, forAi, false); @@ -761,10 +761,9 @@ else if (commander.getRules().canBePartnerCommander()) { cardDb = FModel.getMagicDb().getCommonCards(); //shuffle first 400 random cards Iterable colorList = Iterables.filter(format.getCardPool(cardDb).getAllCards(), - format.isLegalCardPredicate().and(Predicates.compose( + format.isLegalCardPredicate().and(PaperCardPredicates.fromRules( new CardThemedDeckBuilder.MatchColorIdentity(commander.getRules().getColorIdentity()) - .or(DeckGeneratorBase.COLORLESS_CARDS), - PaperCard::getRules))); + .or(DeckGeneratorBase.COLORLESS_CARDS)))); switch (format) { case Brawl: //for Brawl - add additional filterprinted rule to remove old reprints for a consistent look colorList = Iterables.filter(colorList,FModel.getFormats().getStandard().getFilterPrinted()); @@ -842,7 +841,7 @@ public static Map suggestBasicLandCount(Deck d) { // determine how many additional lands we need, but don't take lands already in deck into consideration, // or we risk incorrectly determining the target deck size - int numLands = Iterables.size(Iterables.filter(cards, Predicates.compose(CardRulesPredicates.IS_LAND, PaperCard::getRules))); + int numLands = Iterables.size(Iterables.filter(cards, PaperCardPredicates.fromRules(CardRulesPredicates.IS_LAND))); int sizeNoLands = cards.size() - numLands; // attempt to determine if building for sealed, constructed or EDH diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java index 6a87ec1c0b5..da9113f070a 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java @@ -9,6 +9,7 @@ import forge.deck.DeckFormat; import forge.deck.generation.DeckGenPool; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.model.FModel; import forge.util.Iterables; import forge.util.Predicates; @@ -26,7 +27,7 @@ public CardThemedCommanderDeckBuilder(PaperCard commanderCard0, PaperCard partne // remove Unplayables if(isForAI) { final Iterable playables = Iterables.filter(availableList, - Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS)); this.aiPlayables = Lists.newArrayList(playables); }else{ this.aiPlayables = Lists.newArrayList(availableList); diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java index 07fd70d6db3..a0358811826 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java @@ -10,6 +10,7 @@ import forge.deck.generation.DeckGenPool; import forge.game.GameFormat; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.model.FModel; import forge.util.Iterables; import forge.util.Predicates; @@ -30,7 +31,7 @@ public CardThemedConquestDeckBuilder(PaperCard commanderCard0, final List playables = Iterables.filter(availableList, - Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS)); this.aiPlayables = Lists.newArrayList(playables); }else{ this.aiPlayables = Lists.newArrayList(availableList); diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java index 20a56efed60..f1ada5f12a2 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java @@ -106,7 +106,7 @@ public CardThemedDeckBuilder(PaperCard keyCard0, PaperCard secondKeyCard0, final // remove Unplayables if(isForAI) { final Iterable playables = Iterables.filter(availableList, - Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS)); this.aiPlayables = Lists.newArrayList(playables); }else{ this.aiPlayables = Lists.newArrayList(availableList); @@ -190,11 +190,11 @@ public Deck buildDeck() { System.out.println("Colors: " + colors.toEnumSet().toString()); } Iterable colorList = Iterables.filter(aiPlayables, - Predicates.compose(hasColor, PaperCard::getRules)); + PaperCardPredicates.fromRules(hasColor)); rankedColorList = Lists.newArrayList(colorList); onColorCreaturesAndSpells = Iterables.filter(rankedColorList, - Predicates.compose(CardRulesPredicates.IS_CREATURE - .or(CardRulesPredicates.IS_NON_CREATURE_SPELL), PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE + .or(CardRulesPredicates.IS_NON_CREATURE_SPELL))); // Guava iterables do not copy the collection contents, instead they act // as filters and iterate over _source_ collection each time. So even if @@ -320,8 +320,7 @@ public Deck buildDeck() { //Add remaining non-land colour matching cards to sideboard final CardPool cp = result.getOrCreate(DeckSection.Sideboard); Iterable potentialSideboard = Iterables.filter(aiPlayables, - Predicates.compose(hasColor, PaperCard::getRules) - .and(Predicates.compose(CardRulesPredicates.IS_NON_LAND, PaperCard::getRules))); + PaperCardPredicates.fromRules(hasColor.and(CardRulesPredicates.IS_NON_LAND))); int i=0; while(i<15 && potentialSideboard.iterator().hasNext()){ PaperCard sbCard = potentialSideboard.iterator().next(); @@ -463,7 +462,7 @@ protected void checkEvolvingWilds(){ protected void addThirdColorCards(int num) { if (num > 0) { final Iterable others = Iterables.filter(aiPlayables, - Predicates.compose(CardRulesPredicates.IS_NON_LAND, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_LAND)); // We haven't yet ranked the off-color cards. // Compare them to the cards already in the deckList. //List rankedOthers = CardRanker.rankCardsInPack(others, deckList, colors, true); @@ -480,7 +479,7 @@ protected void addThirdColorCards(int num) { hasColor = CardRulesPredicates.IS_NON_LAND.and(new MatchColorIdentity(colors) .or(DeckGeneratorBase.COLORLESS_CARDS)); final Iterable threeColorList = Iterables.filter(aiPlayables, - Predicates.compose(hasColor, PaperCard::getRules)); + PaperCardPredicates.fromRules(hasColor)); for (final PaperCard card : threeColorList) { if (num > 0) { toAdd.add(card); @@ -500,7 +499,7 @@ protected void addThirdColorCards(int num) { protected void addLowCMCCard(){ final Iterable nonLands = Iterables.filter(rankedColorList, - Predicates.compose(CardRulesPredicates.IS_NON_LAND, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_LAND)); final PaperCard card = Iterables.getFirst(nonLands, null); if (card != null) { deckList.add(card); @@ -523,9 +522,9 @@ protected boolean setBasicLandPool(String edition){ Predicate isSetBasicLand; if (edition !=null){ isSetBasicLand = PaperCardPredicates.printedInSet(edition) - .and(Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules)); - }else{ - isSetBasicLand = Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules); + .and(PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND)); + } else { + isSetBasicLand = PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND); } landPool = new DeckGenPool(format.getCardPool(fullCardDB).getAllCards(isSetBasicLand)); @@ -668,7 +667,7 @@ protected void findBasicLandSets() { */ private void addLands(final int[] clrCnts) { // basic lands that are available in the deck - final Iterable basicLands = Iterables.filter(aiPlayables, Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules)); + final Iterable basicLands = Iterables.filter(aiPlayables, PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND)); // total of all ClrCnts int totalColor = 0; @@ -810,7 +809,7 @@ private boolean containsTronLands(Iterable cards){ */ private void addNonBasicLands() { Iterable lands = Iterables.filter(aiPlayables, - Predicates.compose(CardRulesPredicates.IS_NONBASIC_LAND, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_NONBASIC_LAND)); List landsToAdd = new ArrayList<>(); int minBasics;//Keep a minimum number of basics to ensure playable decks if(colors.isColorless()) { @@ -824,7 +823,7 @@ private void addNonBasicLands() { } lands = Iterables.filter(aiPlayables, - Predicates.compose(CardRulesPredicates.IS_NONBASIC_LAND, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_NONBASIC_LAND)); for (final PaperCard card : lands) { if (landsNeeded > minBasics) { @@ -924,8 +923,7 @@ private void addManaCurveCards(final Iterable creatures, int num, Str for (int i = 1; i < 7; i++) { creatureCosts.put(i, 0); } - final Predicate filter = Predicates.compose(CardRulesPredicates.IS_CREATURE, - PaperCard::getRules); + final Predicate filter = PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE); for (final IPaperCard creature : Iterables.filter(deckList, filter)) { int cmc = creature.getRules().getManaCost().getCMC(); if (cmc < 1) { diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java index 3c5ecd08330..1d079402812 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java @@ -26,6 +26,7 @@ import forge.deck.generation.DeckGeneratorBase; import forge.item.IPaperCard; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.model.FModel; import forge.util.Iterables; import forge.util.MyRandom; @@ -83,13 +84,13 @@ public LimitedDeckBuilder(final List dList, final DeckColors pClrs) { // remove Unplayables final Iterable playables = Iterables.filter(availableList, - Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_LIMITED_DECKS, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_LIMITED_DECKS)); this.aiPlayables = Lists.newArrayList(playables); this.availableList.removeAll(aiPlayables); // keep Conspiracies in a separate list final Iterable conspiracies = Iterables.filter(aiPlayables, - Predicates.compose(CardRulesPredicates.coreType(true, "Conspiracy"), PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.coreType(true, "Conspiracy"))); this.draftedConspiracies = Lists.newArrayList(conspiracies); this.aiPlayables.removeAll(draftedConspiracies); @@ -136,19 +137,19 @@ public Deck buildDeck(final String landSetCode) { // 1. Prepare hasColor = new MatchColorIdentity(colors).or(COLORLESS_CARDS); Iterable colorList = Iterables.filter(aiPlayables, - Predicates.compose(hasColor, PaperCard::getRules)); + PaperCardPredicates.fromRules(hasColor)); rankedColorList = CardRanker.rankCardsInDeck(colorList); onColorCreatures = Iterables.filter(rankedColorList, - Predicates.compose(CardRulesPredicates.IS_CREATURE, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE)); onColorNonCreatures = Iterables.filter(rankedColorList, - Predicates.compose(CardRulesPredicates.IS_NON_CREATURE_SPELL, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_CREATURE_SPELL)); // Guava iterables do not copy the collection contents, instead they act // as filters and iterate over _source_ collection each time. So even if // aiPlayable has changed, there is no need to create a new iterable. // 2. Add any planeswalkers final Iterable onColorWalkers = Iterables.filter(colorList, - Predicates.compose(CardRulesPredicates.IS_PLANESWALKER, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_PLANESWALKER)); final List walkers = Lists.newArrayList(onColorWalkers); deckList.addAll(walkers); aiPlayables.removeAll(walkers); @@ -171,7 +172,7 @@ public Deck buildDeck(final String landSetCode) { // an extra. if (deckList.size() == numSpellsNeeded && getAverageCMC(deckList) < 4) { final Iterable nonLands = Iterables.filter(rankedColorList, - Predicates.compose(CardRulesPredicates.IS_NON_LAND, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_LAND)); final PaperCard card = Iterables.getFirst(nonLands, null); if (card != null) { deckList.add(card); @@ -342,7 +343,8 @@ private void findBasicLandSets() { */ private void addLands(final int[] clrCnts, final String landSetCode) { // basic lands that are available in the deck - final Iterable basicLands = Iterables.filter(aiPlayables, Predicates.compose(CardRulesPredicates.IS_BASIC_LAND, PaperCard::getRules)); + final Iterable basicLands = Iterables.filter(aiPlayables, + PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND)); final Set snowLands = new HashSet<>(); // total of all ClrCnts @@ -455,7 +457,7 @@ private int[] calculateLandNeeds() { */ private void addNonBasicLands() { final Iterable lands = Iterables.filter(aiPlayables, - Predicates.compose(CardRulesPredicates.IS_NONBASIC_LAND, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_NONBASIC_LAND)); List landsToAdd = new ArrayList<>(); for (final PaperCard card : lands) { if (landsNeeded > 0) { @@ -483,7 +485,7 @@ private void addNonBasicLands() { private void addThirdColorCards(int num) { if (num > 0) { final Iterable others = Iterables.filter(aiPlayables, - Predicates.compose(CardRulesPredicates.IS_NON_LAND, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_LAND)); // We haven't yet ranked the off-color cards. // Compare them to the cards already in the deckList. List rankedOthers = CardRanker.rankCardsInPack(others, deckList, colors, true); @@ -499,7 +501,7 @@ private void addThirdColorCards(int num) { hasColor = new MatchColorIdentity(colors).or(DeckGeneratorBase.COLORLESS_CARDS); final Iterable threeColorList = Iterables.filter(rankedOthers, - Predicates.compose(hasColor, PaperCard::getRules)); + PaperCardPredicates.fromRules(hasColor)); for (final PaperCard card : threeColorList) { if (num > 0) { toAdd.add(card); @@ -526,7 +528,7 @@ private void addThirdColorCards(int num) { */ private void addRandomCards(int num) { final Iterable others = Iterables.filter(aiPlayables, - Predicates.compose(CardRulesPredicates.IS_NON_LAND, PaperCard::getRules)); + PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_LAND)); List toAdd = new ArrayList<>(); for (final PaperCard card : others) { if (num > 0) { @@ -669,8 +671,7 @@ private void addManaCurveCreatures(final Iterable creatures, int num) for (int i = 1; i < 7; i++) { creatureCosts.put(i, 0); } - final Predicate filter = Predicates.compose(CardRulesPredicates.IS_CREATURE, - PaperCard::getRules); + final Predicate filter = PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE); for (final IPaperCard creature : Iterables.filter(deckList, filter)) { int cmc = creature.getRules().getManaCost().getCMC(); if (cmc < 1) { diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java index ea4c8251ce6..7154c78b7a4 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java @@ -7,6 +7,7 @@ import forge.deck.DeckSection; import forge.deck.generation.DeckGeneratorBase; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.localinstance.properties.ForgePreferences; import forge.util.Iterables; import forge.util.MyRandom; @@ -265,7 +266,7 @@ protected PaperCard chooseExchangeCard(PaperCard offer) { DeckGeneratorBase.MatchColorIdentity hasColor = new DeckGeneratorBase.MatchColorIdentity(colors); Iterable colorList = Iterables.filter(deckCards, - Predicates.compose(hasColor, PaperCard::getRules).negate()); + PaperCardPredicates.fromRules(hasColor).negate()); PaperCard exchangeCard = null; diff --git a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java index 22fa9d04ffe..01141e6a197 100644 --- a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java +++ b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java @@ -12,6 +12,7 @@ import forge.game.card.Card; import forge.gui.GuiBase; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.localinstance.skin.ISkinImage; import forge.model.FModel; import forge.util.Predicates; @@ -130,7 +131,7 @@ protected ConquestRegion read(String line) { break; case "colors": colorSet = ColorSet.fromNames(value.toCharArray()); - pred = Predicates.compose(CardRulesPredicates.hasColorIdentity(colorSet.getColor()), PaperCard::getRules); + pred = PaperCardPredicates.fromRules(CardRulesPredicates.hasColorIdentity(colorSet.getColor())); break; case "sets": final String[] sets = value.split(","); diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java index f5888cb9d93..8722978e1a2 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java @@ -305,7 +305,7 @@ private static void populateBalancedFilters(final List> col if (preferredColors.contains(MagicColor.COLORLESS) && preferredColors.size() == 1) { Predicate predicateRules = CardRulesPredicates.cost(StringOp.CONTAINS_IC, "p/"); - Predicate predicateCard = Predicates.compose(predicateRules, PaperCard::getRules); + Predicate predicateCard = PaperCardPredicates.fromRules(predicateRules); int size = Iterables.size(Iterables.filter(cardPool, predicateCard)); int totalSize = cardPool.size(); @@ -324,7 +324,7 @@ private static void populateBalancedFilters(final List> col //Try to get multicolored cards that fit into the preferred colors. Predicate predicateRules = CardRulesPredicates.isColor(preferredColors.get(index)) .and(CardRulesPredicates.IS_MULTICOLOR); - Predicate predicateCard = Predicates.compose(predicateRules, PaperCard::getRules); + Predicate predicateCard = PaperCardPredicates.fromRules(predicateRules); //Adjust for the number of multicolored possibilities. This prevents flooding of non-selected //colors if multicolored cards aren't in the selected sets. The more multi-colored cards in the @@ -401,7 +401,7 @@ private static List generateCards( //handful of multi-colored cards. do { if (color2 != null) { - Predicate color2c = Predicates.compose(color2, PaperCard::getRules); + Predicate color2c = PaperCardPredicates.fromRules(color2); card = Aggregates.random(Iterables.filter(source, filter.and(color2c))); } } while (card == null && colorMisses++ < 10); @@ -483,7 +483,7 @@ private static List parseReward(final String s) { if (temp.length > 2) { Predicate cr = parseRulesLimitation(temp[1]); if (cr != null) { - preds.add(Predicates.compose(cr, PaperCard::getRules)); + preds.add(PaperCardPredicates.fromRules(cr)); } } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java index 37e0f34913d..fbfd8a5e37f 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java @@ -106,7 +106,7 @@ protected Predicate buildPredicates(final String [] input) { } if (filterRules != null) { - final Predicate rulesPrinted = Predicates.compose(filterRules, PaperCard::getRules); + final Predicate rulesPrinted = PaperCardPredicates.fromRules(filterRules); filters = filters.and(rulesPrinted); } if (filterRarity != null) { diff --git a/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java b/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java index ef4fb90081e..d0c838fd048 100644 --- a/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java +++ b/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java @@ -19,6 +19,7 @@ import forge.gui.interfaces.IButton; import forge.item.InventoryItem; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.SItemManagerUtil.StatTypes; import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; @@ -50,7 +51,7 @@ public static Predicate buildTextFilter(String text, boolean invert, try { Predicate filter = expression.evaluate(); if (filter != null) { - return Predicates.compose(invert ? filter.negate() : filter, PaperCard::getRules); + return PaperCardPredicates.fromRules(invert ? filter.negate() : filter); } } catch (Exception ignored) { @@ -74,7 +75,7 @@ public static Predicate buildTextFilter(String text, boolean invert, Predicate textFilter; textFilter = invert ? Predicates.or(terms).negate() : Predicates.and(terms); - return Predicates.compose(textFilter, PaperCard::getRules); + return PaperCardPredicates.fromRules(textFilter); } private static List getSplitText(String text) { diff --git a/forge-gui/src/main/java/forge/model/FModel.java b/forge-gui/src/main/java/forge/model/FModel.java index fb2361ff127..6e4364ff6f8 100644 --- a/forge-gui/src/main/java/forge/model/FModel.java +++ b/forge-gui/src/main/java/forge/model/FModel.java @@ -49,6 +49,7 @@ import forge.gui.card.CardPreferences; import forge.gui.interfaces.IProgressBar; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManagerConfig; import forge.localinstance.achievements.*; import forge.localinstance.properties.ForgeConstants; @@ -324,13 +325,13 @@ public static ItemPool getAllCardsNoAlt() { public static ItemPool getArchenemyCards() { if (archenemyCards == null) - return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.IS_SCHEME, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules(CardRulesPredicates.IS_SCHEME)), PaperCard.class); return archenemyCards; } public static ItemPool getPlanechaseCards() { if (planechaseCards == null) - return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.IS_PLANE_OR_PHENOMENON, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules(CardRulesPredicates.IS_PLANE_OR_PHENOMENON)), PaperCard.class); return planechaseCards; } @@ -338,7 +339,7 @@ public static ItemPool getBrawlCommander() { if (brawlCommander == null) { return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt( FModel.getFormats().get("Brawl").getFilterPrinted() - .and(Predicates.compose(CardRulesPredicates.CAN_BE_BRAWL_COMMANDER, PaperCard::getRules)) + .and(PaperCardPredicates.fromRules(CardRulesPredicates.CAN_BE_BRAWL_COMMANDER)) ), PaperCard.class); } return brawlCommander; @@ -346,44 +347,50 @@ public static ItemPool getBrawlCommander() { public static ItemPool getOathbreakerCommander() { if (oathbreakerCommander == null) - return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(Predicates.compose( - CardRulesPredicates.CAN_BE_OATHBREAKER.or(CardRulesPredicates.CAN_BE_SIGNATURE_SPELL), PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(PaperCardPredicates.fromRules( + CardRulesPredicates.CAN_BE_OATHBREAKER.or(CardRulesPredicates.CAN_BE_SIGNATURE_SPELL))), PaperCard.class); return oathbreakerCommander; } public static ItemPool getTinyLeadersCommander() { if (tinyLeadersCommander == null) - return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(Predicates.compose(CardRulesPredicates.CAN_BE_TINY_LEADERS_COMMANDER, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(PaperCardPredicates.fromRules( + CardRulesPredicates.CAN_BE_TINY_LEADERS_COMMANDER)), PaperCard.class); return tinyLeadersCommander; } public static ItemPool getCommanderPool() { if (commanderPool == null) - return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(Predicates.compose(CardRulesPredicates.CAN_BE_COMMANDER, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(PaperCardPredicates.fromRules( + CardRulesPredicates.CAN_BE_COMMANDER)), PaperCard.class); return commanderPool; } public static ItemPool getAvatarPool() { if (avatarPool == null) - return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.IS_VANGUARD, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules( + CardRulesPredicates.IS_VANGUARD)), PaperCard.class); return avatarPool; } public static ItemPool getConspiracyPool() { if (conspiracyPool == null) - return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.IS_CONSPIRACY, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules( + CardRulesPredicates.IS_CONSPIRACY)), PaperCard.class); return conspiracyPool; } public static ItemPool getDungeonPool() { if (dungeonPool == null) - return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.IS_DUNGEON, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules( + CardRulesPredicates.IS_DUNGEON)), PaperCard.class); return dungeonPool; } public static ItemPool getAttractionPool() { if (attractionPool == null) - return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.IS_ATTRACTION, PaperCard::getRules)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules( + CardRulesPredicates.IS_ATTRACTION)), PaperCard.class); return attractionPool; } private static boolean keywordsLoaded = false; diff --git a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java index 6806ee794fb..8c2ed08fd73 100644 --- a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java +++ b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java @@ -11,6 +11,7 @@ import forge.deck.io.CardThemedLDAIO; import forge.deck.io.DeckStorage; import forge.gui.GuiBase; +import forge.item.PaperCardPredicates; import forge.lda.dataset.Dataset; import forge.lda.lda.LDA; import forge.game.GameFormat; @@ -290,8 +291,8 @@ public static HashMap>> initializeComma true); //get all cards - final Iterable cards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards() - , Predicates.compose(CardRulesPredicates.NOT_TRUE_BASIC_LAND, PaperCard::getRules)); + final Iterable cards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards(), + PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)); List cardList = Lists.newArrayList(cards); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); @@ -305,9 +306,9 @@ public static HashMap>> initializeComma } //filter to just legal commanders - List legends = Lists.newArrayList(Iterables.filter(cardList,Predicates.compose( - DeckFormat.Commander::isLegalCommander, PaperCard::getRules - ))); + List legends = Lists.newArrayList(Iterables.filter(cardList, PaperCardPredicates.fromRules( + DeckFormat.Commander::isLegalCommander)) + ); //generate lookups for legends to link commander names to matrix rows for (int i=0; i>> initializeComma public static void updateLegendMatrix(Deck deck, PaperCard legend, Map cardIntegerMap, Map legendIntegerMap, int[][] matrix){ for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(), - Predicates.compose(CardRulesPredicates.NOT_TRUE_BASIC_LAND, PaperCard::getRules))){ + PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND))){ if (!pairCard.getName().equals(legend.getName())){ try { int old = matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(pairCard.getName())]; From 6e3726ee7976310da9d0c4d3d818460ebf8e457c Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 6 Sep 2024 19:23:54 -0400 Subject: [PATCH 24/68] Guava migration - Remove unused imports --- forge-core/src/main/java/forge/deck/DeckFormat.java | 1 - forge-core/src/main/java/forge/item/IPaperCard.java | 10 ---------- forge-core/src/main/java/forge/item/SealedProduct.java | 1 - .../java/forge/game/ability/effects/VentureEffect.java | 1 - .../main/java/forge/game/combat/AttackConstraints.java | 1 - .../forge/itemmanager/filters/CardCMCRangeFilter.java | 1 - .../forge/itemmanager/filters/CardPowerFilter.java | 1 - .../forge/itemmanager/filters/CardToughnessFilter.java | 1 - .../java/forge/itemmanager/filters/StatTypeFilter.java | 1 - .../forge/screens/deckeditor/controllers/CDeckgen.java | 1 - .../deckeditor/controllers/CEditorCommander.java | 1 - .../screens/deckeditor/controllers/CEditorQuest.java | 1 - .../screens/deckeditor/controllers/CStatistics.java | 1 - .../deckeditor/controllers/CStatisticsImporter.java | 1 - .../PlanarConquestCommanderGeneraterGA.java | 1 - .../PlanarConquestTribalGeneraterGA.java | 1 - .../src/forge/adventure/character/EnemySprite.java | 1 - .../src/forge/itemmanager/filters/CardCMCFilter.java | 1 - .../itemmanager/filters/CardColorlessCostFilter.java | 1 - .../src/forge/itemmanager/filters/CardPowerFilter.java | 1 - .../forge/itemmanager/filters/CardToughnessFilter.java | 1 - .../java/forge/deck/CardRelationMatrixGenerator.java | 1 - .../main/java/forge/deck/CommanderDeckGenerator.java | 1 - .../limited/CardThemedCommanderDeckBuilder.java | 1 - .../limited/CardThemedConquestDeckBuilder.java | 1 - .../forge/gamemodes/limited/CardThemedDeckBuilder.java | 1 - .../forge/gamemodes/limited/LimitedDeckBuilder.java | 1 - .../java/forge/gamemodes/limited/LimitedPlayerAI.java | 1 - .../forge/gamemodes/planarconquest/ConquestRegion.java | 1 - .../java/forge/gamemodes/quest/QuestRewardCard.java | 1 - .../forge/gamemodes/quest/QuestUtilUnlockSets.java | 6 ------ .../forge/gamemodes/quest/QuestWinLoseController.java | 1 - .../src/main/java/forge/lda/LDAModelGenetrator.java | 1 - 33 files changed, 47 deletions(-) diff --git a/forge-core/src/main/java/forge/deck/DeckFormat.java b/forge-core/src/main/java/forge/deck/DeckFormat.java index 1ce0957a6b0..c7f0e055126 100644 --- a/forge-core/src/main/java/forge/deck/DeckFormat.java +++ b/forge-core/src/main/java/forge/deck/DeckFormat.java @@ -32,7 +32,6 @@ import forge.item.PaperCardPredicates; import forge.util.Aggregates; import forge.util.Iterables; -import forge.util.Predicates; import forge.util.TextUtil; import org.apache.commons.lang3.Range; import org.apache.commons.lang3.tuple.ImmutablePair; diff --git a/forge-core/src/main/java/forge/item/IPaperCard.java b/forge-core/src/main/java/forge/item/IPaperCard.java index 762186dd2f6..e30a3535a59 100644 --- a/forge-core/src/main/java/forge/item/IPaperCard.java +++ b/forge-core/src/main/java/forge/item/IPaperCard.java @@ -1,20 +1,10 @@ package forge.item; -import com.google.common.collect.Lists; import forge.card.CardRarity; import forge.card.CardRules; -import forge.card.CardType.CoreType; import forge.card.ICardFace; -import forge.card.MagicColor; -import forge.util.PredicateCard; -import forge.util.PredicateString; -import org.apache.commons.lang3.StringUtils; import java.io.Serializable; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.Predicate; public interface IPaperCard extends InventoryItem, Serializable { diff --git a/forge-core/src/main/java/forge/item/SealedProduct.java b/forge-core/src/main/java/forge/item/SealedProduct.java index 3cb69e379c1..4cddf19bb25 100644 --- a/forge-core/src/main/java/forge/item/SealedProduct.java +++ b/forge-core/src/main/java/forge/item/SealedProduct.java @@ -23,7 +23,6 @@ import forge.item.generation.BoosterGenerator; import forge.util.Aggregates; import forge.util.Iterables; -import forge.util.Predicates; import java.util.ArrayList; import java.util.List; diff --git a/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java b/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java index 6bd22dc454e..57333585a91 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/VentureEffect.java @@ -26,7 +26,6 @@ import forge.item.PaperCardPredicates; import forge.util.Localizer; import forge.util.PredicateString.StringOp; -import forge.util.Predicates; public class VentureEffect extends SpellAbilityEffect { 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 2f5e50d54cd..c179409b05f 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackConstraints.java +++ b/forge-game/src/main/java/forge/game/combat/AttackConstraints.java @@ -10,7 +10,6 @@ import java.util.function.Predicate; import forge.util.Iterables; -import forge.util.Predicates; import org.apache.commons.lang3.tuple.Pair; import com.google.common.collect.Collections2; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java index c06c56995cc..33c1e432737 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCRangeFilter.java @@ -5,7 +5,6 @@ import forge.item.PaperCard; import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; -import forge.util.Predicates; import java.util.function.Predicate; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java index 5ace0d2a6e8..6d3c35c1567 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardPowerFilter.java @@ -5,7 +5,6 @@ import forge.item.PaperCard; import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; -import forge.util.Predicates; import java.util.function.Predicate; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java index 1986379fb13..8a31412a9bb 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardToughnessFilter.java @@ -5,7 +5,6 @@ import forge.item.PaperCard; import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; -import forge.util.Predicates; import java.util.function.Predicate; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java index b857f2875d9..c271be9c13a 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/StatTypeFilter.java @@ -18,7 +18,6 @@ import forge.toolbox.FSkin; import forge.util.ItemPool; import forge.util.Localizer; -import forge.util.Predicates; public abstract class StatTypeFilter extends ToggleButtonsFilter { protected final Map buttonMap; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java index 1e18eebcfca..fb548eb6aa0 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java @@ -24,7 +24,6 @@ import forge.screens.deckeditor.views.VDeckgen; import forge.util.Aggregates; import forge.util.Iterables; -import forge.util.Predicates; import java.util.function.Predicate; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java index 35182542874..82483978ffc 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorCommander.java @@ -39,7 +39,6 @@ import forge.screens.match.controllers.CDetailPicture; import forge.toolbox.FComboBox; import forge.util.ItemPool; -import forge.util.Predicates; import java.util.ArrayList; import java.util.List; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java index f466923466a..fdd45ac3da2 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java @@ -60,7 +60,6 @@ import forge.screens.match.controllers.CDetailPicture; import forge.toolbox.FComboBox; import forge.util.ItemPool; -import forge.util.Predicates; /** * Child controller for quest deck editor UI. diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java index a4284504642..3785f9ed157 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatistics.java @@ -18,7 +18,6 @@ import forge.screens.deckeditor.views.VStatistics; import forge.util.ItemPool; import forge.util.Localizer; -import forge.util.Predicates; /** * Controls the "analysis" panel in the deck editor UI. diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java index 085b138dcb7..6663ac0dbd1 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CStatisticsImporter.java @@ -12,7 +12,6 @@ import forge.screens.deckeditor.views.VStatisticsImporter; import forge.util.ItemPool; import forge.util.Localizer; -import forge.util.Predicates; import javax.swing.*; import java.util.AbstractMap; diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java index 76f5a818c68..8dfef11ac4a 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java @@ -25,7 +25,6 @@ import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; import forge.util.Iterables; -import forge.util.Predicates; public class PlanarConquestCommanderGeneraterGA extends PlanarConquestGeneraterGA { diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java index 5b52f66fffa..c49fece3438 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java @@ -24,7 +24,6 @@ import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; import forge.util.Iterables; -import forge.util.Predicates; public class PlanarConquestTribalGeneraterGA extends PlanarConquestGeneraterGA { diff --git a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java index 7e23935c7d2..b8ad177eef1 100644 --- a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java +++ b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java @@ -33,7 +33,6 @@ import forge.item.PaperCardPredicates; import forge.util.Aggregates; import forge.util.MyRandom; -import forge.util.Predicates; import java.util.ArrayList; import java.util.LinkedList; diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java index 67c84b3d7bc..e40f9dedfa7 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardCMCFilter.java @@ -5,7 +5,6 @@ import forge.item.PaperCard; import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; -import forge.util.Predicates; import java.util.function.Predicate; diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java index 13990b86ffe..feea1f172a9 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardColorlessCostFilter.java @@ -5,7 +5,6 @@ import forge.item.PaperCard; import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; -import forge.util.Predicates; import java.util.function.Predicate; diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java index 42328d7beb0..476f26c489d 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardPowerFilter.java @@ -5,7 +5,6 @@ import forge.item.PaperCard; import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; -import forge.util.Predicates; import java.util.function.Predicate; diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java index 5722707c899..04930ad6630 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardToughnessFilter.java @@ -5,7 +5,6 @@ import forge.item.PaperCard; import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; -import forge.util.Predicates; import java.util.function.Predicate; diff --git a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java index 1834057e410..06ee1d63bfb 100644 --- a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java @@ -12,7 +12,6 @@ import forge.item.PaperCardPredicates; import forge.util.Iterables; -import forge.util.Predicates; import org.apache.commons.lang3.ArrayUtils; import com.google.common.collect.Lists; diff --git a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java index ea55de9b273..faa53cdbcf2 100644 --- a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java @@ -14,7 +14,6 @@ import forge.model.FModel; import forge.util.ItemPool; import forge.util.Iterables; -import forge.util.Predicates; /** * Created by maustin on 09/05/2017. diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java index da9113f070a..33242ff86b1 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java @@ -12,7 +12,6 @@ import forge.item.PaperCardPredicates; import forge.model.FModel; import forge.util.Iterables; -import forge.util.Predicates; /** * Created by maustin on 28/02/2018. diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java index a0358811826..214d68ab8b3 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java @@ -13,7 +13,6 @@ import forge.item.PaperCardPredicates; import forge.model.FModel; import forge.util.Iterables; -import forge.util.Predicates; /** * Created by maustin on 28/02/2018. diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java index f1ada5f12a2..64bbf3e007d 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java @@ -35,7 +35,6 @@ import forge.model.FModel; import forge.util.Iterables; import forge.util.MyRandom; -import forge.util.Predicates; /** * Limited format deck. diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java index 1d079402812..0662361e285 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java @@ -30,7 +30,6 @@ import forge.model.FModel; import forge.util.Iterables; import forge.util.MyRandom; -import forge.util.Predicates; /** * Limited format deck. diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java index 7154c78b7a4..52057254f13 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java @@ -11,7 +11,6 @@ import forge.localinstance.properties.ForgePreferences; import forge.util.Iterables; import forge.util.MyRandom; -import forge.util.Predicates; import org.apache.commons.lang3.tuple.Pair; import java.util.Collections; diff --git a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java index 01141e6a197..616c6ed7d5d 100644 --- a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java +++ b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestRegion.java @@ -15,7 +15,6 @@ import forge.item.PaperCardPredicates; import forge.localinstance.skin.ISkinImage; import forge.model.FModel; -import forge.util.Predicates; import forge.util.collect.FCollection; import forge.util.collect.FCollectionReader; import forge.util.collect.FCollectionView; diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java index fbfd8a5e37f..1d28040ea4e 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCard.java @@ -8,7 +8,6 @@ import forge.item.PaperCard; import forge.item.PaperCardPredicates; import forge.model.FModel; -import forge.util.Predicates; public abstract class QuestRewardCard implements IQuestRewardCard { diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java index f06dc93c3e5..7a72efbf537 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java @@ -17,12 +17,6 @@ */ package forge.gamemodes.quest; -import java.util.ArrayList; -import java.util.Collections; -import java.util.EnumSet; -import java.util.List; -import java.util.Map; - import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import forge.card.CardEdition; diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestWinLoseController.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestWinLoseController.java index 3cc2a52c06a..f6d448ab988 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestWinLoseController.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestWinLoseController.java @@ -18,7 +18,6 @@ import forge.gui.interfaces.IWinLoseView; import forge.gui.util.SGuiChoose; import forge.item.*; -import forge.item.PaperCardPredicates; import forge.item.generation.BoosterSlots; import forge.item.generation.IUnOpenedProduct; import forge.item.generation.UnOpenedProduct; diff --git a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java index 8c2ed08fd73..070f476b399 100644 --- a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java +++ b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java @@ -20,7 +20,6 @@ import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; import forge.util.Iterables; -import forge.util.Predicates; import forge.util.storage.IStorage; import forge.util.storage.StorageImmediatelySerialized; import org.apache.commons.lang3.ArrayUtils; From 4c8a94b18aa103668d5b806394b4a80c746955f2 Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 6 Sep 2024 19:48:19 -0400 Subject: [PATCH 25/68] Guava migration - Inline `Predicates.compose` --- forge-ai/src/main/java/forge/ai/AiController.java | 3 ++- forge-core/src/main/java/forge/card/DeckHints.java | 4 ++-- forge-core/src/main/java/forge/util/Predicates.java | 6 ------ .../java/forge/game/ability/effects/ChangeZoneEffect.java | 4 +++- .../forge/game/ability/effects/PlayLandVariantEffect.java | 4 ++-- .../src/main/java/forge/itemmanager/ItemManager.java | 5 +++-- forge-gui-mobile/src/forge/itemmanager/ItemManager.java | 2 +- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index 4d49aa2520f..4c2bf457523 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -61,6 +61,7 @@ import io.sentry.Sentry; import java.util.*; +import java.util.function.Function; import java.util.function.Predicate; /** @@ -2284,7 +2285,7 @@ public ReplacementEffect chooseSingleReplacementEffect(List l List shield = filterList(list, CardTraitPredicates.hasParam("ShieldCounter")); List regeneration = filterList(list, CardTraitPredicates.hasParam("Regeneration")); List umbraArmor = filterList(list, CardTraitPredicates.isKeyword(Keyword.UMBRA_ARMOR)); - List umbraArmorIndestructible = filterList(umbraArmor, Predicates.compose(CardPredicates.hasKeyword(Keyword.INDESTRUCTIBLE), CardTraitBase::getHostCard)); + List umbraArmorIndestructible = filterList(umbraArmor, x -> x.getHostCard().hasKeyword(Keyword.INDESTRUCTIBLE)); // Indestructible umbra armor is the best if (!umbraArmorIndestructible.isEmpty()) { diff --git a/forge-core/src/main/java/forge/card/DeckHints.java b/forge-core/src/main/java/forge/card/DeckHints.java index cf3c3fb3968..1e6aa3bcbed 100644 --- a/forge-core/src/main/java/forge/card/DeckHints.java +++ b/forge-core/src/main/java/forge/card/DeckHints.java @@ -8,7 +8,6 @@ import java.util.function.Predicate; import forge.util.Iterables; -import forge.util.Predicates; import org.apache.commons.lang3.tuple.Pair; import forge.StaticData; @@ -206,7 +205,8 @@ private List getCardsForFilter(Iterable cardList, Type typ private Iterable getMatchingItems(Iterable source, Predicate predicate, Function fn) { // TODO should token generators be counted differently for their potential? // And would there ever be a circumstance where `fn` should be anything but PaperCard::getRules? - return Iterables.filter(source, Predicates.compose(tokens ? rulesWithTokens(predicate) : predicate, fn)); + Predicate predicate1 = tokens ? rulesWithTokens(predicate) : predicate; + return Iterables.filter(source, x -> predicate1.test(fn.apply(x))); } public static Predicate rulesWithTokens(final Predicate predicate) { diff --git a/forge-core/src/main/java/forge/util/Predicates.java b/forge-core/src/main/java/forge/util/Predicates.java index 27e1cf9e6db..32938b844d1 100644 --- a/forge-core/src/main/java/forge/util/Predicates.java +++ b/forge-core/src/main/java/forge/util/Predicates.java @@ -1,6 +1,5 @@ package forge.util; -import java.util.function.Function; import java.util.function.Predicate; public class Predicates { @@ -15,9 +14,4 @@ public static Predicate or(Iterable> compo //TODO: Should be able to clean up the casting here. return x -> Iterables.any(components, (Predicate>) i -> i.test(x)); } - - //TODO: Most uses of this are with the function PaperCard::getRules. Maybe we should just have PaperCardPredicates? - public static Predicate compose(Predicate predicate, Function function) { - return x -> predicate.test(function.apply(x)); - } } diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java index 740fdeaaa51..ff1f205f057 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java @@ -26,6 +26,7 @@ import org.apache.commons.lang3.tuple.Pair; import java.util.*; +import java.util.function.Function; import java.util.function.Predicate; public class ChangeZoneEffect extends SpellAbilityEffect { @@ -1151,7 +1152,8 @@ else if (origin.contains(ZoneType.Hand) && player.isOpponentOf(decider)) { } if (sa.hasParam("DifferentPower")) { for (Card c : chosenCards) { - fetchList = CardLists.filter(fetchList, Predicates.compose(Predicate.isEqual(c.getNetPower()), Card::getNetPower).negate()); + int chosenPower = c.getNetPower(); + fetchList = CardLists.filter(fetchList, x -> x.getNetPower() != chosenPower); } } if (sa.hasParam("ShareLandType")) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java index 32e8dd47282..dc3759a4c2c 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java @@ -1,6 +1,7 @@ package forge.game.ability.effects; import java.util.List; +import java.util.function.Function; import java.util.function.Predicate; import com.google.common.collect.Lists; @@ -19,7 +20,6 @@ import forge.item.PaperCardPredicates; import forge.util.Aggregates; import forge.util.Iterables; -import forge.util.Predicates; public class PlayLandVariantEffect extends SpellAbilityEffect { @@ -48,7 +48,7 @@ public void resolve(final SpellAbility sa) { } } - final Predicate cp = Predicates.compose(landNames::contains, PaperCard::getName); + final Predicate cp = x -> landNames.contains(x.getName()); cards = Lists.newArrayList(Iterables.filter(cards, cp)); // get a random basic land Card random; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java b/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java index 666549e3ab2..66db3ed59ca 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java @@ -48,6 +48,7 @@ import java.util.List; import java.util.*; import java.util.Map.Entry; +import java.util.function.Function; import java.util.function.Predicate; /** @@ -1002,12 +1003,12 @@ public void updateView(final boolean forceFilter, final Iterable itemsToSelec } if (useFilter && this.wantUnique) { - final Predicate> filterForPool = Predicates.compose(this.filterPredicate, Entry::getKey); + final Predicate> filterForPool = x -> this.filterPredicate.test(x.getKey()); final Iterable> items = getUnique(Iterables.filter(this.pool, filterForPool)); this.model.addItems(items); } else if (useFilter) { - final Predicate> pred = Predicates.compose(this.filterPredicate, Entry::getKey); + final Predicate> pred = x -> this.filterPredicate.test(x.getKey());; this.model.addItems(Iterables.filter(this.pool, pred)); } else if (this.wantUnique) { diff --git a/forge-gui-mobile/src/forge/itemmanager/ItemManager.java b/forge-gui-mobile/src/forge/itemmanager/ItemManager.java index e79add651a8..0ec421ddb30 100644 --- a/forge-gui-mobile/src/forge/itemmanager/ItemManager.java +++ b/forge-gui-mobile/src/forge/itemmanager/ItemManager.java @@ -782,7 +782,7 @@ public void updateView(final boolean forceFilter, final Iterable itemsToSelec Iterable> items = pool; if (useFilter) { - Predicate> pred = Predicates.compose(filterPredicate, (Function, T>) Entry::getKey); + Predicate> pred = x -> filterPredicate.test(x.getKey()); items = Iterables.filter(pool, pred); } model.addItems(items); From efe55efa435091f3fe6e098dcef1393e8fe75262 Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 6 Sep 2024 19:55:57 -0400 Subject: [PATCH 26/68] Guava migration - Inline `Iterables.isEmpty` (Collection overload) --- forge-ai/src/main/java/forge/ai/ability/UntapAi.java | 4 ++-- forge-core/src/main/java/forge/util/Iterables.java | 3 --- .../java/forge/game/event/GameEventPlayerStatsChanged.java | 3 +-- forge-gui-mobile/src/forge/screens/match/MatchController.java | 3 +-- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/UntapAi.java b/forge-ai/src/main/java/forge/ai/ability/UntapAi.java index 6f98186da85..8366a2d6df8 100644 --- a/forge-ai/src/main/java/forge/ai/ability/UntapAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/UntapAi.java @@ -21,8 +21,8 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; -import forge.util.Iterables; +import java.util.Collection; import java.util.List; import java.util.Map; @@ -319,7 +319,7 @@ private boolean untapTargetList(final Card source, final TargetRestrictions tgt, @Override public Card chooseSingleCard(Player ai, SpellAbility sa, Iterable list, boolean isOptional, Player targetedPlayer, Map params) { CardCollection pref = CardLists.filterControlledBy(list, ai.getYourTeam()); - if (Iterables.isEmpty(pref)) { + if (pref.isEmpty()) { if (isOptional) { return null; } diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index acc6fc365c7..c3e85351072 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -113,9 +113,6 @@ public static T getLast(List iterable) { public static T getLast(List iterable, T defaultValue) { return iterable.isEmpty() ? defaultValue : iterable.get(iterable.size() - 1); } - public static boolean isEmpty(Collection iterable) { - return iterable.isEmpty(); - } //TODO: Restore everything below public static Iterable unmodifiableIterable(final Iterable iterable) { diff --git a/forge-game/src/main/java/forge/game/event/GameEventPlayerStatsChanged.java b/forge-game/src/main/java/forge/game/event/GameEventPlayerStatsChanged.java index de03c752a2c..b077517cc24 100644 --- a/forge-game/src/main/java/forge/game/event/GameEventPlayerStatsChanged.java +++ b/forge-game/src/main/java/forge/game/event/GameEventPlayerStatsChanged.java @@ -4,7 +4,6 @@ import java.util.Collection; import forge.game.player.Player; -import forge.util.Iterables; import forge.util.Lang; import forge.util.TextUtil; @@ -36,7 +35,7 @@ public T visit(IGameEventVisitor visitor) { @Override public String toString() { - if (null == players || Iterables.isEmpty(players)) { + if (null == players || players.isEmpty()) { return "Player state changes: (empty list)"; } return TextUtil.concatWithSpace("Player state changes:", Lang.joinHomogenous(players)); diff --git a/forge-gui-mobile/src/forge/screens/match/MatchController.java b/forge-gui-mobile/src/forge/screens/match/MatchController.java index ed63a73b1bb..46cc4aa7956 100644 --- a/forge-gui-mobile/src/forge/screens/match/MatchController.java +++ b/forge-gui-mobile/src/forge/screens/match/MatchController.java @@ -12,7 +12,6 @@ import forge.deck.Deck; import forge.game.player.Player; import forge.item.IPaperCard; -import forge.util.Iterables; import forge.util.collect.FCollection; import org.apache.commons.lang3.StringUtils; @@ -680,7 +679,7 @@ public void run() { @Override public GameEntityView chooseSingleEntityForEffect(final String title, final List optionList, final DelayedReveal delayedReveal, final boolean isOptional) { - if (delayedReveal == null || Iterables.isEmpty(delayedReveal.getCards())) { + if (delayedReveal == null || delayedReveal.getCards().isEmpty()) { if (isOptional) { return SGuiChoose.oneOrNone(title, optionList); } From c1de0dee6a32624f487ab3879264c9bc9877188c Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 6 Sep 2024 19:58:24 -0400 Subject: [PATCH 27/68] Guava migration - Inline `Iterables.removeAll` (Collection overload) --- forge-core/src/main/java/forge/util/Iterables.java | 4 ---- .../src/main/java/forge/player/PlayerControllerHuman.java | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index c3e85351072..05efef2204a 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -83,10 +83,6 @@ public static boolean removeIf(Collection iterable, Predicate return iterable.removeIf(test); } - public static boolean removeAll(Collection removeFrom, Collection toRemove) { - return removeFrom.removeAll(toRemove); - } - public static int size(Collection collection) { return collection.size(); } diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index 525dd6dd4d8..50d47dce45e 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -1255,7 +1255,7 @@ public String chooseSomeType(final String kindOfType, final SpellAbility sa, fin final List invalidTypes, final boolean isOptional) { final List types = Lists.newArrayList(validTypes); if (invalidTypes != null && !invalidTypes.isEmpty()) { - Iterables.removeAll(types, invalidTypes); + types.removeAll(invalidTypes); } if (kindOfType.equals("Creature")) { sortCreatureTypes(types); From d9c54aa9a1d95833125b618be593b0049e5c4886 Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 6 Sep 2024 20:18:49 -0400 Subject: [PATCH 28/68] Guava migration - Inline `Iterables.addAll` (Collection overload) --- .../src/main/java/forge/ai/ComputerUtil.java | 4 ++-- .../src/main/java/forge/card/DeckHints.java | 19 ++++++++---------- .../src/main/java/forge/util/Iterables.java | 8 -------- .../src/main/java/forge/game/GameAction.java | 2 +- .../main/java/forge/game/StaticEffects.java | 3 +-- .../java/forge/game/ability/AbilityUtils.java | 20 +++++++++---------- .../game/ability/SpellAbilityEffect.java | 4 ++-- .../ability/effects/CountersPutEffect.java | 8 ++++---- .../java/forge/game/card/CardFactoryUtil.java | 2 +- .../java/forge/game/card/token/TokenInfo.java | 2 +- .../main/java/forge/game/player/Player.java | 2 +- .../forge/game/spellability/SpellAbility.java | 2 +- .../forge/game/trigger/TriggerHandler.java | 2 +- .../gamemodes/limited/LimitedDeckBuilder.java | 12 +++-------- 14 files changed, 36 insertions(+), 54 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index c7add8c8347..de6b2a7aa2c 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -1753,7 +1753,7 @@ public static List predictThreatenedObjects(final Player ai, final S sub = sub.getSubAbility(); } if (sa == null || (sa != spell && sa != sub)) { - Iterables.addAll(objects, predictThreatenedObjects(ai, sa, spell)); + predictThreatenedObjects(ai, sa, spell).forEach(objects::add); } if (top) { break; // only evaluate top-stack @@ -2103,7 +2103,7 @@ else if ((threatApi == ApiType.Attach && (topStack.isCurse() || "Curse".equals(t } } - Iterables.addAll(threatened, predictThreatenedObjects(aiPlayer, saviour, topStack.getSubAbility())); + predictThreatenedObjects(aiPlayer, saviour, topStack.getSubAbility()).forEach(threatened::add); return threatened; } diff --git a/forge-core/src/main/java/forge/card/DeckHints.java b/forge-core/src/main/java/forge/card/DeckHints.java index 1e6aa3bcbed..9f3a3bc43bc 100644 --- a/forge-core/src/main/java/forge/card/DeckHints.java +++ b/forge-core/src/main/java/forge/card/DeckHints.java @@ -1,9 +1,6 @@ package forge.card; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.function.Function; import java.util.function.Predicate; @@ -168,11 +165,11 @@ private List getCardsForFilter(Iterable cardList, Type typ // this is case ABILITY, but other types can also use this when the implicit parsing would miss String[] params = param.split("\\|"); for (String ability : params) { - Iterables.addAll(cards, getMatchingItems(cardList, CardRulesPredicates.deckHas(type, ability), PaperCard::getRules)); + getMatchingItems(cardList, CardRulesPredicates.deckHas(type, ability), PaperCard::getRules).forEach(cards::add); } // bonus if a DeckHas can satisfy the type with multiple ones if (params.length > 1) { - Iterables.addAll(cards, getMatchingItems(cardList, CardRulesPredicates.deckHasExactly(type, params), PaperCard::getRules)); + getMatchingItems(cardList, CardRulesPredicates.deckHasExactly(type, params), PaperCard::getRules).forEach(cards::add); } for (String p : params) { @@ -180,19 +177,19 @@ private List getCardsForFilter(Iterable cardList, Type typ case COLOR: ColorSet cc = ColorSet.fromNames(p); if (cc.isColorless()) { - Iterables.addAll(cards, getMatchingItems(cardList, CardRulesPredicates.IS_COLORLESS, PaperCard::getRules)); + getMatchingItems(cardList, CardRulesPredicates.IS_COLORLESS, PaperCard::getRules).forEach(cards::add); } else { - Iterables.addAll(cards, getMatchingItems(cardList, CardRulesPredicates.isColor(cc.getColor()), PaperCard::getRules)); + getMatchingItems(cardList, CardRulesPredicates.isColor(cc.getColor()), PaperCard::getRules).forEach(cards::add); } break; case KEYWORD: - Iterables.addAll(cards, getMatchingItems(cardList, CardRulesPredicates.hasKeyword(p), PaperCard::getRules)); + getMatchingItems(cardList, CardRulesPredicates.hasKeyword(p), PaperCard::getRules).forEach(cards::add); break; case NAME: - Iterables.addAll(cards, getMatchingItems(cardList, CardRulesPredicates.name(StringOp.EQUALS, p), PaperCard::getRules)); + getMatchingItems(cardList, CardRulesPredicates.name(StringOp.EQUALS, p), PaperCard::getRules).forEach(cards::add); break; case TYPE: - Iterables.addAll(cards, getMatchingItems(cardList, CardRulesPredicates.joinedType(StringOp.CONTAINS_IC, p), PaperCard::getRules)); + getMatchingItems(cardList, CardRulesPredicates.joinedType(StringOp.CONTAINS_IC, p), PaperCard::getRules).forEach(cards::add); break; case NONE: case ABILITY: // already done above diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index 05efef2204a..94d00934680 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -91,14 +91,6 @@ public static boolean contains(Collection collection, Object element) { return collection.contains(element); } - public static boolean addAll(Collection collection, Collection toAdd) { - return collection.addAll(toAdd); - } - - public static void addAll(Collection collection, Iterable toAdd) { - toAdd.forEach(collection::add); - } - public static T getFirst(List iterable, T defaultValue) { return iterable.isEmpty() ? defaultValue : iterable.get(0); } diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index ad3653e9e86..55141bba74a 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -1178,7 +1178,7 @@ public boolean visit(final Card c) { for (final CardCollectionView affected : affectedPerAbility.values()) { if (affected != null) { - Iterables.addAll(affectedCards, affected); + affected.forEach(affectedCards::add); } } diff --git a/forge-game/src/main/java/forge/game/StaticEffects.java b/forge-game/src/main/java/forge/game/StaticEffects.java index 287a9193914..75cdf8982a0 100644 --- a/forge-game/src/main/java/forge/game/StaticEffects.java +++ b/forge-game/src/main/java/forge/game/StaticEffects.java @@ -24,7 +24,6 @@ import forge.game.card.Card; import forge.game.staticability.StaticAbility; -import forge.util.Iterables; /** *

@@ -42,7 +41,7 @@ public class StaticEffects { public final void clearStaticEffects(final Set affectedCards) { // remove all static effects for (final StaticEffect se : staticEffects.values()) { - Iterables.addAll(affectedCards, se.remove()); + se.remove().forEach(affectedCards::add); } this.staticEffects.clear(); } diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index a4e2b9b397c..5d84da5f3e2 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -160,12 +160,12 @@ public static CardCollection getDefinedCards(final Card hostCard, final String d } } else if (defined.equals("ThisTargetedCard") && sa instanceof SpellAbility) { // do not add parent targeted if (((SpellAbility)sa).getTargets() != null) { - Iterables.addAll(cards, ((SpellAbility)sa).getTargets().getTargetCards()); + ((SpellAbility)sa).getTargets().getTargetCards().forEach(cards::add); } } else if (defined.equals("ParentTarget") && sa instanceof SpellAbility) { final SpellAbility parent = ((SpellAbility)sa).getParentTargetingCard(); if (parent != null) { - Iterables.addAll(cards, parent.getTargets().getTargetCards()); + parent.getTargets().getTargetCards().forEach(cards::add); } } else if (defined.startsWith("Triggered") && sa instanceof SpellAbility) { final SpellAbility root = ((SpellAbility)sa).getRootAbility(); @@ -599,13 +599,13 @@ else if (ability instanceof SpellAbility) { final List players = new ArrayList<>(); final SpellAbility saTargeting = sa.getSATargetingPlayer(); if (null != saTargeting) { - Iterables.addAll(players, saTargeting.getTargets().getTargetPlayers()); + saTargeting.getTargets().getTargetPlayers().forEach(players::add); } val = playerXCount(players, calcX[1], card, ability); } else if (calcX[0].startsWith("ThisTargetedPlayer")) { final List players = new ArrayList<>(); - Iterables.addAll(players, sa.getTargets().getTargetPlayers()); + sa.getTargets().getTargetPlayers().forEach(players::add); val = playerXCount(players, calcX[1], card, ability); } else if (calcX[0].startsWith("TargetedObjects")) { @@ -614,7 +614,7 @@ else if (calcX[0].startsWith("TargetedObjects")) { SpellAbility loopSA = sa.getRootAbility(); while (loopSA != null) { if (loopSA.usesTargeting()) { - Iterables.addAll(objects, loopSA.getTargets()); + objects.addAll(loopSA.getTargets()); } loopSA = loopSA.getSubAbility(); } @@ -970,7 +970,7 @@ public static PlayerCollection getDefinedPlayers(final Card card, final String d } } else if (defined.equals("ThisTargetedPlayer") && sa instanceof SpellAbility) { // do not add parent targeted if (((SpellAbility)sa).getTargets() != null) { - Iterables.addAll(players, ((SpellAbility)sa).getTargets().getTargetPlayers()); + ((SpellAbility)sa).getTargets().getTargetPlayers().forEach(players::add); } } else if (defined.equals("TargetedController")) { for (final Card c : getDefinedCards(card, "Targeted", sa)) { @@ -2645,7 +2645,7 @@ public static int xCount(Card c, final String s, final CardTraitBase ctb) { final Set creatTypes = Sets.newHashSet(); for (Card card : cards) { - Iterables.addAll(creatTypes, card.getType().getCreatureTypes()); + creatTypes.addAll(card.getType().getCreatureTypes()); } // filter out fun types? return doXMath(creatTypes.size(), expr, c, ctb); @@ -3915,7 +3915,7 @@ private static CardCollection getPaidCards(CardTraitBase sa, String defined) { public static int countCardTypesFromList(final Iterable list, boolean permanentTypes) { EnumSet types = EnumSet.noneOf(CardType.CoreType.class); for (Card c1 : list) { - Iterables.addAll(types, c1.getType().getCoreTypes()); + c1.getType().getCoreTypes().forEach(types::add); } if (permanentTypes) return (int) types.stream().filter(type -> type.isPermanent).count(); @@ -3925,7 +3925,7 @@ public static int countCardTypesFromList(final Iterable list, boolean perm public static int countSuperTypesFromList(final Iterable list) { EnumSet types = EnumSet.noneOf(CardType.Supertype.class); for (Card c1 : list) { - Iterables.addAll(types, c1.getType().getSupertypes()); + c1.getType().getSupertypes().forEach(types::add); } return types.size(); @@ -3934,7 +3934,7 @@ public static int countSuperTypesFromList(final Iterable list) { public static int countSubTypesFromList(final Iterable list) { Set types = new HashSet<>(); for (Card c1 : list) { - Iterables.addAll(types, c1.getType().getSubtypes()); + c1.getType().getSubtypes().forEach(types::add); } return types.size(); diff --git a/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java b/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java index b9ee94018ff..ff7170bff06 100644 --- a/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java +++ b/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java @@ -229,7 +229,7 @@ private static CardCollection getCards(final boolean definedFirst, final String resultUnique = new CardCollection(); resultDuplicate = resultUnique; } - Iterables.addAll(resultDuplicate, sa.getTargets().getTargetCards()); + sa.getTargets().getTargetCards().forEach(resultDuplicate::add); } else { String[] def = sa.getParamOrDefault(definedParam, "Self").split(" & "); for (String d : def) { @@ -269,7 +269,7 @@ private static PlayerCollection getPlayers(final boolean definedFirst, final Str resultUnique = new PlayerCollection(); resultDuplicate = resultUnique; } - Iterables.addAll(resultDuplicate, sa.getTargets().getTargetPlayers()); + sa.getTargets().getTargetPlayers().forEach(resultDuplicate::add); } else { String[] def = sa.getParamOrDefault(definedParam, "You").split(" & "); for (String d : def) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java index c8e0dbc1898..5313fb709c0 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java @@ -193,8 +193,8 @@ protected void resolvePerType(SpellAbility sa, Player placer, CounterType counte Map params = Maps.newHashMap(); params.put("CounterType", counterType); - Iterables.addAll(tgtObjects, activator.getController().chooseCardsForEffect(leastToughness, sa, - Localizer.getInstance().getMessage("lblChooseACreatureWithLeastToughness"), 1, 1, false, params)); + activator.getController().chooseCardsForEffect(leastToughness, sa, + Localizer.getInstance().getMessage("lblChooseACreatureWithLeastToughness"), 1, 1, false, params).forEach(tgtObjects::add); } else if (sa.hasParam("Choices") && (counterType != null || putOnEachOther || putOnDefined)) { ZoneType choiceZone = ZoneType.Battlefield; if (sa.hasParam("ChoiceZone")) { @@ -242,8 +242,8 @@ protected void resolvePerType(SpellAbility sa, Player placer, CounterType counte if (sa.hasParam("DividedRandomly")) { tgtObjects.addAll(choices); } else { - Iterables.addAll(tgtObjects, chooser.getController().chooseCardsForEffect(choices, sa, title, m, n, - sa.hasParam("ChoiceOptional"), params)); + chooser.getController().chooseCardsForEffect(choices, sa, title, m, n, + sa.hasParam("ChoiceOptional"), params).forEach(tgtObjects::add); } } else { tgtObjects.addAll(getDefinedEntitiesOrTargeted(sa, "Defined")); diff --git a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java index 61f6a3bddba..b8954b02970 100644 --- a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java +++ b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java @@ -516,7 +516,7 @@ public static List getSharedKeywords(final Iterable kw, final Ca public static int getCardTypesFromList(final CardCollectionView list) { EnumSet types = EnumSet.noneOf(CardType.CoreType.class); for (Card c1 : list) { - Iterables.addAll(types, c1.getType().getCoreTypes()); + c1.getType().getCoreTypes().forEach(types::add); } return types.size(); } diff --git a/forge-game/src/main/java/forge/game/card/token/TokenInfo.java b/forge-game/src/main/java/forge/game/card/token/TokenInfo.java index 09391459716..35ea443f86c 100644 --- a/forge-game/src/main/java/forge/game/card/token/TokenInfo.java +++ b/forge-game/src/main/java/forge/game/card/token/TokenInfo.java @@ -101,7 +101,7 @@ private static String[] getCardTypes(Card c) { for (CardType.CoreType t : c.getType().getCoreTypes()) { relevantTypes.add(t.name()); } - Iterables.addAll(relevantTypes, c.getType().getSubtypes()); + c.getType().getSubtypes().forEach(relevantTypes::add); if (c.getType().isLegendary()) { relevantTypes.add("Legendary"); } diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index 4d0927210bb..8a04b8e59f3 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -1925,7 +1925,7 @@ public final void clearAttackedMyTurn() { } public final void setAttackedPlayersMyLastTurn(Iterable players) { attackedPlayersLastTurn.clear(); - Iterables.addAll(attackedPlayersLastTurn, players); + players.forEach(attackedPlayersLastTurn::add); } public final List getAttackedPlayersMyCombat() { diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java index 88bae9d92e2..a9d7c3c1a7a 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java @@ -1994,7 +1994,7 @@ public final List getUniqueTargets() { SpellAbility child = getParent(); while (child != null) { if (child.usesTargeting()) { - Iterables.addAll(targets, child.getTargets()); + targets.addAll(child.getTargets()); } child = child.getParent(); } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java b/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java index 8e5951a0d44..bb2f9c48e86 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java @@ -102,7 +102,7 @@ public final void clearPlayerDefinedDelayedTrigger() { public final void handlePlayerDefinedDelTriggers(final Player player) { final List playerTriggers = playerDefinedDelayedTriggers.removeAll(player); - Iterables.addAll(thisTurnDelayedTriggers, Iterables.filter(playerTriggers, CardTraitPredicates.hasParam("ThisTurn"))); + Iterables.filter(playerTriggers, CardTraitPredicates.hasParam("ThisTurn")).forEach(thisTurnDelayedTriggers::add); delayedTriggers.addAll(playerTriggers); } diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java index 0662361e285..9e2e09d4fc0 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java @@ -1,12 +1,6 @@ package forge.gamemodes.limited; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.function.Predicate; import com.google.common.collect.Lists; @@ -590,10 +584,10 @@ private void checkRemRandomDeckCards() { if (ai.getRemRandomDecks()) { final List comboCards = new ArrayList<>(); if (ai.getDeckNeeds() != null && ai.getDeckNeeds().isValid()) { - Iterables.addAll(comboCards, ai.getDeckNeeds().filter(deckList)); + ai.getDeckNeeds().filter(deckList).forEach(comboCards::add); } if (ai.getDeckHints() != null && ai.getDeckHints().isValid()) { - Iterables.addAll(comboCards, ai.getDeckHints().filter(deckList)); + ai.getDeckHints().filter(deckList).forEach(comboCards::add); } if (comboCards.isEmpty()) { if (logToConsole) { From 79a640ca8a361e9942a49618d04b21bf67c1308f Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 6 Sep 2024 20:20:06 -0400 Subject: [PATCH 29/68] Guava migration - Cleanup imports --- forge-ai/src/main/java/forge/ai/AiController.java | 1 - forge-ai/src/main/java/forge/ai/ability/UntapAi.java | 1 - .../main/java/forge/game/ability/effects/ChangeZoneEffect.java | 2 -- .../java/forge/game/ability/effects/PlayLandVariantEffect.java | 1 - .../src/main/java/forge/itemmanager/ItemManager.java | 1 - 5 files changed, 6 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index 4c2bf457523..a899fedab4a 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -61,7 +61,6 @@ import io.sentry.Sentry; import java.util.*; -import java.util.function.Function; import java.util.function.Predicate; /** diff --git a/forge-ai/src/main/java/forge/ai/ability/UntapAi.java b/forge-ai/src/main/java/forge/ai/ability/UntapAi.java index 8366a2d6df8..72e08815282 100644 --- a/forge-ai/src/main/java/forge/ai/ability/UntapAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/UntapAi.java @@ -22,7 +22,6 @@ import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; -import java.util.Collection; import java.util.List; import java.util.Map; diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java index ff1f205f057..4afeb09a479 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java @@ -26,8 +26,6 @@ import org.apache.commons.lang3.tuple.Pair; import java.util.*; -import java.util.function.Function; -import java.util.function.Predicate; public class ChangeZoneEffect extends SpellAbilityEffect { diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java index dc3759a4c2c..a36b078df29 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java @@ -1,7 +1,6 @@ package forge.game.ability.effects; import java.util.List; -import java.util.function.Function; import java.util.function.Predicate; import com.google.common.collect.Lists; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java b/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java index 66db3ed59ca..79c0b3fc5a9 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java @@ -48,7 +48,6 @@ import java.util.List; import java.util.*; import java.util.Map.Entry; -import java.util.function.Function; import java.util.function.Predicate; /** From 8489866461358f4ec8c67ee8c276a5f6f74c626d Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 6 Sep 2024 20:23:14 -0400 Subject: [PATCH 30/68] Guava migration - Inline `Iterables.contains` (Collection overload) --- forge-game/src/main/java/forge/game/card/CardProperty.java | 7 ++----- .../src/main/java/forge/game/player/PlayerProperty.java | 7 ++----- .../java/forge/game/trigger/TriggerChangesZoneAll.java | 3 +-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/forge-game/src/main/java/forge/game/card/CardProperty.java b/forge-game/src/main/java/forge/game/card/CardProperty.java index e1f99498f7c..3ff761d11a7 100644 --- a/forge-game/src/main/java/forge/game/card/CardProperty.java +++ b/forge-game/src/main/java/forge/game/card/CardProperty.java @@ -34,10 +34,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.Set; +import java.util.*; public class CardProperty { @@ -2132,7 +2129,7 @@ else if (property.equals("blocked")) { } } else if (property.startsWith("NotDefined")) { final String key = property.substring("NotDefined".length()); - if (Iterables.contains(AbilityUtils.getDefinedCards(source, key, spellAbility), card)) { + if (AbilityUtils.getDefinedCards(source, key, spellAbility).contains(card)) { return false; } } else if (property.equals("CanPayManaCost")) { diff --git a/forge-game/src/main/java/forge/game/player/PlayerProperty.java b/forge-game/src/main/java/forge/game/player/PlayerProperty.java index e6c24337f47..182d843e034 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerProperty.java +++ b/forge-game/src/main/java/forge/game/player/PlayerProperty.java @@ -13,10 +13,7 @@ import forge.util.Iterables; import forge.util.TextUtil; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -259,7 +256,7 @@ public static boolean playerHasProperty(Player player, String property, Player s } else if (property.equals("NotedDefender")) { String tracker = player.getDraftNotes().getOrDefault("Cogwork Tracker", ""); - return Iterables.contains(Arrays.asList(tracker.split(",")), String.valueOf(player)); + return Arrays.asList(tracker.split(",")).contains(String.valueOf(player)); } else if (property.startsWith("life")) { int life = player.getLife(); int amount = AbilityUtils.calculateAmount(source, property.substring(6), spellAbility); diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerChangesZoneAll.java b/forge-game/src/main/java/forge/game/trigger/TriggerChangesZoneAll.java index 3809370f86d..9516845b82f 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerChangesZoneAll.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerChangesZoneAll.java @@ -12,7 +12,6 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Expressions; -import forge.util.Iterables; import forge.util.Localizer; public class TriggerChangesZoneAll extends Trigger { @@ -26,7 +25,7 @@ public boolean performTest(Map runParams) { final CardZoneTable table = (CardZoneTable) runParams.get(AbilityKey.Cards); // leaves the GY trigger look back in time - if (Iterables.contains(getActiveZone(), ZoneType.Battlefield) && "Graveyard".equals(getParam("Origin")) + if (getActiveZone().contains(ZoneType.Battlefield) && "Graveyard".equals(getParam("Origin")) && !table.getLastStateBattlefield().contains(getHostCard())) { return false; } From 36cff7e4010bd34c0fdc02e98cafc9801c312368 Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 6 Sep 2024 20:32:22 -0400 Subject: [PATCH 31/68] Guava migration - Inline `Iterables.removeIf` (Collection overload) --- .../src/main/java/forge/ai/AiController.java | 2 +- .../main/java/forge/ai/ComputerUtilMana.java | 6 ++-- .../src/main/java/forge/card/CardType.java | 28 +++++++++---------- .../src/main/java/forge/util/Iterables.java | 4 --- .../game/ability/effects/PumpEffect.java | 4 +-- .../StaticAbilityContinuous.java | 8 +++--- 6 files changed, 24 insertions(+), 28 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index a899fedab4a..5496faa2e9a 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -1538,7 +1538,7 @@ private SpellAbility getSpellAbilityToPlay() { saList = ComputerUtilAbility.getSpellAbilities(cards, player); } - Iterables.removeIf(saList, spellAbility -> { //don't include removedAI cards if somehow the AI can play the ability or gain control of unsupported card + saList.removeIf(spellAbility -> { //don't include removedAI cards if somehow the AI can play the ability or gain control of unsupported card // TODO allow when experimental profile? return spellAbility.isLandAbility() || (spellAbility.getHostCard() != null && ComputerUtilCard.isCardRemAIDeck(spellAbility.getHostCard())); }); diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index 027fd436dfc..37050fdffe0 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -612,7 +612,7 @@ public static CardCollection getManaSourcesToPayCost(final ManaCostBeingPaid cos payMultipleMana(cost, manaProduced, ai); // remove from available lists - Iterables.removeIf(sourcesForShards.values(), CardTraitPredicates.isHostCard(saPayment.getHostCard())); + sourcesForShards.values().removeIf(CardTraitPredicates.isHostCard(saPayment.getHostCard())); } CostPayment.handleOfferings(sa, true, cost.isPaid()); @@ -794,7 +794,7 @@ private static boolean payManaCost(final ManaCostBeingPaid cost, final SpellAbil payMultipleMana(cost, manaProduced, ai); // remove from available lists - Iterables.removeIf(sourcesForShards.values(), CardTraitPredicates.isHostCard(saPayment.getHostCard())); + sourcesForShards.values().removeIf(CardTraitPredicates.isHostCard(saPayment.getHostCard())); } else { final CostPayment pay = new CostPayment(saPayment.getPayCosts(), saPayment); if (!pay.payComputerCosts(new AiCostDecision(ai, saPayment, effect))) { @@ -811,7 +811,7 @@ private static boolean payManaCost(final ManaCostBeingPaid cost, final SpellAbil if (hasConverge) { // hack to prevent converge re-using sources - Iterables.removeIf(sourcesForShards.values(), CardTraitPredicates.isHostCard(saPayment.getHostCard())); + sourcesForShards.values().removeIf(CardTraitPredicates.isHostCard(saPayment.getHostCard())); } } } diff --git a/forge-core/src/main/java/forge/card/CardType.java b/forge-core/src/main/java/forge/card/CardType.java index 9c4f30b23b6..9b8931a2905 100644 --- a/forge-core/src/main/java/forge/card/CardType.java +++ b/forge-core/src/main/java/forge/card/CardType.java @@ -261,7 +261,7 @@ public boolean setCreatureTypes(Collection ctypes) { if (!isCreature() && !isKindred()) { return false; } - boolean changed = Iterables.removeIf(subtypes, Predicates.IS_CREATURE_TYPE); + boolean changed = subtypes.removeIf(Predicates.IS_CREATURE_TYPE); // need to remove AllCreatureTypes too when setting Creature Type if (allCreatureTypes) { changed = true; @@ -605,18 +605,18 @@ public CardTypeView getTypeWithChanges(final Iterable changedCa } else if (!newType.subtypes.isEmpty()) { if (ct.isRemoveLandTypes()) { - Iterables.removeIf(newType.subtypes, Predicates.IS_LAND_TYPE); + newType.subtypes.removeIf(Predicates.IS_LAND_TYPE); } if (ct.isRemoveCreatureTypes()) { - Iterables.removeIf(newType.subtypes, Predicates.IS_CREATURE_TYPE); + newType.subtypes.removeIf(Predicates.IS_CREATURE_TYPE); // need to remove AllCreatureTypes too when removing creature Types newType.allCreatureTypes = false; } if (ct.isRemoveArtifactTypes()) { - Iterables.removeIf(newType.subtypes, Predicates.IS_ARTIFACT_TYPE); + newType.subtypes.removeIf(Predicates.IS_ARTIFACT_TYPE); } if (ct.isRemoveEnchantmentTypes()) { - Iterables.removeIf(newType.subtypes, Predicates.IS_ENCHANTMENT_TYPE); + newType.subtypes.removeIf(Predicates.IS_ENCHANTMENT_TYPE); } } if (ct.getRemoveType() != null) { @@ -655,31 +655,31 @@ public void sanisfySubtypes() { return; } if (!isCreature() && !isKindred()) { - Iterables.removeIf(subtypes, Predicates.IS_CREATURE_TYPE); + subtypes.removeIf(Predicates.IS_CREATURE_TYPE); } if (!isLand()) { - Iterables.removeIf(subtypes, Predicates.IS_LAND_TYPE); + subtypes.removeIf(Predicates.IS_LAND_TYPE); } if (!isArtifact()) { - Iterables.removeIf(subtypes, Predicates.IS_ARTIFACT_TYPE); + subtypes.removeIf(Predicates.IS_ARTIFACT_TYPE); } if (!isEnchantment()) { - Iterables.removeIf(subtypes, Predicates.IS_ENCHANTMENT_TYPE); + subtypes.removeIf(Predicates.IS_ENCHANTMENT_TYPE); } if (!isInstant() && !isSorcery()) { - Iterables.removeIf(subtypes, Predicates.IS_SPELL_TYPE); + subtypes.removeIf(Predicates.IS_SPELL_TYPE); } if (!isPlaneswalker()) { - Iterables.removeIf(subtypes, Predicates.IS_WALKER_TYPE); + subtypes.removeIf(Predicates.IS_WALKER_TYPE); } if (!isDungeon()) { - Iterables.removeIf(subtypes, Predicates.IS_DUNGEON_TYPE); + subtypes.removeIf(Predicates.IS_DUNGEON_TYPE); } if (!isBattle()) { - Iterables.removeIf(subtypes, Predicates.IS_BATTLE_TYPE); + subtypes.removeIf(Predicates.IS_BATTLE_TYPE); } if (!isPlane()) { - Iterables.removeIf(subtypes, Predicates.IS_PLANAR_TYPE); + subtypes.removeIf(Predicates.IS_PLANAR_TYPE); } } diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index 94d00934680..ebc82e0a055 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -79,10 +79,6 @@ public static T find(Collection iterable, Predicate predicate, return iterable.stream().filter(predicate).findFirst().orElse(defaultValue); } - public static boolean removeIf(Collection iterable, Predicate test) { - return iterable.removeIf(test); - } - public static int size(Collection collection) { return collection.size(); } diff --git a/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java index 3afd2a78682..e76511dcc29 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java @@ -356,7 +356,7 @@ public void resolve(final SpellAbility sa) { PlayerCollection players = AbilityUtils.getDefinedPlayers(host, defined, sa); if (players.isEmpty()) return; List newKeywords = Lists.newArrayList(); - Iterables.removeIf(keywords, input -> { + keywords.removeIf(input -> { if (!input.contains("ChosenPlayerUID") && !input.contains("ChosenPlayerName")) { return false; } @@ -471,7 +471,7 @@ public void resolve(final SpellAbility sa) { List affectedKeywords = Lists.newArrayList(keywords); if (!affectedKeywords.isEmpty()) { - Iterables.removeIf(affectedKeywords, input -> { + affectedKeywords.removeIf(input -> { if (input.contains("CardManaCost")) { if (tgtC.getManaCost().isNoCost()) { return true; diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java index 78b0ce238e6..4a966e6f17c 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java @@ -172,7 +172,7 @@ public static CardCollectionView applyContinuousAbility(final StaticAbility stAb // update keywords with Chosen parts final String hostCardUID = Integer.toString(hostCard.getId()); // Protection with "doesn't remove" effect - Iterables.removeIf(addKeywords, input -> { + addKeywords.removeIf(input -> { if (!hostCard.hasChosenColor() && input.contains("ChosenColor")) { return true; } @@ -374,7 +374,7 @@ public static CardCollectionView applyContinuousAbility(final StaticAbility stAb addTypes = Lists.newArrayList(Arrays.asList(params.get("AddType").split(" & "))); List newTypes = Lists.newArrayList(); - Iterables.removeIf(addTypes, input -> { + addTypes.removeIf(input -> { if (input.equals("ChosenType") && !hostCard.hasChosenType()) { return true; } @@ -413,7 +413,7 @@ public static CardCollectionView applyContinuousAbility(final StaticAbility stAb if (params.containsKey("RemoveType")) { removeTypes = Lists.newArrayList(Arrays.asList(params.get("RemoveType").split(" & "))); - Iterables.removeIf(removeTypes, input -> { + removeTypes.removeIf(input -> { if (input.equals("ChosenType") && !hostCard.hasChosenType()) { return true; } @@ -725,7 +725,7 @@ public static CardCollectionView applyContinuousAbility(final StaticAbility stAb newKeywords = Lists.newArrayList(addKeywords); final List extraKeywords = Lists.newArrayList(); - Iterables.removeIf(newKeywords, input -> { + newKeywords.removeIf(input -> { if (input.contains("CardManaCost") && affectedCard.getManaCost().isNoCost()) { return true; } From dfac93a6682c19b8a0d5d66e168046a43061bb23 Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 6 Sep 2024 20:33:37 -0400 Subject: [PATCH 32/68] Guava migration - Inline `Iterables.find` (Collection overload) --- forge-ai/src/main/java/forge/ai/ComputerUtilCard.java | 2 +- forge-core/src/main/java/forge/util/Iterables.java | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index 7170d04894d..ddac99ba93d 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -245,7 +245,7 @@ public static Card getBestLandAI(final Iterable list) { } if (iminBL == Integer.MAX_VALUE) { // All basic lands have no basic land type. Just return something - return Iterables.find(land, CardPredicates.UNTAPPED, land.get(0)); + return land.stream().filter(CardPredicates.UNTAPPED).findFirst().orElse(land.get(0)); } final List bLand = CardLists.getType(land, sminBL); diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index ebc82e0a055..8cc3e7a4628 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -72,12 +72,6 @@ public static boolean any(Collection iterable, Predicate test) public static boolean all(Collection iterable, Predicate test) { return iterable.stream().allMatch(test); } - public static T find(Collection iterable, Predicate predicate) { - return iterable.stream().filter(predicate).findFirst().get(); - } - public static T find(Collection iterable, Predicate predicate, T defaultValue) { - return iterable.stream().filter(predicate).findFirst().orElse(defaultValue); - } public static int size(Collection collection) { return collection.size(); From 47164153f4871092684869ec334f6205d0ceff3e Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 8 Sep 2024 14:14:44 -0400 Subject: [PATCH 33/68] Guava migration - Add helper methods for FCollectionView `anyMatch` and `allMatch` --- .../src/main/java/forge/util/Iterables.java | 9 +++++++++ .../main/java/forge/util/collect/FCollection.java | 15 +++++++++++++++ .../java/forge/util/collect/FCollectionView.java | 11 +++++++++++ 3 files changed, 35 insertions(+) diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index 8cc3e7a4628..f6ef4dd7893 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -1,5 +1,7 @@ package forge.util; +import forge.util.collect.FCollectionView; + import java.util.Collection; import java.util.List; import java.util.Optional; @@ -72,6 +74,13 @@ public static boolean any(Collection iterable, Predicate test) public static boolean all(Collection iterable, Predicate test) { return iterable.stream().allMatch(test); } + public static boolean any(FCollectionView iterable, Predicate test) { + return iterable.anyMatch(test); + } + public static boolean all(FCollectionView iterable, Predicate test) { + return iterable.allMatch(test); + } + public static int size(Collection collection) { return collection.size(); 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 68ce4d0b8c3..844e10a0e67 100644 --- a/forge-core/src/main/java/forge/util/collect/FCollection.java +++ b/forge-core/src/main/java/forge/util/collect/FCollection.java @@ -549,6 +549,17 @@ public T get(final T obj) { } return obj; } + + @Override + public boolean anyMatch(Predicate test) { + return set.stream().anyMatch(test); + } + + @Override + public boolean allMatch(Predicate test) { + return set.stream().allMatch(test); + } + /** * An unmodifiable, empty {@link FCollection}. Overrides all methods with * default implementations suitable for an empty collection, to improve @@ -654,6 +665,10 @@ public final T[] toArray(final T[] a) { } return a; } + + @Override public boolean anyMatch(Predicate test) {return false;} + @Override public boolean allMatch(Predicate test) {return true;} + @Override public final String toString() { return "[]"; } diff --git a/forge-core/src/main/java/forge/util/collect/FCollectionView.java b/forge-core/src/main/java/forge/util/collect/FCollectionView.java index 56da5c6d0a4..c5c89e48e1c 100644 --- a/forge-core/src/main/java/forge/util/collect/FCollectionView.java +++ b/forge-core/src/main/java/forge/util/collect/FCollectionView.java @@ -4,6 +4,7 @@ import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; +import java.util.function.Predicate; /** * Read-only interface to an {@link FCollection}. @@ -76,4 +77,14 @@ public interface FCollectionView extends Iterable { Iterable threadSafeIterable(); T get(final T obj); + + /** + * Returns true if any member of this collection matches the given predicate. + */ + boolean anyMatch(Predicate test); + + /** + * Returns true if each member of this collection matches the given predicate. + */ + boolean allMatch(Predicate test); } \ No newline at end of file From b4015af2038281de1bc86ca561bcba855c80f8df Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 8 Sep 2024 14:56:05 -0400 Subject: [PATCH 34/68] Guava migration - Inline `Iterables.any` and `Iterables.all` (FCollectionView overloads) --- .../java/forge/ai/AiAttackController.java | 4 +-- .../src/main/java/forge/ai/AiController.java | 16 ++++----- .../src/main/java/forge/ai/ComputerUtil.java | 4 +-- .../main/java/forge/ai/ComputerUtilCard.java | 2 +- .../java/forge/ai/ComputerUtilCombat.java | 6 ++-- .../java/forge/ai/PlayerControllerAi.java | 2 +- .../src/main/java/forge/ai/SpecialCardAi.java | 16 ++++----- .../main/java/forge/ai/ability/AmassAi.java | 2 +- .../main/java/forge/ai/ability/AnimateAi.java | 3 +- .../java/forge/ai/ability/ChangeZoneAi.java | 4 +-- .../forge/ai/ability/ChangeZoneAllAi.java | 3 +- .../java/forge/ai/ability/CountersAi.java | 3 +- .../main/java/forge/ai/ability/LifeSetAi.java | 3 +- .../main/java/forge/ai/ability/MeldAi.java | 7 ++-- .../java/forge/ai/ability/PermanentAi.java | 3 +- .../main/java/forge/ai/ability/PumpAi.java | 3 +- .../java/forge/ai/ability/PumpAiBase.java | 21 ++++++------ .../main/java/forge/ai/ability/PumpAllAi.java | 3 +- .../main/java/forge/ai/ability/TapAiBase.java | 3 +- .../main/java/forge/ai/ability/TapAllAi.java | 3 +- .../java/forge/ai/ability/TimeTravelAi.java | 4 +-- .../main/java/forge/ai/ability/TokenAi.java | 4 ++- .../java/forge/ai/ability/UntapAllAi.java | 3 +- .../src/main/java/forge/util/Iterables.java | 8 ----- .../src/main/java/forge/game/ForgeScript.java | 3 +- forge-game/src/main/java/forge/game/Game.java | 4 +-- .../src/main/java/forge/game/GameAction.java | 8 ++--- .../src/main/java/forge/game/GameEntity.java | 5 ++- .../game/ability/effects/AmassEffect.java | 3 +- .../ability/effects/ChangeZoneEffect.java | 2 +- .../ability/effects/ManifestBaseEffect.java | 3 +- .../src/main/java/forge/game/card/Card.java | 8 ++--- .../java/forge/game/card/CardProperty.java | 33 ++++++++++--------- .../forge/game/combat/AttackConstraints.java | 4 +-- .../java/forge/game/combat/CombatUtil.java | 6 ++-- .../java/forge/game/cost/CostSacrifice.java | 3 +- .../java/forge/game/phase/PhaseHandler.java | 3 +- .../main/java/forge/game/player/Player.java | 10 +++--- .../StaticAbilityCantAttackBlock.java | 5 ++- .../StaticAbilityContinuous.java | 2 +- .../src/main/java/forge/game/zone/Zone.java | 3 +- 41 files changed, 103 insertions(+), 132 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiAttackController.java b/forge-ai/src/main/java/forge/ai/AiAttackController.java index dd37ab118f2..577bce8107c 100644 --- a/forge-ai/src/main/java/forge/ai/AiAttackController.java +++ b/forge-ai/src/main/java/forge/ai/AiAttackController.java @@ -611,7 +611,7 @@ private boolean doAssault() { // TODO: the AI should ideally predict how many times it can activate // for now, unless the opponent is tapped out, break at this point // and do not predict the blocker limit (which is safer) - if (Iterables.any(defendingOpponent.getLandsInPlay(), CardPredicates.UNTAPPED)) { + if (defendingOpponent.getLandsInPlay().anyMatch(CardPredicates.UNTAPPED)) { maxBlockersAfterCrew += CardLists.count(CardLists.getNotType(defendingOpponent.getCardsIn(ZoneType.Battlefield), "Creature"), CardPredicates.isType("Vehicle").and(CardPredicates.UNTAPPED)); } @@ -1390,7 +1390,7 @@ public final boolean shouldAttack(final Card attacker, final List defender boolean canTrampleOverDefenders = attacker.hasKeyword(Keyword.TRAMPLE) && attacker.getNetCombatDamage() > Aggregates.sum(validBlockers, Card::getNetToughness); // used to check that CanKillAllDangerous check makes sense in context where creatures with dangerous abilities are present - boolean dangerousBlockersPresent = Iterables.any(validBlockers, + boolean dangerousBlockersPresent = validBlockers.anyMatch( CardPredicates.hasKeyword(Keyword.WITHER) .or(CardPredicates.hasKeyword(Keyword.INFECT)) .or(CardPredicates.hasKeyword(Keyword.LIFELINK)) diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index 5496faa2e9a..c9e3b3c0b28 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -194,7 +194,7 @@ private boolean checkCurseEffects(final SpellAbility sa) { return true; } } - if (Iterables.any(game.getCardsIn(ZoneType.Graveyard), CardPredicates.nameEquals(hostName))) { + if (game.getCardsIn(ZoneType.Graveyard).anyMatch(CardPredicates.nameEquals(hostName))) { return true; } } @@ -436,7 +436,7 @@ private CardCollection filterLandsToPlay(CardCollection landList) { String name = c.getName(); CardCollectionView battlefield = player.getCardsIn(ZoneType.Battlefield); if (c.getType().isLegendary() && !name.equals("Flagstones of Trokair")) { - if (Iterables.any(battlefield, CardPredicates.nameEquals(name))) { + if (battlefield.anyMatch(CardPredicates.nameEquals(name))) { return false; } } @@ -554,7 +554,7 @@ private Card chooseBestLandToPlay(CardCollection landList) { CardCollection oneDrops = CardLists.filter(nonLandsInHand, CardPredicates.hasCMC(1)); for (int i = 0; i < MagicColor.WUBRG.length; i++) { byte color = MagicColor.WUBRG[i]; - if (Iterables.any(oneDrops, CardPredicates.isColor(color))) { + if (oneDrops.anyMatch(CardPredicates.isColor(color))) { for (Card land : landList) { if (land.getType().hasSubtype(MagicColor.Constant.BASIC_LANDS.get(i))) { return land; @@ -597,7 +597,7 @@ private Card chooseBestLandToPlay(CardCollection landList) { } // pick dual lands if available - if (Iterables.any(landList, CardPredicates.NONBASIC_LANDS)) { + if (landList.anyMatch(CardPredicates.NONBASIC_LANDS)) { landList = CardLists.filter(landList, CardPredicates.NONBASIC_LANDS); } } @@ -1400,7 +1400,7 @@ private boolean isSafeToHoldLandDropForMain2(Card landToPlay) { CardCollectionView otb = player.getCardsIn(ZoneType.Battlefield); if (getBooleanProperty(AiProps.HOLD_LAND_DROP_ONLY_IF_HAVE_OTHER_PERMS)) { - if (!Iterables.any(otb, CardPredicates.NON_LANDS)) { + if (!otb.anyMatch(CardPredicates.NON_LANDS)) { return false; } } @@ -1422,7 +1422,7 @@ private boolean isSafeToHoldLandDropForMain2(Card landToPlay) { boolean canCastWithLandDrop = (predictedMana + 1 >= minCMCInHand) && minCMCInHand > 0 && !isTapLand; boolean cantCastAnythingNow = predictedMana < minCMCInHand; - boolean hasRelevantAbsOTB = Iterables.any(otb, card -> { + boolean hasRelevantAbsOTB = otb.anyMatch(card -> { boolean isTapLand1 = false; for (ReplacementEffect repl : card.getReplacementEffects()) { // TODO: improve the detection of taplands @@ -1443,7 +1443,7 @@ private boolean isSafeToHoldLandDropForMain2(Card landToPlay) { return false; }); - boolean hasLandBasedEffect = Iterables.any(otb, card -> { + boolean hasLandBasedEffect = otb.anyMatch(card -> { for (Trigger t : card.getTriggers()) { Map params = t.getMapParams(); if ("ChangesZone".equals(params.get("Mode")) @@ -2172,7 +2172,7 @@ public List orderPlaySa(List activePlayerSAs) { // do mandatory discard early if hand is empty or has DiscardMe card boolean discardEarly = false; CardCollectionView playerHand = player.getCardsIn(ZoneType.Hand); - if (playerHand.isEmpty() || Iterables.any(playerHand, CardPredicates.hasSVar("DiscardMe"))) { + if (playerHand.isEmpty() || playerHand.anyMatch(CardPredicates.hasSVar("DiscardMe"))) { discardEarly = true; result.addAll(mandatoryDiscard); } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index de6b2a7aa2c..5c7a192e3f5 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -2583,13 +2583,13 @@ else if (logic.equals("MostProminentInComputerGraveyard")) { CardCollectionView possibleCards = ai.getAllCards(); for (String b : basics) { - if (!Iterables.any(presentCards, CardPredicates.isType(b)) && Iterables.any(possibleCards, CardPredicates.isType(b))) { + if (!presentCards.anyMatch(CardPredicates.isType(b)) && possibleCards.anyMatch(CardPredicates.isType(b))) { chosen = b; } } if (chosen.isEmpty()) { for (String b : basics) { - if (Iterables.any(possibleCards, CardPredicates.isType(b))) { + if (possibleCards.anyMatch(CardPredicates.isType(b))) { chosen = b; } } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index ddac99ba93d..83b8dbbe41b 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -1056,7 +1056,7 @@ public static List chooseColor(SpellAbility sa, int min, int max, List curDevotion && Iterables.any(hand, CardPredicates.isColor(c))) { + if (devotion > curDevotion && hand.anyMatch(CardPredicates.isColor(c))) { curDevotion = devotion; chosenColor = MagicColor.toLongString(c); } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java index 64b9d762e51..a25568f1e73 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java @@ -216,7 +216,7 @@ public static int poisonIfUnblocked(final Card attacker, final Player attacked) if (attacker.hasKeyword(Keyword.INFECT)) { int pd = predictDamageTo(attacked, damage, attacker, true); // opponent can always order it so that he gets 0 - if (pd == 1 && Iterables.any(attacker.getController().getOpponents().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Vorinclex, Monstrous Raider"))) { + if (pd == 1 && attacker.getController().getOpponents().getCardsIn(ZoneType.Battlefield).anyMatch(CardPredicates.nameEquals("Vorinclex, Monstrous Raider"))) { pd = 0; } poison += pd; @@ -404,11 +404,11 @@ public static boolean lifeInDanger(final Player ai, final Combat combat, final i CardCollectionView otb = ai.getCardsIn(ZoneType.Battlefield); // Special cases: // AI can't lose in combat in presence of Worship (with creatures) - if (Iterables.any(otb, CardPredicates.nameEquals("Worship")) && !ai.getCreaturesInPlay().isEmpty()) { + if (otb.anyMatch(CardPredicates.nameEquals("Worship")) && !ai.getCreaturesInPlay().isEmpty()) { return false; } // AI can't lose in combat in presence of Elderscale Wurm (at 7 life or more) - if (Iterables.any(otb, CardPredicates.nameEquals("Elderscale Wurm")) && ai.getLife() >= 7) { + if (otb.anyMatch(CardPredicates.nameEquals("Elderscale Wurm")) && ai.getLife() >= 7) { return false; } diff --git a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java index 99505d9ca51..1aef3981082 100644 --- a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java +++ b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java @@ -569,7 +569,7 @@ public CardCollectionView orderMoveToZoneList(CardCollectionView cards, ZoneType if (destinationZone == ZoneType.Graveyard) { // In presence of Volrath's Shapeshifter in deck, try to place the best creature on top of the graveyard - if (Iterables.any(getGame().getCardsInGame(), card -> { + if (getGame().getCardsInGame().anyMatch(card -> { // need a custom predicate here since Volrath's Shapeshifter may have a different name OTB return card.getOriginalState(CardStateName.Original).getName().equals("Volrath's Shapeshifter"); })) { diff --git a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java index ca79e7df54b..fb8e4c8c5c5 100644 --- a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java +++ b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java @@ -159,11 +159,11 @@ public static boolean consider(final Player ai, final SpellAbility sa) { CardPredicates.INSTANTS_AND_SORCERIES); if (!hand.isEmpty()) { // has spell that can be cast in hand with put ability - if (Iterables.any(hand, CardPredicates.hasCMC(counterNum + 1))) { + if (hand.anyMatch(CardPredicates.hasCMC(counterNum + 1))) { return false; } // has spell that can be cast if one counter is removed - if (Iterables.any(hand, CardPredicates.hasCMC(counterNum))) { + if (hand.anyMatch(CardPredicates.hasCMC(counterNum))) { sa.setXManaCostPaid(1); return true; } @@ -659,7 +659,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { // Need to have something else in hand that is blue in addition to Force of Will itself, // otherwise the AI will fail to play the card and the card will disappear from the pool return false; - } else if (!Iterables.any(blueCards, CardPredicates.lessCMC(3))) { + } else if (!blueCards.anyMatch(CardPredicates.lessCMC(3))) { // We probably need a low-CMC card to exile to it, exiling a higher CMC spell may be suboptimal // since the AI does not prioritize/value cards vs. permission at the moment. return false; @@ -864,7 +864,7 @@ public static CardCollection considerMultiple(final Player ai, final SpellAbilit for (Card c1 : lib) { if (c1.getName().equals(c.getName())) { - if (!Iterables.any(ai.getCardsIn(ZoneType.Hand), CardPredicates.nameEquals(c1.getName())) + if (!ai.getCardsIn(ZoneType.Hand).anyMatch(CardPredicates.nameEquals(c1.getName())) && ComputerUtilMana.hasEnoughManaSourcesToCast(c1.getFirstSpellAbility(), ai)) { // Try not to search for things we already have in hand or that we can't cast libPriorityList.add(c1); @@ -980,7 +980,7 @@ public static Card considerCardToGet(final Player ai, final SpellAbility sa) for (Card gate : availableGates) { - if (!Iterables.any(currentGates, CardPredicates.nameEquals(gate.getName()))) + if (!currentGates.anyMatch(CardPredicates.nameEquals(gate.getName()))) { // Diversify our mana base return gate; @@ -1130,7 +1130,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { return false; // nothing to draw from the library } - if (Iterables.any(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Yawgmoth's Bargain"))) { + if (ai.getCardsIn(ZoneType.Battlefield).anyMatch(CardPredicates.nameEquals("Yawgmoth's Bargain"))) { // Prefer Yawgmoth's Bargain because AI is generally better with it // TODO: in presence of bad effects which deal damage when a card is drawn, probably better to prefer Necropotence instead? @@ -1148,7 +1148,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { } // TODO: Any other bad effects like that? - boolean blackViseOTB = Iterables.any(game.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Black Vise")); + boolean blackViseOTB = game.getCardsIn(ZoneType.Battlefield).anyMatch(CardPredicates.nameEquals("Black Vise")); if (ph.getNextTurn().equals(ai) && ph.is(PhaseType.MAIN2) && ai.getSpellsCastLastTurn() == 0 @@ -1803,7 +1803,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { int maxHandSize = ai.getMaxHandSize(); // TODO: Any other bad effects like that? - boolean blackViseOTB = Iterables.any(game.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Black Vise")); + boolean blackViseOTB = game.getCardsIn(ZoneType.Battlefield).anyMatch(CardPredicates.nameEquals("Black Vise")); // TODO: Consider effects like "whenever a player draws a card, he loses N life" (e.g. Nekusar, the Mindraiser), // and effects that draw an additional card whenever a card is drawn. diff --git a/forge-ai/src/main/java/forge/ai/ability/AmassAi.java b/forge-ai/src/main/java/forge/ai/ability/AmassAi.java index f3ae9b2447d..31adb3781b8 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AmassAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AmassAi.java @@ -30,7 +30,7 @@ protected boolean checkApiLogic(Player ai, final SpellAbility sa) { final Game game = ai.getGame(); if (!aiArmies.isEmpty()) { - return Iterables.any(aiArmies, CardPredicates.canReceiveCounters(CounterEnumType.P1P1)); + return aiArmies.anyMatch(CardPredicates.canReceiveCounters(CounterEnumType.P1P1)); } final String type = sa.getParam("Type"); StringBuilder sb = new StringBuilder("b_0_0_"); diff --git a/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java b/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java index e9503149190..b6aa11208cc 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AnimateAi.java @@ -23,7 +23,6 @@ import forge.game.staticability.StaticAbilityLayer; import forge.game.zone.ZoneType; import forge.util.FileSection; -import forge.util.Iterables; import java.util.Arrays; import java.util.List; @@ -70,7 +69,7 @@ protected boolean checkAiLogic(final Player ai, final SpellAbility sa, final Str } // check for duplicate static ability - if (Iterables.any(host.getStaticAbilities(), CardTraitPredicates.hasParam("Description", map.get("Description")))) { + if (host.getStaticAbilities().anyMatch(CardTraitPredicates.hasParam("Description", map.get("Description")))) { return false; } // TODO check if Bone Man would deal damage to something that otherwise would regenerate diff --git a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java index 3384e0dc4f5..008eee1ce37 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java @@ -1634,7 +1634,7 @@ public static Card chooseCardToHiddenOriginChangeZone(ZoneType destination, List // Does AI need a land? CardCollectionView hand = decider.getCardsIn(ZoneType.Hand); - if (!Iterables.any(hand, CardPredicates.LANDS) && CardLists.count(decider.getCardsIn(ZoneType.Battlefield), CardPredicates.LANDS) < 4) { + if (!hand.anyMatch(CardPredicates.LANDS) && CardLists.count(decider.getCardsIn(ZoneType.Battlefield), CardPredicates.LANDS) < 4) { boolean canCastSomething = false; for (Card cardInHand : hand) { canCastSomething = canCastSomething || ComputerUtilMana.hasEnoughManaSourcesToCast(cardInHand.getFirstSpellAbility(), decider); @@ -1644,7 +1644,7 @@ public static Card chooseCardToHiddenOriginChangeZone(ZoneType destination, List } } if (c == null) { - if (Iterables.all(fetchList, CardPredicates.LANDS)) { + if (fetchList.allMatch(CardPredicates.LANDS)) { // we're only choosing from lands, so get the best land c = ComputerUtilCard.getBestLandAI(fetchList); } else { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java index a01557c3cd6..571af0de00c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java @@ -29,7 +29,6 @@ import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.MyRandom; public class ChangeZoneAllAi extends SpellAbilityAi { @@ -353,7 +352,7 @@ protected boolean doTriggerAINoCost(Player ai, final SpellAbility sa, boolean ma // TODO: this is a stub to prevent the AI from crashing the game when, for instance, playing the opponent's // Profaner from exile without paying its mana cost. Otherwise the card is marked AI:RemoveDeck:All and // there is no specific AI to support playing it in a smarter way. Feel free to expand. - return Iterables.any(ai.getOpponents().getCardsIn(origin), CardPredicates.CREATURES); + return ai.getOpponents().getCardsIn(origin).anyMatch(CardPredicates.CREATURES); } CardCollectionView humanType = ai.getOpponents().getCardsIn(origin); diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersAi.java index e64920d17d4..5253e9e97c8 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersAi.java @@ -32,7 +32,6 @@ import forge.game.player.Player; import forge.game.zone.ZoneType; import forge.util.Aggregates; -import forge.util.Iterables; /** @@ -64,7 +63,7 @@ public static Card chooseCursedTarget(final CardCollectionView list, final Strin Card choice; // opponent can always order it so that he gets 0 - if (amount == 1 && Iterables.any(ai.getOpponents().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Vorinclex, Monstrous Raider"))) { + if (amount == 1 && ai.getOpponents().getCardsIn(ZoneType.Battlefield).anyMatch(CardPredicates.nameEquals("Vorinclex, Monstrous Raider"))) { return null; } diff --git a/forge-ai/src/main/java/forge/ai/ability/LifeSetAi.java b/forge-ai/src/main/java/forge/ai/ability/LifeSetAi.java index 544743a2f28..ee700b99dd9 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LifeSetAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LifeSetAi.java @@ -14,7 +14,6 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.MyRandom; public class LifeSetAi extends SpellAbilityAi { @@ -132,7 +131,7 @@ protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandator } if (sourceName.equals("Eternity Vessel") - && (Iterables.any(ai.getOpponents().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Vampire Hexmage")) || (source.getCounters(CounterEnumType.CHARGE) == 0))) { + && (ai.getOpponents().getCardsIn(ZoneType.Battlefield).anyMatch(CardPredicates.nameEquals("Vampire Hexmage")) || (source.getCounters(CounterEnumType.CHARGE) == 0))) { return false; } diff --git a/forge-ai/src/main/java/forge/ai/ability/MeldAi.java b/forge-ai/src/main/java/forge/ai/ability/MeldAi.java index 46ddf23c286..bbd1a4ff12d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/MeldAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/MeldAi.java @@ -6,7 +6,6 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; public class MeldAi extends SpellAbilityAi { @Override @@ -19,10 +18,8 @@ protected boolean checkApiLogic(Player aiPlayer, SpellAbility sa) { return false; } - boolean hasPrimaryMeld = Iterables.any(cardsOTB, - CardPredicates.nameEquals(primaryMeld).and(CardPredicates.isOwner(aiPlayer))); - boolean hasSecondaryMeld = Iterables.any(cardsOTB, - CardPredicates.nameEquals(secondaryMeld).and(CardPredicates.isOwner(aiPlayer))); + boolean hasPrimaryMeld = cardsOTB.anyMatch(CardPredicates.nameEquals(primaryMeld).and(CardPredicates.isOwner(aiPlayer))); + boolean hasSecondaryMeld = cardsOTB.anyMatch(CardPredicates.nameEquals(secondaryMeld).and(CardPredicates.isOwner(aiPlayer))); return hasPrimaryMeld && hasSecondaryMeld && sa.getHostCard().getName().equals(primaryMeld); } diff --git a/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java b/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java index e2fb1da8563..7958a895b17 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java @@ -17,7 +17,6 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; public class PermanentAi extends SpellAbilityAi { @@ -213,7 +212,7 @@ protected boolean checkApiLogic(final Player ai, final SpellAbility sa) { if (param.equals("MustHaveInHand")) { // Only cast if another card is present in hand (e.g. Illusions of Grandeur followed by Donate) - boolean hasCard = Iterables.any(ai.getCardsIn(ZoneType.Hand), CardPredicates.nameEquals(value)); + boolean hasCard = ai.getCardsIn(ZoneType.Hand).anyMatch(CardPredicates.nameEquals(value)); if (!hasCard) { dontCast = true; } diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAi.java b/forge-ai/src/main/java/forge/ai/ability/PumpAi.java index e0918276957..a0d1fb2ba07 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAi.java @@ -18,7 +18,6 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; -import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; @@ -795,7 +794,7 @@ private boolean doSameNameLogic(Player aiPlayer, SpellAbility sa) { List toRemove = Lists.newArrayList(); for (final String name : values.keySet()) { - if (!Iterables.any(oppList, CardPredicates.nameEquals(name))) { + if (!oppList.anyMatch(CardPredicates.nameEquals(name))) { toRemove.add(name); } } diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java b/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java index ac68e667644..12458bd0f33 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java @@ -26,7 +26,6 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; public abstract class PumpAiBase extends SpellAbilityAi { @@ -188,7 +187,7 @@ public boolean isUsefulPumpKeyword(final Player ai, final String keyword, final return !ph.isPlayerTurn(opp) && ((combat != null && combat.isAttacking(card)) || CombatUtil.canAttack(card, opp)) && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) && newPower > 0 - && Iterables.any(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)); + && opp.getCreaturesInPlay().anyMatch(CardPredicates.possibleBlockers(card)); } else if (keyword.endsWith("Flying")) { CardCollectionView attackingFlyer = CardCollection.EMPTY; if (combat != null) { @@ -220,8 +219,8 @@ public boolean isUsefulPumpKeyword(final Player ai, final String keyword, final return !ph.isPlayerTurn(opp) && ((combat != null && combat.isAttacking(card)) || CombatUtil.canAttack(card, opp)) && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) && newPower > 0 - && Iterables.any(CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), - flyingOrReach.negate()); + && CardLists.filter(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)) + .anyMatch(flyingOrReach.negate()); } else if (keyword.endsWith("Horsemanship")) { if (ph.isPlayerTurn(opp) && ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS) @@ -282,7 +281,7 @@ public boolean isUsefulPumpKeyword(final Player ai, final String keyword, final return !ph.isPlayerTurn(opp) && ((combat != null && combat.isAttacking(card)) || CombatUtil.canAttack(card, opp)) && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS) && !opp.getCreaturesInPlay().isEmpty() - && Iterables.any(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)); + && opp.getCreaturesInPlay().anyMatch(CardPredicates.possibleBlockers(card)); } else if (keyword.equals("First Strike")) { if (card.hasDoubleStrike()) { return false; @@ -325,7 +324,7 @@ public boolean isUsefulPumpKeyword(final Player ai, final String keyword, final && CombatUtil.canBeBlocked(card, null, opp) && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) && newPower > 1 - && Iterables.any(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)); + && opp.getCreaturesInPlay().anyMatch(CardPredicates.possibleBlockers(card)); } else if (keyword.equals("Infect")) { if (newPower <= 0) { return false; @@ -365,31 +364,31 @@ public boolean isUsefulPumpKeyword(final Player ai, final String keyword, final && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) && newPower > 0 && !CardLists.getType(opp.getLandsInPlay(), "Plains").isEmpty() - && Iterables.any(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)); + && opp.getCreaturesInPlay().anyMatch(CardPredicates.possibleBlockers(card)); } else if (keyword.equals("Landwalk:Island")) { return !ph.isPlayerTurn(opp) && ((combat != null && combat.isAttacking(card)) || CombatUtil.canAttack(card, opp)) && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) && newPower > 0 && !CardLists.getType(opp.getLandsInPlay(), "Island").isEmpty() - && Iterables.any(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)); + && opp.getCreaturesInPlay().anyMatch(CardPredicates.possibleBlockers(card)); } else if (keyword.equals("Landwalk:Swamp")) { return !ph.isPlayerTurn(opp) && ((combat != null && combat.isAttacking(card)) || CombatUtil.canAttack(card, opp)) && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) && newPower > 0 && !CardLists.getType(opp.getLandsInPlay(), "Swamp").isEmpty() - && Iterables.any(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)); + && opp.getCreaturesInPlay().anyMatch(CardPredicates.possibleBlockers(card)); } else if (keyword.equals("Landwalk:Mountain")) { return !ph.isPlayerTurn(opp) && ((combat != null && combat.isAttacking(card)) || CombatUtil.canAttack(card, opp)) && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) && newPower > 0 && !CardLists.getType(opp.getLandsInPlay(), "Mountain").isEmpty() - && Iterables.any(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)); + && opp.getCreaturesInPlay().anyMatch(CardPredicates.possibleBlockers(card)); } else if (keyword.equals("Landwalk:Forest")) { return !ph.isPlayerTurn(opp) && ((combat != null && combat.isAttacking(card)) || CombatUtil.canAttack(card, opp)) && !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS) && newPower > 0 && !CardLists.getType(opp.getLandsInPlay(), "Forest").isEmpty() - && Iterables.any(opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)); + && opp.getCreaturesInPlay().anyMatch(CardPredicates.possibleBlockers(card)); } else if (keyword.equals("Prevent all combat damage that would be dealt to CARDNAME.")) { return combat != null && (combat.isBlocking(card) || combat.isBlocked(card)); } else if (keyword.equals("Menace")) { diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java b/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java index 51bbbd0cf0b..9ff6b3b8427 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java @@ -22,7 +22,6 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; public class PumpAllAi extends PumpAiBase { @@ -134,7 +133,7 @@ else if (power < 0) { // -X/-0 return pumpAgainstRemoval(ai, sa, comp); } - return Iterables.any(ai.getCreaturesInPlay(), c -> c.isValid(valid, source.getController(), source, sa) + return ai.getCreaturesInPlay().anyMatch(c -> c.isValid(valid, source.getController(), source, sa) && ComputerUtilCard.shouldPumpCard(ai, sa, c, defense, power, keywords)); } // pumpAllCanPlayAI() diff --git a/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java b/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java index 9f47bd2c3f6..dc456aa6607 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java +++ b/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java @@ -21,7 +21,6 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; public abstract class TapAiBase extends SpellAbilityAi { @@ -195,7 +194,7 @@ protected boolean tapPrefTargeting(final Player ai, final Card source, final Spe } else if (phase.isPlayerTurn(opp) && phase.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)) { // Tap creatures possible blockers before combat during AI's turn. - if (Iterables.any(tapList, CardPredicates.CREATURES)) { + if (tapList.anyMatch(CardPredicates.CREATURES)) { List creatureList = CardLists.filter(tapList, c -> c.isCreature() && CombatUtil.canAttack(c, opp)); choice = ComputerUtilCard.getBestCreatureAI(creatureList); } else { // no creatures available diff --git a/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java b/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java index c7ea1207ff9..ea5788d2bbf 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java @@ -17,7 +17,6 @@ import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.MyRandom; public class TapAllAi extends SpellAbilityAi { @@ -73,7 +72,7 @@ protected boolean canPlayAI(final Player ai, SpellAbility sa) { // in AI's turn, check if there are possible attackers, before tapping blockers if (game.getPhaseHandler().isPlayerTurn(ai)) { validTappables = ai.getCardsIn(ZoneType.Battlefield); - final boolean any = Iterables.any(validTappables, c -> CombatUtil.canAttack(c) && ComputerUtilCombat.canAttackNextTurn(c)); + final boolean any = validTappables.anyMatch(c -> CombatUtil.canAttack(c) && ComputerUtilCombat.canAttackNextTurn(c)); return any; } return true; diff --git a/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java b/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java index cb45493a0e6..8aa29b830d7 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java @@ -15,8 +15,8 @@ public class TimeTravelAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { - boolean hasSuspendedCards = Iterables.any(aiPlayer.getCardsIn(ZoneType.Exile), CardPredicates.hasSuspend()); - boolean hasRelevantCardsOTB = Iterables.any(aiPlayer.getCardsIn(ZoneType.Battlefield), CardPredicates.hasCounter(CounterEnumType.TIME)); + boolean hasSuspendedCards = aiPlayer.getCardsIn(ZoneType.Exile).anyMatch(CardPredicates.hasSuspend()); + boolean hasRelevantCardsOTB = aiPlayer.getCardsIn(ZoneType.Battlefield).anyMatch(CardPredicates.hasCounter(CounterEnumType.TIME)); // TODO: add more logic for cards which may need it return hasSuspendedCards || hasRelevantCardsOTB; diff --git a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java index dc1b5624698..1798b3a7037 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java @@ -2,6 +2,7 @@ import java.util.List; import java.util.Map; +import java.util.function.Predicate; import forge.ai.AiController; import forge.ai.AiProps; @@ -380,7 +381,8 @@ private boolean tgtRoleAura(final Player ai, final SpellAbility sa, final Card t // look for card without role from ai List prefListSBA = CardLists.filter(tgts, c -> - !Iterables.any(c.getAttachedCards(), att -> att.getController() == ai && att.getType().hasSubtype("Role"))); + !c.getAttachedCards().anyMatch(att -> + att.getController() == ai && att.getType().hasSubtype("Role"))); List prefList; if (isCurse) { diff --git a/forge-ai/src/main/java/forge/ai/ability/UntapAllAi.java b/forge-ai/src/main/java/forge/ai/ability/UntapAllAi.java index bb745813f32..a16f0cfc763 100644 --- a/forge-ai/src/main/java/forge/ai/ability/UntapAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/UntapAllAi.java @@ -11,7 +11,6 @@ import forge.game.spellability.AbilitySub; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; public class UntapAllAi extends SpellAbilityAi { @Override @@ -28,7 +27,7 @@ protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { final String valid = sa.getParamOrDefault("ValidCards", ""); list = CardLists.getValidCards(list, valid, source.getController(), source, sa); // don't untap if only opponent benefits - return Iterables.any(list, CardPredicates.isControlledByAnyOf(aiPlayer.getYourTeam())); + return list.anyMatch(CardPredicates.isControlledByAnyOf(aiPlayer.getYourTeam())); } return false; } diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index f6ef4dd7893..c21dd36f095 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -1,7 +1,5 @@ package forge.util; -import forge.util.collect.FCollectionView; - import java.util.Collection; import java.util.List; import java.util.Optional; @@ -74,12 +72,6 @@ public static boolean any(Collection iterable, Predicate test) public static boolean all(Collection iterable, Predicate test) { return iterable.stream().allMatch(test); } - public static boolean any(FCollectionView iterable, Predicate test) { - return iterable.anyMatch(test); - } - public static boolean all(FCollectionView iterable, Predicate test) { - return iterable.allMatch(test); - } public static int size(Collection collection) { diff --git a/forge-game/src/main/java/forge/game/ForgeScript.java b/forge-game/src/main/java/forge/game/ForgeScript.java index efe199c8b62..fd71564f00a 100644 --- a/forge-game/src/main/java/forge/game/ForgeScript.java +++ b/forge-game/src/main/java/forge/game/ForgeScript.java @@ -21,7 +21,6 @@ import forge.game.trigger.Trigger; import forge.game.zone.ZoneType; import forge.util.Expressions; -import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; @@ -158,7 +157,7 @@ public static boolean cardStateHasProperty(CardState cardState, String property, } return false; } else if (property.equals("hasManaAbility")) { - if (Iterables.any(cardState.getSpellAbilities(), SpellAbilityPredicates.isManaAbility())) { + if (cardState.getSpellAbilities().anyMatch(SpellAbilityPredicates.isManaAbility())) { return true; } for (final Trigger trig : cardState.getTriggers()) { diff --git a/forge-game/src/main/java/forge/game/Game.java b/forge-game/src/main/java/forge/game/Game.java index 278f697beed..f92b788ef8b 100644 --- a/forge-game/src/main/java/forge/game/Game.java +++ b/forge-game/src/main/java/forge/game/Game.java @@ -634,11 +634,11 @@ public boolean isCardExiled(final Card c) { } public boolean isCardInPlay(final String cardName) { - return Iterables.any(getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals(cardName)); + return getCardsIn(ZoneType.Battlefield).anyMatch(CardPredicates.nameEquals(cardName)); } public boolean isCardInCommand(final String cardName) { - return Iterables.any(getCardsIn(ZoneType.Command), CardPredicates.nameEquals(cardName)); + return getCardsIn(ZoneType.Command).anyMatch(CardPredicates.nameEquals(cardName)); } public CardCollectionView getColoredCardsInPlay(final String color) { diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index 55141bba74a..2f24155d86d 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -137,13 +137,13 @@ private Card changeZone(final Zone zoneFrom, Zone zoneTo, final Card c, Integer } if (!found) { - if (Iterables.any(lastBattlefield, CardPredicates.canBeAttached(c, null))) { + if (lastBattlefield.anyMatch(CardPredicates.canBeAttached(c, null))) { found = true; } } if (!found) { - if (Iterables.any(lastGraveyard, CardPredicates.canBeAttached(c, null))) { + if (lastGraveyard.anyMatch(CardPredicates.canBeAttached(c, null))) { found = true; } } @@ -414,10 +414,10 @@ private Card changeZone(final Zone zoneFrom, Zone zoneTo, final Card c, Integer if (Iterables.any(game.getPlayers(), PlayerPredicates.canBeAttached(copied, null))) { found = true; } - if (Iterables.any(lastBattlefield, CardPredicates.canBeAttached(copied, null))) { + if (lastBattlefield.anyMatch(CardPredicates.canBeAttached(copied, null))) { found = true; } - if (Iterables.any(lastGraveyard, CardPredicates.canBeAttached(copied, null))) { + if (lastGraveyard.anyMatch(CardPredicates.canBeAttached(copied, null))) { found = true; } if (!found) { diff --git a/forge-game/src/main/java/forge/game/GameEntity.java b/forge-game/src/main/java/forge/game/GameEntity.java index efbd2ab7fb0..e0833393183 100644 --- a/forge-game/src/main/java/forge/game/GameEntity.java +++ b/forge-game/src/main/java/forge/game/GameEntity.java @@ -20,7 +20,6 @@ import java.util.List; import java.util.Map; -import forge.util.Iterables; import org.apache.commons.lang3.tuple.Pair; import com.google.common.collect.Lists; @@ -176,7 +175,7 @@ public final boolean hasCardAttachments() { public final boolean isEnchanted() { // enchanted means attached by Aura - return Iterables.any(getAttachedCards(), CardPredicates.AURA); + return getAttachedCards().anyMatch(CardPredicates.AURA); } public final boolean hasCardAttachment(Card c) { @@ -188,7 +187,7 @@ public final boolean isEnchantedBy(Card c) { } public final boolean hasCardAttachment(final String cardName) { - return Iterables.any(getAttachedCards(), CardPredicates.nameEquals(cardName)); + return getAttachedCards().anyMatch(CardPredicates.nameEquals(cardName)); } public final boolean isEnchantedBy(final String cardName) { // Rule 303.4k Even if c is no Aura it still counts diff --git a/forge-game/src/main/java/forge/game/ability/effects/AmassEffect.java b/forge-game/src/main/java/forge/game/ability/effects/AmassEffect.java index 80ea03a2cf8..21b5f7a13a2 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/AmassEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/AmassEffect.java @@ -3,7 +3,6 @@ import java.util.EnumSet; import java.util.Map; -import forge.util.Iterables; import org.apache.commons.lang3.mutable.MutableBoolean; import com.google.common.collect.Lists; @@ -58,7 +57,7 @@ public void resolve(SpellAbility sa) { final String type = sa.getParam("Type"); // create army token if needed - if (!Iterables.any(activator.getCardsIn(ZoneType.Battlefield), CardPredicates.isType("Army"))) { + if (!activator.getCardsIn(ZoneType.Battlefield).anyMatch(CardPredicates.isType("Army"))) { CardZoneTable triggerList = new CardZoneTable(); MutableBoolean combatChanged = new MutableBoolean(false); diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java index 4afeb09a479..82da7842f1b 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java @@ -947,7 +947,7 @@ private void changeZonePlayerInvariant(Player chooser, SpellAbility sa, List, Integer> getLegalAttackers() { for (final Card attacker : myPossibleAttackers) { final Set types = restrictions.get(attacker).getTypes(); if (types.contains(AttackRestrictionType.NEED_BLACK_OR_GREEN)) { - if (!Iterables.any(myPossibleAttackers, AttackRestrictionType.NEED_BLACK_OR_GREEN.getPredicate(attacker))) { + if (!myPossibleAttackers.anyMatch(AttackRestrictionType.NEED_BLACK_OR_GREEN.getPredicate(attacker))) { attackersToRemove.add(attacker); } } else if (types.contains(AttackRestrictionType.NEED_GREATER_POWER)) { - if (!Iterables.any(myPossibleAttackers, AttackRestrictionType.NEED_GREATER_POWER.getPredicate(attacker))) { + if (!myPossibleAttackers.anyMatch(AttackRestrictionType.NEED_GREATER_POWER.getPredicate(attacker))) { attackersToRemove.add(attacker); } } diff --git a/forge-game/src/main/java/forge/game/combat/CombatUtil.java b/forge-game/src/main/java/forge/game/combat/CombatUtil.java index aacc6d84af2..2c8d1fc26e7 100644 --- a/forge-game/src/main/java/forge/game/combat/CombatUtil.java +++ b/forge-game/src/main/java/forge/game/combat/CombatUtil.java @@ -38,7 +38,6 @@ import forge.game.staticability.StaticAbilityMustBlock; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.TextUtil; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; @@ -49,6 +48,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Predicate; /** *

@@ -110,7 +110,7 @@ public static boolean couldAttackButNotAttacking(Combat combat, final Card attac final Map attackers = new HashMap<>(combat.getAttackersAndDefenders()); final Game game = attacker.getGame(); - return Iterables.any(getAllPossibleDefenders(attacker.getController()), defender -> { + return getAllPossibleDefenders(attacker.getController()).anyMatch(defender -> { if (!canAttack(attacker, defender) || getAttackCost(game, attacker, defender) != null) { return false; } @@ -161,7 +161,7 @@ public static CardCollection getPossibleAttackers(final Player p) { * @see #canAttack(Card, GameEntity) */ public static boolean canAttack(final Card attacker) { - return Iterables.any(getAllPossibleDefenders(attacker.getController()), defender -> canAttack(attacker, defender)); + return getAllPossibleDefenders(attacker.getController()).anyMatch(defender -> canAttack(attacker, defender)); } /** diff --git a/forge-game/src/main/java/forge/game/cost/CostSacrifice.java b/forge-game/src/main/java/forge/game/cost/CostSacrifice.java index b0bdb664550..43abf19a5cc 100644 --- a/forge-game/src/main/java/forge/game/cost/CostSacrifice.java +++ b/forge-game/src/main/java/forge/game/cost/CostSacrifice.java @@ -33,7 +33,6 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.Lang; /** @@ -150,7 +149,7 @@ public final boolean canPay(final SpellAbility ability, final Player activator, CardCollectionView typeList = activator.getCardsIn(ZoneType.Battlefield); typeList = CardLists.getValidCards(typeList, getType().split(";"), activator, source, ability); // it needs to check if everything can be sacrificed - return Iterables.all(typeList, CardPredicates.canBeSacrificedBy(ability, effect)); + return typeList.allMatch(CardPredicates.canBeSacrificedBy(ability, effect)); } int amount = getAbilityAmount(ability); diff --git a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java index a84b3ff50a4..a9153d07836 100644 --- a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java +++ b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java @@ -41,7 +41,6 @@ import forge.game.zone.Zone; import forge.game.zone.ZoneType; import forge.util.CollectionSuppliers; -import forge.util.Iterables; import forge.util.TextUtil; import forge.util.maps.HashMapOfLists; import forge.util.maps.MapOfLists; @@ -286,7 +285,7 @@ private void onPhaseBegin() { } } // roll for attractions if we have any - if (Iterables.any(playerTurn.getCardsIn(ZoneType.Battlefield), CardPredicates.ATTRACTIONS)) { + if (playerTurn.getCardsIn(ZoneType.Battlefield).anyMatch(CardPredicates.ATTRACTIONS)) { playerTurn.rollToVisitAttractions(); } table.replaceCounterEffect(game, null, false); diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index 8a04b8e59f3..9dd487f0067 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -2086,9 +2086,7 @@ public final boolean hasMetalcraft() { } public final boolean hasDesert() { - return Iterables.any( - getCardsIn(Arrays.asList(ZoneType.Battlefield, ZoneType.Graveyard)), - CardPredicates.isType("Desert")); + return getCardsIn(Arrays.asList(ZoneType.Battlefield, ZoneType.Graveyard)).anyMatch(CardPredicates.isType("Desert")); } public final boolean hasThreshold() { @@ -3748,9 +3746,9 @@ public void addCycled(SpellAbility sp) { public boolean hasUrzaLands() { final CardCollectionView landsControlled = getCardsIn(ZoneType.Battlefield); - return Iterables.any(landsControlled, CardPredicates.isType("Urza's").and(CardPredicates.isType("Mine"))) - && Iterables.any(landsControlled, CardPredicates.isType("Urza's").and(CardPredicates.isType("Power-Plant"))) - && Iterables.any(landsControlled, CardPredicates.isType("Urza's").and(CardPredicates.isType("Tower"))); + return landsControlled.anyMatch(CardPredicates.isType("Urza's").and(CardPredicates.isType("Mine"))) + && landsControlled.anyMatch(CardPredicates.isType("Urza's").and(CardPredicates.isType("Power-Plant"))) + && landsControlled.anyMatch(CardPredicates.isType("Urza's").and(CardPredicates.isType("Tower"))); } public void revealFaceDownCards() { diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantAttackBlock.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantAttackBlock.java index 393d33619ff..ae8acaeafa8 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantAttackBlock.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantAttackBlock.java @@ -17,7 +17,6 @@ */ package forge.game.staticability; -import forge.util.Iterables; import org.apache.commons.lang3.tuple.MutablePair; import org.apache.commons.lang3.tuple.Pair; @@ -105,7 +104,7 @@ public static boolean applyCantAttackAbility(final StaticAbility stAb, final Car if (stAb.hasParam("UnlessDefenderControls")) { String type = stAb.getParam("UnlessDefenderControls"); CardCollectionView list = defender.getCardsIn(ZoneType.Battlefield); - if (Iterables.any(list, + if (list.anyMatch( CardPredicates.restriction(type.split(","), hostCard.getController(), hostCard, stAb))) { return false; } @@ -113,7 +112,7 @@ public static boolean applyCantAttackAbility(final StaticAbility stAb, final Car if (stAb.hasParam("IfDefenderControls")) { String type = stAb.getParam("IfDefenderControls"); CardCollectionView list = defender.getCardsIn(ZoneType.Battlefield); - if (!Iterables.any(list, + if (!list.anyMatch( CardPredicates.restriction(type.split(","), hostCard.getController(), hostCard, stAb))) { return false; } diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java index 4a966e6f17c..1df3d92dd1a 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java @@ -231,7 +231,7 @@ public static CardCollectionView applyContinuousAbility(final StaticAbility stAb CardCollectionView lands = hostCard.getController().getLandsInPlay(); final List basic = MagicColor.Constant.BASIC_LANDS; for (String type : basic) { - if (Iterables.any(lands, CardPredicates.isType(type))) { + if (lands.anyMatch(CardPredicates.isType(type))) { String y = input.replaceAll("YourBasic", type); newKeywords.add(y); } diff --git a/forge-game/src/main/java/forge/game/zone/Zone.java b/forge-game/src/main/java/forge/game/zone/Zone.java index 1c3a0e0064a..404b9db5b47 100644 --- a/forge-game/src/main/java/forge/game/zone/Zone.java +++ b/forge-game/src/main/java/forge/game/zone/Zone.java @@ -35,7 +35,6 @@ import forge.game.event.GameEventZone; import forge.game.player.Player; import forge.util.CollectionSuppliers; -import forge.util.Iterables; import forge.util.MyRandom; import forge.util.maps.EnumMapOfLists; import forge.util.maps.MapOfLists; @@ -146,7 +145,7 @@ public final boolean contains(final Card c) { } public final boolean contains(final Predicate condition) { - return Iterables.any(cardList, condition); + return cardList.anyMatch(condition); } public void remove(final Card c) { From 7e3bb81428893bda381e4099ed7b2607be4e7e62 Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 8 Sep 2024 15:27:36 -0400 Subject: [PATCH 35/68] Guava migration - Inline `Iterables.any` (Collection overload) --- .../src/main/java/forge/ai/AiAttackController.java | 2 +- forge-ai/src/main/java/forge/ai/AiController.java | 2 +- forge-ai/src/main/java/forge/ai/ComputerUtil.java | 12 ++++++------ .../src/main/java/forge/ai/ComputerUtilCard.java | 6 +++--- .../src/main/java/forge/ai/ComputerUtilMana.java | 2 +- .../main/java/forge/ai/ability/ChangeZoneAi.java | 2 +- .../java/forge/ai/ability/CopyPermanentAi.java | 2 +- .../src/main/java/forge/ai/ability/DebuffAi.java | 3 +-- .../src/main/java/forge/ai/ability/EffectAi.java | 8 ++++---- .../src/main/java/forge/ai/ability/PlayAi.java | 4 ++-- forge-core/src/main/java/forge/card/CardType.java | 2 +- forge-core/src/main/java/forge/util/Iterables.java | 3 --- .../src/main/java/forge/game/GameAction.java | 4 ++-- .../forge/game/ability/effects/PlayEffect.java | 12 +++++------- .../main/java/forge/game/card/CardProperty.java | 8 ++++---- .../java/forge/game/combat/AttackConstraints.java | 2 +- .../java/forge/game/combat/AttackRestriction.java | 10 +++------- .../src/main/java/forge/game/phase/Untap.java | 3 +-- .../src/main/java/forge/game/player/Player.java | 3 ++- .../game/spellability/SpellAbilityRestriction.java | 2 +- .../forge/game/spellability/TargetChoices.java | 6 +++--- .../staticability/StaticAbilityPanharmonicon.java | 14 +++++++------- .../java/forge/gamemodes/quest/BoosterUtils.java | 7 ++----- .../main/java/forge/gui/card/CardScriptParser.java | 7 +++---- 24 files changed, 56 insertions(+), 70 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiAttackController.java b/forge-ai/src/main/java/forge/ai/AiAttackController.java index 577bce8107c..1ae072133f1 100644 --- a/forge-ai/src/main/java/forge/ai/AiAttackController.java +++ b/forge-ai/src/main/java/forge/ai/AiAttackController.java @@ -1575,7 +1575,7 @@ public static List exertAttackers(final List attackers, int aggressi if (validTargets.isEmpty()) { missTarget = true; break; - } else if (sa.isCurse() && !Iterables.any(validTargets, + } else if (sa.isCurse() && validTargets.stream().noneMatch( CardPredicates.isControlledByAnyOf(c.getController().getOpponents()))) { // e.g. Ahn-Crop Crasher - the effect is only good when aimed at opponent's creatures missTarget = true; diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index c9e3b3c0b28..cdfe1e9b85c 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -458,7 +458,7 @@ private CardCollection filterLandsToPlay(CardCollection landList) { return false; } } - return Iterables.any(c.getAllPossibleAbilities(player, true), SpellAbility::isLandAbility); + return c.getAllPossibleAbilities(player, true).stream().anyMatch(SpellAbility::isLandAbility); }); return landList; } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index 5c7a192e3f5..5e4b05faa86 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -3083,11 +3083,11 @@ public static boolean lifegainPositive(final Player player, final Card source) { repParams, ReplacementLayer.Other); - if (Iterables.any(list, CardTraitPredicates.hasParam("AILogic", "NoLife"))) { + if (list.stream().anyMatch(CardTraitPredicates.hasParam("AILogic", "NoLife"))) { return false; - } else if (Iterables.any(list, CardTraitPredicates.hasParam("AILogic", "LoseLife"))) { + } else if (list.stream().anyMatch(CardTraitPredicates.hasParam("AILogic", "LoseLife"))) { return false; - } else if (Iterables.any(list, CardTraitPredicates.hasParam("AILogic", "LichDraw"))) { + } else if (list.stream().anyMatch(CardTraitPredicates.hasParam("AILogic", "LichDraw"))) { return false; } return true; @@ -3112,13 +3112,13 @@ public static boolean lifegainNegative(final Player player, final Card source, f ReplacementLayer.Other ); - if (Iterables.any(list, CardTraitPredicates.hasParam("AILogic", "NoLife"))) { + if (list.stream().anyMatch(CardTraitPredicates.hasParam("AILogic", "NoLife"))) { // no life gain is not negative return false; - } else if (Iterables.any(list, CardTraitPredicates.hasParam("AILogic", "LoseLife"))) { + } else if (list.stream().anyMatch(CardTraitPredicates.hasParam("AILogic", "LoseLife"))) { // lose life is only negative is the player can lose life return player.canLoseLife(); - } else if (Iterables.any(list, CardTraitPredicates.hasParam("AILogic", "LichDraw"))) { + } else if (list.stream().anyMatch(CardTraitPredicates.hasParam("AILogic", "LichDraw"))) { // if it would draw more cards than player has, then its negative return player.getCardsIn(ZoneType.Library).size() <= n; } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index 83b8dbbe41b..ac36d80c602 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -1421,7 +1421,7 @@ && doesCreatureAttackAI(ai, c)) { //1. become attacker for whatever reason if (!doesCreatureAttackAI(ai, c) && doesSpecifiedCreatureAttackAI(ai, pumped)) { float threat = 1.0f * ComputerUtilCombat.damageIfUnblocked(pumped, opp, combat, true) / opp.getLife(); - if (!Iterables.any(oppCreatures, CardPredicates.possibleBlockers(pumped))) { + if (oppCreatures.stream().noneMatch(CardPredicates.possibleBlockers(pumped))) { threat *= 2; } if (c.getNetPower() == 0 && c == sa.getHostCard() && power > 0) { @@ -1473,8 +1473,8 @@ && doesCreatureAttackAI(ai, c)) { } //3. grant evasive - if (Iterables.any(oppCreatures, CardPredicates.possibleBlockers(c))) { - if (!Iterables.any(oppCreatures, CardPredicates.possibleBlockers(pumped)) + if (oppCreatures.stream().anyMatch(CardPredicates.possibleBlockers(c))) { + if (oppCreatures.stream().noneMatch(CardPredicates.possibleBlockers(pumped)) && doesSpecifiedCreatureAttackAI(ai, pumped)) { chance += 0.5f * ComputerUtilCombat.damageIfUnblocked(pumped, opp, combat, true) / opp.getLife(); } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index 37050fdffe0..d3b6ba1144a 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -751,7 +751,7 @@ private static boolean payManaCost(final ManaCostBeingPaid cost, final SpellAbil break; // unwise to pay } else if (sa.getParam("AIPhyrexianPayment").startsWith("OnFatalDamage.")) { int dmg = Integer.parseInt(sa.getParam("AIPhyrexianPayment").substring(14)); - if (!Iterables.any(ai.getOpponents(), PlayerPredicates.lifeLessOrEqualTo(dmg))) { + if (ai.getOpponents().stream().noneMatch(PlayerPredicates.lifeLessOrEqualTo(dmg))) { break; // no one to finish with the gut shot } } diff --git a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java index 008eee1ce37..d11af4a45e9 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java @@ -612,7 +612,7 @@ private static Card basicManaFixing(final Player ai, final List list) { // } // pick dual lands if available - if (Iterables.any(result, CardPredicates.NONBASIC_LANDS)) { + if (result.stream().anyMatch(CardPredicates.NONBASIC_LANDS)) { result = CardLists.filter(result, CardPredicates.NONBASIC_LANDS); } diff --git a/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java b/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java index fe801af02c5..a4082a42c74 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java @@ -176,7 +176,7 @@ protected boolean doTriggerAINoCost(final Player aiPlayer, SpellAbility sa, bool list = CardLists.filter(list, c -> (!c.getType().isLegendary() || canCopyLegendary) || !c.getController().equals(aiPlayer)); Card choice; - if (Iterables.any(list, CardPredicates.CREATURES)) { + if (list.stream().anyMatch(CardPredicates.CREATURES)) { if (sa.hasParam("TargetingPlayer")) { choice = ComputerUtilCard.getWorstCreatureAI(list); } else { diff --git a/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java b/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java index 35d3b2d5307..c42b8af1253 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java @@ -23,7 +23,6 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; -import forge.util.Iterables; public class DebuffAi extends SpellAbilityAi { @@ -68,7 +67,7 @@ protected boolean canPlayAI(final Player ai, final SpellAbility sa) { List cards = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa); final Combat combat = game.getCombat(); - return Iterables.any(cards, c -> { + return cards.stream().anyMatch(c -> { if (c.getController().equals(sa.getActivatingPlayer()) || combat == null) return false; diff --git a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java index 35f9e0e27c4..699a4c053a8 100644 --- a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java @@ -334,9 +334,9 @@ protected boolean canPlayAI(final Player ai,final SpellAbility sa) { list = CardLists.filter(list, CardPredicates.CAN_BE_DESTROYED, input -> { Map runParams = AbilityKey.mapFromAffected(input); runParams.put(AbilityKey.Regeneration, true); - List repDestoryList = game.getReplacementHandler().getReplacementList(ReplacementType.Destroy, runParams, ReplacementLayer.Other); + List repDestroyList = game.getReplacementHandler().getReplacementList(ReplacementType.Destroy, runParams, ReplacementLayer.Other); // no Destroy Replacement, or one non-Regeneration one like Totem-Armor - if (repDestoryList.isEmpty() || Iterables.any(repDestoryList, CardTraitPredicates.hasParam("Regeneration").negate())) { + if (repDestroyList.isEmpty() || repDestroyList.stream().anyMatch(CardTraitPredicates.hasParam("Regeneration").negate())) { return false; } @@ -365,9 +365,9 @@ protected boolean canPlayAI(final Player ai,final SpellAbility sa) { Map runParams = AbilityKey.mapFromAffected(sa.getHostCard()); runParams.put(AbilityKey.Regeneration, true); - List repDestoryList = game.getReplacementHandler().getReplacementList(ReplacementType.Destroy, runParams, ReplacementLayer.Other); + List repDestroyList = game.getReplacementHandler().getReplacementList(ReplacementType.Destroy, runParams, ReplacementLayer.Other); // no Destroy Replacement, or one non-Regeneration one like Totem-Armor - if (repDestoryList.isEmpty() || Iterables.any(repDestoryList, CardTraitPredicates.hasParam("Regeneration").negate())) { + if (repDestroyList.isEmpty() || repDestroyList.stream().anyMatch(CardTraitPredicates.hasParam("Regeneration").negate())) { return false; } diff --git a/forge-ai/src/main/java/forge/ai/ability/PlayAi.java b/forge-ai/src/main/java/forge/ai/ability/PlayAi.java index 0fce9f4ced4..52ec31c7f86 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PlayAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PlayAi.java @@ -13,7 +13,6 @@ import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.*; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.MyRandom; import java.util.Iterator; @@ -223,7 +222,8 @@ private static List getPlayableCards(SpellAbility sa, Player ai) { final Iterator itr = cards.iterator(); while (itr.hasNext()) { final Card c = itr.next(); - if (!Iterables.any(AbilityUtils.getBasicSpellsFromPlayEffect(c, ai), SpellAbilityPredicates.isValid(valid, ai , source, sa))) { + if (AbilityUtils.getBasicSpellsFromPlayEffect(c, ai).stream() + .noneMatch(SpellAbilityPredicates.isValid(valid, ai, source, sa))) { itr.remove(); } } diff --git a/forge-core/src/main/java/forge/card/CardType.java b/forge-core/src/main/java/forge/card/CardType.java index 9b8931a2905..3aa0bc249ad 100644 --- a/forge-core/src/main/java/forge/card/CardType.java +++ b/forge-core/src/main/java/forge/card/CardType.java @@ -403,7 +403,7 @@ private static String toMixedCase(final String s) { @Override public boolean hasABasicLandType() { - return Iterables.any(this.subtypes, Predicates.IS_BASIC_LAND_TYPE); + return this.subtypes.stream().anyMatch(Predicates.IS_BASIC_LAND_TYPE); } @Override public boolean hasANonBasicLandType() { diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index c21dd36f095..8d34ca4bd7a 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -66,9 +66,6 @@ public static Iterable transform(final Iterable iterable, final Fun public static Iterable filter(Collection iterable, Predicate filter) { return () -> iterable.stream().filter(filter).iterator(); } - public static boolean any(Collection iterable, Predicate test) { - return iterable.stream().anyMatch(test); - } public static boolean all(Collection iterable, Predicate test) { return iterable.stream().allMatch(test); } diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index 2f24155d86d..8d1db2d0452 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -132,7 +132,7 @@ private Card changeZone(final Zone zoneFrom, Zone zoneTo, final Card c, Integer // need to check before it enters if (c.isAura() && !c.isAttachedToEntity() && toBattlefield && (zoneFrom == null || !zoneFrom.is(ZoneType.Stack))) { boolean found = false; - if (Iterables.any(game.getPlayers(), PlayerPredicates.canBeAttached(c, null))) { + if (game.getPlayers().stream().anyMatch(PlayerPredicates.canBeAttached(c, null))) { found = true; } @@ -411,7 +411,7 @@ private Card changeZone(final Zone zoneFrom, Zone zoneTo, final Card c, Integer if (copied.isAura() && !copied.isAttachedToEntity() && toBattlefield) { if (zoneFrom != null && zoneFrom.is(ZoneType.Stack) && game.getStack().isResolving(c)) { boolean found = false; - if (Iterables.any(game.getPlayers(), PlayerPredicates.canBeAttached(copied, null))) { + if (game.getPlayers().stream().anyMatch(PlayerPredicates.canBeAttached(copied, null))) { found = true; } if (lastBattlefield.anyMatch(CardPredicates.canBeAttached(copied, null))) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java index c82cb1a93fb..85efa8f76a1 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java @@ -1,10 +1,6 @@ package forge.game.ability.effects; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.function.Predicate; import forge.card.CardStateName; @@ -190,7 +186,8 @@ public void resolve(final SpellAbility sa) { Iterator it = tgtCards.iterator(); while (it.hasNext()) { Card c = it.next(); - if (!Iterables.any(AbilityUtils.getBasicSpellsFromPlayEffect(c, controller), SpellAbilityPredicates.isValid(valid, controller , source, sa))) { + if (AbilityUtils.getBasicSpellsFromPlayEffect(c, controller).stream() + .noneMatch(SpellAbilityPredicates.isValid(valid, controller, source, sa))) { // it.remove will only remove item from the list part of CardCollection tgtCards.asSet().remove(c); it.remove(); @@ -232,7 +229,8 @@ public void resolve(final SpellAbility sa) { final String [] valid = {"Spell.cmcLE" + totalCMCLimit}; while (it.hasNext()) { Card c = it.next(); - if (!Iterables.any(AbilityUtils.getBasicSpellsFromPlayEffect(c, controller), SpellAbilityPredicates.isValid(valid, controller , c, sa))) { + if (AbilityUtils.getBasicSpellsFromPlayEffect(c, controller).stream() + .noneMatch(SpellAbilityPredicates.isValid(valid, controller, c, sa))) { // it.remove will only remove item from the list part of CardCollection tgtCards.asSet().remove(c); it.remove(); diff --git a/forge-game/src/main/java/forge/game/card/CardProperty.java b/forge-game/src/main/java/forge/game/card/CardProperty.java index d7626084771..50dded21f8f 100644 --- a/forge-game/src/main/java/forge/game/card/CardProperty.java +++ b/forge-game/src/main/java/forge/game/card/CardProperty.java @@ -906,7 +906,7 @@ public static boolean cardHasProperty(Card card, String property, Player sourceC } else if (restriction.equals(ZoneType.Battlefield.toString())) { return game.getCardsIn(ZoneType.Battlefield).anyMatch(CardPredicates.sharesNameWith(card)); } else if (restriction.equals("ThisTurnCast")) { - return Iterables.any(CardUtil.getThisTurnCast("Card", source, spellAbility, sourceController), CardPredicates.sharesNameWith(card)); + return CardUtil.getThisTurnCast("Card", source, spellAbility, sourceController).stream().anyMatch(CardPredicates.sharesNameWith(card)); } else if (restriction.equals("MovedToGrave")) { if (!(spellAbility instanceof SpellAbility)) { final SpellAbility root = ((SpellAbility) spellAbility).getRootAbility(); @@ -1704,7 +1704,7 @@ else if (property.equals("blocked")) { return false; } String valid = property.split(" ")[1]; - if (Iterables.any(blocked, CardPredicates.restriction(valid, card.getController(), source, spellAbility))) { + if (blocked.stream().anyMatch(CardPredicates.restriction(valid, card.getController(), source, spellAbility))) { return true; } for (Card c : AbilityUtils.getDefinedCards(source, valid, spellAbility)) { @@ -1719,7 +1719,7 @@ else if (property.equals("blocked")) { return false; } String valid = property.split(" ")[1]; - if (Iterables.any(blocked, CardPredicates.restriction(valid, card.getController(), source, spellAbility))) { + if (blocked.stream().anyMatch(CardPredicates.restriction(valid, card.getController(), source, spellAbility))) { return true; } for (Card c : AbilityUtils.getDefinedCards(source, valid, spellAbility)) { @@ -2098,7 +2098,7 @@ else if (property.equals("blocked")) { } List typeList = Lists.newArrayList(types.split(",")); - return Iterables.any(card.getType().getCreatureTypes(), typeList::contains); + return card.getType().getCreatureTypes().stream().anyMatch(typeList::contains); } else if (property.startsWith("Triggered")) { if (spellAbility instanceof SpellAbility) { final String key = property.substring(9); 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 aa0c0c24dd2..55cac993540 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackConstraints.java +++ b/forge-game/src/main/java/forge/game/combat/AttackConstraints.java @@ -266,7 +266,7 @@ private List> collectLegalAttackers(final Map predicateRestriction : predicateRestrictions) { - if (Iterables.any(Sets.union(myAttackers.keySet(), reserved.asSet()), predicateRestriction)) { + if (Sets.union(myAttackers.keySet(), reserved.asSet()).stream().anyMatch(predicateRestriction)) { // predicate fulfilled already, ignore! continue; } diff --git a/forge-game/src/main/java/forge/game/combat/AttackRestriction.java b/forge-game/src/main/java/forge/game/combat/AttackRestriction.java index 10a73cdf7e2..fc0d365d61e 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackRestriction.java +++ b/forge-game/src/main/java/forge/game/combat/AttackRestriction.java @@ -1,13 +1,9 @@ package forge.game.combat; -import java.util.Collections; -import java.util.EnumSet; -import java.util.Map; -import java.util.Set; +import java.util.*; import forge.game.GameEntity; import forge.game.card.Card; -import forge.util.Iterables; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; @@ -54,11 +50,11 @@ public Set getViolation(final Map attac violations.add(AttackRestrictionType.ONLY_ALONE); } if (restrictions.contains(AttackRestrictionType.NEED_GREATER_POWER) - && !Iterables.any(attackers.keySet(), AttackRestrictionType.NEED_GREATER_POWER.getPredicate(attacker))) { + && attackers.keySet().stream().noneMatch(AttackRestrictionType.NEED_GREATER_POWER.getPredicate(attacker))) { violations.add(AttackRestrictionType.NEED_GREATER_POWER); } if (restrictions.contains(AttackRestrictionType.NEED_BLACK_OR_GREEN) - && !Iterables.any(attackers.keySet(), AttackRestrictionType.NEED_BLACK_OR_GREEN.getPredicate(attacker))) { + && attackers.keySet().stream().noneMatch(AttackRestrictionType.NEED_BLACK_OR_GREEN.getPredicate(attacker))) { violations.add(AttackRestrictionType.NEED_BLACK_OR_GREEN); } if (restrictions.contains(AttackRestrictionType.NOT_ALONE) && nAttackers <= 1) { diff --git a/forge-game/src/main/java/forge/game/phase/Untap.java b/forge-game/src/main/java/forge/game/phase/Untap.java index b1a000dd657..eedbd5b20c5 100644 --- a/forge-game/src/main/java/forge/game/phase/Untap.java +++ b/forge-game/src/main/java/forge/game/phase/Untap.java @@ -43,7 +43,6 @@ import forge.game.staticability.StaticAbilityCantPhase; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; -import forge.util.Iterables; /** *

@@ -308,7 +307,7 @@ private static void doDayTime(final Player previous) { final Game game = previous.getGame(); List casted = game.getStack().getSpellsCastLastTurn(); - if (game.isDay() && !Iterables.any(casted, CardPredicates.isController(previous))) { + if (game.isDay() && casted.stream().noneMatch(CardPredicates.isController(previous))) { game.setDayTime(true); } else if (game.isNight() && CardLists.count(casted, CardPredicates.isController(previous)) > 1) { game.setDayTime(false); diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index 9dd487f0067..bae89b2a0de 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -2119,7 +2119,8 @@ public final boolean hasDelirium() { } public final boolean hasLandfall() { - return Iterables.any(getZone(ZoneType.Battlefield).getCardsAddedThisTurn(null), CardPredicates.LANDS); + return getZone(ZoneType.Battlefield).getCardsAddedThisTurn(null).stream() + .anyMatch(CardPredicates.LANDS); } public boolean hasFerocious() { diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java index 5078738ea84..9660aaa66aa 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java @@ -573,7 +573,7 @@ public final boolean checkOtherRestrictions(final Card c, final SpellAbility sa, if (this.getGameTypes().size() > 0) { Predicate pgt = type -> game.getRules().hasAppliedVariant(type); - if (!Iterables.any(getGameTypes(), pgt)) { + if (getGameTypes().stream().noneMatch(pgt)) { return false; } } diff --git a/forge-game/src/main/java/forge/game/spellability/TargetChoices.java b/forge-game/src/main/java/forge/game/spellability/TargetChoices.java index 8bddc154f38..e2397789884 100644 --- a/forge-game/src/main/java/forge/game/spellability/TargetChoices.java +++ b/forge-game/src/main/java/forge/game/spellability/TargetChoices.java @@ -117,15 +117,15 @@ public final Iterable getTargetEntities() { } public final boolean isTargetingAnyCard() { - return Iterables.any(targets, Card.class::isInstance); + return targets.stream().anyMatch(Card.class::isInstance); } public final boolean isTargetingAnyPlayer() { - return Iterables.any(targets, Player.class::isInstance); + return targets.stream().anyMatch(Player.class::isInstance); } public final boolean isTargetingAnySpell() { - return Iterables.any(targets, SpellAbility.class::isInstance); + return targets.stream().anyMatch(SpellAbility.class::isInstance); } public final Card getFirstTargetedCard() { diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityPanharmonicon.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityPanharmonicon.java index 651aa40dea8..dd292c40bab 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityPanharmonicon.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityPanharmonicon.java @@ -20,7 +20,6 @@ import java.util.List; import java.util.Map; -import forge.util.Iterables; import org.apache.commons.lang3.ArrayUtils; public class StaticAbilityPanharmonicon { @@ -177,10 +176,10 @@ public static boolean applyPanharmoniconAbility(final StaticAbility stAb, final Map dmgMap = (Map) runParams.get(AbilityKey.DamageMap); // 1. check it's valid cause for static // 2. and it must also be valid for trigger event - if (!Iterables.any(dmgMap.keySet(), + if (dmgMap.keySet().stream().noneMatch( GameObjectPredicates.matchesValidParam(stAb, "ValidSource") - .and(GameObjectPredicates.matchesValidParam(trigger, "ValidSource")) - )) { + .and(GameObjectPredicates.matchesValidParam(trigger, "ValidSource")) + )) { return false; } // DamageAmount$ can be ignored for now (its usage doesn't interact with ValidSource from either) @@ -190,9 +189,10 @@ public static boolean applyPanharmoniconAbility(final StaticAbility stAb, final return false; } Map dmgMap = (Map) runParams.get(AbilityKey.DamageMap); - if (!Iterables.any(dmgMap.keySet(), GameObjectPredicates.matchesValidParam(stAb, "ValidTarget") - .and(GameObjectPredicates.matchesValidParam(trigger, "ValidTarget")) - )) { + if (dmgMap.keySet().stream().noneMatch( + GameObjectPredicates.matchesValidParam(stAb, "ValidTarget") + .and(GameObjectPredicates.matchesValidParam(trigger, "ValidTarget")) + )) { return false; } } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java index 8722978e1a2..6968cbaa095 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java @@ -19,10 +19,7 @@ import static forge.gamemodes.quest.QuestUtilCards.isLegalInQuestFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; +import java.util.*; import java.util.function.Predicate; import forge.item.*; @@ -137,7 +134,7 @@ public static List getQuestStarterDeck(final GameFormat formatStartin } final boolean allowDuplicates = userPrefs != null && userPrefs.allowDuplicates(); - final boolean mythicsAvailable = Iterables.any(cardPool, PaperCardPredicates.IS_MYTHIC_RARE); + final boolean mythicsAvailable = cardPool.stream().anyMatch(PaperCardPredicates.IS_MYTHIC_RARE); final int numMythics = mythicsAvailable ? numRares / RARES_PER_MYTHIC : 0; final int adjustedRares = numRares - numMythics; diff --git a/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java b/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java index e7bda942ca7..165e7f7577b 100644 --- a/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java +++ b/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java @@ -5,7 +5,6 @@ import java.util.Set; import java.util.function.Predicate; -import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import com.google.common.collect.ImmutableSortedSet; @@ -393,7 +392,7 @@ private static boolean isDefinedCardOrSaLegal(final String defined) { if (DEFINED_CARDS.contains(defined)) { return true; } - return Iterables.any(DEFINED_CARDS_STARTSWITH, startsWith(defined)); + return DEFINED_CARDS_STARTSWITH.stream().anyMatch(startsWith(defined)); } private static boolean isDefinedPlayerLegal(final String defined) { final boolean non = defined.startsWith("Non"), flipped = defined.startsWith("Flipped"); @@ -409,7 +408,7 @@ private static boolean isDefinedPlayerLegal(final String defined) { if (DEFINED_PLAYERS.contains(defined)) { return true; } - return Iterables.any(DEFINED_PLAYERS_STARTSWITH, startsWith(defined)); + return DEFINED_PLAYERS_STARTSWITH.stream().anyMatch(startsWith(defined)); } private static final Set VALID_INCLUSIVE = ImmutableSortedSet.of( @@ -514,7 +513,7 @@ private static boolean isValidExclusive(String valid) { if (VALID_EXCLUSIVE.contains(valid)) { return true; } - return Iterables.any(VALID_EXCLUSIVE_STARTSWITH, startsWith(valid)); + return VALID_EXCLUSIVE_STARTSWITH.stream().anyMatch(startsWith(valid)); } private static final class KeyValuePair { From cf68a75c03f62833aacfe34195576fc7e8b0326b Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 8 Sep 2024 15:29:41 -0400 Subject: [PATCH 36/68] Guava migration - Inline `Iterables.all` (Collection overload) --- forge-core/src/main/java/forge/util/Iterables.java | 3 --- .../forge/localinstance/achievements/AgainstAllOdds.java | 5 ++--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index 8d34ca4bd7a..6f86363025d 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -66,9 +66,6 @@ public static Iterable transform(final Iterable iterable, final Fun public static Iterable filter(Collection iterable, Predicate filter) { return () -> iterable.stream().filter(filter).iterator(); } - public static boolean all(Collection iterable, Predicate test) { - return iterable.stream().allMatch(test); - } public static int size(Collection collection) { diff --git a/forge-gui/src/main/java/forge/localinstance/achievements/AgainstAllOdds.java b/forge-gui/src/main/java/forge/localinstance/achievements/AgainstAllOdds.java index 530602980b9..00de95c14a3 100644 --- a/forge-gui/src/main/java/forge/localinstance/achievements/AgainstAllOdds.java +++ b/forge-gui/src/main/java/forge/localinstance/achievements/AgainstAllOdds.java @@ -4,7 +4,6 @@ import forge.game.player.Player; import forge.game.player.PlayerCollection; import forge.game.player.PlayerPredicates; -import forge.util.Iterables; import forge.util.Localizer; public class AgainstAllOdds extends Achievement { @@ -25,9 +24,9 @@ protected int evaluate(Player player, Game game) { for (Player opp : player.getRegisteredOpponents()) { PlayerCollection otherOpps = player.getRegisteredOpponents(); otherOpps.remove(opp); - if (Iterables.all(otherOpps, PlayerPredicates.sameTeam(opp))) { + if (otherOpps.stream().allMatch(PlayerPredicates.sameTeam(opp))) { teamNum++; - } else if (Iterables.all(otherOpps, PlayerPredicates.sameTeam(opp).negate())) { + } else if (otherOpps.stream().allMatch(PlayerPredicates.sameTeam(opp).negate())) { teamNum--; } } From 76aa19622ec65db5a1e71fed1792c183a97818a5 Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 15 Sep 2024 17:16:24 -0400 Subject: [PATCH 37/68] Guava migration - Replace select usages of `Iterables.filter` --- .../src/main/java/forge/ai/AiController.java | 3 +- .../main/java/forge/ai/ComputerUtilCard.java | 11 ++-- .../main/java/forge/ai/ComputerUtilMana.java | 7 ++- .../src/main/java/forge/ai/SpecialCardAi.java | 4 +- .../forge/ai/ability/ChooseGenericAi.java | 6 +- .../forge/ai/ability/CountersMultiplyAi.java | 5 +- .../main/java/forge/ai/ability/TokenAi.java | 1 - .../src/main/java/forge/card/CardDb.java | 51 +++++++++++---- .../src/main/java/forge/card/CardType.java | 4 +- .../main/java/forge/card/ICardDatabase.java | 4 ++ .../forge/deck/generation/DeckGenPool.java | 8 +-- .../main/java/forge/item/SealedProduct.java | 4 +- .../src/main/java/forge/util/Iterables.java | 7 +-- .../java/forge/util/storage/IStorage.java | 2 + .../java/forge/util/storage/StorageBase.java | 6 ++ .../java/forge/game/ability/AbilityUtils.java | 2 +- .../ability/effects/CopyPermanentEffect.java | 6 +- .../game/ability/effects/PlayEffect.java | 8 +-- .../effects/PlayLandVariantEffect.java | 13 ++-- .../src/main/java/forge/game/card/Card.java | 4 +- .../java/forge/game/card/CardCollection.java | 12 ++++ .../java/forge/game/card/CardDamageMap.java | 7 +-- .../main/java/forge/game/card/CardUtil.java | 6 +- .../forge/game/card/TokenCreateTable.java | 9 +-- .../java/forge/game/combat/CombatUtil.java | 1 - .../spellability/SpellAbilityCondition.java | 7 ++- .../spellability/SpellAbilityRestriction.java | 4 +- .../forge/game/trigger/TriggerHandler.java | 2 +- .../java/forge/gui/ImportSourceAnalyzer.java | 16 ++--- .../java/forge/itemmanager/CardManager.java | 6 +- .../java/forge/itemmanager/ItemManager.java | 2 +- .../PlanarConquestCommanderGeneraterGA.java | 14 ++--- .../PlanarConquestGeneraterGA.java | 14 ++--- .../PlanarConquestTribalGeneraterGA.java | 15 ++--- .../src/forge/adventure/util/CardUtil.java | 17 +++-- .../deck/CardRelationMatrixGenerator.java | 59 +++++++++-------- .../forge/deck/CommanderDeckGenerator.java | 36 +++++------ .../src/main/java/forge/deck/DeckgenUtil.java | 2 +- .../CardThemedCommanderDeckBuilder.java | 8 +-- .../CardThemedConquestDeckBuilder.java | 7 ++- .../limited/CardThemedDeckBuilder.java | 63 ++++++++----------- .../gamemodes/limited/LimitedDeckBuilder.java | 32 +++++----- .../gamemodes/limited/LimitedPlayer.java | 5 +- .../forge/gamemodes/limited/WinstonDraft.java | 7 +-- .../planarconquest/ConquestUtil.java | 2 +- .../forge/gamemodes/quest/BoosterUtils.java | 11 ++-- .../quest/QuestRewardCardChooser.java | 7 +-- .../quest/QuestRewardCardFiltered.java | 7 +-- .../forge/gamemodes/quest/QuestUtilCards.java | 16 +++-- .../forge/player/PlayerControllerHuman.java | 16 ++--- .../java/forge/lda/LDAModelGenetrator.java | 36 +++++------ 51 files changed, 310 insertions(+), 292 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index cdfe1e9b85c..6307829cdf9 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -62,6 +62,7 @@ import java.util.*; import java.util.function.Predicate; +import java.util.stream.Collectors; /** *

@@ -2205,7 +2206,7 @@ public List orderPlaySa(List activePlayerSAs) { // TODO move to more common place private static List filterList(List input, Predicate pred) { - List filtered = Lists.newArrayList(Iterables.filter(input, pred)); + List filtered = input.stream().filter(pred).collect(Collectors.toList()); input.removeAll(filtered); return filtered; } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index ac36d80c602..050574ba77c 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -250,12 +250,11 @@ public static Card getBestLandAI(final Iterable list) { final List bLand = CardLists.getType(land, sminBL); - for (Card ut : Iterables.filter(bLand, CardPredicates.UNTAPPED)) { - return ut; - } - - // TODO potentially risky if simulation mode currently able to reach this from triggers - return Aggregates.random(bLand); // random tapped land of least represented type + return bLand.stream() + .filter(CardPredicates.UNTAPPED) + .findFirst() + // TODO potentially risky if simulation mode currently able to reach this from triggers + .orElseGet(() -> Aggregates.random(bLand)); // random tapped land of least represented type } /** diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index d3b6ba1144a..7b320ebb9ef 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -41,12 +41,12 @@ import forge.game.trigger.TriggerType; import forge.game.zone.Zone; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.MyRandom; import forge.util.TextUtil; import org.apache.commons.lang3.StringUtils; import java.util.*; +import java.util.stream.Collectors; public class ComputerUtilMana { private final static boolean DEBUG_MANA_PAYMENT = false; @@ -264,7 +264,10 @@ public static SpellAbility chooseManaAbility(ManaCostBeingPaid cost, SpellAbilit saList = filteredList; break; case "NotSameCard": - saList = Lists.newArrayList(Iterables.filter(filteredList, saPay -> !saPay.getHostCard().getName().equals(sa.getHostCard().getName()))); + String hostName = sa.getHostCard().getName(); + saList = filteredList.stream() + .filter(saPay -> !saPay.getHostCard().getName().equals(hostName)) + .collect(Collectors.toList()); break; default: break; diff --git a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java index fb8e4c8c5c5..f67ae1cfaf2 100644 --- a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java +++ b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java @@ -685,7 +685,7 @@ public static boolean consider(final Player ai, final SpellAbility sa) { // Goblin Polka Band public static class GoblinPolkaBand { public static boolean consider(final Player ai, final SpellAbility sa) { - int maxPotentialTgts = Lists.newArrayList(Iterables.filter(ai.getOpponents().getCreaturesInPlay(), CardPredicates.UNTAPPED)).size(); + int maxPotentialTgts = ai.getOpponents().getCreaturesInPlay().filter(CardPredicates.UNTAPPED).size(); int maxPotentialPayment = ComputerUtilMana.determineLeftoverMana(sa, ai, "R", false); int numTgts = Math.min(maxPotentialPayment, maxPotentialTgts); @@ -1295,7 +1295,7 @@ public static boolean considerFirstTarget(final Player ai, final SpellAbility sa public static boolean considerSecondTarget(final Player ai, final SpellAbility sa) { Card firstTgt = sa.getParent().getTargetCard(); - Iterable candidates = Iterables.filter(ai.getOpponents().getCardsIn(ZoneType.Battlefield), + CardCollection candidates = ai.getOpponents().getCardsIn(ZoneType.Battlefield).filter( CardPredicates.sharesCardTypeWith(firstTgt).and(CardPredicates.isTargetableBy(sa))); Card secondTgt = Aggregates.random(candidates); if (secondTgt != null) { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseGenericAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseGenericAi.java index 29b47d497a8..e9686d20584 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseGenericAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseGenericAi.java @@ -13,11 +13,11 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Aggregates; -import forge.util.Iterables; import forge.util.collect.FCollection; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; public class ChooseGenericAi extends SpellAbilityAi { @@ -84,7 +84,9 @@ public SpellAbility chooseSingleSpellAbility(Player player, SpellAbility sa, Lis } else if ("Random".equals(logic)) { return Aggregates.random(spells); } else if ("Phasing".equals(logic)) { // Teferi's Realm : keep aggressive - List filtered = Lists.newArrayList(Iterables.filter(spells, sp -> !sp.getDescription().contains("Creature") && !sp.getDescription().contains("Land"))); + List filtered = spells.stream() + .filter(sp -> !sp.getDescription().contains("Creature") && !sp.getDescription().contains("Land")) + .collect(Collectors.toList()); return Aggregates.random(filtered); } else if ("PayUnlessCost".equals(logic)) { for (final SpellAbility sp : spells) { diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java index 522590f4e13..6e1defd5d4b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java @@ -23,7 +23,6 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; public class CountersMultiplyAi extends SpellAbilityAi { @@ -103,7 +102,9 @@ protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandator if (list.isEmpty()) { return false; } - Card safeMatch = Iterables.getFirst(Iterables.filter(list, CardPredicates.hasCounters().negate()), null); + Card safeMatch = list.stream() + .filter(CardPredicates.hasCounters().negate()) + .findFirst().orElse(null); sa.getTargets().add(safeMatch == null ? list.getFirst() : safeMatch); return true; } diff --git a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java index 1798b3a7037..7407e41fb4c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java @@ -2,7 +2,6 @@ import java.util.List; import java.util.Map; -import java.util.function.Predicate; import forge.ai.AiController; import forge.ai.AiProps; diff --git a/forge-core/src/main/java/forge/card/CardDb.java b/forge-core/src/main/java/forge/card/CardDb.java index d0bd09571d5..89c851d5750 100644 --- a/forge-core/src/main/java/forge/card/CardDb.java +++ b/forge-core/src/main/java/forge/card/CardDb.java @@ -38,6 +38,7 @@ import java.util.Map.Entry; import java.util.function.Predicate; import java.util.stream.Collectors; +import java.util.stream.Stream; public final class CardDb implements ICardDatabase, IDeckGenPool { public final static String foilSuffix = "+"; @@ -827,7 +828,7 @@ private PaperCard tryToGetCardFromEditions(String cardInfo, CardArtPreference ar return null; // nothing to do // Filter Cards Editions based on set preferences - List acceptedEditions = Lists.newArrayList(Iterables.filter(cardEditions, artPref::accept)); + List acceptedEditions = cardEditions.stream().filter(artPref::accept).collect(Collectors.toList()); /* At this point, it may be possible that Art Preference is too-strict for the requested card! i.e. acceptedEditions.size() == 0! @@ -899,6 +900,10 @@ public Collection getUniqueCardsNoAlt() { }).values(); } + public List getUniqueCardsNoAlt(String cardName) { + return Lists.newArrayList(Maps.filterEntries(uniqueCardsByName, entry -> entry.getKey().equals(entry.getValue().getName())).get(getName(cardName))); + } + public PaperCard getUniqueByName(final String name) { return uniqueCardsByName.get(getName(name)); } @@ -940,8 +945,23 @@ public Collection getAllCardsNoAlt() { return Multimaps.filterEntries(allCardsByName, entry -> entry.getKey().equals(entry.getValue().getName())).values(); } - public Collection getAllNonPromoCards() { - return Lists.newArrayList(Iterables.filter(getAllCards(), paperCard -> { + @Override + public Stream streamAllCards() { + return allCardsByName.values().stream(); + } + @Override + public Stream streamUniqueCards() { + return uniqueCardsByName.values().stream(); + } + public Stream streamAllCardsNoAlt() { + return allCardsByName.entries().stream().filter(e -> e.getKey().equals(e.getValue().getName())).map(Entry::getValue); + } + public Stream streamUniqueCardsNoAlt() { + return uniqueCardsByName.entrySet().stream().filter(e -> e.getKey().equals(e.getValue().getName())).map(Entry::getValue); + } + public Stream streamAllNonPromoCards() { + //TODO: This should probably just be a filter to tack onto streamAllCards + return streamAllCards().filter(paperCard -> { CardEdition edition = null; try { edition = editions.getEditionByCodeOrThrow(paperCard.getEdition()); @@ -949,11 +969,19 @@ public Collection getAllNonPromoCards() { return false; } return edition != null && edition.getType() != Type.PROMO; - })); + }); + } + + public Stream streamAllFaces() { + return facesByName.values().stream(); + } + + public Collection getAllNonPromoCards() { + return streamAllNonPromoCards().collect(Collectors.toList()); } public Collection getUniqueCardsNoAltNoOnline() { - return Lists.newArrayList(Iterables.filter(getUniqueCardsNoAlt(), paperCard -> { + return streamUniqueCardsNoAlt().filter(paperCard -> { CardEdition edition = null; try { edition = editions.getEditionByCodeOrThrow(paperCard.getEdition()); @@ -963,11 +991,12 @@ public Collection getUniqueCardsNoAltNoOnline() { return false; } return true; - })); + }).collect(Collectors.toList()); } public Collection getAllNonPromosNonReprintsNoAlt() { - return Lists.newArrayList(Iterables.filter(getAllCardsNoAlt(), paperCard -> { + //TODO: This should probably also be a stream filter. + return streamAllCardsNoAlt().filter(paperCard -> { CardEdition edition = null; try { edition = editions.getEditionByCodeOrThrow(paperCard.getEdition()); @@ -977,7 +1006,7 @@ public Collection getAllNonPromosNonReprintsNoAlt() { return false; } return true; - })); + }).collect(Collectors.toList()); } public String getName(final String cardName) { @@ -1007,19 +1036,19 @@ public List getAllCardsNoAlt(String cardName) { */ @Override public List getAllCards(Predicate predicate) { - return Lists.newArrayList(Iterables.filter(getAllCards(), predicate)); + return streamAllCards().filter(predicate).collect(Collectors.toCollection(ArrayList::new)); } @Override public List getAllCards(final String cardName, Predicate predicate){ - return Lists.newArrayList(Iterables.filter(getAllCards(cardName), predicate)); + return getAllCards(cardName).stream().filter(predicate).collect(Collectors.toCollection(ArrayList::new)); } /** * Returns a modifiable list of cards matching the given predicate */ public List getAllCardsNoAlt(Predicate predicate) { - return Lists.newArrayList(Iterables.filter(getAllCardsNoAlt(), predicate)); + return streamAllCardsNoAlt().filter(predicate).collect(Collectors.toCollection(ArrayList::new)); } // Do I want a foiled version of these cards? diff --git a/forge-core/src/main/java/forge/card/CardType.java b/forge-core/src/main/java/forge/card/CardType.java index 3aa0bc249ad..ae289765fe2 100644 --- a/forge-core/src/main/java/forge/card/CardType.java +++ b/forge-core/src/main/java/forge/card/CardType.java @@ -304,9 +304,7 @@ public Set getCreatureTypes() { creatureTypes.addAll(getAllCreatureTypes()); creatureTypes.removeAll(this.excludedCreatureSubtypes); } else { - for (final String t : Iterables.filter(subtypes, Predicates.IS_CREATURE_TYPE)) { - creatureTypes.add(t); - } + subtypes.stream().filter(Predicates.IS_CREATURE_TYPE).forEach(creatureTypes::add); } return creatureTypes; } diff --git a/forge-core/src/main/java/forge/card/ICardDatabase.java b/forge-core/src/main/java/forge/card/ICardDatabase.java index 52b86868627..4e4016accce 100644 --- a/forge-core/src/main/java/forge/card/ICardDatabase.java +++ b/forge-core/src/main/java/forge/card/ICardDatabase.java @@ -7,6 +7,7 @@ import java.util.Date; import java.util.List; import java.util.function.Predicate; +import java.util.stream.Stream; public interface ICardDatabase extends Iterable { /** @@ -85,6 +86,9 @@ public interface ICardDatabase extends Iterable { Collection getAllCards(CardEdition edition); Collection getUniqueCards(); + Stream streamAllCards(); + Stream streamUniqueCards(); + /* UTILITY METHODS * =============== */ int getMaxArtIndex(String cardName); diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java b/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java index dd3b313f7eb..188c409ed53 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java @@ -38,11 +38,9 @@ public PaperCard getCard(String name) { @Override public PaperCard getCard(String name, String edition) { Predicate filter = PaperCardPredicates.printedInSet(edition).and(PaperCardPredicates.name(name)); - Iterable editionCards=Iterables.filter(cards.values(), filter); - if (editionCards.iterator().hasNext()){ - return editionCards.iterator().next(); - } - return getCard(name); + return cards.values().stream() + .filter(filter) + .findFirst().orElseGet(() -> getCard(name)); } @Override diff --git a/forge-core/src/main/java/forge/item/SealedProduct.java b/forge-core/src/main/java/forge/item/SealedProduct.java index 4cddf19bb25..f2fb3ea7743 100644 --- a/forge-core/src/main/java/forge/item/SealedProduct.java +++ b/forge-core/src/main/java/forge/item/SealedProduct.java @@ -22,11 +22,11 @@ import forge.card.CardRulesPredicates; import forge.item.generation.BoosterGenerator; import forge.util.Aggregates; -import forge.util.Iterables; import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; +import java.util.stream.Collectors; public abstract class SealedProduct implements InventoryItemFromSet { @@ -114,6 +114,6 @@ protected PaperCard getRandomBasicLand(final String setCode) { protected List getRandomBasicLands(final String setCode, final int count) { Predicate cardsRule = PaperCardPredicates.printedInSet(setCode) .and(PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND)); - return Aggregates.random(Iterables.filter(StaticData.instance().getCommonCards().getAllCards(), cardsRule), count); + return Aggregates.random(StaticData.instance().getCommonCards().streamAllCards().filter(cardsRule).collect(Collectors.toList()), count); } } diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index 6f86363025d..a0d1e9b9911 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -19,6 +19,9 @@ private Iterables(){} public static Iterable filter(Iterable iterable, Predicate filter) { return () -> StreamSupport.stream(iterable.spliterator(), false).filter(filter).iterator(); } + public static Iterable filter(Collection iterable, Predicate filter) { + return () -> iterable.stream().filter(filter).iterator(); + } public static Iterable filter(final Iterable iterable, final Class desiredType) { return () -> StreamSupport.stream(iterable.spliterator(), false) .filter(desiredType::isInstance) @@ -63,10 +66,6 @@ public static Iterable transform(final Iterable iterable, final Fun //TODO: Inline everything below. - public static Iterable filter(Collection iterable, Predicate filter) { - return () -> iterable.stream().filter(filter).iterator(); - } - public static int size(Collection collection) { return collection.size(); diff --git a/forge-core/src/main/java/forge/util/storage/IStorage.java b/forge-core/src/main/java/forge/util/storage/IStorage.java index 3818c8edfbb..e9689f211c1 100644 --- a/forge-core/src/main/java/forge/util/storage/IStorage.java +++ b/forge-core/src/main/java/forge/util/storage/IStorage.java @@ -19,6 +19,7 @@ import java.util.Collection; import java.util.function.Predicate; +import java.util.stream.Stream; import forge.util.IHasName; @@ -35,4 +36,5 @@ public interface IStorage extends Iterable, IHasName { IStorage> getFolders(); IStorage tryGetFolder(String path); IStorage getFolderOrCreate(String path); + Stream stream(); } \ No newline at end of file diff --git a/forge-core/src/main/java/forge/util/storage/StorageBase.java b/forge-core/src/main/java/forge/util/storage/StorageBase.java index 7de2ca73ccc..3683047181d 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageBase.java +++ b/forge-core/src/main/java/forge/util/storage/StorageBase.java @@ -24,6 +24,7 @@ import java.io.FilenameFilter; import java.util.*; import java.util.function.Predicate; +import java.util.stream.Stream; /** *

@@ -65,6 +66,11 @@ public Iterator iterator() { return map.values().iterator(); } + @Override + public Stream stream() { + return map.values().stream(); + } + @Override public boolean contains(String name) { return name != null && map.containsKey(name); diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index 5d84da5f3e2..1140dfef976 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -495,7 +495,7 @@ else if (ability != null) { players.addAll(player.getOpponents()); val = playerXCount(players, calcX[1], card, ability); } else if (hType.equals("RegisteredOpponents")) { - players.addAll(Iterables.filter(game.getRegisteredPlayers(), PlayerPredicates.isOpponentOf(player))); + players.addAll(game.getRegisteredPlayers().filter(PlayerPredicates.isOpponentOf(player))); val = playerXCount(players, calcX[1], card, ability); } else if (hType.equals("Other")) { players.addAll(player.getAllOtherPlayers()); diff --git a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java index 89ffe7e6f6d..b0aa3745307 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java @@ -150,7 +150,7 @@ public void resolve(final SpellAbility sa) { List tgtCards = Lists.newArrayList(); if (sa.hasParam("ValidSupportedCopy")) { - List cards = Lists.newArrayList(StaticData.instance().getCommonCards().getUniqueCards()); + Iterable cards = StaticData.instance().getCommonCards().getUniqueCards(); String valid = sa.getParam("ValidSupportedCopy"); if (valid.contains("X")) { valid = TextUtil.fastReplace(valid, @@ -158,11 +158,11 @@ public void resolve(final SpellAbility sa) { } if (StringUtils.containsIgnoreCase(valid, "creature")) { Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE); - cards = Lists.newArrayList(Iterables.filter(cards, cpp)); + cards = Iterables.filter(cards, cpp); } if (StringUtils.containsIgnoreCase(valid, "equipment")) { Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.IS_EQUIPMENT); - cards = Lists.newArrayList(Iterables.filter(cards, cpp)); + cards = Iterables.filter(cards, cpp); } if (sa.hasParam("RandomCopied")) { List copysource = Lists.newArrayList(cards); diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java index 85efa8f76a1..43d9de299b7 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java @@ -2,6 +2,7 @@ import java.util.*; import java.util.function.Predicate; +import java.util.stream.Collectors; import forge.card.CardStateName; import forge.card.GamePieceType; @@ -10,7 +11,6 @@ import org.apache.commons.lang3.StringUtils; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; import forge.StaticData; import forge.card.CardRulesPredicates; @@ -117,13 +117,11 @@ public void resolve(final SpellAbility sa) { cards.add(StaticData.instance().getCommonCards().getUniqueByName(name)); } } else if (valid.equalsIgnoreCase("sorcery")) { - cards = Lists.newArrayList(StaticData.instance().getCommonCards().getUniqueCards()); final Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.IS_SORCERY); - cards = Lists.newArrayList(Iterables.filter(cards, cpp)); + cards = StaticData.instance().getCommonCards().streamUniqueCards().filter(cpp).collect(Collectors.toList()); } else if (valid.equalsIgnoreCase("instant")) { - cards = Lists.newArrayList(StaticData.instance().getCommonCards().getUniqueCards()); final Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.IS_INSTANT); - cards = Lists.newArrayList(Iterables.filter(cards, cpp)); + cards = StaticData.instance().getCommonCards().streamUniqueCards().filter(cpp).collect(Collectors.toList()); } if (sa.hasParam("RandomCopied")) { final CardCollection choice = new CardCollection(); diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java index a36b078df29..e16508b1fd1 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java @@ -1,7 +1,8 @@ package forge.game.ability.effects; import java.util.List; -import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.stream.Stream; import com.google.common.collect.Lists; @@ -18,7 +19,6 @@ import forge.item.PaperCard; import forge.item.PaperCardPredicates; import forge.util.Aggregates; -import forge.util.Iterables; public class PlayLandVariantEffect extends SpellAbilityEffect { @@ -28,10 +28,9 @@ public void resolve(final SpellAbility sa) { final Player activator = sa.getActivatingPlayer(); final Game game = source.getGame(); final String landType = sa.getParam("Clone"); - List cards = Lists.newArrayList(StaticData.instance().getCommonCards().getUniqueCards()); + Stream cardStream = StaticData.instance().getCommonCards().streamUniqueCards(); if ("BasicLand".equals(landType)) { - final Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND); - cards = Lists.newArrayList(Iterables.filter(cards, cpp)); + cardStream = cardStream.filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND)); } // current color of source card final ColorSet color = source.getColor(); @@ -47,8 +46,8 @@ public void resolve(final SpellAbility sa) { } } - final Predicate cp = x -> landNames.contains(x.getName()); - cards = Lists.newArrayList(Iterables.filter(cards, cp)); + cardStream = cardStream.filter(x -> landNames.contains(x.getName())); + List cards = cardStream.collect(Collectors.toList()); // get a random basic land Card random; // if activator cannot play the random land, loop diff --git a/forge-game/src/main/java/forge/game/card/Card.java b/forge-game/src/main/java/forge/game/card/Card.java index 95dbf2cd41f..895cbc5cde6 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -3371,9 +3371,7 @@ public void updateSpellAbilities(List list, CardState state, Boole if (ck.isRemoveNonMana()) { // List only has nonMana if (null == mana) { - List toRemove = Lists.newArrayList( - Iterables.filter(list, SpellAbilityPredicates.isManaAbility().negate())); - list.removeAll(toRemove); + list.removeIf(SpellAbilityPredicates.isManaAbility().negate()); } else if (false == mana) { list.clear(); } diff --git a/forge-game/src/main/java/forge/game/card/CardCollection.java b/forge-game/src/main/java/forge/game/card/CardCollection.java index a5dbd4c4bca..684cde8e2ca 100644 --- a/forge-game/src/main/java/forge/game/card/CardCollection.java +++ b/forge-game/src/main/java/forge/game/card/CardCollection.java @@ -2,6 +2,8 @@ import forge.util.collect.FCollection; +import java.util.function.Predicate; + public class CardCollection extends FCollection implements CardCollectionView { private static final long serialVersionUID = -8133537013727100275L; @@ -123,6 +125,16 @@ public CardCollection subList(final int fromIndex, final int toIndex) { return new CardCollection(super.subList(fromIndex, toIndex)); } + /** + * Creates a new CardCollection containing the elements from this collection which match + * the given predicate. + */ + public CardCollection filter(Predicate test) { + CardCollection out = new CardCollection(); + this.stream().filter(test).forEach(out::add); + return out; + } + /** * An unmodifiable, empty {@link CardCollection}. */ diff --git a/forge-game/src/main/java/forge/game/card/CardDamageMap.java b/forge-game/src/main/java/forge/game/card/CardDamageMap.java index 00e86fad8d7..e4b190da9ed 100644 --- a/forge-game/src/main/java/forge/game/card/CardDamageMap.java +++ b/forge-game/src/main/java/forge/game/card/CardDamageMap.java @@ -6,11 +6,11 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.stream.Collectors; import com.google.common.collect.ForwardingTable; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import com.google.common.collect.Table; import forge.game.CardTraitBase; @@ -23,7 +23,6 @@ import forge.game.player.PlayerCollection; import forge.game.spellability.SpellAbility; import forge.game.trigger.TriggerType; -import forge.util.Iterables; public class CardDamageMap extends ForwardingTable { private Table dataMap = HashBasedTable.create(); @@ -193,10 +192,10 @@ public CardDamageMap filteredMap(String validSource, String validTarget, Card ho Set filteredSource = null; Set filteredTarget = null; if (validSource != null) { - filteredSource = Sets.newHashSet(Iterables.filter(rowKeySet(), GameObjectPredicates.restriction(validSource.split(","), host.getController(), host, sa))); + filteredSource = rowKeySet().stream().filter(GameObjectPredicates.restriction(validSource.split(","), host.getController(), host, sa)).collect(Collectors.toSet()); } if (validTarget != null) { - filteredTarget = Sets.newHashSet(Iterables.filter(columnKeySet(), GameObjectPredicates.restriction(validTarget.split(","), host.getController(), host, sa))); + filteredTarget = columnKeySet().stream().filter(GameObjectPredicates.restriction(validTarget.split(","), host.getController(), host, sa)).collect(Collectors.toSet()); } for (Table.Cell c : cellSet()) { diff --git a/forge-game/src/main/java/forge/game/card/CardUtil.java b/forge-game/src/main/java/forge/game/card/CardUtil.java index b91f1d70660..0b542956b48 100644 --- a/forge-game/src/main/java/forge/game/card/CardUtil.java +++ b/forge-game/src/main/java/forge/game/card/CardUtil.java @@ -19,6 +19,7 @@ import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; @@ -39,7 +40,6 @@ import forge.game.spellability.SpellAbilityPredicates; import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.TextUtil; import forge.util.collect.FCollection; @@ -142,7 +142,9 @@ public static List getLastTurnCast(final String valid, final Card src, fin } public static List getThisTurnActivated(final String valid, final Card src, final CardTraitBase ctb, final Player controller) { - return Lists.newArrayList(Iterables.filter(src.getGame().getStack().getAbilityActivatedThisTurn(), SpellAbilityPredicates.isValid(valid.split(","), controller, src, ctb))); + return src.getGame().getStack().getAbilityActivatedThisTurn().stream() + .filter(SpellAbilityPredicates.isValid(valid.split(","), controller, src, ctb)) + .collect(Collectors.toList()); } public static List getCastSinceBeginningOfYourLastTurn(final String valid, final Card src, final CardTraitBase ctb, final Player controller) { diff --git a/forge-game/src/main/java/forge/game/card/TokenCreateTable.java b/forge-game/src/main/java/forge/game/card/TokenCreateTable.java index c138a398346..e4f4b04b51b 100644 --- a/forge-game/src/main/java/forge/game/card/TokenCreateTable.java +++ b/forge-game/src/main/java/forge/game/card/TokenCreateTable.java @@ -2,13 +2,14 @@ import java.util.List; import java.util.Map; +import java.util.function.Predicate; +import java.util.stream.Collectors; -import forge.util.Iterables; +import forge.game.GameObject; import org.apache.commons.lang3.ObjectUtils; import com.google.common.collect.ForwardingTable; import com.google.common.collect.HashBasedTable; -import com.google.common.collect.Lists; import com.google.common.collect.Table; import forge.game.CardTraitBase; @@ -48,8 +49,8 @@ public int getFilterAmount(String validOwner, String validToken, final CardTrait } if (validOwner != null) { - filteredPlayer = Lists.newArrayList(Iterables.filter(rowKeySet(), - GameObjectPredicates.restriction(validOwner.split(","), host.getController(), host, ctb))); + Predicate restriction = GameObjectPredicates.restriction(validOwner.split(","), host.getController(), host, ctb); + filteredPlayer = rowKeySet().stream().filter(restriction).collect(Collectors.toList()); if (filteredPlayer.isEmpty()) { return 0; } diff --git a/forge-game/src/main/java/forge/game/combat/CombatUtil.java b/forge-game/src/main/java/forge/game/combat/CombatUtil.java index 2c8d1fc26e7..77cc98d5179 100644 --- a/forge-game/src/main/java/forge/game/combat/CombatUtil.java +++ b/forge-game/src/main/java/forge/game/combat/CombatUtil.java @@ -48,7 +48,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.function.Predicate; /** *

diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java index 3858120d826..6dc9828d3ab 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java @@ -34,6 +34,7 @@ import org.apache.commons.lang3.StringUtils; import java.util.*; +import java.util.function.Predicate; /** *

@@ -385,7 +386,8 @@ public final boolean areMet(final SpellAbility sa) { } } - final int left = Iterables.size(Iterables.filter(list, GameObjectPredicates.restriction(getIsPresent().split(","), activator, host, sa))); + Predicate restriction = GameObjectPredicates.restriction(getIsPresent().split(","), activator, host, sa); + final int left = (int) list.stream().filter(restriction).count(); final String rightString = this.getPresentCompare().substring(2); int right = AbilityUtils.calculateAmount(host, rightString, sa); @@ -416,7 +418,8 @@ public final boolean areMet(final SpellAbility sa) { } } - final int left = Iterables.size(Iterables.filter(list, GameObjectPredicates.restriction(getIsPresent2().split(","), activator, host, sa))); + Predicate restriction = GameObjectPredicates.restriction(getIsPresent2().split(","), activator, host, sa); + final int left = (int) list.stream().filter(restriction).count(); final String rightString = this.getPresentCompare2().substring(2); int right = AbilityUtils.calculateAmount(host, rightString, sa); diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java index 9660aaa66aa..f0cae61de69 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java @@ -38,7 +38,6 @@ import forge.game.zone.Zone; import forge.game.zone.ZoneType; import forge.util.Expressions; -import forge.util.Iterables; import forge.util.collect.FCollection; /** @@ -468,7 +467,8 @@ public final boolean checkOtherRestrictions(final Card c, final SpellAbility sa, list = new FCollection<>(game.getCardsIn(getPresentZone())); } - final int left = Iterables.size(Iterables.filter(list, GameObjectPredicates.restriction(getIsPresent().split(","), activator, c, sa))); + Predicate restriction = GameObjectPredicates.restriction(getIsPresent().split(","), activator, c, sa); + final int left = (int) list.stream().filter(restriction).count(); final String rightString = this.getPresentCompare().substring(2); int right = AbilityUtils.calculateAmount(c, rightString, sa); diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java b/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java index bb2f9c48e86..d86382aa9b7 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java @@ -102,7 +102,7 @@ public final void clearPlayerDefinedDelayedTrigger() { public final void handlePlayerDefinedDelTriggers(final Player player) { final List playerTriggers = playerDefinedDelayedTriggers.removeAll(player); - Iterables.filter(playerTriggers, CardTraitPredicates.hasParam("ThisTurn")).forEach(thisTurnDelayedTriggers::add); + playerTriggers.stream().filter(CardTraitPredicates.hasParam("ThisTurn")).forEach(thisTurnDelayedTriggers::add); delayedTriggers.addAll(playerTriggers); } diff --git a/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java b/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java index 5831a95215b..b8a0852fb92 100644 --- a/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java +++ b/forge-gui-desktop/src/main/java/forge/gui/ImportSourceAnalyzer.java @@ -24,8 +24,8 @@ import java.util.TreeMap; import java.util.function.Predicate; +import forge.card.CardDb; import forge.item.PaperCardPredicates; -import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; @@ -356,15 +356,15 @@ boolean onDir(final File dir) { // set card pics // - private static void addSetCards(final Map cardFileNames, final Iterable library, final Predicate filter) { - for (final PaperCard c : Iterables.filter(library, filter)) { + private static void addSetCards(final Map cardFileNames, final CardDb library, final Predicate filter) { + library.streamAllCards().filter(filter).forEach(c -> { String filename = c.getCardImageKey() + ".jpg"; cardFileNames.put(filename, filename); if (c.hasBackFace()) { filename = c.getCardAltImageKey() + ".jpg"; cardFileNames.put(filename, filename); } - } + }); } Map> cardFileNamesBySet; @@ -375,8 +375,8 @@ private void analyzeCardPicsSetDir(final File root) { for (final CardEdition ce : FModel.getMagicDb().getEditions()) { final Map cardFileNames = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); final Predicate filter = PaperCardPredicates.printedInSet(ce.getCode()); - addSetCards(cardFileNames, FModel.getMagicDb().getCommonCards().getAllCards(), filter); - addSetCards(cardFileNames, FModel.getMagicDb().getVariantCards().getAllCards(), filter); + addSetCards(cardFileNames, FModel.getMagicDb().getCommonCards(), filter); + addSetCards(cardFileNames, FModel.getMagicDb().getVariantCards(), filter); cardFileNamesBySet.put(ce.getCode2(), cardFileNames); } @@ -384,14 +384,14 @@ private void analyzeCardPicsSetDir(final File root) { nameUpdates = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); final Predicate predPlanes = arg0 -> arg0.getRules().getType().isPlane() || arg0.getRules().getType().isPhenomenon(); - for (final PaperCard c : Iterables.filter(FModel.getMagicDb().getVariantCards().getAllCards(), predPlanes)) { + FModel.getMagicDb().getVariantCards().streamAllCards().filter(predPlanes).forEach(c -> { String baseName = c.getCardImageKey(); nameUpdates.put(baseName + ".full.jpg", baseName + ".jpg"); if (c.hasBackFace()) { baseName = c.getCardAltImageKey(); nameUpdates.put(baseName + ".full.jpg", baseName + ".jpg"); } - } + }); } final CardEdition.Collection editions = FModel.getMagicDb().getEditions(); diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/CardManager.java b/forge-gui-desktop/src/main/java/forge/itemmanager/CardManager.java index 1b3f3100eb8..78e4b86a5df 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/CardManager.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/CardManager.java @@ -16,12 +16,13 @@ import forge.screens.home.quest.DialogChooseFormats; import forge.screens.home.quest.DialogChooseSets; import forge.screens.match.controllers.CDetailPicture; -import forge.util.Iterables; import forge.util.Localizer; import javax.swing.*; import java.util.*; import java.util.Map.Entry; +import java.util.function.Predicate; +import java.util.stream.Collectors; /** * ItemManager for cards @@ -76,7 +77,8 @@ protected Iterable> getUnique(Iterable acceptedEditions = Lists.newArrayList(Iterables.filter(entriesByEdition.keySet(), ed -> StaticData.instance().getCardArtPreference().accept(ed))); + Predicate editionPredicate = ed -> StaticData.instance().getCardArtPreference().accept(ed); + List acceptedEditions = entriesByEdition.keySet().stream().filter(editionPredicate).collect(Collectors.toList()); // If policy too strict, fall back to getting all editions. if (acceptedEditions.size() == 0) diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java b/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java index 79c0b3fc5a9..cd29558f492 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java @@ -1007,7 +1007,7 @@ public void updateView(final boolean forceFilter, final Iterable itemsToSelec this.model.addItems(items); } else if (useFilter) { - final Predicate> pred = x -> this.filterPredicate.test(x.getKey());; + final Predicate> pred = x -> this.filterPredicate.test(x.getKey()); this.model.addItems(Iterables.filter(this.pool, pred)); } else if (this.wantUnique) { diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java index 8dfef11ac4a..fd0b1411a02 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestCommanderGeneraterGA.java @@ -3,8 +3,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; - -import com.google.common.collect.Lists; +import java.util.stream.Collectors; import forge.GuiDesktop; import forge.StaticData; @@ -24,7 +23,6 @@ import forge.localinstance.properties.ForgeConstants; import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; -import forge.util.Iterables; public class PlanarConquestCommanderGeneraterGA extends PlanarConquestGeneraterGA { @@ -75,14 +73,14 @@ protected void initializeCards(){ cards.add(StaticData.instance().getCommonCards().getUniqueByName(cardName)); } - Iterable filtered= Iterables.filter(cards, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS + List filteredList = cards.stream() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS .and(CardRulesPredicates.IS_PLANESWALKER) //.and(CardRulesPredicates.IS_LEGENDARY) - ).and(gameFormat.getFilterPrinted()) - ); + )) + .filter(gameFormat.getFilterPrinted()) + .collect(Collectors.toList()); - List filteredList = Lists.newArrayList(filtered); rankedList = CardRanker.rankCardsInDeck(filteredList); List decks = new ArrayList<>(); for(PaperCard card: rankedList.subList(0,cardsToUse)){ diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java index 1a452f70acf..43dd1acc27d 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestGeneraterGA.java @@ -4,13 +4,12 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import forge.item.PaperCardPredicates; import forge.util.*; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.collect.Lists; - import forge.GuiDesktop; import forge.LobbyPlayer; import forge.StaticData; @@ -106,13 +105,12 @@ protected void initializeCards(){ cards.add(StaticData.instance().getCommonCards().getUniqueByName(cardName)); } - Iterable filtered= Iterables.filter(cards, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS - .and(CardRulesPredicates.IS_NON_LAND) - ).and(gameFormat.getFilterPrinted()) - ); + List filteredList = cards.stream() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS + .and(CardRulesPredicates.IS_NON_LAND))) + .filter(gameFormat.getFilterPrinted()) + .collect(Collectors.toList()); - List filteredList = Lists.newArrayList(filtered); setRankedList(CardRanker.rankCardsInDeck(filteredList)); List decks = new ArrayList<>(); for(PaperCard card: getRankedList().subList(0,cardsToUse)){ diff --git a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java index c49fece3438..efb4c9e26b7 100644 --- a/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java +++ b/forge-gui-desktop/src/test/java/forge/planarconquestgenerate/PlanarConquestTribalGeneraterGA.java @@ -3,8 +3,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; - -import com.google.common.collect.Lists; +import java.util.stream.Collectors; import forge.GuiDesktop; import forge.StaticData; @@ -23,7 +22,6 @@ import forge.localinstance.properties.ForgeConstants; import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; -import forge.util.Iterables; public class PlanarConquestTribalGeneraterGA extends PlanarConquestGeneraterGA { @@ -77,14 +75,13 @@ protected void initializeCards(){ cards.add(StaticData.instance().getCommonCards().getUniqueByName(cardName)); } - Iterable filteredTribe= Iterables.filter(cards, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS + List filteredListTribe = cards.stream() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS .and(CardRulesPredicates.hasCreatureType("Pirate")) - .and(CardRulesPredicates.IS_CREATURE) - ).and(gameFormat.getFilterPrinted()) - ); + .and(CardRulesPredicates.IS_CREATURE))) + .filter(gameFormat.getFilterPrinted()) + .collect(Collectors.toList()); - List filteredListTribe = Lists.newArrayList(filteredTribe); rankedList = CardRanker.rankCardsInDeck(filteredListTribe); List decks = new ArrayList<>(); for(PaperCard card: rankedList.subList(0,cardsToUse)){ diff --git a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java index dfd2eabe7d0..1afb48d1b44 100644 --- a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java +++ b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java @@ -2,7 +2,6 @@ import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.utils.Json; -import com.google.common.collect.Lists; import forge.StaticData; import forge.adventure.data.ConfigData; import forge.adventure.data.GeneratedDeckData; @@ -27,6 +26,7 @@ import java.util.*; import java.util.function.Predicate; import java.util.regex.Pattern; +import java.util.stream.Collectors; import static forge.adventure.data.RewardData.generateAllCards; @@ -804,15 +804,22 @@ public static Deck generateRandomBoosterPackAsDeck(final Predicate } public static PaperCard getCardByName(String cardName) { - List validCards = Lists.newArrayList(Iterables.filter(getFullCardPool(Config.instance().getSettingData().useAllCardVariants), - input -> input.getCardName().equals(cardName))); + List validCards; + //Faster to ask the CardDB for a card name than it is to search the pool. + if (Config.instance().getSettingData().useAllCardVariants) + validCards = FModel.getMagicDb().getCommonCards().getAllCards(cardName); + else + validCards = FModel.getMagicDb().getCommonCards().getUniqueCardsNoAlt(cardName); return validCards.get(Current.world().getRandom().nextInt(validCards.size())); } public static PaperCard getCardByNameAndEdition(String cardName, String edition) { - List validCards = Lists.newArrayList(Iterables.filter(getFullCardPool(Config.instance().getSettingData().useAllCardVariants), - input -> input.getCardName().equals(cardName) && input.getEdition().equals(edition))); + List cardPool = Config.instance().getSettingData().useAllCardVariants + ? FModel.getMagicDb().getCommonCards().getAllCards(cardName) + : FModel.getMagicDb().getCommonCards().getUniqueCardsNoAlt(cardName); + List validCards = cardPool.stream() + .filter(input -> input.getEdition().equals(edition)).collect(Collectors.toList()); if (validCards.isEmpty()) { System.err.println("Unexpected behavior: tried to call getCardByNameAndEdition for card " + cardName + " from the edition " + edition + ", but didn't find it in the DB. A random existing instance will be returned."); diff --git a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java index 06ee1d63bfb..57b7bb0e324 100644 --- a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java @@ -9,13 +9,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import forge.item.PaperCardPredicates; -import forge.util.Iterables; import org.apache.commons.lang3.ArrayUtils; -import com.google.common.collect.Lists; - import forge.card.CardRulesPredicates; import forge.deck.io.CardThemedMatrixIO; import forge.deck.io.DeckStorage; @@ -73,9 +71,9 @@ public static HashMap>> initializeForma ForgeConstants.DECK_GEN_DIR, false), true); - final Iterable cards = Iterables.filter(format.getAllCards(), - PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)); - List cardList = Lists.newArrayList(cards); + List cardList = format.getAllCards().stream() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)) + .collect(Collectors.toList()); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); Map integerCardMap = new HashMap<>(); @@ -88,18 +86,19 @@ public static HashMap>> initializeForma for (PaperCard card:cardList){ for (Deck deck:decks){ - if (deck.getMain().contains(card)){ - for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(), - PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND))){ - if (!pairCard.getName().equals(card.getName())){ + if (deck.getMain().contains(card)) { + String cardName = card.getName(); + deck.getMain().toFlatList().stream() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)) + .filter(pairCard -> !pairCard.getName().equals(cardName)) + .forEach(pairCard -> { try { - int old = matrix[cardIntegerMap.get(card.getName())][cardIntegerMap.get(pairCard.getName())]; - matrix[cardIntegerMap.get(card.getName())][cardIntegerMap.get(pairCard.getName())] = old + 1; - }catch (NullPointerException ne){ + int old = matrix[cardIntegerMap.get(cardName)][cardIntegerMap.get(pairCard.getName())]; + matrix[cardIntegerMap.get(cardName)][cardIntegerMap.get(pairCard.getName())] = old + 1; + } catch (NullPointerException ne) { //Todo: Not sure what was failing here } - } - } + }); } } } @@ -142,9 +141,9 @@ public static HashMap>> initializeComma true); //get all cards - final Iterable cards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards(), - PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)); - List cardList = Lists.newArrayList(cards); + List cardList = FModel.getMagicDb().getCommonCards().streamUniqueCards() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)) + .collect(Collectors.toList()); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); Map integerCardMap = new HashMap<>(); @@ -157,7 +156,7 @@ public static HashMap>> initializeComma } //filter to just legal commanders - List legends = Lists.newArrayList(Iterables.filter(cardList, format.isLegalCommanderPredicate())); + List legends = cardList.stream().filter(format.isLegalCommanderPredicate()).collect(Collectors.toList()); //generate lookups for legends to link commander names to matrix rows for (int i=0; i>> initializeComma //update the matrix by incrementing the connectivity count for each card in the deck public static void updateLegendMatrix(Deck deck, PaperCard legend, Map cardIntegerMap, Map legendIntegerMap, int[][] matrix){ - for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(), - PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND))){ - if (!pairCard.getName().equals(legend.getName())){ + String cardName = legend.getName(); + deck.getMain().toFlatList().stream() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)) + .filter(pairCard -> !pairCard.getName().equals(cardName)) + .forEach(pairCard -> { try { - int old = matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(pairCard.getName())]; - matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(pairCard.getName())] = old + 1; - }catch (NullPointerException ne){ + int old = matrix[legendIntegerMap.get(cardName)][cardIntegerMap.get(pairCard.getName())]; + matrix[legendIntegerMap.get(cardName)][cardIntegerMap.get(pairCard.getName())] = old + 1; + } catch (NullPointerException ne) { //Todo: Not sure what was failing here ne.printStackTrace(); } - } - - } + }); //add partner commanders to matrix if(deck.getCommanders().size()>1){ for(PaperCard partner:deck.getCommanders()){ if(!partner.equals(legend)){ - int old = matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(partner.getName())]; - matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(partner.getName())] = old + 1; + int old = matrix[legendIntegerMap.get(cardName)][cardIntegerMap.get(partner.getName())]; + matrix[legendIntegerMap.get(cardName)][cardIntegerMap.get(partner.getName())] = old + 1; } } } diff --git a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java index faa53cdbcf2..2a53a6d0ae8 100644 --- a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java @@ -1,9 +1,10 @@ package forge.deck; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.function.Predicate; +import java.util.stream.Collectors; import forge.card.CardEdition; import forge.card.CardRules; @@ -13,7 +14,6 @@ import forge.item.PaperCardPredicates; import forge.model.FModel; import forge.util.ItemPool; -import forge.util.Iterables; /** * Created by maustin on 09/05/2017. @@ -23,11 +23,11 @@ public static List getCommanderDecks(final DeckFormat format, boolean if (format.equals(DeckFormat.Brawl)){ return getBrawlDecks(format, isForAi, isCardGen); } - ItemPool uniqueCards; + ItemPool uniqueCards; if (isCardGen){ uniqueCards = new ItemPool<>(PaperCard.class); String matrixKey = (format.equals(DeckFormat.TinyLeaders) ? DeckFormat.Commander : format).toString(); //use Commander for Tiny Leaders - HashMap matrixPool = CardRelationMatrixGenerator.cardPools.get(matrixKey); + HashMap>> matrixPool = CardRelationMatrixGenerator.cardPools.get(matrixKey); if (matrixPool != null) { Iterable legendNames = matrixPool.keySet(); for (String legendName : legendNames) { @@ -39,18 +39,15 @@ public static List getCommanderDecks(final DeckFormat format, boolean uniqueCards = ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getUniqueCards(), PaperCard.class); } Predicate canPlay = isForAi ? DeckGeneratorBase.AI_CAN_PLAY : CardRulesPredicates.IS_KEPT_IN_RANDOM_DECKS; - @SuppressWarnings("unchecked") - Iterable legends = Iterables.filter(uniqueCards.toFlatList(), format.isLegalCommanderPredicate() - .and(PaperCardPredicates.fromRules(canPlay))); - final List decks = new ArrayList<>(); - for (PaperCard legend: legends) { - decks.add(new CommanderDeckGenerator(legend, format, isForAi, isCardGen)); - } - return decks; + return uniqueCards.toFlatList().stream() + .filter(format.isLegalCommanderPredicate()) + .filter(PaperCardPredicates.fromRules(canPlay)) + .map(legend -> new CommanderDeckGenerator(legend, format, isForAi, isCardGen)) + .collect(Collectors.toList()); } public static List getBrawlDecks(final DeckFormat format, boolean isForAi, boolean isCardGen){ - ItemPool uniqueCards; + ItemPool uniqueCards; if (isCardGen){ uniqueCards = new ItemPool<>(PaperCard.class); //TODO: update to actual Brawl model from real Brawl decks @@ -63,14 +60,11 @@ public static List getBrawlDecks(final DeckFormat format, boolean isF uniqueCards = ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getUniqueCards(), PaperCard.class); } Predicate canPlay = isForAi ? DeckGeneratorBase.AI_CAN_PLAY : CardRulesPredicates.IS_KEPT_IN_RANDOM_DECKS; - @SuppressWarnings("unchecked") - Iterable legends = Iterables.filter(uniqueCards.toFlatList(), format.isLegalCardPredicate() - .and(PaperCardPredicates.fromRules(CardRulesPredicates.CAN_BE_BRAWL_COMMANDER.and(canPlay)))); - final List decks = new ArrayList<>(); - for (PaperCard legend: legends) { - decks.add(new CommanderDeckGenerator(legend, format, isForAi, isCardGen)); - } - return decks; + return uniqueCards.toFlatList().stream() + .filter(format.isLegalCardPredicate()) + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.CAN_BE_BRAWL_COMMANDER.and(canPlay))) + .map(legend -> new CommanderDeckGenerator(legend, format, isForAi, isCardGen)) + .collect(Collectors.toList()); } private final PaperCard legend; diff --git a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java index 39e9e6e47b0..0b43529be0b 100644 --- a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java +++ b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java @@ -841,7 +841,7 @@ public static Map suggestBasicLandCount(Deck d) { // determine how many additional lands we need, but don't take lands already in deck into consideration, // or we risk incorrectly determining the target deck size - int numLands = Iterables.size(Iterables.filter(cards, PaperCardPredicates.fromRules(CardRulesPredicates.IS_LAND))); + int numLands = (int) cards.stream().filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_LAND)).count(); int sizeNoLands = cards.size() - numLands; // attempt to determine if building for sealed, constructed or EDH diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java index 33242ff86b1..c410df4f374 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedCommanderDeckBuilder.java @@ -1,6 +1,7 @@ package forge.gamemodes.limited; import java.util.List; +import java.util.stream.Collectors; import com.google.common.collect.Lists; @@ -11,7 +12,6 @@ import forge.item.PaperCard; import forge.item.PaperCardPredicates; import forge.model.FModel; -import forge.util.Iterables; /** * Created by maustin on 28/02/2018. @@ -25,9 +25,9 @@ public CardThemedCommanderDeckBuilder(PaperCard commanderCard0, PaperCard partne secondKeyCard = partner0; // remove Unplayables if(isForAI) { - final Iterable playables = Iterables.filter(availableList, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS)); - this.aiPlayables = Lists.newArrayList(playables); + this.aiPlayables = availableList.stream() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS)) + .collect(Collectors.toList()); }else{ this.aiPlayables = Lists.newArrayList(availableList); } diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java index 214d68ab8b3..1b4cf443bc9 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java @@ -1,6 +1,7 @@ package forge.gamemodes.limited; import java.util.List; +import java.util.stream.Collectors; import com.google.common.collect.Lists; @@ -29,9 +30,9 @@ public CardThemedConquestDeckBuilder(PaperCard commanderCard0, final List playables = Iterables.filter(availableList, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS)); - this.aiPlayables = Lists.newArrayList(playables); + this.aiPlayables = availableList.stream() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS)) + .collect(Collectors.toList()); }else{ this.aiPlayables = Lists.newArrayList(availableList); } diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java index 64bbf3e007d..ae3349ec1d5 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java @@ -9,6 +9,7 @@ import java.util.Map; import java.util.Set; import java.util.function.Predicate; +import java.util.stream.Collectors; import com.google.common.collect.Lists; @@ -104,9 +105,9 @@ public CardThemedDeckBuilder(PaperCard keyCard0, PaperCard secondKeyCard0, final this.isForAI = isForAI; // remove Unplayables if(isForAI) { - final Iterable playables = Iterables.filter(availableList, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS)); - this.aiPlayables = Lists.newArrayList(playables); + this.aiPlayables = availableList.stream() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_DECKS)) + .collect(Collectors.toList()); }else{ this.aiPlayables = Lists.newArrayList(availableList); } @@ -188,9 +189,9 @@ public Deck buildDeck() { System.out.println(keyCard.getName()); System.out.println("Colors: " + colors.toEnumSet().toString()); } - Iterable colorList = Iterables.filter(aiPlayables, - PaperCardPredicates.fromRules(hasColor)); - rankedColorList = Lists.newArrayList(colorList); + rankedColorList = aiPlayables.stream() + .filter(PaperCardPredicates.fromRules(hasColor)) + .collect(Collectors.toList()); onColorCreaturesAndSpells = Iterables.filter(rankedColorList, PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE .or(CardRulesPredicates.IS_NON_CREATURE_SPELL))); @@ -318,11 +319,11 @@ public Deck buildDeck() { //Add remaining non-land colour matching cards to sideboard final CardPool cp = result.getOrCreate(DeckSection.Sideboard); - Iterable potentialSideboard = Iterables.filter(aiPlayables, - PaperCardPredicates.fromRules(hasColor.and(CardRulesPredicates.IS_NON_LAND))); + Iterator potentialSideboard = aiPlayables.stream() + .filter(PaperCardPredicates.fromRules(hasColor.and(CardRulesPredicates.IS_NON_LAND))).iterator(); int i=0; - while(i<15 && potentialSideboard.iterator().hasNext()){ - PaperCard sbCard = potentialSideboard.iterator().next(); + while(i<15 && potentialSideboard.hasNext()){ + PaperCard sbCard = potentialSideboard.next(); cp.add(sbCard); aiPlayables.remove(sbCard); rankedColorList.remove(sbCard); @@ -398,8 +399,9 @@ protected void addKeyCards(){ } // Add the second keycard if not land if(secondKeyCard!=null && !secondKeyCard.getRules().getMainPart().getType().isLand()) { - Iterable secondKeyCards = Iterables.filter(aiPlayables, PaperCardPredicates.name(secondKeyCard.getName())); - final List keyCardList = Lists.newArrayList(secondKeyCards); + final List keyCardList = aiPlayables.stream() + .filter(PaperCardPredicates.name(secondKeyCard.getName())) + .collect(Collectors.toList()); deckList.addAll(keyCardList); aiPlayables.removeAll(keyCardList); rankedColorList.removeAll(keyCardList); @@ -418,8 +420,9 @@ protected void addLandKeyCards(){ } // Add the deck card if(secondKeyCard!=null && secondKeyCard.getRules().getMainPart().getType().isLand()) { - Iterable secondKeyCards = Iterables.filter(aiPlayables, PaperCardPredicates.name(secondKeyCard.getName())); - final List keyCardList = Lists.newArrayList(secondKeyCards); + final List keyCardList = aiPlayables.stream() + .filter(PaperCardPredicates.name(secondKeyCard.getName())) + .collect(Collectors.toList()); deckList.addAll(keyCardList); aiPlayables.removeAll(keyCardList); rankedColorList.removeAll(keyCardList); @@ -444,7 +447,7 @@ public boolean test(CardRules subject) { * If evolving wilds is in the deck and there are fewer than 4 spaces for basic lands - remove evolving wilds */ protected void checkEvolvingWilds(){ - List evolvingWilds = Lists.newArrayList(Iterables.filter(deckList, PaperCardPredicates.name("Evolving Wilds"))); + List evolvingWilds = deckList.stream().filter(PaperCardPredicates.name("Evolving Wilds")).collect(Collectors.toList()); if((evolvingWilds.size()>0 && landsNeeded<4 ) || colors.countColors()<2){ deckList.removeAll(evolvingWilds); landsNeeded=landsNeeded+evolvingWilds.size(); @@ -497,9 +500,9 @@ protected void addThirdColorCards(int num) { } protected void addLowCMCCard(){ - final Iterable nonLands = Iterables.filter(rankedColorList, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_LAND)); - final PaperCard card = Iterables.getFirst(nonLands, null); + final PaperCard card = rankedColorList.stream() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_LAND)) + .findFirst().orElse(null); if (card != null) { deckList.add(card); aiPlayables.remove(card); @@ -665,17 +668,10 @@ protected void findBasicLandSets() { * counts of lands needed, by color */ private void addLands(final int[] clrCnts) { - // basic lands that are available in the deck - final Iterable basicLands = Iterables.filter(aiPlayables, PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND)); - // total of all ClrCnts int totalColor = 0; - int numColors = 0; for (int i = 0; i < 5; i++) { totalColor += clrCnts[i]; - if (clrCnts[i] > 0) { - numColors++; - } } // add one of each land required first so that any rounding errors do not remove the only land of a colour for (int i = 0; i < 5; i++) { @@ -821,9 +817,6 @@ private void addNonBasicLands() { minBasics=Math.round((MyRandom.getRandom().nextInt(8)+6)*((float) targetSize) / 60); } - lands = Iterables.filter(aiPlayables, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_NONBASIC_LAND)); - for (final PaperCard card : lands) { if (landsNeeded > minBasics) { // Use only lands that are within our colors @@ -922,16 +915,10 @@ private void addManaCurveCards(final Iterable creatures, int num, Str for (int i = 1; i < 7; i++) { creatureCosts.put(i, 0); } - final Predicate filter = PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE); - for (final IPaperCard creature : Iterables.filter(deckList, filter)) { - int cmc = creature.getRules().getManaCost().getCMC(); - if (cmc < 1) { - cmc = 1; - } else if (cmc > 6) { - cmc = 6; - } - creatureCosts.put(cmc, creatureCosts.get(cmc) + 1); - } + deckList.stream().filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE)) + .mapToInt(c -> c.getRules().getManaCost().getCMC()) + .map(cmc -> Math.min(Math.max(cmc, 1), 6)) + .forEach(cmc -> creatureCosts.put(cmc, creatureCosts.get(cmc) + 1)); List creaturesToAdd = new ArrayList<>(); for (final PaperCard card : creatures) { diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java index 9e2e09d4fc0..9959ce4fdfb 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java @@ -2,6 +2,7 @@ import java.util.*; import java.util.function.Predicate; +import java.util.stream.Collectors; import com.google.common.collect.Lists; @@ -76,15 +77,15 @@ public LimitedDeckBuilder(final List dList, final DeckColors pClrs) { this.colors = pClrs.getChosenColors(); // remove Unplayables - final Iterable playables = Iterables.filter(availableList, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_LIMITED_DECKS)); - this.aiPlayables = Lists.newArrayList(playables); + this.aiPlayables = availableList.stream() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_KEPT_IN_AI_LIMITED_DECKS)) + .collect(Collectors.toList()); this.availableList.removeAll(aiPlayables); // keep Conspiracies in a separate list - final Iterable conspiracies = Iterables.filter(aiPlayables, - PaperCardPredicates.fromRules(CardRulesPredicates.coreType(true, "Conspiracy"))); - this.draftedConspiracies = Lists.newArrayList(conspiracies); + this.draftedConspiracies = aiPlayables.stream() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.coreType(true, "Conspiracy"))) + .collect(Collectors.toList()); this.aiPlayables.removeAll(draftedConspiracies); findBasicLandSets(); @@ -164,9 +165,9 @@ public Deck buildDeck(final String landSetCode) { // 6. If there are still on-color cards, and the average cmc is low, add // an extra. if (deckList.size() == numSpellsNeeded && getAverageCMC(deckList) < 4) { - final Iterable nonLands = Iterables.filter(rankedColorList, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_LAND)); - final PaperCard card = Iterables.getFirst(nonLands, null); + final PaperCard card = rankedColorList.stream() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_LAND)) + .findFirst().orElse(null); if (card != null) { deckList.add(card); aiPlayables.remove(card); @@ -665,15 +666,10 @@ private void addManaCurveCreatures(final Iterable creatures, int num) creatureCosts.put(i, 0); } final Predicate filter = PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE); - for (final IPaperCard creature : Iterables.filter(deckList, filter)) { - int cmc = creature.getRules().getManaCost().getCMC(); - if (cmc < 1) { - cmc = 1; - } else if (cmc > 6) { - cmc = 6; - } - creatureCosts.put(cmc, creatureCosts.get(cmc) + 1); - } + deckList.stream().filter(filter) + .mapToInt(creature -> creature.getRules().getManaCost().getCMC()) + .map(cmc -> Math.max(1, Math.min(cmc, 6))) + .forEach(cmc -> creatureCosts.put(cmc, creatureCosts.get(cmc) + 1)); List creaturesToAdd = new ArrayList<>(); for (final PaperCard card : creatures) { diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayer.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayer.java index 3043e2ff9df..bac699548a2 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayer.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayer.java @@ -14,6 +14,7 @@ import forge.util.TextUtil; import java.util.*; +import java.util.stream.Collectors; public class LimitedPlayer { // A Player class for inside some type of limited environment, like Draft. @@ -731,7 +732,9 @@ public PaperCard pickFromArchdemonCurse(DraftPack chooseFrom) { public void addSingleBoosterPack() { // if this is just a normal draft, allow picking a pack from any set // If this is adventure or quest or whatever then we should limit it to something - List possibleEditions = Lists.newArrayList(Iterables.filter(FModel.getMagicDb().getEditions(), CardEdition.Predicates.CAN_MAKE_BOOSTER)); + List possibleEditions = FModel.getMagicDb().getEditions().stream() + .filter(CardEdition.Predicates.CAN_MAKE_BOOSTER) + .collect(Collectors.toList()); CardEdition edition = chooseEdition(possibleEditions); if (edition == null) { addLog(name() + " chose not to add a booster pack to the draft."); diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java b/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java index ec0439ce7b2..89b7470cdba 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java @@ -10,7 +10,6 @@ import forge.deck.Deck; import forge.item.PaperCard; import forge.item.PaperCardPredicates; -import forge.util.Iterables; import forge.util.MyRandom; public class WinstonDraft extends BoosterDraft { @@ -41,9 +40,9 @@ private void initializeWinstonDraft() { for (final Supplier> supply : this.product) { for (int j = 0; j < NUM_PLAYERS; j++) { // Remove Basic Lands from draft for simplicity - for (final PaperCard paperCard : Iterables.filter(supply.get(), PaperCardPredicates.IS_BASIC_LAND.negate())) { - this.deck.add(paperCard); - } + supply.get().stream() + .filter(PaperCardPredicates.IS_BASIC_LAND.negate()) + .forEach(this.deck::add); } } Collections.shuffle(this.deck, MyRandom.getRandom()); diff --git a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java index 881255a3316..195a6bdbe8d 100644 --- a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java +++ b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java @@ -156,7 +156,7 @@ public static CardPool getAvailablePool(Deck deck) { if (colorIdentity != MagicColor.ALL_COLORS) { Predicate pred = DeckFormat.Commander.isLegalCardForCommanderPredicate(deck.getCommanders()); - availableCards.retainAll(Lists.newArrayList(Iterables.filter(availableCards, pred))); + availableCards.removeIf(pred.negate()); } //create pool from available cards diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java index 6968cbaa095..9612e1c249a 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java @@ -21,14 +21,13 @@ import java.util.*; import java.util.function.Predicate; +import java.util.stream.Collectors; import forge.item.*; import forge.util.Iterables; import forge.util.Predicates; import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.Lists; - import forge.card.CardEdition; import forge.card.CardRules; import forge.card.CardRulesPredicates; @@ -121,7 +120,7 @@ public static List getQuestStarterDeck(final GameFormat formatStartin filter = formatStartingPool.getFilterPrinted(); } - final List cardPool = Lists.newArrayList(Iterables.filter(FModel.getMagicDb().getCommonCards().getAllNonPromoCards(), filter)); + final List cardPool = FModel.getMagicDb().getCommonCards().streamAllNonPromoCards().filter(filter).collect(Collectors.toList()); if (userPrefs != null && userPrefs.grantCompleteSet()) { for (PaperCard card : cardPool) { @@ -304,7 +303,7 @@ private static void populateBalancedFilters(final List> col Predicate predicateRules = CardRulesPredicates.cost(StringOp.CONTAINS_IC, "p/"); Predicate predicateCard = PaperCardPredicates.fromRules(predicateRules); - int size = Iterables.size(Iterables.filter(cardPool, predicateCard)); + int size = (int) cardPool.stream().filter(predicateCard).count(); int totalSize = cardPool.size(); double phyrexianAmount = (double) size / totalSize; @@ -326,7 +325,7 @@ private static void populateBalancedFilters(final List> col //Adjust for the number of multicolored possibilities. This prevents flooding of non-selected //colors if multicolored cards aren't in the selected sets. The more multi-colored cards in the //sets, the more that will be selected. - if (usedMulticolor / 8 < Iterables.size(Iterables.filter(cardPool, predicateCard))) { + if (usedMulticolor / 8 < cardPool.stream().filter(predicateCard).count()) { colorFilters.add(predicateRules); usedMulticolor++; } else { @@ -490,7 +489,7 @@ private static List parseReward(final String s) { PrintSheet ps = new PrintSheet("Quest rewards"); Predicate predicate = preds.size() == 1 ? preds.get(0) : Predicates.and(preds); - ps.addAll(Iterables.filter(FModel.getMagicDb().getCommonCards().getAllNonPromoCards(), predicate)); + FModel.getMagicDb().getCommonCards().streamAllNonPromoCards().filter(predicate).forEach(ps::add); rewards.addAll(ps.random(qty, true)); } else if (temp.length == 2 && temp[0].equalsIgnoreCase("duplicate") && temp[1].equalsIgnoreCase("card")) { // Type 2: a duplicate card of the players choice diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardChooser.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardChooser.java index 29cb0ff13b1..f194ea29cf8 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardChooser.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardChooser.java @@ -9,7 +9,6 @@ import forge.item.PaperCard; import forge.model.FModel; import forge.util.ItemPool; -import forge.util.Iterables; /** * Resolves a card chooser InventoryItem into a CardPrinted. @@ -109,10 +108,8 @@ public final List getChoices() { } else if (type == poolType.predicateFilter) { List cardChoices = new ArrayList<>(); - for (final PaperCard card : Iterables.filter(FModel.getMagicDb().getCommonCards().getAllCards(), predicates)) { - cardChoices.add(card); - } - Collections.sort(cardChoices); + FModel.getMagicDb().getCommonCards().streamAllCards().filter(predicates) + .sorted().forEach(cardChoices::add); //TODO: Once java is at 10+, can use Collectors.toUnmodifiableList return Collections.unmodifiableList(cardChoices); } else { diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardFiltered.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardFiltered.java index d14fe24078f..7e69b107121 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardFiltered.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestRewardCardFiltered.java @@ -7,7 +7,6 @@ import forge.item.PaperCard; import forge.model.FModel; -import forge.util.Iterables; /** * Allows the player to choose a card from a predicate-filtered list of cards. @@ -60,10 +59,8 @@ public String getItemType() { @Override public final List getChoices() { List cardChoices = new ArrayList<>(); - for (final PaperCard card : Iterables.filter(FModel.getMagicDb().getCommonCards().getAllCards(), predicates)) { - cardChoices.add(card); - } - Collections.sort(cardChoices); + FModel.getMagicDb().getCommonCards().streamAllCards().filter(predicates) + .sorted().forEach(cardChoices::add); //TODO: Once java is at 10+, can use Collectors.toUnmodifiableList return Collections.unmodifiableList(cardChoices); } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java index f948eb26b79..5881ea1cd2b 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java @@ -47,6 +47,7 @@ import java.util.Map.Entry; import java.util.function.Function; import java.util.function.Predicate; +import java.util.stream.Collectors; /** * This is a helper class to execute operations on QuestData. It has been @@ -111,10 +112,10 @@ public static ItemPool generateBasicLands(final int nBasic, final int wastesCodes.add("OGW"); } } else { - Iterable allEditions = FModel.getMagicDb().getEditions(); - for (CardEdition edition : Iterables.filter(allEditions, CardEdition.Predicates.hasBasicLands)) { - landCodes.add(edition.getCode()); - } + FModel.getMagicDb().getEditions().stream() + .filter(CardEdition.Predicates.hasBasicLands) + .map(CardEdition::getCode) + .forEach(landCodes::add); snowLandCodes.add("ICE"); snowLandCodes.add("CSP"); snowLandCodes.add("KHM"); @@ -667,12 +668,9 @@ private void generateBoosterBoxesInShop(final int count) { if (questController.getFormat() != null) { formatFilter = formatFilter.and(isLegalInQuestFormat(questController.getFormat())); } - Iterable rightEditions = Iterables.filter(FModel.getMagicDb().getEditions(), formatFilter); - List editions = new ArrayList<>(); - for (CardEdition e : rightEditions) { - editions.add(e); - } + List editions = FModel.getMagicDb().getEditions().stream() + .filter(formatFilter).collect(Collectors.toList()); Collections.shuffle(editions); diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index 50d47dce45e..bb039b17b85 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -1805,16 +1805,12 @@ private byte chooseColorCommon(final String message, final Card c, final ColorSe @Override public ICardFace chooseSingleCardFace(final SpellAbility sa, final String message, final Predicate cpp, final String name) { - final Iterable cardsFromDb = FModel.getMagicDb().getCommonCards().getAllFaces(); - final List cards = Lists.newArrayList(Iterables.filter(cardsFromDb, cpp)); - CardFaceView cardFaceView; - List choices = new ArrayList<>(); - for (ICardFace cardFace : cards) { - cardFaceView = new CardFaceView(CardTranslation.getTranslatedName(cardFace.getName()), cardFace.getName()); - choices.add(cardFaceView); - } - Collections.sort(choices); - cardFaceView = getGui().one(message, choices); + List choices = FModel.getMagicDb().getCommonCards().streamAllFaces() + .filter(cpp) + .map(cardFace -> new CardFaceView(CardTranslation.getTranslatedName(cardFace.getName()), cardFace.getName())) + .sorted() + .collect(Collectors.toList()); + CardFaceView cardFaceView = getGui().one(message, choices); return StaticData.instance().getCommonCards().getFaceByName(cardFaceView.getOracleName()); } diff --git a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java index 070f476b399..c6a1dee9ecf 100644 --- a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java +++ b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java @@ -1,7 +1,5 @@ package forge.lda; -import com.google.common.collect.Lists; - import forge.GuiDesktop; import forge.StaticData; import forge.card.CardRulesPredicates; @@ -19,7 +17,6 @@ import forge.localinstance.properties.ForgeConstants; import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; -import forge.util.Iterables; import forge.util.storage.IStorage; import forge.util.storage.StorageImmediatelySerialized; import org.apache.commons.lang3.ArrayUtils; @@ -27,6 +24,7 @@ import java.io.File; import java.util.*; +import java.util.stream.Collectors; import static forge.lda.lda.inference.InferenceMethod.CGS; @@ -290,9 +288,9 @@ public static HashMap>> initializeComma true); //get all cards - final Iterable cards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards(), - PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)); - List cardList = Lists.newArrayList(cards); + List cardList = FModel.getMagicDb().getCommonCards().streamUniqueCards() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)) + .collect(Collectors.toList()); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); Map integerCardMap = new HashMap<>(); @@ -305,9 +303,9 @@ public static HashMap>> initializeComma } //filter to just legal commanders - List legends = Lists.newArrayList(Iterables.filter(cardList, PaperCardPredicates.fromRules( - DeckFormat.Commander::isLegalCommander)) - ); + List legends = cardList.stream() + .filter(PaperCardPredicates.fromRules(DeckFormat.Commander::isLegalCommander)) + .collect(Collectors.toList()); //generate lookups for legends to link commander names to matrix rows for (int i=0; i>> initializeComma //update the matrix by incrementing the connectivity count for each card in the deck public static void updateLegendMatrix(Deck deck, PaperCard legend, Map cardIntegerMap, Map legendIntegerMap, int[][] matrix){ - for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(), - PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND))){ - if (!pairCard.getName().equals(legend.getName())){ + String cardName = legend.getName(); + deck.getMain().toFlatList().stream() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)) + .filter(PaperCardPredicates.name(cardName).negate()) + .forEach(pairCard -> { try { - int old = matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(pairCard.getName())]; - matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(pairCard.getName())] = old + 1; + int old = matrix[legendIntegerMap.get(cardName)][cardIntegerMap.get(pairCard.getName())]; + matrix[legendIntegerMap.get(cardName)][cardIntegerMap.get(pairCard.getName())] = old + 1; }catch (NullPointerException ne){ //TODO: Not sure what was failing here ne.printStackTrace(); } - } - - } + }); //add partner commanders to matrix if(deck.getCommanders().size()>1){ for(PaperCard partner:deck.getCommanders()){ if(!partner.equals(legend)){ - int old = matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(partner.getName())]; - matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(partner.getName())] = old + 1; + int old = matrix[legendIntegerMap.get(cardName)][cardIntegerMap.get(partner.getName())]; + matrix[legendIntegerMap.get(cardName)][cardIntegerMap.get(partner.getName())] = old + 1; } } } From 1644e7427e98d9f15bdd25e158f97dc80981576f Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 15 Sep 2024 17:33:18 -0400 Subject: [PATCH 38/68] Guava migration - Replace select usages of `Iterables.transform` --- .../src/main/java/forge/util/Iterables.java | 24 ------------------- .../gamemodes/quest/QuestUtilUnlockSets.java | 12 ++++++---- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index a0d1e9b9911..22328230401 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -1,7 +1,6 @@ package forge.util; import java.util.Collection; -import java.util.List; import java.util.Optional; import java.util.function.Function; import java.util.function.Predicate; @@ -59,33 +58,10 @@ public static int indexOf(Iterable iterable, Predicate predica } public static Iterable transform(final Iterable iterable, final Function function) { - //TODO: Collection input variant. Some usages use Lists.newArrayList on output which could be made part of the stream. //Should probably also be ? extends T in the function type return () -> StreamSupport.stream(iterable.spliterator(), false).map(function).iterator(); } - //TODO: Inline everything below. - - - public static int size(Collection collection) { - return collection.size(); - } - - public static boolean contains(Collection collection, Object element) { - return collection.contains(element); - } - - public static T getFirst(List iterable, T defaultValue) { - return iterable.isEmpty() ? defaultValue : iterable.get(0); - } - - public static T getLast(List iterable) { - return iterable.get(iterable.size() - 1); - } - public static T getLast(List iterable, T defaultValue) { - return iterable.isEmpty() ? defaultValue : iterable.get(iterable.size() - 1); - } - //TODO: Restore everything below public static Iterable unmodifiableIterable(final Iterable iterable) { return com.google.common.collect.Iterables.unmodifiableIterable(iterable); diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java index 7a72efbf537..116a5670f8e 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java @@ -35,6 +35,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair; import java.util.*; +import java.util.stream.Collectors; /** * This is a helper class for unlocking new sets during a format-limited @@ -136,14 +137,17 @@ private static List getUnlockableEditions(final QuestController qDa throw new RuntimeException("BUG? Could not find unlockable sets even though we should."); } List options = new ArrayList<>(); + CardEdition.Collection editions = FModel.getMagicDb().getEditions(); // Sort current sets by date - List allowedSets = Lists.newArrayList(Iterables.transform(qData.getFormat().getAllowedSetCodes(), FModel.getMagicDb().getEditions()::get)); - Collections.sort(allowedSets); + List allowedSets = qData.getFormat().getAllowedSetCodes().stream() + .map(editions::get) + .sorted().collect(Collectors.toList()); // Sort unlockable sets by date - List excludedSets = Lists.newArrayList(Iterables.transform(qData.getFormat().getLockedSets(), FModel.getMagicDb().getEditions()::get)); - Collections.sort(excludedSets); + List excludedSets = qData.getFormat().getLockedSets().stream() + .map(editions::get) + .sorted().collect(Collectors.toList()); // get a number of sets between an excluded and any included set List> excludedWithDistances = new ArrayList<>(); From ae251372c191bf7e7404f58ed5934be359f4d1e0 Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 15 Sep 2024 18:18:27 -0400 Subject: [PATCH 39/68] Guava migration - Cleanup --- forge-game/src/main/java/forge/game/card/CardProperty.java | 2 +- .../java/forge/gamemodes/quest/QuestChallengeGenerator.java | 6 ++++++ .../java/forge/gamemodes/quest/QuestUtilUnlockSets.java | 2 -- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/forge-game/src/main/java/forge/game/card/CardProperty.java b/forge-game/src/main/java/forge/game/card/CardProperty.java index d314c85fbbd..415df5d3264 100644 --- a/forge-game/src/main/java/forge/game/card/CardProperty.java +++ b/forge-game/src/main/java/forge/game/card/CardProperty.java @@ -671,7 +671,7 @@ public static boolean cardHasProperty(Card card, String property, Player sourceC return false; } } else if (property.startsWith("TopLibraryLand")) { - CardCollection cards = CardLists.filter(card.getOwner().getCardsIn(ZoneType.Library), CardPredicates.Presets.LANDS); + CardCollection cards = CardLists.filter(card.getOwner().getCardsIn(ZoneType.Library), CardPredicates.LANDS); if (cards.isEmpty() || !card.equals(cards.get(0))) { return false; } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestChallengeGenerator.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestChallengeGenerator.java index 9c6f3d1cf3a..98a8569faa9 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestChallengeGenerator.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestChallengeGenerator.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Map; import java.util.function.Predicate; +import java.util.stream.Stream; import forge.deck.DeckgenUtil; import forge.game.GameFormat; @@ -217,5 +218,10 @@ public String getName() { public Iterator iterator() { return challenges.values().iterator(); } + + @Override + public Stream stream() { + return challenges.values().stream(); + } } } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java index 116a5670f8e..c5fc3c3a899 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java @@ -18,7 +18,6 @@ package forge.gamemodes.quest; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; import forge.card.CardEdition; import forge.gamemodes.quest.data.QuestPreferences.QPref; import forge.gamemodes.quest.io.ReadPriceList; @@ -29,7 +28,6 @@ import forge.item.SealedTemplate; import forge.item.generation.UnOpenedProduct; import forge.model.FModel; -import forge.util.Iterables; import forge.util.TextUtil; import forge.util.storage.IStorage; import org.apache.commons.lang3.tuple.ImmutablePair; From 7ab333a60a82cba7925a67fa61d430dd1b7a9713 Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 16 Sep 2024 09:10:21 -0400 Subject: [PATCH 40/68] Guava migration - ItemPool collector --- .../src/main/java/forge/util/ItemPool.java | 41 +++++++++++++++---- .../controllers/CEditorVariant.java | 6 +-- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/forge-core/src/main/java/forge/util/ItemPool.java b/forge-core/src/main/java/forge/util/ItemPool.java index b3ab7cdae17..fded45d31ec 100644 --- a/forge-core/src/main/java/forge/util/ItemPool.java +++ b/forge-core/src/main/java/forge/util/ItemPool.java @@ -18,15 +18,11 @@ package forge.util; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Predicate; +import java.util.function.*; +import java.util.stream.Collector; import com.google.common.collect.Maps; import forge.item.InventoryItem; @@ -74,6 +70,37 @@ public static ItemPool Collector> collector(Class cls) { + return new Collector, ItemPool>() { + @Override + public Supplier> supplier() { + return () -> new ItemPool(cls); + } + + @Override + public BiConsumer, InventoryItem> accumulator() { + return (pool, item) -> { + if (cls.isInstance(item)) pool.add(cls.cast(item), 1); + }; + } + + @Override + public BinaryOperator> combiner() { + return (first, second) -> { + first.addAll(second); + return first; + }; + } + + @Override public Function, ItemPool> finisher() { + return Function.identity(); + } + @Override public Set characteristics() { + return EnumSet.of(Characteristics.IDENTITY_FINISH); + } + }; + } + protected ItemPool(final Map items0, final Class cls) { if (items0 != null) { items = items0; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java index 228047427b5..872daa9655c 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java @@ -141,10 +141,10 @@ protected void buildRemoveContextMenu(EditorContextMenuBuilder cmb) { */ @Override public void resetTables() { - Iterable allNT = FModel.getMagicDb().getVariantCards().getAllCards(); - allNT = Iterables.filter(allNT, cardPoolCondition); + ItemPool allNT = FModel.getMagicDb().getVariantCards().streamAllCards() + .filter(cardPoolCondition).collect(ItemPool.collector(PaperCard.class)); - this.getCatalogManager().setPool(ItemPool.createFrom(allNT, PaperCard.class), true); + this.getCatalogManager().setPool(allNT, true); this.getDeckManager().setPool(this.controller.getModel().getOrCreate(this.sectionMode)); } From c91334029abd66b4cbd785d0462b1f268dd2c3b2 Mon Sep 17 00:00:00 2001 From: Jetz Date: Thu, 19 Sep 2024 09:20:02 -0400 Subject: [PATCH 41/68] Guava migration - Refactor edition type checks --- .../src/main/java/forge/card/CardDb.java | 59 +++++++------------ .../src/main/java/forge/card/CardEdition.java | 2 + .../java/forge/item/PaperCardPredicates.java | 1 - .../adventure/scene/SpellSmithScene.java | 2 +- .../gamemodes/limited/ThemedChaosDraft.java | 8 +-- .../planarconquest/ConquestUtil.java | 3 +- .../forge/gamemodes/quest/BoosterUtils.java | 19 +++--- 7 files changed, 38 insertions(+), 56 deletions(-) diff --git a/forge-core/src/main/java/forge/card/CardDb.java b/forge-core/src/main/java/forge/card/CardDb.java index 89c851d5750..900e3df7cd5 100644 --- a/forge-core/src/main/java/forge/card/CardDb.java +++ b/forge-core/src/main/java/forge/card/CardDb.java @@ -76,9 +76,11 @@ public enum CardArtPreference { latestFirst = latestSetFirst; } + private static final EnumSet ALLOWED_SET_TYPES = EnumSet.of(Type.CORE, Type.EXPANSION, Type.REPRINT); + public boolean accept(CardEdition ed) { if (ed == null) return false; - return !filterSets || ed.getType() == Type.CORE || ed.getType() == Type.EXPANSION || ed.getType() == Type.REPRINT; + return !filterSets || ALLOWED_SET_TYPES.contains(ed.getType()); } } @@ -959,54 +961,33 @@ public Stream streamAllCardsNoAlt() { public Stream streamUniqueCardsNoAlt() { return uniqueCardsByName.entrySet().stream().filter(e -> e.getKey().equals(e.getValue().getName())).map(Entry::getValue); } - public Stream streamAllNonPromoCards() { - //TODO: This should probably just be a filter to tack onto streamAllCards - return streamAllCards().filter(paperCard -> { - CardEdition edition = null; - try { - edition = editions.getEditionByCodeOrThrow(paperCard.getEdition()); - } catch (Exception ex) { - return false; - } - return edition != null && edition.getType() != Type.PROMO; - }); - } public Stream streamAllFaces() { return facesByName.values().stream(); } - public Collection getAllNonPromoCards() { - return streamAllNonPromoCards().collect(Collectors.toList()); - } + public static final Predicate EDITION_NON_PROMO = paperCard -> { + String code = paperCard.getEdition(); + CardEdition edition = StaticData.instance().getCardEdition(code); + if(edition == null && code.equals("???")) + return true; + return edition != null && edition.getType() != Type.PROMO; + }; - public Collection getUniqueCardsNoAltNoOnline() { - return streamUniqueCardsNoAlt().filter(paperCard -> { - CardEdition edition = null; - try { - edition = editions.getEditionByCodeOrThrow(paperCard.getEdition()); - if (edition.getType() == Type.ONLINE||edition.getType() == Type.FUNNY) - return false; - } catch (Exception ex) { - return false; - } + public static final Predicate EDITION_NON_REPRINT = paperCard -> { + String code = paperCard.getEdition(); + CardEdition edition = StaticData.instance().getCardEdition(code); + if(edition == null && code.equals("???")) return true; - }).collect(Collectors.toList()); + return edition != null && Type.REPRINT_SET_TYPES.contains(edition.getType()); + }; + + public Collection getAllNonPromoCards() { + return streamAllCards().filter(EDITION_NON_PROMO).collect(Collectors.toList()); } public Collection getAllNonPromosNonReprintsNoAlt() { - //TODO: This should probably also be a stream filter. - return streamAllCardsNoAlt().filter(paperCard -> { - CardEdition edition = null; - try { - edition = editions.getEditionByCodeOrThrow(paperCard.getEdition()); - if (edition.getType() == Type.PROMO || edition.getType() == Type.REPRINT || edition.getType()==Type.COLLECTOR_EDITION) - return false; - } catch (Exception ex) { - return false; - } - return true; - }).collect(Collectors.toList()); + return streamAllCardsNoAlt().filter(EDITION_NON_REPRINT).collect(Collectors.toList()); } public String getName(final String cardName) { diff --git a/forge-core/src/main/java/forge/card/CardEdition.java b/forge-core/src/main/java/forge/card/CardEdition.java index c24c5d0b011..6a2e828e73a 100644 --- a/forge-core/src/main/java/forge/card/CardEdition.java +++ b/forge-core/src/main/java/forge/card/CardEdition.java @@ -76,6 +76,8 @@ public enum Type { OTHER, // FALLBACK CATEGORY CUSTOM_SET; // custom sets + public static final EnumSet REPRINT_SET_TYPES = EnumSet.of(REPRINT, PROMO, COLLECTOR_EDITION); + public String getBoosterBoxDefault() { switch (this) { case CORE: diff --git a/forge-core/src/main/java/forge/item/PaperCardPredicates.java b/forge-core/src/main/java/forge/item/PaperCardPredicates.java index 804864aff7e..3e97bb33ed5 100644 --- a/forge-core/src/main/java/forge/item/PaperCardPredicates.java +++ b/forge-core/src/main/java/forge/item/PaperCardPredicates.java @@ -177,7 +177,6 @@ private PredicateCards(final List operand) { } } - //TODO: Remove public static Predicate fromRules(Predicate cardRulesPredicate) { return paperCard -> cardRulesPredicate.test(paperCard.getRules()); } diff --git a/forge-gui-mobile/src/forge/adventure/scene/SpellSmithScene.java b/forge-gui-mobile/src/forge/adventure/scene/SpellSmithScene.java index fbcebe551ec..203f64fc054 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/SpellSmithScene.java +++ b/forge-gui-mobile/src/forge/adventure/scene/SpellSmithScene.java @@ -141,7 +141,7 @@ public void loadEditions() { editions = StaticData.instance().getSortedEditions().stream().filter(input -> { if (input == null) return false; - if (input.getType() == CardEdition.Type.REPRINT || input.getType() == CardEdition.Type.PROMO || input.getType() == CardEdition.Type.COLLECTOR_EDITION) + if (CardEdition.Type.REPRINT_SET_TYPES.contains(input.getType())) return false; if (input.getDate() != null) { Instant now = Instant.now(); //this should filter upcoming sets from release date + 1 day.. diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/ThemedChaosDraft.java b/forge-gui/src/main/java/forge/gamemodes/limited/ThemedChaosDraft.java index 7747950c8a8..29748a85515 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/ThemedChaosDraft.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/ThemedChaosDraft.java @@ -1,5 +1,6 @@ package forge.gamemodes.limited; +import java.util.EnumSet; import java.util.List; import java.util.function.Predicate; @@ -101,14 +102,13 @@ private Predicate getFormatFilter(String formatName) { return cardEdition -> DEFAULT_FILTER.test(cardEdition) && format.isSetLegal(cardEdition.getCode()); } + private static final EnumSet DEFAULT_FILTER_TYPES = EnumSet.of( + CardEdition.Type.CORE, CardEdition.Type.EXPANSION, CardEdition.Type.REPRINT); /** * Default filter that only allows actual sets that were printed as 15-card boosters */ private static final Predicate DEFAULT_FILTER = cardEdition -> { - boolean isExpansion = cardEdition.getType().equals(CardEdition.Type.EXPANSION); - boolean isCoreSet = cardEdition.getType().equals(CardEdition.Type.CORE); - boolean isReprintSet = cardEdition.getType().equals(CardEdition.Type.REPRINT); - if (isExpansion || isCoreSet || isReprintSet) { + if (DEFAULT_FILTER_TYPES.contains(cardEdition.getType())) { // Only allow sets with 15 cards in booster packs if (cardEdition.hasBoosterTemplate()) { final List> slots = cardEdition.getBoosterTemplate().getSlots(); diff --git a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java index 195a6bdbe8d..00015208733 100644 --- a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java +++ b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java @@ -185,7 +185,8 @@ public static void setPlaneTemporarilyAccessible(String planeName, boolean acces public static Iterable getStartingPlaneswalkerOptions(final PaperCard startingCommander) { final byte colorIdentity = startingCommander.getRules().getColorIdentity().getColor(); - final List selected = Lists.newArrayList(); + final Set selected = Sets.newHashSet(); + //TODO: Could make this more efficient by streaming unique cards and then mapping them to an acceptable print if they aren't already... return Iterables.filter(FModel.getMagicDb().getCommonCards().getAllNonPromosNonReprintsNoAlt(), card -> { if (selected.contains(card.getName())) { return false; diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java index 9612e1c249a..b8462670cf4 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java @@ -23,16 +23,12 @@ import java.util.function.Predicate; import java.util.stream.Collectors; +import forge.card.*; import forge.item.*; import forge.util.Iterables; import forge.util.Predicates; import org.apache.commons.lang3.StringUtils; -import forge.card.CardEdition; -import forge.card.CardRules; -import forge.card.CardRulesPredicates; -import forge.card.MagicColor; -import forge.card.PrintSheet; import forge.game.GameFormat; import forge.gamemodes.quest.data.QuestPreferences.QPref; import forge.model.FModel; @@ -115,12 +111,13 @@ public static List getQuestStarterDeck(final GameFormat formatStartin } - Predicate filter = x -> true; + Predicate filter = CardDb.EDITION_NON_PROMO; if (formatStartingPool != null) { - filter = formatStartingPool.getFilterPrinted(); + filter = filter.and(formatStartingPool.getFilterPrinted()); } - final List cardPool = FModel.getMagicDb().getCommonCards().streamAllNonPromoCards().filter(filter).collect(Collectors.toList()); + final List cardPool = FModel.getMagicDb().getCommonCards().streamAllCards() + .filter(filter).collect(Collectors.toList()); if (userPrefs != null && userPrefs.grantCompleteSet()) { for (PaperCard card : cardPool) { @@ -475,6 +472,7 @@ private static List parseReward(final String s) { List> preds = new ArrayList<>(); preds.add(PaperCardPredicates.IS_RARE_OR_MYTHIC); // Determine rarity + preds.add(CardDb.EDITION_NON_PROMO); if (temp.length > 2) { Predicate cr = parseRulesLimitation(temp[1]); @@ -488,8 +486,9 @@ private static List parseReward(final String s) { } PrintSheet ps = new PrintSheet("Quest rewards"); - Predicate predicate = preds.size() == 1 ? preds.get(0) : Predicates.and(preds); - FModel.getMagicDb().getCommonCards().streamAllNonPromoCards().filter(predicate).forEach(ps::add); + Predicate predicate = Predicates.and(preds); + FModel.getMagicDb().getCommonCards().streamAllCards() + .filter(predicate).forEach(ps::add); rewards.addAll(ps.random(qty, true)); } else if (temp.length == 2 && temp[0].equalsIgnoreCase("duplicate") && temp[1].equalsIgnoreCase("card")) { // Type 2: a duplicate card of the players choice From c2f72bb3c2b4862da42d2a5475245a2187d00987 Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 22 Sep 2024 11:05:19 -0400 Subject: [PATCH 42/68] Guava migration - Stream support for FCollectionView --- .../src/main/java/forge/util/collect/FCollection.java | 7 +++++++ .../src/main/java/forge/util/collect/FCollectionView.java | 3 +++ 2 files changed, 10 insertions(+) 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 844e10a0e67..c2bad40335b 100644 --- a/forge-core/src/main/java/forge/util/collect/FCollection.java +++ b/forge-core/src/main/java/forge/util/collect/FCollection.java @@ -12,6 +12,7 @@ import java.util.NoSuchElementException; import java.util.Set; import java.util.function.Predicate; +import java.util.stream.Stream; import forge.util.Iterables; import org.apache.commons.lang3.ArrayUtils; @@ -550,6 +551,11 @@ public T get(final T obj) { return obj; } + @Override + public Stream stream() { + return list.stream(); + } + @Override public boolean anyMatch(Predicate test) { return set.stream().anyMatch(test); @@ -666,6 +672,7 @@ public final T[] toArray(final T[] a) { return a; } + @Override public Stream stream() {return Stream.empty();} @Override public boolean anyMatch(Predicate test) {return false;} @Override public boolean allMatch(Predicate test) {return true;} diff --git a/forge-core/src/main/java/forge/util/collect/FCollectionView.java b/forge-core/src/main/java/forge/util/collect/FCollectionView.java index c5c89e48e1c..d344950ad27 100644 --- a/forge-core/src/main/java/forge/util/collect/FCollectionView.java +++ b/forge-core/src/main/java/forge/util/collect/FCollectionView.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.NoSuchElementException; import java.util.function.Predicate; +import java.util.stream.Stream; /** * Read-only interface to an {@link FCollection}. @@ -78,6 +79,8 @@ public interface FCollectionView extends Iterable { T get(final T obj); + Stream stream(); + /** * Returns true if any member of this collection matches the given predicate. */ From 05d58c2fce52c329f15e370470a3d415499f07c4 Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 22 Sep 2024 14:47:57 -0400 Subject: [PATCH 43/68] Guava migration - Add `StreamUtils.random` collectors --- .../src/main/java/forge/ai/ComputerUtil.java | 5 +- .../deck/generation/DeckGeneratorBase.java | 6 +- .../main/java/forge/item/SealedProduct.java | 11 +- .../src/main/java/forge/util/StreamUtils.java | 106 ++++++++++++++++++ .../ability/effects/ChooseCardNameEffect.java | 5 +- .../game/ability/effects/PlayEffect.java | 31 ++--- .../deckeditor/controllers/CDeckgen.java | 10 +- .../src/forge/adventure/scene/DuelScene.java | 3 +- .../src/main/java/forge/deck/DeckgenUtil.java | 37 +++--- 9 files changed, 159 insertions(+), 55 deletions(-) create mode 100644 forge-core/src/main/java/forge/util/StreamUtils.java diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index 91317e57a54..70b59bfba78 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -2450,7 +2450,10 @@ public static CardCollection getCardsToDiscardFromOpponent(Player chooser, Playe // not enough good choices, need to fill the rest int minDiff = min - goodChoices.size(); if (minDiff > 0) { - goodChoices.addAll(Aggregates.random(CardLists.filter(validCards, ((Predicate) goodChoices::contains).negate()), minDiff)); + List choices = validCards.stream() + .filter(((Predicate) goodChoices::contains).negate()) + .collect(StreamUtils.random(minDiff)); + goodChoices.addAll(choices); return goodChoices; } diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index 15a056da475..b55a94183ad 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -234,11 +234,11 @@ protected void adjustDeckSize(int targetSize) { addSome(targetSize - actualSize, tDeck.toFlatList()); } else if (actualSize > targetSize) { - Predicate exceptBasicLand = PaperCardPredicates.fromRules(CardRulesPredicates.NOT_BASIC_LAND); for (int i = 0; i < 3 && actualSize > targetSize; i++) { - Iterable matchingCards = Iterables.filter(tDeck.toFlatList(), exceptBasicLand); - List toRemove = Aggregates.random(matchingCards, actualSize - targetSize); + List toRemove = tDeck.toFlatList().stream() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.NOT_BASIC_LAND)) + .collect(StreamUtils.random(actualSize - targetSize)); tDeck.removeAllFlat(toRemove); for (PaperCard c : toRemove) { diff --git a/forge-core/src/main/java/forge/item/SealedProduct.java b/forge-core/src/main/java/forge/item/SealedProduct.java index f2fb3ea7743..9dda5706c71 100644 --- a/forge-core/src/main/java/forge/item/SealedProduct.java +++ b/forge-core/src/main/java/forge/item/SealedProduct.java @@ -21,12 +21,10 @@ import forge.StaticData; import forge.card.CardRulesPredicates; import forge.item.generation.BoosterGenerator; -import forge.util.Aggregates; +import forge.util.StreamUtils; import java.util.ArrayList; import java.util.List; -import java.util.function.Predicate; -import java.util.stream.Collectors; public abstract class SealedProduct implements InventoryItemFromSet { @@ -112,8 +110,9 @@ protected PaperCard getRandomBasicLand(final String setCode) { } protected List getRandomBasicLands(final String setCode, final int count) { - Predicate cardsRule = PaperCardPredicates.printedInSet(setCode) - .and(PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND)); - return Aggregates.random(StaticData.instance().getCommonCards().streamAllCards().filter(cardsRule).collect(Collectors.toList()), count); + return StaticData.instance().getCommonCards().streamAllCards() + .filter(PaperCardPredicates.printedInSet(setCode)) + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND)) + .collect(StreamUtils.random(count)); } } diff --git a/forge-core/src/main/java/forge/util/StreamUtils.java b/forge-core/src/main/java/forge/util/StreamUtils.java new file mode 100644 index 00000000000..f112ba1b3f5 --- /dev/null +++ b/forge-core/src/main/java/forge/util/StreamUtils.java @@ -0,0 +1,106 @@ +package forge.util; + +import java.util.*; +import java.util.function.*; +import java.util.stream.Collector; +import java.util.stream.Stream; + +public class StreamUtils { + + private StreamUtils(){} + + /** + * Reduces a stream to a random element of the stream. Used with {@link Stream#collect}. + * Result will be wrapped in an Optional, absent only if the stream is empty. + */ + public static Collector> random() { + return new RandomCollectorSingle<>(); + } + + /** + * Selects a number of items randomly from this stream. Used with {@link Stream#collect}. + * @param count Number of elements to select from the stream. + */ + public static Collector> random(int count) { + return new RandomCollectorMulti<>(count); + } + + private static abstract class RandomCollector implements Collector, O> { + private final int size; + RandomCollector(int size) { + this.size = size; + } + + @Override + public Supplier> supplier() { + return () -> new RandomReservoir<>(size); + } + + @Override + public BiConsumer, T> accumulator() { + return RandomReservoir::accumulate; + } + + @Override + public BinaryOperator> combiner() { + return (first, second) -> { + //There's probably a way to adapt the Random Reservoir method + //so that two partially processed lists can be combined into one. + //But I have no idea what that is. + throw new UnsupportedOperationException("Parallel streams not supported."); + }; + } + + private final EnumSet CHARACTERISTICS = EnumSet.of(Characteristics.UNORDERED); + @Override + public Set characteristics() { + return CHARACTERISTICS; + } + } + + private static class RandomCollectorSingle extends RandomCollector> { + RandomCollectorSingle() { + super(1); + } + + @Override + public Function, Optional> finisher() { + return (chosen) -> chosen.samples.isEmpty() ? Optional.empty() : Optional.of(chosen.samples.get(0)); + } + } + + private static class RandomCollectorMulti extends RandomCollector> { + RandomCollectorMulti(int size) { + super(size); + } + + @Override + public Function, List> finisher() { + return (chosen) -> chosen.samples; + } + } + + private static class RandomReservoir { + final int maxSize; + ArrayList samples; + int sampleCount = 0; + + public RandomReservoir(int size) { + this.maxSize = size; + this.samples = new ArrayList<>(size); + } + + public void accumulate(T next) { + sampleCount++; + if(sampleCount < maxSize) { + //Add the first [maxSize] items into the result list + samples.add(next); + return; + } + //Progressively reduce odds of adding an item into the reservoir + int j = MyRandom.getRandom().nextInt(sampleCount); + if(j < maxSize) + samples.set(j, next); + } + } +} diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java index f47ef140fd7..866a5e8f8ff 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java @@ -131,8 +131,9 @@ public void resolve(SpellAbility sa) { cpp = CardFacePredicates.valid(valid); } if (randomChoice) { - final Iterable cards = Iterables.filter(StaticData.instance().getCommonCards().getAllFaces(), cpp); - chosen = Aggregates.random(cards).getName(); + chosen = StaticData.instance().getCommonCards().streamAllFaces() + .filter(cpp).collect(StreamUtils.random()).get() + .getName(); } else { chosen = p.getController().chooseCardName(sa, cpp, valid, message); } diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java index 43d9de299b7..790cb14caf3 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java @@ -1,9 +1,9 @@ package forge.game.ability.effects; import java.util.*; -import java.util.function.Predicate; -import java.util.stream.Collectors; +import java.util.stream.Stream; +import forge.card.CardDb; import forge.card.CardStateName; import forge.card.GamePieceType; import forge.item.PaperCardPredicates; @@ -109,25 +109,28 @@ public void resolve(final SpellAbility sa) { } } else if (sa.hasParam("AnySupportedCard")) { final String valid = sa.getParam("AnySupportedCard"); - List cards = null; + Stream cards; + CardDb cardDb = StaticData.instance().getCommonCards(); if (valid.startsWith("Names:")) { - cards = new ArrayList<>(); - for (String name : valid.substring(6).split(",")) { - name = name.replace(";", ","); - cards.add(StaticData.instance().getCommonCards().getUniqueByName(name)); - } + cards = Arrays.stream(valid.substring(6).split(",")) + .map(name -> name.replace(";", ",")) + .map(cardDb::getUniqueByName); } else if (valid.equalsIgnoreCase("sorcery")) { - final Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.IS_SORCERY); - cards = StaticData.instance().getCommonCards().streamUniqueCards().filter(cpp).collect(Collectors.toList()); + cards = cardDb.streamUniqueCards() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_SORCERY)); } else if (valid.equalsIgnoreCase("instant")) { - final Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.IS_INSTANT); - cards = StaticData.instance().getCommonCards().streamUniqueCards().filter(cpp).collect(Collectors.toList()); + cards = cardDb.streamUniqueCards() + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_INSTANT)); + } else { + //Could just return a stream of all cards, but that should probably be a specific option rather than a fallback. + //Could also just leave it null but there's currently nothing else that can happen that case. + throw new UnsupportedOperationException("Unknown parameter for AnySupportedCard: " + valid); } if (sa.hasParam("RandomCopied")) { final CardCollection choice = new CardCollection(); final String num = sa.getParamOrDefault("RandomNum", "1"); - int ncopied = AbilityUtils.calculateAmount(source, num, sa); - for (PaperCard cp : Aggregates.random(cards, ncopied)) { + int nCopied = AbilityUtils.calculateAmount(source, num, sa); + for (PaperCard cp : cards.collect(StreamUtils.random(nCopied))) { final Card possibleCard = Card.fromPaperCard(cp, sa.getActivatingPlayer()); if (sa.getActivatingPlayer().isAI() && possibleCard.getRules() != null && possibleCard.getRules().getAiHints().getRemAIDecks()) continue; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java index fb548eb6aa0..3a3fe4d8c7a 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java @@ -22,9 +22,9 @@ import forge.screens.deckeditor.CDeckEditorUI; import forge.screens.deckeditor.SEditorIO; import forge.screens.deckeditor.views.VDeckgen; -import forge.util.Aggregates; -import forge.util.Iterables; +import forge.util.StreamUtils; +import java.util.List; import java.util.function.Predicate; @@ -71,8 +71,10 @@ private void newRandomCon final Deck randomDeck = new Deck(); final Predicate notBasicLand = PaperCardPredicates.fromRules(CardRulesPredicates.NOT_BASIC_LAND); - final Iterable source = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards(), notBasicLand); - randomDeck.getMain().addAllFlat(Aggregates.random(source, 15 * 5)); + List randomCards = FModel.getMagicDb().getCommonCards().streamUniqueCards() + .filter(notBasicLand) + .collect(StreamUtils.random(15 * 5)); + randomDeck.getMain().addAllFlat(randomCards); for(final String landName : MagicColor.Constant.BASIC_LANDS) { randomDeck.getMain().add(landName, 1); diff --git a/forge-gui-mobile/src/forge/adventure/scene/DuelScene.java b/forge-gui-mobile/src/forge/adventure/scene/DuelScene.java index 6c711650c75..a76767ae64f 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/DuelScene.java +++ b/forge-gui-mobile/src/forge/adventure/scene/DuelScene.java @@ -237,8 +237,7 @@ public void enter() { DeckProxy deckProxy = null; if (chaosBattle) { deckProxyMapMap = DeckProxy.getAllQuestChallenges(); - List decks = new ArrayList<>(deckProxyMapMap.keySet()); - deckProxy = Aggregates.random(decks); + deckProxy = Aggregates.random(deckProxyMapMap.keySet()); //playerextras List playerCards = new ArrayList<>(); for (String s : deckProxyMapMap.get(deckProxy).getLeft()) { diff --git a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java index 0b43529be0b..5e5421a3753 100644 --- a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java +++ b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java @@ -9,6 +9,7 @@ import java.util.Map; import java.util.Set; import java.util.function.Predicate; +import java.util.stream.Collectors; import forge.item.PaperCardPredicates; import forge.util.*; @@ -463,25 +464,18 @@ public static Deck getRandomOrPreconOrThemeDeck(String colors, boolean forAi, bo try { if (useGeneticAI) { if (!selection.isEmpty()) - deck = Aggregates.random(Iterables.filter(geneticAI, deckProxy -> deckProxy.getColorIdentity().sharesColorWith(ColorSet.fromNames(colors.toCharArray())))).getDeck(); + deck = geneticAI.stream() + .filter(deckProxy -> deckProxy.getColorIdentity().sharesColorWith(ColorSet.fromNames(colors.toCharArray()))) + .collect(StreamUtils.random()).get().getDeck(); else deck = Aggregates.random(geneticAI).getDeck(); } else { - Predicate sizePredicate = deckProxy -> deckProxy.getMainSize() <= 60; - if (!selection.isEmpty() && selection.size() < 4) { - Predicate colorPredicate = deckProxy -> deckProxy.getColorIdentity().hasAllColors(ColorSet.fromNames(colors.toCharArray()).getColor()); - Predicate pred = sizePredicate.and(colorPredicate); - if (isTheme) - deck = Aggregates.random(Iterables.filter(advThemes, pred)).getDeck(); - else - deck = Aggregates.random(Iterables.filter(advPrecons, pred)).getDeck(); - } else { - if (isTheme) - deck = Aggregates.random(Iterables.filter(advThemes, sizePredicate)).getDeck(); - else - deck = Aggregates.random(Iterables.filter(advPrecons, sizePredicate)).getDeck(); - } + Predicate predicate = deckProxy -> deckProxy.getMainSize() <= 60; + if (!selection.isEmpty() && selection.size() < 4) + predicate = predicate.and(deckProxy -> deckProxy.getColorIdentity().hasAllColors(ColorSet.fromNames(colors.toCharArray()).getColor())); + List source = isTheme ? advThemes : advPrecons; + deck = source.stream().filter(predicate).collect(StreamUtils.random()).get().getDeck(); } } catch (Exception e) { e.printStackTrace(); @@ -658,18 +652,15 @@ else if (rndPlane.getRules().getType().isPlane()) { /** Generate a 2-5-color Commander deck. */ public static Deck generateCommanderDeck(boolean forAi, GameType gameType) { - final Deck deck; - IDeckGenPool cardDb = FModel.getMagicDb().getCommonCards(); - PaperCard commander; - ColorSet colorID; - // Get random multicolor Legendary creature final DeckFormat format = gameType.getDeckFormat(); Predicate canPlay = forAi ? DeckGeneratorBase.AI_CAN_PLAY : CardRulesPredicates.IS_KEPT_IN_RANDOM_DECKS; - Predicate legal = format.isLegalCardPredicate().and(format.isLegalCommanderPredicate()); - Iterable legends = cardDb.getAllCards(legal.and(PaperCardPredicates.fromRules(canPlay))); - commander = Aggregates.random(legends); + PaperCard commander = FModel.getMagicDb().getCommonCards().streamAllCards() + .filter(format.isLegalCardPredicate()) + .filter(format.isLegalCommanderPredicate()) + .filter(PaperCardPredicates.fromRules(canPlay)) + .collect(StreamUtils.random()).get(); return generateRandomCommanderDeck(commander, format, forAi, false); } From e739dad1ba135a3e34804ce06c2a2b415bf62937 Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 22 Sep 2024 14:48:20 -0400 Subject: [PATCH 44/68] Guava migration - Slim down quest reward logic --- .../forge/gamemodes/quest/QuestUtilCards.java | 173 +++++------------- .../quest/QuestWinLoseController.java | 20 +- 2 files changed, 57 insertions(+), 136 deletions(-) diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java index 5881ea1cd2b..24b76891bcf 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java @@ -19,10 +19,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import forge.card.CardEdition; -import forge.card.CardRarity; -import forge.card.ICardDatabase; -import forge.card.MagicColor; +import forge.card.*; import forge.deck.Deck; import forge.deck.DeckSection; import forge.game.GameFormat; @@ -41,13 +38,13 @@ import org.apache.commons.lang3.tuple.Pair; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map.Entry; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * This is a helper class to execute operations on QuestData. It has been @@ -55,12 +52,6 @@ */ public final class QuestUtilCards { - private static final Predicate COMMON_PREDICATE = PaperCardPredicates.IS_COMMON; - private static final Predicate UNCOMMON_PREDICATE = PaperCardPredicates.IS_UNCOMMON; - private static final Predicate RARE_PREDICATE = PaperCardPredicates.IS_RARE_OR_MYTHIC; - private static final Predicate ONLY_RARE_PREDICATE = PaperCardPredicates.IS_RARE; - private static final Predicate MYTHIC_PREDICATE = PaperCardPredicates.IS_MYTHIC_RARE; - private final QuestController questController; private final QuestPreferences questPreferences; private final QuestAssets questAssets; @@ -212,118 +203,46 @@ public Predicate applyFormatFilter(Predicate source) { } /** - * Adds the random rare. - * - * @return the card printed - */ - public PaperCard addRandomRare() { - final boolean usePromos = questPreferences.getPrefInt(QPref.EXCLUDE_PROMOS_FROM_POOL) == 0; - final Collection pool = usePromos ? FModel.getMagicDb().getCommonCards().getAllCards() - : FModel.getMagicDb().getCommonCards().getAllNonPromoCards(); - - final Predicate myFilter = applyFormatFilter(QuestUtilCards.RARE_PREDICATE); - - final PaperCard card = Aggregates.random(Iterables.filter(pool, myFilter)); - addSingleCard(card, 1); - return card; - } - - /** - * Adds a random common. - * - * @param n the number of cards to add - * @return the list of cards added - */ - public List addRandomCommon(final int n) { - final boolean usePromos = questPreferences.getPrefInt(QPref.EXCLUDE_PROMOS_FROM_POOL) == 0; - final Collection pool = usePromos ? FModel.getMagicDb().getCommonCards().getAllCards() - : FModel.getMagicDb().getCommonCards().getAllNonPromoCards(); - - final Predicate myFilter = applyFormatFilter(QuestUtilCards.COMMON_PREDICATE); - final List newCards = Aggregates.random(Iterables.filter(pool, myFilter), n); - addAllCards(newCards); - return newCards; - } - - /** - * Adds a random uncommon. - * - * @param n the number of cards to add - * @return the list of cards added - */ - public List addRandomUncommon(final int n) { - final boolean usePromos = questPreferences.getPrefInt(QPref.EXCLUDE_PROMOS_FROM_POOL) == 0; - final Collection pool = usePromos ? FModel.getMagicDb().getCommonCards().getAllCards() - : FModel.getMagicDb().getCommonCards().getAllNonPromoCards(); - - final Predicate myFilter = applyFormatFilter(QuestUtilCards.UNCOMMON_PREDICATE); - final List newCards = Aggregates.random(Iterables.filter(pool, myFilter), n); - addAllCards(newCards); - return newCards; - } - - /** - * Adds the random rare. - * - * @param n - * the n - * @return the list + * @return a stream of cards that can be rewarded according to the quest format and preferences. */ - public List addRandomRare(final int n) { - final boolean usePromos = questPreferences.getPrefInt(QPref.EXCLUDE_PROMOS_FROM_POOL) == 0; - final Collection pool = usePromos ? FModel.getMagicDb().getCommonCards().getAllCards() - : FModel.getMagicDb().getCommonCards().getAllNonPromoCards(); - - final Predicate myFilter = applyFormatFilter(QuestUtilCards.RARE_PREDICATE); - - final List newCards = Aggregates.random(Iterables.filter(pool, myFilter), n); - addAllCards(newCards); - return newCards; + private Stream getQuestCardPool() { + Stream pool = FModel.getMagicDb().getCommonCards().streamAllCards(); + if(!(questPreferences.getPrefInt(QPref.EXCLUDE_PROMOS_FROM_POOL) == 0)) + pool = pool.filter(CardDb.EDITION_NON_PROMO); + if(questController.getFormat() != null) + pool = pool.filter(questController.getFormat().getFilterPrinted()); + return pool; } /** * Adds the random rare. * - * @param n - * the n - * @return the list + * @return the card printed */ - public List addRandomRareNotMythic(final int n) { - final boolean usePromos = questPreferences.getPrefInt(QPref.EXCLUDE_PROMOS_FROM_POOL) == 0; - final Collection pool = usePromos ? FModel.getMagicDb().getCommonCards().getAllCards() - : FModel.getMagicDb().getCommonCards().getAllNonPromoCards(); - - final Predicate myFilter = applyFormatFilter(QuestUtilCards.ONLY_RARE_PREDICATE); + public PaperCard addRandomRare() { + Stream pool = getQuestCardPool(); + final PaperCard card = pool + .filter(applyFormatFilter(PaperCardPredicates.IS_RARE_OR_MYTHIC)) + .collect(StreamUtils.random()).get(); - final List newCards = Aggregates.random(Iterables.filter(pool, myFilter), n); - addAllCards(newCards); - return newCards; + addSingleCard(card, 1); + return card; } /** - * Adds the random rare. + * Adds n random cards that match the given predicate (and all other format restrictions) + * to the player card pool. * - * @param n - * the n - * @return the list + * @param n Number of cards to add from the reward pool. + * @param predicate Filter to select possible new cards from. + * @return the list of cards added to the card pool. */ - public List addRandomMythicRare(final int n) { - final boolean usePromos = questPreferences.getPrefInt(QPref.EXCLUDE_PROMOS_FROM_POOL) == 0; - final Collection pool = usePromos ? FModel.getMagicDb().getCommonCards().getAllCards() - : FModel.getMagicDb().getCommonCards().getAllNonPromoCards(); + public List addRandomCards(final int n, Predicate predicate) { + Stream pool = getQuestCardPool(); + final List newCards = pool.filter(predicate).collect(StreamUtils.random(n)); - final Predicate myFilter = applyFormatFilter(QuestUtilCards.MYTHIC_PREDICATE); - - final Iterable cardPool = Iterables.filter(pool, myFilter); - - if (!cardPool.iterator().hasNext()) { - return null; - } - - final List newCards = Aggregates.random(cardPool, n); addAllCards(newCards); return newCards; - } /** @@ -544,6 +463,8 @@ public int getSellPriceLimit() { * @return the predicate */ public static Predicate isLegalInQuestFormat(final GameFormatQuest qFormat) { + if(qFormat == null) + return x -> true; return GameFormatQuest.QPredicates.isLegalInFormatQuest(qFormat); } @@ -635,12 +556,12 @@ private static int getRandomCardFromBooster(final List cards, final P * the count */ private void generateTournamentsInShop(final int count) { - Predicate formatFilter = CardEdition.Predicates.HAS_TOURNAMENT_PACK; - if (questController.getFormat() != null) { - formatFilter = formatFilter.and(isLegalInQuestFormat(questController.getFormat())); - } - Iterable rightEditions = Iterables.filter(FModel.getMagicDb().getEditions(), formatFilter); - questAssets.getShopList().addAllOfTypeFlat(Aggregates.random(Iterables.transform(rightEditions, TournamentPack::fromSet), count)); + List packs = FModel.getMagicDb().getEditions().stream() + .filter(CardEdition.Predicates.HAS_TOURNAMENT_PACK) + .filter(isLegalInQuestFormat(questController.getFormat())) + .map(TournamentPack::fromSet) + .collect(StreamUtils.random(count)); + questAssets.getShopList().addAllOfTypeFlat(packs); } /** @@ -650,12 +571,12 @@ private void generateTournamentsInShop(final int count) { * the count */ private void generateFatPacksInShop(final int count) { - Predicate formatFilter = CardEdition.Predicates.HAS_FAT_PACK; - if (questController.getFormat() != null) { - formatFilter = formatFilter.and(isLegalInQuestFormat(questController.getFormat())); - } - Iterable rightEditions = Iterables.filter(FModel.getMagicDb().getEditions(), formatFilter); - questAssets.getShopList().addAllOfTypeFlat(Aggregates.random(Iterables.transform(rightEditions, FatPack::fromSet), count)); + List packs = FModel.getMagicDb().getEditions().stream() + .filter(CardEdition.Predicates.HAS_FAT_PACK) + .filter(isLegalInQuestFormat(questController.getFormat())) + .map(FatPack::fromSet) + .collect(StreamUtils.random(count)); + questAssets.getShopList().addAllOfTypeFlat(packs); } private void generateBoosterBoxesInShop(final int count) { @@ -698,14 +619,14 @@ private void generateBoosterBoxesInShop(final int count) { * the count */ private void generatePreconsInShop(final int count) { - final List meetRequirements = new ArrayList<>(); - for (final PreconDeck deck : QuestController.getPrecons()) { - if (QuestController.getPreconDeals(deck).meetsRequiremnts(questController.getAchievements()) - && (null == questController.getFormat() || questController.getFormat().isSetLegal(deck.getEdition()))) { - meetRequirements.add(deck); - } + Predicate formatFilter = deck -> QuestController.getPreconDeals(deck).meetsRequiremnts(questController.getAchievements()); + if (questController.getFormat() != null) { + formatFilter = formatFilter.and(deck -> questController.getFormat().isSetLegal(deck.getEdition())); } - questAssets.getShopList().addAllOfTypeFlat(Aggregates.random(meetRequirements, count)); + final List decks = QuestController.getPrecons().stream() + .filter(formatFilter) + .collect(StreamUtils.random(count)); + questAssets.getShopList().addAllOfTypeFlat(decks); } @SuppressWarnings("unchecked") diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestWinLoseController.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestWinLoseController.java index f6d448ab988..5ab40dd8a9d 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestWinLoseController.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestWinLoseController.java @@ -425,45 +425,45 @@ private void awardWinStreakBonus() { switch (currentStreak) { case 3: - cardsWon.addAll(qData.getCards().addRandomCommon(1)); + cardsWon.addAll(qData.getCards().addRandomCards(1, PaperCardPredicates.IS_COMMON)); typeWon = "common"; break; case 5: - cardsWon.addAll(qData.getCards().addRandomUncommon(1)); + cardsWon.addAll(qData.getCards().addRandomCards(1, PaperCardPredicates.IS_UNCOMMON)); typeWon = "uncommon"; break; case 7: - cardsWon.addAll(qData.getCards().addRandomRareNotMythic(1)); + cardsWon.addAll(qData.getCards().addRandomCards(1, PaperCardPredicates.IS_RARE)); typeWon = "rare"; break; case 10: - cardsToAdd = qData.getCards().addRandomMythicRare(1); + cardsToAdd = qData.getCards().addRandomCards(1, PaperCardPredicates.IS_MYTHIC_RARE); if (cardsToAdd != null) { cardsWon.addAll(cardsToAdd); typeWon = "mythic rare"; } else { - cardsWon.addAll(qData.getCards().addRandomRareNotMythic(3)); + cardsWon.addAll(qData.getCards().addRandomCards(3, PaperCardPredicates.IS_RARE)); typeWon = "rare"; } break; case 25: - cardsToAdd = qData.getCards().addRandomMythicRare(5); + cardsToAdd = qData.getCards().addRandomCards(5, PaperCardPredicates.IS_MYTHIC_RARE); if (cardsToAdd != null) { cardsWon.addAll(cardsToAdd); typeWon = "mythic rare"; } else { - cardsWon.addAll(qData.getCards().addRandomRareNotMythic(15)); + cardsWon.addAll(qData.getCards().addRandomCards(15, PaperCardPredicates.IS_RARE)); typeWon = "rare"; } addDraftToken = true; break; case 0: //The 50th win in the streak is 0, since (50 % 50 == 0) - cardsToAdd = qData.getCards().addRandomMythicRare(10); + cardsToAdd = qData.getCards().addRandomCards(10, PaperCardPredicates.IS_MYTHIC_RARE); if (cardsToAdd != null) { cardsWon.addAll(cardsToAdd); typeWon = "mythic rare"; } else { - cardsWon.addAll(qData.getCards().addRandomRareNotMythic(30)); + cardsWon.addAll(qData.getCards().addRandomCards(30, PaperCardPredicates.IS_RARE)); typeWon = "rare"; } addDraftToken = true; @@ -490,7 +490,7 @@ private void awardWinStreakBonus() { * */ private void awardJackpot() { - final List cardsWon = qData.getCards().addRandomRare(10); + final List cardsWon = qData.getCards().addRandomCards(10, PaperCardPredicates.IS_RARE_OR_MYTHIC); view.showCards(Localizer.getInstance().getMessage("lblJustWonTenRandomRares"), cardsWon); } From cbcfa8f88453f60f83e2629f48e61a688e86de74 Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 22 Sep 2024 15:56:48 -0400 Subject: [PATCH 45/68] Guava migration - Replace select usages of Aggregates methods --- .../main/java/forge/ai/ComputerUtilCard.java | 34 +++++++++---------- .../java/forge/ai/ability/CountersPutAi.java | 5 ++- .../java/forge/ai/ability/DamageDealAi.java | 6 ++-- .../java/forge/game/ability/AbilityUtils.java | 14 +++++--- .../forge/game/player/PlayerCollection.java | 1 + 5 files changed, 34 insertions(+), 26 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index 3929f8c4702..e302932f00c 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -4,6 +4,7 @@ import java.util.Map.Entry; import java.util.function.Function; import java.util.function.Predicate; +import java.util.stream.Stream; import forge.ai.simulation.GameStateEvaluator; import forge.card.mana.ManaCost; @@ -81,12 +82,11 @@ public static void sortByEvaluateCreature(final CardCollection list) { * @return a {@link forge.game.card.Card} object. */ public static Card getBestArtifactAI(final List list) { - List all = CardLists.filter(list, CardPredicates.ARTIFACTS); - if (all.size() == 0) { - return null; - } // get biggest Artifact - return Aggregates.itemWithMax(all, Card::getCMC); + return list.stream() + .filter(CardPredicates.ARTIFACTS) + .max(Comparator.comparing(Card::getCMC)) + .orElse(null); } /** @@ -96,12 +96,11 @@ public static Card getBestArtifactAI(final List list) { * @return best Planeswalker */ public static Card getBestPlaneswalkerAI(final List list) { - List all = CardLists.filter(list, CardPredicates.PLANESWALKERS); - if (all.isEmpty()) { - return null; - } // no AI logic, just return most expensive - return Aggregates.itemWithMax(all, Card::getCMC); + return list.stream() + .filter(CardPredicates.PLANESWALKERS) + .max(Comparator.comparing(Card::getCMC)) + .orElse(null); } /** @@ -111,12 +110,11 @@ public static Card getBestPlaneswalkerAI(final List list) { * @return best Planeswalker */ public static Card getWorstPlaneswalkerAI(final List list) { - List all = CardLists.filter(list, CardPredicates.PLANESWALKERS); - if (all.isEmpty()) { - return null; - } // no AI logic, just return least expensive - return Aggregates.itemWithMin(all, Card::getCMC); + return list.stream() + .filter(CardPredicates.PLANESWALKERS) + .min(Comparator.comparing(Card::getCMC)) + .orElse(null); } public static Card getBestPlaneswalkerToDamage(final List pws) { @@ -182,13 +180,13 @@ public static Card getWorstPlaneswalkerToDamage(final List pws) { * @return a {@link forge.game.card.Card} object. */ public static Card getBestEnchantmentAI(final List list, final SpellAbility spell, final boolean targeted) { - List all = CardLists.filter(list, CardPredicates.ENCHANTMENTS); + Stream cardStream = list.stream().filter(CardPredicates.ENCHANTMENTS); if (targeted) { - all = CardLists.filter(all, c -> c.canBeTargetedBy(spell)); + cardStream = cardStream.filter(c -> c.canBeTargetedBy(spell)); } // get biggest Enchantment - return Aggregates.itemWithMax(all, Card::getCMC); + return cardStream.max(Comparator.comparing(Card::getCMC)).orElse(null); } /** diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java index 467af4ae521..95d7c5381ba 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java @@ -380,7 +380,10 @@ protected boolean checkApiLogic(Player ai, final SpellAbility sa) { sa.setXManaCostPaid(amount); } else if ("ExiledCreatureFromGraveCMC".equals(logic)) { // e.g. Necropolis - amount = Aggregates.max(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.CREATURES), Card::getCMC); + amount = ai.getCardsIn(ZoneType.Graveyard).stream() + .filter(CardPredicates.CREATURES) + .mapToInt(Card::getCMC) + .max().orElse(0); if (amount > 0 && ai.getGame().getPhaseHandler().is(PhaseType.END_OF_TURN)) { return true; } diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java index d311f927525..a2a0b5416bc 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java @@ -168,8 +168,10 @@ protected boolean canPlayAI(Player ai, SpellAbility sa) { } } else if ("WildHunt".equals(logic)) { // This dummy ability will just deal 0 damage, but holds the logic for the AI for Master of Wild Hunt - List wolves = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), "Creature.Wolf+untapped+YouCtrl+Other", ai, source, sa); - dmg = Aggregates.sum(wolves, Card::getNetPower); + dmg = ai.getCardsIn(ZoneType.Battlefield).stream() + .filter(CardPredicates.restriction("Creature.Wolf+untapped+YouCtrl+Other", ai, source, sa)) + .mapToInt(Card::getNetPower) + .sum(); } else if ("Triskelion".equals(logic)) { final int n = source.getCounters(CounterEnumType.P1P1); if (n > 0) { diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index bac2620b331..e01d70ea0a2 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -2887,14 +2887,18 @@ public static int xCount(Card c, final String s, final CardTraitBase ctb) { // TODO move below to handlePaid if (sq[0].startsWith("SumPower")) { final String[] restrictions = l[0].split("_"); - CardCollection filteredCards = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), restrictions[1], player, c, ctb); - return doXMath(Aggregates.sum(filteredCards, Card::getNetPower), expr, c, ctb); + int sumPower = game.getCardsIn(ZoneType.Battlefield).stream() + .filter(CardPredicates.restriction(restrictions[1], player, c, ctb)) + .mapToInt(Card::getNetPower).sum(); + return doXMath(sumPower, expr, c, ctb); } if (sq[0].startsWith("DifferentPower_")) { final String restriction = l[0].substring(15); - CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), restriction, player, c, ctb); - final Iterable powers = Aggregates.uniqueByLast(list, Card::getNetPower); - return doXMath(Iterables.size(powers), expr, c, ctb); + final int uniquePowers = (int) game.getCardsIn(ZoneType.Battlefield).stream() + .filter(CardPredicates.restriction(restriction, player, c, ctb)) + .map(Card::getNetPower) + .distinct().count(); + return doXMath(uniquePowers, expr, c, ctb); } if (sq[0].startsWith("DifferentCounterKinds_")) { final Set kinds = Sets.newHashSet(); diff --git a/forge-game/src/main/java/forge/game/player/PlayerCollection.java b/forge-game/src/main/java/forge/game/player/PlayerCollection.java index adbd323760d..a7e09370036 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerCollection.java +++ b/forge-game/src/main/java/forge/game/player/PlayerCollection.java @@ -67,6 +67,7 @@ public Player max(Comparator comp) { } // value functions with Function + //TODO: Could probably move these up to FCollectionView, apply them, and trim off a bunch of "Aggregates" clauses. public Integer min(Function func) { return Aggregates.min(this, func); } From d173c22688870cab3be02e78b99a2d0a0f6eb6e8 Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 22 Sep 2024 16:12:04 -0400 Subject: [PATCH 46/68] Fixed some predicate logic issues. --- .../src/main/java/forge/ai/ability/DamageDealAi.java | 3 +-- .../src/main/java/forge/card/CardRulesPredicates.java | 10 ++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java index a2a0b5416bc..2a9a314f415 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java @@ -894,8 +894,7 @@ private boolean damageChooseRequiredTargets(final Player ai, final SpellAbility // See if there's an indestructible target that can be used CardCollection indestructible = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), - CardPredicates.CREATURES - .and(CardPredicates.PLANESWALKERS) //TODO: Should this be "or" Planeswalkers? + (CardPredicates.CREATURES.or(CardPredicates.PLANESWALKERS)) .and(CardPredicates.hasKeyword(Keyword.INDESTRUCTIBLE)) .and(CardPredicates.isTargetableBy(sa)) ); diff --git a/forge-core/src/main/java/forge/card/CardRulesPredicates.java b/forge-core/src/main/java/forge/card/CardRulesPredicates.java index cc31ba35f09..dd8c039ce35 100644 --- a/forge-core/src/main/java/forge/card/CardRulesPredicates.java +++ b/forge-core/src/main/java/forge/card/CardRulesPredicates.java @@ -564,12 +564,10 @@ public boolean test(final CardRules subject) { public static final Predicate IS_INSTANT = CardRulesPredicates.coreType(true, CardType.CoreType.Instant); public static final Predicate IS_SORCERY = CardRulesPredicates.coreType(true, CardType.CoreType.Sorcery); public static final Predicate IS_ENCHANTMENT = CardRulesPredicates.coreType(true, CardType.CoreType.Enchantment); - public static final Predicate IS_NON_CREATURE_SPELL = - CardRulesPredicates.IS_SORCERY - .or(CardRulesPredicates.IS_INSTANT) - .or(CardRulesPredicates.IS_PLANESWALKER) - .or(CardRulesPredicates.IS_ENCHANTMENT) //TODO: Battles? Is testing these one by one really the best way to check "non-creature"? - .or(CardRulesPredicates.IS_ARTIFACT.and(CardRulesPredicates.IS_CREATURE.negate())); + public static final Predicate IS_NON_CREATURE_SPELL = ( + CardRulesPredicates.IS_CREATURE.or(CardRulesPredicates.IS_LAND).or(CardRules::isVariant) + ).negate(); + public static final Predicate IS_PLANE = CardRulesPredicates.coreType(true, CardType.CoreType.Plane); public static final Predicate IS_PHENOMENON = CardRulesPredicates.coreType(true, CardType.CoreType.Phenomenon); public static final Predicate IS_PLANE_OR_PHENOMENON = IS_PLANE.or(IS_PHENOMENON); From cb4c64ce2c0577f7135201c67855ac788b153dd3 Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 22 Sep 2024 16:48:08 -0400 Subject: [PATCH 47/68] Guava migration - Added PaperCard predicates for commonly forwarded CardRules predicates --- .../deck/generation/DeckGeneratorBase.java | 8 ++++---- .../java/forge/item/PaperCardPredicates.java | 14 ++++++++++++- .../main/java/forge/item/SealedProduct.java | 2 +- .../item/generation/BoosterGenerator.java | 6 +++--- .../ability/effects/CopyPermanentEffect.java | 3 +-- .../effects/PlayLandVariantEffect.java | 2 +- .../deckeditor/controllers/CDeckgen.java | 3 +-- .../deckeditor/controllers/CEditorQuest.java | 3 +-- .../deck/CardRelationMatrixGenerator.java | 8 ++++---- .../src/main/java/forge/deck/DeckgenUtil.java | 10 +++++----- .../limited/CardThemedDeckBuilder.java | 14 ++++++------- .../gamemodes/limited/LimitedDeckBuilder.java | 20 +++++++------------ .../forge/gamemodes/limited/WinstonDraft.java | 2 +- .../src/main/java/forge/model/FModel.java | 3 +-- .../java/forge/lda/LDAModelGenetrator.java | 4 ++-- 15 files changed, 51 insertions(+), 51 deletions(-) diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index b55a94183ad..ff9c1e0e3a1 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -87,7 +87,7 @@ protected void addCreaturesAndSpells(int size, List cards = selectCardsOfMatchingColorForPlayer(forAi); // build subsets based on type - final Iterable creatures = Iterables.filter(cards, PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE)); + final Iterable creatures = Iterables.filter(cards, PaperCardPredicates.IS_CREATURE); final int creatCnt = (int) Math.ceil(getCreaturePercentage() * size); trace.append("Creatures to add:").append(creatCnt).append("\n"); addCmcAdjusted(creatures, creatCnt, cmcLevels); @@ -109,9 +109,9 @@ protected boolean setBasicLandPool(String edition){ Predicate isSetBasicLand; if (edition != null){ isSetBasicLand = PaperCardPredicates.printedInSet(edition) - .and(PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND)); + .and(PaperCardPredicates.IS_BASIC_LAND); } else { - isSetBasicLand = PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND); + isSetBasicLand = PaperCardPredicates.IS_BASIC_LAND; } landPool = new DeckGenPool(StaticData.instance().getCommonCards().getAllCards(isSetBasicLand)); @@ -237,7 +237,7 @@ else if (actualSize > targetSize) { for (int i = 0; i < 3 && actualSize > targetSize; i++) { List toRemove = tDeck.toFlatList().stream() - .filter(PaperCardPredicates.fromRules(CardRulesPredicates.NOT_BASIC_LAND)) + .filter(PaperCardPredicates.NOT_BASIC_LAND) .collect(StreamUtils.random(actualSize - targetSize)); tDeck.removeAllFlat(toRemove); diff --git a/forge-core/src/main/java/forge/item/PaperCardPredicates.java b/forge-core/src/main/java/forge/item/PaperCardPredicates.java index 3e97bb33ed5..27cbb584192 100644 --- a/forge-core/src/main/java/forge/item/PaperCardPredicates.java +++ b/forge-core/src/main/java/forge/item/PaperCardPredicates.java @@ -187,7 +187,7 @@ public static Predicate fromRules(Predicate cardRulesPredi public static final Predicate IS_MYTHIC_RARE = PaperCardPredicates.rarity(true, CardRarity.MythicRare); public static final Predicate IS_RARE_OR_MYTHIC = PaperCardPredicates.IS_RARE.or(PaperCardPredicates.IS_MYTHIC_RARE); public static final Predicate IS_SPECIAL = PaperCardPredicates.rarity(true, CardRarity.Special); - public static final Predicate IS_BASIC_LAND = PaperCardPredicates.rarity(true, CardRarity.BasicLand); + public static final Predicate IS_BASIC_LAND_RARITY = PaperCardPredicates.rarity(true, CardRarity.BasicLand); public static final Predicate IS_BLACK = PaperCardPredicates.color(true, false, MagicColor.BLACK); public static final Predicate IS_BLUE = PaperCardPredicates.color(true, false, MagicColor.BLUE); public static final Predicate IS_GREEN = PaperCardPredicates.color(true, false, MagicColor.GREEN); @@ -196,4 +196,16 @@ public static Predicate fromRules(Predicate cardRulesPredi public static final Predicate IS_COLORLESS = PaperCardPredicates.color(true, true, MagicColor.COLORLESS); public static final Predicate IS_UNREBALANCED = PaperCard::isUnRebalanced; public static final Predicate IS_REBALANCED = PaperCard::isRebalanced; + + //Common rules-based predicates. + public static final Predicate IS_LAND = fromRules(CardRulesPredicates.IS_LAND); + public static final Predicate IS_NON_LAND = fromRules(CardRulesPredicates.IS_NON_LAND); + public static final Predicate IS_BASIC_LAND = fromRules(CardRulesPredicates.IS_BASIC_LAND); + /** Matches any card except Plains, Island, Swamp, Mountain, Forest, or Wastes. */ + public static final Predicate NOT_BASIC_LAND = fromRules(CardRulesPredicates.NOT_BASIC_LAND); + /** Matches any card except Plains, Island, Swamp, Mountain, or Forest. */ + public static final Predicate NOT_TRUE_BASIC_LAND = fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND); + public static final Predicate IS_NONBASIC_LAND = fromRules(CardRulesPredicates.IS_NONBASIC_LAND); + public static final Predicate IS_CREATURE = fromRules(CardRulesPredicates.IS_CREATURE); + public static final Predicate CAN_BE_COMMANDER = fromRules(CardRulesPredicates.CAN_BE_COMMANDER); } diff --git a/forge-core/src/main/java/forge/item/SealedProduct.java b/forge-core/src/main/java/forge/item/SealedProduct.java index 9dda5706c71..50ec4d5295e 100644 --- a/forge-core/src/main/java/forge/item/SealedProduct.java +++ b/forge-core/src/main/java/forge/item/SealedProduct.java @@ -112,7 +112,7 @@ protected PaperCard getRandomBasicLand(final String setCode) { protected List getRandomBasicLands(final String setCode, final int count) { return StaticData.instance().getCommonCards().streamAllCards() .filter(PaperCardPredicates.printedInSet(setCode)) - .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND)) + .filter(PaperCardPredicates.IS_BASIC_LAND) .collect(StreamUtils.random(count)); } } diff --git a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java index 0d7f78c7f75..176da6242c1 100644 --- a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java +++ b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java @@ -514,7 +514,7 @@ public static void replaceCard(List booster, PaperCard toAdd) { Predicate rarityPredicate = null; switch (toAdd.getRarity()) { case BasicLand: - rarityPredicate = PaperCardPredicates.IS_BASIC_LAND; + rarityPredicate = PaperCardPredicates.IS_BASIC_LAND_RARITY; break; case Common: rarityPredicate = PaperCardPredicates.IS_COMMON; @@ -678,8 +678,8 @@ private static Predicate buildExtraPredicate(List operators) .or(CardRulesPredicates.splitType(CardSplitType.Meld)) .or(CardRulesPredicates.splitType(CardSplitType.Modal) )); - } else if (operator.equalsIgnoreCase(BoosterSlots.LAND)) { toAdd = PaperCardPredicates.fromRules(CardRulesPredicates.IS_LAND); - } else if (operator.equalsIgnoreCase(BoosterSlots.BASIC_LAND)) { toAdd = PaperCardPredicates.IS_BASIC_LAND; + } else if (operator.equalsIgnoreCase(BoosterSlots.LAND)) { toAdd = PaperCardPredicates.IS_LAND; + } else if (operator.equalsIgnoreCase(BoosterSlots.BASIC_LAND)) { toAdd = PaperCardPredicates.IS_BASIC_LAND_RARITY; } else if (operator.equalsIgnoreCase(BoosterSlots.TIME_SHIFTED)) { toAdd = PaperCardPredicates.IS_SPECIAL; } else if (operator.equalsIgnoreCase(BoosterSlots.SPECIAL)) { toAdd = PaperCardPredicates.IS_SPECIAL; } else if (operator.equalsIgnoreCase(BoosterSlots.MYTHIC)) { toAdd = PaperCardPredicates.IS_MYTHIC_RARE; diff --git a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java index 185f3ffc130..fe95aeb158b 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java @@ -157,8 +157,7 @@ public void resolve(final SpellAbility sa) { "X", Integer.toString(AbilityUtils.calculateAmount(host, "X", sa))); } if (StringUtils.containsIgnoreCase(valid, "creature")) { - Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE); - cards = Iterables.filter(cards, cpp); + cards = Iterables.filter(cards, PaperCardPredicates.IS_CREATURE); } if (StringUtils.containsIgnoreCase(valid, "equipment")) { Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.IS_EQUIPMENT); diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java index e16508b1fd1..c6acb5fde0c 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java @@ -30,7 +30,7 @@ public void resolve(final SpellAbility sa) { final String landType = sa.getParam("Clone"); Stream cardStream = StaticData.instance().getCommonCards().streamUniqueCards(); if ("BasicLand".equals(landType)) { - cardStream = cardStream.filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND)); + cardStream = cardStream.filter(PaperCardPredicates.IS_BASIC_LAND); } // current color of source card final ColorSet color = source.getColor(); diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java index 3a3fe4d8c7a..dfa70acd957 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java @@ -70,9 +70,8 @@ private void newRandomCon final Deck randomDeck = new Deck(); - final Predicate notBasicLand = PaperCardPredicates.fromRules(CardRulesPredicates.NOT_BASIC_LAND); List randomCards = FModel.getMagicDb().getCommonCards().streamUniqueCards() - .filter(notBasicLand) + .filter(PaperCardPredicates.NOT_BASIC_LAND) .collect(StreamUtils.random(15 * 5)); randomDeck.getMain().addAllFlat(randomCards); diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java index fdd45ac3da2..ded7c53ea45 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java @@ -346,8 +346,7 @@ private Deck getDeck(){ } private ItemPool getCommanderCardPool(){ - Predicate commanderPredicate = PaperCardPredicates.fromRules(CardRulesPredicates.CAN_BE_COMMANDER); - return getRemainingCardPool().getFilteredPool(commanderPredicate); + return getRemainingCardPool().getFilteredPool(PaperCardPredicates.CAN_BE_COMMANDER); } @Override diff --git a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java index 57b7bb0e324..c82f09c6cd9 100644 --- a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java @@ -72,7 +72,7 @@ public static HashMap>> initializeForma true); List cardList = format.getAllCards().stream() - .filter(PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)) + .filter(PaperCardPredicates.NOT_TRUE_BASIC_LAND) .collect(Collectors.toList()); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); @@ -89,7 +89,7 @@ public static HashMap>> initializeForma if (deck.getMain().contains(card)) { String cardName = card.getName(); deck.getMain().toFlatList().stream() - .filter(PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)) + .filter(PaperCardPredicates.NOT_TRUE_BASIC_LAND) .filter(pairCard -> !pairCard.getName().equals(cardName)) .forEach(pairCard -> { try { @@ -142,7 +142,7 @@ public static HashMap>> initializeComma //get all cards List cardList = FModel.getMagicDb().getCommonCards().streamUniqueCards() - .filter(PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)) + .filter(PaperCardPredicates.NOT_TRUE_BASIC_LAND) .collect(Collectors.toList()); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); @@ -200,7 +200,7 @@ public static void updateLegendMatrix(Deck deck, PaperCard legend, Map legendIntegerMap, int[][] matrix){ String cardName = legend.getName(); deck.getMain().toFlatList().stream() - .filter(PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)) + .filter(PaperCardPredicates.NOT_TRUE_BASIC_LAND) .filter(pairCard -> !pairCard.getName().equals(cardName)) .forEach(pairCard -> { try { diff --git a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java index 5e5421a3753..ccdbf587d82 100644 --- a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java +++ b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java @@ -216,8 +216,8 @@ public static Deck buildLDACardGenDeck(PaperCard card,GameFormat format, boolean System.out.println("Wrong card count "+deck.getMain().countAll()); deck=buildLDACArchetypeDeck(format,isForAI); } - if(deck.getMain().countAll(PaperCardPredicates.fromRules(CardRulesPredicates.IS_LAND))>27){ - System.out.println("Too many lands "+deck.getMain().countAll(PaperCardPredicates.fromRules(CardRulesPredicates.IS_LAND))); + if(deck.getMain().countAll(PaperCardPredicates.IS_LAND)>27){ + System.out.println("Too many lands "+deck.getMain().countAll(PaperCardPredicates.IS_LAND)); deck=buildLDACArchetypeDeck(format,isForAI); } while(deck.get(DeckSection.Sideboard).countAll()>15){ @@ -315,8 +315,8 @@ public static Deck buildLDACArchetypeDeck(Archetype archetype, GameFormat format System.out.println("Wrong card count "+deck.getMain().countAll()); deck=buildLDACArchetypeDeck(format,isForAI); } - if(deck.getMain().countAll(PaperCardPredicates.fromRules(CardRulesPredicates.IS_LAND))>27){ - System.out.println("Too many lands "+deck.getMain().countAll(PaperCardPredicates.fromRules(CardRulesPredicates.IS_LAND))); + if(deck.getMain().countAll(PaperCardPredicates.IS_LAND)>27){ + System.out.println("Too many lands "+deck.getMain().countAll(PaperCardPredicates.IS_LAND)); deck=buildLDACArchetypeDeck(format,isForAI); } while(deck.get(DeckSection.Sideboard).countAll()>15){ @@ -832,7 +832,7 @@ public static Map suggestBasicLandCount(Deck d) { // determine how many additional lands we need, but don't take lands already in deck into consideration, // or we risk incorrectly determining the target deck size - int numLands = (int) cards.stream().filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_LAND)).count(); + int numLands = (int) cards.stream().filter(PaperCardPredicates.IS_LAND).count(); int sizeNoLands = cards.size() - numLands; // attempt to determine if building for sealed, constructed or EDH diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java index ae3349ec1d5..f3a0745e8d3 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java @@ -463,8 +463,7 @@ protected void checkEvolvingWilds(){ */ protected void addThirdColorCards(int num) { if (num > 0) { - final Iterable others = Iterables.filter(aiPlayables, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_LAND)); + final Iterable others = Iterables.filter(aiPlayables, PaperCardPredicates.IS_NON_LAND); // We haven't yet ranked the off-color cards. // Compare them to the cards already in the deckList. //List rankedOthers = CardRanker.rankCardsInPack(others, deckList, colors, true); @@ -501,7 +500,7 @@ protected void addThirdColorCards(int num) { protected void addLowCMCCard(){ final PaperCard card = rankedColorList.stream() - .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_LAND)) + .filter(PaperCardPredicates.IS_NON_LAND) .findFirst().orElse(null); if (card != null) { deckList.add(card); @@ -524,9 +523,9 @@ protected boolean setBasicLandPool(String edition){ Predicate isSetBasicLand; if (edition !=null){ isSetBasicLand = PaperCardPredicates.printedInSet(edition) - .and(PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND)); + .and(PaperCardPredicates.IS_BASIC_LAND); } else { - isSetBasicLand = PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND); + isSetBasicLand = PaperCardPredicates.IS_BASIC_LAND; } landPool = new DeckGenPool(format.getCardPool(fullCardDB).getAllCards(isSetBasicLand)); @@ -803,8 +802,7 @@ private boolean containsTronLands(Iterable cards){ * Add non-basic lands to the deck. */ private void addNonBasicLands() { - Iterable lands = Iterables.filter(aiPlayables, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_NONBASIC_LAND)); + Iterable lands = Iterables.filter(aiPlayables, PaperCardPredicates.IS_NONBASIC_LAND); List landsToAdd = new ArrayList<>(); int minBasics;//Keep a minimum number of basics to ensure playable decks if(colors.isColorless()) { @@ -915,7 +913,7 @@ private void addManaCurveCards(final Iterable creatures, int num, Str for (int i = 1; i < 7; i++) { creatureCosts.put(i, 0); } - deckList.stream().filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE)) + deckList.stream().filter(PaperCardPredicates.IS_CREATURE) .mapToInt(c -> c.getRules().getManaCost().getCMC()) .map(cmc -> Math.min(Math.max(cmc, 1), 6)) .forEach(cmc -> creatureCosts.put(cmc, creatureCosts.get(cmc) + 1)); diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java index 9959ce4fdfb..ccd3a9dd36f 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java @@ -133,8 +133,7 @@ public Deck buildDeck(final String landSetCode) { Iterable colorList = Iterables.filter(aiPlayables, PaperCardPredicates.fromRules(hasColor)); rankedColorList = CardRanker.rankCardsInDeck(colorList); - onColorCreatures = Iterables.filter(rankedColorList, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE)); + onColorCreatures = Iterables.filter(rankedColorList, PaperCardPredicates.IS_CREATURE); onColorNonCreatures = Iterables.filter(rankedColorList, PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_CREATURE_SPELL)); // Guava iterables do not copy the collection contents, instead they act @@ -166,7 +165,7 @@ public Deck buildDeck(final String landSetCode) { // an extra. if (deckList.size() == numSpellsNeeded && getAverageCMC(deckList) < 4) { final PaperCard card = rankedColorList.stream() - .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_LAND)) + .filter(PaperCardPredicates.IS_NON_LAND) .findFirst().orElse(null); if (card != null) { deckList.add(card); @@ -337,8 +336,7 @@ private void findBasicLandSets() { */ private void addLands(final int[] clrCnts, final String landSetCode) { // basic lands that are available in the deck - final Iterable basicLands = Iterables.filter(aiPlayables, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_BASIC_LAND)); + final Iterable basicLands = Iterables.filter(aiPlayables, PaperCardPredicates.IS_BASIC_LAND); final Set snowLands = new HashSet<>(); // total of all ClrCnts @@ -450,8 +448,7 @@ private int[] calculateLandNeeds() { * Add non-basic lands to the deck. */ private void addNonBasicLands() { - final Iterable lands = Iterables.filter(aiPlayables, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_NONBASIC_LAND)); + final Iterable lands = Iterables.filter(aiPlayables, PaperCardPredicates.IS_NONBASIC_LAND); List landsToAdd = new ArrayList<>(); for (final PaperCard card : lands) { if (landsNeeded > 0) { @@ -478,8 +475,7 @@ private void addNonBasicLands() { */ private void addThirdColorCards(int num) { if (num > 0) { - final Iterable others = Iterables.filter(aiPlayables, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_LAND)); + final Iterable others = Iterables.filter(aiPlayables, PaperCardPredicates.IS_NON_LAND); // We haven't yet ranked the off-color cards. // Compare them to the cards already in the deckList. List rankedOthers = CardRanker.rankCardsInPack(others, deckList, colors, true); @@ -521,8 +517,7 @@ private void addThirdColorCards(int num) { * number to add */ private void addRandomCards(int num) { - final Iterable others = Iterables.filter(aiPlayables, - PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_LAND)); + final Iterable others = Iterables.filter(aiPlayables, PaperCardPredicates.IS_NON_LAND); List toAdd = new ArrayList<>(); for (final PaperCard card : others) { if (num > 0) { @@ -665,8 +660,7 @@ private void addManaCurveCreatures(final Iterable creatures, int num) for (int i = 1; i < 7; i++) { creatureCosts.put(i, 0); } - final Predicate filter = PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE); - deckList.stream().filter(filter) + deckList.stream().filter(PaperCardPredicates.IS_CREATURE) .mapToInt(creature -> creature.getRules().getManaCost().getCMC()) .map(cmc -> Math.max(1, Math.min(cmc, 6))) .forEach(cmc -> creatureCosts.put(cmc, creatureCosts.get(cmc) + 1)); diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java b/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java index 89b7470cdba..0fd8066fa71 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/WinstonDraft.java @@ -41,7 +41,7 @@ private void initializeWinstonDraft() { for (int j = 0; j < NUM_PLAYERS; j++) { // Remove Basic Lands from draft for simplicity supply.get().stream() - .filter(PaperCardPredicates.IS_BASIC_LAND.negate()) + .filter(PaperCardPredicates.IS_BASIC_LAND_RARITY.negate()) .forEach(this.deck::add); } } diff --git a/forge-gui/src/main/java/forge/model/FModel.java b/forge-gui/src/main/java/forge/model/FModel.java index 6e4364ff6f8..a91b01408d1 100644 --- a/forge-gui/src/main/java/forge/model/FModel.java +++ b/forge-gui/src/main/java/forge/model/FModel.java @@ -361,8 +361,7 @@ public static ItemPool getTinyLeadersCommander() { public static ItemPool getCommanderPool() { if (commanderPool == null) - return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(PaperCardPredicates.fromRules( - CardRulesPredicates.CAN_BE_COMMANDER)), PaperCard.class); + return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(PaperCardPredicates.CAN_BE_COMMANDER), PaperCard.class); return commanderPool; } diff --git a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java index c6a1dee9ecf..5c6cd38a81b 100644 --- a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java +++ b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java @@ -289,7 +289,7 @@ public static HashMap>> initializeComma //get all cards List cardList = FModel.getMagicDb().getCommonCards().streamUniqueCards() - .filter(PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)) + .filter(PaperCardPredicates.NOT_TRUE_BASIC_LAND) .collect(Collectors.toList()); cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes")); Map cardIntegerMap = new HashMap<>(); @@ -349,7 +349,7 @@ public static void updateLegendMatrix(Deck deck, PaperCard legend, Map legendIntegerMap, int[][] matrix){ String cardName = legend.getName(); deck.getMain().toFlatList().stream() - .filter(PaperCardPredicates.fromRules(CardRulesPredicates.NOT_TRUE_BASIC_LAND)) + .filter(PaperCardPredicates.NOT_TRUE_BASIC_LAND) .filter(PaperCardPredicates.name(cardName).negate()) .forEach(pairCard -> { try { From 1af22ff4b6a6441f9e6a42001be00d1f0125de92 Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 22 Sep 2024 16:54:49 -0400 Subject: [PATCH 48/68] Guava migration - Remove CollectionSuppliers --- .../java/forge/util/CollectionSuppliers.java | 30 ------------------- .../java/forge/game/phase/PhaseHandler.java | 3 +- .../src/main/java/forge/game/zone/Zone.java | 11 ++----- .../java/forge/gui/framework/SLayoutIO.java | 6 ++-- .../forge/gamemodes/match/HostedMatch.java | 9 ++---- .../quest/MainWorldEventDuelManager.java | 3 +- .../quest/QuestEventDuelManager.java | 3 +- .../quest/QuestEventLDADuelManager.java | 3 +- 8 files changed, 12 insertions(+), 56 deletions(-) delete mode 100644 forge-core/src/main/java/forge/util/CollectionSuppliers.java diff --git a/forge-core/src/main/java/forge/util/CollectionSuppliers.java b/forge-core/src/main/java/forge/util/CollectionSuppliers.java deleted file mode 100644 index f4ac83515e7..00000000000 --- a/forge-core/src/main/java/forge/util/CollectionSuppliers.java +++ /dev/null @@ -1,30 +0,0 @@ -package forge.util; - -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.function.Supplier; - -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - -public final class CollectionSuppliers { - - /** - * Private constructor to prevent instantiation. - */ - private CollectionSuppliers() { - } - - public static Supplier> arrayLists() { - return Lists::newArrayList; - } - - public static Supplier> hashSets() { - return Sets::newHashSet; - } - - public static > Supplier> treeSets() { - return Sets::newTreeSet; - } -} diff --git a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java index 7c73f8e3ae0..6e8b31f405d 100644 --- a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java +++ b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java @@ -40,7 +40,6 @@ import forge.game.trigger.TriggerType; import forge.game.zone.Zone; import forge.game.zone.ZoneType; -import forge.util.CollectionSuppliers; import forge.util.TextUtil; import forge.util.maps.HashMapOfLists; import forge.util.maps.MapOfLists; @@ -716,7 +715,7 @@ private void declareBlockersTurnBasedAction() { // map: defender => (many) attacker => (many) blocker Map> blockers = Maps.newHashMap(); for (GameEntity ge : combat.getDefendersControlledBy(p)) { - MapOfLists protectThisDefender = new HashMapOfLists<>(CollectionSuppliers.arrayLists()); + MapOfLists protectThisDefender = new HashMapOfLists<>(ArrayList::new); for (Card att : combat.getAttackersOf(ge)) { protectThisDefender.addAll(att, combat.getBlockers(att)); } diff --git a/forge-game/src/main/java/forge/game/zone/Zone.java b/forge-game/src/main/java/forge/game/zone/Zone.java index 404b9db5b47..41bddba1170 100644 --- a/forge-game/src/main/java/forge/game/zone/Zone.java +++ b/forge-game/src/main/java/forge/game/zone/Zone.java @@ -17,11 +17,7 @@ */ package forge.game.zone; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; import java.util.function.Predicate; @@ -34,7 +30,6 @@ import forge.game.event.EventValueChangeType; import forge.game.event.GameEventZone; import forge.game.player.Player; -import forge.util.CollectionSuppliers; import forge.util.MyRandom; import forge.util.maps.EnumMapOfLists; import forge.util.maps.MapOfLists; @@ -54,8 +49,8 @@ public class Zone implements java.io.Serializable, Iterable { protected final ZoneType zoneType; protected final Game game; - protected final transient MapOfLists cardsAddedThisTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.arrayLists()); - protected final transient MapOfLists cardsAddedLastTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.arrayLists()); + protected final transient MapOfLists cardsAddedThisTurn = new EnumMapOfLists<>(ZoneType.class, ArrayList::new); + protected final transient MapOfLists cardsAddedLastTurn = new EnumMapOfLists<>(ZoneType.class, ArrayList::new); public Zone(final ZoneType zone0, Game game0) { zoneType = zone0; diff --git a/forge-gui-desktop/src/main/java/forge/gui/framework/SLayoutIO.java b/forge-gui-desktop/src/main/java/forge/gui/framework/SLayoutIO.java index 47c66958d90..733467c610f 100644 --- a/forge-gui-desktop/src/main/java/forge/gui/framework/SLayoutIO.java +++ b/forge-gui-desktop/src/main/java/forge/gui/framework/SLayoutIO.java @@ -9,7 +9,6 @@ import forge.toolbox.FAbsolutePositioner; import forge.toolbox.SaveOpenDialog; import forge.toolbox.SaveOpenDialog.Filetypes; -import forge.util.CollectionSuppliers; import forge.util.ThreadUtil; import forge.util.maps.HashMapOfLists; import forge.util.maps.MapOfLists; @@ -23,6 +22,7 @@ import javax.xml.stream.events.XMLEvent; import java.awt.*; import java.io.*; +import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -513,8 +513,8 @@ private static MapOfLists readLayout(final XMLEventReader re Attribute attribute; EDocID selectedId = null; double x0 = 0, y0 = 0, w0 = 0, h0 = 0; - - MapOfLists model = new HashMapOfLists<>(CollectionSuppliers.arrayLists()); + + MapOfLists model = new HashMapOfLists<>(ArrayList::new); LayoutInfo currentKey = null; while (null != reader && reader.hasNext()) { diff --git a/forge-gui/src/main/java/forge/gamemodes/match/HostedMatch.java b/forge-gui/src/main/java/forge/gamemodes/match/HostedMatch.java index df56faac030..98249ea73f8 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/HostedMatch.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/HostedMatch.java @@ -1,11 +1,7 @@ package forge.gamemodes.match; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; import forge.ai.AiProfileUtil; import forge.gui.control.PlaybackSpeed; @@ -53,7 +49,6 @@ import forge.sound.MusicPlaylist; import forge.sound.SoundSystem; import forge.trackable.TrackableCollection; -import forge.util.CollectionSuppliers; import forge.util.TextUtil; import forge.util.collect.FCollectionView; import forge.util.maps.HashMapOfLists; @@ -189,7 +184,7 @@ public void startGame() { final GameView gameView = getGameView(); humanCount = 0; - final MapOfLists playersPerGui = new HashMapOfLists<>(CollectionSuppliers.arrayLists()); + final MapOfLists playersPerGui = new HashMapOfLists<>(ArrayList::new); for (int iPlayer = 0; iPlayer < players.size(); iPlayer++) { final RegisteredPlayer rp = match.getPlayers().get(iPlayer); final Player p = players.get(iPlayer); diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/MainWorldEventDuelManager.java b/forge-gui/src/main/java/forge/gamemodes/quest/MainWorldEventDuelManager.java index d7ac90f1454..41d025ea457 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/MainWorldEventDuelManager.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/MainWorldEventDuelManager.java @@ -11,7 +11,6 @@ import forge.gamemodes.quest.data.QuestPreferences.QPref; import forge.gamemodes.quest.io.MainWorldDuelReader; import forge.model.FModel; -import forge.util.CollectionSuppliers; import forge.util.MyRandom; import forge.util.maps.EnumMapOfLists; import forge.util.maps.MapOfLists; @@ -20,7 +19,7 @@ public class MainWorldEventDuelManager implements QuestEventDuelManagerInterface { - protected final MapOfLists sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, CollectionSuppliers.arrayLists()); + protected final MapOfLists sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, ArrayList::new); protected final IStorage allDuels; /** diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestEventDuelManager.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestEventDuelManager.java index 9f147e80cbc..a6f90917700 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestEventDuelManager.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestEventDuelManager.java @@ -28,7 +28,6 @@ import forge.gamemodes.quest.data.QuestPreferences.QPref; import forge.gamemodes.quest.io.QuestDuelReader; import forge.model.FModel; -import forge.util.CollectionSuppliers; import forge.util.MyRandom; import forge.util.maps.EnumMapOfLists; import forge.util.maps.MapOfLists; @@ -43,7 +42,7 @@ */ public class QuestEventDuelManager implements QuestEventDuelManagerInterface { - private final MapOfLists sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, CollectionSuppliers.arrayLists()); + private final MapOfLists sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, ArrayList::new); private final IStorage allDuels; /** diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestEventLDADuelManager.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestEventLDADuelManager.java index e85d3a2f391..adfa0ad1fb7 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestEventLDADuelManager.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestEventLDADuelManager.java @@ -29,7 +29,6 @@ import forge.gamemodes.quest.data.QuestPreferences.DifficultyPrefs; import forge.gamemodes.quest.data.QuestPreferences.QPref; import forge.model.FModel; -import forge.util.CollectionSuppliers; import forge.util.MyRandom; import forge.util.maps.EnumMapOfLists; import forge.util.maps.MapOfLists; @@ -43,7 +42,7 @@ public class QuestEventLDADuelManager implements QuestEventDuelManagerInterface { private List archetypes; - private final MapOfLists sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, CollectionSuppliers.arrayLists()); + private final MapOfLists sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, ArrayList::new); private GameFormat baseFormat; public QuestEventLDADuelManager(GameFormat baseFormat){ From a57bab1dac19eaa2b74deb4ea2078cb4f57d3f0c Mon Sep 17 00:00:00 2001 From: Jetz Date: Tue, 24 Sep 2024 09:33:23 -0400 Subject: [PATCH 49/68] Guava migration - Remove single use Predicate implementations Remove unused parameters of other predicates --- .../src/main/java/forge/card/CardDb.java | 65 ++------ .../src/main/java/forge/card/CardEdition.java | 33 +--- .../java/forge/card/CardRulesPredicates.java | 149 +++--------------- .../main/java/forge/card/CardSplitType.java | 5 + .../main/java/forge/card/ICardDatabase.java | 4 +- .../deck/generation/DeckGeneratorBase.java | 2 +- .../java/forge/item/PaperCardPredicates.java | 89 +++-------- .../item/generation/BoosterGenerator.java | 10 +- .../main/java/forge/util/PredicateCard.java | 83 ---------- .../gamemodes/limited/LimitedDeckBuilder.java | 2 +- .../forge/gamemodes/quest/QuestUtilCards.java | 2 +- .../gamemodes/quest/data/GameFormatQuest.java | 26 --- 12 files changed, 73 insertions(+), 397 deletions(-) delete mode 100644 forge-core/src/main/java/forge/util/PredicateCard.java diff --git a/forge-core/src/main/java/forge/card/CardDb.java b/forge-core/src/main/java/forge/card/CardDb.java index 900e3df7cd5..67f13b8abb9 100644 --- a/forge-core/src/main/java/forge/card/CardDb.java +++ b/forge-core/src/main/java/forge/card/CardDb.java @@ -1060,69 +1060,26 @@ public Iterator iterator() { } @Override - public Predicate wasPrintedInSets(List setCodes) { - return new PredicateExistsInSets(setCodes); - } - - private class PredicateExistsInSets implements Predicate { - private final List sets; - - public PredicateExistsInSets(final List wantSets) { - this.sets = wantSets; // maybe should make a copy here? - } - - @Override - public boolean test(final PaperCard subject) { - for (PaperCard c : getAllCards(subject.getName())) { - if (sets.contains(c.getEdition())) { - return true; - } - } - return false; - } + public Predicate wasPrintedInSets(Collection setCodes) { + Set sets = new HashSet<>(setCodes); + return paperCard -> getAllCards(paperCard.getName()).stream() + .map(PaperCard::getEdition) + .anyMatch(sets::contains); } // This Predicate validates if a card is legal in a given format (identified by the list of allowed sets) @Override - public Predicate isLegal(List allowedSetCodes){ - return new PredicateLegalInSets(allowedSetCodes); - } - - private class PredicateLegalInSets implements Predicate { - private final List sets = new ArrayList<>(); - - public PredicateLegalInSets(final List allowedSets){ - this.sets.addAll(allowedSets); - } - @Override - public boolean test(final PaperCard card){ - if (card == null) return false; - return this.sets.contains(card.getEdition()); - } + public Predicate isLegal(Collection allowedSetCodes){ + Set sets = new HashSet<>(allowedSetCodes); + return paperCard -> paperCard != null && sets.contains(paperCard.getEdition()); } // This Predicate validates if a card was printed at [rarity], on any of its printings @Override public Predicate wasPrintedAtRarity(CardRarity rarity) { - return new PredicatePrintedAtRarity(rarity); - } - - private class PredicatePrintedAtRarity implements Predicate { - private final Set matchingCards; - - public PredicatePrintedAtRarity(CardRarity rarity) { - this.matchingCards = new HashSet<>(); - for (PaperCard c : getAllCards()) { - if (c.getRarity() == rarity) { - this.matchingCards.add(c.getName()); - } - } - } - - @Override - public boolean test(final PaperCard subject) { - return matchingCards.contains(subject.getName()); - } + return paperCard -> getAllCards(paperCard.getName()).stream() + .map(PaperCard::getRarity) + .anyMatch(rarity::equals); } public StringBuilder appendCardToStringBuilder(PaperCard card, StringBuilder sb) { diff --git a/forge-core/src/main/java/forge/card/CardEdition.java b/forge-core/src/main/java/forge/card/CardEdition.java index 6a2e828e73a..4b59e6ba4bb 100644 --- a/forge-core/src/main/java/forge/card/CardEdition.java +++ b/forge-core/src/main/java/forge/card/CardEdition.java @@ -892,14 +892,7 @@ public CardEdition getTheLatestOfAllTheOriginalEditionsOfCardsIn(CardPool cards) } public static class Predicates { - public static final Predicate CAN_MAKE_BOOSTER = new CanMakeBooster(); - - private static class CanMakeBooster implements Predicate { - @Override - public boolean test(final CardEdition subject) { - return subject.hasBoosterTemplate(); - } - } + public static final Predicate CAN_MAKE_BOOSTER = CardEdition::hasBoosterTemplate; public static CardEdition getRandomSetWithAllBasicLands(Iterable allEditions) { return Aggregates.random(Iterables.filter(allEditions, hasBasicLands)); @@ -921,29 +914,11 @@ public static CardEdition getPreferredArtEditionWithAllBasicLands() { } - public static final Predicate HAS_TOURNAMENT_PACK = new CanMakeStarter(); - private static class CanMakeStarter implements Predicate { - @Override - public boolean test(final CardEdition subject) { - return StaticData.instance().getTournamentPacks().contains(subject.getCode()); - } - } + public static final Predicate HAS_TOURNAMENT_PACK = edition -> StaticData.instance().getTournamentPacks().contains(edition.getCode()); - public static final Predicate HAS_FAT_PACK = new CanMakeFatPack(); - private static class CanMakeFatPack implements Predicate { - @Override - public boolean test(final CardEdition subject) { - return subject.getFatPackCount() > 0; - } - } + public static final Predicate HAS_FAT_PACK = edition -> edition.getFatPackCount() > 0; - public static final Predicate HAS_BOOSTER_BOX = new CanMakeBoosterBox(); - private static class CanMakeBoosterBox implements Predicate { - @Override - public boolean test(final CardEdition subject) { - return subject.getBoosterBoxCount() > 0; - } - } + public static final Predicate HAS_BOOSTER_BOX = edition -> edition.getBoosterBoxCount() > 0; public static final Predicate hasBasicLands = ed -> { if (ed == null) { diff --git a/forge-core/src/main/java/forge/card/CardRulesPredicates.java b/forge-core/src/main/java/forge/card/CardRulesPredicates.java index dd8c039ce35..8dca9022415 100644 --- a/forge-core/src/main/java/forge/card/CardRulesPredicates.java +++ b/forge-core/src/main/java/forge/card/CardRulesPredicates.java @@ -85,14 +85,6 @@ public static Predicate name(final PredicateString.StringOp op, final return new LeafString(LeafString.CardField.NAME, op, what); } - /** - * TODO: Write javadoc for this method. - * @param transform - * @return - */ - public static Predicate splitType(final CardSplitType transform) { - return new PredicateSplitType(transform); - } /** * Sub type. @@ -105,15 +97,6 @@ public static Predicate subType(final String what) { return new LeafString(LeafString.CardField.SUBTYPE, PredicateString.StringOp.CONTAINS, what); } - /** - * Sub type. - * - * @param op - * the op - * @param what - * the what - * @return the predicate - */ public static Predicate subType(final PredicateString.StringOp op, final String what) { return new LeafString(LeafString.CardField.SUBTYPE, op, what); } @@ -172,64 +155,26 @@ public static Predicate deckHasExactly(final DeckHints.Type type, fin }; } - /** - * Core type. - * - * @param isEqual - * the is equal - * @param what - * the what - * @return the predicate - */ - public static Predicate coreType(final boolean isEqual, final String what) { + public static Predicate coreType(final String what) { try { - return CardRulesPredicates.coreType(isEqual, Enum.valueOf(CardType.CoreType.class, what)); + return CardRulesPredicates.coreType(Enum.valueOf(CardType.CoreType.class, what)); } catch (final Exception e) { return x -> false; } } /** - * Core type. - * - * @param isEqual - * the is equal - * @param type - * the type - * @return the predicate + * @return a Predicate that matches cards that have the specified core type. */ - public static Predicate coreType(final boolean isEqual, final CardType.CoreType type) { - return new PredicateCoreType(type, isEqual); - } - - /** - * Super type. - * - * @param isEqual - * the is equal - * @param what - * the what - * @return the predicate - */ - public static Predicate superType(final boolean isEqual, final String what) { - try { - return CardRulesPredicates.superType(isEqual, Enum.valueOf(CardType.Supertype.class, what)); - } catch (final Exception e) { - return x -> false; - } + public static Predicate coreType(final CardType.CoreType type) { + return card -> card.getType().hasType(type); } /** - * Super type. - * - * @param isEqual - * the is equal - * @param type - * the type - * @return the predicate + * @return a Predicate that matches cards that have the specified supertype. */ - public static Predicate superType(final boolean isEqual, final CardType.Supertype type) { - return new PredicateSuperType(type, isEqual); + public static Predicate superType(final CardType.Supertype type) { + return card -> card.getType().hasSupertype(type); } /** @@ -494,58 +439,12 @@ private boolean op(final int op1, final int op2) { } } - private static class PredicateCoreType implements Predicate { - private final CardType.CoreType operand; - private final boolean shouldBeEqual; - - @Override - public boolean test(final CardRules card) { - if (null == card) { - return false; - } - return this.shouldBeEqual == card.getType().hasType(this.operand); - } - - public PredicateCoreType(final CardType.CoreType type, final boolean wantEqual) { - this.operand = type; - this.shouldBeEqual = wantEqual; - } - } - - private static class PredicateSuperType implements Predicate { - private final CardType.Supertype operand; - private final boolean shouldBeEqual; - - @Override - public boolean test(final CardRules card) { - return this.shouldBeEqual == card.getType().hasSupertype(this.operand); - } - - public PredicateSuperType(final CardType.Supertype type, final boolean wantEqual) { - this.operand = type; - this.shouldBeEqual = wantEqual; - } - } - - private static class PredicateSplitType implements Predicate { - private final CardSplitType cst; - - public PredicateSplitType(final CardSplitType type) { - cst = type; - } - - @Override - public boolean test(final CardRules subject) { - return subject.getSplitType() == cst; - } - } - - public static final Predicate IS_CREATURE = CardRulesPredicates.coreType(true, CardType.CoreType.Creature); - public static final Predicate IS_LEGENDARY = CardRulesPredicates.superType(true, CardType.Supertype.Legendary); - public static final Predicate IS_ARTIFACT = CardRulesPredicates.coreType(true, CardType.CoreType.Artifact); + public static final Predicate IS_CREATURE = CardRulesPredicates.coreType(CardType.CoreType.Creature); + public static final Predicate IS_LEGENDARY = CardRulesPredicates.superType(CardType.Supertype.Legendary); + public static final Predicate IS_ARTIFACT = CardRulesPredicates.coreType(CardType.CoreType.Artifact); public static final Predicate IS_ATTRACTION = CardRulesPredicates.IS_ARTIFACT.and(CardRulesPredicates.subType("Attraction")); public static final Predicate IS_EQUIPMENT = CardRulesPredicates.subType("Equipment"); - public static final Predicate IS_LAND = CardRulesPredicates.coreType(true, CardType.CoreType.Land); + public static final Predicate IS_LAND = CardRulesPredicates.coreType(CardType.CoreType.Land); public static final Predicate IS_BASIC_LAND = subject -> subject.getType().isBasicLand(); public static final Predicate NOT_BASIC_LAND = subject -> !subject.getType().isBasicLand(); /** Matches only Plains, Island, Swamp, Mountain, or Forest. */ @@ -557,25 +456,25 @@ public boolean test(final CardRules subject) { public static final Predicate CAN_BE_PARTNER_COMMANDER = CardRules::canBePartnerCommander; public static final Predicate CAN_BE_OATHBREAKER = CardRules::canBeOathbreaker; public static final Predicate CAN_BE_SIGNATURE_SPELL = CardRules::canBeSignatureSpell; - public static final Predicate IS_PLANESWALKER = CardRulesPredicates.coreType(true, CardType.CoreType.Planeswalker); + public static final Predicate IS_PLANESWALKER = CardRulesPredicates.coreType(CardType.CoreType.Planeswalker); public static final Predicate CAN_BE_TINY_LEADERS_COMMANDER = CardRulesPredicates.IS_LEGENDARY.and(CardRulesPredicates.IS_CREATURE.or(CardRulesPredicates.IS_PLANESWALKER)); public static final Predicate CAN_BE_BRAWL_COMMANDER = CardRulesPredicates.IS_LEGENDARY.and(CardRulesPredicates.IS_CREATURE.or(CardRulesPredicates.IS_PLANESWALKER)); - public static final Predicate IS_BATTLE = CardRulesPredicates.coreType(true, CardType.CoreType.Battle); - public static final Predicate IS_INSTANT = CardRulesPredicates.coreType(true, CardType.CoreType.Instant); - public static final Predicate IS_SORCERY = CardRulesPredicates.coreType(true, CardType.CoreType.Sorcery); - public static final Predicate IS_ENCHANTMENT = CardRulesPredicates.coreType(true, CardType.CoreType.Enchantment); + public static final Predicate IS_BATTLE = CardRulesPredicates.coreType(CardType.CoreType.Battle); + public static final Predicate IS_INSTANT = CardRulesPredicates.coreType(CardType.CoreType.Instant); + public static final Predicate IS_SORCERY = CardRulesPredicates.coreType(CardType.CoreType.Sorcery); + public static final Predicate IS_ENCHANTMENT = CardRulesPredicates.coreType(CardType.CoreType.Enchantment); public static final Predicate IS_NON_CREATURE_SPELL = ( CardRulesPredicates.IS_CREATURE.or(CardRulesPredicates.IS_LAND).or(CardRules::isVariant) ).negate(); - public static final Predicate IS_PLANE = CardRulesPredicates.coreType(true, CardType.CoreType.Plane); - public static final Predicate IS_PHENOMENON = CardRulesPredicates.coreType(true, CardType.CoreType.Phenomenon); + public static final Predicate IS_PLANE = CardRulesPredicates.coreType(CardType.CoreType.Plane); + public static final Predicate IS_PHENOMENON = CardRulesPredicates.coreType(CardType.CoreType.Phenomenon); public static final Predicate IS_PLANE_OR_PHENOMENON = IS_PLANE.or(IS_PHENOMENON); - public static final Predicate IS_SCHEME = CardRulesPredicates.coreType(true, CardType.CoreType.Scheme); - public static final Predicate IS_VANGUARD = CardRulesPredicates.coreType(true, CardType.CoreType.Vanguard); - public static final Predicate IS_CONSPIRACY = CardRulesPredicates.coreType(true, CardType.CoreType.Conspiracy); - public static final Predicate IS_DUNGEON = CardRulesPredicates.coreType(true, CardType.CoreType.Dungeon); - public static final Predicate IS_NON_LAND = CardRulesPredicates.coreType(false, CardType.CoreType.Land); + public static final Predicate IS_SCHEME = CardRulesPredicates.coreType(CardType.CoreType.Scheme); + public static final Predicate IS_VANGUARD = CardRulesPredicates.coreType(CardType.CoreType.Vanguard); + public static final Predicate IS_CONSPIRACY = CardRulesPredicates.coreType(CardType.CoreType.Conspiracy); + public static final Predicate IS_DUNGEON = CardRulesPredicates.coreType(CardType.CoreType.Dungeon); + public static final Predicate IS_NON_LAND = CardRulesPredicates.coreType(CardType.CoreType.Land); public static final Predicate IS_WHITE = CardRulesPredicates.isColor(MagicColor.WHITE); public static final Predicate IS_BLUE = CardRulesPredicates.isColor(MagicColor.BLUE); public static final Predicate IS_BLACK = CardRulesPredicates.isColor(MagicColor.BLACK); diff --git a/forge-core/src/main/java/forge/card/CardSplitType.java b/forge-core/src/main/java/forge/card/CardSplitType.java index 69c6aea1814..292af425be4 100644 --- a/forge-core/src/main/java/forge/card/CardSplitType.java +++ b/forge-core/src/main/java/forge/card/CardSplitType.java @@ -2,6 +2,8 @@ import forge.card.CardFace.FaceSelectionMethod; +import java.util.EnumSet; + public enum CardSplitType { None(FaceSelectionMethod.USE_PRIMARY_FACE, null), @@ -13,6 +15,9 @@ public enum CardSplitType Modal(FaceSelectionMethod.USE_ACTIVE_FACE, CardStateName.Modal), Specialize(FaceSelectionMethod.USE_ACTIVE_FACE, null); + public static final EnumSet DUAL_FACED_CARDS = EnumSet.of( + CardSplitType.Transform, CardSplitType.Meld, CardSplitType.Modal); + CardSplitType(FaceSelectionMethod calcMode, CardStateName stateName) { method = calcMode; this.changedStateName = stateName; diff --git a/forge-core/src/main/java/forge/card/ICardDatabase.java b/forge-core/src/main/java/forge/card/ICardDatabase.java index 4e4016accce..1144234f325 100644 --- a/forge-core/src/main/java/forge/card/ICardDatabase.java +++ b/forge-core/src/main/java/forge/card/ICardDatabase.java @@ -94,7 +94,7 @@ public interface ICardDatabase extends Iterable { int getMaxArtIndex(String cardName); int getArtCount(String cardName, String edition); // Utility Predicates - Predicate wasPrintedInSets(List allowedSetCodes); - Predicate isLegal(List allowedSetCodes); + Predicate wasPrintedInSets(Collection allowedSetCodes); + Predicate isLegal(Collection allowedSetCodes); Predicate wasPrintedAtRarity(CardRarity rarity); } \ No newline at end of file diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index ff9c1e0e3a1..99d93a14fec 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -387,7 +387,7 @@ protected List getDualLandList(Predicate canPlay) { } //filter to provide all dual lands from pool matching 2 or 3 colors from current deck - Predicate dualLandFilter = CardRulesPredicates.coreType(true, CardType.CoreType.Land); + Predicate dualLandFilter = CardRulesPredicates.coreType(CardType.CoreType.Land); Predicate exceptBasicLand = CardRulesPredicates.NOT_BASIC_LAND; Iterable landCards = pool.getAllCards(PaperCardPredicates.fromRules(dualLandFilter.and(exceptBasicLand).and(canPlay))); diff --git a/forge-core/src/main/java/forge/item/PaperCardPredicates.java b/forge-core/src/main/java/forge/item/PaperCardPredicates.java index 27cbb584192..0a26bc5aad7 100644 --- a/forge-core/src/main/java/forge/item/PaperCardPredicates.java +++ b/forge-core/src/main/java/forge/item/PaperCardPredicates.java @@ -2,7 +2,6 @@ import com.google.common.collect.Lists; import forge.card.*; -import forge.util.PredicateCard; import forge.util.PredicateString; import org.apache.commons.lang3.StringUtils; @@ -15,13 +14,6 @@ * Filters based on PaperCard values. */ public abstract class PaperCardPredicates { - public static Predicate rarity(final boolean isEqual, final CardRarity value) { - return new PredicateRarity(value, isEqual); - } - - public static Predicate color(final boolean isEqual, final boolean noColor, final byte value) { - return new PredicateColor(value, noColor, isEqual); - } public static Predicate printedInSets(final String[] sets) { return printedInSets(Lists.newArrayList(sets), true); @@ -42,70 +34,50 @@ public static Predicate printedInSet(final String value) { } public static Predicate name(final String what) { - return new PredicateName(PredicateString.StringOp.EQUALS_IC, what); - } - - public static Predicate name(final PredicateString.StringOp op, final String what) { - return new PredicateName(op, what); + return new PredicateName(what); } public static Predicate names(final List what) { return new PredicateNames(what); } - public static Predicate cards(final List what) { - return new PredicateCards(what); - } - private static final class PredicateColor implements Predicate { private final byte operand; - private final boolean noColor; - private final boolean shouldBeEqual; - private PredicateColor(final byte color, final boolean noColor, final boolean wantEqual) { + private PredicateColor(final byte color) { this.operand = color; - this.noColor = noColor; - this.shouldBeEqual = wantEqual; } @Override public boolean test(final PaperCard card) { - boolean colorFound = false; - if (noColor) { - return card.getRules().getColor().isColorless() == shouldBeEqual; - } for (final byte color : card.getRules().getColor()) { if (color == operand) { - colorFound = true; - break; + return true; } } if (card.getRules().getType().hasType(CardType.CoreType.Land)) { for (final byte color : card.getRules().getColorIdentity()) { if (color == operand) { - colorFound = true; - break; + return true; } } } - return colorFound == shouldBeEqual; + return false; } } private static final class PredicateRarity implements Predicate { private final CardRarity operand; - private final boolean shouldBeEqual; @Override public boolean test(final PaperCard card) { - return (card.getRarity() == this.operand) == this.shouldBeEqual; + return (card.getRarity() == this.operand); } - private PredicateRarity(final CardRarity type, final boolean wantEqual) { + private PredicateRarity(final CardRarity type) { this.operand = type; - this.shouldBeEqual = wantEqual; } } @@ -132,8 +104,8 @@ public boolean test(final PaperCard card) { return this.op(card.getName(), this.operand); } - private PredicateName(final StringOp operator, final String operand) { - super(operator); + private PredicateName(final String operand) { + super(StringOp.EQUALS_IC); this.operand = operand; } } @@ -158,42 +130,23 @@ private PredicateNames(final List operand) { } } - private static final class PredicateCards extends PredicateCard { - private final List operand; - - @Override - public boolean test(final PaperCard card) { - for (final PaperCard element : this.operand) { - if (this.op(card, element)) { - return true; - } - } - return false; - } - - private PredicateCards(final List operand) { - super(StringOp.EQUALS); - this.operand = operand; - } - } - public static Predicate fromRules(Predicate cardRulesPredicate) { return paperCard -> cardRulesPredicate.test(paperCard.getRules()); } - public static final Predicate IS_COMMON = PaperCardPredicates.rarity(true, CardRarity.Common); - public static final Predicate IS_UNCOMMON = PaperCardPredicates.rarity(true, CardRarity.Uncommon); - public static final Predicate IS_RARE = PaperCardPredicates.rarity(true, CardRarity.Rare); - public static final Predicate IS_MYTHIC_RARE = PaperCardPredicates.rarity(true, CardRarity.MythicRare); + public static final Predicate IS_COMMON = new PredicateRarity(CardRarity.Common); + public static final Predicate IS_UNCOMMON = new PredicateRarity(CardRarity.Uncommon); + public static final Predicate IS_RARE = new PredicateRarity(CardRarity.Rare); + public static final Predicate IS_MYTHIC_RARE = new PredicateRarity(CardRarity.MythicRare); public static final Predicate IS_RARE_OR_MYTHIC = PaperCardPredicates.IS_RARE.or(PaperCardPredicates.IS_MYTHIC_RARE); - public static final Predicate IS_SPECIAL = PaperCardPredicates.rarity(true, CardRarity.Special); - public static final Predicate IS_BASIC_LAND_RARITY = PaperCardPredicates.rarity(true, CardRarity.BasicLand); - public static final Predicate IS_BLACK = PaperCardPredicates.color(true, false, MagicColor.BLACK); - public static final Predicate IS_BLUE = PaperCardPredicates.color(true, false, MagicColor.BLUE); - public static final Predicate IS_GREEN = PaperCardPredicates.color(true, false, MagicColor.GREEN); - public static final Predicate IS_RED = PaperCardPredicates.color(true, false, MagicColor.RED); - public static final Predicate IS_WHITE = PaperCardPredicates.color(true, false, MagicColor.WHITE); - public static final Predicate IS_COLORLESS = PaperCardPredicates.color(true, true, MagicColor.COLORLESS); + public static final Predicate IS_SPECIAL = new PredicateRarity(CardRarity.Special); + public static final Predicate IS_BASIC_LAND_RARITY = new PredicateRarity(CardRarity.BasicLand); + public static final Predicate IS_BLACK = new PredicateColor(MagicColor.BLACK); + public static final Predicate IS_BLUE = new PredicateColor(MagicColor.BLUE); + public static final Predicate IS_GREEN = new PredicateColor(MagicColor.GREEN); + public static final Predicate IS_RED = new PredicateColor(MagicColor.RED); + public static final Predicate IS_WHITE = new PredicateColor(MagicColor.WHITE); + public static final Predicate IS_COLORLESS = paperCard -> paperCard.getRules().getColor().isColorless(); public static final Predicate IS_UNREBALANCED = PaperCard::isUnRebalanced; public static final Predicate IS_REBALANCED = PaperCard::isRebalanced; diff --git a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java index 176da6242c1..82881adbf4e 100644 --- a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java +++ b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java @@ -673,11 +673,7 @@ private static Predicate buildExtraPredicate(List operators) Predicate toAdd = null; if (operator.equalsIgnoreCase(BoosterSlots.DUAL_FACED_CARD)) { - toAdd = PaperCardPredicates.fromRules( - CardRulesPredicates.splitType(CardSplitType.Transform) - .or(CardRulesPredicates.splitType(CardSplitType.Meld)) - .or(CardRulesPredicates.splitType(CardSplitType.Modal) - )); + toAdd = card -> CardSplitType.DUAL_FACED_CARDS.contains(card.getRules().getSplitType()); } else if (operator.equalsIgnoreCase(BoosterSlots.LAND)) { toAdd = PaperCardPredicates.IS_LAND; } else if (operator.equalsIgnoreCase(BoosterSlots.BASIC_LAND)) { toAdd = PaperCardPredicates.IS_BASIC_LAND_RARITY; } else if (operator.equalsIgnoreCase(BoosterSlots.TIME_SHIFTED)) { toAdd = PaperCardPredicates.IS_SPECIAL; @@ -718,8 +714,8 @@ private static Predicate buildExtraPredicate(List operators) toAdd = PaperCardPredicates.printedInSets(sets); } else if (operator.startsWith("fromSheet(") && invert) { String sheetName = StringUtils.strip(operator.substring(9), "()\" "); - Iterable cards = StaticData.instance().getPrintSheets().get(sheetName).toFlatList(); - toAdd = PaperCardPredicates.cards(Lists.newArrayList(cards)); + Set cards = Sets.newHashSet(StaticData.instance().getPrintSheets().get(sheetName).toFlatList()); + toAdd = cards::contains; } if (toAdd == null) { diff --git a/forge-core/src/main/java/forge/util/PredicateCard.java b/forge-core/src/main/java/forge/util/PredicateCard.java deleted file mode 100644 index 611e091abbd..00000000000 --- a/forge-core/src/main/java/forge/util/PredicateCard.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Forge: Play Magic: the Gathering. - * Copyright (C) 2020 Jamin W. Collins - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package forge.util; - -import forge.item.PaperCard; - -import java.util.function.Predicate; - -/** - * Special predicate class to perform string operations. - * - * @param - * the generic type - */ -public abstract class PredicateCard implements Predicate { - /** Possible operators for string operands. */ - public enum StringOp { - /** The EQUALS. */ - EQUALS, - } - - /** The operator. */ - private final StringOp operator; - - /** - * Op. - * - * @param op1 - * the op1 - * @param op2 - * the op2 - * @return true, if successful - */ - protected final boolean op(final PaperCard op1, final PaperCard op2) { - switch (this.getOperator()) { - case EQUALS: - return op1.equals(op2); - default: - return false; - } - } - - /** - * Instantiates a new predicate string. - * - * @param operator - * the operator - */ - public PredicateCard(final StringOp operator) { - this.operator = operator; - } - - /** - * @return the operator - */ - public StringOp getOperator() { - return operator; - } - - public static PredicateCard equals(final PaperCard what) { - return new PredicateCard(StringOp.EQUALS) { - public boolean test(PaperCard subject) { - return op(subject, what); - } - }; - } - -} diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java index ccd3a9dd36f..33840ba6bed 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java @@ -84,7 +84,7 @@ public LimitedDeckBuilder(final List dList, final DeckColors pClrs) { // keep Conspiracies in a separate list this.draftedConspiracies = aiPlayables.stream() - .filter(PaperCardPredicates.fromRules(CardRulesPredicates.coreType(true, "Conspiracy"))) + .filter(PaperCardPredicates.fromRules(CardRulesPredicates.IS_CONSPIRACY)) .collect(Collectors.toList()); this.aiPlayables.removeAll(draftedConspiracies); diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java index 24b76891bcf..b0eef4b10d5 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java @@ -465,7 +465,7 @@ public int getSellPriceLimit() { public static Predicate isLegalInQuestFormat(final GameFormatQuest qFormat) { if(qFormat == null) return x -> true; - return GameFormatQuest.QPredicates.isLegalInFormatQuest(qFormat); + return edition -> qFormat.isSetLegal(edition.getCode()); } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/data/GameFormatQuest.java b/forge-gui/src/main/java/forge/gamemodes/quest/data/GameFormatQuest.java index 083d53f3f7d..a64fcd71573 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/data/GameFormatQuest.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/data/GameFormatQuest.java @@ -162,30 +162,4 @@ public int getUnlocksUsed() { return unlocksUsed; } - public abstract static class QPredicates { - /** - * Checks if is legal in quest format. - * - * @param qFormat the format - * @return the predicate - */ - public static Predicate isLegalInFormatQuest(final GameFormatQuest qFormat) { - return new LegalInFormatQuest(qFormat); - } - - private static final class LegalInFormatQuest implements Predicate { - private final GameFormatQuest qFormat; - - private LegalInFormatQuest(final GameFormatQuest fmt) { - this.qFormat = fmt; - } - - @Override - public boolean test(final CardEdition subject) { - return this.qFormat.isSetLegal(subject.getCode()); - } - } - - } - } From 52112e671c4a331484113d8d862ec820822ed15f Mon Sep 17 00:00:00 2001 From: Jetz Date: Wed, 25 Sep 2024 08:46:07 -0400 Subject: [PATCH 50/68] Guava migration - Slight cleanup --- forge-core/src/main/java/forge/card/CardDb.java | 4 ---- forge-core/src/main/java/forge/card/CardEdition.java | 6 ++++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/forge-core/src/main/java/forge/card/CardDb.java b/forge-core/src/main/java/forge/card/CardDb.java index 67f13b8abb9..c72b1ec3530 100644 --- a/forge-core/src/main/java/forge/card/CardDb.java +++ b/forge-core/src/main/java/forge/card/CardDb.java @@ -982,10 +982,6 @@ public Stream streamAllFaces() { return edition != null && Type.REPRINT_SET_TYPES.contains(edition.getType()); }; - public Collection getAllNonPromoCards() { - return streamAllCards().filter(EDITION_NON_PROMO).collect(Collectors.toList()); - } - public Collection getAllNonPromosNonReprintsNoAlt() { return streamAllCardsNoAlt().filter(EDITION_NON_REPRINT).collect(Collectors.toList()); } diff --git a/forge-core/src/main/java/forge/card/CardEdition.java b/forge-core/src/main/java/forge/card/CardEdition.java index 4b59e6ba4bb..06ceed5dfb7 100644 --- a/forge-core/src/main/java/forge/card/CardEdition.java +++ b/forge-core/src/main/java/forge/card/CardEdition.java @@ -40,6 +40,7 @@ import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; /** @@ -810,8 +811,9 @@ public Iterable getOrderedEditions() { } public Iterable getPrereleaseEditions() { - List res = Lists.newArrayList(this); - return Iterables.filter(res, edition -> edition.getPrerelease() != null); + return this.stream() + .filter(edition -> edition.getPrerelease() != null) + .collect(Collectors.toList()); } public CardEdition getEditionByCodeOrThrow(final String code) { From d01c4e056b8e72d2105ae61eeee3a53517579d5b Mon Sep 17 00:00:00 2001 From: Jetz Date: Wed, 25 Sep 2024 08:48:28 -0400 Subject: [PATCH 51/68] Guava migration - Remove unused imports --- forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java | 1 - forge-core/src/main/java/forge/card/ICardDatabase.java | 1 - forge-core/src/main/java/forge/item/SealedProduct.java | 1 - .../java/forge/game/ability/effects/PlayLandVariantEffect.java | 1 - .../java/forge/screens/deckeditor/controllers/CDeckgen.java | 2 -- .../java/forge/screens/deckeditor/controllers/CEditorQuest.java | 1 - .../forge/screens/deckeditor/controllers/CEditorVariant.java | 1 - .../src/main/java/forge/deck/CardRelationMatrixGenerator.java | 1 - forge-gui/src/main/java/forge/deck/DeckgenUtil.java | 1 - forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java | 1 - 10 files changed, 11 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java index 2a9a314f415..65f0d220e12 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java @@ -26,7 +26,6 @@ import forge.game.spellability.TargetRestrictions; import forge.game.staticability.StaticAbilityMustTarget; import forge.game.zone.ZoneType; -import forge.util.Aggregates; import forge.util.MyRandom; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; diff --git a/forge-core/src/main/java/forge/card/ICardDatabase.java b/forge-core/src/main/java/forge/card/ICardDatabase.java index 1144234f325..c1e72b4f6a7 100644 --- a/forge-core/src/main/java/forge/card/ICardDatabase.java +++ b/forge-core/src/main/java/forge/card/ICardDatabase.java @@ -5,7 +5,6 @@ import java.util.Collection; import java.util.Date; -import java.util.List; import java.util.function.Predicate; import java.util.stream.Stream; diff --git a/forge-core/src/main/java/forge/item/SealedProduct.java b/forge-core/src/main/java/forge/item/SealedProduct.java index 50ec4d5295e..19b58de9ddb 100644 --- a/forge-core/src/main/java/forge/item/SealedProduct.java +++ b/forge-core/src/main/java/forge/item/SealedProduct.java @@ -19,7 +19,6 @@ package forge.item; import forge.StaticData; -import forge.card.CardRulesPredicates; import forge.item.generation.BoosterGenerator; import forge.util.StreamUtils; diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java index c6acb5fde0c..88f3928de51 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayLandVariantEffect.java @@ -7,7 +7,6 @@ import com.google.common.collect.Lists; import forge.StaticData; -import forge.card.CardRulesPredicates; import forge.card.ColorSet; import forge.card.MagicColor; import forge.game.Game; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java index dfa70acd957..c71c37596f9 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java @@ -2,7 +2,6 @@ import forge.Singletons; import forge.card.CardDb; -import forge.card.CardRulesPredicates; import forge.card.MagicColor; import forge.deck.Deck; import forge.deck.DeckBase; @@ -25,7 +24,6 @@ import forge.util.StreamUtils; import java.util.List; -import java.util.function.Predicate; /** diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java index ded7c53ea45..c1d79674fbb 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuest.java @@ -29,7 +29,6 @@ import javax.swing.KeyStroke; import forge.card.CardRules; -import forge.card.CardRulesPredicates; import forge.card.ColorSet; import forge.card.mana.ManaCost; import forge.deck.CardPool; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java index 872daa9655c..9b7d8ccd5e0 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorVariant.java @@ -33,7 +33,6 @@ import forge.screens.deckeditor.views.VDeckgen; import forge.screens.match.controllers.CDetailPicture; import forge.util.ItemPool; -import forge.util.Iterables; import forge.util.Localizer; import forge.util.storage.IStorage; diff --git a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java index c82f09c6cd9..e4fdf6dac9d 100644 --- a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java @@ -14,7 +14,6 @@ import forge.item.PaperCardPredicates; import org.apache.commons.lang3.ArrayUtils; -import forge.card.CardRulesPredicates; import forge.deck.io.CardThemedMatrixIO; import forge.deck.io.DeckStorage; import forge.game.GameFormat; diff --git a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java index ccdbf587d82..55b8755a87a 100644 --- a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java +++ b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java @@ -9,7 +9,6 @@ import java.util.Map; import java.util.Set; import java.util.function.Predicate; -import java.util.stream.Collectors; import forge.item.PaperCardPredicates; import forge.util.*; diff --git a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java index 5c6cd38a81b..50d0b688af2 100644 --- a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java +++ b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java @@ -2,7 +2,6 @@ import forge.GuiDesktop; import forge.StaticData; -import forge.card.CardRulesPredicates; import forge.deck.Deck; import forge.deck.DeckFormat; import forge.deck.io.Archetype; From 1395baa2ffe7c80009f713d3c4eae5ff456ed78d Mon Sep 17 00:00:00 2001 From: Jetz Date: Wed, 25 Sep 2024 08:59:21 -0400 Subject: [PATCH 52/68] Guava migration - Fix build error --- forge-core/src/main/java/forge/util/ItemPool.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/forge-core/src/main/java/forge/util/ItemPool.java b/forge-core/src/main/java/forge/util/ItemPool.java index fded45d31ec..bc361b5aaf4 100644 --- a/forge-core/src/main/java/forge/util/ItemPool.java +++ b/forge-core/src/main/java/forge/util/ItemPool.java @@ -70,15 +70,15 @@ public static ItemPool Collector> collector(Class cls) { - return new Collector, ItemPool>() { + public static Collector> collector(Class cls) { + return new Collector, ItemPool>() { @Override public Supplier> supplier() { return () -> new ItemPool(cls); } @Override - public BiConsumer, InventoryItem> accumulator() { + public BiConsumer, T> accumulator() { return (pool, item) -> { if (cls.isInstance(item)) pool.add(cls.cast(item), 1); }; From f636910ebbb4a1b813be7f92ea4c0a99b8a83cda Mon Sep 17 00:00:00 2001 From: Jetz Date: Wed, 25 Sep 2024 09:01:46 -0400 Subject: [PATCH 53/68] Guava migration - Rename `StreamUtils` -> `StreamUtil` for consistency --- forge-ai/src/main/java/forge/ai/ComputerUtil.java | 2 +- .../java/forge/deck/generation/DeckGeneratorBase.java | 2 +- forge-core/src/main/java/forge/item/SealedProduct.java | 4 ++-- .../forge/util/{StreamUtils.java => StreamUtil.java} | 4 ++-- .../game/ability/effects/ChooseCardNameEffect.java | 2 +- .../java/forge/game/ability/effects/PlayEffect.java | 2 +- .../forge/screens/deckeditor/controllers/CDeckgen.java | 4 ++-- forge-gui/src/main/java/forge/deck/DeckgenUtil.java | 6 +++--- .../java/forge/gamemodes/quest/QuestUtilCards.java | 10 +++++----- 9 files changed, 18 insertions(+), 18 deletions(-) rename forge-core/src/main/java/forge/util/{StreamUtils.java => StreamUtil.java} (98%) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index 70b59bfba78..aceccc32aab 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -2452,7 +2452,7 @@ public static CardCollection getCardsToDiscardFromOpponent(Player chooser, Playe if (minDiff > 0) { List choices = validCards.stream() .filter(((Predicate) goodChoices::contains).negate()) - .collect(StreamUtils.random(minDiff)); + .collect(StreamUtil.random(minDiff)); goodChoices.addAll(choices); return goodChoices; } diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index 99d93a14fec..95a51c22ca2 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -238,7 +238,7 @@ else if (actualSize > targetSize) { for (int i = 0; i < 3 && actualSize > targetSize; i++) { List toRemove = tDeck.toFlatList().stream() .filter(PaperCardPredicates.NOT_BASIC_LAND) - .collect(StreamUtils.random(actualSize - targetSize)); + .collect(StreamUtil.random(actualSize - targetSize)); tDeck.removeAllFlat(toRemove); for (PaperCard c : toRemove) { diff --git a/forge-core/src/main/java/forge/item/SealedProduct.java b/forge-core/src/main/java/forge/item/SealedProduct.java index 19b58de9ddb..bf68e1dcbfc 100644 --- a/forge-core/src/main/java/forge/item/SealedProduct.java +++ b/forge-core/src/main/java/forge/item/SealedProduct.java @@ -20,7 +20,7 @@ import forge.StaticData; import forge.item.generation.BoosterGenerator; -import forge.util.StreamUtils; +import forge.util.StreamUtil; import java.util.ArrayList; import java.util.List; @@ -112,6 +112,6 @@ protected List getRandomBasicLands(final String setCode, final int co return StaticData.instance().getCommonCards().streamAllCards() .filter(PaperCardPredicates.printedInSet(setCode)) .filter(PaperCardPredicates.IS_BASIC_LAND) - .collect(StreamUtils.random(count)); + .collect(StreamUtil.random(count)); } } diff --git a/forge-core/src/main/java/forge/util/StreamUtils.java b/forge-core/src/main/java/forge/util/StreamUtil.java similarity index 98% rename from forge-core/src/main/java/forge/util/StreamUtils.java rename to forge-core/src/main/java/forge/util/StreamUtil.java index f112ba1b3f5..c53a41cb239 100644 --- a/forge-core/src/main/java/forge/util/StreamUtils.java +++ b/forge-core/src/main/java/forge/util/StreamUtil.java @@ -5,9 +5,9 @@ import java.util.stream.Collector; import java.util.stream.Stream; -public class StreamUtils { +public class StreamUtil { - private StreamUtils(){} + private StreamUtil(){} /** * Reduces a stream to a random element of the stream. Used with {@link Stream#collect}. diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java index 866a5e8f8ff..6d69708fce7 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardNameEffect.java @@ -132,7 +132,7 @@ public void resolve(SpellAbility sa) { } if (randomChoice) { chosen = StaticData.instance().getCommonCards().streamAllFaces() - .filter(cpp).collect(StreamUtils.random()).get() + .filter(cpp).collect(StreamUtil.random()).get() .getName(); } else { chosen = p.getController().chooseCardName(sa, cpp, valid, message); diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java index 790cb14caf3..22da1e33deb 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java @@ -130,7 +130,7 @@ public void resolve(final SpellAbility sa) { final CardCollection choice = new CardCollection(); final String num = sa.getParamOrDefault("RandomNum", "1"); int nCopied = AbilityUtils.calculateAmount(source, num, sa); - for (PaperCard cp : cards.collect(StreamUtils.random(nCopied))) { + for (PaperCard cp : cards.collect(StreamUtil.random(nCopied))) { final Card possibleCard = Card.fromPaperCard(cp, sa.getActivatingPlayer()); if (sa.getActivatingPlayer().isAI() && possibleCard.getRules() != null && possibleCard.getRules().getAiHints().getRemAIDecks()) continue; diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java index c71c37596f9..19d9f63f93c 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CDeckgen.java @@ -21,7 +21,7 @@ import forge.screens.deckeditor.CDeckEditorUI; import forge.screens.deckeditor.SEditorIO; import forge.screens.deckeditor.views.VDeckgen; -import forge.util.StreamUtils; +import forge.util.StreamUtil; import java.util.List; @@ -70,7 +70,7 @@ private void newRandomCon List randomCards = FModel.getMagicDb().getCommonCards().streamUniqueCards() .filter(PaperCardPredicates.NOT_BASIC_LAND) - .collect(StreamUtils.random(15 * 5)); + .collect(StreamUtil.random(15 * 5)); randomDeck.getMain().addAllFlat(randomCards); for(final String landName : MagicColor.Constant.BASIC_LANDS) { diff --git a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java index 55b8755a87a..af7ef6bca92 100644 --- a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java +++ b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java @@ -465,7 +465,7 @@ public static Deck getRandomOrPreconOrThemeDeck(String colors, boolean forAi, bo if (!selection.isEmpty()) deck = geneticAI.stream() .filter(deckProxy -> deckProxy.getColorIdentity().sharesColorWith(ColorSet.fromNames(colors.toCharArray()))) - .collect(StreamUtils.random()).get().getDeck(); + .collect(StreamUtil.random()).get().getDeck(); else deck = Aggregates.random(geneticAI).getDeck(); @@ -474,7 +474,7 @@ public static Deck getRandomOrPreconOrThemeDeck(String colors, boolean forAi, bo if (!selection.isEmpty() && selection.size() < 4) predicate = predicate.and(deckProxy -> deckProxy.getColorIdentity().hasAllColors(ColorSet.fromNames(colors.toCharArray()).getColor())); List source = isTheme ? advThemes : advPrecons; - deck = source.stream().filter(predicate).collect(StreamUtils.random()).get().getDeck(); + deck = source.stream().filter(predicate).collect(StreamUtil.random()).get().getDeck(); } } catch (Exception e) { e.printStackTrace(); @@ -659,7 +659,7 @@ public static Deck generateCommanderDeck(boolean forAi, GameType gameType) { .filter(format.isLegalCardPredicate()) .filter(format.isLegalCommanderPredicate()) .filter(PaperCardPredicates.fromRules(canPlay)) - .collect(StreamUtils.random()).get(); + .collect(StreamUtil.random()).get(); return generateRandomCommanderDeck(commander, format, forAi, false); } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java index b0eef4b10d5..cd3255c0a9e 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java @@ -223,7 +223,7 @@ public PaperCard addRandomRare() { Stream pool = getQuestCardPool(); final PaperCard card = pool .filter(applyFormatFilter(PaperCardPredicates.IS_RARE_OR_MYTHIC)) - .collect(StreamUtils.random()).get(); + .collect(StreamUtil.random()).get(); addSingleCard(card, 1); return card; @@ -239,7 +239,7 @@ public PaperCard addRandomRare() { */ public List addRandomCards(final int n, Predicate predicate) { Stream pool = getQuestCardPool(); - final List newCards = pool.filter(predicate).collect(StreamUtils.random(n)); + final List newCards = pool.filter(predicate).collect(StreamUtil.random(n)); addAllCards(newCards); return newCards; @@ -560,7 +560,7 @@ private void generateTournamentsInShop(final int count) { .filter(CardEdition.Predicates.HAS_TOURNAMENT_PACK) .filter(isLegalInQuestFormat(questController.getFormat())) .map(TournamentPack::fromSet) - .collect(StreamUtils.random(count)); + .collect(StreamUtil.random(count)); questAssets.getShopList().addAllOfTypeFlat(packs); } @@ -575,7 +575,7 @@ private void generateFatPacksInShop(final int count) { .filter(CardEdition.Predicates.HAS_FAT_PACK) .filter(isLegalInQuestFormat(questController.getFormat())) .map(FatPack::fromSet) - .collect(StreamUtils.random(count)); + .collect(StreamUtil.random(count)); questAssets.getShopList().addAllOfTypeFlat(packs); } @@ -625,7 +625,7 @@ private void generatePreconsInShop(final int count) { } final List decks = QuestController.getPrecons().stream() .filter(formatFilter) - .collect(StreamUtils.random(count)); + .collect(StreamUtil.random(count)); questAssets.getShopList().addAllOfTypeFlat(decks); } From 0278f5817b5cc70c64212de38731523295a00684 Mon Sep 17 00:00:00 2001 From: Jetz Date: Wed, 25 Sep 2024 09:26:41 -0400 Subject: [PATCH 54/68] Guava migration - Create `IterableUtil` to house iterable helper methods dependent on Java predicates --- .../java/forge/ai/AiAttackController.java | 6 +- .../src/main/java/forge/ai/AiController.java | 2 +- .../main/java/forge/ai/ComputerUtilCard.java | 24 +++--- .../java/forge/ai/ComputerUtilCombat.java | 3 +- .../main/java/forge/ai/ComputerUtilCost.java | 4 +- .../java/forge/ai/PlayerControllerAi.java | 4 +- .../src/main/java/forge/ai/SpecialCardAi.java | 6 +- .../java/forge/ai/ability/ChooseCardAi.java | 3 +- .../ai/ability/CountersProliferateAi.java | 6 +- .../java/forge/ai/ability/CountersPutAi.java | 3 +- .../main/java/forge/ai/ability/ManaAi.java | 4 +- .../main/java/forge/ai/ability/RepeatAi.java | 6 +- .../src/main/java/forge/card/CardEdition.java | 5 +- .../java/forge/card/CardRulesPredicates.java | 2 +- .../src/main/java/forge/card/CardType.java | 3 +- .../src/main/java/forge/card/DeckHints.java | 3 +- .../forge/deck/generation/DeckGenPool.java | 4 +- .../deck/generation/DeckGeneratorBase.java | 8 +- .../item/generation/BoosterGenerator.java | 18 ++-- .../item/generation/UnOpenedProduct.java | 4 +- .../main/java/forge/util/IterableUtil.java | 83 +++++++++++++++++++ .../src/main/java/forge/util/Iterables.java | 53 ------------ .../src/main/java/forge/util/Predicates.java | 17 ---- .../java/forge/util/storage/StorageBase.java | 4 +- forge-game/src/main/java/forge/game/Game.java | 2 +- .../src/main/java/forge/game/GameAction.java | 4 +- .../main/java/forge/game/GameEntityView.java | 3 +- .../src/main/java/forge/game/GameFormat.java | 4 +- .../java/forge/game/ability/AbilityUtils.java | 20 ++--- .../ability/effects/ChooseGenericEffect.java | 7 +- .../game/ability/effects/CloneEffect.java | 8 +- .../ability/effects/CopyPermanentEffect.java | 6 +- .../effects/CopySpellAbilityEffect.java | 7 +- .../ability/effects/DamageDealEffect.java | 7 +- .../game/ability/effects/EffectEffect.java | 4 +- .../game/ability/effects/MakeCardEffect.java | 7 +- .../game/ability/effects/PlayEffect.java | 2 +- .../ability/effects/RepeatEachEffect.java | 6 +- .../main/java/forge/game/card/CardLists.java | 15 ++-- .../java/forge/game/card/CardPredicates.java | 4 +- .../java/forge/game/card/CardProperty.java | 3 +- .../main/java/forge/game/card/CardState.java | 3 +- .../main/java/forge/game/card/CardView.java | 4 +- .../java/forge/game/card/CardZoneTable.java | 3 +- .../forge/game/combat/AttackConstraints.java | 3 +- .../main/java/forge/game/combat/Combat.java | 10 +-- .../forge/game/mana/ManaCostBeingPaid.java | 7 +- .../main/java/forge/game/player/Player.java | 4 +- .../forge/game/player/PlayerCollection.java | 4 +- .../game/spellability/TargetChoices.java | 15 ++-- .../trigger/TriggerAttackersDeclared.java | 4 +- .../game/trigger/TriggerChangesZone.java | 4 +- .../game/trigger/TriggerPhaseOutAll.java | 4 +- .../forge/game/trigger/TriggerTapAll.java | 4 +- .../game/trigger/TriggerTokenCreatedOnce.java | 4 +- .../main/java/forge/game/zone/MagicStack.java | 6 +- .../java/forge/itemmanager/ItemManager.java | 6 +- .../itemmanager/filters/CardCMCFilter.java | 4 +- .../itemmanager/filters/CardTypeFilter.java | 4 +- .../deckeditor/AddBasicLandsDialog.java | 4 +- .../deckeditor/controllers/ACEditorBase.java | 7 +- .../test/java/forge/card/LegacyCardDb.java | 4 +- .../src/forge/adventure/data/RewardData.java | 7 +- .../src/forge/adventure/util/CardUtil.java | 3 +- .../src/forge/deck/AddBasicLandsDialog.java | 7 +- .../src/forge/itemmanager/ItemManager.java | 9 +- .../itemmanager/filters/CardTypeFilter.java | 4 +- .../planarconquest/ConquestAEtherScreen.java | 2 +- .../planarconquest/ConquestPlaneSelector.java | 6 +- .../src/forge/toolbox/ListChooser.java | 7 +- .../src/main/java/forge/deck/DeckProxy.java | 4 +- .../src/main/java/forge/deck/DeckgenUtil.java | 6 +- .../java/forge/deck/RandomDeckGenerator.java | 5 +- .../forge/gamemodes/limited/BoosterDraft.java | 2 +- .../CardThemedConquestDeckBuilder.java | 4 +- .../limited/CardThemedDeckBuilder.java | 14 ++-- .../gamemodes/limited/LimitedDeckBuilder.java | 20 ++--- .../gamemodes/limited/LimitedPlayerAI.java | 4 +- .../gamemodes/limited/SealedDeckBuilder.java | 13 +-- .../match/input/InputSelectTargets.java | 2 +- .../gamemodes/net/server/FServerManager.java | 4 +- .../planarconquest/ConquestUtil.java | 7 +- .../forge/gamemodes/quest/BoosterUtils.java | 11 +-- .../forge/gamemodes/quest/QuestUtilCards.java | 2 +- .../forge/itemmanager/BooleanExpression.java | 4 +- .../java/forge/itemmanager/ColumnDef.java | 7 +- .../java/forge/itemmanager/SFilterUtil.java | 8 +- .../java/forge/player/TargetSelection.java | 6 +- 88 files changed, 327 insertions(+), 333 deletions(-) create mode 100644 forge-core/src/main/java/forge/util/IterableUtil.java delete mode 100644 forge-core/src/main/java/forge/util/Predicates.java diff --git a/forge-ai/src/main/java/forge/ai/AiAttackController.java b/forge-ai/src/main/java/forge/ai/AiAttackController.java index 185e1a3d1dc..8deb61891d0 100644 --- a/forge-ai/src/main/java/forge/ai/AiAttackController.java +++ b/forge-ai/src/main/java/forge/ai/AiAttackController.java @@ -125,7 +125,7 @@ public static List getOpponentCreatures(final Player defender) { CardCollection tappedDefenders = new CardCollection(); for (Card c : CardLists.filter(defender.getCardsIn(ZoneType.Battlefield), canAnimate)) { - for (SpellAbility sa : Iterables.filter(c.getSpellAbilities(), SpellAbilityPredicates.isApi(ApiType.Animate))) { + for (SpellAbility sa : IterableUtil.filter(c.getSpellAbilities(), SpellAbilityPredicates.isApi(ApiType.Animate))) { if (sa.usesTargeting() || !sa.getParamOrDefault("Defined", "Self").equals("Self")) { continue; } @@ -149,7 +149,7 @@ public static List getOpponentCreatures(final Player defender) { defenders.removeAll(tappedDefenders); // Transform (e.g. Incubator tokens) - for (SpellAbility sa : Iterables.filter(c.getSpellAbilities(), SpellAbilityPredicates.isApi(ApiType.SetState))) { + for (SpellAbility sa : IterableUtil.filter(c.getSpellAbilities(), SpellAbilityPredicates.isApi(ApiType.SetState))) { Card transformedCopy = ComputerUtilCombat.canTransform(c); if (transformedCopy.isCreature()) { int saCMC = sa.getPayCosts() != null && sa.getPayCosts().hasManaCost() ? @@ -1313,7 +1313,7 @@ && isEffectiveAttacker(ai, attacker, combat, defender)) { if (attackersLeft.isEmpty() || possibleDefenders.isEmpty()) { break; } - CardCollection pwDefending = new CardCollection(Iterables.filter(possibleDefenders, Card.class)); + CardCollection pwDefending = new CardCollection(IterableUtil.filter(possibleDefenders, Card.class)); if (pwDefending.isEmpty()) { // TODO for now only looks at same player as we'd have to check the others from start too //defender = new PlayerCollection(Iterables.filter(possibleDefenders, Player.class)).min(PlayerPredicates.compareByLife()); diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index 6307829cdf9..7f603a8719e 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -1544,7 +1544,7 @@ private SpellAbility getSpellAbilityToPlay() { return spellAbility.isLandAbility() || (spellAbility.getHostCard() != null && ComputerUtilCard.isCardRemAIDeck(spellAbility.getHostCard())); }); //update LivingEndPlayer - useLivingEnd = Iterables.any(player.getZone(ZoneType.Library), CardPredicates.nameEquals("Living End")); + useLivingEnd = IterableUtil.any(player.getZone(ZoneType.Library), CardPredicates.nameEquals("Living End")); SpellAbility chosenSa = chooseSpellAbilityToPlayFromList(saList, true); diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index e302932f00c..e19e39fd980 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -211,17 +211,17 @@ public static Card getBestLandAI(final Iterable list) { // Urza's Mine/Tower/Power Plant final CardCollectionView aiAvailable = nbLand.get(0).getController().getCardsIn(Arrays.asList(ZoneType.Battlefield, ZoneType.Hand)); - if (Iterables.any(list, CardPredicates.nameEquals("Urza's Mine"))) { + if (IterableUtil.any(list, CardPredicates.nameEquals("Urza's Mine"))) { if (CardLists.filter(aiAvailable, CardPredicates.nameEquals("Urza's Mine")).isEmpty()) { return CardLists.filter(nbLand, CardPredicates.nameEquals("Urza's Mine")).getFirst(); } } - if (Iterables.any(list, CardPredicates.nameEquals("Urza's Tower"))) { + if (IterableUtil.any(list, CardPredicates.nameEquals("Urza's Tower"))) { if (CardLists.filter(aiAvailable, CardPredicates.nameEquals("Urza's Tower")).isEmpty()) { return CardLists.filter(nbLand, CardPredicates.nameEquals("Urza's Tower")).getFirst(); } } - if (Iterables.any(list, CardPredicates.nameEquals("Urza's Power Plant"))) { + if (IterableUtil.any(list, CardPredicates.nameEquals("Urza's Power Plant"))) { if (CardLists.filter(aiAvailable, CardPredicates.nameEquals("Urza's Power Plant")).isEmpty()) { return CardLists.filter(nbLand, CardPredicates.nameEquals("Urza's Power Plant")).getFirst(); } @@ -354,10 +354,10 @@ public static Card getCheapestPermanentAI(Iterable all, final SpellAbility */ public static Card getBestAI(final Iterable list) { // Get Best will filter by appropriate getBest list if ALL of the list is of that type - if (Iterables.all(list, CardPredicates.CREATURES)) { + if (IterableUtil.all(list, CardPredicates.CREATURES)) { return getBestCreatureAI(list); } - if (Iterables.all(list, CardPredicates.LANDS)) { + if (IterableUtil.all(list, CardPredicates.LANDS)) { return getBestLandAI(list); } // TODO - Once we get an EvaluatePermanent this should call getBestPermanent() @@ -374,7 +374,7 @@ public static Card getBestCreatureAI(final Iterable list) { if (Iterables.size(list) == 1) { return Iterables.get(list, 0); } - return Aggregates.itemWithMax(Iterables.filter(list, CardPredicates.CREATURES), ComputerUtilCard.creatureEvaluator); + return Aggregates.itemWithMax(IterableUtil.filter(list, CardPredicates.CREATURES), ComputerUtilCard.creatureEvaluator); } /** @@ -387,7 +387,7 @@ public static Card getBestLandToPlayAI(final Iterable list) { if (Iterables.size(list) == 1) { return Iterables.get(list, 0); } - return Aggregates.itemWithMax(Iterables.filter(list, Card::hasPlayableLandFace), ComputerUtilCard.landEvaluator); + return Aggregates.itemWithMax(IterableUtil.filter(list, Card::hasPlayableLandFace), ComputerUtilCard.landEvaluator); } /** @@ -402,7 +402,7 @@ public static Card getWorstCreatureAI(final Iterable list) { if (Iterables.size(list) == 1) { return Iterables.get(list, 0); } - return Aggregates.itemWithMin(Iterables.filter(list, CardPredicates.CREATURES), ComputerUtilCard.creatureEvaluator); + return Aggregates.itemWithMin(IterableUtil.filter(list, CardPredicates.CREATURES), ComputerUtilCard.creatureEvaluator); } // This selection rates tokens higher @@ -476,21 +476,21 @@ public static Card getWorstPermanentAI(final Iterable list, final boolean return null; } - final boolean hasEnchantmants = Iterables.any(list, CardPredicates.ENCHANTMENTS); + final boolean hasEnchantmants = IterableUtil.any(list, CardPredicates.ENCHANTMENTS); if (biasEnch && hasEnchantmants) { return getCheapestPermanentAI(CardLists.filter(list, CardPredicates.ENCHANTMENTS), null, false); } - final boolean hasArtifacts = Iterables.any(list, CardPredicates.ARTIFACTS); + final boolean hasArtifacts = IterableUtil.any(list, CardPredicates.ARTIFACTS); if (biasArt && hasArtifacts) { return getCheapestPermanentAI(CardLists.filter(list, CardPredicates.ARTIFACTS), null, false); } - if (biasLand && Iterables.any(list, CardPredicates.LANDS)) { + if (biasLand && IterableUtil.any(list, CardPredicates.LANDS)) { return getWorstLand(CardLists.filter(list, CardPredicates.LANDS)); } - final boolean hasCreatures = Iterables.any(list, CardPredicates.CREATURES); + final boolean hasCreatures = IterableUtil.any(list, CardPredicates.CREATURES); if (biasCreature && hasCreatures) { return getWorstCreatureAI(CardLists.filter(list, CardPredicates.CREATURES)); } diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java index bd63ed91c50..0afca935bc1 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java @@ -42,6 +42,7 @@ import forge.game.trigger.Trigger; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; +import forge.util.IterableUtil; import forge.util.Iterables; import forge.util.MyRandom; import forge.util.TextUtil; @@ -78,7 +79,7 @@ public static void setCombatRegenTestSuppression(boolean shouldSuppress) { */ public static boolean canAttackNextTurn(final Card attacker) { final Iterable defenders = CombatUtil.getAllPossibleDefenders(attacker.getController()); - return Iterables.any(defenders, input -> canAttackNextTurn(attacker, input)); + return IterableUtil.any(defenders, input -> canAttackNextTurn(attacker, input)); } /** diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java index 68ad94b63e8..9b9415a9df0 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java @@ -20,7 +20,7 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetChoices; import forge.game.zone.ZoneType; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.MyRandom; import forge.util.TextUtil; import forge.util.collect.FCollectionView; @@ -922,7 +922,7 @@ public static int getMaxXValue(SpellAbility sa, Player ai, final boolean effect) public static CardCollection paymentChoicesWithoutTargets(Iterable choices, SpellAbility source, Player ai) { if (source.usesTargeting()) { final CardCollection targets = new CardCollection(source.getTargets().getTargetCards()); - choices = Iterables.filter(choices, CardPredicates.isController(ai).and(targets::contains).negate()); + choices = IterableUtil.filter(choices, CardPredicates.isController(ai).and(targets::contains).negate()); } return new CardCollection(choices); } diff --git a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java index 1aef3981082..5136a9e8096 100644 --- a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java +++ b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java @@ -696,7 +696,7 @@ public CardCollectionView chooseCardsToDelve(int genericAmount, CardCollection g @Override public CardCollectionView chooseCardsToDiscardUnlessType(int num, CardCollectionView hand, String uType, SpellAbility sa) { - Iterable cardsOfType = Iterables.filter(hand, CardPredicates.restriction(uType.split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa)); + Iterable cardsOfType = IterableUtil.filter(hand, CardPredicates.restriction(uType.split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa)); if (!Iterables.isEmpty(cardsOfType)) { Card toDiscard = Aggregates.itemWithMin(cardsOfType, Card::getCMC); return new CardCollection(toDiscard); @@ -1335,7 +1335,7 @@ public boolean chooseCardsPile(SpellAbility sa, CardCollectionView pile1, CardCo // Probably want to see if the face up pile has anything "worth it", then potentially take face down pile return pile1.size() >= pile2.size(); } else { - boolean allCreatures = Iterables.all(Iterables.concat(pile1, pile2), CardPredicates.CREATURES); + boolean allCreatures = IterableUtil.all(Iterables.concat(pile1, pile2), CardPredicates.CREATURES); int cmc1 = allCreatures ? ComputerUtilCard.evaluateCreatureList(pile1) : ComputerUtilCard.evaluatePermanentList(pile1); int cmc2 = allCreatures ? ComputerUtilCard.evaluateCreatureList(pile2) : ComputerUtilCard.evaluatePermanentList(pile2); diff --git a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java index f67ae1cfaf2..91b0457a3a8 100644 --- a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java +++ b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java @@ -384,7 +384,7 @@ public static boolean considerTargetingOpponent(final Player ai, final SpellAbil ai.getCardsIn(ZoneType.Battlefield).threadSafeIterable(), CardPredicates.hasSVar("DonateMe"))); if (donateTarget != null) { // first filter for opponents which can be targeted by SA - final Iterable oppList = Iterables.filter(ai.getOpponents(), + final Iterable oppList = IterableUtil.filter(ai.getOpponents(), PlayerPredicates.isTargetableBy(sa)); // All opponents have hexproof or something like that @@ -393,7 +393,7 @@ public static boolean considerTargetingOpponent(final Player ai, final SpellAbil } // filter for player who does not have donate target already - Iterable oppTarget = Iterables.filter(oppList, + Iterable oppTarget = IterableUtil.filter(oppList, PlayerPredicates.isNotCardInPlay(donateTarget.getName())); // fall back to previous list if (Iterables.isEmpty(oppTarget)) { @@ -1763,7 +1763,7 @@ public static boolean considerPWAbilityPriority(final Player ai, final SpellAbil // check if +1 would be sufficient if (single != null) { // TODO use better logic to find the right Deal Damage Effect? - SpellAbility ugin_burn = Iterables.find(source.getSpellAbilities(), SpellAbilityPredicates.isApi(ApiType.DealDamage), null); + SpellAbility ugin_burn = IterableUtil.find(source.getSpellAbilities(), SpellAbilityPredicates.isApi(ApiType.DealDamage), null); if (ugin_burn != null) { // basic logic copied from DamageDealAi::dealDamageChooseTgtC if (ugin_burn.canTarget(single)) { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java index 3efdce0e464..6f01a7ea4cd 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java @@ -25,6 +25,7 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.IterableUtil; import forge.util.Iterables; public class ChooseCardAi extends SpellAbilityAi { @@ -177,7 +178,7 @@ public Card chooseSingleCard(final Player ai, final SpellAbility sa, Iterable T chooseSingleEntity(Player ai, SpellAbility sa, C boolean aggroAI = (((PlayerControllerAi) ai.getController()).getAi()).getBooleanProperty(AiProps.PLAY_AGGRO); // because countertype can't be chosen anymore, only look for poison counters - for (final Player p : Iterables.filter(options, Player.class)) { + for (final Player p : IterableUtil.filter(options, Player.class)) { if (p.isOpponentOf(ai)) { if (p.getCounters(poison) > 0 && p.canReceiveCounters(poison)) { return (T)p; @@ -123,7 +123,7 @@ public T chooseSingleEntity(Player ai, SpellAbility sa, C } } - for (final Card c : Iterables.filter(options, Card.class)) { + for (final Card c : IterableUtil.filter(options, Card.class)) { // AI planeswalker always, opponent planeswalkers never if (c.isPlaneswalker()) { if (c.getController().isOpponentOf(ai)) { diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java index 95d7c5381ba..704ded794a2 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java @@ -24,6 +24,7 @@ import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.IterableUtil; import forge.util.Iterables; import forge.util.MyRandom; @@ -791,7 +792,7 @@ protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandator } } else if (sa.getTargetRestrictions().canOnlyTgtOpponent() && !sa.getTargetRestrictions().canTgtCreature()) { // can only target opponent - PlayerCollection playerList = new PlayerCollection(Iterables.filter( + PlayerCollection playerList = new PlayerCollection(IterableUtil.filter( sa.getTargetRestrictions().getAllCandidates(sa, true, true), Player.class)); if (playerList.isEmpty()) { diff --git a/forge-ai/src/main/java/forge/ai/ability/ManaAi.java b/forge-ai/src/main/java/forge/ai/ability/ManaAi.java index 5545f502dda..d5d6029f23b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ManaAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ManaAi.java @@ -29,7 +29,7 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Aggregates; -import forge.util.Iterables; +import forge.util.IterableUtil; public class ManaAi extends SpellAbilityAi { @@ -253,7 +253,7 @@ public static boolean doManaRitualLogic(Player ai, SpellAbility sa, boolean from private boolean improvesPosition(Player ai, SpellAbility sa) { boolean activateForTrigger = (!ai.getManaPool().hasBurn() || !ai.canLoseLife() || ai.cantLoseForZeroOrLessLife()) && - Iterables.any(Iterables.filter(sa.getHostCard().getTriggers(), CardTraitPredicates.hasParam("AILogic", "ActivateOnce")), + IterableUtil.any(IterableUtil.filter(sa.getHostCard().getTriggers(), CardTraitPredicates.hasParam("AILogic", "ActivateOnce")), t -> sa.getHostCard().getAbilityActivatedThisTurn(t.getOverridingAbility()) == 0); PhaseHandler ph = ai.getGame().getPhaseHandler(); diff --git a/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java b/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java index 96b7aeac972..d402cc9e37b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java @@ -12,7 +12,7 @@ import forge.game.player.PlayerCollection; import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; -import forge.util.Iterables; +import forge.util.IterableUtil; public class RepeatAi extends SpellAbilityAi { @@ -53,9 +53,9 @@ protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandator if (sa.usesTargeting()) { if (logic.startsWith("CopyBestCreature")) { Card best = null; - Iterable targetableAi = Iterables.filter(ai.getCreaturesInPlay(), CardPredicates.isTargetableBy(sa)); + Iterable targetableAi = IterableUtil.filter(ai.getCreaturesInPlay(), CardPredicates.isTargetableBy(sa)); if (!logic.endsWith("IgnoreLegendary")) { - best = ComputerUtilCard.getBestAI(Iterables.filter(targetableAi, Card::ignoreLegendRule)); + best = ComputerUtilCard.getBestAI(IterableUtil.filter(targetableAi, Card::ignoreLegendRule)); } else { best = ComputerUtilCard.getBestAI(targetableAi); } diff --git a/forge-core/src/main/java/forge/card/CardEdition.java b/forge-core/src/main/java/forge/card/CardEdition.java index 06ceed5dfb7..e440ac86ece 100644 --- a/forge-core/src/main/java/forge/card/CardEdition.java +++ b/forge-core/src/main/java/forge/card/CardEdition.java @@ -26,7 +26,6 @@ import forge.item.SealedTemplate; import forge.item.SealedTemplateWithSlots; import forge.util.*; -import forge.util.Iterables; import forge.util.storage.StorageBase; import forge.util.storage.StorageReaderBase; import forge.util.storage.StorageReaderFolder; @@ -897,12 +896,12 @@ public static class Predicates { public static final Predicate CAN_MAKE_BOOSTER = CardEdition::hasBoosterTemplate; public static CardEdition getRandomSetWithAllBasicLands(Iterable allEditions) { - return Aggregates.random(Iterables.filter(allEditions, hasBasicLands)); + return Aggregates.random(IterableUtil.filter(allEditions, hasBasicLands)); } public static CardEdition getPreferredArtEditionWithAllBasicLands() { CardDb.CardArtPreference artPreference = StaticData.instance().getCardArtPreference(); - Iterable editionsWithBasicLands = Iterables.filter( + Iterable editionsWithBasicLands = IterableUtil.filter( StaticData.instance().getEditions().getOrderedEditions(), hasBasicLands.and(artPreference::accept)); Iterator editionsIterator = editionsWithBasicLands.iterator(); diff --git a/forge-core/src/main/java/forge/card/CardRulesPredicates.java b/forge-core/src/main/java/forge/card/CardRulesPredicates.java index 8dca9022415..b4b8ffad686 100644 --- a/forge-core/src/main/java/forge/card/CardRulesPredicates.java +++ b/forge-core/src/main/java/forge/card/CardRulesPredicates.java @@ -129,7 +129,7 @@ public static Predicate hasCreatureType(final String... creatureTypes * @return the predicate */ public static Predicate hasKeyword(final String keyword) { - return card -> Iterables.any(card.getAllFaces(), cf -> cf != null && card.hasStartOfKeyword(keyword, cf)); + return card -> IterableUtil.any(card.getAllFaces(), cf -> cf != null && card.hasStartOfKeyword(keyword, cf)); } /** diff --git a/forge-core/src/main/java/forge/card/CardType.java b/forge-core/src/main/java/forge/card/CardType.java index 0cc9727153a..a38d0872a4e 100644 --- a/forge-core/src/main/java/forge/card/CardType.java +++ b/forge-core/src/main/java/forge/card/CardType.java @@ -20,6 +20,7 @@ import java.util.*; import java.util.function.Predicate; +import forge.util.IterableUtil; import forge.util.Iterables; import org.apache.commons.lang3.EnumUtils; import org.apache.commons.lang3.NotImplementedException; @@ -631,7 +632,7 @@ else if (!newType.subtypes.isEmpty()) { } // remove specific creature types from all creature types if (ct.getRemoveType() != null && newType.allCreatureTypes) { - newType.excludedCreatureSubtypes.addAll(Lists.newArrayList(Iterables.filter(ct.getRemoveType(), Predicates.IS_CREATURE_TYPE))); + newType.excludedCreatureSubtypes.addAll(Lists.newArrayList(IterableUtil.filter(ct.getRemoveType(), Predicates.IS_CREATURE_TYPE))); } } // sanisfy subtypes diff --git a/forge-core/src/main/java/forge/card/DeckHints.java b/forge-core/src/main/java/forge/card/DeckHints.java index 9f3a3bc43bc..0e617d55535 100644 --- a/forge-core/src/main/java/forge/card/DeckHints.java +++ b/forge-core/src/main/java/forge/card/DeckHints.java @@ -4,6 +4,7 @@ import java.util.function.Function; import java.util.function.Predicate; +import forge.util.IterableUtil; import forge.util.Iterables; import org.apache.commons.lang3.tuple.Pair; @@ -203,7 +204,7 @@ private Iterable getMatchingItems(Iterable source, Predica // TODO should token generators be counted differently for their potential? // And would there ever be a circumstance where `fn` should be anything but PaperCard::getRules? Predicate predicate1 = tokens ? rulesWithTokens(predicate) : predicate; - return Iterables.filter(source, x -> predicate1.test(fn.apply(x))); + return IterableUtil.filter(source, x -> predicate1.test(fn.apply(x))); } public static Predicate rulesWithTokens(final Predicate predicate) { diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java b/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java index 188c409ed53..211efffb820 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java @@ -6,7 +6,7 @@ import forge.item.PaperCard; import forge.item.PaperCardPredicates; -import forge.util.Iterables; +import forge.util.IterableUtil; public class DeckGenPool implements IDeckGenPool { private final Map cards = new HashMap<>(); @@ -64,6 +64,6 @@ public Iterable getAllCards() { @Override public Iterable getAllCards(Predicate filter) { - return Iterables.filter(getAllCards(), filter); + return IterableUtil.filter(getAllCards(), filter); } } diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java index 95a51c22ca2..eb16174359c 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorBase.java @@ -87,13 +87,13 @@ protected void addCreaturesAndSpells(int size, List cards = selectCardsOfMatchingColorForPlayer(forAi); // build subsets based on type - final Iterable creatures = Iterables.filter(cards, PaperCardPredicates.IS_CREATURE); + final Iterable creatures = IterableUtil.filter(cards, PaperCardPredicates.IS_CREATURE); final int creatCnt = (int) Math.ceil(getCreaturePercentage() * size); trace.append("Creatures to add:").append(creatCnt).append("\n"); addCmcAdjusted(creatures, creatCnt, cmcLevels); Predicate preSpells = PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_CREATURE_SPELL); - final Iterable spells = Iterables.filter(cards, preSpells); + final Iterable spells = IterableUtil.filter(cards, preSpells); final int spellCnt = (int) Math.ceil(getSpellPercentage() * size); trace.append("Spells to add:").append(spellCnt).append("\n"); addCmcAdjusted(spells, spellCnt, cmcLevels); @@ -261,7 +261,7 @@ protected void addCmcAdjusted(Iterable source, int cnt, List pair : cmcLevels) { - Iterable matchingCards = Iterables.filter(source, PaperCardPredicates.fromRules(pair.getLeft())); + Iterable matchingCards = IterableUtil.filter(source, PaperCardPredicates.fromRules(pair.getLeft())); int cmcCountForPool = (int) Math.ceil(pair.getRight() * desiredOverTotal); int addOfThisCmc = Math.round(pair.getRight() * requestedOverTotal); @@ -291,7 +291,7 @@ protected Iterable selectCardsOfMatchingColorForPlayer(boolean forAi) if (useArtifacts) { hasColor = hasColor.or(COLORLESS_CARDS); } - return Iterables.filter(pool.getAllCards(), PaperCardPredicates.fromRules(canPlay.and(hasColor).and(canUseInFormat))); + return IterableUtil.filter(pool.getAllCards(), PaperCardPredicates.fromRules(canPlay.and(hasColor).and(canUseInFormat))); } protected static Map countLands(ItemPool outList) { diff --git a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java index 82881adbf4e..7d0d2a11fde 100644 --- a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java +++ b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java @@ -614,35 +614,35 @@ public static PrintSheet makeSheet(String sheetKey, Iterable src) { if (null == mainCode || mainCode.equalsIgnoreCase(BoosterSlots.ANY)) { // no restriction on rarity Predicate predicate = setPred.and(extraPred); - ps.addAll(Iterables.filter(src, predicate)); + ps.addAll(IterableUtil.filter(src, predicate)); } else if (mainCode.equalsIgnoreCase(BoosterSlots.UNCOMMON_RARE)) { // for sets like ARN, where U1 cards are considered rare and U3 are uncommon Predicate predicateRares = setPred.and(PaperCardPredicates.IS_RARE).and(extraPred); - ps.addAll(Iterables.filter(src, predicateRares)); + ps.addAll(IterableUtil.filter(src, predicateRares)); Predicate predicateUncommon = setPred.and(PaperCardPredicates.IS_UNCOMMON).and(extraPred); - ps.addAll(Iterables.filter(src, predicateUncommon), 3); + ps.addAll(IterableUtil.filter(src, predicateUncommon), 3); } else if (mainCode.equalsIgnoreCase(BoosterSlots.RARE_MYTHIC)) { // Typical ratio of rares to mythics is 53:15, changing to 35:10 in smaller sets. // To achieve the desired 1:8 are all mythics are added once, and all rares added twice per print sheet. Predicate predicateMythic = setPred.and(PaperCardPredicates.IS_MYTHIC_RARE).and(extraPred); - ps.addAll(Iterables.filter(src, predicateMythic)); + ps.addAll(IterableUtil.filter(src, predicateMythic)); Predicate predicateRare = setPred.and(PaperCardPredicates.IS_RARE).and(extraPred); - ps.addAll(Iterables.filter(src, predicateRare), 2); + ps.addAll(IterableUtil.filter(src, predicateRare), 2); } else if (mainCode.equalsIgnoreCase(BoosterSlots.UNCOMMON_RARE_MYTHIC)) { // Extended version of RARE_MYTHIC, used for Alchemy slots Predicate predicateMythic = setPred.and(PaperCardPredicates.IS_MYTHIC_RARE).and(extraPred); - ps.addAll(Iterables.filter(src, predicateMythic)); + ps.addAll(IterableUtil.filter(src, predicateMythic)); Predicate predicateRare = setPred.and(PaperCardPredicates.IS_RARE).and(extraPred); - ps.addAll(Iterables.filter(src, predicateRare), 2); + ps.addAll(IterableUtil.filter(src, predicateRare), 2); Predicate predicateUncommon = setPred.and(PaperCardPredicates.IS_UNCOMMON).and(extraPred); - ps.addAll(Iterables.filter(src, predicateUncommon), 4); + ps.addAll(IterableUtil.filter(src, predicateUncommon), 4); } else { throw new IllegalArgumentException("Booster generator: operator could not be parsed - " + mainCode); } @@ -734,7 +734,7 @@ private static Predicate buildExtraPredicate(List operators) return x -> true; } - return Predicates.and(conditions); + return IterableUtil.and(conditions); } } diff --git a/forge-core/src/main/java/forge/item/generation/UnOpenedProduct.java b/forge-core/src/main/java/forge/item/generation/UnOpenedProduct.java index f7062a8b3da..86a79a1d2ce 100644 --- a/forge-core/src/main/java/forge/item/generation/UnOpenedProduct.java +++ b/forge-core/src/main/java/forge/item/generation/UnOpenedProduct.java @@ -5,7 +5,7 @@ import forge.item.PaperCard; import forge.item.SealedTemplate; import forge.util.ItemPool; -import forge.util.Iterables; +import forge.util.IterableUtil; import org.apache.commons.lang3.tuple.Pair; import java.util.ArrayList; @@ -47,7 +47,7 @@ public UnOpenedProduct(SealedTemplate template, Iterable cards) { } public UnOpenedProduct(SealedTemplate sealedProductTemplate, Predicate filterPrinted) { - this(sealedProductTemplate, Iterables.filter(StaticData.instance().getCommonCards().getAllCards(), filterPrinted)); + this(sealedProductTemplate, IterableUtil.filter(StaticData.instance().getCommonCards().getAllCards(), filterPrinted)); } private void prebuildSheets(Iterable sourceList) { diff --git a/forge-core/src/main/java/forge/util/IterableUtil.java b/forge-core/src/main/java/forge/util/IterableUtil.java new file mode 100644 index 00000000000..f52e0a4e69d --- /dev/null +++ b/forge-core/src/main/java/forge/util/IterableUtil.java @@ -0,0 +1,83 @@ +package forge.util; + +import java.util.Collection; +import java.util.Optional; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.StreamSupport; + +/** + * Provides helper methods for Iterables and Predicates similar + * to the Guava library, but supporting Java 8's implementation + * of Predicates instead. + */ +public class IterableUtil { + + + /** + * Merges a collection of predicates into a single predicate, + * which requires the subject to match each of the component predicates. + */ + public static Predicate and(Iterable> components) { + return x -> all(components, i -> i.test(x)); + } + + /** + * Merges a collection of predicates into a single predicate, + * which requires the subject to match at least one of the component predicates. + */ + public static Predicate or(Iterable> components) { + return x -> any(components, i -> i.test(x)); + } + + public static Iterable filter(Iterable iterable, Predicate filter) { + return () -> StreamSupport.stream(iterable.spliterator(), false).filter(filter).iterator(); + } + + public static Iterable filter(Collection iterable, Predicate filter) { + return () -> iterable.stream().filter(filter).iterator(); + } + + public static Iterable filter(final Iterable iterable, final Class desiredType) { + return () -> StreamSupport.stream(iterable.spliterator(), false) + .filter(desiredType::isInstance) + .map(desiredType::cast) + .iterator(); + } + + public static boolean any(Iterable iterable, Predicate test) { + return StreamSupport.stream(iterable.spliterator(), false).anyMatch(test); + } + + public static boolean all(Iterable iterable, Predicate test) { + return StreamSupport.stream(iterable.spliterator(), false).allMatch(test); + } + + @SuppressWarnings("OptionalGetWithoutIsPresent") + public static T find(Iterable iterable, Predicate predicate) { + return StreamSupport.stream(iterable.spliterator(), false).filter(predicate).findFirst().get(); + } + + public static T find(Iterable iterable, Predicate predicate, T defaultValue) { + return StreamSupport.stream(iterable.spliterator(), false).filter(predicate).findFirst().orElse(defaultValue); + } + + public static Optional tryFind(Iterable iterable, Predicate predicate) { + return StreamSupport.stream(iterable.spliterator(), false).filter(predicate).findFirst(); + } + + public static int indexOf(Iterable iterable, Predicate predicate) { + int index = 0; + for(T i : iterable) { + if(predicate.test(i)) + return index; + index++; + } + return -1; + } + + public static Iterable transform(final Iterable iterable, final Function function) { + //Should probably also be ? extends T in the function type + return () -> StreamSupport.stream(iterable.spliterator(), false).map(function).iterator(); + } +} diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index 22328230401..02f1d2e0721 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -1,10 +1,6 @@ package forge.util; import java.util.Collection; -import java.util.Optional; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.stream.StreamSupport; /** * Provides helper methods for Iterables similar to the Guava library, @@ -13,55 +9,6 @@ public class Iterables { private Iterables(){} - //TODO: Migrate everything below. - - public static Iterable filter(Iterable iterable, Predicate filter) { - return () -> StreamSupport.stream(iterable.spliterator(), false).filter(filter).iterator(); - } - public static Iterable filter(Collection iterable, Predicate filter) { - return () -> iterable.stream().filter(filter).iterator(); - } - public static Iterable filter(final Iterable iterable, final Class desiredType) { - return () -> StreamSupport.stream(iterable.spliterator(), false) - .filter(desiredType::isInstance) - .map(desiredType::cast) - .iterator(); - } - - public static boolean any(Iterable iterable, Predicate test) { - return StreamSupport.stream(iterable.spliterator(), false).anyMatch(test); - } - - public static boolean all(Iterable iterable, Predicate test) { - return StreamSupport.stream(iterable.spliterator(), false).allMatch(test); - } - - @SuppressWarnings("OptionalGetWithoutIsPresent") - public static T find(Iterable iterable, Predicate predicate) { - return StreamSupport.stream(iterable.spliterator(), false).filter(predicate).findFirst().get(); - } - public static T find(Iterable iterable, Predicate predicate, T defaultValue) { - return StreamSupport.stream(iterable.spliterator(), false).filter(predicate).findFirst().orElse(defaultValue); - } - public static Optional tryFind(Iterable iterable, Predicate predicate) { - return StreamSupport.stream(iterable.spliterator(), false).filter(predicate).findFirst(); - } - - public static int indexOf(Iterable iterable, Predicate predicate) { - int index = 0; - for(T i : iterable) { - if(predicate.test(i)) - return index; - index++; - } - return -1; - } - - public static Iterable transform(final Iterable iterable, final Function function) { - //Should probably also be ? extends T in the function type - return () -> StreamSupport.stream(iterable.spliterator(), false).map(function).iterator(); - } - //TODO: Restore everything below public static Iterable unmodifiableIterable(final Iterable iterable) { return com.google.common.collect.Iterables.unmodifiableIterable(iterable); diff --git a/forge-core/src/main/java/forge/util/Predicates.java b/forge-core/src/main/java/forge/util/Predicates.java deleted file mode 100644 index 32938b844d1..00000000000 --- a/forge-core/src/main/java/forge/util/Predicates.java +++ /dev/null @@ -1,17 +0,0 @@ -package forge.util; - -import java.util.function.Predicate; - -public class Predicates { - private Predicates(){} - - //TODO: Migrate everything below. - public static Predicate and(Iterable> components) { - //TODO: Should be able to clean up the casting here. - return x -> Iterables.all(components, (Predicate>) i -> i.test(x)); - } - public static Predicate or(Iterable> components) { - //TODO: Should be able to clean up the casting here. - return x -> Iterables.any(components, (Predicate>) i -> i.test(x)); - } -} diff --git a/forge-core/src/main/java/forge/util/storage/StorageBase.java b/forge-core/src/main/java/forge/util/storage/StorageBase.java index 3683047181d..1ae5226f6c3 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageBase.java +++ b/forge-core/src/main/java/forge/util/storage/StorageBase.java @@ -18,7 +18,7 @@ package forge.util.storage; import forge.util.IItemReader; -import forge.util.Iterables; +import forge.util.IterableUtil; import java.io.File; import java.io.FilenameFilter; @@ -83,7 +83,7 @@ public int size() { @Override public T find(Predicate condition) { - return Iterables.tryFind(map.values(), condition).orElse(null); + return IterableUtil.tryFind(map.values(), condition).orElse(null); } @Override diff --git a/forge-game/src/main/java/forge/game/Game.java b/forge-game/src/main/java/forge/game/Game.java index f92b788ef8b..d4da6bdc15a 100644 --- a/forge-game/src/main/java/forge/game/Game.java +++ b/forge-game/src/main/java/forge/game/Game.java @@ -1100,7 +1100,7 @@ public Multimap chooseCardsForAnte(final boolean matchRarity) { private void chooseRandomCardsForAnte(final Player player, final Multimap anteed) { final CardCollectionView lib = player.getCardsIn(ZoneType.Library); Predicate goodForAnte = CardPredicates.BASIC_LANDS.negate(); - Card ante = Aggregates.random(Iterables.filter(lib, goodForAnte)); + Card ante = Aggregates.random(IterableUtil.filter(lib, goodForAnte)); if (ante == null) { getGameLog().add(GameLogEntryType.ANTE, "Only basic lands found. Will ante one of them"); ante = Aggregates.random(lib); diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index a6e7ccb9c9a..7b2743b4396 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -796,14 +796,14 @@ private Card moveTo(final Zone zoneTo, Card c, Integer position, SpellAbility ca if (!stAb.hasParam("ValidAttacker") || (stAb.hasParam("ValidBlocker") && stAb.getParam("ValidBlocker").equals("Creature.Self"))) { continue; } - for (Card creature : Iterables.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.CREATURES)) { + for (Card creature : IterableUtil.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.CREATURES)) { if (stAb.matchesValidParam("ValidAttacker", creature)) { creature.updateAbilityTextForView(); } } } if (stAb.checkMode(StaticAbilityCantAttackBlock.MinMaxBlockerMode)) { - for (Card creature : Iterables.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.CREATURES)) { + for (Card creature : IterableUtil.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.CREATURES)) { if (stAb.matchesValidParam("ValidCard", creature)) { creature.updateAbilityTextForView(); } diff --git a/forge-game/src/main/java/forge/game/GameEntityView.java b/forge-game/src/main/java/forge/game/GameEntityView.java index 64ade841f4e..90ccca22323 100644 --- a/forge-game/src/main/java/forge/game/GameEntityView.java +++ b/forge-game/src/main/java/forge/game/GameEntityView.java @@ -5,6 +5,7 @@ import forge.trackable.TrackableObject; import forge.trackable.TrackableProperty; import forge.trackable.Tracker; +import forge.util.IterableUtil; import forge.util.Iterables; public abstract class GameEntityView extends TrackableObject { @@ -51,7 +52,7 @@ public void updatePreventNextDamage(GameEntity e) { public Iterable getAttachedCards() { if (hasAnyCardAttachments()) { - Iterable active = Iterables.filter(get(TrackableProperty.AttachedCards), c -> !c.isPhasedOut()); + Iterable active = IterableUtil.filter(get(TrackableProperty.AttachedCards), c -> !c.isPhasedOut()); if (!Iterables.isEmpty(active)) { return active; } diff --git a/forge-game/src/main/java/forge/game/GameFormat.java b/forge-game/src/main/java/forge/game/GameFormat.java index 10298834f56..eae9b415968 100644 --- a/forge-game/src/main/java/forge/game/GameFormat.java +++ b/forge-game/src/main/java/forge/game/GameFormat.java @@ -29,7 +29,7 @@ import forge.item.PaperCardPredicates; import forge.util.FileSection; import forge.util.FileUtil; -import forge.util.Predicates; +import forge.util.IterableUtil; import forge.util.storage.StorageBase; import forge.util.storage.StorageReaderRecursiveFolderWithUserFolder; @@ -156,7 +156,7 @@ protected Predicate buildFilter(boolean printed) { for (CardRarity cr: this.getAllowedRarities()) { crp.add(StaticData.instance().getCommonCards().wasPrintedAtRarity(cr)); } - p = p.and(Predicates.or(crp)); + p = p.and(IterableUtil.or(crp)); } if (!this.getAdditionalCards().isEmpty()) { p = p.or(PaperCardPredicates.names(this.getAdditionalCards())); diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index e01d70ea0a2..5e72902f9df 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -178,7 +178,7 @@ public static CardCollection getDefinedCards(final Card hostCard, final String d if (crd instanceof Card) { c = (Card) crd; } else if (crd instanceof Iterable) { - cards.addAll(Iterables.filter((Iterable) crd, Card.class)); + cards.addAll(IterableUtil.filter((Iterable) crd, Card.class)); } } else if (defined.contains("HostCard")) { //Triggered*HostCard @@ -194,7 +194,7 @@ else if (defined.contains("HostCard")) { //Triggered*HostCard if (crd instanceof Card) { c = game.getCardState((Card) crd); } else if (crd instanceof Iterable) { - cards.addAll(Iterables.filter((Iterable) crd, Card.class)); + cards.addAll(IterableUtil.filter((Iterable) crd, Card.class)); } } } else if (defined.startsWith("Replaced") && sa instanceof SpellAbility) { @@ -205,7 +205,7 @@ else if (defined.contains("HostCard")) { //Triggered*HostCard if (crd instanceof Card) { c = (Card) crd; } else if (crd instanceof Iterable) { - cards.addAll(Iterables.filter((Iterable) crd, Card.class)); + cards.addAll(IterableUtil.filter((Iterable) crd, Card.class)); } } else if (defined.equals("Remembered") || defined.equals("RememberedCard")) { if (!hostCard.hasRemembered()) { @@ -719,11 +719,11 @@ else if (calcX[0].startsWith("ParentTargeted")) { } else if (calcX[0].startsWith("TriggerRemembered")) { final SpellAbility root = sa.getRootAbility(); - list = Iterables.filter(root.getTriggerRemembered(), Card.class); + list = IterableUtil.filter(root.getTriggerRemembered(), Card.class); } else if (calcX[0].startsWith("TriggerObjects")) { final SpellAbility root = sa.getRootAbility(); - list = Iterables.filter((Iterable) root.getTriggeringObjects().getOrDefault( + list = IterableUtil.filter((Iterable) root.getTriggeringObjects().getOrDefault( (AbilityKey.fromString(calcX[0].substring(14))), new CardCollection()), Card.class); } // CardTriggered used to bypass AbilityKeys that could also be Player above @@ -741,7 +741,7 @@ else if (calcX[0].startsWith("Replaced")) { } if (list != null) { // there could be null inside! - list = Iterables.filter(list, Card.class); + list = IterableUtil.filter(list, Card.class); val = handlePaid(list, calcX[1], card, ability); } } @@ -1052,9 +1052,9 @@ public static PlayerCollection getDefinedPlayers(final Card card, final String d o = ((SpellAbility) c).getActivatingPlayer(); } else if (c instanceof Iterable) { // For merged permanent if (orCont) { - addPlayer(Iterables.filter((Iterable)c, Player.class), "", players); + addPlayer(IterableUtil.filter((Iterable)c, Player.class), "", players); } - addPlayer(Iterables.filter((Iterable)c, Card.class), "Controller", players); + addPlayer(IterableUtil.filter((Iterable)c, Card.class), "Controller", players); } } else if (defParsed.endsWith("Opponent")) { String triggeringType = defParsed.substring(9); @@ -1091,7 +1091,7 @@ public static PlayerCollection getDefinedPlayers(final Card card, final String d players.add((Player) o); } if (o instanceof Iterable) { - players.addAll(Iterables.filter((Iterable)o, Player.class)); + players.addAll(IterableUtil.filter((Iterable)o, Player.class)); } } } else if (defined.startsWith("OppNon")) { @@ -3679,7 +3679,7 @@ public static int objectXCount(final List objects, final String s, final Card } if (s.startsWith("Valid")) { - return handlePaid(Iterables.filter(objects, Card.class), s, source, ctb); + return handlePaid(IterableUtil.filter(objects, Card.class), s, source, ctb); } int n = s.startsWith("Amount") ? objects.size() : 0; diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChooseGenericEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChooseGenericEffect.java index 52b3f725a7b..c42033864e3 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChooseGenericEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChooseGenericEffect.java @@ -16,10 +16,7 @@ import forge.game.GameEntityCounterTable; import forge.game.player.Player; import forge.game.spellability.SpellAbility; -import forge.util.Aggregates; -import forge.util.Iterables; -import forge.util.Lang; -import forge.util.Localizer; +import forge.util.*; public class ChooseGenericEffect extends SpellAbilityEffect { @@ -106,7 +103,7 @@ public void resolve(SpellAbility sa) { chosenSAs = p.getController().chooseSpellAbilitiesForEffect(abilities, sa, prompt, amount, ImmutableMap.of()); } - List oldRem = Lists.newArrayList(Iterables.filter(host.getRemembered(), Player.class)); + List oldRem = Lists.newArrayList(IterableUtil.filter(host.getRemembered(), Player.class)); if (tempRem) { host.removeRemembered(oldRem); host.addRemembered(p); // currently we only ever need the Chooser, may need more support later diff --git a/forge-game/src/main/java/forge/game/ability/effects/CloneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CloneEffect.java index 312d9e9bdec..2f3d6699fe2 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CloneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CloneEffect.java @@ -12,7 +12,7 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.CardTranslation; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.Localizer; import forge.util.collect.FCollection; @@ -179,9 +179,9 @@ public void run() { cloneCard.clearImprintedCards(); cloneCard.clearRemembered(); // restore original Remembered and Imprinted, ignore cards from players who lost - cloneCard.addImprintedCards(Iterables.filter(clonedImprinted, CardPredicates.ownerLives())); - cloneCard.addRemembered(Iterables.filter(clonedRemembered, Player.class)); - cloneCard.addRemembered(Iterables.filter(Iterables.filter(clonedRemembered, Card.class), CardPredicates.ownerLives())); + cloneCard.addImprintedCards(IterableUtil.filter(clonedImprinted, CardPredicates.ownerLives())); + cloneCard.addRemembered(IterableUtil.filter(clonedRemembered, Player.class)); + cloneCard.addRemembered(IterableUtil.filter(IterableUtil.filter(clonedRemembered, Card.class), CardPredicates.ownerLives())); cloneCard.updateStateForView(); game.fireEvent(new GameEventCardStatsChanged(cloneCard)); } diff --git a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java index fe95aeb158b..11b157968e8 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CopyPermanentEffect.java @@ -157,11 +157,11 @@ public void resolve(final SpellAbility sa) { "X", Integer.toString(AbilityUtils.calculateAmount(host, "X", sa))); } if (StringUtils.containsIgnoreCase(valid, "creature")) { - cards = Iterables.filter(cards, PaperCardPredicates.IS_CREATURE); + cards = IterableUtil.filter(cards, PaperCardPredicates.IS_CREATURE); } if (StringUtils.containsIgnoreCase(valid, "equipment")) { Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.IS_EQUIPMENT); - cards = Iterables.filter(cards, cpp); + cards = IterableUtil.filter(cards, cpp); } if (sa.hasParam("RandomCopied")) { List copysource = Lists.newArrayList(cards); @@ -194,7 +194,7 @@ public void resolve(final SpellAbility sa) { } Predicate cpp = PaperCardPredicates.fromRules(CardRulesPredicates.name(StringOp.EQUALS, name)); - cards = Lists.newArrayList(Iterables.filter(cards, cpp)); + cards = Lists.newArrayList(IterableUtil.filter(cards, cpp)); if (!cards.isEmpty()) { tgtCards.add(Card.fromPaperCard(cards.get(0), controller)); diff --git a/forge-game/src/main/java/forge/game/ability/effects/CopySpellAbilityEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CopySpellAbilityEffect.java index 645f64f3174..c51968e750e 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CopySpellAbilityEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CopySpellAbilityEffect.java @@ -15,10 +15,7 @@ import forge.game.spellability.SpellAbility; import forge.game.staticability.StaticAbilityCantBeCopied; import forge.game.zone.ZoneType; -import forge.util.CardTranslation; -import forge.util.Iterables; -import forge.util.Lang; -import forge.util.Localizer; +import forge.util.*; import forge.util.collect.FCollection; import java.util.Iterator; @@ -104,7 +101,7 @@ public void resolve(SpellAbility sa) { continue; } - FCollection all = new FCollection<>(Iterables.filter(targetedSA.getTargetRestrictions().getAllCandidates(targetedSA, true), GameObjectPredicates.restriction(sa.getParam("CopyForEachCanTarget").split(","), sa.getActivatingPlayer(), card, sa))); + FCollection all = new FCollection<>(IterableUtil.filter(targetedSA.getTargetRestrictions().getAllCandidates(targetedSA, true), GameObjectPredicates.restriction(sa.getParam("CopyForEachCanTarget").split(","), sa.getActivatingPlayer(), card, sa))); // Remove targeted players because getAllCandidates include all the valid players all.removeAll(getTargetPlayers(targetedSA)); diff --git a/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java b/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java index df40509773f..395fa8a4bc6 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java @@ -22,10 +22,7 @@ import forge.game.replacement.ReplacementType; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Aggregates; -import forge.util.Iterables; -import forge.util.Lang; -import forge.util.Localizer; +import forge.util.*; import forge.util.collect.FCollection; public class DamageDealEffect extends DamageBaseEffect { @@ -228,7 +225,7 @@ public void resolve(SpellAbility sa) { return; } - CardCollection assigneeCards = new CardCollection(Iterables.filter(tgts, Card.class)); + CardCollection assigneeCards = new CardCollection(IterableUtil.filter(tgts, Card.class)); Player assigningPlayer = players.get(0); Map map = assigningPlayer.getController().assignCombatDamage(sourceLKI, assigneeCards, null, dmg, null, true); diff --git a/forge-game/src/main/java/forge/game/ability/effects/EffectEffect.java b/forge-game/src/main/java/forge/game/ability/effects/EffectEffect.java index a6fe6f0f877..82a7dff7a91 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/EffectEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/EffectEffect.java @@ -25,7 +25,7 @@ import forge.game.trigger.Trigger; import forge.game.trigger.TriggerHandler; import forge.game.zone.ZoneType; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.TextUtil; import forge.util.collect.FCollection; @@ -88,7 +88,7 @@ public void resolve(SpellAbility sa) { if (sa.hasParam("ForgetCounter")) { CounterType cType = CounterType.getType(sa.getParam("ForgetCounter")); - rememberList = new FCollection<>(CardLists.filter(Iterables.filter(rememberList, Card.class), CardPredicates.hasCounter(cType))); + rememberList = new FCollection<>(CardLists.filter(IterableUtil.filter(rememberList, Card.class), CardPredicates.hasCounter(cType))); } // don't create Effect if there is no remembered Objects diff --git a/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java b/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java index c33eb7d3b35..bb85e022ff5 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java @@ -15,10 +15,7 @@ import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; import forge.item.*; -import forge.util.Aggregates; -import forge.util.CardTranslation; -import forge.util.Iterables; -import forge.util.Localizer; +import forge.util.*; import java.util.ArrayList; import java.util.Arrays; @@ -150,7 +147,7 @@ public void resolve(SpellAbility sa) { while (toMake > 0) { PaperCard pc; if (pack != null) { - pc = Iterables.getLast(Iterables.filter(pack, PaperCardPredicates.name(name))); + pc = Iterables.getLast(IterableUtil.filter(pack, PaperCardPredicates.name(name))); } else { pc = StaticData.instance().getCommonCards().getUniqueByName(name); } diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java index 22da1e33deb..d60f505ddd6 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java @@ -380,7 +380,7 @@ public void resolve(final SpellAbility sa) { } abCost = new Cost(source.getManaCost(), false); } else if (cost.equals("SuspendCost")) { - abCost = Iterables.find(tgtCard.getNonManaAbilities(), s -> s.isKeyword(Keyword.SUSPEND)).getPayCosts(); + abCost = IterableUtil.find(tgtCard.getNonManaAbilities(), s -> s.isKeyword(Keyword.SUSPEND)).getPayCosts(); } else { if (cost.contains("ConvertedManaCost")) { if (unpayableCost) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java b/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java index 657e5827abf..cb5bf90227a 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java @@ -21,7 +21,7 @@ import forge.game.trigger.TriggerType; import forge.game.trigger.WrappedAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.collect.FCollection; public class RepeatEachEffect extends SpellAbilityEffect { @@ -185,7 +185,7 @@ else if (sa.hasParam("DefinedCards")) { } if (nextTurn) { game.getCleanup().addUntil(p, (GameCommand) () -> { - List tempRemembered = Lists.newArrayList(Iterables.filter(source.getRemembered(), Player.class)); + List tempRemembered = Lists.newArrayList(IterableUtil.filter(source.getRemembered(), Player.class)); source.removeRemembered(tempRemembered); source.addRemembered(p); AbilityUtils.resolve(repeat); @@ -194,7 +194,7 @@ else if (sa.hasParam("DefinedCards")) { }); } else { // to avoid risk of collision with other abilities swap out other Remembered Player while resolving - List tempRemembered = Lists.newArrayList(Iterables.filter(source.getRemembered(), Player.class)); + List tempRemembered = Lists.newArrayList(IterableUtil.filter(source.getRemembered(), Player.class)); source.removeRemembered(tempRemembered); source.addRemembered(p); if (sa.hasParam("AmountFromVotes")) { diff --git a/forge-game/src/main/java/forge/game/card/CardLists.java b/forge-game/src/main/java/forge/game/card/CardLists.java index 8b9e79efae7..5c3536464a0 100644 --- a/forge-game/src/main/java/forge/game/card/CardLists.java +++ b/forge-game/src/main/java/forge/game/card/CardLists.java @@ -30,9 +30,8 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.game.staticability.StaticAbilityCrewValue; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.MyRandom; -import forge.util.Predicates; import forge.util.collect.FCollectionView; /** @@ -310,15 +309,15 @@ public static CardCollection getColor(Iterable cardList, byte color) { * criteria; may be empty, but never null. */ public static CardCollection filter(Iterable cardList, Predicate filt) { - return new CardCollection(Iterables.filter(cardList, filt)); + return new CardCollection(IterableUtil.filter(cardList, filt)); } public static CardCollection filter(Iterable cardList, Predicate f1, Predicate f2) { - return new CardCollection(Iterables.filter(cardList, f1.and(f2))); + return new CardCollection(IterableUtil.filter(cardList, f1.and(f2))); } public static CardCollection filter(Iterable cardList, Iterable> filt) { - return new CardCollection(Iterables.filter(cardList, Predicates.and(filt))); + return new CardCollection(IterableUtil.filter(cardList, IterableUtil.and(filt))); } /** @@ -333,15 +332,15 @@ public static CardCollection filter(Iterable cardList, Iterable filterAsList(Iterable cardList, Predicate filt) { - return Lists.newArrayList(Iterables.filter(cardList, filt)); + return Lists.newArrayList(IterableUtil.filter(cardList, filt)); } public static List filterAsList(Iterable cardList, Predicate f1, Predicate f2) { - return Lists.newArrayList(Iterables.filter(cardList, f1.and(f2))); + return Lists.newArrayList(IterableUtil.filter(cardList, f1.and(f2))); } public static List filterAsList(Iterable cardList, Iterable> filt) { - return Lists.newArrayList(Iterables.filter(cardList, Predicates.and(filt))); + return Lists.newArrayList(IterableUtil.filter(cardList, IterableUtil.and(filt))); } public static int count(Iterable cardList, Predicate filt) { diff --git a/forge-game/src/main/java/forge/game/card/CardPredicates.java b/forge-game/src/main/java/forge/game/card/CardPredicates.java index f1c2b62168a..4f37e6ee818 100644 --- a/forge-game/src/main/java/forge/game/card/CardPredicates.java +++ b/forge-game/src/main/java/forge/game/card/CardPredicates.java @@ -29,7 +29,7 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.Zone; import forge.game.zone.ZoneType; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.PredicateString; import forge.util.collect.FCollectionView; @@ -72,7 +72,7 @@ public static Predicate hasKeyword(final Keyword keyword) { public static Predicate containsKeyword(final String keyword) { return c -> { - if (Iterables.any(c.getHiddenExtrinsicKeywords(), PredicateString.contains(keyword))) { + if (IterableUtil.any(c.getHiddenExtrinsicKeywords(), PredicateString.contains(keyword))) { return true; } diff --git a/forge-game/src/main/java/forge/game/card/CardProperty.java b/forge-game/src/main/java/forge/game/card/CardProperty.java index 415df5d3264..416ad52b979 100644 --- a/forge-game/src/main/java/forge/game/card/CardProperty.java +++ b/forge-game/src/main/java/forge/game/card/CardProperty.java @@ -27,6 +27,7 @@ import forge.game.zone.ZoneType; import forge.item.PaperCard; import forge.util.Expressions; +import forge.util.IterableUtil; import forge.util.Iterables; import forge.util.TextUtil; import forge.util.collect.FCollection; @@ -836,7 +837,7 @@ public static boolean cardHasProperty(Card card, String property, Player sourceC final String restriction = property.split("sharesCardTypeWithOther ")[1]; CardCollection list = AbilityUtils.getDefinedCards(source, restriction, spellAbility); list.remove(card); - return Iterables.any(list, CardPredicates.sharesCardTypeWith(card)); + return IterableUtil.any(list, CardPredicates.sharesCardTypeWith(card)); } final String restriction = property.split("sharesCardTypeWith ")[1]; diff --git a/forge-game/src/main/java/forge/game/card/CardState.java b/forge-game/src/main/java/forge/game/card/CardState.java index ebbb765a436..34a9e1eb5c2 100644 --- a/forge-game/src/main/java/forge/game/card/CardState.java +++ b/forge-game/src/main/java/forge/game/card/CardState.java @@ -47,6 +47,7 @@ import forge.game.spellability.SpellPermanent; import forge.game.staticability.StaticAbility; import forge.game.trigger.Trigger; +import forge.util.IterableUtil; import forge.util.Iterables; import forge.util.ITranslatable; import forge.util.collect.FCollection; @@ -368,7 +369,7 @@ public final FCollectionView getNonManaAbilities() { } public final Iterable getIntrinsicSpellAbilities() { - return Iterables.filter(getSpellAbilities(), SpellAbilityPredicates.isIntrinsic()); + return IterableUtil.filter(getSpellAbilities(), SpellAbilityPredicates.isIntrinsic()); } public final SpellAbility getFirstAbility() { diff --git a/forge-game/src/main/java/forge/game/card/CardView.java b/forge-game/src/main/java/forge/game/card/CardView.java index 5caefa96aac..0fb67c24b58 100644 --- a/forge-game/src/main/java/forge/game/card/CardView.java +++ b/forge-game/src/main/java/forge/game/card/CardView.java @@ -570,7 +570,7 @@ void setPlayerMayLook(Iterable list) { public boolean canBeShownToAny(final Iterable viewers) { if (viewers == null || Iterables.isEmpty(viewers)) { return true; } - return Iterables.any(viewers, this::canBeShownTo); + return IterableUtil.any(viewers, this::canBeShownTo); } public boolean canBeShownTo(final PlayerView viewer) { @@ -636,7 +636,7 @@ public boolean canBeShownTo(final PlayerView viewer) { public boolean canFaceDownBeShownToAny(final Iterable viewers) { if (viewers == null || Iterables.isEmpty(viewers)) { return true; } - return Iterables.any(viewers, this::canFaceDownBeShownTo); + return IterableUtil.any(viewers, this::canFaceDownBeShownTo); } public boolean canFaceDownBeShownTo(final PlayerView viewer) { diff --git a/forge-game/src/main/java/forge/game/card/CardZoneTable.java b/forge-game/src/main/java/forge/game/card/CardZoneTable.java index 7fef845a4a9..727ab1baf23 100644 --- a/forge-game/src/main/java/forge/game/card/CardZoneTable.java +++ b/forge-game/src/main/java/forge/game/card/CardZoneTable.java @@ -17,6 +17,7 @@ import forge.game.spellability.SpellAbility; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; +import forge.util.IterableUtil; import forge.util.Iterables; public class CardZoneTable extends ForwardingTable { @@ -135,7 +136,7 @@ private void triggerTokenCreatedOnce(Game game) { public CardCollection filterCards(Iterable origin, Iterable destination, String valid, Card host, CardTraitBase sa) { CardCollection allCards = new CardCollection(); - if (destination != null && !Iterables.any(destination, d -> columnKeySet().contains(d))) { + if (destination != null && !IterableUtil.any(destination, d -> columnKeySet().contains(d))) { return allCards; } if (origin != null) { 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 55cac993540..96d9af10dcf 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackConstraints.java +++ b/forge-game/src/main/java/forge/game/combat/AttackConstraints.java @@ -9,6 +9,7 @@ import java.util.Set; import java.util.function.Predicate; +import forge.util.IterableUtil; import forge.util.Iterables; import org.apache.commons.lang3.tuple.Pair; @@ -362,7 +363,7 @@ private List getSortedFilteredRequirements() { while (!sortedPlayerReqs.isEmpty()) { Pair playerReq = MapToAmountUtil.max(sortedPlayerReqs); // find best attack to also fulfill the additional requirements - Attack bestMatch = Iterables.getLast(Iterables.filter(result, att -> !usedAttackers.contains(att.attacker) && att.defender.equals(playerReq.getLeft())), null); + Attack bestMatch = Iterables.getLast(IterableUtil.filter(result, att -> !usedAttackers.contains(att.attacker) && att.defender.equals(playerReq.getLeft())), null); if (bestMatch != null) { bestMatch.requirements += playerReq.getRight(); usedAttackers.add(bestMatch.attacker); 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 204aa54a42a..43a58c2526c 100644 --- a/forge-game/src/main/java/forge/game/combat/Combat.java +++ b/forge-game/src/main/java/forge/game/combat/Combat.java @@ -37,7 +37,7 @@ import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; import forge.util.CardTranslation; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.Localizer; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; @@ -218,15 +218,15 @@ public final FCollection getDefendersControlledBy(Player who) { } public final FCollectionView getDefendingPlayers() { - return new FCollection<>(Iterables.filter(attackableEntries, Player.class)); + return new FCollection<>(IterableUtil.filter(attackableEntries, Player.class)); } public final CardCollection getDefendingPlaneswalkers() { - return CardLists.filter(Iterables.filter(attackableEntries, Card.class), CardPredicates.PLANESWALKERS); + return CardLists.filter(IterableUtil.filter(attackableEntries, Card.class), CardPredicates.PLANESWALKERS); } public final CardCollection getDefendingBattles() { - return CardLists.filter(Iterables.filter(attackableEntries, Card.class), CardPredicates.BATTLES); + return CardLists.filter(IterableUtil.filter(attackableEntries, Card.class), CardPredicates.BATTLES); } public final Map getAttackersAndDefenders() { @@ -608,7 +608,7 @@ public final void removeFromCombat(final Card c) { } } - for (Card battleOrPW : Iterables.filter(attackableEntries, Card.class)) { + for (Card battleOrPW : IterableUtil.filter(attackableEntries, Card.class)) { if (battleOrPW.equals(c)) { Multimap attackerBuffer = ArrayListMultimap.create(); Collection bands = attackedByBands.get(c); diff --git a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java index 4fddebd1e7b..963f3c5f48c 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java +++ b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java @@ -25,6 +25,7 @@ import java.util.Map.Entry; import java.util.function.Predicate; +import forge.util.IterableUtil; import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; @@ -464,7 +465,7 @@ public final boolean ai_payMana(final String mana, final ManaPool pool) { return pool.canPayForShardWithColor(ms, colorMask); }; - return tryPayMana(colorMask, Iterables.filter(unpaidShards.keySet(), predCanBePaid), pool.getPossibleColorUses(colorMask)) != null; + return tryPayMana(colorMask, IterableUtil.filter(unpaidShards.keySet(), predCanBePaid), pool.getPossibleColorUses(colorMask)) != null; } /** @@ -485,12 +486,12 @@ public final boolean payMana(final Mana mana, final ManaPool pool) { byte inColor = mana.getColor(); byte outColor = pool.getPossibleColorUses(inColor); - return tryPayMana(inColor, Iterables.filter(unpaidShards.keySet(), predCanBePaid), outColor) != null; + return tryPayMana(inColor, IterableUtil.filter(unpaidShards.keySet(), predCanBePaid), outColor) != null; } public final ManaCostShard payManaViaConvoke(final byte color) { Predicate predCanBePaid = ms -> !ms.isSnow() && !ms.isColorless() && ms.canBePaidWithManaOfColor(color); - return tryPayMana(color, Iterables.filter(unpaidShards.keySet(), predCanBePaid), (byte)0xFF); + return tryPayMana(color, IterableUtil.filter(unpaidShards.keySet(), predCanBePaid), (byte)0xFF); } public ManaCostShard getShardToPayByPriority(Iterable payableShards, byte possibleUses) { diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index db1a546be9a..2e9fe7f1b85 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -1608,7 +1608,7 @@ public final CardCollectionView mill(int n, final ZoneType destination, SpellAbi Iterable milledView = getCardsIn(ZoneType.Library); // 614.13c if (sa.getRootAbility().getReplacingObject(AbilityKey.SimultaneousETB) != null) { - milledView = Iterables.filter(milledView, c -> !((CardCollection) sa.getRootAbility().getReplacingObject(AbilityKey.SimultaneousETB)).contains(c)); + milledView = IterableUtil.filter(milledView, c -> !((CardCollection) sa.getRootAbility().getReplacingObject(AbilityKey.SimultaneousETB)).contains(c)); } CardCollectionView milled = new CardCollection(Iterables.limit(milledView, n)); @@ -1893,7 +1893,7 @@ public final void addCreaturesAttackedThisTurn(final Card c, final GameEntity e) } public final Iterable getAttackedPlayersMyTurn() { - return Iterables.filter(attackedThisTurn.keySet(), Player.class); + return IterableUtil.filter(attackedThisTurn.keySet(), Player.class); } public final List getAttackedPlayersMyLastTurn() { return attackedPlayersLastTurn; diff --git a/forge-game/src/main/java/forge/game/player/PlayerCollection.java b/forge-game/src/main/java/forge/game/player/PlayerCollection.java index a7e09370036..b6a05eeb2a0 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerCollection.java +++ b/forge-game/src/main/java/forge/game/player/PlayerCollection.java @@ -8,7 +8,7 @@ import forge.game.card.CardCollection; import forge.game.zone.ZoneType; import forge.util.Aggregates; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.collect.FCollection; public class PlayerCollection extends FCollection { @@ -53,7 +53,7 @@ public final CardCollection getCreaturesInPlay() { // filter functions with predicate public PlayerCollection filter(Predicate pred) { - return new PlayerCollection(Iterables.filter(this, pred)); + return new PlayerCollection(IterableUtil.filter(this, pred)); } // sort functions with Comparator diff --git a/forge-game/src/main/java/forge/game/spellability/TargetChoices.java b/forge-game/src/main/java/forge/game/spellability/TargetChoices.java index e2397789884..14b3361c321 100644 --- a/forge-game/src/main/java/forge/game/spellability/TargetChoices.java +++ b/forge-game/src/main/java/forge/game/spellability/TargetChoices.java @@ -30,6 +30,7 @@ import forge.game.card.CardCollection; import forge.game.card.CardCollectionView; import forge.game.player.Player; +import forge.util.IterableUtil; import forge.util.Iterables; import forge.util.collect.FCollection; @@ -51,7 +52,7 @@ public class TargetChoices extends ForwardingList implements Cloneab public final int getTotalTargetedCMC() { int totalCMC = 0; - for (Card c : Iterables.filter(targets, Card.class)) { + for (Card c : IterableUtil.filter(targets, Card.class)) { totalCMC += c.getCMC(); } return totalCMC; @@ -59,7 +60,7 @@ public final int getTotalTargetedCMC() { public final int getTotalTargetedPower() { int totalPower = 0; - for (Card c : Iterables.filter(targets, Card.class)) { + for (Card c : IterableUtil.filter(targets, Card.class)) { totalPower += c.getNetPower(); } return totalPower; @@ -101,19 +102,19 @@ public boolean remove(Object object) { } public final CardCollectionView getTargetCards() { - return new CardCollection(Iterables.filter(targets, Card.class)); + return new CardCollection(IterableUtil.filter(targets, Card.class)); } public final Iterable getTargetPlayers() { - return Iterables.filter(targets, Player.class); + return IterableUtil.filter(targets, Player.class); } public final Iterable getTargetSpells() { - return Iterables.filter(targets, SpellAbility.class); + return IterableUtil.filter(targets, SpellAbility.class); } public final Iterable getTargetEntities() { - return Iterables.filter(targets, GameEntity.class); + return IterableUtil.filter(targets, GameEntity.class); } public final boolean isTargetingAnyCard() { @@ -161,7 +162,7 @@ protected List delegate() { @Override public boolean contains(Object o) { if (o instanceof Card) { - return Iterables.any(Iterables.filter(targets, Card.class), c -> c.equalsWithGameTimestamp((Card) o)); + return IterableUtil.any(IterableUtil.filter(targets, Card.class), c -> c.equalsWithGameTimestamp((Card) o)); } return super.contains(o); } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java index eab5c6e8933..dde410ae1fe 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttackersDeclared.java @@ -28,7 +28,7 @@ import forge.game.card.CardLists; import forge.game.spellability.SpellAbility; import forge.util.Expressions; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.Localizer; import forge.util.collect.FCollection; @@ -91,7 +91,7 @@ public final void setTriggeringObjects(final SpellAbility sa, Map runParams) { // checks which card this spell was the castSA SpellAbility castSA = getHostCard().getCastSA(); - int left = Iterables.indexOf(thisTurnCast, CardPredicates.castSA(Predicate.isEqual(castSA))); + int left = IterableUtil.indexOf(thisTurnCast, CardPredicates.castSA(Predicate.isEqual(castSA))); int right = Integer.parseInt(compare.substring(2)); if (!Expressions.compare(left + 1, compare, right)) { return false; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOutAll.java b/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOutAll.java index 4934ec5a5ba..6c5e01c9db0 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOutAll.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerPhaseOutAll.java @@ -4,7 +4,7 @@ import forge.game.card.Card; import forge.game.card.CardPredicates; import forge.game.spellability.SpellAbility; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.Localizer; import java.util.Map; @@ -28,7 +28,7 @@ public boolean performTest(Map runParams) { public void setTriggeringObjects(SpellAbility sa, Map runParams) { Iterable cards = (Iterable) runParams.get(AbilityKey.Cards); if (hasParam("ValidCards")) { - cards = Iterables.filter(cards, CardPredicates.restriction(getParam("ValidCards").split(","), + cards = IterableUtil.filter(cards, CardPredicates.restriction(getParam("ValidCards").split(","), getHostCard().getController(), getHostCard(), this)); } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerTapAll.java b/forge-game/src/main/java/forge/game/trigger/TriggerTapAll.java index e5e5f3893fe..386341bae66 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerTapAll.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerTapAll.java @@ -4,7 +4,7 @@ import forge.game.card.Card; import forge.game.card.CardPredicates; import forge.game.spellability.SpellAbility; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.Localizer; import java.util.Map; @@ -24,7 +24,7 @@ public boolean performTest(Map runParams) { public void setTriggeringObjects(SpellAbility sa, Map runParams) { Iterable cards = (Iterable) runParams.get(AbilityKey.Cards); if (hasParam("ValidCards")) { - cards = Iterables.filter(cards, CardPredicates.restriction(getParam("ValidCards").split(","), + cards = IterableUtil.filter(cards, CardPredicates.restriction(getParam("ValidCards").split(","), getHostCard().getController(), getHostCard(), this)); } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerTokenCreatedOnce.java b/forge-game/src/main/java/forge/game/trigger/TriggerTokenCreatedOnce.java index 270beea9bc6..e4bf6d689d1 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerTokenCreatedOnce.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerTokenCreatedOnce.java @@ -26,7 +26,7 @@ import forge.game.card.CardPredicates; import forge.game.player.PlayerCollection; import forge.game.spellability.SpellAbility; -import forge.util.Iterables; +import forge.util.IterableUtil; public class TriggerTokenCreatedOnce extends Trigger { @@ -44,7 +44,7 @@ public String getImportantStackObjects(SpellAbility sa) { public final void setTriggeringObjects(final SpellAbility sa, Map runParams) { Iterable tokens = (Iterable) runParams.get(AbilityKey.Cards); if (hasParam("ValidToken")) { - tokens = Iterables.filter(tokens, CardPredicates.restriction(getParam("ValidToken").split(","), getHostCard().getController(), getHostCard(), this)); + tokens = IterableUtil.filter(tokens, CardPredicates.restriction(getParam("ValidToken").split(","), getHostCard().getController(), getHostCard(), this)); } sa.setTriggeringObject(AbilityKey.Cards, tokens); diff --git a/forge-game/src/main/java/forge/game/zone/MagicStack.java b/forge-game/src/main/java/forge/game/zone/MagicStack.java index 971491b9725..669e3ff52c0 100644 --- a/forge-game/src/main/java/forge/game/zone/MagicStack.java +++ b/forge-game/src/main/java/forge/game/zone/MagicStack.java @@ -42,7 +42,7 @@ import forge.game.spellability.TargetChoices; import forge.game.trigger.Trigger; import forge.game.trigger.TriggerType; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.TextUtil; import java.util.*; @@ -230,7 +230,7 @@ public final void clearUndoStack() { undoStackOwner = null; } public Iterable filterUndoStackByHost(final Card c) { - return Iterables.filter(undoStack, CardTraitPredicates.isHostCard(c)); + return IterableUtil.filter(undoStack, CardTraitPredicates.isHostCard(c)); } public final void add(SpellAbility sp) { @@ -1020,7 +1020,7 @@ static protected boolean commitCrimeCheck(Player p, Iterable chos List zoneList = ImmutableList.of(ZoneType.Battlefield, ZoneType.Graveyard, ZoneType.Stack); for (TargetChoices tc : chosenTargets) { - if (Iterables.any(tc.getTargetPlayers(), PlayerPredicates.isOpponentOf(p))) { + if (IterableUtil.any(tc.getTargetPlayers(), PlayerPredicates.isOpponentOf(p))) { return true; } for (SpellAbility sp : tc.getTargetSpells()) { diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java b/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java index cd29558f492..30ba107e601 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/ItemManager.java @@ -901,7 +901,7 @@ public boolean applyFilters() { predicates.add(mainSearchFilter.buildPredicate(this.genericType)); } - final Predicate newFilterPredicate = predicates.size() == 0 ? null : Predicates.and(predicates); + final Predicate newFilterPredicate = predicates.size() == 0 ? null : IterableUtil.and(predicates); if (this.filterPredicate == newFilterPredicate) { return false; } this.filterPredicate = newFilterPredicate; @@ -1003,12 +1003,12 @@ public void updateView(final boolean forceFilter, final Iterable itemsToSelec if (useFilter && this.wantUnique) { final Predicate> filterForPool = x -> this.filterPredicate.test(x.getKey()); - final Iterable> items = getUnique(Iterables.filter(this.pool, filterForPool)); + final Iterable> items = getUnique(IterableUtil.filter(this.pool, filterForPool)); this.model.addItems(items); } else if (useFilter) { final Predicate> pred = x -> this.filterPredicate.test(x.getKey()); - this.model.addItems(Iterables.filter(this.pool, pred)); + this.model.addItems(IterableUtil.filter(this.pool, pred)); } else if (this.wantUnique) { final Iterable> items = getUnique(this.pool); diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java index 650e10b0cc0..af839241d28 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardCMCFilter.java @@ -12,7 +12,7 @@ import forge.itemmanager.ItemManager; import forge.itemmanager.SItemManagerUtil.StatTypes; import forge.itemmanager.SpellShopManager; -import forge.util.Predicates; +import forge.util.IterableUtil; /** * TODO: Write javadoc for this type. @@ -56,6 +56,6 @@ protected final Predicate buildPredicate() { //use custom return true delegate to validate the item is a card return card -> true; } - return PaperCardPredicates.fromRules(Predicates.or(cmcs)); + return PaperCardPredicates.fromRules(IterableUtil.or(cmcs)); } } diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java index 72116738054..604a7b35f8d 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardTypeFilter.java @@ -12,7 +12,7 @@ import forge.itemmanager.ItemManager; import forge.itemmanager.SItemManagerUtil.StatTypes; import forge.itemmanager.SpellShopManager; -import forge.util.Predicates; +import forge.util.IterableUtil; public class CardTypeFilter extends StatTypeFilter { @@ -54,6 +54,6 @@ protected final Predicate buildPredicate() { //use custom return true delegate to validate the item is a card return card -> true; } - return PaperCardPredicates.fromRules(Predicates.or(types)); + return PaperCardPredicates.fromRules(IterableUtil.or(types)); } } diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/AddBasicLandsDialog.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/AddBasicLandsDialog.java index a377bc72071..7cff8386751 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/AddBasicLandsDialog.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/AddBasicLandsDialog.java @@ -54,7 +54,7 @@ import forge.toolbox.FSkin; import forge.toolbox.FSkin.SkinnedPanel; import forge.toolbox.FTextField; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.Localizer; import forge.util.MyRandom; import forge.view.arcane.CardPanel; @@ -68,7 +68,7 @@ public class AddBasicLandsDialog { private static final int LAND_PANEL_PADDING = 3; private final FComboBoxPanel cbLandSet = new FComboBoxPanel<>(Localizer.getInstance().getMessage("lblLandSet") + ":", FlowLayout.CENTER, - Iterables.filter(StaticData.instance().getSortedEditions(), CardEdition.Predicates.hasBasicLands)); + IterableUtil.filter(StaticData.instance().getSortedEditions(), CardEdition.Predicates.hasBasicLands)); private final MainPanel panel = new MainPanel(); private final LandPanel pnlPlains = new LandPanel("Plains"); diff --git a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/ACEditorBase.java b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/ACEditorBase.java index 2759dec2275..2cc3d496d76 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/ACEditorBase.java +++ b/forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/ACEditorBase.java @@ -61,10 +61,7 @@ import forge.toolbox.FComboBox; import forge.toolbox.FLabel; import forge.toolbox.FSkin; -import forge.util.Aggregates; -import forge.util.ItemPool; -import forge.util.Iterables; -import forge.util.Localizer; +import forge.util.*; import forge.view.FView; /** @@ -232,7 +229,7 @@ protected ItemPool getAllowedAdditions(final Iterable cardAmountInfo = Iterables.find(cardsByName, + Entry cardAmountInfo = IterableUtil.find(cardsByName, t -> t.getKey().equals(card.getRules().getNormalizedName()), null); if (cardAmountInfo != null) { max -= cardAmountInfo.getValue(); diff --git a/forge-gui-desktop/src/test/java/forge/card/LegacyCardDb.java b/forge-gui-desktop/src/test/java/forge/card/LegacyCardDb.java index ef33a9aa5b1..02cab067d70 100644 --- a/forge-gui-desktop/src/test/java/forge/card/LegacyCardDb.java +++ b/forge-gui-desktop/src/test/java/forge/card/LegacyCardDb.java @@ -204,7 +204,7 @@ public PaperCard getCardFromEdition(final String cardName, final Date printedBef LegacySetPreference fromSet = fromSets; List cards = getAllCards(cr.cardName); if (printedBefore != null) { - cards = Lists.newArrayList(Iterables.filter(cards, c -> { + cards = Lists.newArrayList(IterableUtil.filter(cards, c -> { CardEdition ed = editions.get(c.getEdition()); return ed.getDate().before(printedBefore); })); @@ -220,7 +220,7 @@ public PaperCard getCardFromEdition(final String cardName, final Date printedBef // fromSet = LegacySetPreference.EarliestCoreExp; if (StringUtils.isNotBlank(cr.edition)) { - cards = Lists.newArrayList(Iterables.filter(cards, input -> input.getEdition().equalsIgnoreCase(cr.edition))); + cards = Lists.newArrayList(IterableUtil.filter(cards, input -> input.getEdition().equalsIgnoreCase(cr.edition))); } if (artIndex == -1 && cr.artIndex > 0) { artIndex = cr.artIndex; diff --git a/forge-gui-mobile/src/forge/adventure/data/RewardData.java b/forge-gui-mobile/src/forge/adventure/data/RewardData.java index 3e4089df6b0..67b2352de71 100644 --- a/forge-gui-mobile/src/forge/adventure/data/RewardData.java +++ b/forge-gui-mobile/src/forge/adventure/data/RewardData.java @@ -9,6 +9,7 @@ import forge.adventure.world.WorldSave; import forge.deck.Deck; import forge.item.PaperCard; +import forge.util.IterableUtil; import forge.util.Iterables; import java.io.Serializable; @@ -92,9 +93,9 @@ static private void initializeAllCards(){ if(legals==null) allCards = CardUtil.getFullCardPool(false); // we need unique cards only here, so that a unique card can be chosen before a set variant is determined else - allCards = Iterables.filter(CardUtil.getFullCardPool(false), new CardUtil.CardPredicate(legals, true)); + allCards = IterableUtil.filter(CardUtil.getFullCardPool(false), new CardUtil.CardPredicate(legals, true)); //Filter out specific cards. - allCards = Iterables.filter(allCards, input -> { + allCards = IterableUtil.filter(allCards, input -> { if(input == null) return false; if (Iterables.contains(input.getRules().getMainPart().getKeywords(), "Remove CARDNAME from your deck before playing if you're not playing for ante.")) @@ -111,7 +112,7 @@ static private void initializeAllCards(){ return !Arrays.asList(configData.restrictedCards).contains(input.getName()); }); //Filter AI cards for enemies. - allEnemyCards=Iterables.filter(allCards, input -> { + allEnemyCards= IterableUtil.filter(allCards, input -> { if (input == null) return false; return !input.getRules().getAiHints().getRemAIDecks(); }); diff --git a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java index 1afb48d1b44..1f19f9fc3c2 100644 --- a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java +++ b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java @@ -20,6 +20,7 @@ import forge.item.generation.UnOpenedProduct; import forge.model.FModel; import forge.util.Aggregates; +import forge.util.IterableUtil; import forge.util.Iterables; import java.text.SimpleDateFormat; @@ -792,7 +793,7 @@ public static Deck generateBoosterPackAsDeck(CardEdition edition){ public static Deck generateRandomBoosterPackAsDeck(final Predicate editionFilter) { Predicate filter = CardEdition.Predicates.CAN_MAKE_BOOSTER.and(editionFilter); - Iterable possibleEditions = Iterables.filter(FModel.getMagicDb().getEditions(), filter); + Iterable possibleEditions = IterableUtil.filter(FModel.getMagicDb().getEditions(), filter); if (!possibleEditions.iterator().hasNext()) { System.err.println("No sets found matching edition filter that can create boosters."); diff --git a/forge-gui-mobile/src/forge/deck/AddBasicLandsDialog.java b/forge-gui-mobile/src/forge/deck/AddBasicLandsDialog.java index c5634d40c04..50da1056ff1 100644 --- a/forge-gui-mobile/src/forge/deck/AddBasicLandsDialog.java +++ b/forge-gui-mobile/src/forge/deck/AddBasicLandsDialog.java @@ -46,10 +46,7 @@ import forge.toolbox.FOptionPane; import forge.toolbox.FScrollPane; import forge.toolbox.FTextArea; -import forge.util.Callback; -import forge.util.Iterables; -import forge.util.MyRandom; -import forge.util.Utils; +import forge.util.*; public class AddBasicLandsDialog extends FDialog { @@ -61,7 +58,7 @@ public class AddBasicLandsDialog extends FDialog { private final Callback callback; private final FLabel lblLandSet = add(new FLabel.Builder().text(Forge.getLocalizer().getMessage("lblLandSet") + ":").font(FSkinFont.get(12)).textColor(FLabel.getInlineLabelColor()).build()); - private final FComboBox cbLandSet = add(new FComboBox<>(Iterables.filter(StaticData.instance().getEditions(), CardEdition.Predicates.hasBasicLands))); + private final FComboBox cbLandSet = add(new FComboBox<>(IterableUtil.filter(StaticData.instance().getEditions(), CardEdition.Predicates.hasBasicLands))); private final FScrollPane scroller = add(new FScrollPane() { @Override diff --git a/forge-gui-mobile/src/forge/itemmanager/ItemManager.java b/forge-gui-mobile/src/forge/itemmanager/ItemManager.java index 0ec421ddb30..9ccfad3ff9c 100644 --- a/forge-gui-mobile/src/forge/itemmanager/ItemManager.java +++ b/forge-gui-mobile/src/forge/itemmanager/ItemManager.java @@ -52,10 +52,7 @@ import forge.toolbox.FLabel; import forge.toolbox.FList; import forge.toolbox.FList.CompactModeHandler; -import forge.util.ItemPool; -import forge.util.Iterables; -import forge.util.LayoutHelper; -import forge.util.Predicates; +import forge.util.*; public abstract class ItemManager extends FContainer implements IItemManager, ActivateHandler { @@ -685,7 +682,7 @@ public boolean applyFilters() { predicates.add(advancedSearchFilter.buildPredicate(genericType)); } - Predicate newFilterPredicate = predicates.size() == 0 ? null : Predicates.and(predicates); + Predicate newFilterPredicate = predicates.size() == 0 ? null : IterableUtil.and(predicates); if (filterPredicate == newFilterPredicate) { return false; } filterPredicate = newFilterPredicate; @@ -783,7 +780,7 @@ public void updateView(final boolean forceFilter, final Iterable itemsToSelec Iterable> items = pool; if (useFilter) { Predicate> pred = x -> filterPredicate.test(x.getKey()); - items = Iterables.filter(pool, pred); + items = IterableUtil.filter(pool, pred); } model.addItems(items); } diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java index f631ee8ef12..13cf423d203 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/CardTypeFilter.java @@ -9,7 +9,7 @@ import forge.item.PaperCardPredicates; import forge.itemmanager.ItemManager; import forge.itemmanager.SItemManagerUtil.StatTypes; -import forge.util.Predicates; +import forge.util.IterableUtil; public class CardTypeFilter extends StatTypeFilter { @@ -51,6 +51,6 @@ protected final Predicate buildPredicate() { //use custom return true delegate to validate the item is a card return card -> true; } - return PaperCardPredicates.fromRules(Predicates.or(types)); + return PaperCardPredicates.fromRules(IterableUtil.or(types)); } } diff --git a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java index c07da345c23..f92b38be18d 100644 --- a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java +++ b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java @@ -146,7 +146,7 @@ private void pullFromTheAEther() { CardRarity rarity = btnRarityFilter.selectedOption.getRarity(MyRandom.getRandom().nextDouble()); while (true) { final CardRarity allowedRarity = rarity; - rewardPool = Iterables.filter(filteredPool, card -> allowedRarity == card.getRarity() + rewardPool = IterableUtil.filter(filteredPool, card -> allowedRarity == card.getRarity() || allowedRarity == CardRarity.Rare && card.getRarity() == CardRarity.Special); if (Iterables.isEmpty(rewardPool)) { //if pool is empty, must reduce rarity and try again if (rarity == minRarity) { diff --git a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestPlaneSelector.java b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestPlaneSelector.java index bb4969fa017..09e075c905b 100644 --- a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestPlaneSelector.java +++ b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestPlaneSelector.java @@ -22,7 +22,7 @@ import forge.toolbox.FOptionPane; import forge.toolbox.FTimer; import forge.toolbox.GuiDialog; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.Utils; import forge.util.collect.FCollectionView; @@ -34,7 +34,7 @@ public class ConquestPlaneSelector extends FDisplayObject { private static final float MONITOR_LEFT_MULTIPLIER = 19f / 443f; private static final float ARROW_THICKNESS = Utils.scale(3); - private static List planes = ImmutableList.copyOf(Iterables.filter(FModel.getPlanes(), plane -> { + private static List planes = ImmutableList.copyOf(IterableUtil.filter(FModel.getPlanes(), plane -> { return !plane.isUnreachable(); //filter out unreachable planes })); @@ -224,6 +224,6 @@ public void draw(Graphics g) { } public void updateReachablePlanes() { - planes = ImmutableList.copyOf(Iterables.filter(FModel.getPlanes(), plane -> !plane.isUnreachable())); + planes = ImmutableList.copyOf(IterableUtil.filter(FModel.getPlanes(), plane -> !plane.isUnreachable())); } } diff --git a/forge-gui-mobile/src/forge/toolbox/ListChooser.java b/forge-gui-mobile/src/forge/toolbox/ListChooser.java index 3c39bd4ee95..a381d4cef34 100644 --- a/forge-gui-mobile/src/forge/toolbox/ListChooser.java +++ b/forge-gui-mobile/src/forge/toolbox/ListChooser.java @@ -38,10 +38,7 @@ import forge.itemmanager.filters.ListLabelFilter; import forge.menu.FMenuItem; import forge.menu.FPopupMenu; -import forge.util.Callback; -import forge.util.Iterables; -import forge.util.Predicates; -import forge.util.Utils; +import forge.util.*; /** * A simple class that shows a list of choices in a dialog. Two properties @@ -176,7 +173,7 @@ public void applyFilters() { lstChoices.setListData(list); } else { - lstChoices.setListData(Iterables.filter(list, Predicates.and(predicates))); + lstChoices.setListData(IterableUtil.filter(list, IterableUtil.and(predicates))); } if (!lstChoices.isEmpty() && lstChoices.getMaxChoices() > 0) { diff --git a/forge-gui/src/main/java/forge/deck/DeckProxy.java b/forge-gui/src/main/java/forge/deck/DeckProxy.java index 9d350b16962..29ce16aa646 100644 --- a/forge-gui/src/main/java/forge/deck/DeckProxy.java +++ b/forge-gui/src/main/java/forge/deck/DeckProxy.java @@ -17,7 +17,7 @@ import forge.model.FModel; import forge.util.BinaryUtil; import forge.util.IHasName; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.storage.IStorage; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -361,7 +361,7 @@ public Set getExhaustiveFormats() { public String getFormatsString() { Set formats = getFormats(); if (formats.size() > 1) - return StringUtils.join(Iterables.transform(formats, GameFormat::getName), ", "); + return StringUtils.join(IterableUtil.transform(formats, GameFormat::getName), ", "); Object[] formatArray = formats.toArray(); GameFormat format = (GameFormat)formatArray[0]; if (format != GameFormat.NoFormat) diff --git a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java index af7ef6bca92..6ff02d999bd 100644 --- a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java +++ b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java @@ -389,7 +389,7 @@ public static QuestEvent getQuestEvent(final String name) { } } - QuestEventDuel duel = Iterables.find(qCtrl.getDuelsManager().getAllDuels(), in -> in.getName().equals(name)); + QuestEventDuel duel = IterableUtil.find(qCtrl.getDuelsManager().getAllDuels(), in -> in.getName().equals(name)); return duel; } @@ -750,13 +750,13 @@ else if (commander.getRules().canBePartnerCommander()) { }else{ cardDb = FModel.getMagicDb().getCommonCards(); //shuffle first 400 random cards - Iterable colorList = Iterables.filter(format.getCardPool(cardDb).getAllCards(), + Iterable colorList = IterableUtil.filter(format.getCardPool(cardDb).getAllCards(), format.isLegalCardPredicate().and(PaperCardPredicates.fromRules( new CardThemedDeckBuilder.MatchColorIdentity(commander.getRules().getColorIdentity()) .or(DeckGeneratorBase.COLORLESS_CARDS)))); switch (format) { case Brawl: //for Brawl - add additional filterprinted rule to remove old reprints for a consistent look - colorList = Iterables.filter(colorList,FModel.getFormats().getStandard().getFilterPrinted()); + colorList = IterableUtil.filter(colorList,FModel.getFormats().getStandard().getFilterPrinted()); break; case Oathbreaker: //check for signature spells diff --git a/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java b/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java index 75c3bee1ed5..841fbb83035 100644 --- a/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java @@ -9,6 +9,7 @@ import forge.gamemodes.quest.QuestController; import forge.model.FModel; import forge.util.Aggregates; +import forge.util.IterableUtil; import forge.util.Iterables; public class RandomDeckGenerator extends DeckProxy implements Comparable { @@ -172,7 +173,7 @@ private Deck getUserDeck() { if (Iterables.isEmpty(decks)) { return getGeneratedDeck(); //fall back to generated deck if no decks in filtered list } - Iterable AIDecks = Iterables.filter(decks, deckProxy -> deckProxy.getAI().inMainDeck == 0); + Iterable AIDecks = IterableUtil.filter(decks, deckProxy -> deckProxy.getAI().inMainDeck == 0); if (isAi && Iterables.size(AIDecks) > 10) return Aggregates.random(AIDecks).getDeck(); return Aggregates.random(decks).getDeck(); @@ -201,7 +202,7 @@ private Deck getFavoriteDeck() { decks = DeckProxy.getAllConstructedDecks(); break; } - decks = Iterables.filter(decks, DeckProxy::isFavoriteDeck); + decks = IterableUtil.filter(decks, DeckProxy::isFavoriteDeck); if (Iterables.isEmpty(decks)) { return getGeneratedDeck(); //fall back to generated deck if no favorite decks } diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java b/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java index 66bf6d08410..ccd75c3806c 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/BoosterDraft.java @@ -204,7 +204,7 @@ protected boolean generateProduct() { // Filter all sets by theme restrictions final Predicate themeFilter = theme.getEditionFilter(); final CardEdition.Collection allEditions = StaticData.instance().getEditions(); - final Iterable chaosDraftEditions = Iterables.filter( + final Iterable chaosDraftEditions = IterableUtil.filter( allEditions.getOrderedEditions(), themeFilter); // Add chaos "boosters" as special suppliers diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java index 1b4cf443bc9..8e4cc8716de 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedConquestDeckBuilder.java @@ -13,7 +13,7 @@ import forge.item.PaperCard; import forge.item.PaperCardPredicates; import forge.model.FModel; -import forge.util.Iterables; +import forge.util.IterableUtil; /** * Created by maustin on 28/02/2018. @@ -22,7 +22,7 @@ public class CardThemedConquestDeckBuilder extends CardThemedDeckBuilder { public CardThemedConquestDeckBuilder(PaperCard commanderCard0, final List dList, GameFormat gameFormat, boolean isForAI, DeckFormat format) { super(new DeckGenPool( - Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards(), + IterableUtil.filter(FModel.getMagicDb().getCommonCards().getUniqueCards(), gameFormat.getFilterPrinted()) ), format); this.availableList = dList; diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java index f3a0745e8d3..a54a2caa3fd 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java @@ -34,7 +34,7 @@ import forge.item.PaperCardPredicates; import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.MyRandom; /** @@ -192,7 +192,7 @@ public Deck buildDeck() { rankedColorList = aiPlayables.stream() .filter(PaperCardPredicates.fromRules(hasColor)) .collect(Collectors.toList()); - onColorCreaturesAndSpells = Iterables.filter(rankedColorList, + onColorCreaturesAndSpells = IterableUtil.filter(rankedColorList, PaperCardPredicates.fromRules(CardRulesPredicates.IS_CREATURE .or(CardRulesPredicates.IS_NON_CREATURE_SPELL))); @@ -391,7 +391,7 @@ private int sumMapValues(Map integerMap){ protected void addKeyCards(){ // Add the first keycard if not land if(!keyCard.getRules().getMainPart().getType().isLand()) { - keyCards = Iterables.filter(aiPlayables, PaperCardPredicates.name(keyCard.getName())); + keyCards = IterableUtil.filter(aiPlayables, PaperCardPredicates.name(keyCard.getName())); final List keyCardList = Lists.newArrayList(keyCards); deckList.addAll(keyCardList); aiPlayables.removeAll(keyCardList); @@ -411,7 +411,7 @@ protected void addKeyCards(){ protected void addLandKeyCards(){ // Add the deck card if(keyCard.getRules().getMainPart().getType().isLand()) { - keyCards = Iterables.filter(aiPlayables, PaperCardPredicates.name(keyCard.getName())); + keyCards = IterableUtil.filter(aiPlayables, PaperCardPredicates.name(keyCard.getName())); final List keyCardList = Lists.newArrayList(keyCards); deckList.addAll(keyCardList); aiPlayables.removeAll(keyCardList); @@ -463,7 +463,7 @@ protected void checkEvolvingWilds(){ */ protected void addThirdColorCards(int num) { if (num > 0) { - final Iterable others = Iterables.filter(aiPlayables, PaperCardPredicates.IS_NON_LAND); + final Iterable others = IterableUtil.filter(aiPlayables, PaperCardPredicates.IS_NON_LAND); // We haven't yet ranked the off-color cards. // Compare them to the cards already in the deckList. //List rankedOthers = CardRanker.rankCardsInPack(others, deckList, colors, true); @@ -479,7 +479,7 @@ protected void addThirdColorCards(int num) { hasColor = CardRulesPredicates.IS_NON_LAND.and(new MatchColorIdentity(colors) .or(DeckGeneratorBase.COLORLESS_CARDS)); - final Iterable threeColorList = Iterables.filter(aiPlayables, + final Iterable threeColorList = IterableUtil.filter(aiPlayables, PaperCardPredicates.fromRules(hasColor)); for (final PaperCard card : threeColorList) { if (num > 0) { @@ -802,7 +802,7 @@ private boolean containsTronLands(Iterable cards){ * Add non-basic lands to the deck. */ private void addNonBasicLands() { - Iterable lands = Iterables.filter(aiPlayables, PaperCardPredicates.IS_NONBASIC_LAND); + Iterable lands = IterableUtil.filter(aiPlayables, PaperCardPredicates.IS_NONBASIC_LAND); List landsToAdd = new ArrayList<>(); int minBasics;//Keep a minimum number of basics to ensure playable decks if(colors.isColorless()) { diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java index 33840ba6bed..170a7c3055b 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedDeckBuilder.java @@ -23,7 +23,7 @@ import forge.item.PaperCard; import forge.item.PaperCardPredicates; import forge.model.FModel; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.MyRandom; /** @@ -130,18 +130,18 @@ public Deck buildDeck() { public Deck buildDeck(final String landSetCode) { // 1. Prepare hasColor = new MatchColorIdentity(colors).or(COLORLESS_CARDS); - Iterable colorList = Iterables.filter(aiPlayables, + Iterable colorList = IterableUtil.filter(aiPlayables, PaperCardPredicates.fromRules(hasColor)); rankedColorList = CardRanker.rankCardsInDeck(colorList); - onColorCreatures = Iterables.filter(rankedColorList, PaperCardPredicates.IS_CREATURE); - onColorNonCreatures = Iterables.filter(rankedColorList, + onColorCreatures = IterableUtil.filter(rankedColorList, PaperCardPredicates.IS_CREATURE); + onColorNonCreatures = IterableUtil.filter(rankedColorList, PaperCardPredicates.fromRules(CardRulesPredicates.IS_NON_CREATURE_SPELL)); // Guava iterables do not copy the collection contents, instead they act // as filters and iterate over _source_ collection each time. So even if // aiPlayable has changed, there is no need to create a new iterable. // 2. Add any planeswalkers - final Iterable onColorWalkers = Iterables.filter(colorList, + final Iterable onColorWalkers = IterableUtil.filter(colorList, PaperCardPredicates.fromRules(CardRulesPredicates.IS_PLANESWALKER)); final List walkers = Lists.newArrayList(onColorWalkers); deckList.addAll(walkers); @@ -336,7 +336,7 @@ private void findBasicLandSets() { */ private void addLands(final int[] clrCnts, final String landSetCode) { // basic lands that are available in the deck - final Iterable basicLands = Iterables.filter(aiPlayables, PaperCardPredicates.IS_BASIC_LAND); + final Iterable basicLands = IterableUtil.filter(aiPlayables, PaperCardPredicates.IS_BASIC_LAND); final Set snowLands = new HashSet<>(); // total of all ClrCnts @@ -448,7 +448,7 @@ private int[] calculateLandNeeds() { * Add non-basic lands to the deck. */ private void addNonBasicLands() { - final Iterable lands = Iterables.filter(aiPlayables, PaperCardPredicates.IS_NONBASIC_LAND); + final Iterable lands = IterableUtil.filter(aiPlayables, PaperCardPredicates.IS_NONBASIC_LAND); List landsToAdd = new ArrayList<>(); for (final PaperCard card : lands) { if (landsNeeded > 0) { @@ -475,7 +475,7 @@ private void addNonBasicLands() { */ private void addThirdColorCards(int num) { if (num > 0) { - final Iterable others = Iterables.filter(aiPlayables, PaperCardPredicates.IS_NON_LAND); + final Iterable others = IterableUtil.filter(aiPlayables, PaperCardPredicates.IS_NON_LAND); // We haven't yet ranked the off-color cards. // Compare them to the cards already in the deckList. List rankedOthers = CardRanker.rankCardsInPack(others, deckList, colors, true); @@ -490,7 +490,7 @@ private void addThirdColorCards(int num) { } hasColor = new MatchColorIdentity(colors).or(DeckGeneratorBase.COLORLESS_CARDS); - final Iterable threeColorList = Iterables.filter(rankedOthers, + final Iterable threeColorList = IterableUtil.filter(rankedOthers, PaperCardPredicates.fromRules(hasColor)); for (final PaperCard card : threeColorList) { if (num > 0) { @@ -517,7 +517,7 @@ private void addThirdColorCards(int num) { * number to add */ private void addRandomCards(int num) { - final Iterable others = Iterables.filter(aiPlayables, PaperCardPredicates.IS_NON_LAND); + final Iterable others = IterableUtil.filter(aiPlayables, PaperCardPredicates.IS_NON_LAND); List toAdd = new ArrayList<>(); for (final PaperCard card : others) { if (num > 0) { diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java index 52057254f13..2f8a5a1abdf 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayerAI.java @@ -9,7 +9,7 @@ import forge.item.PaperCard; import forge.item.PaperCardPredicates; import forge.localinstance.properties.ForgePreferences; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.MyRandom; import org.apache.commons.lang3.tuple.Pair; @@ -264,7 +264,7 @@ protected PaperCard chooseExchangeCard(PaperCard offer) { List deckCards = deck.getOrCreate(DeckSection.Sideboard).toFlatList(); DeckGeneratorBase.MatchColorIdentity hasColor = new DeckGeneratorBase.MatchColorIdentity(colors); - Iterable colorList = Iterables.filter(deckCards, + Iterable colorList = IterableUtil.filter(deckCards, PaperCardPredicates.fromRules(hasColor).negate()); PaperCard exchangeCard = null; diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java index 346f6a7ec83..60d6aa99c8a 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java @@ -9,6 +9,7 @@ import forge.card.ColorSet; import forge.card.MagicColor; import forge.item.PaperCard; +import forge.util.IterableUtil; import forge.util.Iterables; import forge.util.MyRandom; @@ -41,13 +42,13 @@ private ColorSet chooseColors() { colorChooserList.add(cp); } - Iterable rules = Iterables.transform(colorChooserList, PaperCard::getRules); + Iterable rules = IterableUtil.transform(colorChooserList, PaperCard::getRules); - int white = Iterables.size(Iterables.filter(rules, CardRulesPredicates.IS_WHITE)); - int blue = Iterables.size(Iterables.filter(rules, CardRulesPredicates.IS_BLUE)); - int black = Iterables.size(Iterables.filter(rules, CardRulesPredicates.IS_BLACK)); - int red = Iterables.size(Iterables.filter(rules, CardRulesPredicates.IS_RED)); - int green = Iterables.size(Iterables.filter(rules, CardRulesPredicates.IS_GREEN)); + int white = Iterables.size(IterableUtil.filter(rules, CardRulesPredicates.IS_WHITE)); + int blue = Iterables.size(IterableUtil.filter(rules, CardRulesPredicates.IS_BLUE)); + int black = Iterables.size(IterableUtil.filter(rules, CardRulesPredicates.IS_BLACK)); + int red = Iterables.size(IterableUtil.filter(rules, CardRulesPredicates.IS_RED)); + int green = Iterables.size(IterableUtil.filter(rules, CardRulesPredicates.IS_GREEN)); final int[] colorCounts = { white, blue, black, red, green }; int[] countsCopy = Arrays.copyOf(colorCounts, 5); diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java index a06a84b66bc..0dce64c767a 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java @@ -395,7 +395,7 @@ private void removeTarget(final GameEntity ge) { if (ge instanceof Card) { getController().getGui().setUsedToPay(CardView.get((Card) ge), false); // try to get last selected card - lastTarget = Iterables.getLast(Iterables.filter(targets, Card.class), null); + lastTarget = Iterables.getLast(IterableUtil.filter(targets, Card.class), null); } else if (ge instanceof Player) { getController().getGui().setHighlighted(PlayerView.get((Player) ge), false); diff --git a/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java b/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java index 4691c2c4d07..c42f07a4fb4 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java @@ -10,7 +10,7 @@ import forge.gui.interfaces.IGuiGame; import forge.interfaces.IGameController; import forge.interfaces.ILobbyListener; -import forge.util.Iterables; +import forge.util.IterableUtil; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.*; import io.netty.channel.nio.NioEventLoopGroup; @@ -148,7 +148,7 @@ public void broadcastExcept(final NetEvent event, final RemoteClient notTo) { } public void broadcastExcept(final NetEvent event, final Collection notTo) { Predicate filter = ((Predicate) notTo::contains).negate(); - broadcastTo(event, Iterables.filter(clients.values(), filter)); + broadcastTo(event, IterableUtil.filter(clients.values(), filter)); } private void broadcastTo(final NetEvent event, final Iterable to) { for (final RemoteClient client : to) { diff --git a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java index 00015208733..da43f352935 100644 --- a/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java +++ b/forge-gui/src/main/java/forge/gamemodes/planarconquest/ConquestUtil.java @@ -36,10 +36,7 @@ import forge.localinstance.skin.FSkinProp; import forge.localinstance.skin.IHasSkinProp; import forge.model.FModel; -import forge.util.FileUtil; -import forge.util.Iterables; -import forge.util.Localizer; -import forge.util.MyRandom; +import forge.util.*; public class ConquestUtil { private ConquestUtil() {} @@ -187,7 +184,7 @@ public static Iterable getStartingPlaneswalkerOptions(final PaperCard final byte colorIdentity = startingCommander.getRules().getColorIdentity().getColor(); final Set selected = Sets.newHashSet(); //TODO: Could make this more efficient by streaming unique cards and then mapping them to an acceptable print if they aren't already... - return Iterables.filter(FModel.getMagicDb().getCommonCards().getAllNonPromosNonReprintsNoAlt(), card -> { + return IterableUtil.filter(FModel.getMagicDb().getCommonCards().getAllNonPromosNonReprintsNoAlt(), card -> { if (selected.contains(card.getName())) { return false; } diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java index b8462670cf4..0f74413be48 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java @@ -25,15 +25,12 @@ import forge.card.*; import forge.item.*; -import forge.util.Iterables; -import forge.util.Predicates; +import forge.util.*; import org.apache.commons.lang3.StringUtils; import forge.game.GameFormat; import forge.gamemodes.quest.data.QuestPreferences.QPref; import forge.model.FModel; -import forge.util.Aggregates; -import forge.util.MyRandom; import forge.util.PredicateString.StringOp; /** @@ -185,7 +182,7 @@ public static List generateRandomBoosterPacks(final int quantity, List output = new ArrayList<>(); Predicate filter = CardEdition.Predicates.CAN_MAKE_BOOSTER.and(editionFilter); - Iterable possibleEditions = Iterables.filter(FModel.getMagicDb().getEditions(), filter); + Iterable possibleEditions = IterableUtil.filter(FModel.getMagicDb().getEditions(), filter); if (!possibleEditions.iterator().hasNext()) { System.err.println("No sets found in starting pool that can create boosters."); @@ -395,7 +392,7 @@ private static List generateCards( do { if (color2 != null) { Predicate color2c = PaperCardPredicates.fromRules(color2); - card = Aggregates.random(Iterables.filter(source, filter.and(color2c))); + card = Aggregates.random(IterableUtil.filter(source, filter.and(color2c))); } } while (card == null && colorMisses++ < 10); } @@ -486,7 +483,7 @@ private static List parseReward(final String s) { } PrintSheet ps = new PrintSheet("Quest rewards"); - Predicate predicate = Predicates.and(preds); + Predicate predicate = IterableUtil.and(preds); FModel.getMagicDb().getCommonCards().streamAllCards() .filter(predicate).forEach(ps::add); rewards.addAll(ps.random(qty, true)); diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java index cd3255c0a9e..a5a656876cf 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilCards.java @@ -790,7 +790,7 @@ public int getCompletionPercent(String edition) { // get all cards in the specified edition Predicate filter = PaperCardPredicates.printedInSet(edition); - Iterable editionCards = Iterables.filter(FModel.getMagicDb().getCommonCards().getAllCards(), filter); + Iterable editionCards = IterableUtil.filter(FModel.getMagicDb().getCommonCards().getAllCards(), filter); ItemPool ownedCards = questAssets.getCardPool(); // 100% means at least one of every basic land and at least 4 of every other card in the set diff --git a/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java b/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java index 3c0e419b158..f43e9aff453 100644 --- a/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java +++ b/forge-gui/src/main/java/forge/itemmanager/BooleanExpression.java @@ -8,8 +8,8 @@ import forge.card.CardRules; import forge.card.CardRulesPredicates; +import forge.util.IterableUtil; import forge.util.PredicateString.StringOp; -import forge.util.Predicates; public class BooleanExpression { private Stack operators = new Stack<>(); @@ -160,7 +160,7 @@ private Predicate valueOf(final String value) { predicates.add(CardRulesPredicates.cost(StringOp.CONTAINS_IC, value)); } if (!predicates.isEmpty()) { - return Predicates.or(predicates); + return IterableUtil.or(predicates); } return x -> true; diff --git a/forge-gui/src/main/java/forge/itemmanager/ColumnDef.java b/forge-gui/src/main/java/forge/itemmanager/ColumnDef.java index 173f1a301a7..48e9ba6abda 100644 --- a/forge-gui/src/main/java/forge/itemmanager/ColumnDef.java +++ b/forge-gui/src/main/java/forge/itemmanager/ColumnDef.java @@ -30,10 +30,7 @@ import forge.item.PaperCard; import forge.itemmanager.ItemColumnConfig.SortState; import forge.model.FModel; -import forge.util.CardTranslation; -import forge.util.Iterables; -import forge.util.Localizer; -import forge.util.TextUtil; +import forge.util.*; import org.apache.commons.lang3.StringUtils; @@ -190,7 +187,7 @@ public enum ColumnDef { sanctioned.add(gf); } } - return StringUtils.join(Iterables.transform(sanctioned, GameFormat::getName), ", "); + return StringUtils.join(IterableUtil.transform(sanctioned, GameFormat::getName), ", "); }), /** * The Draft ranking column. diff --git a/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java b/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java index d0c838fd048..496884ef97e 100644 --- a/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java +++ b/forge-gui/src/main/java/forge/itemmanager/SFilterUtil.java @@ -24,8 +24,8 @@ import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; import forge.util.BinaryUtil; +import forge.util.IterableUtil; import forge.util.PredicateString.StringOp; -import forge.util.Predicates; /** * Static factory; holds blocks of form elements and predicates @@ -70,10 +70,10 @@ public static Predicate buildTextFilter(String text, boolean invert, if (inText) { subands.add(CardRulesPredicates.rules(StringOp.CONTAINS_IC, s)); } if (inCost) { subands.add(CardRulesPredicates.cost(StringOp.CONTAINS_IC, s)); } - terms.add(Predicates.or(subands)); + terms.add(IterableUtil.or(subands)); } Predicate textFilter; - textFilter = invert ? Predicates.or(terms).negate() : Predicates.and(terms); + textFilter = invert ? IterableUtil.or(terms).negate() : IterableUtil.and(terms); return PaperCardPredicates.fromRules(textFilter); } @@ -381,7 +381,7 @@ public static Predicate buildFormatFilter(Set formats, bo for (GameFormat f : formats) { predicates.add(allowReprints ? f.getFilterRules() : f.getFilterPrinted()); } - return Predicates.or(predicates); + return IterableUtil.or(predicates); } public static Predicate optimizedAnd(Predicate p1, Predicate p2) { diff --git a/forge-gui/src/main/java/forge/player/TargetSelection.java b/forge-gui/src/main/java/forge/player/TargetSelection.java index 52a7e2f3a8e..679bb1cdb7e 100644 --- a/forge-gui/src/main/java/forge/player/TargetSelection.java +++ b/forge-gui/src/main/java/forge/player/TargetSelection.java @@ -47,7 +47,7 @@ import forge.game.zone.ZoneType; import forge.gamemodes.match.input.InputSelectTargets; import forge.util.Aggregates; -import forge.util.Iterables; +import forge.util.IterableUtil; import forge.util.TextUtil; /** @@ -117,7 +117,7 @@ public final boolean chooseTargets(Integer numTargets, Collection divis boolean hasEnoughCandidates = candidates.size() >= minTargets; if (tgt.isDifferentControllers() || tgt.isForEachPlayer()) { PlayerCollection controllers = new PlayerCollection(); - Iterables.filter(candidates, Card.class).forEach(c -> controllers.add(c.getController())); + IterableUtil.filter(candidates, Card.class).forEach(c -> controllers.add(c.getController())); hasEnoughCandidates &= controllers.size() >= minTargets; } mandatory &= hasEnoughCandidates; @@ -154,7 +154,7 @@ public final boolean chooseTargets(Integer numTargets, Collection divis mustTargetFiltered = StaticAbilityMustTarget.filterMustTargetCards(controller.getPlayer(), validTargets, ability); } if (filter != null) { - validTargets = new CardCollection(Iterables.filter(validTargets, filter)); + validTargets = new CardCollection(IterableUtil.filter(validTargets, filter)); } // single zone From 6a04fcd50057bb478d509dfabb1fef819fd7c35d Mon Sep 17 00:00:00 2001 From: Jetz Date: Thu, 26 Sep 2024 09:36:50 -0400 Subject: [PATCH 55/68] Guava migration - Remove migration scaffold --- .../java/forge/ai/AiAttackController.java | 1 + .../src/main/java/forge/ai/AiController.java | 1 + .../src/main/java/forge/ai/ComputerUtil.java | 5 +- .../main/java/forge/ai/ComputerUtilCard.java | 1 + .../java/forge/ai/ComputerUtilCombat.java | 6 +- .../java/forge/ai/PlayerControllerAi.java | 5 +- .../main/java/forge/ai/SpecialAiLogic.java | 2 +- .../src/main/java/forge/ai/SpecialCardAi.java | 1 + .../main/java/forge/ai/SpellAbilityAi.java | 4 +- .../main/java/forge/ai/ability/AmassAi.java | 2 +- .../java/forge/ai/ability/AssignGroupAi.java | 4 +- .../java/forge/ai/ability/ChangeZoneAi.java | 2 +- .../java/forge/ai/ability/ChooseCardAi.java | 2 +- .../forge/ai/ability/ChooseCardNameAi.java | 2 +- .../java/forge/ai/ability/ChoosePlayerAi.java | 2 +- .../java/forge/ai/ability/ChooseSourceAi.java | 2 +- .../java/forge/ai/ability/ChooseTypeAi.java | 2 +- .../main/java/forge/ai/ability/ClashAi.java | 2 +- .../java/forge/ai/ability/ControlGainAi.java | 2 +- .../ai/ability/ControlGainVariantAi.java | 2 +- .../forge/ai/ability/CopyPermanentAi.java | 2 +- .../java/forge/ai/ability/CountersMoveAi.java | 2 +- .../java/forge/ai/ability/CountersPutAi.java | 2 +- .../ai/ability/CountersPutOrRemoveAi.java | 2 +- .../forge/ai/ability/CountersRemoveAi.java | 2 +- .../src/main/java/forge/ai/ability/DigAi.java | 2 +- .../main/java/forge/ai/ability/EffectAi.java | 2 +- .../forge/ai/ability/LegendaryRuleAi.java | 2 +- .../java/forge/ai/ability/LifeGainAi.java | 2 +- .../java/forge/ai/ability/ManifestBaseAi.java | 2 +- .../java/forge/ai/ability/MustBlockAi.java | 2 +- .../main/java/forge/ai/ability/RevealAi.java | 2 +- .../java/forge/ai/ability/TimeTravelAi.java | 2 +- .../main/java/forge/ai/ability/TokenAi.java | 2 +- .../src/main/java/forge/card/CardRules.java | 2 +- .../src/main/java/forge/card/CardType.java | 15 ++-- .../src/main/java/forge/card/DeckHints.java | 2 +- .../src/main/java/forge/deck/DeckFormat.java | 2 +- .../src/main/java/forge/util/Iterables.java | 68 ------------------- forge-core/src/main/java/forge/util/Lang.java | 1 + .../java/forge/util/collect/FCollection.java | 7 +- .../src/main/java/forge/game/GameAction.java | 1 - .../main/java/forge/game/GameEntityView.java | 2 +- .../java/forge/game/GameLogFormatter.java | 1 + .../src/main/java/forge/game/GameView.java | 2 +- .../src/main/java/forge/game/Match.java | 8 +-- .../java/forge/game/ability/AbilityUtils.java | 1 - .../game/ability/SpellAbilityEffect.java | 1 + .../game/ability/effects/AttachEffect.java | 2 +- .../game/ability/effects/BidLifeEffect.java | 2 +- .../ability/effects/ChangeTargetsEffect.java | 2 +- .../ability/effects/ChangeZoneAllEffect.java | 2 +- .../ability/effects/ChangeZoneEffect.java | 1 + .../ability/effects/ControlSpellEffect.java | 2 +- .../ability/effects/DamageDealEffect.java | 1 + .../ability/effects/DelayedTriggerEffect.java | 2 +- .../game/ability/effects/DiscardEffect.java | 1 + .../game/ability/effects/MakeCardEffect.java | 1 + .../ability/effects/MultiplePilesEffect.java | 2 +- .../game/ability/effects/PumpAllEffect.java | 2 +- .../effects/RearrangeTopOfLibraryEffect.java | 2 +- .../game/ability/effects/TokenEffectBase.java | 2 +- .../src/main/java/forge/game/card/Card.java | 1 - .../java/forge/game/card/CardFactoryUtil.java | 5 +- .../java/forge/game/card/CardProperty.java | 2 +- .../main/java/forge/game/card/CardState.java | 2 +- .../main/java/forge/game/card/CardView.java | 1 + .../java/forge/game/card/CardZoneTable.java | 2 +- .../java/forge/game/card/token/TokenInfo.java | 2 +- .../forge/game/combat/AttackConstraints.java | 7 +- .../game/event/GameEventCardStatsChanged.java | 2 +- .../forge/game/mana/ManaCostBeingPaid.java | 4 +- .../main/java/forge/game/player/Player.java | 1 - .../forge/game/player/PlayerProperty.java | 2 +- .../java/forge/game/player/PlayerView.java | 2 +- .../forge/game/player/RegisteredPlayer.java | 2 +- .../forge/game/spellability/SpellAbility.java | 7 +- .../spellability/SpellAbilityCondition.java | 2 +- .../game/spellability/TargetChoices.java | 2 +- .../StaticAbilityContinuous.java | 2 +- .../main/java/forge/game/trigger/Trigger.java | 2 +- .../game/trigger/TriggerAbilityTriggered.java | 2 +- .../game/trigger/TriggerAttackerBlocked.java | 2 +- .../forge/game/trigger/TriggerHandler.java | 6 +- .../main/java/forge/game/zone/PlayerZone.java | 2 +- .../filters/AdvancedSearchFilter.java | 2 +- .../java/forge/screens/bazaar/CBazaarUI.java | 2 +- .../main/java/forge/screens/home/CLobby.java | 2 +- .../main/java/forge/screens/home/VLobby.java | 1 + .../screens/match/controllers/CCombat.java | 2 +- .../workshop/views/VWorkshopCatalog.java | 2 +- .../util/PlayerControllerForTests.java | 2 +- .../util/SpecificationHandler.java | 2 +- .../test/java/forge/item/DeckHintsTest.java | 2 +- .../src/forge/adventure/data/RewardData.java | 2 +- .../src/forge/adventure/util/CardUtil.java | 2 +- .../filters/AdvancedSearchFilter.java | 2 +- .../screens/constructed/LobbyScreen.java | 2 +- .../forge/screens/match/views/VReveal.java | 2 +- .../planarconquest/ConquestAEtherScreen.java | 1 + .../planarconquest/NewConquestScreen.java | 2 +- .../src/forge/toolbox/GuiChoose.java | 2 +- .../java/forge/deck/RandomDeckGenerator.java | 5 +- .../forge/gamemodes/limited/CardRanker.java | 2 +- .../gamemodes/limited/LimitedPlayer.java | 2 +- .../gamemodes/limited/SealedDeckBuilder.java | 2 +- .../gamemodes/match/AbstractGuiGame.java | 7 +- .../match/input/InputSelectManyBase.java | 2 +- .../match/input/InputSelectTargets.java | 1 + .../download/GuiDownloadSetPicturesLQ.java | 2 +- .../main/java/forge/gui/util/SGuiChoose.java | 2 +- .../java/forge/player/HumanCostDecision.java | 1 + .../src/main/java/forge/player/HumanPlay.java | 5 +- .../forge/player/HumanPlaySpellAbility.java | 2 +- .../forge/player/PlayerControllerHuman.java | 1 - 115 files changed, 120 insertions(+), 223 deletions(-) delete mode 100644 forge-core/src/main/java/forge/util/Iterables.java diff --git a/forge-ai/src/main/java/forge/ai/AiAttackController.java b/forge-ai/src/main/java/forge/ai/AiAttackController.java index 8deb61891d0..8b52c51dba5 100644 --- a/forge-ai/src/main/java/forge/ai/AiAttackController.java +++ b/forge-ai/src/main/java/forge/ai/AiAttackController.java @@ -17,6 +17,7 @@ */ package forge.ai; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.ability.AnimateAi; import forge.game.GameEntity; diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index 7f603a8719e..d82ffe69408 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -18,6 +18,7 @@ package forge.ai; import com.esotericsoftware.minlog.Log; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.ability.ChangeZoneAi; import forge.ai.ability.LearnAi; diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index aceccc32aab..ef2237e2f8b 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -20,10 +20,7 @@ import java.util.*; import java.util.function.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; +import com.google.common.collect.*; import forge.game.card.*; import forge.game.cost.*; import forge.util.*; diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index e19e39fd980..f4d589a2e5e 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -6,6 +6,7 @@ import java.util.function.Predicate; import java.util.stream.Stream; +import com.google.common.collect.Iterables; import forge.ai.simulation.GameStateEvaluator; import forge.card.mana.ManaCost; import forge.game.card.*; diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java index 0afca935bc1..1decb6e77b4 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCombat.java @@ -17,6 +17,7 @@ */ package forge.ai; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import forge.game.Game; @@ -43,7 +44,6 @@ import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; import forge.util.IterableUtil; -import forge.util.Iterables; import forge.util.MyRandom; import forge.util.TextUtil; import forge.util.collect.FCollection; @@ -2539,10 +2539,10 @@ public static GameEntity addAttackerToCombat(SpellAbility sa, Card attacker, Ite GameEntity def = combat.getDefenderByAttacker(sa.getHostCard()); // 1. If the card that spawned the attacker was sent at a card, attack the same. Consider improving. if (def instanceof Card && Iterables.contains(defenders, def)) { - if (((Card)def).isPlaneswalker()) { + if (((Card) def).isPlaneswalker()) { return def; } - if (((Card)def).isBattle()) { + if (((Card) def).isBattle()) { return def; } } diff --git a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java index 5136a9e8096..773c2a7ebe8 100644 --- a/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java +++ b/forge-ai/src/main/java/forge/ai/PlayerControllerAi.java @@ -1,9 +1,6 @@ package forge.ai; -import com.google.common.collect.ListMultimap; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Multimap; +import com.google.common.collect.*; import forge.LobbyPlayer; import forge.ai.ability.ProtectAi; import forge.card.CardStateName; diff --git a/forge-ai/src/main/java/forge/ai/SpecialAiLogic.java b/forge-ai/src/main/java/forge/ai/SpecialAiLogic.java index 77ddf327c18..0bb9c6f0dae 100644 --- a/forge-ai/src/main/java/forge/ai/SpecialAiLogic.java +++ b/forge-ai/src/main/java/forge/ai/SpecialAiLogic.java @@ -1,5 +1,6 @@ package forge.ai; +import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import forge.ai.ability.TokenAi; @@ -16,7 +17,6 @@ import forge.game.zone.ZoneType; import forge.util.Aggregates; import forge.util.Expressions; -import forge.util.Iterables; import java.util.List; diff --git a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java index 91b0457a3a8..96981dc84d7 100644 --- a/forge-ai/src/main/java/forge/ai/SpecialCardAi.java +++ b/forge-ai/src/main/java/forge/ai/SpecialCardAi.java @@ -17,6 +17,7 @@ */ package forge.ai; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.ability.AnimateAi; import forge.ai.ability.FightAi; diff --git a/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java b/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java index 95742d46631..df9b899de51 100644 --- a/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java +++ b/forge-ai/src/main/java/forge/ai/SpellAbilityAi.java @@ -1,5 +1,6 @@ package forge.ai; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.card.CardStateName; import forge.card.ICardFace; @@ -19,7 +20,6 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbilityCondition; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.MyRandom; import java.util.Collection; @@ -361,7 +361,7 @@ protected GameEntity chooseSingleAttackableEntity(Player ai, SpellAbility sa, It public String chooseCardName(Player ai, SpellAbility sa, List faces) { System.err.println("Warning: default (ie. inherited from base class) implementation of chooseCardName is used for " + this.getClass().getName() + ". Consider declaring an overloaded method"); - final ICardFace face = Iterables.getFirst(faces, null); + final ICardFace face = Iterables.getFirst(faces, null); return face == null ? "" : face.getName(); } diff --git a/forge-ai/src/main/java/forge/ai/ability/AmassAi.java b/forge-ai/src/main/java/forge/ai/ability/AmassAi.java index 31adb3781b8..66e272af130 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AmassAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AmassAi.java @@ -2,6 +2,7 @@ import java.util.Map; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -20,7 +21,6 @@ import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; public class AmassAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/AssignGroupAi.java b/forge-ai/src/main/java/forge/ai/ability/AssignGroupAi.java index d97cbda5aab..abf8b22cf49 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AssignGroupAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AssignGroupAi.java @@ -3,10 +3,10 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import forge.ai.SpellAbilityAi; import forge.game.player.Player; import forge.game.spellability.SpellAbility; -import forge.util.Iterables; public class AssignGroupAi extends SpellAbilityAi { @@ -26,7 +26,7 @@ public SpellAbility chooseSingleSpellAbility(Player player, SpellAbility sa, Lis return spells.get(player.isOpponentOf(t) ? 1 : 0); } } - + return Iterables.getFirst(spells, null); } } diff --git a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java index d11af4a45e9..b6cf58d4b09 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAi.java @@ -1,5 +1,6 @@ package forge.ai.ability; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import forge.ai.*; @@ -26,7 +27,6 @@ import forge.game.staticability.StaticAbilityMustTarget; import forge.game.zone.ZoneType; import forge.util.Aggregates; -import forge.util.Iterables; import forge.util.MyRandom; import org.apache.commons.lang3.StringUtils; diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java index 6f01a7ea4cd..fc40e652d68 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import forge.ai.AiAttackController; import forge.ai.ComputerUtilAbility; import forge.ai.ComputerUtilCard; @@ -26,7 +27,6 @@ import forge.game.zone.ZoneType; import forge.util.Aggregates; import forge.util.IterableUtil; -import forge.util.Iterables; public class ChooseCardAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseCardNameAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseCardNameAi.java index affe9aeaaba..6f16595eedb 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCardNameAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCardNameAi.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.StaticData; @@ -25,7 +26,6 @@ import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; import forge.item.PaperCard; -import forge.util.Iterables; import forge.util.MyRandom; public class ChooseCardNameAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChoosePlayerAi.java b/forge-ai/src/main/java/forge/ai/ability/ChoosePlayerAi.java index a8a03436699..d2e1aed14a1 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChoosePlayerAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChoosePlayerAi.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.ComputerUtil; @@ -12,7 +13,6 @@ import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; public class ChoosePlayerAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java index 43bbf5dc13b..52e44bb50db 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import forge.ai.AiAttackController; import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCombat; @@ -23,7 +24,6 @@ import forge.game.spellability.SpellAbilityStackInstance; import forge.game.zone.ZoneType; import forge.util.Aggregates; -import forge.util.Iterables; public class ChooseSourceAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java index b85501fe732..fca70976b61 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Set; +import com.google.common.collect.Iterables; import forge.ai.AiCardMemory; import forge.ai.ComputerUtilAbility; import forge.ai.ComputerUtilCard; @@ -25,7 +26,6 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Aggregates; -import forge.util.Iterables; public class ChooseTypeAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/ClashAi.java b/forge-ai/src/main/java/forge/ai/ability/ClashAi.java index 4e4f4c5f77c..30efdfe6b3e 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ClashAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ClashAi.java @@ -3,6 +3,7 @@ import java.util.Map; +import com.google.common.collect.Iterables; import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; import forge.game.card.Card; @@ -14,7 +15,6 @@ import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; public class ClashAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java b/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java index a84edee7d00..7f7c70bd8fb 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.ComputerUtil; @@ -42,7 +43,6 @@ import forge.game.staticability.StaticAbilityMustTarget; import forge.game.zone.ZoneType; import forge.util.Aggregates; -import forge.util.Iterables; //AB:GainControl|ValidTgts$Creature|TgtPrompt$Select target legendary creature|LoseControl$Untap,LoseControl|SpellDescription$Gain control of target xxxxxxx diff --git a/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java b/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java index b7ffe94c3b4..8c43ea29c56 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; import forge.game.card.Card; @@ -28,7 +29,6 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; /** diff --git a/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java b/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java index a4082a42c74..c0fe8337941 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java @@ -5,6 +5,7 @@ import java.util.Map; import java.util.function.Predicate; +import com.google.common.collect.Iterables; import forge.ai.AiPlayDecision; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilAbility; @@ -30,7 +31,6 @@ import forge.game.player.PlayerCollection; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; public class CopyPermanentAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java index 77fe4368de7..40018954cee 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; @@ -15,7 +16,6 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.MyRandom; import forge.util.collect.FCollection; diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java index 704ded794a2..4a2e467b986 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutAi.java @@ -1,5 +1,6 @@ package forge.ai.ability; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.*; import forge.game.Game; @@ -25,7 +26,6 @@ import forge.game.zone.ZoneType; import forge.util.Aggregates; import forge.util.IterableUtil; -import forge.util.Iterables; import forge.util.MyRandom; import java.util.Collections; diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java index 26309cec653..bd59630e797 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.function.Predicate; +import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; @@ -39,7 +40,6 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; -import forge.util.Iterables; /** *

diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java index d411413e61b..3ddaa19cf13 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java @@ -4,6 +4,7 @@ import java.util.Map; import java.util.function.Predicate; +import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCost; @@ -25,7 +26,6 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; -import forge.util.Iterables; public class CountersRemoveAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/DigAi.java b/forge-ai/src/main/java/forge/ai/ability/DigAi.java index 9e8ce50009f..79f8ca128fe 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DigAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DigAi.java @@ -2,6 +2,7 @@ import java.util.Map; +import com.google.common.collect.Iterables; import forge.ai.AiAttackController; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilAbility; @@ -24,7 +25,6 @@ import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.TextUtil; diff --git a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java index 699a4c053a8..263ce13df5a 100644 --- a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java @@ -1,5 +1,6 @@ package forge.ai.ability; +import com.google.common.collect.Iterables; import forge.ai.*; import forge.game.CardTraitPredicates; import forge.game.Game; @@ -23,7 +24,6 @@ import forge.game.spellability.TargetRestrictions; import forge.game.zone.MagicStack; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.MyRandom; import forge.util.TextUtil; diff --git a/forge-ai/src/main/java/forge/ai/ability/LegendaryRuleAi.java b/forge-ai/src/main/java/forge/ai/ability/LegendaryRuleAi.java index e6ffd0c60a4..45c7060d34f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LegendaryRuleAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LegendaryRuleAi.java @@ -2,6 +2,7 @@ import java.util.Map; +import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.SpellAbilityAi; import forge.game.card.Card; @@ -9,7 +10,6 @@ import forge.game.card.CounterEnumType; import forge.game.player.Player; import forge.game.spellability.SpellAbility; -import forge.util.Iterables; /** * TODO: Write javadoc for this type. diff --git a/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java b/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java index 1907f315e98..2462fd6d716 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java @@ -1,5 +1,6 @@ package forge.ai.ability; +import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilAbility; import forge.ai.ComputerUtilCombat; @@ -18,7 +19,6 @@ import forge.game.player.PlayerPredicates; import forge.game.spellability.AbilitySub; import forge.game.spellability.SpellAbility; -import forge.util.Iterables; import forge.util.MyRandom; public class LifeGainAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/ManifestBaseAi.java b/forge-ai/src/main/java/forge/ai/ability/ManifestBaseAi.java index 85a35809895..5dbf8617ec8 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ManifestBaseAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ManifestBaseAi.java @@ -2,6 +2,7 @@ import java.util.Map; +import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCost; @@ -17,7 +18,6 @@ import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.MyRandom; /** diff --git a/forge-ai/src/main/java/forge/ai/ability/MustBlockAi.java b/forge-ai/src/main/java/forge/ai/ability/MustBlockAi.java index 0be815470e0..b8c21e2dda8 100644 --- a/forge-ai/src/main/java/forge/ai/ability/MustBlockAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/MustBlockAi.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import forge.ai.AiCardMemory; import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCombat; @@ -17,7 +18,6 @@ import forge.game.phase.PhaseType; import forge.game.player.Player; import forge.game.spellability.SpellAbility; -import forge.util.Iterables; public class MustBlockAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/RevealAi.java b/forge-ai/src/main/java/forge/ai/ability/RevealAi.java index 7bb856b3b5a..7acb1e17ff5 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RevealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RevealAi.java @@ -1,5 +1,6 @@ package forge.ai.ability; +import com.google.common.collect.Iterables; import forge.ai.AiPlayDecision; import forge.ai.PlayerControllerAi; import forge.game.ability.AbilityUtils; @@ -8,7 +9,6 @@ import forge.game.player.Player; import forge.game.spellability.Spell; import forge.game.spellability.SpellAbility; -import forge.util.Iterables; import forge.util.MyRandom; public class RevealAi extends RevealAiBase { diff --git a/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java b/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java index 8aa29b830d7..db08e348fe1 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java @@ -1,5 +1,6 @@ package forge.ai.ability; +import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.SpellAbilityAi; import forge.game.card.*; @@ -8,7 +9,6 @@ import forge.game.player.PlayerController; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; import java.util.Map; diff --git a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java index 7407e41fb4c..ee1587d4ca6 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import forge.ai.AiController; import forge.ai.AiProps; import forge.ai.ComputerUtil; @@ -39,7 +40,6 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.MyRandom; /** diff --git a/forge-core/src/main/java/forge/card/CardRules.java b/forge-core/src/main/java/forge/card/CardRules.java index 691734bb135..5fd541fda23 100644 --- a/forge-core/src/main/java/forge/card/CardRules.java +++ b/forge-core/src/main/java/forge/card/CardRules.java @@ -19,8 +19,8 @@ import java.util.*; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import com.google.common.collect.Maps; diff --git a/forge-core/src/main/java/forge/card/CardType.java b/forge-core/src/main/java/forge/card/CardType.java index a38d0872a4e..b3a95c0e7bd 100644 --- a/forge-core/src/main/java/forge/card/CardType.java +++ b/forge-core/src/main/java/forge/card/CardType.java @@ -20,19 +20,12 @@ import java.util.*; import java.util.function.Predicate; +import com.google.common.collect.*; import forge.util.IterableUtil; -import forge.util.Iterables; import org.apache.commons.lang3.EnumUtils; import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - import forge.util.Settable; /** @@ -197,9 +190,9 @@ public boolean addAll(final CardType type) { } public boolean addAll(final CardTypeView type) { boolean changed = false; - if (Iterables.addAll_withReturn(coreTypes, type.getCoreTypes())) { changed = true; } - if (Iterables.addAll_withReturn(supertypes, type.getSupertypes())) { changed = true; } - if (Iterables.addAll_withReturn(subtypes, type.getSubtypes())) { changed = true; } + if (Iterables.addAll(coreTypes, type.getCoreTypes())) { changed = true; } + if (Iterables.addAll(supertypes, type.getSupertypes())) { changed = true; } + if (Iterables.addAll(subtypes, type.getSubtypes())) { changed = true; } sanisfySubtypes(); return changed; } diff --git a/forge-core/src/main/java/forge/card/DeckHints.java b/forge-core/src/main/java/forge/card/DeckHints.java index 0e617d55535..a813d75ec8b 100644 --- a/forge-core/src/main/java/forge/card/DeckHints.java +++ b/forge-core/src/main/java/forge/card/DeckHints.java @@ -4,8 +4,8 @@ import java.util.function.Function; import java.util.function.Predicate; +import com.google.common.collect.Iterables; import forge.util.IterableUtil; -import forge.util.Iterables; import org.apache.commons.lang3.tuple.Pair; import forge.StaticData; diff --git a/forge-core/src/main/java/forge/deck/DeckFormat.java b/forge-core/src/main/java/forge/deck/DeckFormat.java index c7f0e055126..169d5fdca2b 100644 --- a/forge-core/src/main/java/forge/deck/DeckFormat.java +++ b/forge-core/src/main/java/forge/deck/DeckFormat.java @@ -18,6 +18,7 @@ package forge.deck; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; import forge.StaticData; import forge.card.CardRules; import forge.card.CardRulesPredicates; @@ -31,7 +32,6 @@ import forge.item.PaperCard; import forge.item.PaperCardPredicates; import forge.util.Aggregates; -import forge.util.Iterables; import forge.util.TextUtil; import org.apache.commons.lang3.Range; import org.apache.commons.lang3.tuple.ImmutablePair; diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java deleted file mode 100644 index 02f1d2e0721..00000000000 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ /dev/null @@ -1,68 +0,0 @@ -package forge.util; - -import java.util.Collection; - -/** - * Provides helper methods for Iterables similar to the Guava library, - * but supporting Java 8's implementation of Iterators instead. - */ -public class Iterables { - private Iterables(){} - - //TODO: Restore everything below - public static Iterable unmodifiableIterable(final Iterable iterable) { - return com.google.common.collect.Iterables.unmodifiableIterable(iterable); - } - - public static int size(Iterable iterable) { - return com.google.common.collect.Iterables.size(iterable); - } - - public static boolean contains(Iterable iterable, Object element) { - return com.google.common.collect.Iterables.contains(iterable, element); - } - - public static boolean addAll_withReturn(Collection collection, Iterable toAdd) { - return com.google.common.collect.Iterables.addAll(collection, toAdd); - } - - public static Iterable concat(Iterable a, Iterable b) { - return com.google.common.collect.Iterables.concat(a, b); - } - public static Iterable concat(Iterable> inputs) { - return com.google.common.collect.Iterables.concat(inputs); - } - public static Iterable concat(Iterable a, Iterable b, Iterable c) { - return com.google.common.collect.Iterables.concat(a, b, c); - } - public static Iterable concat(Iterable a, Iterable b, Iterable c, Iterable d) { - return com.google.common.collect.Iterables.concat(a, b, c, d); - } - - public static int frequency(Iterable iterable, Object element) { - return com.google.common.collect.Iterables.frequency(iterable, element); - } - - public static T get(Iterable iterable, int position) { - return com.google.common.collect.Iterables.get(iterable, position); - } - - public static T getFirst(Iterable iterable, T defaultValue) { - return com.google.common.collect.Iterables.getFirst(iterable, defaultValue); - } - - public static T getLast(Iterable iterable) { - return com.google.common.collect.Iterables.getLast(iterable); - } - public static T getLast(Iterable iterable, T defaultValue) { - return com.google.common.collect.Iterables.getLast(iterable, defaultValue); - } - - public static Iterable limit(final Iterable iterable, final int limitSize) { - return com.google.common.collect.Iterables.limit(iterable, limitSize); - } - - public static boolean isEmpty(Iterable iterable) { - return com.google.common.collect.Iterables.isEmpty(iterable); - } -} diff --git a/forge-core/src/main/java/forge/util/Lang.java b/forge-core/src/main/java/forge/util/Lang.java index cfd0053b4e2..f6674cb1d1f 100644 --- a/forge-core/src/main/java/forge/util/Lang.java +++ b/forge-core/src/main/java/forge/util/Lang.java @@ -5,6 +5,7 @@ import java.util.function.Function; import java.util.regex.Pattern; +import com.google.common.collect.Iterables; import org.apache.commons.lang3.StringUtils; import com.google.common.collect.Lists; 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 c2bad40335b..7753a2a918f 100644 --- a/forge-core/src/main/java/forge/util/collect/FCollection.java +++ b/forge-core/src/main/java/forge/util/collect/FCollection.java @@ -14,14 +14,9 @@ import java.util.function.Predicate; import java.util.stream.Stream; -import forge.util.Iterables; +import com.google.common.collect.*; import org.apache.commons.lang3.ArrayUtils; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import com.google.common.collect.Ordering; -import com.google.common.collect.Sets; - /** * Collection with unique elements ({@link Set}) that maintains the order in * which the elements are added to it ({@link List}). diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index 7b2743b4396..c21debe0165 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -53,7 +53,6 @@ import forge.game.zone.ZoneType; import forge.item.PaperCard; import forge.util.*; -import forge.util.Iterables; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; import org.apache.commons.lang3.tuple.ImmutablePair; diff --git a/forge-game/src/main/java/forge/game/GameEntityView.java b/forge-game/src/main/java/forge/game/GameEntityView.java index 90ccca22323..9b7a1b3a0f7 100644 --- a/forge-game/src/main/java/forge/game/GameEntityView.java +++ b/forge-game/src/main/java/forge/game/GameEntityView.java @@ -1,12 +1,12 @@ package forge.game; +import com.google.common.collect.Iterables; import forge.game.card.CardView; import forge.trackable.TrackableCollection; import forge.trackable.TrackableObject; import forge.trackable.TrackableProperty; import forge.trackable.Tracker; import forge.util.IterableUtil; -import forge.util.Iterables; public abstract class GameEntityView extends TrackableObject { private static final long serialVersionUID = -5129089945124455670L; diff --git a/forge-game/src/main/java/forge/game/GameLogFormatter.java b/forge-game/src/main/java/forge/game/GameLogFormatter.java index 4f67bb4b74e..cbea29a7d95 100644 --- a/forge-game/src/main/java/forge/game/GameLogFormatter.java +++ b/forge-game/src/main/java/forge/game/GameLogFormatter.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.Map.Entry; +import com.google.common.collect.Iterables; import com.google.common.eventbus.Subscribe; import forge.LobbyPlayer; diff --git a/forge-game/src/main/java/forge/game/GameView.java b/forge-game/src/main/java/forge/game/GameView.java index 476d94cb721..10e0da7a76b 100644 --- a/forge-game/src/main/java/forge/game/GameView.java +++ b/forge-game/src/main/java/forge/game/GameView.java @@ -2,6 +2,7 @@ import java.util.List; +import com.google.common.collect.Iterables; import forge.LobbyPlayer; import forge.deck.Deck; import forge.game.GameOutcome.AnteResult; @@ -19,7 +20,6 @@ import forge.trackable.TrackableCollection; import forge.trackable.TrackableObject; import forge.trackable.TrackableProperty; -import forge.util.Iterables; import forge.util.collect.FCollectionView; public class GameView extends TrackableObject { diff --git a/forge-game/src/main/java/forge/game/Match.java b/forge-game/src/main/java/forge/game/Match.java index 109e6c2da53..2c5b7e3605e 100644 --- a/forge-game/src/main/java/forge/game/Match.java +++ b/forge-game/src/main/java/forge/game/Match.java @@ -1,11 +1,6 @@ package forge.game; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.HashMultiset; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multiset; +import com.google.common.collect.*; import com.google.common.eventbus.EventBus; import forge.LobbyPlayer; import forge.deck.CardPool; @@ -25,7 +20,6 @@ import forge.game.zone.PlayerZone; import forge.game.zone.ZoneType; import forge.item.PaperCard; -import forge.util.Iterables; import forge.util.Localizer; import forge.util.MyRandom; import forge.util.collect.FCollectionView; diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index 5e72902f9df..aa8fec0b5d5 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -30,7 +30,6 @@ import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; import forge.util.*; -import forge.util.Iterables; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; import io.sentry.Breadcrumb; diff --git a/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java b/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java index 052223b214c..78d127ecfb3 100644 --- a/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java +++ b/forge-game/src/main/java/forge/game/ability/SpellAbilityEffect.java @@ -1,5 +1,6 @@ package forge.game.ability; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Table; diff --git a/forge-game/src/main/java/forge/game/ability/effects/AttachEffect.java b/forge-game/src/main/java/forge/game/ability/effects/AttachEffect.java index 014d3433e0b..386af44b332 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/AttachEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/AttachEffect.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import forge.game.Game; import forge.game.GameActionUtil; import forge.game.GameEntity; @@ -21,7 +22,6 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.CardTranslation; -import forge.util.Iterables; import forge.util.Lang; import forge.util.Localizer; import forge.util.collect.FCollection; diff --git a/forge-game/src/main/java/forge/game/ability/effects/BidLifeEffect.java b/forge-game/src/main/java/forge/game/ability/effects/BidLifeEffect.java index 39490a706a0..bf86680c19b 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/BidLifeEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/BidLifeEffect.java @@ -1,12 +1,12 @@ package forge.game.ability.effects; +import com.google.common.collect.Iterables; import forge.game.ability.AbilityUtils; import forge.game.ability.SpellAbilityEffect; import forge.game.card.Card; import forge.game.player.Player; import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; -import forge.util.Iterables; import forge.util.Localizer; import forge.util.collect.FCollection; diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java index d8a202fd944..7cf05cd02af 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.function.Predicate; -import forge.util.Iterables; +import com.google.common.collect.Iterables; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneAllEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneAllEffect.java index 9686580fbfd..a3cb790e883 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneAllEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneAllEffect.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import forge.game.Game; import forge.game.GameActionUtil; import forge.game.GameEntityCounterTable; @@ -15,7 +16,6 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.Zone; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.Lang; import forge.util.Localizer; import forge.util.TextUtil; diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java index d575b8fa318..f4ace0bfc4b 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java @@ -1,5 +1,6 @@ package forge.game.ability.effects; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; diff --git a/forge-game/src/main/java/forge/game/ability/effects/ControlSpellEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ControlSpellEffect.java index 232342da635..2b694f5fe73 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ControlSpellEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ControlSpellEffect.java @@ -2,6 +2,7 @@ import java.util.List; +import com.google.common.collect.Iterables; import forge.game.Game; import forge.game.GameObject; import forge.game.ability.SpellAbilityEffect; @@ -9,7 +10,6 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbilityStackInstance; -import forge.util.Iterables; public class ControlSpellEffect extends SpellAbilityEffect { /* (non-Javadoc) diff --git a/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java b/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java index 395fa8a4bc6..ff78d9b5d1c 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java @@ -4,6 +4,7 @@ import java.util.Map; import java.util.Map.Entry; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.game.Game; diff --git a/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java b/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java index 49090d00e98..f75f623a420 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java @@ -2,6 +2,7 @@ import java.util.Map; +import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import forge.GameCommand; @@ -15,7 +16,6 @@ import forge.game.spellability.SpellAbility; import forge.game.trigger.Trigger; import forge.game.trigger.TriggerHandler; -import forge.util.Iterables; public class DelayedTriggerEffect extends SpellAbilityEffect { diff --git a/forge-game/src/main/java/forge/game/ability/effects/DiscardEffect.java b/forge-game/src/main/java/forge/game/ability/effects/DiscardEffect.java index aba04ddf64c..3a16eeae9a2 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/DiscardEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/DiscardEffect.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; diff --git a/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java b/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java index bb85e022ff5..8ff2792d476 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/MakeCardEffect.java @@ -1,5 +1,6 @@ package forge.game.ability.effects; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.StaticData; import forge.card.ICardFace; diff --git a/forge-game/src/main/java/forge/game/ability/effects/MultiplePilesEffect.java b/forge-game/src/main/java/forge/game/ability/effects/MultiplePilesEffect.java index aaf74f1dcc4..6fdbbb0c984 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/MultiplePilesEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/MultiplePilesEffect.java @@ -4,6 +4,7 @@ import java.util.Map; import java.util.Map.Entry; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -17,7 +18,6 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Aggregates; -import forge.util.Iterables; import forge.util.Lang; import forge.util.Localizer; diff --git a/forge-game/src/main/java/forge/game/ability/effects/PumpAllEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PumpAllEffect.java index 4a44c77d979..28df9b4a6cb 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PumpAllEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PumpAllEffect.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.GameCommand; @@ -18,7 +19,6 @@ import forge.game.player.PlayerCollection; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; public class PumpAllEffect extends SpellAbilityEffect { diff --git a/forge-game/src/main/java/forge/game/ability/effects/RearrangeTopOfLibraryEffect.java b/forge-game/src/main/java/forge/game/ability/effects/RearrangeTopOfLibraryEffect.java index c1e4110fd92..1c55d999a89 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/RearrangeTopOfLibraryEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/RearrangeTopOfLibraryEffect.java @@ -2,6 +2,7 @@ import java.util.List; +import com.google.common.collect.Iterables; import forge.game.ability.AbilityUtils; import forge.game.ability.SpellAbilityEffect; import forge.game.card.Card; @@ -10,7 +11,6 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.Lang; import forge.util.Localizer; diff --git a/forge-game/src/main/java/forge/game/ability/effects/TokenEffectBase.java b/forge-game/src/main/java/forge/game/ability/effects/TokenEffectBase.java index a7b06f64d00..521e81a49b8 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/TokenEffectBase.java +++ b/forge-game/src/main/java/forge/game/ability/effects/TokenEffectBase.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; +import com.google.common.collect.Iterables; import forge.card.GamePieceType; import forge.game.card.*; -import forge.util.Iterables; import org.apache.commons.lang3.mutable.MutableBoolean; import com.google.common.collect.Lists; diff --git a/forge-game/src/main/java/forge/game/card/Card.java b/forge-game/src/main/java/forge/game/card/Card.java index ccaab0dba50..a78801658f1 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -51,7 +51,6 @@ import forge.trackable.TrackableProperty; import forge.trackable.Tracker; import forge.util.*; -import forge.util.Iterables; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; import io.sentry.Breadcrumb; diff --git a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java index 672f6d6e521..565a95051a8 100644 --- a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java +++ b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java @@ -17,10 +17,7 @@ */ package forge.game.card; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; +import com.google.common.collect.*; import forge.GameCommand; import forge.card.*; import forge.card.mana.ManaCost; diff --git a/forge-game/src/main/java/forge/game/card/CardProperty.java b/forge-game/src/main/java/forge/game/card/CardProperty.java index 416ad52b979..96e5b600c6b 100644 --- a/forge-game/src/main/java/forge/game/card/CardProperty.java +++ b/forge-game/src/main/java/forge/game/card/CardProperty.java @@ -1,5 +1,6 @@ package forge.game.card; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import forge.StaticData; @@ -28,7 +29,6 @@ import forge.item.PaperCard; import forge.util.Expressions; import forge.util.IterableUtil; -import forge.util.Iterables; import forge.util.TextUtil; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; diff --git a/forge-game/src/main/java/forge/game/card/CardState.java b/forge-game/src/main/java/forge/game/card/CardState.java index 34a9e1eb5c2..8a0747f5a22 100644 --- a/forge-game/src/main/java/forge/game/card/CardState.java +++ b/forge-game/src/main/java/forge/game/card/CardState.java @@ -22,6 +22,7 @@ import java.util.Set; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import forge.card.CardEdition; @@ -48,7 +49,6 @@ import forge.game.staticability.StaticAbility; import forge.game.trigger.Trigger; import forge.util.IterableUtil; -import forge.util.Iterables; import forge.util.ITranslatable; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; diff --git a/forge-game/src/main/java/forge/game/card/CardView.java b/forge-game/src/main/java/forge/game/card/CardView.java index 0fb67c24b58..682402225e0 100644 --- a/forge-game/src/main/java/forge/game/card/CardView.java +++ b/forge-game/src/main/java/forge/game/card/CardView.java @@ -1,5 +1,6 @@ package forge.game.card; +import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import forge.ImageKeys; import forge.StaticData; diff --git a/forge-game/src/main/java/forge/game/card/CardZoneTable.java b/forge-game/src/main/java/forge/game/card/CardZoneTable.java index 727ab1baf23..a2daf717bb7 100644 --- a/forge-game/src/main/java/forge/game/card/CardZoneTable.java +++ b/forge-game/src/main/java/forge/game/card/CardZoneTable.java @@ -7,6 +7,7 @@ import com.google.common.collect.ForwardingTable; import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Iterables; import com.google.common.collect.Table; import forge.game.CardTraitBase; import forge.game.Game; @@ -18,7 +19,6 @@ import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; import forge.util.IterableUtil; -import forge.util.Iterables; public class CardZoneTable extends ForwardingTable { // TODO use EnumBasedTable if exist diff --git a/forge-game/src/main/java/forge/game/card/token/TokenInfo.java b/forge-game/src/main/java/forge/game/card/token/TokenInfo.java index 35ea443f86c..07b142edb66 100644 --- a/forge-game/src/main/java/forge/game/card/token/TokenInfo.java +++ b/forge-game/src/main/java/forge/game/card/token/TokenInfo.java @@ -3,8 +3,8 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import forge.card.GamePieceType; -import forge.util.Iterables; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; 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 96d9af10dcf..afcb0f1b066 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackConstraints.java +++ b/forge-game/src/main/java/forge/game/combat/AttackConstraints.java @@ -9,15 +9,10 @@ import java.util.Set; import java.util.function.Predicate; +import com.google.common.collect.*; import forge.util.IterableUtil; -import forge.util.Iterables; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.collect.Collections2; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import com.google.common.primitives.Ints; import forge.game.Game; diff --git a/forge-game/src/main/java/forge/game/event/GameEventCardStatsChanged.java b/forge-game/src/main/java/forge/game/event/GameEventCardStatsChanged.java index 13470f7a40c..f58f4c85e11 100644 --- a/forge-game/src/main/java/forge/game/event/GameEventCardStatsChanged.java +++ b/forge-game/src/main/java/forge/game/event/GameEventCardStatsChanged.java @@ -3,7 +3,7 @@ import java.util.Arrays; import java.util.Collection; -import forge.util.Iterables; +import com.google.common.collect.Iterables; import org.apache.commons.lang3.StringUtils; import forge.game.card.Card; diff --git a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java index 963f3c5f48c..47657b7b42f 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java +++ b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java @@ -25,8 +25,8 @@ import java.util.Map.Entry; import java.util.function.Predicate; +import com.google.common.collect.Iterables; import forge.util.IterableUtil; -import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import com.google.common.collect.Lists; @@ -512,7 +512,7 @@ public ManaCostShard getShardToPayByPriority(Iterable payableShar return null; } - return Iterables.getFirst(choice, null); + return Iterables.getFirst(choice, null); } private ManaCostShard tryPayMana(final byte colorMask, Iterable payableShards, byte possibleUses) { diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index 2e9fe7f1b85..8729ca9071f 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -54,7 +54,6 @@ import forge.item.IPaperCard; import forge.item.PaperCard; import forge.util.*; -import forge.util.Iterables; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; import org.apache.commons.lang3.tuple.ImmutablePair; diff --git a/forge-game/src/main/java/forge/game/player/PlayerProperty.java b/forge-game/src/main/java/forge/game/player/PlayerProperty.java index 182d843e034..d7a3d077c9a 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerProperty.java +++ b/forge-game/src/main/java/forge/game/player/PlayerProperty.java @@ -1,5 +1,6 @@ package forge.game.player; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.game.CardTraitBase; import forge.game.Game; @@ -10,7 +11,6 @@ import forge.game.card.CardPredicates; import forge.game.zone.ZoneType; import forge.util.Expressions; -import forge.util.Iterables; import forge.util.TextUtil; import java.util.*; diff --git a/forge-game/src/main/java/forge/game/player/PlayerView.java b/forge-game/src/main/java/forge/game/player/PlayerView.java index d2ab87a88c0..d7c78cf1ab9 100644 --- a/forge-game/src/main/java/forge/game/player/PlayerView.java +++ b/forge-game/src/main/java/forge/game/player/PlayerView.java @@ -2,6 +2,7 @@ import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableMultiset; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import forge.LobbyPlayer; @@ -19,7 +20,6 @@ import forge.trackable.TrackableProperty; import forge.trackable.Tracker; import forge.util.CardTranslation; -import forge.util.Iterables; import forge.util.Lang; import forge.util.Localizer; import forge.util.collect.FCollection; diff --git a/forge-game/src/main/java/forge/game/player/RegisteredPlayer.java b/forge-game/src/main/java/forge/game/player/RegisteredPlayer.java index a6157f088c3..8967d91df3c 100644 --- a/forge-game/src/main/java/forge/game/player/RegisteredPlayer.java +++ b/forge-game/src/main/java/forge/game/player/RegisteredPlayer.java @@ -1,5 +1,6 @@ package forge.game.player; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.LobbyPlayer; import forge.deck.CardPool; @@ -8,7 +9,6 @@ import forge.game.GameType; import forge.item.IPaperCard; import forge.item.PaperCard; -import forge.util.Iterables; import java.util.Collections; import java.util.List; diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java index 3d2474931ef..a997896f732 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java @@ -19,12 +19,7 @@ import java.util.*; -import com.google.common.collect.HashBasedTable; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Table; -import com.google.common.collect.TreeBasedTable; +import com.google.common.collect.*; import forge.game.cost.CostSacrifice; import forge.util.*; diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java index 6dc9828d3ab..80967bea5a5 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java @@ -17,6 +17,7 @@ */ package forge.game.spellability; +import com.google.common.collect.Iterables; import forge.card.ColorSet; import forge.game.Game; import forge.game.GameObject; @@ -29,7 +30,6 @@ import forge.game.player.Player; import forge.game.zone.ZoneType; import forge.util.Expressions; -import forge.util.Iterables; import forge.util.collect.FCollection; import org.apache.commons.lang3.StringUtils; diff --git a/forge-game/src/main/java/forge/game/spellability/TargetChoices.java b/forge-game/src/main/java/forge/game/spellability/TargetChoices.java index 14b3361c321..aa99ed3fd16 100644 --- a/forge-game/src/main/java/forge/game/spellability/TargetChoices.java +++ b/forge-game/src/main/java/forge/game/spellability/TargetChoices.java @@ -22,6 +22,7 @@ import java.util.Map; import com.google.common.collect.ForwardingList; +import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import forge.game.GameEntity; @@ -31,7 +32,6 @@ import forge.game.card.CardCollectionView; import forge.game.player.Player; import forge.util.IterableUtil; -import forge.util.Iterables; import forge.util.collect.FCollection; /** diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java index 50c9454f2d0..b9b44973165 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java @@ -18,6 +18,7 @@ package forge.game.staticability; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import forge.GameCommand; @@ -40,7 +41,6 @@ import forge.game.spellability.SpellAbility; import forge.game.trigger.Trigger; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.TextUtil; import org.apache.commons.lang3.StringUtils; diff --git a/forge-game/src/main/java/forge/game/trigger/Trigger.java b/forge-game/src/main/java/forge/game/trigger/Trigger.java index cd57524b07a..9ab6ac9d7f1 100644 --- a/forge-game/src/main/java/forge/game/trigger/Trigger.java +++ b/forge-game/src/main/java/forge/game/trigger/Trigger.java @@ -17,6 +17,7 @@ */ package forge.game.trigger; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import forge.game.*; @@ -36,7 +37,6 @@ import forge.game.zone.ZoneType; import forge.util.CardTranslation; import forge.util.ITranslatable; -import forge.util.Iterables; import forge.util.Lang; import forge.util.TextUtil; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAbilityTriggered.java b/forge-game/src/main/java/forge/game/trigger/TriggerAbilityTriggered.java index 1f8de3bb69c..e17b405baf6 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAbilityTriggered.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAbilityTriggered.java @@ -18,12 +18,12 @@ package forge.game.trigger; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; import forge.game.ability.AbilityKey; import forge.game.card.Card; import forge.game.card.CardZoneTable; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; -import forge.util.Iterables; import forge.util.Localizer; import forge.util.TextUtil; diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java index 9a0ba429d09..3f6ada026e7 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerAttackerBlocked.java @@ -19,11 +19,11 @@ import java.util.Map; +import com.google.common.collect.Iterables; import forge.game.ability.AbilityKey; import forge.game.card.Card; import forge.game.card.CardLists; import forge.game.spellability.SpellAbility; -import forge.util.Iterables; import forge.util.Localizer; /** diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java b/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java index d86382aa9b7..19e8a49af2c 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java @@ -19,10 +19,7 @@ import java.util.*; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ListMultimap; -import com.google.common.collect.Lists; -import com.google.common.collect.Multimaps; +import com.google.common.collect.*; import forge.game.CardTraitBase; import forge.game.CardTraitPredicates; @@ -40,7 +37,6 @@ import forge.game.zone.Zone; import forge.game.zone.ZoneType; import forge.util.FileSection; -import forge.util.Iterables; import forge.util.Visitor; import io.sentry.Breadcrumb; import io.sentry.Sentry; diff --git a/forge-game/src/main/java/forge/game/zone/PlayerZone.java b/forge-game/src/main/java/forge/game/zone/PlayerZone.java index 7d8d094fa0e..4778fe162ff 100644 --- a/forge-game/src/main/java/forge/game/zone/PlayerZone.java +++ b/forge-game/src/main/java/forge/game/zone/PlayerZone.java @@ -17,13 +17,13 @@ */ package forge.game.zone; +import com.google.common.collect.Iterables; import forge.card.CardStateName; import forge.game.card.Card; import forge.game.card.CardLists; import forge.game.keyword.Keyword; import forge.game.player.Player; import forge.game.spellability.SpellAbility; -import forge.util.Iterables; import forge.util.Lang; import java.util.function.Predicate; diff --git a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/AdvancedSearchFilter.java b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/AdvancedSearchFilter.java index 7133acabc92..58e423c0175 100644 --- a/forge-gui-desktop/src/main/java/forge/itemmanager/filters/AdvancedSearchFilter.java +++ b/forge-gui-desktop/src/main/java/forge/itemmanager/filters/AdvancedSearchFilter.java @@ -12,7 +12,7 @@ import javax.swing.ScrollPaneConstants; import javax.swing.SwingConstants; -import forge.util.Iterables; +import com.google.common.collect.Iterables; import org.apache.commons.lang3.ArrayUtils; import com.google.common.collect.ImmutableList; diff --git a/forge-gui-desktop/src/main/java/forge/screens/bazaar/CBazaarUI.java b/forge-gui-desktop/src/main/java/forge/screens/bazaar/CBazaarUI.java index e74181e78e0..9e44c44ab9a 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/bazaar/CBazaarUI.java +++ b/forge-gui-desktop/src/main/java/forge/screens/bazaar/CBazaarUI.java @@ -2,10 +2,10 @@ import javax.swing.SwingUtilities; +import com.google.common.collect.Iterables; import forge.gamemodes.quest.bazaar.QuestBazaarManager; import forge.gui.framework.ICDoc; import forge.toolbox.FLabel; -import forge.util.Iterables; public enum CBazaarUI implements ICDoc { SINGLETON_INSTANCE; diff --git a/forge-gui-desktop/src/main/java/forge/screens/home/CLobby.java b/forge-gui-desktop/src/main/java/forge/screens/home/CLobby.java index e584792d408..a637bf4c303 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/home/CLobby.java +++ b/forge-gui-desktop/src/main/java/forge/screens/home/CLobby.java @@ -5,12 +5,12 @@ import javax.swing.SwingUtilities; +import com.google.common.collect.Iterables; import forge.deck.DeckProxy; import forge.localinstance.properties.ForgePreferences; import forge.localinstance.properties.ForgePreferences.FPref; import forge.model.FModel; import forge.toolbox.FList; -import forge.util.Iterables; public class CLobby { diff --git a/forge-gui-desktop/src/main/java/forge/screens/home/VLobby.java b/forge-gui-desktop/src/main/java/forge/screens/home/VLobby.java index 80b6125bc37..d555ad6b71e 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/home/VLobby.java +++ b/forge-gui-desktop/src/main/java/forge/screens/home/VLobby.java @@ -14,6 +14,7 @@ import javax.swing.event.ListSelectionListener; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.ai.AIOption; diff --git a/forge-gui-desktop/src/main/java/forge/screens/match/controllers/CCombat.java b/forge-gui-desktop/src/main/java/forge/screens/match/controllers/CCombat.java index c460771c1f8..c11b1c9a41f 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/match/controllers/CCombat.java +++ b/forge-gui-desktop/src/main/java/forge/screens/match/controllers/CCombat.java @@ -1,6 +1,6 @@ package forge.screens.match.controllers; -import forge.util.Iterables; +import com.google.common.collect.Iterables; import org.apache.commons.lang3.StringUtils; import forge.game.GameEntityView; diff --git a/forge-gui-desktop/src/main/java/forge/screens/workshop/views/VWorkshopCatalog.java b/forge-gui-desktop/src/main/java/forge/screens/workshop/views/VWorkshopCatalog.java index cea2223a981..7b7f4c937b3 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/workshop/views/VWorkshopCatalog.java +++ b/forge-gui-desktop/src/main/java/forge/screens/workshop/views/VWorkshopCatalog.java @@ -2,6 +2,7 @@ import javax.swing.JPanel; +import com.google.common.collect.Iterables; import forge.gui.framework.DragCell; import forge.gui.framework.DragTab; import forge.gui.framework.EDocID; @@ -14,7 +15,6 @@ import forge.screens.workshop.controllers.CCardScript; import forge.screens.workshop.controllers.CWorkshopCatalog; import forge.util.ItemPool; -import forge.util.Iterables; import forge.util.Localizer; import net.miginfocom.swing.MigLayout; diff --git a/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/PlayerControllerForTests.java b/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/PlayerControllerForTests.java index 612cac56293..639e4d26928 100644 --- a/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/PlayerControllerForTests.java +++ b/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/PlayerControllerForTests.java @@ -1,5 +1,6 @@ package forge.gamesimulationtests.util; +import com.google.common.collect.Iterables; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; @@ -47,7 +48,6 @@ import forge.player.HumanPlay; import forge.util.Aggregates; import forge.util.ITriggerEvent; -import forge.util.Iterables; import forge.util.MyRandom; import forge.util.collect.FCollectionView; import org.apache.commons.lang3.tuple.ImmutablePair; diff --git a/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/SpecificationHandler.java b/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/SpecificationHandler.java index 1d9ab87a536..e43ab4735da 100644 --- a/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/SpecificationHandler.java +++ b/forge-gui-desktop/src/test/java/forge/gamesimulationtests/util/SpecificationHandler.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.List; -import forge.util.Iterables; +import com.google.common.collect.Iterables; import org.apache.commons.lang3.StringUtils; public abstract class SpecificationHandler> { diff --git a/forge-gui-desktop/src/test/java/forge/item/DeckHintsTest.java b/forge-gui-desktop/src/test/java/forge/item/DeckHintsTest.java index 3cad6f8a551..b82e3aee81e 100644 --- a/forge-gui-desktop/src/test/java/forge/item/DeckHintsTest.java +++ b/forge-gui-desktop/src/test/java/forge/item/DeckHintsTest.java @@ -1,5 +1,6 @@ package forge.item; +import com.google.common.collect.Iterables; import forge.GuiDesktop; import forge.card.CardRarity; import forge.card.CardRules; @@ -7,7 +8,6 @@ import forge.gui.GuiBase; import forge.localinstance.properties.ForgeConstants; import forge.util.FileUtil; -import forge.util.Iterables; import junit.framework.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; diff --git a/forge-gui-mobile/src/forge/adventure/data/RewardData.java b/forge-gui-mobile/src/forge/adventure/data/RewardData.java index 67b2352de71..1e95f6ae534 100644 --- a/forge-gui-mobile/src/forge/adventure/data/RewardData.java +++ b/forge-gui-mobile/src/forge/adventure/data/RewardData.java @@ -1,6 +1,7 @@ package forge.adventure.data; import com.badlogic.gdx.utils.Array; +import com.google.common.collect.Iterables; import forge.StaticData; import forge.adventure.util.CardUtil; import forge.adventure.util.Config; @@ -10,7 +11,6 @@ import forge.deck.Deck; import forge.item.PaperCard; import forge.util.IterableUtil; -import forge.util.Iterables; import java.io.Serializable; import java.util.*; diff --git a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java index 1f19f9fc3c2..f1e87bb344d 100644 --- a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java +++ b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java @@ -2,6 +2,7 @@ import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.utils.Json; +import com.google.common.collect.Iterables; import forge.StaticData; import forge.adventure.data.ConfigData; import forge.adventure.data.GeneratedDeckData; @@ -21,7 +22,6 @@ import forge.model.FModel; import forge.util.Aggregates; import forge.util.IterableUtil; -import forge.util.Iterables; import java.text.SimpleDateFormat; import java.util.*; diff --git a/forge-gui-mobile/src/forge/itemmanager/filters/AdvancedSearchFilter.java b/forge-gui-mobile/src/forge/itemmanager/filters/AdvancedSearchFilter.java index 39aaee29eef..02d9465dc62 100644 --- a/forge-gui-mobile/src/forge/itemmanager/filters/AdvancedSearchFilter.java +++ b/forge-gui-mobile/src/forge/itemmanager/filters/AdvancedSearchFilter.java @@ -2,6 +2,7 @@ import com.badlogic.gdx.utils.Align; +import com.google.common.collect.Iterables; import forge.Forge; import forge.assets.FSkinImage; import forge.assets.TextRenderer; @@ -24,7 +25,6 @@ import forge.toolbox.FScrollPane; import forge.toolbox.FTextField; import forge.util.Callback; -import forge.util.Iterables; import java.util.function.Predicate; diff --git a/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java b/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java index 4bb268079b1..6b54d729833 100644 --- a/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java +++ b/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java @@ -6,8 +6,8 @@ import java.util.List; import java.util.Set; +import com.google.common.collect.Iterables; import forge.player.GamePlayerUtil; -import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import com.badlogic.gdx.Gdx; diff --git a/forge-gui-mobile/src/forge/screens/match/views/VReveal.java b/forge-gui-mobile/src/forge/screens/match/views/VReveal.java index f162ca4d215..ae0a15d99ca 100644 --- a/forge-gui-mobile/src/forge/screens/match/views/VReveal.java +++ b/forge-gui-mobile/src/forge/screens/match/views/VReveal.java @@ -1,6 +1,7 @@ package forge.screens.match.views; import com.badlogic.gdx.utils.Align; +import com.google.common.collect.Iterables; import forge.Forge; import forge.Graphics; import forge.assets.FImage; @@ -17,7 +18,6 @@ import forge.toolbox.FLabel; import forge.util.CardTranslation; import forge.util.ImageUtil; -import forge.util.Iterables; import forge.util.Utils; import java.util.ArrayList; diff --git a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java index f92b38be18d..ac451ffdd1e 100644 --- a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java +++ b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java @@ -10,6 +10,7 @@ import com.badlogic.gdx.utils.Align; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; import forge.Forge; import forge.Graphics; import forge.animation.ForgeAnimation; diff --git a/forge-gui-mobile/src/forge/screens/planarconquest/NewConquestScreen.java b/forge-gui-mobile/src/forge/screens/planarconquest/NewConquestScreen.java index f6cb6a9490d..95e170a17ca 100644 --- a/forge-gui-mobile/src/forge/screens/planarconquest/NewConquestScreen.java +++ b/forge-gui-mobile/src/forge/screens/planarconquest/NewConquestScreen.java @@ -1,5 +1,6 @@ package forge.screens.planarconquest; +import com.google.common.collect.Iterables; import forge.Forge; import forge.assets.FImage; import forge.card.CardImage; @@ -18,7 +19,6 @@ import forge.screens.planarconquest.ConquestMenu.LaunchReason; import forge.toolbox.FChoiceList; import forge.toolbox.FOptionPane; -import forge.util.Iterables; import forge.util.ThreadUtil; public class NewConquestScreen extends MultiStepWizardScreen { diff --git a/forge-gui-mobile/src/forge/toolbox/GuiChoose.java b/forge-gui-mobile/src/forge/toolbox/GuiChoose.java index 8f762fad64d..09e642050b7 100644 --- a/forge-gui-mobile/src/forge/toolbox/GuiChoose.java +++ b/forge-gui-mobile/src/forge/toolbox/GuiChoose.java @@ -7,8 +7,8 @@ import java.util.List; import java.util.function.Function; +import com.google.common.collect.Iterables; import forge.Forge; -import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; import forge.game.card.CardView; diff --git a/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java b/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java index 841fbb83035..aa21438e909 100644 --- a/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; +import com.google.common.collect.Iterables; import forge.game.GameFormat; import forge.game.GameType; import forge.game.IHasGameType; @@ -10,7 +11,6 @@ import forge.model.FModel; import forge.util.Aggregates; import forge.util.IterableUtil; -import forge.util.Iterables; public class RandomDeckGenerator extends DeckProxy implements Comparable { private enum RandomDeckType { @@ -174,8 +174,7 @@ private Deck getUserDeck() { return getGeneratedDeck(); //fall back to generated deck if no decks in filtered list } Iterable AIDecks = IterableUtil.filter(decks, deckProxy -> deckProxy.getAI().inMainDeck == 0); - if (isAi && Iterables.size(AIDecks) > 10) - return Aggregates.random(AIDecks).getDeck(); + if (isAi && Iterables.size(AIDecks) > 10) return Aggregates.random(AIDecks).getDeck(); return Aggregates.random(decks).getDeck(); } diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardRanker.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardRanker.java index 32ca4f394c9..21660e5abc4 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardRanker.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardRanker.java @@ -1,12 +1,12 @@ package forge.gamemodes.limited; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.card.ColorSet; import forge.card.DeckHints; import forge.card.MagicColor; import forge.item.PaperCard; -import forge.util.Iterables; import org.apache.commons.lang3.tuple.Pair; import java.util.ArrayList; diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayer.java b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayer.java index bac699548a2..d705025ec4d 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayer.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/LimitedPlayer.java @@ -1,5 +1,6 @@ package forge.gamemodes.limited; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import forge.card.CardEdition; @@ -10,7 +11,6 @@ import forge.gui.util.SGuiChoose; import forge.item.PaperCard; import forge.model.FModel; -import forge.util.Iterables; import forge.util.TextUtil; import java.util.*; diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java index 60d6aa99c8a..d5908dc050c 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/SealedDeckBuilder.java @@ -4,13 +4,13 @@ import java.util.Arrays; import java.util.List; +import com.google.common.collect.Iterables; import forge.card.CardRules; import forge.card.CardRulesPredicates; import forge.card.ColorSet; import forge.card.MagicColor; import forge.item.PaperCard; import forge.util.IterableUtil; -import forge.util.Iterables; import forge.util.MyRandom; /** diff --git a/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java b/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java index ef0cdf05a17..e8cda84e416 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java @@ -9,16 +9,11 @@ import java.util.Timer; import java.util.TimerTask; +import com.google.common.collect.*; import forge.gui.control.PlaybackSpeed; import forge.trackable.TrackableCollection; -import forge.util.Iterables; import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - import forge.game.GameView; import forge.game.card.Card; import forge.game.card.CardView; diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectManyBase.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectManyBase.java index adc75fa0ac1..fce32159c0e 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectManyBase.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectManyBase.java @@ -2,6 +2,7 @@ import java.util.Collection; +import com.google.common.collect.Iterables; import forge.game.GameEntity; import forge.game.card.Card; import forge.game.card.CardView; @@ -11,7 +12,6 @@ import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; import forge.player.PlayerControllerHuman; -import forge.util.Iterables; public abstract class InputSelectManyBase extends InputSyncronizedBase { private static final long serialVersionUID = -2305549394512889450L; diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java index 0dce64c767a..a27a8f613f3 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java @@ -7,6 +7,7 @@ import java.util.Set; import java.util.function.Predicate; +import com.google.common.collect.Iterables; import org.apache.commons.lang3.ObjectUtils; import com.google.common.collect.Lists; diff --git a/forge-gui/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java b/forge-gui/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java index 76a87677526..ee723815ecf 100644 --- a/forge-gui/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java +++ b/forge-gui/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.TreeMap; -import forge.util.Iterables; +import com.google.common.collect.Iterables; import org.apache.commons.lang3.StringUtils; import forge.StaticData; diff --git a/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java b/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java index cbb78bfc42b..d212d9267dd 100644 --- a/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java +++ b/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.function.Function; -import forge.util.Iterables; +import com.google.common.collect.Iterables; import org.apache.commons.lang3.StringUtils; import forge.gui.GuiBase; diff --git a/forge-gui/src/main/java/forge/player/HumanCostDecision.java b/forge-gui/src/main/java/forge/player/HumanCostDecision.java index 29f8e48abc5..c63cab28d4e 100644 --- a/forge-gui/src/main/java/forge/player/HumanCostDecision.java +++ b/forge-gui/src/main/java/forge/player/HumanCostDecision.java @@ -1,5 +1,6 @@ package forge.player; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import forge.card.CardType; import forge.card.MagicColor; diff --git a/forge-gui/src/main/java/forge/player/HumanPlay.java b/forge-gui/src/main/java/forge/player/HumanPlay.java index f32dca1faef..3db1d43a8cc 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlay.java +++ b/forge-gui/src/main/java/forge/player/HumanPlay.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.Iterables; import forge.ImageKeys; import forge.game.ability.AbilityKey; import forge.game.cost.*; @@ -41,7 +42,6 @@ import forge.gui.FThreads; import forge.gui.util.SGuiChoose; import forge.util.Aggregates; -import forge.util.Iterables; import forge.util.Localizer; import forge.util.TextUtil; import forge.util.collect.FCollectionView; @@ -195,7 +195,8 @@ public static boolean payCostDuringAbilityResolve(final PlayerControllerHuman co // Only human player pays this way Card current = null; // Used in spells with RepeatEach effect to distinguish cards, Cut the Tethers if (sourceAbility.hasParam("ShowCurrentCard")) { - current = Iterables.getFirst(AbilityUtils.getDefinedCards(source, sourceAbility.getParam("ShowCurrentCard"), sourceAbility), null); + Iterable iterable = AbilityUtils.getDefinedCards(source, sourceAbility.getParam("ShowCurrentCard"), sourceAbility); + current = Iterables.getFirst(iterable, null); } final List parts = cost.getCostParts(); diff --git a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java index b8b339834c3..0c7ddab3310 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java +++ b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java @@ -19,7 +19,7 @@ import java.util.Collections; -import forge.util.Iterables; +import com.google.common.collect.Iterables; import org.apache.commons.lang3.StringUtils; import forge.card.CardType; diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index 0e4488fd443..9df50619d37 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -62,7 +62,6 @@ import forge.model.FModel; import forge.trackable.TrackableCollection; import forge.util.*; -import forge.util.Iterables; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; import io.sentry.Sentry; From 871947a540b758cccd78d7fcc01d84f051be0ae5 Mon Sep 17 00:00:00 2001 From: Jetz Date: Thu, 26 Sep 2024 09:59:26 -0400 Subject: [PATCH 56/68] Guava migration - Optimize imports --- .../src/main/java/forge/ai/AiCardMemory.java | 6 ++-- .../src/main/java/forge/ai/AiProfileUtil.java | 13 ++++---- .../src/main/java/forge/ai/ComputerUtil.java | 26 +++++++-------- .../src/main/java/forge/ai/SpellApiToAi.java | 5 ++- .../forge/ai/ability/ActivateAbilityAi.java | 6 ++-- .../main/java/forge/ai/ability/AddTurnAi.java | 7 ++-- .../forge/ai/ability/AlterAttributeAi.java | 6 ++-- .../java/forge/ai/ability/AlwaysPlayAi.java | 4 +-- .../main/java/forge/ai/ability/AmassAi.java | 11 ++----- .../java/forge/ai/ability/AssignGroupAi.java | 6 ++-- .../main/java/forge/ai/ability/AttachAi.java | 26 +++++---------- .../main/java/forge/ai/ability/BidLifeAi.java | 4 +-- .../main/java/forge/ai/ability/BondAi.java | 4 +-- .../forge/ai/ability/ChangeCombatantsAi.java | 6 ++-- .../forge/ai/ability/ChangeZoneAllAi.java | 24 +++----------- .../main/java/forge/ai/ability/CharmAi.java | 15 +++------ .../java/forge/ai/ability/ChooseCardAi.java | 21 ++++-------- .../forge/ai/ability/ChooseCardNameAi.java | 19 +++-------- .../java/forge/ai/ability/ChooseColorAi.java | 7 +--- .../forge/ai/ability/ChooseCompanionAi.java | 9 +++--- .../forge/ai/ability/ChooseGenericAi.java | 3 +- .../java/forge/ai/ability/ChoosePlayerAi.java | 7 ++-- .../java/forge/ai/ability/ChooseSourceAi.java | 6 ++-- .../java/forge/ai/ability/ChooseTypeAi.java | 22 ++++--------- .../main/java/forge/ai/ability/ClashAi.java | 4 +-- .../main/java/forge/ai/ability/CloneAi.java | 12 +++---- .../forge/ai/ability/ControlExchangeAi.java | 1 - .../java/forge/ai/ability/ControlGainAi.java | 13 +++----- .../ai/ability/ControlGainVariantAi.java | 6 ++-- .../forge/ai/ability/CopyPermanentAi.java | 26 ++++----------- .../forge/ai/ability/CopySpellAbilityAi.java | 14 +++----- .../main/java/forge/ai/ability/CounterAi.java | 22 ++++--------- .../java/forge/ai/ability/CountersAi.java | 12 ++----- .../java/forge/ai/ability/CountersMoveAi.java | 6 ++-- .../forge/ai/ability/CountersMultiplyAi.java | 16 +++------- .../ai/ability/CountersProliferateAi.java | 15 +++------ .../forge/ai/ability/CountersPutAllAi.java | 7 ++-- .../ai/ability/CountersPutOrRemoveAi.java | 16 +++------- .../forge/ai/ability/CountersRemoveAi.java | 16 +++------- .../java/forge/ai/ability/DamageAllAi.java | 6 +--- .../forge/ai/ability/DamagePreventAi.java | 12 +++---- .../main/java/forge/ai/ability/DayTimeAi.java | 4 +-- .../main/java/forge/ai/ability/DebuffAi.java | 9 +++--- .../java/forge/ai/ability/DestroyAllAi.java | 6 +--- .../src/main/java/forge/ai/ability/DigAi.java | 13 ++------ .../java/forge/ai/ability/DigMultipleAi.java | 4 +-- .../java/forge/ai/ability/DigUntilAi.java | 6 ++-- .../main/java/forge/ai/ability/DiscardAi.java | 15 +++------ .../java/forge/ai/ability/DiscoverAi.java | 1 - .../java/forge/ai/ability/DrainManaAi.java | 4 +-- .../main/java/forge/ai/ability/DrawAi.java | 20 +++--------- .../main/java/forge/ai/ability/EncodeAi.java | 6 ++-- .../main/java/forge/ai/ability/ExploreAi.java | 13 ++------ .../ai/ability/FlipOntoBattlefieldAi.java | 4 +-- .../src/main/java/forge/ai/ability/FogAi.java | 10 ++---- .../main/java/forge/ai/ability/GoadAi.java | 4 +-- .../main/java/forge/ai/ability/HauntAi.java | 4 +-- .../java/forge/ai/ability/InvestigateAi.java | 4 +-- .../main/java/forge/ai/ability/LearnAi.java | 4 +-- .../forge/ai/ability/LegendaryRuleAi.java | 4 +-- .../ai/ability/LifeExchangeVariantAi.java | 8 +---- .../java/forge/ai/ability/LifeGainAi.java | 6 +--- .../java/forge/ai/ability/LifeLoseAi.java | 4 +-- .../main/java/forge/ai/ability/ManaAi.java | 13 +++----- .../java/forge/ai/ability/ManifestBaseAi.java | 4 +-- .../main/java/forge/ai/ability/MillAi.java | 9 +++--- .../java/forge/ai/ability/MustBlockAi.java | 6 ++-- .../main/java/forge/ai/ability/MutateAi.java | 4 +-- .../forge/ai/ability/PermanentCreatureAi.java | 13 ++------ .../main/java/forge/ai/ability/PlayAi.java | 5 ++- .../forge/ai/ability/PowerExchangeAi.java | 4 +-- .../main/java/forge/ai/ability/ProtectAi.java | 13 +++----- .../main/java/forge/ai/ability/PumpAi.java | 7 +--- .../java/forge/ai/ability/PumpAiBase.java | 19 +++-------- .../main/java/forge/ai/ability/PumpAllAi.java | 8 ++--- .../ai/ability/RearrangeTopOfLibraryAi.java | 11 ++----- .../java/forge/ai/ability/RegenerateAi.java | 12 +++---- .../main/java/forge/ai/ability/RepeatAi.java | 4 +-- .../java/forge/ai/ability/RepeatEachAi.java | 6 ++-- .../forge/ai/ability/ReplaceDamageAi.java | 4 +-- .../java/forge/ai/ability/RollDiceAi.java | 4 +-- .../java/forge/ai/ability/SacrificeAi.java | 6 ++-- .../main/java/forge/ai/ability/ScryAi.java | 4 +-- .../java/forge/ai/ability/SetStateAi.java | 7 ++-- .../main/java/forge/ai/ability/ShuffleAi.java | 4 +-- .../java/forge/ai/ability/SkipPhaseAi.java | 4 +-- .../main/java/forge/ai/ability/SurveilAi.java | 10 ++---- .../main/java/forge/ai/ability/TapAiBase.java | 12 +++---- .../main/java/forge/ai/ability/TapAllAi.java | 4 +-- .../java/forge/ai/ability/TimeTravelAi.java | 5 ++- .../main/java/forge/ai/ability/TokenAi.java | 23 +++---------- .../java/forge/ai/ability/TwoPilesAi.java | 4 +-- .../java/forge/ai/ability/UnattachAllAi.java | 6 ++-- .../main/java/forge/ai/ability/VoteAi.java | 4 +-- .../java/forge/ai/simulation/GameCopier.java | 21 ++++++------ .../forge/ai/simulation/GameSimulator.java | 8 ++--- .../ai/simulation/MultiTargetSelector.java | 6 ++-- .../main/java/forge/ai/simulation/Plan.java | 7 ++-- .../ai/simulation/PossibleTargetSelector.java | 9 +++--- .../ai/simulation/SimulationController.java | 8 ++--- .../SpellAbilityChoicesIterator.java | 11 ++----- .../ai/simulation/SpellAbilityPicker.java | 25 +++++---------- .../src/main/java/forge/MulliganDefs.java | 4 +-- .../src/main/java/forge/card/CardDb.java | 5 ++- .../src/main/java/forge/card/CardFace.java | 7 ++-- .../src/main/java/forge/card/CardRules.java | 10 +++--- .../java/forge/card/CardRulesPredicates.java | 13 +++++--- .../src/main/java/forge/card/CardType.java | 7 ++-- .../main/java/forge/card/CardTypeView.java | 6 ++-- .../src/main/java/forge/card/ColorSet.java | 12 ++----- .../src/main/java/forge/card/DeckHints.java | 16 ++++++---- .../src/main/java/forge/card/PrintSheet.java | 12 +++---- .../main/java/forge/card/mana/ManaCost.java | 7 ++-- .../src/main/java/forge/deck/DeckBase.java | 4 +-- .../src/main/java/forge/deck/DeckFormat.java | 6 +--- .../forge/deck/generation/DeckGenPool.java | 8 ++--- .../deck/generation/DeckGenerator2Color.java | 12 +++---- .../deck/generation/DeckGenerator3Color.java | 10 +++--- .../deck/generation/DeckGenerator4Color.java | 10 +++--- .../deck/generation/DeckGenerator5Color.java | 10 +++--- .../generation/DeckGeneratorMonoColor.java | 10 +++--- .../java/forge/deck/io/DeckFileHeader.java | 9 +++--- .../forge/deck/io/DeckGroupSerializer.java | 14 ++++---- .../java/forge/deck/io/DeckSerializer.java | 15 ++++----- .../main/java/forge/deck/io/DeckStorage.java | 10 +++--- .../src/main/java/forge/item/PaperToken.java | 9 +++--- .../src/main/java/forge/item/PreconDeck.java | 10 +++--- .../item/generation/BoosterGenerator.java | 10 ++++-- .../item/generation/ChaosBoosterSupplier.java | 4 +-- .../item/generation/IUnOpenedProduct.java | 4 +-- .../src/main/java/forge/util/Aggregates.java | 4 +-- .../src/main/java/forge/util/Base64Coder.java | 5 ++- .../main/java/forge/util/CardTranslation.java | 6 ++-- .../src/main/java/forge/util/FileSection.java | 16 +++------- .../src/main/java/forge/util/ItemPool.java | 6 ++-- .../main/java/forge/util/ItemPoolSorter.java | 4 +-- forge-core/src/main/java/forge/util/Lang.java | 18 +++-------- .../src/main/java/forge/util/LineReader.java | 7 ++-- .../main/java/forge/util/NameGenerator.java | 4 +-- .../main/java/forge/util/ReflectionUtil.java | 4 +-- .../src/main/java/forge/util/StreamUtil.java | 5 ++- .../src/main/java/forge/util/TextUtil.java | 14 ++++---- .../src/main/java/forge/util/ThreadUtil.java | 9 +----- .../java/forge/util/collect/FCollection.java | 17 +++------- .../forge/util/collect/FCollectionReader.java | 4 +-- .../java/forge/util/maps/MapToAmountUtil.java | 12 +++---- .../java/forge/util/storage/IStorage.java | 4 +-- .../forge/util/storage/StorageExtendable.java | 4 +-- .../storage/StorageImmediatelySerialized.java | 6 ++-- .../forge/util/storage/StorageReaderBase.java | 7 ++-- .../forge/util/storage/StorageReaderFile.java | 7 ++-- .../storage/StorageReaderFileSections.java | 7 ++-- .../util/storage/StorageReaderFolder.java | 10 ++---- ...geReaderRecursiveFolderWithUserFolder.java | 13 ++------ .../java/forge/game/card/ActivationTable.java | 10 +++--- .../forge/game/card/CardChangedWords.java | 4 +-- .../java/forge/game/card/CardCloneStates.java | 5 ++- .../forge/game/card/CardDamageHistory.java | 10 +++--- .../java/forge/game/card/CardDamageMap.java | 11 +++---- .../java/forge/game/card/CardFactory.java | 4 ++- .../java/forge/game/card/CardFactoryUtil.java | 4 ++- .../main/java/forge/game/card/CardLists.java | 11 +++---- .../java/forge/game/card/CardPlayOption.java | 3 +- .../java/forge/game/card/CardPredicates.java | 6 ++-- .../java/forge/game/card/CardProperty.java | 5 ++- .../main/java/forge/game/card/CardState.java | 18 ++++------- .../forge/game/card/CardTraitChanges.java | 7 ++-- .../main/java/forge/game/card/CardUtil.java | 9 +++--- .../java/forge/game/card/CardZoneTable.java | 4 +-- .../java/forge/game/card/CounterEnumType.java | 4 +-- .../java/forge/game/card/CounterType.java | 11 +++---- .../forge/game/card/TokenCreateTable.java | 16 ++++------ .../java/forge/game/card/token/TokenInfo.java | 16 ++++------ .../src/main/java/forge/game/cost/Cost.java | 4 ++- .../java/forge/game/cost/CostAddMana.java | 9 +++--- .../java/forge/game/cost/CostAdjustment.java | 26 ++++++--------- .../forge/game/cost/CostCollectEvidence.java | 6 +--- .../java/forge/game/cost/CostDiscard.java | 15 +++------ .../main/java/forge/game/cost/CostDraw.java | 4 +-- .../main/java/forge/game/cost/CostEnlist.java | 4 +-- .../forge/game/cost/CostExileFromStack.java | 4 +-- .../game/cost/CostExiledMoveToGrave.java | 4 +-- .../main/java/forge/game/cost/CostForage.java | 10 ++---- .../java/forge/game/cost/CostGainLife.java | 5 ++- .../main/java/forge/game/cost/CostMill.java | 4 +-- .../main/java/forge/game/cost/CostPart.java | 7 ++-- .../forge/game/cost/CostPartWithTrigger.java | 5 ++- .../java/forge/game/cost/CostPayEnergy.java | 1 - .../java/forge/game/cost/CostPayment.java | 14 ++++---- .../forge/game/cost/CostPutCardToLib.java | 4 +-- .../java/forge/game/cost/CostPutCounter.java | 5 ++- .../forge/game/cost/CostRemoveAnyCounter.java | 8 ++--- .../forge/game/cost/CostRemoveCounter.java | 5 ++- .../main/java/forge/game/cost/CostReturn.java | 4 +-- .../main/java/forge/game/cost/CostReveal.java | 12 +++---- .../java/forge/game/cost/CostSacrifice.java | 10 +++--- .../java/forge/game/cost/CostUnattach.java | 4 +-- .../java/forge/game/cost/PaymentDecision.java | 4 +-- .../forge/game/mana/ManaCostBeingPaid.java | 18 ++++------- .../main/java/forge/game/mana/ManaPool.java | 9 ++---- .../forge/deck/ArchetypeDeckGenerator.java | 9 +++--- .../forge/deck/CardArchetypeLDAGenerator.java | 12 ++----- .../deck/CardRelationMatrixGenerator.java | 20 ++++-------- .../forge/deck/CardThemedDeckGenerator.java | 6 ++-- .../java/forge/deck/ColorDeckGenerator.java | 8 ++--- .../forge/deck/CommanderDeckGenerator.java | 12 +++---- .../java/forge/deck/DeckGeneratorTheme.java | 8 ++--- .../java/forge/deck/DeckImportController.java | 15 ++++----- .../src/main/java/forge/deck/DeckgenUtil.java | 28 ++++------------ .../main/java/forge/deck/NetDeckCategory.java | 9 ++++-- .../java/forge/deck/RandomDeckGenerator.java | 6 ++-- .../main/java/forge/deck/io/Archetype.java | 4 +-- .../forge/deck/io/CardThemedMatrixIO.java | 15 +++------ .../java/forge/deck/io/DeckPreferences.java | 22 ++++++------- .../main/java/forge/deck/io/DeckRecords.java | 8 ++--- .../main/java/forge/download/AutoUpdater.java | 28 ++++++---------- .../java/forge/error/ExceptionHandler.java | 12 ++----- .../gamemodes/match/AbstractGuiGame.java | 19 ++++------- .../java/forge/gamemodes/match/GameLobby.java | 16 +++------- .../forge/gamemodes/match/HostedMatch.java | 26 +++++---------- .../java/forge/gamemodes/match/LobbySlot.java | 7 ++-- .../forge/gamemodes/match/LocalLobby.java | 4 +-- .../forge/gamemodes/match/input/Input.java | 4 +-- .../gamemodes/match/input/InputAttack.java | 9 +++--- .../gamemodes/match/input/InputBase.java | 4 +-- .../gamemodes/match/input/InputBlock.java | 4 +-- .../gamemodes/match/input/InputConfirm.java | 5 ++- .../match/input/InputConfirmMulligan.java | 4 +-- .../gamemodes/match/input/InputLockUI.java | 6 ++-- .../match/input/InputLondonMulligan.java | 4 +-- .../match/input/InputPassPriority.java | 7 ++-- .../gamemodes/match/input/InputPayMana.java | 10 ++---- .../input/InputPayManaOfCostPayment.java | 6 ++-- .../gamemodes/match/input/InputProxy.java | 12 +++---- .../gamemodes/match/input/InputQueue.java | 6 ++-- ...InputSelectCardsForConvokeOrImprovise.java | 11 +++---- .../input/InputSelectEntitiesFromList.java | 8 ++--- .../match/input/InputSelectManyBase.java | 4 +-- .../match/input/InputSelectTargets.java | 17 ++++------ .../match/input/InputSyncronizedBase.java | 4 +-- .../gamemodes/net/CObjectInputStream.java | 8 ++--- .../java/forge/gamemodes/net/ChatMessage.java | 6 ++-- .../net/CompatibleObjectDecoder.java | 6 ++-- .../net/CompatibleObjectEncoder.java | 6 ++-- .../gamemodes/net/GameProtocolHandler.java | 8 ++--- .../gamemodes/net/GameProtocolSender.java | 4 +-- .../java/forge/gamemodes/net/IRemote.java | 4 +-- .../forge/gamemodes/net/NetConnectUtil.java | 3 +- .../forge/gamemodes/net/OfflineLobby.java | 4 +-- .../forge/gamemodes/net/ProtocolMethod.java | 12 +++---- .../java/forge/gamemodes/net/ReplyPool.java | 4 +-- .../gamemodes/net/client/FGameClient.java | 15 +++------ .../net/client/GameClientHandler.java | 17 ++++------ .../net/client/NetGameController.java | 4 +-- .../forge/gamemodes/net/event/NetEvent.java | 4 +-- .../forge/gamemodes/net/event/ReplyEvent.java | 4 +-- .../net/event/UpdateLobbyPlayerEvent.java | 6 ++-- .../gamemodes/net/server/NetGuiGame.java | 10 +++--- .../gamemodes/net/server/RemoteClient.java | 4 +-- .../gamemodes/net/server/ServerGameLobby.java | 7 ++-- .../gamemodes/quest/io/ReadPriceList.java | 8 ++--- .../java/forge/gui/card/CardPreferences.java | 22 ++++++------- .../forge/gui/card/CardReaderExperiments.java | 16 ++++------ .../java/forge/gui/card/CardScriptInfo.java | 6 ++-- .../java/forge/gui/card/CardScriptParser.java | 14 ++++---- .../gui/control/FControlGameEventHandler.java | 7 ++-- .../gui/control/FControlGamePlayback.java | 20 +++--------- .../forge/gui/control/WatchLocalGame.java | 4 +-- .../GuiDownloadAchievementImages.java | 4 +-- .../gui/download/GuiDownloadPicturesHQ.java | 10 ++---- .../gui/download/GuiDownloadPicturesLQ.java | 6 ++-- .../forge/gui/download/GuiDownloadPrices.java | 5 ++- .../gui/download/GuiDownloadQuestImages.java | 4 +-- .../gui/download/GuiDownloadService.java | 32 ++++++------------- .../download/GuiDownloadSetPicturesLQ.java | 15 ++++----- .../forge/gui/download/GuiDownloadSkins.java | 4 +-- .../java/forge/gui/error/BugReporter.java | 9 ++---- .../java/forge/gui/interfaces/IGuiBase.java | 14 ++++---- .../java/forge/gui/interfaces/IGuiGame.java | 10 +++--- .../forge/gui/interfaces/IWinLoseView.java | 4 +-- .../main/java/forge/gui/util/SGuiChoose.java | 9 +++--- .../main/java/forge/gui/util/SOptionPane.java | 5 ++- .../src/main/java/forge/model/CardBlock.java | 17 +++++----- .../java/forge/model/CardCollections.java | 4 +-- .../src/main/java/forge/model/FModel.java | 4 ++- .../main/java/forge/model/UnOpenedMeta.java | 6 ++-- .../java/forge/player/GamePlayerUtil.java | 7 ++-- .../src/main/java/forge/player/HumanPlay.java | 24 ++++---------- .../forge/player/HumanPlaySpellAbility.java | 7 ++-- .../java/forge/player/PlayerZoneUpdate.java | 6 ++-- .../java/forge/player/PlayerZoneUpdates.java | 7 ++-- .../player/RecordActionsMacroSystem.java | 5 ++- .../java/forge/player/TargetSelection.java | 17 +++------- .../java/forge/sound/EventVisualizer.java | 6 ++-- .../src/main/java/forge/util/HttpUtil.java | 10 ++---- .../main/java/forge/util/IgnoringXStream.java | 6 ++-- .../src/main/java/forge/util/WordUtil.java | 4 +-- .../src/main/java/forge/util/XmlReader.java | 20 ++++++------ .../src/main/java/forge/util/XmlUtil.java | 11 +++---- .../src/main/java/forge/util/XmlWriter.java | 14 ++++---- .../src/forge/lda/dataset/BagOfWords.java | 4 ++- .../forge/lda/lda/inference/Inference.java | 5 ++- .../internal/CollapsedGibbsSampler.java | 10 +++--- 303 files changed, 1079 insertions(+), 1662 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiCardMemory.java b/forge-ai/src/main/java/forge/ai/AiCardMemory.java index 5bcfacb2ab3..dd611f87529 100644 --- a/forge-ai/src/main/java/forge/ai/AiCardMemory.java +++ b/forge-ai/src/main/java/forge/ai/AiCardMemory.java @@ -18,12 +18,12 @@ package forge.ai; -import java.util.HashSet; -import java.util.Set; - import forge.game.card.Card; import forge.game.player.Player; +import java.util.HashSet; +import java.util.Set; + /** *

* AiCardMemory class. diff --git a/forge-ai/src/main/java/forge/ai/AiProfileUtil.java b/forge-ai/src/main/java/forge/ai/AiProfileUtil.java index 672c1c12984..5fe94c6e22c 100644 --- a/forge-ai/src/main/java/forge/ai/AiProfileUtil.java +++ b/forge-ai/src/main/java/forge/ai/AiProfileUtil.java @@ -17,19 +17,18 @@ */ package forge.ai; +import forge.LobbyPlayer; +import forge.util.Aggregates; +import forge.util.FileUtil; +import forge.util.TextUtil; +import org.apache.commons.lang3.ArrayUtils; + import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.lang3.ArrayUtils; - -import forge.LobbyPlayer; -import forge.util.Aggregates; -import forge.util.FileUtil; -import forge.util.TextUtil; - /** * Holds default AI personality profile values in an enum. * Loads profile from the given text file when setProfile is called. diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index ef2237e2f8b..1effc4e98a8 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -17,15 +17,7 @@ */ package forge.ai; -import java.util.*; -import java.util.function.Predicate; - import com.google.common.collect.*; -import forge.game.card.*; -import forge.game.cost.*; -import forge.util.*; -import org.apache.commons.lang3.StringUtils; - import forge.ai.AiCardMemory.MemorySet; import forge.ai.ability.ProtectAi; import forge.ai.ability.TokenAi; @@ -34,19 +26,15 @@ import forge.card.ColorSet; import forge.card.MagicColor; import forge.card.mana.ManaAtom; -import forge.game.CardTraitPredicates; -import forge.game.Game; -import forge.game.GameActionUtil; -import forge.game.GameEntity; -import forge.game.GameEntityCounterTable; -import forge.game.GameObject; -import forge.game.GameType; +import forge.game.*; import forge.game.ability.AbilityKey; import forge.game.ability.AbilityUtils; import forge.game.ability.ApiType; import forge.game.ability.effects.CharmEffect; +import forge.game.card.*; import forge.game.combat.Combat; import forge.game.combat.CombatUtil; +import forge.game.cost.*; import forge.game.keyword.Keyword; import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; @@ -65,7 +53,15 @@ import forge.game.trigger.WrappedAbility; import forge.game.zone.Zone; import forge.game.zone.ZoneType; +import forge.util.Aggregates; +import forge.util.MyRandom; +import forge.util.StreamUtil; +import forge.util.TextUtil; import forge.util.collect.FCollection; +import org.apache.commons.lang3.StringUtils; + +import java.util.*; +import java.util.function.Predicate; /** diff --git a/forge-ai/src/main/java/forge/ai/SpellApiToAi.java b/forge-ai/src/main/java/forge/ai/SpellApiToAi.java index abb619a974c..e317464f411 100644 --- a/forge-ai/src/main/java/forge/ai/SpellApiToAi.java +++ b/forge-ai/src/main/java/forge/ai/SpellApiToAi.java @@ -1,14 +1,13 @@ package forge.ai; -import java.util.Map; - import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; - import forge.ai.ability.*; import forge.game.ability.ApiType; import forge.util.ReflectionUtil; +import java.util.Map; + public enum SpellApiToAi { Converter; diff --git a/forge-ai/src/main/java/forge/ai/ability/ActivateAbilityAi.java b/forge-ai/src/main/java/forge/ai/ability/ActivateAbilityAi.java index b87c5b00db1..2c4374f46d6 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ActivateAbilityAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ActivateAbilityAi.java @@ -1,8 +1,5 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import forge.ai.SpellAbilityAi; import forge.game.ability.AbilityUtils; import forge.game.card.Card; @@ -13,6 +10,9 @@ import forge.game.zone.ZoneType; import forge.util.MyRandom; +import java.util.List; +import java.util.Map; + public class ActivateAbilityAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/AddTurnAi.java b/forge-ai/src/main/java/forge/ai/ability/AddTurnAi.java index a1c3e24d807..951e0aa90e0 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AddTurnAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AddTurnAi.java @@ -17,16 +17,15 @@ */ package forge.ai.ability; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; - import forge.ai.SpellAbilityAi; import forge.game.ability.AbilityUtils; import forge.game.player.Player; import forge.game.player.PlayerCollection; import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; /** *

diff --git a/forge-ai/src/main/java/forge/ai/ability/AlterAttributeAi.java b/forge-ai/src/main/java/forge/ai/ability/AlterAttributeAi.java index caa3261a519..51fdc74be0d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AlterAttributeAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AlterAttributeAi.java @@ -1,8 +1,5 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import forge.ai.SpellAbilityAi; import forge.game.ability.AbilityUtils; import forge.game.card.Card; @@ -13,6 +10,9 @@ import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; +import java.util.List; +import java.util.Map; + public class AlterAttributeAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/AlwaysPlayAi.java b/forge-ai/src/main/java/forge/ai/ability/AlwaysPlayAi.java index 3c80fd8b35b..6387c89ebed 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AlwaysPlayAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AlwaysPlayAi.java @@ -1,13 +1,13 @@ package forge.ai.ability; -import java.util.Map; - import forge.ai.SpellAbilityAi; import forge.game.player.Player; import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; +import java.util.Map; + public class AlwaysPlayAi extends SpellAbilityAi { /* (non-Javadoc) * @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility) diff --git a/forge-ai/src/main/java/forge/ai/ability/AmassAi.java b/forge-ai/src/main/java/forge/ai/ability/AmassAi.java index 66e272af130..a73cb26c46f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AmassAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AmassAi.java @@ -1,20 +1,13 @@ package forge.ai.ability; -import java.util.Map; - import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; - import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; import forge.game.Game; import forge.game.ability.AbilityUtils; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; -import forge.game.card.CounterEnumType; +import forge.game.card.*; import forge.game.card.token.TokenInfo; import forge.game.phase.PhaseHandler; import forge.game.player.Player; @@ -22,6 +15,8 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Map; + public class AmassAi extends SpellAbilityAi { @Override protected boolean checkApiLogic(Player ai, final SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/AssignGroupAi.java b/forge-ai/src/main/java/forge/ai/ability/AssignGroupAi.java index abf8b22cf49..43a62a9259f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AssignGroupAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AssignGroupAi.java @@ -1,13 +1,13 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Iterables; import forge.ai.SpellAbilityAi; import forge.game.player.Player; import forge.game.spellability.SpellAbility; +import java.util.List; +import java.util.Map; + public class AssignGroupAi extends SpellAbilityAi { protected boolean canPlayAI(Player ai, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java index 1a64a02490a..ed70ffd99e5 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java @@ -1,30 +1,14 @@ package forge.ai.ability; -import java.util.*; - -import forge.game.card.*; -import org.apache.commons.lang3.ObjectUtils; - import com.google.common.collect.Lists; import com.google.common.collect.Sets; - -import forge.ai.AiAttackController; -import forge.ai.AiCardMemory; -import forge.ai.AiController; -import forge.ai.AiProps; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilAbility; -import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilCombat; -import forge.ai.ComputerUtilCost; -import forge.ai.PlayerControllerAi; -import forge.ai.SpecialCardAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.Game; import forge.game.GameObject; import forge.game.ability.AbilityFactory; import forge.game.ability.AbilityUtils; import forge.game.ability.ApiType; +import forge.game.card.*; import forge.game.combat.Combat; import forge.game.combat.CombatUtil; import forge.game.cost.Cost; @@ -44,6 +28,12 @@ import forge.game.zone.ZoneType; import forge.util.Aggregates; import forge.util.MyRandom; +import org.apache.commons.lang3.ObjectUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; public class AttachAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/BidLifeAi.java b/forge-ai/src/main/java/forge/ai/ability/BidLifeAi.java index 3828af7604c..2d07529b09e 100644 --- a/forge-ai/src/main/java/forge/ai/ability/BidLifeAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/BidLifeAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.List; - import forge.ai.AiAttackController; import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; @@ -14,6 +12,8 @@ import forge.game.zone.ZoneType; import forge.util.MyRandom; +import java.util.List; + public class BidLifeAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/BondAi.java b/forge-ai/src/main/java/forge/ai/ability/BondAi.java index bd7ea559f1c..ba040031401 100644 --- a/forge-ai/src/main/java/forge/ai/ability/BondAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/BondAi.java @@ -17,14 +17,14 @@ */ package forge.ai.ability; -import java.util.Map; - import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; import forge.game.card.Card; import forge.game.player.Player; import forge.game.spellability.SpellAbility; +import java.util.Map; + /** *

* AbilityFactoryBond class. diff --git a/forge-ai/src/main/java/forge/ai/ability/ChangeCombatantsAi.java b/forge-ai/src/main/java/forge/ai/ability/ChangeCombatantsAi.java index f99261af499..1187dc81cdc 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeCombatantsAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeCombatantsAi.java @@ -1,8 +1,5 @@ package forge.ai.ability; -import java.util.Collection; -import java.util.Map; - import forge.ai.SpellAbilityAi; import forge.game.GameEntity; import forge.game.player.Player; @@ -10,6 +7,9 @@ import forge.game.player.PlayerPredicates; import forge.game.spellability.SpellAbility; +import java.util.Collection; +import java.util.Map; + public class ChangeCombatantsAi extends SpellAbilityAi { /* (non-Javadoc) * @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility) diff --git a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java index 571af0de00c..ba17e0546b2 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChangeZoneAllAi.java @@ -1,26 +1,9 @@ package forge.ai.ability; -import java.util.Collections; -import java.util.Map; - -import forge.ai.AiController; -import forge.ai.AiPlayerPredicates; -import forge.ai.AiProps; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilAbility; -import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilCombat; -import forge.ai.ComputerUtilCost; -import forge.ai.PlayerControllerAi; -import forge.ai.SpecialCardAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.Game; import forge.game.ability.AbilityUtils; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; +import forge.game.card.*; import forge.game.cost.Cost; import forge.game.phase.PhaseType; import forge.game.player.Player; @@ -31,6 +14,9 @@ import forge.game.zone.ZoneType; import forge.util.MyRandom; +import java.util.Collections; +import java.util.Map; + public class ChangeZoneAllAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player ai, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/CharmAi.java b/forge-ai/src/main/java/forge/ai/ability/CharmAi.java index 7d02582f652..4bdf26b772d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CharmAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CharmAi.java @@ -1,16 +1,7 @@ package forge.ai.ability; -import java.util.Collections; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Lists; - -import forge.ai.AiController; -import forge.ai.AiPlayDecision; -import forge.ai.ComputerUtilAbility; -import forge.ai.PlayerControllerAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.ability.AbilityUtils; import forge.game.ability.effects.CharmEffect; import forge.game.card.Card; @@ -21,6 +12,10 @@ import forge.util.MyRandom; import forge.util.collect.FCollection; +import java.util.Collections; +import java.util.List; +import java.util.Map; + public class CharmAi extends SpellAbilityAi { @Override protected boolean checkApiLogic(Player ai, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java index fc40e652d68..2a68856b091 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java @@ -1,22 +1,9 @@ package forge.ai.ability; -import java.util.Collections; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Iterables; -import forge.ai.AiAttackController; -import forge.ai.ComputerUtilAbility; -import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilCombat; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.Game; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; -import forge.game.card.CounterEnumType; +import forge.game.card.*; import forge.game.combat.Combat; import forge.game.keyword.Keyword; import forge.game.phase.PhaseHandler; @@ -28,6 +15,10 @@ import forge.util.Aggregates; import forge.util.IterableUtil; +import java.util.Collections; +import java.util.List; +import java.util.Map; + public class ChooseCardAi extends SpellAbilityAi { /** diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseCardNameAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseCardNameAi.java index 6f16595eedb..0d760959026 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCardNameAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCardNameAi.java @@ -1,22 +1,10 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Iterables; import com.google.common.collect.Lists; - import forge.StaticData; -import forge.ai.AiAttackController; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilCard; -import forge.ai.SpecialCardAi; -import forge.ai.SpellAbilityAi; -import forge.card.CardDb; -import forge.card.CardRules; -import forge.card.CardSplitType; -import forge.card.CardStateName; -import forge.card.ICardFace; +import forge.ai.*; +import forge.card.*; import forge.game.card.Card; import forge.game.card.CardCollection; import forge.game.card.CardCopyService; @@ -28,6 +16,9 @@ import forge.item.PaperCard; import forge.util.MyRandom; +import java.util.List; +import java.util.Map; + public class ChooseCardNameAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseColorAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseColorAi.java index c3d3b307d93..e893cc2b6ca 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseColorAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseColorAi.java @@ -1,11 +1,6 @@ package forge.ai.ability; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilAbility; -import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilCost; -import forge.ai.SpecialCardAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.card.MagicColor; import forge.game.Game; import forge.game.card.CardCollectionView; diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseCompanionAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseCompanionAi.java index e3e50950b18..1240d9ab54f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCompanionAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCompanionAi.java @@ -1,16 +1,15 @@ package forge.ai.ability; -import java.util.Collections; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Lists; - import forge.ai.SpellAbilityAi; import forge.game.card.Card; import forge.game.player.Player; import forge.game.spellability.SpellAbility; +import java.util.Collections; +import java.util.List; +import java.util.Map; + public class ChooseCompanionAi extends SpellAbilityAi { /* (non-Javadoc) diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseGenericAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseGenericAi.java index e9686d20584..6e7eb0742e3 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseGenericAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseGenericAi.java @@ -4,7 +4,8 @@ import forge.ai.*; import forge.card.MagicColor; import forge.game.Game; -import forge.game.card.*; +import forge.game.card.Card; +import forge.game.card.CardCollectionView; import forge.game.cost.Cost; import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; diff --git a/forge-ai/src/main/java/forge/ai/ability/ChoosePlayerAi.java b/forge-ai/src/main/java/forge/ai/ability/ChoosePlayerAi.java index d2e1aed14a1..d2622f900b4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChoosePlayerAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChoosePlayerAi.java @@ -1,11 +1,7 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Iterables; import com.google.common.collect.Lists; - import forge.ai.ComputerUtil; import forge.ai.SpellAbilityAi; import forge.game.player.Player; @@ -14,6 +10,9 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.List; +import java.util.Map; + public class ChoosePlayerAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player ai, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java index 52e44bb50db..9e16b6bb3bf 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java @@ -1,8 +1,5 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Iterables; import forge.ai.AiAttackController; import forge.ai.ComputerUtilCard; @@ -25,6 +22,9 @@ import forge.game.zone.ZoneType; import forge.util.Aggregates; +import java.util.List; +import java.util.Map; + public class ChooseSourceAi extends SpellAbilityAi { /* (non-Javadoc) diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java index fca70976b61..89f6451822c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseTypeAi.java @@ -1,24 +1,11 @@ package forge.ai.ability; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import com.google.common.collect.Iterables; -import forge.ai.AiCardMemory; -import forge.ai.ComputerUtilAbility; -import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilMana; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.card.CardType; import forge.game.ability.AbilityUtils; import forge.game.ability.ApiType; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; +import forge.game.card.*; import forge.game.keyword.Keyword; import forge.game.phase.PhaseType; import forge.game.player.Player; @@ -27,6 +14,11 @@ import forge.game.zone.ZoneType; import forge.util.Aggregates; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + public class ChooseTypeAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/ClashAi.java b/forge-ai/src/main/java/forge/ai/ability/ClashAi.java index 30efdfe6b3e..254da6006db 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ClashAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ClashAi.java @@ -1,8 +1,6 @@ package forge.ai.ability; -import java.util.Map; - import com.google.common.collect.Iterables; import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; @@ -16,6 +14,8 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Map; + public class ClashAi extends SpellAbilityAi { /* (non-Javadoc) diff --git a/forge-ai/src/main/java/forge/ai/ability/CloneAi.java b/forge-ai/src/main/java/forge/ai/ability/CloneAi.java index 7479165a142..0fd433286ce 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CloneAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CloneAi.java @@ -1,17 +1,10 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; import forge.game.Game; import forge.game.ability.AbilityUtils; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; +import forge.game.card.*; import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; import forge.game.player.Player; @@ -19,6 +12,9 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.List; +import java.util.Map; + public class CloneAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/ControlExchangeAi.java b/forge-ai/src/main/java/forge/ai/ability/ControlExchangeAi.java index a8a13e575c6..82ab4d67455 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ControlExchangeAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ControlExchangeAi.java @@ -1,7 +1,6 @@ package forge.ai.ability; import com.google.common.collect.Lists; - import forge.ai.ComputerUtilCard; import forge.ai.SpecialCardAi; import forge.ai.SpellAbilityAi; diff --git a/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java b/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java index 7f7c70bd8fb..8a405acaba8 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ControlGainAi.java @@ -17,17 +17,9 @@ */ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Iterables; import com.google.common.collect.Lists; - -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilCombat; -import forge.ai.SpecialCardAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.Game; import forge.game.ability.AbilityUtils; import forge.game.card.Card; @@ -44,6 +36,9 @@ import forge.game.zone.ZoneType; import forge.util.Aggregates; +import java.util.List; +import java.util.Map; + //AB:GainControl|ValidTgts$Creature|TgtPrompt$Select target legendary creature|LoseControl$Untap,LoseControl|SpellDescription$Gain control of target xxxxxxx diff --git a/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java b/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java index 8c43ea29c56..7d6dc51bd1c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ControlGainVariantAi.java @@ -17,9 +17,6 @@ */ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Iterables; import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; @@ -30,6 +27,9 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.List; +import java.util.Map; + /** *

diff --git a/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java b/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java index c0fe8337941..2d988d23d1e 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CopyPermanentAi.java @@ -1,29 +1,12 @@ package forge.ai.ability; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.function.Predicate; - import com.google.common.collect.Iterables; -import forge.ai.AiPlayDecision; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilAbility; -import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilCombat; -import forge.ai.ComputerUtilCost; -import forge.ai.SpecialCardAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.Game; import forge.game.GameEntity; import forge.game.ability.AbilityKey; import forge.game.ability.AbilityUtils; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; -import forge.game.card.CardUtil; +import forge.game.card.*; import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; import forge.game.player.Player; @@ -32,6 +15,11 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; + public class CopyPermanentAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/CopySpellAbilityAi.java b/forge-ai/src/main/java/forge/ai/ability/CopySpellAbilityAi.java index db20d9dc4e9..8ca5fb23402 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CopySpellAbilityAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CopySpellAbilityAi.java @@ -1,15 +1,6 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - -import forge.ai.AiCardMemory; -import forge.ai.AiPlayDecision; -import forge.ai.AiProps; -import forge.ai.ComputerUtilCard; -import forge.ai.PlayerControllerAi; -import forge.ai.SpecialCardAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.Game; import forge.game.ability.ApiType; import forge.game.player.Player; @@ -18,6 +9,9 @@ import forge.game.spellability.SpellAbility; import forge.util.MyRandom; +import java.util.List; +import java.util.Map; + public class CopySpellAbilityAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/CounterAi.java b/forge-ai/src/main/java/forge/ai/ability/CounterAi.java index 2c8f8648701..b83a496c6f0 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CounterAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CounterAi.java @@ -1,23 +1,10 @@ package forge.ai.ability; -import java.util.Iterator; - -import forge.game.ability.effects.CounterEffect; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; - -import forge.ai.AiController; -import forge.ai.AiProps; -import forge.ai.ComputerUtilAbility; -import forge.ai.ComputerUtilCost; -import forge.ai.ComputerUtilMana; -import forge.ai.PlayerControllerAi; -import forge.ai.SpecialCardAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.Game; import forge.game.ability.AbilityUtils; import forge.game.ability.ApiType; +import forge.game.ability.effects.CounterEffect; import forge.game.card.Card; import forge.game.cost.Cost; import forge.game.cost.CostDiscard; @@ -28,6 +15,11 @@ import forge.game.spellability.SpellAbilityStackInstance; import forge.game.zone.ZoneType; import forge.util.MyRandom; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.Iterator; public class CounterAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersAi.java index 5253e9e97c8..e3b9a6ed7fc 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersAi.java @@ -17,22 +17,16 @@ */ package forge.ai.ability; -import java.util.List; - import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; -import forge.game.card.CounterEnumType; -import forge.game.card.CounterType; +import forge.game.card.*; import forge.game.keyword.Keyword; import forge.game.player.Player; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import java.util.List; + /** *

diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java index 40018954cee..e32c32ab106 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersMoveAi.java @@ -1,8 +1,5 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; @@ -19,6 +16,9 @@ import forge.util.MyRandom; import forge.util.collect.FCollection; +import java.util.List; +import java.util.Map; + public class CountersMoveAi extends SpellAbilityAi { @Override protected boolean checkApiLogic(final Player ai, final SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java index 6e1defd5d4b..6fbcf7bc5c4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersMultiplyAi.java @@ -1,22 +1,12 @@ package forge.ai.ability; -import java.util.Collections; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Lists; - import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCost; import forge.ai.SpellAbilityAi; import forge.game.Game; import forge.game.ability.AbilityUtils; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; -import forge.game.card.CounterEnumType; -import forge.game.card.CounterType; +import forge.game.card.*; import forge.game.keyword.Keyword; import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; @@ -24,6 +14,10 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Collections; +import java.util.List; +import java.util.Map; + public class CountersMultiplyAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersProliferateAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersProliferateAi.java index b7b8be5d34b..8a4dc0ab193 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersProliferateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersProliferateAi.java @@ -1,16 +1,7 @@ package forge.ai.ability; -import java.util.Collection; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Lists; - -import forge.ai.AiProps; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilCard; -import forge.ai.PlayerControllerAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.GameEntity; import forge.game.card.*; import forge.game.player.Player; @@ -18,6 +9,10 @@ import forge.game.zone.ZoneType; import forge.util.IterableUtil; +import java.util.Collection; +import java.util.List; +import java.util.Map; + public class CountersProliferateAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutAllAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutAllAi.java index 2b8767530b4..cd04e931f90 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutAllAi.java @@ -1,10 +1,6 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Lists; - import forge.ai.ComputerUtilCost; import forge.ai.SpellAbilityAi; import forge.game.ability.AbilityUtils; @@ -21,6 +17,9 @@ import forge.game.zone.ZoneType; import forge.util.MyRandom; +import java.util.List; +import java.util.Map; + public class CountersPutAllAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player ai, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java index bd59630e797..6867c696d48 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersPutOrRemoveAi.java @@ -17,23 +17,13 @@ */ package forge.ai.ability; -import java.util.List; -import java.util.Map; -import java.util.function.Predicate; - import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; import forge.game.Game; import forge.game.ability.AbilityUtils; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; -import forge.game.card.CounterEnumType; -import forge.game.card.CounterType; +import forge.game.card.*; import forge.game.keyword.Keyword; import forge.game.player.Player; import forge.game.player.PlayerController.BinaryChoiceType; @@ -41,6 +31,10 @@ import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; + /** *

* AbilityFactory_PutOrRemoveCountersAi class. diff --git a/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java b/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java index 3ddaa19cf13..2b138b133e9 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CountersRemoveAi.java @@ -1,9 +1,5 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; -import java.util.function.Predicate; - import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; @@ -12,13 +8,7 @@ import forge.game.Game; import forge.game.GameEntity; import forge.game.ability.AbilityUtils; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; -import forge.game.card.CounterEnumType; -import forge.game.card.CounterType; +import forge.game.card.*; import forge.game.keyword.Keyword; import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; @@ -27,6 +17,10 @@ import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; + public class CountersRemoveAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java index 51948face98..f505555979f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageAllAi.java @@ -1,10 +1,6 @@ package forge.ai.ability; -import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilCombat; -import forge.ai.ComputerUtilCost; -import forge.ai.ComputerUtilMana; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.ability.AbilityUtils; import forge.game.card.Card; import forge.game.card.CardCollection; diff --git a/forge-ai/src/main/java/forge/ai/ability/DamagePreventAi.java b/forge-ai/src/main/java/forge/ai/ability/DamagePreventAi.java index 89482adde62..106af35c80d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamagePreventAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamagePreventAi.java @@ -1,8 +1,5 @@ package forge.ai.ability; -import java.util.ArrayList; -import java.util.List; - import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCombat; @@ -10,11 +7,7 @@ import forge.game.Game; import forge.game.GameObject; import forge.game.ability.AbilityUtils; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; +import forge.game.card.*; import forge.game.combat.Combat; import forge.game.cost.Cost; import forge.game.phase.PhaseHandler; @@ -25,6 +18,9 @@ import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; +import java.util.ArrayList; +import java.util.List; + public class DamagePreventAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/DayTimeAi.java b/forge-ai/src/main/java/forge/ai/ability/DayTimeAi.java index d390d9214af..b12e262580f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DayTimeAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DayTimeAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.Map; - import forge.ai.SpellAbilityAi; import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; @@ -9,6 +7,8 @@ import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; +import java.util.Map; + public class DayTimeAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java b/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java index c42b8af1253..ac7939f30e6 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DebuffAi.java @@ -1,11 +1,6 @@ package forge.ai.ability; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - import com.google.common.collect.Lists; - import forge.ai.AiAttackController; import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCost; @@ -24,6 +19,10 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + public class DebuffAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java index 96d2479cf26..630876e1d53 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java @@ -2,11 +2,7 @@ import forge.ai.*; import forge.card.MagicColor; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; -import forge.game.card.CounterEnumType; +import forge.game.card.*; import forge.game.combat.Combat; import forge.game.cost.Cost; import forge.game.keyword.Keyword; diff --git a/forge-ai/src/main/java/forge/ai/ability/DigAi.java b/forge-ai/src/main/java/forge/ai/ability/DigAi.java index 79f8ca128fe..930ea118cca 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DigAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DigAi.java @@ -1,16 +1,7 @@ package forge.ai.ability; -import java.util.Map; - import com.google.common.collect.Iterables; -import forge.ai.AiAttackController; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilAbility; -import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilCombat; -import forge.ai.ComputerUtilCost; -import forge.ai.SpecialCardAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.Game; import forge.game.GameEntity; import forge.game.ability.AbilityUtils; @@ -27,6 +18,8 @@ import forge.game.zone.ZoneType; import forge.util.TextUtil; +import java.util.Map; + public class DigAi extends SpellAbilityAi { /* (non-Javadoc) diff --git a/forge-ai/src/main/java/forge/ai/ability/DigMultipleAi.java b/forge-ai/src/main/java/forge/ai/ability/DigMultipleAi.java index 8945350c112..08ce3d26562 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DigMultipleAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DigMultipleAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.Map; - import forge.ai.AiAttackController; import forge.ai.ComputerUtil; import forge.ai.SpellAbilityAi; @@ -14,6 +12,8 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Map; + public class DigMultipleAi extends SpellAbilityAi { /* (non-Javadoc) diff --git a/forge-ai/src/main/java/forge/ai/ability/DigUntilAi.java b/forge-ai/src/main/java/forge/ai/ability/DigUntilAi.java index 699ae42e7ee..4e1cbf3a454 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DigUntilAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DigUntilAi.java @@ -1,8 +1,5 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import forge.ai.AiAttackController; import forge.ai.ComputerUtilCost; import forge.ai.SpellAbilityAi; @@ -16,6 +13,9 @@ import forge.game.zone.ZoneType; import forge.util.MyRandom; +import java.util.List; +import java.util.Map; + public class DigUntilAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/DiscardAi.java b/forge-ai/src/main/java/forge/ai/ability/DiscardAi.java index a09a9e91ceb..5ce68804d0c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DiscardAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DiscardAi.java @@ -1,15 +1,6 @@ package forge.ai.ability; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilAbility; -import forge.ai.ComputerUtilCost; -import forge.ai.ComputerUtilMana; -import forge.ai.SpecialCardAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.ability.AbilityUtils; import forge.game.card.Card; import forge.game.card.CardCollectionView; @@ -25,6 +16,10 @@ import forge.game.zone.ZoneType; import forge.util.MyRandom; +import java.util.Collections; +import java.util.List; +import java.util.Map; + public class DiscardAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/DiscoverAi.java b/forge-ai/src/main/java/forge/ai/ability/DiscoverAi.java index c0ac69a99b7..19caeb40ca1 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DiscoverAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DiscoverAi.java @@ -8,7 +8,6 @@ import forge.game.card.Card; import forge.game.player.Player; import forge.game.player.PlayerActionConfirmMode; - import forge.game.spellability.Spell; import forge.game.spellability.SpellAbility; diff --git a/forge-ai/src/main/java/forge/ai/ability/DrainManaAi.java b/forge-ai/src/main/java/forge/ai/ability/DrainManaAi.java index 1e4f8760149..957f45691e1 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DrainManaAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DrainManaAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.List; - import forge.ai.SpellAbilityAi; import forge.game.ability.AbilityUtils; import forge.game.card.Card; @@ -9,6 +7,8 @@ import forge.game.spellability.SpellAbility; import forge.util.MyRandom; +import java.util.List; + public class DrainManaAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/DrawAi.java b/forge-ai/src/main/java/forge/ai/ability/DrawAi.java index 453f45ac6f5..bb05e10b80d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DrawAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DrawAi.java @@ -18,17 +18,7 @@ */ package forge.ai.ability; -import java.util.Map; - -import forge.ai.AiCostDecision; -import forge.ai.AiProps; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilAbility; -import forge.ai.ComputerUtilCost; -import forge.ai.ComputerUtilMana; -import forge.ai.PlayerControllerAi; -import forge.ai.SpecialCardAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.Game; import forge.game.ability.AbilityUtils; import forge.game.ability.ApiType; @@ -38,14 +28,12 @@ import forge.game.cost.*; import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; -import forge.game.player.GameLossReason; -import forge.game.player.Player; -import forge.game.player.PlayerActionConfirmMode; -import forge.game.player.PlayerCollection; -import forge.game.player.PlayerPredicates; +import forge.game.player.*; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Map; + public class DrawAi extends SpellAbilityAi { /* (non-Javadoc) diff --git a/forge-ai/src/main/java/forge/ai/ability/EncodeAi.java b/forge-ai/src/main/java/forge/ai/ability/EncodeAi.java index d25ff5e8453..6e5579272ea 100644 --- a/forge-ai/src/main/java/forge/ai/ability/EncodeAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/EncodeAi.java @@ -17,9 +17,6 @@ */ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCombat; import forge.ai.SpellAbilityAi; @@ -30,6 +27,9 @@ import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; +import java.util.List; +import java.util.Map; + /** *

* AbilityFactoryBond class. diff --git a/forge-ai/src/main/java/forge/ai/ability/ExploreAi.java b/forge-ai/src/main/java/forge/ai/ability/ExploreAi.java index 619918d763f..ef3996b70c3 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ExploreAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ExploreAi.java @@ -1,17 +1,8 @@ package forge.ai.ability; -import forge.ai.AiController; -import forge.ai.AiProps; -import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilMana; -import forge.ai.PlayerControllerAi; -import forge.ai.SpellAbilityAi; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; +import forge.ai.*; +import forge.game.card.*; import forge.game.player.Player; import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; diff --git a/forge-ai/src/main/java/forge/ai/ability/FlipOntoBattlefieldAi.java b/forge-ai/src/main/java/forge/ai/ability/FlipOntoBattlefieldAi.java index b385ee9205c..0a142a221ce 100644 --- a/forge-ai/src/main/java/forge/ai/ability/FlipOntoBattlefieldAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/FlipOntoBattlefieldAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.Map; - import forge.ai.SpellAbilityAi; import forge.game.card.CardCollectionView; import forge.game.card.CardLists; @@ -12,6 +10,8 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Map; + public class FlipOntoBattlefieldAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/FogAi.java b/forge-ai/src/main/java/forge/ai/ability/FogAi.java index 6c197ca8d4f..7ee2f2eef0f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/FogAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/FogAi.java @@ -1,13 +1,7 @@ package forge.ai.ability; -import java.util.List; - -import forge.ai.AiCardMemory; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilCombat; -import forge.ai.PlayerControllerAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.Game; import forge.game.GameObject; import forge.game.ability.ApiType; @@ -20,6 +14,8 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.List; + public class FogAi extends SpellAbilityAi { /* (non-Javadoc) diff --git a/forge-ai/src/main/java/forge/ai/ability/GoadAi.java b/forge-ai/src/main/java/forge/ai/ability/GoadAi.java index 89ac3299d99..7f1bca5e4f1 100644 --- a/forge-ai/src/main/java/forge/ai/ability/GoadAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/GoadAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.List; - import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCombat; import forge.ai.SpellAbilityAi; @@ -13,6 +11,8 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.List; + public class GoadAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/HauntAi.java b/forge-ai/src/main/java/forge/ai/ability/HauntAi.java index 26bb8d2ba81..3943e091530 100644 --- a/forge-ai/src/main/java/forge/ai/ability/HauntAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/HauntAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.List; - import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; import forge.game.Game; @@ -12,6 +10,8 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.List; + public class HauntAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/InvestigateAi.java b/forge-ai/src/main/java/forge/ai/ability/InvestigateAi.java index 7087208f25c..e7c8c69d463 100644 --- a/forge-ai/src/main/java/forge/ai/ability/InvestigateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/InvestigateAi.java @@ -1,8 +1,6 @@ package forge.ai.ability; -import java.util.Map; - import forge.ai.SpellAbilityAi; import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; @@ -10,6 +8,8 @@ import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; +import java.util.Map; + public class InvestigateAi extends SpellAbilityAi { /* (non-Javadoc) * @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility) diff --git a/forge-ai/src/main/java/forge/ai/ability/LearnAi.java b/forge-ai/src/main/java/forge/ai/ability/LearnAi.java index a155b4f77de..b465cb77c01 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LearnAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LearnAi.java @@ -1,8 +1,6 @@ package forge.ai.ability; -import java.util.Map; - import forge.ai.ComputerUtilCard; import forge.ai.PlayerControllerAi; import forge.ai.SpellAbilityAi; @@ -15,6 +13,8 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Map; + public class LearnAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/LegendaryRuleAi.java b/forge-ai/src/main/java/forge/ai/ability/LegendaryRuleAi.java index 45c7060d34f..4f498b4bd6b 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LegendaryRuleAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LegendaryRuleAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.Map; - import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.SpellAbilityAi; @@ -11,6 +9,8 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; +import java.util.Map; + /** * TODO: Write javadoc for this type. * diff --git a/forge-ai/src/main/java/forge/ai/ability/LifeExchangeVariantAi.java b/forge-ai/src/main/java/forge/ai/ability/LifeExchangeVariantAi.java index 5910bf46cc6..f79e25b44e7 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LifeExchangeVariantAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LifeExchangeVariantAi.java @@ -1,12 +1,6 @@ package forge.ai.ability; -import forge.ai.AiAttackController; -import forge.ai.AiProps; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilAbility; -import forge.ai.ComputerUtilCombat; -import forge.ai.PlayerControllerAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.Game; import forge.game.card.Card; import forge.game.keyword.Keyword; diff --git a/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java b/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java index 2462fd6d716..0d97d83437c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LifeGainAi.java @@ -1,11 +1,7 @@ package forge.ai.ability; import com.google.common.collect.Iterables; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilAbility; -import forge.ai.ComputerUtilCombat; -import forge.ai.ComputerUtilCost; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.Game; import forge.game.ability.AbilityUtils; import forge.game.card.Card; diff --git a/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java b/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java index 778446f6f38..a26f360ddee 100644 --- a/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/LifeLoseAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.List; - import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCost; import forge.ai.SpellAbilityAi; @@ -16,6 +14,8 @@ import forge.game.spellability.SpellAbility; import forge.util.collect.FCollection; +import java.util.List; + public class LifeLoseAi extends SpellAbilityAi { /* diff --git a/forge-ai/src/main/java/forge/ai/ability/ManaAi.java b/forge-ai/src/main/java/forge/ai/ability/ManaAi.java index d5d6029f23b..05cde6e8a5e 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ManaAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ManaAi.java @@ -1,8 +1,5 @@ package forge.ai.ability; -import java.util.Arrays; -import java.util.List; - import forge.ai.*; import forge.card.ColorSet; import forge.card.MagicColor; @@ -10,12 +7,7 @@ import forge.card.mana.ManaCost; import forge.game.CardTraitPredicates; import forge.game.ability.AbilityUtils; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; -import forge.game.card.CounterEnumType; -import forge.game.card.CounterType; +import forge.game.card.*; import forge.game.cost.CostPart; import forge.game.cost.CostRemoveCounter; import forge.game.keyword.Keyword; @@ -31,6 +23,9 @@ import forge.util.Aggregates; import forge.util.IterableUtil; +import java.util.Arrays; +import java.util.List; + public class ManaAi extends SpellAbilityAi { /* diff --git a/forge-ai/src/main/java/forge/ai/ability/ManifestBaseAi.java b/forge-ai/src/main/java/forge/ai/ability/ManifestBaseAi.java index 5dbf8617ec8..3bbe9b44a44 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ManifestBaseAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ManifestBaseAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.Map; - import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; @@ -20,6 +18,8 @@ import forge.game.zone.ZoneType; import forge.util.MyRandom; +import java.util.Map; + /** * Created by friarsol on 1/23/15. */ diff --git a/forge-ai/src/main/java/forge/ai/ability/MillAi.java b/forge-ai/src/main/java/forge/ai/ability/MillAi.java index 073df55136a..6a58a861341 100644 --- a/forge-ai/src/main/java/forge/ai/ability/MillAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/MillAi.java @@ -1,12 +1,7 @@ package forge.ai.ability; -import java.util.Collections; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Lists; import com.google.common.collect.Maps; - import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCost; import forge.ai.SpecialCardAi; @@ -24,6 +19,10 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Collections; +import java.util.List; +import java.util.Map; + public class MillAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/MustBlockAi.java b/forge-ai/src/main/java/forge/ai/ability/MustBlockAi.java index b8c21e2dda8..e0e41559727 100644 --- a/forge-ai/src/main/java/forge/ai/ability/MustBlockAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/MustBlockAi.java @@ -1,8 +1,5 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Iterables; import forge.ai.AiCardMemory; import forge.ai.ComputerUtilCard; @@ -19,6 +16,9 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; +import java.util.List; +import java.util.Map; + public class MustBlockAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/MutateAi.java b/forge-ai/src/main/java/forge/ai/ability/MutateAi.java index 61217e369db..432c86584fc 100644 --- a/forge-ai/src/main/java/forge/ai/ability/MutateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/MutateAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.Map; - import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; @@ -14,6 +12,8 @@ import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; +import java.util.Map; + public class MutateAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/PermanentCreatureAi.java b/forge-ai/src/main/java/forge/ai/ability/PermanentCreatureAi.java index 8ff03ccc2db..42c61985504 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PermanentCreatureAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PermanentCreatureAi.java @@ -1,19 +1,11 @@ package forge.ai.ability; -import forge.game.card.CardCopyService; -import org.apache.commons.lang3.StringUtils; - -import forge.ai.AiController; -import forge.ai.AiProps; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilCombat; -import forge.ai.ComputerUtilCost; -import forge.ai.PlayerControllerAi; +import forge.ai.*; import forge.card.mana.ManaCost; import forge.game.Game; import forge.game.ability.ApiType; import forge.game.card.Card; +import forge.game.card.CardCopyService; import forge.game.card.CardLists; import forge.game.combat.Combat; import forge.game.keyword.Keyword; @@ -24,6 +16,7 @@ import forge.game.staticability.StaticAbility; import forge.game.zone.ZoneType; import forge.util.MyRandom; +import org.apache.commons.lang3.StringUtils; /** * AbilityFactory for Creature Spells. diff --git a/forge-ai/src/main/java/forge/ai/ability/PlayAi.java b/forge-ai/src/main/java/forge/ai/ability/PlayAi.java index 52ec31c7f86..7be460dbfef 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PlayAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PlayAi.java @@ -11,7 +11,10 @@ import forge.game.keyword.Keyword; import forge.game.player.Player; import forge.game.player.PlayerActionConfirmMode; -import forge.game.spellability.*; +import forge.game.spellability.Spell; +import forge.game.spellability.SpellAbility; +import forge.game.spellability.SpellAbilityPredicates; +import forge.game.spellability.SpellPermanent; import forge.game.zone.ZoneType; import forge.util.MyRandom; diff --git a/forge-ai/src/main/java/forge/ai/ability/PowerExchangeAi.java b/forge-ai/src/main/java/forge/ai/ability/PowerExchangeAi.java index a4fc7eb2465..fa96446e376 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PowerExchangeAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PowerExchangeAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.List; - import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; import forge.game.ability.AbilityUtils; @@ -14,6 +12,8 @@ import forge.game.zone.ZoneType; import forge.util.MyRandom; +import java.util.List; + public class PowerExchangeAi extends SpellAbilityAi { /* (non-Javadoc) diff --git a/forge-ai/src/main/java/forge/ai/ability/ProtectAi.java b/forge-ai/src/main/java/forge/ai/ability/ProtectAi.java index a30318b7462..8f1031bc3cf 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ProtectAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ProtectAi.java @@ -1,14 +1,6 @@ package forge.ai.ability; -import java.util.ArrayList; -import java.util.List; - -import forge.ai.AiAttackController; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilCombat; -import forge.ai.ComputerUtilCost; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.card.MagicColor; import forge.game.Game; import forge.game.GameObject; @@ -27,6 +19,9 @@ import forge.game.spellability.TargetRestrictions; import forge.util.MyRandom; +import java.util.ArrayList; +import java.util.List; + public class ProtectAi extends SpellAbilityAi { private static boolean hasProtectionFrom(final Card card, final String color) { final List onlyColors = new ArrayList<>(MagicColor.Constant.ONLY_COLORS); diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAi.java b/forge-ai/src/main/java/forge/ai/ability/PumpAi.java index a0d1fb2ba07..4554c48e045 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAi.java @@ -2,7 +2,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; - import forge.ai.*; import forge.game.Game; import forge.game.ability.AbilityUtils; @@ -20,11 +19,7 @@ import forge.game.zone.ZoneType; import org.apache.commons.lang3.StringUtils; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; +import java.util.*; public class PumpAi extends PumpAiBase { diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java b/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java index 12458bd0f33..86d8a68d433 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAiBase.java @@ -1,22 +1,10 @@ package forge.ai.ability; -import java.util.List; -import java.util.function.Predicate; - -import forge.ai.AiAttackController; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilCombat; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.card.MagicColor; import forge.game.Game; import forge.game.ability.AbilityUtils; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; -import forge.game.card.CardUtil; +import forge.game.card.*; import forge.game.combat.Combat; import forge.game.combat.CombatUtil; import forge.game.keyword.Keyword; @@ -27,6 +15,9 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.List; +import java.util.function.Predicate; + public abstract class PumpAiBase extends SpellAbilityAi { public boolean containsUsefulKeyword(final Player ai, final List keywords, final Card card, final SpellAbility sa, final int attack) { diff --git a/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java b/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java index 9ff6b3b8427..2399b4aea95 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PumpAllAi.java @@ -1,9 +1,5 @@ package forge.ai.ability; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCombat; @@ -23,6 +19,10 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + public class PumpAllAi extends PumpAiBase { /* (non-Javadoc) diff --git a/forge-ai/src/main/java/forge/ai/ability/RearrangeTopOfLibraryAi.java b/forge-ai/src/main/java/forge/ai/ability/RearrangeTopOfLibraryAi.java index aac480c5185..bdce6b58dd1 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RearrangeTopOfLibraryAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RearrangeTopOfLibraryAi.java @@ -1,14 +1,7 @@ package forge.ai.ability; -import java.util.Map; - -import forge.ai.AiCardMemory; -import forge.ai.AiController; -import forge.ai.AiProps; -import forge.ai.ComputerUtilMana; -import forge.ai.PlayerControllerAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.ability.AbilityUtils; import forge.game.card.Card; import forge.game.card.CardLists; @@ -23,6 +16,8 @@ import forge.game.zone.ZoneType; import forge.util.MyRandom; +import java.util.Map; + public class RearrangeTopOfLibraryAi extends SpellAbilityAi { /* (non-Javadoc) * @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility) diff --git a/forge-ai/src/main/java/forge/ai/ability/RegenerateAi.java b/forge-ai/src/main/java/forge/ai/ability/RegenerateAi.java index 2b332347a7e..fc8dd326e04 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RegenerateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RegenerateAi.java @@ -17,9 +17,6 @@ */ package forge.ai.ability; -import java.util.ArrayList; -import java.util.List; - import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCombat; @@ -27,17 +24,16 @@ import forge.game.Game; import forge.game.GameObject; import forge.game.ability.AbilityUtils; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; +import forge.game.card.*; import forge.game.combat.Combat; import forge.game.phase.PhaseType; import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.ArrayList; +import java.util.List; + /** *

* AbilityFactory_Regenerate class. diff --git a/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java b/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java index d402cc9e37b..52205aecc40 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RepeatAi.java @@ -1,8 +1,6 @@ package forge.ai.ability; -import java.util.Map; - import forge.ai.*; import forge.game.card.Card; import forge.game.card.CardPredicates; @@ -14,6 +12,8 @@ import forge.game.spellability.SpellAbility; import forge.util.IterableUtil; +import java.util.Map; + public class RepeatAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java b/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java index fe784006446..639d891e8e0 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RepeatEachAi.java @@ -1,8 +1,5 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import forge.ai.ComputerUtilCard; import forge.ai.SpecialCardAi; import forge.ai.SpellAbilityAi; @@ -14,6 +11,9 @@ import forge.game.zone.ZoneType; import forge.util.TextUtil; +import java.util.List; +import java.util.Map; + public class RepeatEachAi extends SpellAbilityAi { diff --git a/forge-ai/src/main/java/forge/ai/ability/ReplaceDamageAi.java b/forge-ai/src/main/java/forge/ai/ability/ReplaceDamageAi.java index daa3a870c08..2bf0000393e 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ReplaceDamageAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ReplaceDamageAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.Map; - import forge.ai.ComputerUtilCard; import forge.ai.SpellAbilityAi; import forge.game.card.Card; @@ -9,6 +7,8 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; +import java.util.Map; + public class ReplaceDamageAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/RollDiceAi.java b/forge-ai/src/main/java/forge/ai/ability/RollDiceAi.java index 3cb3cedf5ff..e079cbb09ed 100644 --- a/forge-ai/src/main/java/forge/ai/ability/RollDiceAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/RollDiceAi.java @@ -1,8 +1,6 @@ package forge.ai.ability; -import java.util.Map; - import forge.ai.SpellAbilityAi; import forge.game.Game; import forge.game.card.Card; @@ -13,6 +11,8 @@ import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; +import java.util.Map; + public class RollDiceAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/SacrificeAi.java b/forge-ai/src/main/java/forge/ai/ability/SacrificeAi.java index dede84b9f0f..515345c5b88 100644 --- a/forge-ai/src/main/java/forge/ai/ability/SacrificeAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/SacrificeAi.java @@ -1,8 +1,5 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCost; import forge.ai.SpellAbilityAi; @@ -20,6 +17,9 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.List; +import java.util.Map; + public class SacrificeAi extends SpellAbilityAi { @Override diff --git a/forge-ai/src/main/java/forge/ai/ability/ScryAi.java b/forge-ai/src/main/java/forge/ai/ability/ScryAi.java index 8df58ec64e5..b25a445ce69 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ScryAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ScryAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.Map; - import forge.ai.ComputerUtilMana; import forge.ai.SpecialCardAi; import forge.ai.SpellAbilityAi; @@ -17,6 +15,8 @@ import forge.game.zone.ZoneType; import forge.util.MyRandom; +import java.util.Map; + public class ScryAi extends SpellAbilityAi { /* (non-Javadoc) diff --git a/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java b/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java index 4dac2a7ea9f..551e57498e4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/SetStateAi.java @@ -1,13 +1,9 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCost; import forge.ai.SpellAbilityAi; import forge.card.CardStateName; - import forge.game.ability.AbilityUtils; import forge.game.card.*; import forge.game.phase.PhaseHandler; @@ -17,6 +13,9 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.List; +import java.util.Map; + public class SetStateAi extends SpellAbilityAi { @Override protected boolean checkApiLogic(final Player aiPlayer, final SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/ShuffleAi.java b/forge-ai/src/main/java/forge/ai/ability/ShuffleAi.java index cf66187b55e..50684e8874d 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ShuffleAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ShuffleAi.java @@ -1,13 +1,13 @@ package forge.ai.ability; -import java.util.Map; - import forge.ai.SpellAbilityAi; import forge.game.phase.PhaseType; import forge.game.player.Player; import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; +import java.util.Map; + public class ShuffleAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/SkipPhaseAi.java b/forge-ai/src/main/java/forge/ai/ability/SkipPhaseAi.java index 908308a29c4..500706b9c83 100644 --- a/forge-ai/src/main/java/forge/ai/ability/SkipPhaseAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/SkipPhaseAi.java @@ -1,13 +1,13 @@ package forge.ai.ability; -import java.util.Map; - import forge.ai.AiAttackController; import forge.ai.SpellAbilityAi; import forge.game.player.Player; import forge.game.player.PlayerActionConfirmMode; import forge.game.spellability.SpellAbility; +import java.util.Map; + public class SkipPhaseAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/SurveilAi.java b/forge-ai/src/main/java/forge/ai/ability/SurveilAi.java index 54df44cafe1..67277aadc0c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/SurveilAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/SurveilAi.java @@ -1,12 +1,6 @@ package forge.ai.ability; -import java.util.Map; - -import forge.ai.AiCardMemory; -import forge.ai.AiProps; -import forge.ai.ComputerUtilCost; -import forge.ai.PlayerControllerAi; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.card.Card; import forge.game.cost.Cost; import forge.game.cost.CostPayLife; @@ -18,6 +12,8 @@ import forge.game.zone.ZoneType; import forge.util.MyRandom; +import java.util.Map; + public class SurveilAi extends SpellAbilityAi { /* diff --git a/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java b/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java index dc456aa6607..cd361036c00 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java +++ b/forge-ai/src/main/java/forge/ai/ability/TapAiBase.java @@ -1,13 +1,6 @@ package forge.ai.ability; -import java.util.List; -import java.util.function.Predicate; - -import forge.ai.AiAttackController; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilAbility; -import forge.ai.ComputerUtilCard; -import forge.ai.SpellAbilityAi; +import forge.ai.*; import forge.game.Game; import forge.game.ability.AbilityUtils; import forge.game.ability.ApiType; @@ -22,6 +15,9 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.List; +import java.util.function.Predicate; + public abstract class TapAiBase extends SpellAbilityAi { /** diff --git a/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java b/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java index ea5788d2bbf..1e54900c19e 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TapAllAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.List; - import forge.ai.ComputerUtilCombat; import forge.ai.SpellAbilityAi; import forge.game.Game; @@ -19,6 +17,8 @@ import forge.game.zone.ZoneType; import forge.util.MyRandom; +import java.util.List; + public class TapAllAi extends SpellAbilityAi { @Override protected boolean canPlayAI(final Player ai, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java b/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java index db08e348fe1..70def99ebfe 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TimeTravelAi.java @@ -3,7 +3,10 @@ import com.google.common.collect.Iterables; import forge.ai.ComputerUtil; import forge.ai.SpellAbilityAi; -import forge.game.card.*; +import forge.game.card.Card; +import forge.game.card.CardPredicates; +import forge.game.card.CounterEnumType; +import forge.game.card.CounterType; import forge.game.player.Player; import forge.game.player.PlayerActionConfirmMode; import forge.game.player.PlayerController; diff --git a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java index ee1587d4ca6..c2ff7d8d5d7 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TokenAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TokenAi.java @@ -1,28 +1,12 @@ package forge.ai.ability; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Iterables; -import forge.ai.AiController; -import forge.ai.AiProps; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilCombat; -import forge.ai.ComputerUtilCost; -import forge.ai.ComputerUtilMana; -import forge.ai.PlayerControllerAi; -import forge.ai.SpellAbilityAi; -import forge.ai.SpellApiToAi; +import forge.ai.*; import forge.game.Game; import forge.game.GameEntity; import forge.game.ability.AbilityUtils; import forge.game.ability.ApiType; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; -import forge.game.card.CardUtil; +import forge.game.card.*; import forge.game.card.token.TokenInfo; import forge.game.combat.Combat; import forge.game.combat.CombatUtil; @@ -42,6 +26,9 @@ import forge.game.zone.ZoneType; import forge.util.MyRandom; +import java.util.List; +import java.util.Map; + /** *

* AbilityFactory_Token class. diff --git a/forge-ai/src/main/java/forge/ai/ability/TwoPilesAi.java b/forge-ai/src/main/java/forge/ai/ability/TwoPilesAi.java index fa62249caf4..248602264a7 100644 --- a/forge-ai/src/main/java/forge/ai/ability/TwoPilesAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/TwoPilesAi.java @@ -1,7 +1,5 @@ package forge.ai.ability; -import java.util.List; - import forge.ai.AiAttackController; import forge.ai.SpellAbilityAi; import forge.game.ability.AbilityUtils; @@ -13,6 +11,8 @@ import forge.game.zone.ZoneType; import forge.util.collect.FCollection; +import java.util.List; + public class TwoPilesAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player ai, SpellAbility sa) { diff --git a/forge-ai/src/main/java/forge/ai/ability/UnattachAllAi.java b/forge-ai/src/main/java/forge/ai/ability/UnattachAllAi.java index ca0f965975f..09bba16dd2f 100644 --- a/forge-ai/src/main/java/forge/ai/ability/UnattachAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/UnattachAllAi.java @@ -1,8 +1,5 @@ package forge.ai.ability; -import java.util.ArrayList; -import java.util.List; - import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCost; import forge.ai.SpellAbilityAi; @@ -14,6 +11,9 @@ import forge.game.spellability.SpellAbility; import forge.util.MyRandom; +import java.util.ArrayList; +import java.util.List; + public class UnattachAllAi extends SpellAbilityAi { /* (non-Javadoc) diff --git a/forge-ai/src/main/java/forge/ai/ability/VoteAi.java b/forge-ai/src/main/java/forge/ai/ability/VoteAi.java index 7a1221aff3a..c31126beb28 100644 --- a/forge-ai/src/main/java/forge/ai/ability/VoteAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/VoteAi.java @@ -1,8 +1,6 @@ package forge.ai.ability; -import java.util.Map; - import forge.ai.SpellAbilityAi; import forge.game.card.Card; import forge.game.card.CardLists; @@ -11,6 +9,8 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Map; + public class VoteAi extends SpellAbilityAi { /* (non-Javadoc) * @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility) diff --git a/forge-ai/src/main/java/forge/ai/simulation/GameCopier.java b/forge-ai/src/main/java/forge/ai/simulation/GameCopier.java index 408d820eaa5..3d4c03e3369 100644 --- a/forge-ai/src/main/java/forge/ai/simulation/GameCopier.java +++ b/forge-ai/src/main/java/forge/ai/simulation/GameCopier.java @@ -1,16 +1,6 @@ package forge.ai.simulation; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import com.google.common.collect.Table; - +import com.google.common.collect.*; import forge.LobbyPlayer; import forge.ai.AIOption; import forge.ai.LobbyPlayerAi; @@ -18,7 +8,10 @@ import forge.card.CardRules; import forge.game.*; import forge.game.ability.effects.DetachedCardEffect; -import forge.game.card.*; +import forge.game.card.Card; +import forge.game.card.CardCloneStates; +import forge.game.card.CardCopyService; +import forge.game.card.CounterType; import forge.game.card.token.TokenInfo; import forge.game.combat.Combat; import forge.game.mana.Mana; @@ -34,6 +27,10 @@ import forge.game.zone.ZoneType; import forge.item.PaperCard; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + public class GameCopier { private static final ZoneType[] ZONES = new ZoneType[] { ZoneType.Battlefield, diff --git a/forge-ai/src/main/java/forge/ai/simulation/GameSimulator.java b/forge-ai/src/main/java/forge/ai/simulation/GameSimulator.java index c6b354ef553..00e84689580 100644 --- a/forge-ai/src/main/java/forge/ai/simulation/GameSimulator.java +++ b/forge-ai/src/main/java/forge/ai/simulation/GameSimulator.java @@ -1,12 +1,6 @@ package forge.ai.simulation; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import forge.ai.ComputerUtil; import forge.ai.PlayerControllerAi; import forge.ai.simulation.GameStateEvaluator.Score; @@ -19,6 +13,8 @@ import forge.game.spellability.TargetChoices; import forge.util.collect.FCollectionView; +import java.util.*; + public class GameSimulator { public static boolean COPY_STACK = false; final private SimulationController controller; diff --git a/forge-ai/src/main/java/forge/ai/simulation/MultiTargetSelector.java b/forge-ai/src/main/java/forge/ai/simulation/MultiTargetSelector.java index da65c4d5855..fcf8bbf34fa 100644 --- a/forge-ai/src/main/java/forge/ai/simulation/MultiTargetSelector.java +++ b/forge-ai/src/main/java/forge/ai/simulation/MultiTargetSelector.java @@ -1,12 +1,12 @@ package forge.ai.simulation; -import java.util.ArrayList; -import java.util.List; - import forge.game.spellability.AbilitySub; import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbilityCondition; +import java.util.ArrayList; +import java.util.List; + public class MultiTargetSelector { public static class Targets { private ArrayList targets; diff --git a/forge-ai/src/main/java/forge/ai/simulation/Plan.java b/forge-ai/src/main/java/forge/ai/simulation/Plan.java index 80b50e3cde3..bdebb458110 100644 --- a/forge-ai/src/main/java/forge/ai/simulation/Plan.java +++ b/forge-ai/src/main/java/forge/ai/simulation/Plan.java @@ -1,15 +1,14 @@ package forge.ai.simulation; -import java.util.ArrayList; -import java.util.List; - import com.google.common.base.Joiner; - import forge.ai.simulation.GameStateEvaluator.Score; import forge.game.card.Card; import forge.game.phase.PhaseType; import forge.game.spellability.SpellAbility; +import java.util.ArrayList; +import java.util.List; + public class Plan { private final List decisions; private final Score finalScore; diff --git a/forge-ai/src/main/java/forge/ai/simulation/PossibleTargetSelector.java b/forge-ai/src/main/java/forge/ai/simulation/PossibleTargetSelector.java index eba03fc1b29..a5bd2d560ca 100644 --- a/forge-ai/src/main/java/forge/ai/simulation/PossibleTargetSelector.java +++ b/forge-ai/src/main/java/forge/ai/simulation/PossibleTargetSelector.java @@ -1,11 +1,6 @@ package forge.ai.simulation; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import com.google.common.collect.ArrayListMultimap; - import forge.ai.ComputerUtilCard; import forge.game.GameObject; import forge.game.ability.AbilityUtils; @@ -15,6 +10,10 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + public class PossibleTargetSelector { private final SpellAbility sa; private final SpellAbility targetingSa; diff --git a/forge-ai/src/main/java/forge/ai/simulation/SimulationController.java b/forge-ai/src/main/java/forge/ai/simulation/SimulationController.java index 2f214ecd09a..254f19ac0ab 100644 --- a/forge-ai/src/main/java/forge/ai/simulation/SimulationController.java +++ b/forge-ai/src/main/java/forge/ai/simulation/SimulationController.java @@ -1,15 +1,15 @@ package forge.ai.simulation; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - import forge.ai.simulation.GameStateEvaluator.Score; import forge.game.GameObject; import forge.game.card.Card; import forge.game.player.Player; import forge.game.spellability.SpellAbility; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + public class SimulationController { private static boolean DEBUG = false; private static int MAX_DEPTH = 3; diff --git a/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityChoicesIterator.java b/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityChoicesIterator.java index 3feff134314..fc0cc44d32d 100644 --- a/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityChoicesIterator.java +++ b/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityChoicesIterator.java @@ -1,20 +1,15 @@ package forge.ai.simulation; import forge.ai.ComputerUtilAbility; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; - -import org.apache.commons.math3.util.CombinatoricsUtils; - import forge.ai.ComputerUtilCost; import forge.ai.simulation.GameStateEvaluator.Score; import forge.game.card.Card; import forge.game.card.CardCollection; import forge.game.spellability.AbilitySub; import forge.game.spellability.SpellAbility; +import org.apache.commons.math3.util.CombinatoricsUtils; + +import java.util.*; public class SpellAbilityChoicesIterator { private final SimulationController controller; diff --git a/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityPicker.java b/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityPicker.java index 483449ace0a..01f1cdadbd3 100644 --- a/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityPicker.java +++ b/forge-ai/src/main/java/forge/ai/simulation/SpellAbilityPicker.java @@ -1,35 +1,26 @@ package forge.ai.simulation; -import forge.util.MyRandom; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.Set; - -import forge.ai.AiPlayDecision; -import forge.ai.ComputerUtil; -import forge.ai.ComputerUtilAbility; -import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilCost; +import forge.ai.*; import forge.ai.ability.ChangeZoneAi; import forge.ai.ability.LearnAi; import forge.ai.simulation.GameStateEvaluator.Score; import forge.game.Game; import forge.game.ability.ApiType; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; +import forge.game.card.*; import forge.game.phase.PhaseType; import forge.game.player.Player; import forge.game.spellability.AbilitySub; - import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbilityCondition; import forge.game.zone.ZoneType; +import forge.util.MyRandom; import forge.util.TextUtil; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.Set; + public class SpellAbilityPicker { private Game game; private Player player; diff --git a/forge-core/src/main/java/forge/MulliganDefs.java b/forge-core/src/main/java/forge/MulliganDefs.java index f35cb824dbf..a4a535fde55 100644 --- a/forge-core/src/main/java/forge/MulliganDefs.java +++ b/forge-core/src/main/java/forge/MulliganDefs.java @@ -1,9 +1,9 @@ package forge; -import java.util.List; - import com.google.common.collect.Lists; +import java.util.List; + /* * A class that contains definitions of available Mulligan rule variants and helper methods to access them */ diff --git a/forge-core/src/main/java/forge/card/CardDb.java b/forge-core/src/main/java/forge/card/CardDb.java index c72b1ec3530..0fba8700859 100644 --- a/forge-core/src/main/java/forge/card/CardDb.java +++ b/forge-core/src/main/java/forge/card/CardDb.java @@ -21,16 +21,15 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Multimaps; - import forge.StaticData; import forge.card.CardEdition.CardInSet; import forge.card.CardEdition.Type; import forge.deck.generation.IDeckGenPool; import forge.item.IPaperCard; import forge.item.PaperCard; -import forge.util.*; +import forge.util.Lang; +import forge.util.TextUtil; import forge.util.lang.LangEnglish; - import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; diff --git a/forge-core/src/main/java/forge/card/CardFace.java b/forge-core/src/main/java/forge/card/CardFace.java index 2fbf01e2664..f7495b047d5 100644 --- a/forge-core/src/main/java/forge/card/CardFace.java +++ b/forge-core/src/main/java/forge/card/CardFace.java @@ -1,13 +1,12 @@ package forge.card; +import forge.card.mana.ManaCost; +import org.apache.commons.lang3.StringUtils; + import java.util.*; import java.util.Map.Entry; import java.util.stream.Collectors; -import org.apache.commons.lang3.StringUtils; - -import forge.card.mana.ManaCost; - // // DO NOT AUTOFORMAT / CHECKSTYLE THIS FILE // diff --git a/forge-core/src/main/java/forge/card/CardRules.java b/forge-core/src/main/java/forge/card/CardRules.java index 5fd541fda23..3d12f84a5c7 100644 --- a/forge-core/src/main/java/forge/card/CardRules.java +++ b/forge-core/src/main/java/forge/card/CardRules.java @@ -17,20 +17,18 @@ */ package forge.card; -import java.util.*; - import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import org.apache.commons.lang3.StringUtils; - import com.google.common.collect.Maps; - import forge.card.mana.IParserManaCost; import forge.card.mana.ManaCost; import forge.card.mana.ManaCostShard; import forge.util.TextUtil; +import org.apache.commons.lang3.StringUtils; + +import java.util.*; -import static forge.card.MagicColor.Constant.*; +import static forge.card.MagicColor.Constant.BASIC_LANDS; import static org.apache.commons.lang3.StringUtils.containsIgnoreCase; /** diff --git a/forge-core/src/main/java/forge/card/CardRulesPredicates.java b/forge-core/src/main/java/forge/card/CardRulesPredicates.java index b4b8ffad686..a8e2c9fe4a5 100644 --- a/forge-core/src/main/java/forge/card/CardRulesPredicates.java +++ b/forge-core/src/main/java/forge/card/CardRulesPredicates.java @@ -1,11 +1,16 @@ package forge.card; -import java.util.*; -import java.util.function.Predicate; - -import forge.util.*; +import forge.util.CardTranslation; +import forge.util.ComparableOp; +import forge.util.IterableUtil; +import forge.util.PredicateString; import org.apache.commons.lang3.StringUtils; +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; +import java.util.function.Predicate; + /** * Filtering conditions specific for CardRules class, defined here along with * some presets. diff --git a/forge-core/src/main/java/forge/card/CardType.java b/forge-core/src/main/java/forge/card/CardType.java index b3a95c0e7bd..67dabc6fb5d 100644 --- a/forge-core/src/main/java/forge/card/CardType.java +++ b/forge-core/src/main/java/forge/card/CardType.java @@ -17,16 +17,15 @@ */ package forge.card; -import java.util.*; -import java.util.function.Predicate; - import com.google.common.collect.*; import forge.util.IterableUtil; +import forge.util.Settable; import org.apache.commons.lang3.EnumUtils; import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.StringUtils; -import forge.util.Settable; +import java.util.*; +import java.util.function.Predicate; /** *

diff --git a/forge-core/src/main/java/forge/card/CardTypeView.java b/forge-core/src/main/java/forge/card/CardTypeView.java index 762f87ee287..d56514a02b5 100644 --- a/forge-core/src/main/java/forge/card/CardTypeView.java +++ b/forge-core/src/main/java/forge/card/CardTypeView.java @@ -1,11 +1,11 @@ package forge.card; -import java.io.Serializable; -import java.util.Set; - import forge.card.CardType.CoreType; import forge.card.CardType.Supertype; +import java.io.Serializable; +import java.util.Set; + //Interface to expose only the desired functions of CardType without allowing modification public interface CardTypeView extends Iterable, Serializable { boolean isEmpty(); diff --git a/forge-core/src/main/java/forge/card/ColorSet.java b/forge-core/src/main/java/forge/card/ColorSet.java index 9648e968487..4726b309eb9 100644 --- a/forge-core/src/main/java/forge/card/ColorSet.java +++ b/forge-core/src/main/java/forge/card/ColorSet.java @@ -17,21 +17,15 @@ */ package forge.card; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.Set; - import com.google.common.collect.UnmodifiableIterator; - import forge.card.MagicColor.Color; import forge.card.mana.ManaCost; import forge.card.mana.ManaCostShard; import forge.util.BinaryUtil; +import java.io.Serializable; +import java.util.*; + /** *

CardColor class.

*

Represents a set of any number of colors out of 5 possible in the game

diff --git a/forge-core/src/main/java/forge/card/DeckHints.java b/forge-core/src/main/java/forge/card/DeckHints.java index a813d75ec8b..59ac974a5f1 100644 --- a/forge-core/src/main/java/forge/card/DeckHints.java +++ b/forge-core/src/main/java/forge/card/DeckHints.java @@ -1,18 +1,20 @@ package forge.card; -import java.util.*; -import java.util.function.Function; -import java.util.function.Predicate; - import com.google.common.collect.Iterables; -import forge.util.IterableUtil; -import org.apache.commons.lang3.tuple.Pair; - import forge.StaticData; import forge.item.PaperCard; import forge.token.TokenDb; +import forge.util.IterableUtil; import forge.util.PredicateString.StringOp; import forge.util.collect.FCollection; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Predicate; /** * DeckHints provides the ability for a Card to "want" another Card or type of diff --git a/forge-core/src/main/java/forge/card/PrintSheet.java b/forge-core/src/main/java/forge/card/PrintSheet.java index bf3761bc40f..aa8fcedbfaf 100644 --- a/forge-core/src/main/java/forge/card/PrintSheet.java +++ b/forge-core/src/main/java/forge/card/PrintSheet.java @@ -1,11 +1,5 @@ package forge.card; -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map.Entry; - import forge.deck.CardPool; import forge.item.PaperCard; import forge.util.ItemPool; @@ -14,6 +8,12 @@ import forge.util.storage.StorageExtendable; import forge.util.storage.StorageReaderFileSections; +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map.Entry; + /** * TODO: Write javadoc for this type. diff --git a/forge-core/src/main/java/forge/card/mana/ManaCost.java b/forge-core/src/main/java/forge/card/mana/ManaCost.java index eb96946b575..585ccf2b1ee 100644 --- a/forge-core/src/main/java/forge/card/mana/ManaCost.java +++ b/forge-core/src/main/java/forge/card/mana/ManaCost.java @@ -17,15 +17,14 @@ */ package forge.card.mana; +import com.google.common.collect.Lists; +import org.apache.commons.lang3.StringUtils; + import java.io.Serializable; import java.util.Collections; import java.util.Iterator; import java.util.List; -import org.apache.commons.lang3.StringUtils; - -import com.google.common.collect.Lists; - /** *

* CardManaCost class. diff --git a/forge-core/src/main/java/forge/deck/DeckBase.java b/forge-core/src/main/java/forge/deck/DeckBase.java index 6c4c302889e..12eb7544b06 100644 --- a/forge-core/src/main/java/forge/deck/DeckBase.java +++ b/forge-core/src/main/java/forge/deck/DeckBase.java @@ -17,12 +17,12 @@ */ package forge.deck; +import forge.item.InventoryItem; + import java.io.Serializable; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import forge.item.InventoryItem; - public abstract class DeckBase implements Serializable, Comparable, InventoryItem { private static final long serialVersionUID = -7538150536939660052L; // gameType is from Constant.GameType, like GameType.Regular diff --git a/forge-core/src/main/java/forge/deck/DeckFormat.java b/forge-core/src/main/java/forge/deck/DeckFormat.java index 169d5fdca2b..e51cc9231b1 100644 --- a/forge-core/src/main/java/forge/deck/DeckFormat.java +++ b/forge-core/src/main/java/forge/deck/DeckFormat.java @@ -20,11 +20,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import forge.StaticData; -import forge.card.CardRules; -import forge.card.CardRulesPredicates; -import forge.card.CardType; -import forge.card.ColorSet; -import forge.card.ICardFace; +import forge.card.*; import forge.deck.generation.DeckGenPool; import forge.deck.generation.DeckGeneratorBase.FilterCMC; import forge.deck.generation.IDeckGenPool; diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java b/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java index 211efffb820..b674c226616 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGenPool.java @@ -1,13 +1,13 @@ package forge.deck.generation; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Predicate; - import forge.item.PaperCard; import forge.item.PaperCardPredicates; import forge.util.IterableUtil; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Predicate; + public class DeckGenPool implements IDeckGenPool { private final Map cards = new HashMap<>(); diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGenerator2Color.java b/forge-core/src/main/java/forge/deck/generation/DeckGenerator2Color.java index 70270043f18..380702b57f2 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGenerator2Color.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGenerator2Color.java @@ -17,20 +17,18 @@ */ package forge.deck.generation; -import java.util.Arrays; -import java.util.List; -import java.util.function.Predicate; - -import org.apache.commons.lang3.tuple.ImmutablePair; - import com.google.common.collect.Lists; - import forge.card.ColorSet; import forge.card.MagicColor; import forge.deck.CardPool; import forge.deck.DeckFormat; import forge.item.PaperCard; import forge.util.MyRandom; +import org.apache.commons.lang3.tuple.ImmutablePair; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; /** *

diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGenerator3Color.java b/forge-core/src/main/java/forge/deck/generation/DeckGenerator3Color.java index cf7d0facc01..738ce17b922 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGenerator3Color.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGenerator3Color.java @@ -17,19 +17,17 @@ */ package forge.deck.generation; -import java.util.List; -import java.util.function.Predicate; - -import org.apache.commons.lang3.tuple.ImmutablePair; - import com.google.common.collect.Lists; - import forge.card.ColorSet; import forge.card.MagicColor; import forge.deck.CardPool; import forge.deck.DeckFormat; import forge.item.PaperCard; import forge.util.MyRandom; +import org.apache.commons.lang3.tuple.ImmutablePair; + +import java.util.List; +import java.util.function.Predicate; /** *

diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGenerator4Color.java b/forge-core/src/main/java/forge/deck/generation/DeckGenerator4Color.java index 99e2c964540..91e271ed86a 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGenerator4Color.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGenerator4Color.java @@ -17,19 +17,17 @@ */ package forge.deck.generation; -import java.util.List; -import java.util.function.Predicate; - -import org.apache.commons.lang3.tuple.ImmutablePair; - import com.google.common.collect.Lists; - import forge.card.ColorSet; import forge.card.MagicColor; import forge.deck.CardPool; import forge.deck.DeckFormat; import forge.item.PaperCard; import forge.util.MyRandom; +import org.apache.commons.lang3.tuple.ImmutablePair; + +import java.util.List; +import java.util.function.Predicate; /** *

diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGenerator5Color.java b/forge-core/src/main/java/forge/deck/generation/DeckGenerator5Color.java index 7c3c10a83b9..c348e7c560b 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGenerator5Color.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGenerator5Color.java @@ -17,17 +17,15 @@ */ package forge.deck.generation; -import java.util.List; -import java.util.function.Predicate; - -import org.apache.commons.lang3.tuple.ImmutablePair; - import com.google.common.collect.Lists; - import forge.card.ColorSet; import forge.deck.CardPool; import forge.deck.DeckFormat; import forge.item.PaperCard; +import org.apache.commons.lang3.tuple.ImmutablePair; + +import java.util.List; +import java.util.function.Predicate; /** *

diff --git a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorMonoColor.java b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorMonoColor.java index fa5be73b7f1..45a4ca31d83 100644 --- a/forge-core/src/main/java/forge/deck/generation/DeckGeneratorMonoColor.java +++ b/forge-core/src/main/java/forge/deck/generation/DeckGeneratorMonoColor.java @@ -17,19 +17,17 @@ */ package forge.deck.generation; -import java.util.List; -import java.util.function.Predicate; - -import org.apache.commons.lang3.tuple.ImmutablePair; - import com.google.common.collect.Lists; - import forge.card.ColorSet; import forge.card.MagicColor; import forge.deck.CardPool; import forge.deck.DeckFormat; import forge.item.PaperCard; import forge.util.MyRandom; +import org.apache.commons.lang3.tuple.ImmutablePair; + +import java.util.List; +import java.util.function.Predicate; /** *

diff --git a/forge-core/src/main/java/forge/deck/io/DeckFileHeader.java b/forge-core/src/main/java/forge/deck/io/DeckFileHeader.java index 6e36e4efbaf..594b7d76179 100644 --- a/forge-core/src/main/java/forge/deck/io/DeckFileHeader.java +++ b/forge-core/src/main/java/forge/deck/io/DeckFileHeader.java @@ -17,15 +17,14 @@ */ package forge.deck.io; +import forge.deck.DeckFormat; +import forge.util.FileSection; +import org.apache.commons.lang3.StringUtils; + import java.util.HashMap; import java.util.Set; import java.util.TreeSet; -import org.apache.commons.lang3.StringUtils; - -import forge.deck.DeckFormat; -import forge.util.FileSection; - /** * TODO: Write javadoc for this type. * diff --git a/forge-core/src/main/java/forge/deck/io/DeckGroupSerializer.java b/forge-core/src/main/java/forge/deck/io/DeckGroupSerializer.java index dc5019c3a39..007ed489b74 100644 --- a/forge-core/src/main/java/forge/deck/io/DeckGroupSerializer.java +++ b/forge-core/src/main/java/forge/deck/io/DeckGroupSerializer.java @@ -17,19 +17,17 @@ */ package forge.deck.io; -import java.io.File; -import java.io.FilenameFilter; -import java.util.List; - -import forge.deck.DeckBase; -import org.apache.commons.lang3.StringUtils; - import com.google.common.collect.ImmutableList; - import forge.deck.Deck; +import forge.deck.DeckBase; import forge.deck.DeckGroup; import forge.util.IItemSerializer; import forge.util.storage.StorageReaderFolder; +import org.apache.commons.lang3.StringUtils; + +import java.io.File; +import java.io.FilenameFilter; +import java.util.List; /** * TODO: Write javadoc for this type. diff --git a/forge-core/src/main/java/forge/deck/io/DeckSerializer.java b/forge-core/src/main/java/forge/deck/io/DeckSerializer.java index a067e53fb45..98a290691fd 100644 --- a/forge-core/src/main/java/forge/deck/io/DeckSerializer.java +++ b/forge-core/src/main/java/forge/deck/io/DeckSerializer.java @@ -1,13 +1,5 @@ package forge.deck.io; -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.apache.commons.lang3.StringUtils; - import forge.deck.CardPool; import forge.deck.Deck; import forge.deck.DeckSection; @@ -15,6 +7,13 @@ import forge.util.FileSectionManual; import forge.util.FileUtil; import forge.util.TextUtil; +import org.apache.commons.lang3.StringUtils; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; public class DeckSerializer { diff --git a/forge-core/src/main/java/forge/deck/io/DeckStorage.java b/forge-core/src/main/java/forge/deck/io/DeckStorage.java index 9f9bc30342f..a6aa18fff37 100644 --- a/forge-core/src/main/java/forge/deck/io/DeckStorage.java +++ b/forge-core/src/main/java/forge/deck/io/DeckStorage.java @@ -17,11 +17,6 @@ */ package forge.deck.io; -import java.io.File; -import java.io.FilenameFilter; -import java.util.List; -import java.util.Map; - import forge.deck.Deck; import forge.deck.DeckBase; import forge.util.FileSection; @@ -30,6 +25,11 @@ import forge.util.IItemSerializer; import forge.util.storage.StorageReaderFolder; +import java.io.File; +import java.io.FilenameFilter; +import java.util.List; +import java.util.Map; + /** * This class knows how to make a file out of a deck object and vice versa. */ diff --git a/forge-core/src/main/java/forge/item/PaperToken.java b/forge-core/src/main/java/forge/item/PaperToken.java index c13b0435880..c0fa6ed936a 100644 --- a/forge-core/src/main/java/forge/item/PaperToken.java +++ b/forge-core/src/main/java/forge/item/PaperToken.java @@ -1,13 +1,12 @@ package forge.item; -import java.util.ArrayList; -import java.util.Locale; - +import forge.ImageKeys; import forge.card.*; +import forge.util.MyRandom; import org.apache.commons.lang3.StringUtils; -import forge.ImageKeys; -import forge.util.MyRandom; +import java.util.ArrayList; +import java.util.Locale; public class PaperToken implements InventoryItemFromSet, IPaperCard { private static final long serialVersionUID = 1L; diff --git a/forge-core/src/main/java/forge/item/PreconDeck.java b/forge-core/src/main/java/forge/item/PreconDeck.java index 157272c84da..9ed912819a2 100644 --- a/forge-core/src/main/java/forge/item/PreconDeck.java +++ b/forge-core/src/main/java/forge/item/PreconDeck.java @@ -17,11 +17,6 @@ */ package forge.item; -import java.io.File; -import java.io.FilenameFilter; -import java.util.List; -import java.util.Map; - import forge.ImageKeys; import forge.StaticData; import forge.deck.Deck; @@ -31,6 +26,11 @@ import forge.util.FileUtil; import forge.util.storage.StorageReaderFolder; +import java.io.File; +import java.io.FilenameFilter; +import java.util.List; +import java.util.Map; + public class PreconDeck implements InventoryItemFromSet { private final Deck deck; diff --git a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java index 7d0d2a11fde..b68002eb2ba 100644 --- a/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java +++ b/forge-core/src/main/java/forge/item/generation/BoosterGenerator.java @@ -20,10 +20,16 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import forge.StaticData; -import forge.card.*; +import forge.card.CardEdition; import forge.card.CardEdition.FoilType; +import forge.card.CardRarity; +import forge.card.CardSplitType; +import forge.card.PrintSheet; import forge.item.*; -import forge.util.*; +import forge.util.Aggregates; +import forge.util.IterableUtil; +import forge.util.MyRandom; +import forge.util.TextUtil; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; diff --git a/forge-core/src/main/java/forge/item/generation/ChaosBoosterSupplier.java b/forge-core/src/main/java/forge/item/generation/ChaosBoosterSupplier.java index 55203a7f47c..c4a38769dc1 100644 --- a/forge-core/src/main/java/forge/item/generation/ChaosBoosterSupplier.java +++ b/forge-core/src/main/java/forge/item/generation/ChaosBoosterSupplier.java @@ -1,12 +1,12 @@ package forge.item.generation; -import java.util.List; - import forge.card.CardEdition; import forge.item.BoosterPack; import forge.item.PaperCard; import forge.util.BagRandomizer; +import java.util.List; + public class ChaosBoosterSupplier implements IUnOpenedProduct { private BagRandomizer randomizer; diff --git a/forge-core/src/main/java/forge/item/generation/IUnOpenedProduct.java b/forge-core/src/main/java/forge/item/generation/IUnOpenedProduct.java index e5bece9cbb5..de4a3050ce6 100644 --- a/forge-core/src/main/java/forge/item/generation/IUnOpenedProduct.java +++ b/forge-core/src/main/java/forge/item/generation/IUnOpenedProduct.java @@ -1,10 +1,10 @@ package forge.item.generation; +import forge.item.PaperCard; + import java.util.List; import java.util.function.Supplier; -import forge.item.PaperCard; - /** * TODO: Write javadoc for this type. * diff --git a/forge-core/src/main/java/forge/util/Aggregates.java b/forge-core/src/main/java/forge/util/Aggregates.java index 9a81d1f6309..6fa001d5be9 100644 --- a/forge-core/src/main/java/forge/util/Aggregates.java +++ b/forge-core/src/main/java/forge/util/Aggregates.java @@ -1,11 +1,11 @@ package forge.util; +import com.google.common.collect.Lists; + import java.util.*; import java.util.Map.Entry; import java.util.function.Function; -import com.google.common.collect.Lists; - /** * TODO: Write javadoc for this type. * diff --git a/forge-core/src/main/java/forge/util/Base64Coder.java b/forge-core/src/main/java/forge/util/Base64Coder.java index 8df0f11b935..c0c018bfa9c 100644 --- a/forge-core/src/main/java/forge/util/Base64Coder.java +++ b/forge-core/src/main/java/forge/util/Base64Coder.java @@ -31,14 +31,13 @@ package forge.util; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; - import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.PBEParameterSpec; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; /** * A Base64 encoder/decoder. diff --git a/forge-core/src/main/java/forge/util/CardTranslation.java b/forge-core/src/main/java/forge/util/CardTranslation.java index 3912e2daf83..f035dadb324 100644 --- a/forge-core/src/main/java/forge/util/CardTranslation.java +++ b/forge-core/src/main/java/forge/util/CardTranslation.java @@ -1,14 +1,14 @@ package forge.util; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.Pair; + import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.tuple.Pair; - public class CardTranslation { private static Map translatednames; diff --git a/forge-core/src/main/java/forge/util/FileSection.java b/forge-core/src/main/java/forge/util/FileSection.java index e4db0e9dd5d..d8c2f853b46 100644 --- a/forge-core/src/main/java/forge/util/FileSection.java +++ b/forge-core/src/main/java/forge/util/FileSection.java @@ -17,21 +17,15 @@ */ package forge.util; +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Table; +import org.apache.commons.lang3.StringUtils; + import java.text.NumberFormat; import java.text.ParseException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.TreeMap; +import java.util.*; import java.util.regex.Pattern; -import org.apache.commons.lang3.StringUtils; - -import com.google.common.collect.HashBasedTable; -import com.google.common.collect.Table; - /** * TODO: Write javadoc for this type. * diff --git a/forge-core/src/main/java/forge/util/ItemPool.java b/forge-core/src/main/java/forge/util/ItemPool.java index bc361b5aaf4..d49929a5f51 100644 --- a/forge-core/src/main/java/forge/util/ItemPool.java +++ b/forge-core/src/main/java/forge/util/ItemPool.java @@ -17,6 +17,9 @@ */ package forge.util; +import com.google.common.collect.Maps; +import forge.item.InventoryItem; + import java.io.Serializable; import java.util.*; import java.util.Map.Entry; @@ -24,9 +27,6 @@ import java.util.function.*; import java.util.stream.Collector; -import com.google.common.collect.Maps; -import forge.item.InventoryItem; - /** *

* ItemPool class. diff --git a/forge-core/src/main/java/forge/util/ItemPoolSorter.java b/forge-core/src/main/java/forge/util/ItemPoolSorter.java index f0a9212df9a..69830c7b860 100644 --- a/forge-core/src/main/java/forge/util/ItemPoolSorter.java +++ b/forge-core/src/main/java/forge/util/ItemPoolSorter.java @@ -17,12 +17,12 @@ */ package forge.util; +import forge.item.PaperCard; + import java.util.Comparator; import java.util.Map.Entry; import java.util.function.Function; -import forge.item.PaperCard; - /** *

diff --git a/forge-core/src/main/java/forge/util/Lang.java b/forge-core/src/main/java/forge/util/Lang.java index f6674cb1d1f..67f2cf1bccd 100644 --- a/forge-core/src/main/java/forge/util/Lang.java +++ b/forge-core/src/main/java/forge/util/Lang.java @@ -1,23 +1,15 @@ package forge.util; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import forge.util.lang.*; +import org.apache.commons.lang3.StringUtils; + import java.util.Collection; import java.util.List; import java.util.function.Function; import java.util.regex.Pattern; -import com.google.common.collect.Iterables; -import org.apache.commons.lang3.StringUtils; - -import com.google.common.collect.Lists; - -import forge.util.lang.LangChinese; -import forge.util.lang.LangEnglish; -import forge.util.lang.LangGerman; -import forge.util.lang.LangItalian; -import forge.util.lang.LangJapanese; -import forge.util.lang.LangSpanish; -import forge.util.lang.LangFrench; - /** * Static library containing language-related utility methods. */ diff --git a/forge-core/src/main/java/forge/util/LineReader.java b/forge-core/src/main/java/forge/util/LineReader.java index 9da9e51c3c0..7657bd949b3 100644 --- a/forge-core/src/main/java/forge/util/LineReader.java +++ b/forge-core/src/main/java/forge/util/LineReader.java @@ -21,11 +21,8 @@ * TODO: Write javadoc for this type. * */ -import java.io.BufferedReader; -import java.io.Closeable; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; + +import java.io.*; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collection; diff --git a/forge-core/src/main/java/forge/util/NameGenerator.java b/forge-core/src/main/java/forge/util/NameGenerator.java index 3203ca344bb..351495e4e0e 100644 --- a/forge-core/src/main/java/forge/util/NameGenerator.java +++ b/forge-core/src/main/java/forge/util/NameGenerator.java @@ -1,12 +1,12 @@ /** Random name generator for Forge. */ package forge.util; +import org.apache.commons.lang3.ArrayUtils; + import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.apache.commons.lang3.ArrayUtils; - /** * @author Marc * diff --git a/forge-core/src/main/java/forge/util/ReflectionUtil.java b/forge-core/src/main/java/forge/util/ReflectionUtil.java index f614256fc79..72cb08df156 100644 --- a/forge-core/src/main/java/forge/util/ReflectionUtil.java +++ b/forge-core/src/main/java/forge/util/ReflectionUtil.java @@ -1,11 +1,11 @@ package forge.util; +import org.apache.commons.lang3.reflect.TypeUtils; + import java.lang.reflect.Array; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import org.apache.commons.lang3.reflect.TypeUtils; - /** * Static utilities related to reflection. * diff --git a/forge-core/src/main/java/forge/util/StreamUtil.java b/forge-core/src/main/java/forge/util/StreamUtil.java index c53a41cb239..e7eb383e52f 100644 --- a/forge-core/src/main/java/forge/util/StreamUtil.java +++ b/forge-core/src/main/java/forge/util/StreamUtil.java @@ -1,7 +1,10 @@ package forge.util; import java.util.*; -import java.util.function.*; +import java.util.function.BiConsumer; +import java.util.function.BinaryOperator; +import java.util.function.Function; +import java.util.function.Supplier; import java.util.stream.Collector; import java.util.stream.Stream; diff --git a/forge-core/src/main/java/forge/util/TextUtil.java b/forge-core/src/main/java/forge/util/TextUtil.java index c9388983c77..57a944a54a2 100644 --- a/forge-core/src/main/java/forge/util/TextUtil.java +++ b/forge-core/src/main/java/forge/util/TextUtil.java @@ -1,5 +1,11 @@ package forge.util; +import com.google.common.collect.ImmutableSortedMap; +import forge.item.IPaperCard; +import forge.item.PaperCard; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; + import java.text.DecimalFormat; import java.text.Normalizer; import java.util.ArrayList; @@ -8,14 +14,6 @@ import java.util.Map; import java.util.Map.Entry; -import forge.item.IPaperCard; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; - -import com.google.common.collect.ImmutableSortedMap; - -import forge.item.PaperCard; - /** * TODO: Write javadoc for this type. * diff --git a/forge-core/src/main/java/forge/util/ThreadUtil.java b/forge-core/src/main/java/forge/util/ThreadUtil.java index c481816ff95..d340111c1a3 100644 --- a/forge-core/src/main/java/forge/util/ThreadUtil.java +++ b/forge-core/src/main/java/forge/util/ThreadUtil.java @@ -1,13 +1,6 @@ package forge.util; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; public class ThreadUtil { static { 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 7753a2a918f..630af00f41c 100644 --- a/forge-core/src/main/java/forge/util/collect/FCollection.java +++ b/forge-core/src/main/java/forge/util/collect/FCollection.java @@ -1,22 +1,13 @@ package forge.util.collect; +import com.google.common.collect.*; +import org.apache.commons.lang3.ArrayUtils; + import java.io.Serializable; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.NoSuchElementException; -import java.util.Set; +import java.util.*; import java.util.function.Predicate; import java.util.stream.Stream; -import com.google.common.collect.*; -import org.apache.commons.lang3.ArrayUtils; - /** * Collection with unique elements ({@link Set}) that maintains the order in * which the elements are added to it ({@link List}). diff --git a/forge-core/src/main/java/forge/util/collect/FCollectionReader.java b/forge-core/src/main/java/forge/util/collect/FCollectionReader.java index 10e8dc4f045..a29357400d9 100644 --- a/forge-core/src/main/java/forge/util/collect/FCollectionReader.java +++ b/forge-core/src/main/java/forge/util/collect/FCollectionReader.java @@ -1,9 +1,9 @@ package forge.util.collect; -import java.io.File; - import forge.util.FileUtil; +import java.io.File; + public abstract class FCollectionReader { protected final File file; diff --git a/forge-core/src/main/java/forge/util/maps/MapToAmountUtil.java b/forge-core/src/main/java/forge/util/maps/MapToAmountUtil.java index f2a04e02790..2c67da00a9b 100644 --- a/forge-core/src/main/java/forge/util/maps/MapToAmountUtil.java +++ b/forge-core/src/main/java/forge/util/maps/MapToAmountUtil.java @@ -1,17 +1,15 @@ package forge.util.maps; +import com.google.common.collect.Lists; +import forge.util.collect.FCollection; +import forge.util.collect.FCollectionView; +import org.apache.commons.lang3.tuple.Pair; + import java.util.Collections; import java.util.List; import java.util.Map.Entry; import java.util.NoSuchElementException; -import org.apache.commons.lang3.tuple.Pair; - -import com.google.common.collect.Lists; - -import forge.util.collect.FCollection; -import forge.util.collect.FCollectionView; - public final class MapToAmountUtil { diff --git a/forge-core/src/main/java/forge/util/storage/IStorage.java b/forge-core/src/main/java/forge/util/storage/IStorage.java index e9689f211c1..a93c6174444 100644 --- a/forge-core/src/main/java/forge/util/storage/IStorage.java +++ b/forge-core/src/main/java/forge/util/storage/IStorage.java @@ -17,12 +17,12 @@ */ package forge.util.storage; +import forge.util.IHasName; + import java.util.Collection; import java.util.function.Predicate; import java.util.stream.Stream; -import forge.util.IHasName; - public interface IStorage extends Iterable, IHasName { String getFullPath(); T get(String name); diff --git a/forge-core/src/main/java/forge/util/storage/StorageExtendable.java b/forge-core/src/main/java/forge/util/storage/StorageExtendable.java index d0eb92dee2b..50807b641ca 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageExtendable.java +++ b/forge-core/src/main/java/forge/util/storage/StorageExtendable.java @@ -17,10 +17,10 @@ */ package forge.util.storage; -import java.util.Map; - import forge.util.IItemReader; +import java.util.Map; + /** *

* StorageBase class. diff --git a/forge-core/src/main/java/forge/util/storage/StorageImmediatelySerialized.java b/forge-core/src/main/java/forge/util/storage/StorageImmediatelySerialized.java index 02bb126e038..c6ddc7d2941 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageImmediatelySerialized.java +++ b/forge-core/src/main/java/forge/util/storage/StorageImmediatelySerialized.java @@ -17,12 +17,12 @@ */ package forge.util.storage; -import java.io.File; -import java.util.function.Function; - import forge.util.IItemSerializer; import forge.util.TextUtil; +import java.io.File; +import java.util.function.Function; + /** *

* StorageImmediatelySerialized class. diff --git a/forge-core/src/main/java/forge/util/storage/StorageReaderBase.java b/forge-core/src/main/java/forge/util/storage/StorageReaderBase.java index 6f602c6aafc..0519e87540a 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageReaderBase.java +++ b/forge-core/src/main/java/forge/util/storage/StorageReaderBase.java @@ -1,14 +1,13 @@ package forge.util.storage; +import com.google.common.collect.ImmutableList; +import forge.util.IItemReader; + import java.io.File; import java.util.Map; import java.util.TreeMap; import java.util.function.Function; -import com.google.common.collect.ImmutableList; - -import forge.util.IItemReader; - public abstract class StorageReaderBase implements IItemReader { protected final Function keySelector; public StorageReaderBase(final Function keySelector0) { diff --git a/forge-core/src/main/java/forge/util/storage/StorageReaderFile.java b/forge-core/src/main/java/forge/util/storage/StorageReaderFile.java index 10f8ce9493e..fe2e35bc1bc 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageReaderFile.java +++ b/forge-core/src/main/java/forge/util/storage/StorageReaderFile.java @@ -17,14 +17,13 @@ */ package forge.util.storage; +import forge.util.FileUtil; +import org.apache.commons.lang3.StringUtils; + import java.io.File; import java.util.Map; import java.util.function.Function; -import org.apache.commons.lang3.StringUtils; - -import forge.util.FileUtil; - /** * This class treats every line of a given file as a source for a named object. * diff --git a/forge-core/src/main/java/forge/util/storage/StorageReaderFileSections.java b/forge-core/src/main/java/forge/util/storage/StorageReaderFileSections.java index b20a8006548..0b6d1926ff5 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageReaderFileSections.java +++ b/forge-core/src/main/java/forge/util/storage/StorageReaderFileSections.java @@ -17,16 +17,15 @@ */ package forge.util.storage; +import forge.util.FileUtil; +import org.apache.commons.lang3.StringUtils; + import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.function.Function; -import org.apache.commons.lang3.StringUtils; - -import forge.util.FileUtil; - /** * This class treats every line of a given file as a source for a named object. * diff --git a/forge-core/src/main/java/forge/util/storage/StorageReaderFolder.java b/forge-core/src/main/java/forge/util/storage/StorageReaderFolder.java index 9eb5db24ff3..6ccd8dea43a 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageReaderFolder.java +++ b/forge-core/src/main/java/forge/util/storage/StorageReaderFolder.java @@ -17,18 +17,14 @@ */ package forge.util.storage; +import forge.util.TextUtil; + import java.io.File; import java.io.FilenameFilter; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; +import java.util.*; import java.util.function.Function; -import forge.util.TextUtil; - /** * This class treats every file in the given folder as a source for a named * object. The descendant should implement read method to deserialize a single diff --git a/forge-core/src/main/java/forge/util/storage/StorageReaderRecursiveFolderWithUserFolder.java b/forge-core/src/main/java/forge/util/storage/StorageReaderRecursiveFolderWithUserFolder.java index 12d22fc43e0..000fb387cef 100644 --- a/forge-core/src/main/java/forge/util/storage/StorageReaderRecursiveFolderWithUserFolder.java +++ b/forge-core/src/main/java/forge/util/storage/StorageReaderRecursiveFolderWithUserFolder.java @@ -17,21 +17,14 @@ */ package forge.util.storage; +import forge.util.TextUtil; + import java.io.File; import java.io.FilenameFilter; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; +import java.util.*; import java.util.function.Function; -import forge.util.TextUtil; - /** * This class treats every file in the given folder as a source for a named * object. The descendant should implement read method to deserialize a single diff --git a/forge-game/src/main/java/forge/game/card/ActivationTable.java b/forge-game/src/main/java/forge/game/card/ActivationTable.java index 1dad7571d12..75bc756069e 100644 --- a/forge-game/src/main/java/forge/game/card/ActivationTable.java +++ b/forge-game/src/main/java/forge/game/card/ActivationTable.java @@ -1,18 +1,16 @@ package forge.game.card; -import java.util.List; -import java.util.Optional; - -import org.apache.commons.lang3.ObjectUtils; - import com.google.common.collect.ForwardingTable; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Lists; import com.google.common.collect.Table; - import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.staticability.StaticAbility; +import org.apache.commons.lang3.ObjectUtils; + +import java.util.List; +import java.util.Optional; public class ActivationTable extends ForwardingTable, List> { Table, List> dataTable = HashBasedTable.create(); diff --git a/forge-game/src/main/java/forge/game/card/CardChangedWords.java b/forge-game/src/main/java/forge/game/card/CardChangedWords.java index 70872e925e6..0f7d700302f 100644 --- a/forge-game/src/main/java/forge/game/card/CardChangedWords.java +++ b/forge-game/src/main/java/forge/game/card/CardChangedWords.java @@ -1,12 +1,12 @@ package forge.game.card; -import java.util.Map; - import com.google.common.collect.ForwardingMap; import com.google.common.collect.Maps; import com.google.common.collect.Table; import com.google.common.collect.TreeBasedTable; +import java.util.Map; + public final class CardChangedWords extends ForwardingMap { class WordHolder { diff --git a/forge-game/src/main/java/forge/game/card/CardCloneStates.java b/forge-game/src/main/java/forge/game/card/CardCloneStates.java index 796bf0e75ea..4cb5b0c51c9 100644 --- a/forge-game/src/main/java/forge/game/card/CardCloneStates.java +++ b/forge-game/src/main/java/forge/game/card/CardCloneStates.java @@ -1,13 +1,12 @@ package forge.game.card; -import java.util.Map; - import com.google.common.collect.ForwardingMap; import com.google.common.collect.Maps; - import forge.card.CardStateName; import forge.game.CardTraitBase; +import java.util.Map; + public class CardCloneStates extends ForwardingMap { private Map dataMap = Maps.newEnumMap(CardStateName.class); diff --git a/forge-game/src/main/java/forge/game/card/CardDamageHistory.java b/forge-game/src/main/java/forge/game/card/CardDamageHistory.java index e45be2ff404..03dddee587f 100644 --- a/forge-game/src/main/java/forge/game/card/CardDamageHistory.java +++ b/forge-game/src/main/java/forge/game/card/CardDamageHistory.java @@ -1,18 +1,16 @@ package forge.game.card; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.tuple.Pair; - import com.google.common.collect.Lists; - import forge.game.CardTraitBase; import forge.game.GameEntity; import forge.game.player.Player; import forge.game.zone.ZoneType; import forge.util.collect.FCollection; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.List; +import java.util.Map; /** * TODO: Write javadoc for this type. diff --git a/forge-game/src/main/java/forge/game/card/CardDamageMap.java b/forge-game/src/main/java/forge/game/card/CardDamageMap.java index e4b190da9ed..f102db9f914 100644 --- a/forge-game/src/main/java/forge/game/card/CardDamageMap.java +++ b/forge-game/src/main/java/forge/game/card/CardDamageMap.java @@ -3,16 +3,10 @@ */ package forge.game.card; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.stream.Collectors; - import com.google.common.collect.ForwardingTable; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Maps; import com.google.common.collect.Table; - import forge.game.CardTraitBase; import forge.game.Game; import forge.game.GameEntity; @@ -24,6 +18,11 @@ import forge.game.spellability.SpellAbility; import forge.game.trigger.TriggerType; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.stream.Collectors; + public class CardDamageMap extends ForwardingTable { private Table dataMap = HashBasedTable.create(); diff --git a/forge-game/src/main/java/forge/game/card/CardFactory.java b/forge-game/src/main/java/forge/game/card/CardFactory.java index f00d3c7ab3a..18805e07482 100644 --- a/forge-game/src/main/java/forge/game/card/CardFactory.java +++ b/forge-game/src/main/java/forge/game/card/CardFactory.java @@ -43,7 +43,9 @@ import forge.util.CardTranslation; import forge.util.TextUtil; -import java.util.*; +import java.util.Arrays; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; import java.util.stream.Collectors; diff --git a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java index 565a95051a8..cfad74119f3 100644 --- a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java +++ b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java @@ -44,7 +44,9 @@ import forge.game.trigger.Trigger; import forge.game.trigger.TriggerHandler; import forge.game.zone.ZoneType; -import forge.util.*; +import forge.util.Lang; +import forge.util.Localizer; +import forge.util.TextUtil; import io.sentry.Breadcrumb; import io.sentry.Sentry; import org.apache.commons.lang3.StringUtils; diff --git a/forge-game/src/main/java/forge/game/card/CardLists.java b/forge-game/src/main/java/forge/game/card/CardLists.java index 5c3536464a0..a4508f80d48 100644 --- a/forge-game/src/main/java/forge/game/card/CardLists.java +++ b/forge-game/src/main/java/forge/game/card/CardLists.java @@ -17,13 +17,7 @@ */ package forge.game.card; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.function.Predicate; - import com.google.common.collect.Lists; - import forge.game.CardTraitBase; import forge.game.keyword.Keyword; import forge.game.player.Player; @@ -34,6 +28,11 @@ import forge.util.MyRandom; import forge.util.collect.FCollectionView; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.function.Predicate; + /** *

* CardListUtil class. diff --git a/forge-game/src/main/java/forge/game/card/CardPlayOption.java b/forge-game/src/main/java/forge/game/card/CardPlayOption.java index ce7c527469d..5def9de68ef 100644 --- a/forge-game/src/main/java/forge/game/card/CardPlayOption.java +++ b/forge-game/src/main/java/forge/game/card/CardPlayOption.java @@ -1,13 +1,12 @@ package forge.game.card; -import org.apache.commons.lang3.StringUtils; - import forge.card.MagicColor; import forge.game.ability.AbilityUtils; import forge.game.cost.Cost; import forge.game.mana.ManaConversionMatrix; import forge.game.player.Player; import forge.game.staticability.StaticAbility; +import org.apache.commons.lang3.StringUtils; public final class CardPlayOption { public enum PayManaCost { diff --git a/forge-game/src/main/java/forge/game/card/CardPredicates.java b/forge-game/src/main/java/forge/game/card/CardPredicates.java index 4f37e6ee818..5396b69806e 100644 --- a/forge-game/src/main/java/forge/game/card/CardPredicates.java +++ b/forge-game/src/main/java/forge/game/card/CardPredicates.java @@ -17,9 +17,6 @@ */ package forge.game.card; -import java.util.Comparator; -import java.util.function.Predicate; - import forge.game.CardTraitBase; import forge.game.GameEntity; import forge.game.combat.CombatUtil; @@ -33,6 +30,9 @@ import forge.util.PredicateString; import forge.util.collect.FCollectionView; +import java.util.Comparator; +import java.util.function.Predicate; + /** *

diff --git a/forge-game/src/main/java/forge/game/card/CardProperty.java b/forge-game/src/main/java/forge/game/card/CardProperty.java index 96e5b600c6b..21640eb4f87 100644 --- a/forge-game/src/main/java/forge/game/card/CardProperty.java +++ b/forge-game/src/main/java/forge/game/card/CardProperty.java @@ -35,7 +35,10 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; -import java.util.*; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Set; public class CardProperty { diff --git a/forge-game/src/main/java/forge/game/card/CardState.java b/forge-game/src/main/java/forge/game/card/CardState.java index 8a0747f5a22..9947641d33a 100644 --- a/forge-game/src/main/java/forge/game/card/CardState.java +++ b/forge-game/src/main/java/forge/game/card/CardState.java @@ -17,20 +17,10 @@ */ package forge.game.card; -import java.util.Collection; -import java.util.Map; -import java.util.Set; - import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; - -import forge.card.CardEdition; -import forge.card.CardRarity; -import forge.card.CardStateName; -import forge.card.CardType; -import forge.card.CardTypeView; -import forge.card.MagicColor; +import forge.card.*; import forge.card.mana.ManaCost; import forge.game.CardTraitBase; import forge.game.ForgeScript; @@ -48,14 +38,18 @@ import forge.game.spellability.SpellPermanent; import forge.game.staticability.StaticAbility; import forge.game.trigger.Trigger; -import forge.util.IterableUtil; import forge.util.ITranslatable; +import forge.util.IterableUtil; import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; import io.sentry.Breadcrumb; import io.sentry.Sentry; import org.apache.commons.lang3.StringUtils; +import java.util.Collection; +import java.util.Map; +import java.util.Set; + public class CardState extends GameObject implements IHasSVars, ITranslatable { private String name = ""; private CardType type = new CardType(false); diff --git a/forge-game/src/main/java/forge/game/card/CardTraitChanges.java b/forge-game/src/main/java/forge/game/card/CardTraitChanges.java index 6228d3af8a8..be7020a39ab 100644 --- a/forge-game/src/main/java/forge/game/card/CardTraitChanges.java +++ b/forge-game/src/main/java/forge/game/card/CardTraitChanges.java @@ -1,15 +1,14 @@ package forge.game.card; -import java.util.Collection; -import java.util.List; - import com.google.common.collect.Lists; - import forge.game.replacement.ReplacementEffect; import forge.game.spellability.SpellAbility; import forge.game.staticability.StaticAbility; import forge.game.trigger.Trigger; +import java.util.Collection; +import java.util.List; + public class CardTraitChanges implements Cloneable { private List triggers = Lists.newArrayList(); diff --git a/forge-game/src/main/java/forge/game/card/CardUtil.java b/forge-game/src/main/java/forge/game/card/CardUtil.java index 0b542956b48..97fc376e0fc 100644 --- a/forge-game/src/main/java/forge/game/card/CardUtil.java +++ b/forge-game/src/main/java/forge/game/card/CardUtil.java @@ -17,14 +17,9 @@ */ package forge.game.card; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Sets; - import forge.ImageKeys; import forge.card.CardStateName; import forge.card.CardType; @@ -43,6 +38,10 @@ import forge.util.TextUtil; import forge.util.collect.FCollection; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + public final class CardUtil { // disable instantiation private CardUtil() { } diff --git a/forge-game/src/main/java/forge/game/card/CardZoneTable.java b/forge-game/src/main/java/forge/game/card/CardZoneTable.java index a2daf717bb7..6b1c73d2b0c 100644 --- a/forge-game/src/main/java/forge/game/card/CardZoneTable.java +++ b/forge-game/src/main/java/forge/game/card/CardZoneTable.java @@ -3,8 +3,6 @@ */ package forge.game.card; -import java.util.Map; - import com.google.common.collect.ForwardingTable; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Iterables; @@ -20,6 +18,8 @@ import forge.game.zone.ZoneType; import forge.util.IterableUtil; +import java.util.Map; + public class CardZoneTable extends ForwardingTable { // TODO use EnumBasedTable if exist private Table dataMap = HashBasedTable.create(); diff --git a/forge-game/src/main/java/forge/game/card/CounterEnumType.java b/forge-game/src/main/java/forge/game/card/CounterEnumType.java index 1a8645dedad..8a05b458d34 100644 --- a/forge-game/src/main/java/forge/game/card/CounterEnumType.java +++ b/forge-game/src/main/java/forge/game/card/CounterEnumType.java @@ -18,10 +18,10 @@ package forge.game.card; -import java.util.Locale; - import com.google.common.collect.ImmutableList; +import java.util.Locale; + /** * The class Counters. * diff --git a/forge-game/src/main/java/forge/game/card/CounterType.java b/forge-game/src/main/java/forge/game/card/CounterType.java index a1f7fd2f408..19acccf4add 100644 --- a/forge-game/src/main/java/forge/game/card/CounterType.java +++ b/forge-game/src/main/java/forge/game/card/CounterType.java @@ -1,15 +1,14 @@ package forge.game.card; -import java.io.Serializable; -import java.util.Map; -import java.util.Objects; - -import org.apache.commons.lang3.builder.EqualsBuilder; - import com.google.common.collect.ComparisonChain; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; import com.google.common.collect.Ordering; +import org.apache.commons.lang3.builder.EqualsBuilder; + +import java.io.Serializable; +import java.util.Map; +import java.util.Objects; public class CounterType implements Comparable, Serializable { private static final long serialVersionUID = -7575835723159144478L; diff --git a/forge-game/src/main/java/forge/game/card/TokenCreateTable.java b/forge-game/src/main/java/forge/game/card/TokenCreateTable.java index e4f4b04b51b..64b84ff5981 100644 --- a/forge-game/src/main/java/forge/game/card/TokenCreateTable.java +++ b/forge-game/src/main/java/forge/game/card/TokenCreateTable.java @@ -1,20 +1,18 @@ package forge.game.card; -import java.util.List; -import java.util.Map; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import forge.game.GameObject; -import org.apache.commons.lang3.ObjectUtils; - import com.google.common.collect.ForwardingTable; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Table; - import forge.game.CardTraitBase; +import forge.game.GameObject; import forge.game.GameObjectPredicates; import forge.game.player.Player; +import org.apache.commons.lang3.ObjectUtils; + +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; +import java.util.stream.Collectors; public class TokenCreateTable extends ForwardingTable { diff --git a/forge-game/src/main/java/forge/game/card/token/TokenInfo.java b/forge-game/src/main/java/forge/game/card/token/TokenInfo.java index 07b142edb66..2fe3b0d888c 100644 --- a/forge-game/src/main/java/forge/game/card/token/TokenInfo.java +++ b/forge-game/src/main/java/forge/game/card/token/TokenInfo.java @@ -1,19 +1,12 @@ package forge.game.card.token; -import java.util.List; -import java.util.Map; - -import com.google.common.collect.Iterables; -import forge.card.GamePieceType; -import org.apache.commons.lang3.ObjectUtils; -import org.apache.commons.lang3.StringUtils; - import com.google.common.base.Joiner; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; - import forge.ImageKeys; import forge.StaticData; import forge.card.CardType; +import forge.card.GamePieceType; import forge.card.MagicColor; import forge.game.Game; import forge.game.ability.AbilityUtils; @@ -25,6 +18,11 @@ import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.item.PaperToken; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; +import java.util.Map; public class TokenInfo { final String name; diff --git a/forge-game/src/main/java/forge/game/cost/Cost.java b/forge-game/src/main/java/forge/game/cost/Cost.java index 1c3aad763aa..bdb3c494f03 100644 --- a/forge-game/src/main/java/forge/game/cost/Cost.java +++ b/forge-game/src/main/java/forge/game/cost/Cost.java @@ -35,7 +35,9 @@ import org.apache.commons.lang3.StringUtils; import java.io.Serializable; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; /** *

diff --git a/forge-game/src/main/java/forge/game/cost/CostAddMana.java b/forge-game/src/main/java/forge/game/cost/CostAddMana.java index 8f644205782..40f16cc6d22 100644 --- a/forge-game/src/main/java/forge/game/cost/CostAddMana.java +++ b/forge-game/src/main/java/forge/game/cost/CostAddMana.java @@ -17,16 +17,15 @@ */ package forge.game.cost; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; - import forge.card.mana.ManaAtom; import forge.game.card.Card; import forge.game.mana.Mana; import forge.game.player.Player; import forge.game.spellability.SpellAbility; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; /** * The Class CostAddMana. diff --git a/forge-game/src/main/java/forge/game/cost/CostAdjustment.java b/forge-game/src/main/java/forge/game/cost/CostAdjustment.java index 7542f2fdc52..c667c0812f0 100644 --- a/forge-game/src/main/java/forge/game/cost/CostAdjustment.java +++ b/forge-game/src/main/java/forge/game/cost/CostAdjustment.java @@ -1,17 +1,7 @@ package forge.game.cost; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import forge.game.player.PlayerCollection; -import forge.game.ability.AbilityKey; -import forge.game.trigger.TriggerType; -import org.apache.commons.lang3.StringUtils; - import com.google.common.base.Strings; import com.google.common.collect.Lists; - import forge.card.CardStateName; import forge.card.mana.ManaAtom; import forge.card.mana.ManaCost; @@ -19,25 +9,27 @@ import forge.card.mana.ManaCostShard; import forge.game.Game; import forge.game.GameObject; +import forge.game.ability.AbilityKey; import forge.game.ability.AbilityUtils; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; -import forge.game.card.CardUtil; -import forge.game.card.CardZoneTable; +import forge.game.card.*; import forge.game.keyword.Keyword; import forge.game.keyword.KeywordInterface; import forge.game.mana.ManaCostBeingPaid; import forge.game.player.Player; +import forge.game.player.PlayerCollection; import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbilityPredicates; import forge.game.spellability.TargetChoices; import forge.game.staticability.StaticAbility; +import forge.game.trigger.TriggerType; import forge.game.zone.Zone; import forge.game.zone.ZoneType; import forge.util.Localizer; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; public class CostAdjustment { diff --git a/forge-game/src/main/java/forge/game/cost/CostCollectEvidence.java b/forge-game/src/main/java/forge/game/cost/CostCollectEvidence.java index 96ccc36853d..feadeb2f22e 100644 --- a/forge-game/src/main/java/forge/game/cost/CostCollectEvidence.java +++ b/forge-game/src/main/java/forge/game/cost/CostCollectEvidence.java @@ -3,11 +3,7 @@ import forge.game.Game; import forge.game.ability.AbilityKey; import forge.game.ability.SpellAbilityEffect; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; +import forge.game.card.*; import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.trigger.TriggerType; diff --git a/forge-game/src/main/java/forge/game/cost/CostDiscard.java b/forge-game/src/main/java/forge/game/cost/CostDiscard.java index 1e94d38f550..e89a8213419 100644 --- a/forge-game/src/main/java/forge/game/cost/CostDiscard.java +++ b/forge-game/src/main/java/forge/game/cost/CostDiscard.java @@ -17,25 +17,20 @@ */ package forge.game.cost; -import java.util.List; -import java.util.Map; -import java.util.Set; - import com.google.common.collect.Lists; import com.google.common.collect.Sets; - import forge.game.ability.AbilityKey; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; +import forge.game.card.*; import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; import forge.util.TextUtil; +import java.util.List; +import java.util.Map; +import java.util.Set; + /** * The Class CostDiscard. */ diff --git a/forge-game/src/main/java/forge/game/cost/CostDraw.java b/forge-game/src/main/java/forge/game/cost/CostDraw.java index 0028bf9859d..563ecbdf450 100644 --- a/forge-game/src/main/java/forge/game/cost/CostDraw.java +++ b/forge-game/src/main/java/forge/game/cost/CostDraw.java @@ -17,8 +17,6 @@ */ package forge.game.cost; -import java.util.Map; - import forge.game.Game; import forge.game.ability.AbilityKey; import forge.game.card.Card; @@ -26,6 +24,8 @@ import forge.game.player.PlayerCollection; import forge.game.spellability.SpellAbility; +import java.util.Map; + /** * The Class CostDraw. */ diff --git a/forge-game/src/main/java/forge/game/cost/CostEnlist.java b/forge-game/src/main/java/forge/game/cost/CostEnlist.java index 2fdb647a782..806846d7e17 100644 --- a/forge-game/src/main/java/forge/game/cost/CostEnlist.java +++ b/forge-game/src/main/java/forge/game/cost/CostEnlist.java @@ -17,8 +17,6 @@ */ package forge.game.cost; -import java.util.Map; - import forge.game.ability.AbilityKey; import forge.game.card.Card; import forge.game.card.CardCollection; @@ -27,6 +25,8 @@ import forge.game.spellability.SpellAbility; import forge.game.trigger.TriggerType; +import java.util.Map; + /** * The Class CostExert. */ diff --git a/forge-game/src/main/java/forge/game/cost/CostExileFromStack.java b/forge-game/src/main/java/forge/game/cost/CostExileFromStack.java index c4e21caf932..dee21cd4354 100644 --- a/forge-game/src/main/java/forge/game/cost/CostExileFromStack.java +++ b/forge-game/src/main/java/forge/game/cost/CostExileFromStack.java @@ -17,8 +17,6 @@ */ package forge.game.cost; -import java.util.Map; - import forge.game.Game; import forge.game.ability.AbilityKey; import forge.game.ability.SpellAbilityEffect; @@ -28,6 +26,8 @@ import forge.game.spellability.SpellAbilityStackInstance; import forge.game.zone.ZoneType; +import java.util.Map; + /** * The Class CostExile. */ diff --git a/forge-game/src/main/java/forge/game/cost/CostExiledMoveToGrave.java b/forge-game/src/main/java/forge/game/cost/CostExiledMoveToGrave.java index 5eaf8446340..75590ecf7e4 100644 --- a/forge-game/src/main/java/forge/game/cost/CostExiledMoveToGrave.java +++ b/forge-game/src/main/java/forge/game/cost/CostExiledMoveToGrave.java @@ -17,8 +17,6 @@ */ package forge.game.cost; -import java.util.Map; - import forge.game.ability.AbilityKey; import forge.game.card.Card; import forge.game.card.CardCollectionView; @@ -27,6 +25,8 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Map; + /** * This is for the "ExiledMoveToGrave" Cost. */ diff --git a/forge-game/src/main/java/forge/game/cost/CostForage.java b/forge-game/src/main/java/forge/game/cost/CostForage.java index af2130a0e82..28d73847ff7 100644 --- a/forge-game/src/main/java/forge/game/cost/CostForage.java +++ b/forge-game/src/main/java/forge/game/cost/CostForage.java @@ -1,20 +1,16 @@ package forge.game.cost; -import java.util.Map; - import forge.game.Game; import forge.game.ability.AbilityKey; import forge.game.ability.SpellAbilityEffect; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; +import forge.game.card.*; import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.trigger.TriggerType; import forge.game.zone.ZoneType; +import java.util.Map; + public class CostForage extends CostPartWithList { private static final long serialVersionUID = 1L; diff --git a/forge-game/src/main/java/forge/game/cost/CostGainLife.java b/forge-game/src/main/java/forge/game/cost/CostGainLife.java index 627ef417fac..34626114746 100644 --- a/forge-game/src/main/java/forge/game/cost/CostGainLife.java +++ b/forge-game/src/main/java/forge/game/cost/CostGainLife.java @@ -17,13 +17,12 @@ */ package forge.game.cost; -import java.util.List; - import com.google.common.collect.Lists; - import forge.game.player.Player; import forge.game.spellability.SpellAbility; +import java.util.List; + /** * The Class CostGainLife. */ diff --git a/forge-game/src/main/java/forge/game/cost/CostMill.java b/forge-game/src/main/java/forge/game/cost/CostMill.java index 36c377dd8d4..d021e4d6a2f 100644 --- a/forge-game/src/main/java/forge/game/cost/CostMill.java +++ b/forge-game/src/main/java/forge/game/cost/CostMill.java @@ -17,8 +17,6 @@ */ package forge.game.cost; -import java.util.Map; - import forge.game.Game; import forge.game.ability.AbilityKey; import forge.game.card.CardZoneTable; @@ -27,6 +25,8 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Map; + /** * This is for the "Mill" Cost. Putting cards from the top of your library into * your graveyard as a cost. This Cost doesn't appear on very many cards, but diff --git a/forge-game/src/main/java/forge/game/cost/CostPart.java b/forge-game/src/main/java/forge/game/cost/CostPart.java index 776fe634781..a4972731f87 100644 --- a/forge-game/src/main/java/forge/game/cost/CostPart.java +++ b/forge-game/src/main/java/forge/game/cost/CostPart.java @@ -17,16 +17,15 @@ */ package forge.game.cost; -import java.io.Serializable; - import forge.card.CardType; -import org.apache.commons.lang3.StringUtils; - import forge.game.CardTraitBase; import forge.game.ability.AbilityUtils; import forge.game.card.Card; import forge.game.player.Player; import forge.game.spellability.SpellAbility; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; /** * The Class CostPart. diff --git a/forge-game/src/main/java/forge/game/cost/CostPartWithTrigger.java b/forge-game/src/main/java/forge/game/cost/CostPartWithTrigger.java index e8a4aeae435..916f0889953 100644 --- a/forge-game/src/main/java/forge/game/cost/CostPartWithTrigger.java +++ b/forge-game/src/main/java/forge/game/cost/CostPartWithTrigger.java @@ -1,9 +1,6 @@ package forge.game.cost; -import java.util.Map; - import com.google.common.collect.Maps; - import forge.game.card.Card; import forge.game.card.CardCollectionView; import forge.game.player.Player; @@ -12,6 +9,8 @@ import forge.game.trigger.TriggerHandler; import forge.game.trigger.TriggerType; +import java.util.Map; + public abstract class CostPartWithTrigger extends CostPartWithList { /** * Serializables need a version ID. diff --git a/forge-game/src/main/java/forge/game/cost/CostPayEnergy.java b/forge-game/src/main/java/forge/game/cost/CostPayEnergy.java index 74ce867df36..f4c50b2f2b4 100644 --- a/forge-game/src/main/java/forge/game/cost/CostPayEnergy.java +++ b/forge-game/src/main/java/forge/game/cost/CostPayEnergy.java @@ -18,7 +18,6 @@ package forge.game.cost; import com.google.common.base.Strings; - import forge.game.card.Card; import forge.game.card.CounterEnumType; import forge.game.player.Player; diff --git a/forge-game/src/main/java/forge/game/cost/CostPayment.java b/forge-game/src/main/java/forge/game/cost/CostPayment.java index 7c4ebf3fd2f..997487800f0 100644 --- a/forge-game/src/main/java/forge/game/cost/CostPayment.java +++ b/forge-game/src/main/java/forge/game/cost/CostPayment.java @@ -17,16 +17,8 @@ */ package forge.game.cost; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import forge.game.mana.*; -import org.apache.commons.lang3.tuple.Pair; - import com.google.common.collect.Lists; import com.google.common.collect.Maps; - import forge.card.MagicColor; import forge.card.mana.ManaCostShard; import forge.game.Game; @@ -34,8 +26,14 @@ import forge.game.card.Card; import forge.game.card.CardCollection; import forge.game.card.CardZoneTable; +import forge.game.mana.*; import forge.game.player.Player; import forge.game.spellability.SpellAbility; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; /** *

diff --git a/forge-game/src/main/java/forge/game/cost/CostPutCardToLib.java b/forge-game/src/main/java/forge/game/cost/CostPutCardToLib.java index 5b92acc8642..e511ea3e78c 100644 --- a/forge-game/src/main/java/forge/game/cost/CostPutCardToLib.java +++ b/forge-game/src/main/java/forge/game/cost/CostPutCardToLib.java @@ -17,8 +17,6 @@ */ package forge.game.cost; -import java.util.Map; - import forge.game.Game; import forge.game.ability.AbilityKey; import forge.game.card.Card; @@ -30,6 +28,8 @@ import forge.game.zone.ZoneType; import forge.util.collect.FCollectionView; +import java.util.Map; + /** * This is for the "PutCardToLib" Cost. */ diff --git a/forge-game/src/main/java/forge/game/cost/CostPutCounter.java b/forge-game/src/main/java/forge/game/cost/CostPutCounter.java index 99efbf65b62..b75f941d35d 100644 --- a/forge-game/src/main/java/forge/game/cost/CostPutCounter.java +++ b/forge-game/src/main/java/forge/game/cost/CostPutCounter.java @@ -17,10 +17,7 @@ */ package forge.game.cost; -import java.util.List; - import com.google.common.collect.Sets; - import forge.game.Game; import forge.game.GameEntityCounterTable; import forge.game.ability.AbilityKey; @@ -31,6 +28,8 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.List; + /** * The Class CostPutCounter. */ diff --git a/forge-game/src/main/java/forge/game/cost/CostRemoveAnyCounter.java b/forge-game/src/main/java/forge/game/cost/CostRemoveAnyCounter.java index 6ce057e4a98..f3029a574ea 100644 --- a/forge-game/src/main/java/forge/game/cost/CostRemoveAnyCounter.java +++ b/forge-game/src/main/java/forge/game/cost/CostRemoveAnyCounter.java @@ -17,10 +17,6 @@ */ package forge.game.cost; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Optional; - import forge.game.GameEntity; import forge.game.ability.AbilityUtils; import forge.game.card.Card; @@ -31,6 +27,10 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; + /** * The Class CostRemoveAnyCounter. */ diff --git a/forge-game/src/main/java/forge/game/cost/CostRemoveCounter.java b/forge-game/src/main/java/forge/game/cost/CostRemoveCounter.java index 36e2453670a..8a199a3f196 100644 --- a/forge-game/src/main/java/forge/game/cost/CostRemoveCounter.java +++ b/forge-game/src/main/java/forge/game/cost/CostRemoveCounter.java @@ -17,10 +17,7 @@ */ package forge.game.cost; -import java.util.List; - import com.google.common.collect.Lists; - import forge.game.card.Card; import forge.game.card.CardLists; import forge.game.card.CounterEnumType; @@ -30,6 +27,8 @@ import forge.game.zone.ZoneType; import forge.util.Lang; +import java.util.List; + /** * The Class CostRemoveCounter. */ diff --git a/forge-game/src/main/java/forge/game/cost/CostReturn.java b/forge-game/src/main/java/forge/game/cost/CostReturn.java index 457d9096d03..a30be724092 100644 --- a/forge-game/src/main/java/forge/game/cost/CostReturn.java +++ b/forge-game/src/main/java/forge/game/cost/CostReturn.java @@ -17,8 +17,6 @@ */ package forge.game.cost; -import java.util.Map; - import forge.game.ability.AbilityKey; import forge.game.card.Card; import forge.game.card.CardCollectionView; @@ -27,6 +25,8 @@ import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Map; + /** * The Class CostReturn. */ diff --git a/forge-game/src/main/java/forge/game/cost/CostReveal.java b/forge-game/src/main/java/forge/game/cost/CostReveal.java index 2cd67ffaa10..ff88e85980e 100644 --- a/forge-game/src/main/java/forge/game/cost/CostReveal.java +++ b/forge-game/src/main/java/forge/game/cost/CostReveal.java @@ -17,19 +17,15 @@ */ package forge.game.cost; -import java.util.Arrays; -import java.util.List; - import forge.game.GameLogEntryType; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; +import forge.game.card.*; import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Arrays; +import java.util.List; + /** * The Class CostReveal. */ diff --git a/forge-game/src/main/java/forge/game/cost/CostSacrifice.java b/forge-game/src/main/java/forge/game/cost/CostSacrifice.java index 43abf19a5cc..323b6242885 100644 --- a/forge-game/src/main/java/forge/game/cost/CostSacrifice.java +++ b/forge-game/src/main/java/forge/game/cost/CostSacrifice.java @@ -17,13 +17,8 @@ */ package forge.game.cost; -import forge.card.CardType; - -import java.util.Map; -import java.util.Set; - import com.google.common.collect.Sets; - +import forge.card.CardType; import forge.game.Game; import forge.game.ability.AbilityKey; import forge.game.card.Card; @@ -35,6 +30,9 @@ import forge.game.zone.ZoneType; import forge.util.Lang; +import java.util.Map; +import java.util.Set; + /** * The Class CostSacrifice. */ diff --git a/forge-game/src/main/java/forge/game/cost/CostUnattach.java b/forge-game/src/main/java/forge/game/cost/CostUnattach.java index f4d6739f6fd..bbde2c7df1a 100644 --- a/forge-game/src/main/java/forge/game/cost/CostUnattach.java +++ b/forge-game/src/main/java/forge/game/cost/CostUnattach.java @@ -17,14 +17,14 @@ */ package forge.game.cost; -import java.util.List; - import forge.game.card.Card; import forge.game.card.CardLists; import forge.game.player.Player; import forge.game.spellability.SpellAbility; import forge.util.TextUtil; +import java.util.List; + /** * The Class CostUnattach. */ diff --git a/forge-game/src/main/java/forge/game/cost/PaymentDecision.java b/forge-game/src/main/java/forge/game/cost/PaymentDecision.java index f5560b92b54..b33777d3df4 100644 --- a/forge-game/src/main/java/forge/game/cost/PaymentDecision.java +++ b/forge-game/src/main/java/forge/game/cost/PaymentDecision.java @@ -1,7 +1,5 @@ package forge.game.cost; -import java.util.List; - import forge.game.GameEntityCounterTable; import forge.game.card.Card; import forge.game.card.CardCollection; @@ -11,6 +9,8 @@ import forge.game.spellability.SpellAbility; import forge.util.TextUtil; +import java.util.List; + public class PaymentDecision { public int c = 0; public String type; diff --git a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java index 47657b7b42f..727ef9231be 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java +++ b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java @@ -17,27 +17,21 @@ */ package forge.game.mana; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.function.Predicate; - import com.google.common.collect.Iterables; -import forge.util.IterableUtil; -import org.apache.commons.lang3.StringUtils; - import com.google.common.collect.Lists; import com.google.common.collect.Maps; - import forge.card.ColorSet; import forge.card.MagicColor; import forge.card.mana.IParserManaCost; import forge.card.mana.ManaAtom; import forge.card.mana.ManaCost; import forge.card.mana.ManaCostShard; +import forge.util.IterableUtil; +import org.apache.commons.lang3.StringUtils; + +import java.util.*; +import java.util.Map.Entry; +import java.util.function.Predicate; /** *

diff --git a/forge-game/src/main/java/forge/game/mana/ManaPool.java b/forge-game/src/main/java/forge/game/mana/ManaPool.java index a9e7483e414..2f5eadd4cc6 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaPool.java +++ b/forge-game/src/main/java/forge/game/mana/ManaPool.java @@ -17,15 +17,8 @@ */ package forge.game.mana; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Lists; - import forge.card.mana.ManaAtom; import forge.card.mana.ManaCostShard; import forge.game.Game; @@ -41,6 +34,8 @@ import forge.game.spellability.SpellAbility; import forge.game.staticability.StaticAbilityUnspentMana; +import java.util.*; + /** *

* ManaPool class. diff --git a/forge-gui/src/main/java/forge/deck/ArchetypeDeckGenerator.java b/forge-gui/src/main/java/forge/deck/ArchetypeDeckGenerator.java index 8d60d7fdb09..2a3ccab0bb9 100644 --- a/forge-gui/src/main/java/forge/deck/ArchetypeDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/ArchetypeDeckGenerator.java @@ -1,15 +1,14 @@ package forge.deck; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.tuple.Pair; - import forge.card.CardEdition; import forge.deck.io.Archetype; import forge.game.GameFormat; import forge.item.PaperCard; import forge.model.FModel; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.ArrayList; +import java.util.List; /** * Created by maustin on 09/05/2017. diff --git a/forge-gui/src/main/java/forge/deck/CardArchetypeLDAGenerator.java b/forge-gui/src/main/java/forge/deck/CardArchetypeLDAGenerator.java index cf6a2679b1c..c5ee008a8e4 100644 --- a/forge-gui/src/main/java/forge/deck/CardArchetypeLDAGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardArchetypeLDAGenerator.java @@ -1,18 +1,12 @@ package forge.deck; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.lang3.tuple.Pair; - import forge.StaticData; import forge.deck.io.Archetype; import forge.deck.io.CardThemedLDAIO; import forge.model.FModel; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.*; /** * Created by maustin on 09/05/2017. diff --git a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java index e4fdf6dac9d..a32f1a21bf7 100644 --- a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java @@ -1,27 +1,19 @@ package forge.deck; -import java.io.File; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import forge.item.PaperCardPredicates; -import org.apache.commons.lang3.ArrayUtils; - import forge.deck.io.CardThemedMatrixIO; import forge.deck.io.DeckStorage; import forge.game.GameFormat; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.localinstance.properties.ForgeConstants; import forge.model.FModel; import forge.util.storage.IStorage; import forge.util.storage.StorageImmediatelySerialized; +import org.apache.commons.lang3.ArrayUtils; + +import java.io.File; +import java.util.*; +import java.util.stream.Collectors; /** * Created by maustin on 09/05/2017. diff --git a/forge-gui/src/main/java/forge/deck/CardThemedDeckGenerator.java b/forge-gui/src/main/java/forge/deck/CardThemedDeckGenerator.java index 00c1e8a4e84..a8fee1c7369 100644 --- a/forge-gui/src/main/java/forge/deck/CardThemedDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardThemedDeckGenerator.java @@ -1,13 +1,13 @@ package forge.deck; -import java.util.ArrayList; -import java.util.List; - import forge.card.CardEdition; import forge.game.GameFormat; import forge.item.PaperCard; import forge.model.FModel; +import java.util.ArrayList; +import java.util.List; + /** * Created by maustin on 09/05/2017. */ diff --git a/forge-gui/src/main/java/forge/deck/ColorDeckGenerator.java b/forge-gui/src/main/java/forge/deck/ColorDeckGenerator.java index 655609306d1..c3c8f653937 100644 --- a/forge-gui/src/main/java/forge/deck/ColorDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/ColorDeckGenerator.java @@ -1,13 +1,13 @@ package forge.deck; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Predicate; - import forge.card.CardEdition; import forge.item.PaperCard; import forge.itemmanager.IItemManager; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Predicate; + public class ColorDeckGenerator extends DeckProxy implements Comparable { public static List getColorDecks(final IItemManager lstDecks0, final Predicate formatFilter0, final boolean isAi0) { final String[] colors = new String[] { "Random 1", "Random 2", "Random 3", diff --git a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java index 2a53a6d0ae8..793921ceb60 100644 --- a/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CommanderDeckGenerator.java @@ -1,11 +1,5 @@ package forge.deck; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Predicate; -import java.util.stream.Collectors; - import forge.card.CardEdition; import forge.card.CardRules; import forge.card.CardRulesPredicates; @@ -15,6 +9,12 @@ import forge.model.FModel; import forge.util.ItemPool; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; +import java.util.stream.Collectors; + /** * Created by maustin on 09/05/2017. */ diff --git a/forge-gui/src/main/java/forge/deck/DeckGeneratorTheme.java b/forge-gui/src/main/java/forge/deck/DeckGeneratorTheme.java index 8ae9629b6ed..a9ce3e2bc4d 100644 --- a/forge-gui/src/main/java/forge/deck/DeckGeneratorTheme.java +++ b/forge-gui/src/main/java/forge/deck/DeckGeneratorTheme.java @@ -17,16 +17,16 @@ */ package forge.deck; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - import forge.deck.generation.DeckGeneratorBase; import forge.deck.generation.IDeckGenPool; import forge.localinstance.properties.ForgeConstants; import forge.util.FileUtil; import forge.util.MyRandom; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + /** *

* ThemeDeckGenerator class. diff --git a/forge-gui/src/main/java/forge/deck/DeckImportController.java b/forge-gui/src/main/java/forge/deck/DeckImportController.java index 511abab4469..8ba686c67ce 100644 --- a/forge-gui/src/main/java/forge/deck/DeckImportController.java +++ b/forge-gui/src/main/java/forge/deck/DeckImportController.java @@ -1,26 +1,25 @@ package forge.deck; -import java.text.DateFormatSymbols; -import java.util.*; - import forge.StaticData; import forge.card.CardDb; import forge.card.CardEdition; +import forge.deck.DeckRecognizer.Token; import forge.deck.DeckRecognizer.TokenType; import forge.game.GameFormat; import forge.game.GameType; -import forge.deck.DeckRecognizer.Token; -import forge.localinstance.properties.ForgePreferences; -import forge.model.FModel; -import org.apache.commons.lang3.StringUtils; - import forge.gui.interfaces.ICheckBox; import forge.gui.interfaces.IComboBox; import forge.gui.util.SOptionPane; import forge.item.PaperCard; +import forge.localinstance.properties.ForgePreferences; +import forge.model.FModel; import forge.util.Localizer; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; +import java.text.DateFormatSymbols; +import java.util.*; + public class DeckImportController { private boolean createNewDeck; // Date filter diff --git a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java index 6ff02d999bd..a626b8e49cf 100644 --- a/forge-gui/src/main/java/forge/deck/DeckgenUtil.java +++ b/forge-gui/src/main/java/forge/deck/DeckgenUtil.java @@ -1,21 +1,6 @@ package forge.deck; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Predicate; - -import forge.item.PaperCardPredicates; -import forge.util.*; -import org.apache.commons.lang3.tuple.Pair; - import com.google.common.collect.Lists; - import forge.StaticData; import forge.card.CardDb; import forge.card.CardRules; @@ -23,12 +8,7 @@ import forge.card.ColorSet; import forge.card.mana.ManaCost; import forge.card.mana.ManaCostShard; -import forge.deck.generation.DeckGenerator2Color; -import forge.deck.generation.DeckGenerator3Color; -import forge.deck.generation.DeckGenerator5Color; -import forge.deck.generation.DeckGeneratorBase; -import forge.deck.generation.DeckGeneratorMonoColor; -import forge.deck.generation.IDeckGenPool; +import forge.deck.generation.*; import forge.deck.io.Archetype; import forge.game.GameFormat; import forge.game.GameType; @@ -42,10 +22,16 @@ import forge.gamemodes.quest.QuestEventDuel; import forge.gui.util.SOptionPane; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.itemmanager.IItemManager; import forge.localinstance.properties.ForgePreferences.FPref; import forge.model.FModel; +import forge.util.*; import forge.util.storage.IStorage; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.*; +import java.util.function.Predicate; /** * Utility collection for various types of decks. diff --git a/forge-gui/src/main/java/forge/deck/NetDeckCategory.java b/forge-gui/src/main/java/forge/deck/NetDeckCategory.java index d455ec4442b..a43d38c63ac 100644 --- a/forge-gui/src/main/java/forge/deck/NetDeckCategory.java +++ b/forge-gui/src/main/java/forge/deck/NetDeckCategory.java @@ -11,8 +11,13 @@ import forge.util.WaitCallback; import forge.util.storage.StorageBase; -import java.io.*; -import java.util.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; public class NetDeckCategory extends StorageBase { public static final String PREFIX = "NET_DECK_"; diff --git a/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java b/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java index aa21438e909..9be684b929c 100644 --- a/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java +++ b/forge-gui/src/main/java/forge/deck/RandomDeckGenerator.java @@ -1,8 +1,5 @@ package forge.deck; -import java.util.ArrayList; -import java.util.List; - import com.google.common.collect.Iterables; import forge.game.GameFormat; import forge.game.GameType; @@ -12,6 +9,9 @@ import forge.util.Aggregates; import forge.util.IterableUtil; +import java.util.ArrayList; +import java.util.List; + public class RandomDeckGenerator extends DeckProxy implements Comparable { private enum RandomDeckType { Generated, diff --git a/forge-gui/src/main/java/forge/deck/io/Archetype.java b/forge-gui/src/main/java/forge/deck/io/Archetype.java index 4f3bea8e0d6..9d0c575d0f3 100644 --- a/forge-gui/src/main/java/forge/deck/io/Archetype.java +++ b/forge-gui/src/main/java/forge/deck/io/Archetype.java @@ -1,11 +1,11 @@ package forge.deck.io; +import org.apache.commons.lang3.tuple.Pair; + import java.io.Serializable; import java.util.List; -import org.apache.commons.lang3.tuple.Pair; - public class Archetype implements Serializable { static final long serialVersionUID = 1733769383530140352L; diff --git a/forge-gui/src/main/java/forge/deck/io/CardThemedMatrixIO.java b/forge-gui/src/main/java/forge/deck/io/CardThemedMatrixIO.java index 1c5cff0bf84..08da50a103a 100644 --- a/forge-gui/src/main/java/forge/deck/io/CardThemedMatrixIO.java +++ b/forge-gui/src/main/java/forge/deck/io/CardThemedMatrixIO.java @@ -1,19 +1,14 @@ package forge.deck.io; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import forge.game.GameFormat; import forge.item.PaperCard; import forge.localinstance.properties.ForgeConstants; +import java.io.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * Created by maustin on 11/05/2017. */ diff --git a/forge-gui/src/main/java/forge/deck/io/DeckPreferences.java b/forge-gui/src/main/java/forge/deck/io/DeckPreferences.java index 64da675dc60..ce6aaafff22 100644 --- a/forge-gui/src/main/java/forge/deck/io/DeckPreferences.java +++ b/forge-gui/src/main/java/forge/deck/io/DeckPreferences.java @@ -1,21 +1,19 @@ package forge.deck.io; -import java.io.File; -import java.io.FileNotFoundException; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - import forge.deck.DeckProxy; import forge.deck.DeckType; import forge.localinstance.properties.ForgeConstants; import forge.util.XmlUtil; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.File; +import java.io.FileNotFoundException; +import java.util.HashMap; +import java.util.Map; /** * Preferences associated with individual decks diff --git a/forge-gui/src/main/java/forge/deck/io/DeckRecords.java b/forge-gui/src/main/java/forge/deck/io/DeckRecords.java index 3588662674b..00c007de1d9 100644 --- a/forge-gui/src/main/java/forge/deck/io/DeckRecords.java +++ b/forge-gui/src/main/java/forge/deck/io/DeckRecords.java @@ -1,17 +1,13 @@ package forge.deck.io; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import forge.LobbyPlayer; import forge.ai.LobbyPlayerAi; import forge.game.GameOutcome; import forge.game.Match; import forge.game.player.RegisteredPlayer; +import java.util.*; + @SuppressWarnings("unused") public class DeckRecords { private static final Map recordLookup = new HashMap<>(); diff --git a/forge-gui/src/main/java/forge/download/AutoUpdater.java b/forge-gui/src/main/java/forge/download/AutoUpdater.java index 73907ab5379..1e624445a4a 100644 --- a/forge-gui/src/main/java/forge/download/AutoUpdater.java +++ b/forge-gui/src/main/java/forge/download/AutoUpdater.java @@ -1,24 +1,6 @@ package forge.download; -import java.awt.Desktop; -import java.io.File; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.MalformedURLException; -import java.net.Socket; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.swing.SwingUtilities; - -import org.apache.commons.lang3.StringUtils; - import com.google.common.collect.ImmutableList; - import forge.gui.GuiBase; import forge.gui.download.GuiDownloadZipService; import forge.gui.util.SOptionPane; @@ -28,6 +10,16 @@ import forge.util.FileUtil; import forge.util.Localizer; import forge.util.WaitCallback; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; +import java.io.File; +import java.io.IOException; +import java.net.*; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class AutoUpdater { private final String SNAPSHOT_VERSION_INDEX = "https://downloads.cardforge.org/dailysnapshots/"; diff --git a/forge-gui/src/main/java/forge/error/ExceptionHandler.java b/forge-gui/src/main/java/forge/error/ExceptionHandler.java index 57802b34c31..707380f2a54 100644 --- a/forge-gui/src/main/java/forge/error/ExceptionHandler.java +++ b/forge-gui/src/main/java/forge/error/ExceptionHandler.java @@ -18,21 +18,15 @@ package forge.error; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; -import java.lang.Thread.UncaughtExceptionHandler; - import com.esotericsoftware.minlog.Log; - import forge.FTrace; import forge.gui.error.BugReporter; import forge.localinstance.properties.ForgeConstants; import forge.util.MultiplexOutputStream; +import java.io.*; +import java.lang.Thread.UncaughtExceptionHandler; + /** * This class handles all exceptions that weren't caught by showing the error to * the user. diff --git a/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java b/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java index e8cda84e416..626c6909eb9 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java @@ -1,19 +1,6 @@ package forge.gamemodes.match; -import java.io.Serializable; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; - import com.google.common.collect.*; -import forge.gui.control.PlaybackSpeed; -import forge.trackable.TrackableCollection; -import org.apache.commons.lang3.StringUtils; - import forge.game.GameView; import forge.game.card.Card; import forge.game.card.CardView; @@ -23,6 +10,7 @@ import forge.game.player.PlayerView; import forge.gui.FThreads; import forge.gui.GuiBase; +import forge.gui.control.PlaybackSpeed; import forge.gui.interfaces.IGuiGame; import forge.gui.interfaces.IMayViewCards; import forge.interfaces.IGameController; @@ -31,8 +19,13 @@ import forge.localinstance.skin.FSkinProp; import forge.model.FModel; import forge.player.PlayerControllerHuman; +import forge.trackable.TrackableCollection; import forge.trackable.TrackableTypes; import forge.util.Localizer; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; +import java.util.*; public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards { private PlayerView currentPlayer = null; diff --git a/forge-gui/src/main/java/forge/gamemodes/match/GameLobby.java b/forge-gui/src/main/java/forge/gamemodes/match/GameLobby.java index c92bc865263..dd89c1150a9 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/GameLobby.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/GameLobby.java @@ -1,20 +1,8 @@ package forge.gamemodes.match; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.lang3.StringUtils; - import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.primitives.Ints; - import forge.LobbyPlayer; import forge.ai.AIOption; import forge.deck.CardPool; @@ -38,6 +26,10 @@ import forge.player.GamePlayerUtil; import forge.util.Localizer; import forge.util.NameGenerator; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; +import java.util.*; public abstract class GameLobby implements IHasGameType { private final static int MAX_PLAYERS = 8; diff --git a/forge-gui/src/main/java/forge/gamemodes/match/HostedMatch.java b/forge-gui/src/main/java/forge/gamemodes/match/HostedMatch.java index 98249ea73f8..60b28c1d3c3 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/HostedMatch.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/HostedMatch.java @@ -1,24 +1,13 @@ package forge.gamemodes.match; -import java.util.*; -import java.util.Map.Entry; - -import forge.ai.AiProfileUtil; -import forge.gui.control.PlaybackSpeed; -import org.apache.commons.lang3.StringUtils; - import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.eventbus.Subscribe; - import forge.LobbyPlayer; import forge.StaticData; -import forge.game.Game; -import forge.game.GameRules; -import forge.game.GameType; -import forge.game.GameView; -import forge.game.Match; +import forge.ai.AiProfileUtil; +import forge.game.*; import forge.game.event.GameEvent; import forge.game.event.GameEventSubgameEnd; import forge.game.event.GameEventSubgameStart; @@ -31,12 +20,9 @@ import forge.gui.GuiBase; import forge.gui.control.FControlGameEventHandler; import forge.gui.control.FControlGamePlayback; +import forge.gui.control.PlaybackSpeed; import forge.gui.control.WatchLocalGame; -import forge.gui.events.IUiEventVisitor; -import forge.gui.events.UiEvent; -import forge.gui.events.UiEventAttackerDeclared; -import forge.gui.events.UiEventBlockerAssigned; -import forge.gui.events.UiEventNextGameDecision; +import forge.gui.events.*; import forge.gui.interfaces.IGuiGame; import forge.interfaces.IGameController; import forge.localinstance.properties.ForgeConstants; @@ -53,6 +39,10 @@ import forge.util.collect.FCollectionView; import forge.util.maps.HashMapOfLists; import forge.util.maps.MapOfLists; +import org.apache.commons.lang3.StringUtils; + +import java.util.*; +import java.util.Map.Entry; public class HostedMatch { private Match match; diff --git a/forge-gui/src/main/java/forge/gamemodes/match/LobbySlot.java b/forge-gui/src/main/java/forge/gamemodes/match/LobbySlot.java index 8a9f6e2c327..96a4cd1f805 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/LobbySlot.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/LobbySlot.java @@ -1,14 +1,13 @@ package forge.gamemodes.match; -import java.io.Serializable; -import java.util.Set; - import com.google.common.collect.ImmutableSet; - import forge.ai.AIOption; import forge.deck.Deck; import forge.gamemodes.net.event.UpdateLobbyPlayerEvent; +import java.io.Serializable; +import java.util.Set; + public final class LobbySlot implements Serializable { private static final long serialVersionUID = 9203252798721142264L; diff --git a/forge-gui/src/main/java/forge/gamemodes/match/LocalLobby.java b/forge-gui/src/main/java/forge/gamemodes/match/LocalLobby.java index 65c20c4a74b..e0956506f6b 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/LocalLobby.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/LocalLobby.java @@ -1,10 +1,10 @@ package forge.gamemodes.match; -import java.util.Collections; - import forge.gui.GuiBase; import forge.gui.interfaces.IGuiGame; +import java.util.Collections; + public final class LocalLobby extends GameLobby { private IGuiGame gui = null; diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/Input.java b/forge-gui/src/main/java/forge/gamemodes/match/input/Input.java index 2d9624828f6..3f8973c52a0 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/Input.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/Input.java @@ -1,13 +1,13 @@ package forge.gamemodes.match.input; -import java.util.List; - import forge.game.card.Card; import forge.game.player.Player; import forge.game.player.PlayerView; import forge.game.spellability.SpellAbility; import forge.util.ITriggerEvent; +import java.util.List; + public interface Input { PlayerView getOwner(); diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputAttack.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputAttack.java index 70595e51f77..805f184737e 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputAttack.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputAttack.java @@ -17,12 +17,7 @@ */ package forge.gamemodes.match.input; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - import com.google.common.collect.Sets; - import forge.game.GameEntity; import forge.game.GameEntityView; import forge.game.card.Card; @@ -42,6 +37,10 @@ import forge.util.Localizer; import forge.util.collect.FCollectionView; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + /** *

* InputAttack class. diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputBase.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputBase.java index 2ae2db4175e..f59d1ee0d1a 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputBase.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputBase.java @@ -17,8 +17,6 @@ */ package forge.gamemodes.match.input; -import java.util.List; - import forge.game.Game; import forge.game.card.Card; import forge.game.card.CardView; @@ -34,6 +32,8 @@ import forge.util.ITriggerEvent; import forge.util.Localizer; +import java.util.List; + /** *

* Abstract Input class. diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputBlock.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputBlock.java index b0d04e6cf4a..f5fe9466cbf 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputBlock.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputBlock.java @@ -17,8 +17,6 @@ */ package forge.gamemodes.match.input; -import java.util.List; - import forge.game.card.Card; import forge.game.card.CardView; import forge.game.combat.Combat; @@ -34,6 +32,8 @@ import forge.util.Localizer; import forge.util.ThreadUtil; +import java.util.List; + /** *

* Input_Block class. diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputConfirm.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputConfirm.java index 833014c755f..518fc8f7a58 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputConfirm.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputConfirm.java @@ -17,10 +17,7 @@ */ package forge.gamemodes.match.input; -import java.util.List; - import com.google.common.collect.ImmutableList; - import forge.game.card.Card; import forge.game.card.CardView; import forge.game.spellability.SpellAbility; @@ -30,6 +27,8 @@ import forge.player.PlayerControllerHuman; import forge.util.Localizer; +import java.util.List; + /** *

* InputConfirm class. diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputConfirmMulligan.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputConfirmMulligan.java index 7643ba5bdb1..cd814690afc 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputConfirmMulligan.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputConfirmMulligan.java @@ -17,8 +17,6 @@ */ package forge.gamemodes.match.input; -import java.util.List; - import forge.game.Game; import forge.game.card.Card; import forge.game.card.CardCollection; @@ -32,6 +30,8 @@ import forge.util.Localizer; import forge.util.ThreadUtil; +import java.util.List; + /** *

* InputConfirmMulligan class. diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputLockUI.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputLockUI.java index f31c44a3165..be1a4600bcb 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputLockUI.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputLockUI.java @@ -1,8 +1,5 @@ package forge.gamemodes.match.input; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - import forge.game.card.Card; import forge.game.player.Player; import forge.game.player.PlayerView; @@ -13,6 +10,9 @@ import forge.util.Localizer; import forge.util.ThreadUtil; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + public class InputLockUI implements Input { private final AtomicInteger iCall = new AtomicInteger(); diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputLondonMulligan.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputLondonMulligan.java index d27c22580d5..153ea541cea 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputLondonMulligan.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputLondonMulligan.java @@ -17,8 +17,6 @@ */ package forge.gamemodes.match.input; -import java.util.List; - import forge.game.Game; import forge.game.card.Card; import forge.game.card.CardCollection; @@ -29,6 +27,8 @@ import forge.util.ITriggerEvent; import forge.util.Localizer; +import java.util.List; + /** *

* InputLondonMulligan class. diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputPassPriority.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputPassPriority.java index c134489837d..93eb1395e37 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputPassPriority.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputPassPriority.java @@ -17,15 +17,11 @@ */ package forge.gamemodes.match.input; -import java.util.ArrayList; -import java.util.List; - import forge.game.Game; import forge.game.card.Card; import forge.game.player.Player; import forge.game.player.PlayerController; import forge.game.player.actions.PassPriorityAction; - import forge.game.spellability.SpellAbility; import forge.localinstance.properties.ForgePreferences.FPref; import forge.model.FModel; @@ -35,6 +31,9 @@ import forge.util.Localizer; import forge.util.ThreadUtil; +import java.util.ArrayList; +import java.util.List; + /** *

* Input_PassPriority class. diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputPayMana.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputPayMana.java index 20a1b70496d..5d0517b0903 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputPayMana.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputPayMana.java @@ -1,14 +1,6 @@ package forge.gamemodes.match.input; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - import com.google.common.collect.Lists; - import forge.ai.ComputerUtilMana; import forge.ai.PlayerControllerAi; import forge.card.ColorSet; @@ -33,6 +25,8 @@ import forge.util.Localizer; import forge.util.TextUtil; +import java.util.*; + public abstract class InputPayMana extends InputSyncronizedBase { private static final long serialVersionUID = 718128600948280315L; diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputPayManaOfCostPayment.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputPayManaOfCostPayment.java index ab204505f24..70cf6b65ed4 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputPayManaOfCostPayment.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputPayManaOfCostPayment.java @@ -1,8 +1,5 @@ package forge.gamemodes.match.input; -import java.util.ArrayList; -import java.util.List; - import forge.card.mana.ManaAtom; import forge.card.mana.ManaCostShard; import forge.game.mana.Mana; @@ -16,6 +13,9 @@ import forge.util.ITriggerEvent; import forge.util.Localizer; +import java.util.ArrayList; +import java.util.List; + public class InputPayManaOfCostPayment extends InputPayMana { public InputPayManaOfCostPayment(final PlayerControllerHuman controller, ManaCostBeingPaid cost, SpellAbility spellAbility, Player payer, ManaConversionMatrix matrix, boolean effect) { diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputProxy.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputProxy.java index 9dc29a86f3f..f3c2cd3d1fc 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputProxy.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputProxy.java @@ -17,12 +17,6 @@ */ package forge.gamemodes.match.input; -import java.util.ArrayList; -import java.util.List; -import java.util.Observable; -import java.util.Observer; -import java.util.concurrent.atomic.AtomicReference; - import forge.game.card.Card; import forge.game.card.CardView; import forge.game.player.Player; @@ -32,6 +26,12 @@ import forge.player.PlayerControllerHuman; import forge.util.ITriggerEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.Observable; +import java.util.Observer; +import java.util.concurrent.atomic.AtomicReference; + /** *

* GuiInput class. diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputQueue.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputQueue.java index b669697d598..ae1972f82a9 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputQueue.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputQueue.java @@ -17,13 +17,13 @@ */ package forge.gamemodes.match.input; +import forge.game.GameView; +import forge.player.PlayerControllerHuman; + import java.util.Observable; import java.util.concurrent.BlockingDeque; import java.util.concurrent.LinkedBlockingDeque; -import forge.game.GameView; -import forge.player.PlayerControllerHuman; - /** *

* InputControl class. diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectCardsForConvokeOrImprovise.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectCardsForConvokeOrImprovise.java index 97075abb257..3b5b2634048 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectCardsForConvokeOrImprovise.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectCardsForConvokeOrImprovise.java @@ -1,12 +1,6 @@ package forge.gamemodes.match.input; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Maps; - import forge.card.ColorSet; import forge.card.mana.ManaCost; import forge.card.mana.ManaCostShard; @@ -21,6 +15,11 @@ import forge.util.ITriggerEvent; import forge.util.TextUtil; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public final class InputSelectCardsForConvokeOrImprovise extends InputSelectManyBase { private static final long serialVersionUID = -1779224307654698954L; diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectEntitiesFromList.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectEntitiesFromList.java index 340c43ce2b3..a011a55421c 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectEntitiesFromList.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectEntitiesFromList.java @@ -1,9 +1,5 @@ package forge.gamemodes.match.input; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - import forge.game.GameEntity; import forge.game.ability.AbilityUtils; import forge.game.card.Card; @@ -25,6 +21,10 @@ import forge.util.collect.FCollection; import forge.util.collect.FCollectionView; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + public class InputSelectEntitiesFromList extends InputSelectManyBase { private static final long serialVersionUID = -6609493252672573139L; diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectManyBase.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectManyBase.java index fce32159c0e..00c492a09e5 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectManyBase.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectManyBase.java @@ -1,7 +1,5 @@ package forge.gamemodes.match.input; -import java.util.Collection; - import com.google.common.collect.Iterables; import forge.game.GameEntity; import forge.game.card.Card; @@ -13,6 +11,8 @@ import forge.model.FModel; import forge.player.PlayerControllerHuman; +import java.util.Collection; + public abstract class InputSelectManyBase extends InputSyncronizedBase { private static final long serialVersionUID = -2305549394512889450L; diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java index a27a8f613f3..3ed01ecf1e4 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSelectTargets.java @@ -1,18 +1,8 @@ package forge.gamemodes.match.input; -import java.util.ArrayList; -import java.util.Collection; - -import java.util.List; -import java.util.Set; -import java.util.function.Predicate; - import com.google.common.collect.Iterables; -import org.apache.commons.lang3.ObjectUtils; - import com.google.common.collect.Lists; import com.google.common.collect.Sets; - import forge.game.GameEntity; import forge.game.GameObject; import forge.game.ability.ApiType; @@ -30,6 +20,13 @@ import forge.player.PlayerZoneUpdate; import forge.player.PlayerZoneUpdates; import forge.util.*; +import org.apache.commons.lang3.ObjectUtils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.function.Predicate; public final class InputSelectTargets extends InputSyncronizedBase { private final List choices; diff --git a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSyncronizedBase.java b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSyncronizedBase.java index c34cdf6c1d7..b6bc7bc805b 100644 --- a/forge-gui/src/main/java/forge/gamemodes/match/input/InputSyncronizedBase.java +++ b/forge-gui/src/main/java/forge/gamemodes/match/input/InputSyncronizedBase.java @@ -1,11 +1,11 @@ package forge.gamemodes.match.input; -import java.util.concurrent.CountDownLatch; - import forge.gui.FThreads; import forge.gui.error.BugReporter; import forge.player.PlayerControllerHuman; +import java.util.concurrent.CountDownLatch; + public abstract class InputSyncronizedBase extends InputBase implements InputSynchronized { private static final long serialVersionUID = 8756177361251703052L; private final CountDownLatch cdlDone; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/CObjectInputStream.java b/forge-gui/src/main/java/forge/gamemodes/net/CObjectInputStream.java index 54f9325b7a9..e378f36734e 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/CObjectInputStream.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/CObjectInputStream.java @@ -1,13 +1,9 @@ package forge.gamemodes.net; -import java.io.EOFException; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectStreamClass; - import io.netty.handler.codec.serialization.ClassResolver; +import java.io.*; + public class CObjectInputStream extends ObjectInputStream { private final ClassResolver classResolver; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/ChatMessage.java b/forge-gui/src/main/java/forge/gamemodes/net/ChatMessage.java index 7212ee1c9c8..826133e69e8 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/ChatMessage.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/ChatMessage.java @@ -1,12 +1,12 @@ package forge.gamemodes.net; -import java.text.SimpleDateFormat; -import java.util.Date; - import forge.localinstance.properties.ForgePreferences; import forge.localinstance.properties.ForgePreferences.FPref; import forge.model.FModel; +import java.text.SimpleDateFormat; +import java.util.Date; + public class ChatMessage { private static final ForgePreferences prefs = FModel.getPreferences(); private static final SimpleDateFormat inFormat = new SimpleDateFormat("HH:mm:ss"); diff --git a/forge-gui/src/main/java/forge/gamemodes/net/CompatibleObjectDecoder.java b/forge-gui/src/main/java/forge/gamemodes/net/CompatibleObjectDecoder.java index 3b70145ddc8..3bf45089424 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/CompatibleObjectDecoder.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/CompatibleObjectDecoder.java @@ -1,8 +1,5 @@ package forge.gamemodes.net; -import java.io.ObjectInputStream; -import java.io.StreamCorruptedException; - import forge.gui.GuiBase; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufInputStream; @@ -11,6 +8,9 @@ import io.netty.handler.codec.serialization.ClassResolver; import net.jpountz.lz4.LZ4BlockInputStream; +import java.io.ObjectInputStream; +import java.io.StreamCorruptedException; + public class CompatibleObjectDecoder extends LengthFieldBasedFrameDecoder { private final ClassResolver classResolver; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/CompatibleObjectEncoder.java b/forge-gui/src/main/java/forge/gamemodes/net/CompatibleObjectEncoder.java index 573154536be..3496af17d66 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/CompatibleObjectEncoder.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/CompatibleObjectEncoder.java @@ -1,8 +1,5 @@ package forge.gamemodes.net; -import java.io.ObjectOutputStream; -import java.io.Serializable; - import forge.gui.GuiBase; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufOutputStream; @@ -10,6 +7,9 @@ import io.netty.handler.codec.MessageToByteEncoder; import net.jpountz.lz4.LZ4BlockOutputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + public class CompatibleObjectEncoder extends MessageToByteEncoder { private static final byte[] LENGTH_PLACEHOLDER = new byte[4]; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/GameProtocolHandler.java b/forge-gui/src/main/java/forge/gamemodes/net/GameProtocolHandler.java index 5fd23a11af5..d70dec69db9 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/GameProtocolHandler.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/GameProtocolHandler.java @@ -1,9 +1,5 @@ package forge.gamemodes.net; -import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - import forge.gamemodes.net.event.GuiGameEvent; import forge.gamemodes.net.event.ReplyEvent; import forge.gui.FThreads; @@ -12,6 +8,10 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + public abstract class GameProtocolHandler extends ChannelInboundHandlerAdapter { private final boolean runInEdt; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/GameProtocolSender.java b/forge-gui/src/main/java/forge/gamemodes/net/GameProtocolSender.java index dcdf8944c61..384eb044ff3 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/GameProtocolSender.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/GameProtocolSender.java @@ -1,9 +1,9 @@ package forge.gamemodes.net; -import java.util.concurrent.TimeoutException; - import forge.gamemodes.net.event.GuiGameEvent; +import java.util.concurrent.TimeoutException; + public final class GameProtocolSender { private final IRemote remote; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/IRemote.java b/forge-gui/src/main/java/forge/gamemodes/net/IRemote.java index 1a0d787de5a..9dec8dafc09 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/IRemote.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/IRemote.java @@ -1,10 +1,10 @@ package forge.gamemodes.net; -import java.util.concurrent.TimeoutException; - import forge.gamemodes.net.event.IdentifiableNetEvent; import forge.gamemodes.net.event.NetEvent; +import java.util.concurrent.TimeoutException; + public interface IRemote { void send(NetEvent event); Object sendAndWait(IdentifiableNetEvent event) throws TimeoutException; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/NetConnectUtil.java b/forge-gui/src/main/java/forge/gamemodes/net/NetConnectUtil.java index b3e83ca43a5..cc70f5dbb4b 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/NetConnectUtil.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/NetConnectUtil.java @@ -1,7 +1,5 @@ package forge.gamemodes.net; -import org.apache.commons.lang3.StringUtils; - import forge.gamemodes.match.GameLobby.GameLobbyData; import forge.gamemodes.match.LobbySlotType; import forge.gamemodes.net.client.ClientGameLobby; @@ -23,6 +21,7 @@ import forge.model.FModel; import forge.player.GamePlayerUtil; import forge.util.Localizer; +import org.apache.commons.lang3.StringUtils; public class NetConnectUtil { private NetConnectUtil() { } diff --git a/forge-gui/src/main/java/forge/gamemodes/net/OfflineLobby.java b/forge-gui/src/main/java/forge/gamemodes/net/OfflineLobby.java index 68f4b20c7d2..7bcdef1f81e 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/OfflineLobby.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/OfflineLobby.java @@ -1,12 +1,12 @@ package forge.gamemodes.net; -import java.util.Collections; - import forge.gamemodes.match.GameLobby; import forge.gamemodes.match.LobbySlot; import forge.gamemodes.match.LobbySlotType; import forge.gui.interfaces.IGuiGame; +import java.util.Collections; + //Temporary lobby instance to use for OnlineLobby before connecting to a server public final class OfflineLobby extends GameLobby { public OfflineLobby() { diff --git a/forge-gui/src/main/java/forge/gamemodes/net/ProtocolMethod.java b/forge-gui/src/main/java/forge/gamemodes/net/ProtocolMethod.java index b79ab45e7eb..366f39c5f1f 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/ProtocolMethod.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/ProtocolMethod.java @@ -1,11 +1,5 @@ package forge.gamemodes.net; -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - import forge.deck.CardPool; import forge.game.GameEntityView; import forge.game.GameView; @@ -24,6 +18,12 @@ import forge.util.ITriggerEvent; import forge.util.ReflectionUtil; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + /** * The methods that can be sent through this protocol. */ diff --git a/forge-gui/src/main/java/forge/gamemodes/net/ReplyPool.java b/forge-gui/src/main/java/forge/gamemodes/net/ReplyPool.java index cefacdb0aaf..30c63223d09 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/ReplyPool.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/ReplyPool.java @@ -1,13 +1,13 @@ package forge.gamemodes.net; +import com.google.common.collect.Maps; + import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.FutureTask; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import com.google.common.collect.Maps; - public class ReplyPool { private final Map pool = Maps.newHashMap(); diff --git a/forge-gui/src/main/java/forge/gamemodes/net/client/FGameClient.java b/forge-gui/src/main/java/forge/gamemodes/net/client/FGameClient.java index 1b402c8d64d..59e8c87d0f6 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/client/FGameClient.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/client/FGameClient.java @@ -1,10 +1,6 @@ package forge.gamemodes.net.client; -import java.util.List; -import java.util.concurrent.TimeoutException; - import com.google.common.collect.Lists; - import forge.game.player.PlayerView; import forge.gamemodes.net.CompatibleObjectDecoder; import forge.gamemodes.net.CompatibleObjectEncoder; @@ -16,18 +12,15 @@ import forge.gui.interfaces.IGuiGame; import forge.interfaces.ILobbyListener; import io.netty.bootstrap.Bootstrap; -import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelPipeline; -import io.netty.channel.EventLoopGroup; +import io.netty.channel.*; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.handler.codec.serialization.ClassResolvers; +import java.util.List; +import java.util.concurrent.TimeoutException; + public class FGameClient implements IToServer { private final IGuiGame clientGui; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/client/GameClientHandler.java b/forge-gui/src/main/java/forge/gamemodes/net/client/GameClientHandler.java index 6fa78153927..211c4169e77 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/client/GameClientHandler.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/client/GameClientHandler.java @@ -1,18 +1,8 @@ package forge.gamemodes.net.client; -import java.util.Collections; -import java.util.EnumMap; -import java.util.Iterator; -import java.util.List; - import com.google.common.collect.Lists; - import forge.LobbyPlayer; -import forge.game.Game; -import forge.game.GameRules; -import forge.game.GameType; -import forge.game.GameView; -import forge.game.Match; +import forge.game.*; import forge.game.player.PlayerView; import forge.game.player.RegisteredPlayer; import forge.gamemodes.match.LobbySlot; @@ -34,6 +24,11 @@ import forge.trackable.Tracker; import io.netty.channel.ChannelHandlerContext; +import java.util.Collections; +import java.util.EnumMap; +import java.util.Iterator; +import java.util.List; + final class GameClientHandler extends GameProtocolHandler { private final FGameClient client; private final IGuiGame gui; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/client/NetGameController.java b/forge-gui/src/main/java/forge/gamemodes/net/client/NetGameController.java index 2e4ed59cdd6..57bec3d0aee 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/client/NetGameController.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/client/NetGameController.java @@ -1,7 +1,5 @@ package forge.gamemodes.net.client; -import java.util.List; - import forge.game.card.CardView; import forge.game.player.PlayerView; import forge.game.player.actions.PlayerAction; @@ -14,6 +12,8 @@ import forge.interfaces.IMacroSystem; import forge.util.ITriggerEvent; +import java.util.List; + public class NetGameController implements IGameController { private final GameProtocolSender sender; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/event/NetEvent.java b/forge-gui/src/main/java/forge/gamemodes/net/event/NetEvent.java index a5fe571c6f3..16394d58a55 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/event/NetEvent.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/event/NetEvent.java @@ -1,9 +1,9 @@ package forge.gamemodes.net.event; -import java.io.Serializable; - import forge.gamemodes.net.server.RemoteClient; +import java.io.Serializable; + public interface NetEvent extends Serializable { void updateForClient(RemoteClient client); } diff --git a/forge-gui/src/main/java/forge/gamemodes/net/event/ReplyEvent.java b/forge-gui/src/main/java/forge/gamemodes/net/event/ReplyEvent.java index 6e10c7f3683..aeb9ef3aeeb 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/event/ReplyEvent.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/event/ReplyEvent.java @@ -1,9 +1,9 @@ package forge.gamemodes.net.event; -import java.io.Serializable; - import forge.gamemodes.net.server.RemoteClient; +import java.io.Serializable; + public final class ReplyEvent implements NetEvent { private static final long serialVersionUID = -2814651319617795386L; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/event/UpdateLobbyPlayerEvent.java b/forge-gui/src/main/java/forge/gamemodes/net/event/UpdateLobbyPlayerEvent.java index cf287999deb..9d6106a36cd 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/event/UpdateLobbyPlayerEvent.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/event/UpdateLobbyPlayerEvent.java @@ -1,8 +1,5 @@ package forge.gamemodes.net.event; -import java.util.Collections; -import java.util.Set; - import forge.ai.AIOption; import forge.deck.CardPool; import forge.deck.Deck; @@ -10,6 +7,9 @@ import forge.gamemodes.match.LobbySlotType; import forge.gamemodes.net.server.RemoteClient; +import java.util.Collections; +import java.util.Set; + public final class UpdateLobbyPlayerEvent implements NetEvent { private static final long serialVersionUID = -7354695008599789571L; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/server/NetGuiGame.java b/forge-gui/src/main/java/forge/gamemodes/net/server/NetGuiGame.java index 4cfb1ffca80..04f0e1fa70b 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/server/NetGuiGame.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/server/NetGuiGame.java @@ -1,10 +1,5 @@ package forge.gamemodes.net.server; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - import forge.LobbyPlayer; import forge.ai.GameState; import forge.deck.CardPool; @@ -27,6 +22,11 @@ import forge.trackable.TrackableCollection; import forge.util.ITriggerEvent; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + public class NetGuiGame extends AbstractGuiGame { private final GameProtocolSender sender; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/server/RemoteClient.java b/forge-gui/src/main/java/forge/gamemodes/net/server/RemoteClient.java index 2d5b5084d5c..407169eaba7 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/server/RemoteClient.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/server/RemoteClient.java @@ -1,12 +1,12 @@ package forge.gamemodes.net.server; -import java.util.concurrent.TimeoutException; - import forge.gamemodes.net.ReplyPool; import forge.gamemodes.net.event.IdentifiableNetEvent; import forge.gamemodes.net.event.NetEvent; import io.netty.channel.Channel; +import java.util.concurrent.TimeoutException; + public final class RemoteClient implements IToClient { private final Channel channel; diff --git a/forge-gui/src/main/java/forge/gamemodes/net/server/ServerGameLobby.java b/forge-gui/src/main/java/forge/gamemodes/net/server/ServerGameLobby.java index 44369085159..db11301c012 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/server/ServerGameLobby.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/server/ServerGameLobby.java @@ -1,13 +1,12 @@ package forge.gamemodes.net.server; -import java.util.Collections; - -import org.apache.commons.lang3.StringUtils; - import forge.gamemodes.match.GameLobby; import forge.gamemodes.match.LobbySlot; import forge.gamemodes.match.LobbySlotType; import forge.gui.interfaces.IGuiGame; +import org.apache.commons.lang3.StringUtils; + +import java.util.Collections; public final class ServerGameLobby extends GameLobby { diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/io/ReadPriceList.java b/forge-gui/src/main/java/forge/gamemodes/quest/io/ReadPriceList.java index 180ed91b4ec..5f83ee206d8 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/io/ReadPriceList.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/io/ReadPriceList.java @@ -17,15 +17,15 @@ */ package forge.gamemodes.quest.io; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import forge.card.MagicColor; import forge.localinstance.properties.ForgeConstants; import forge.util.FileUtil; import forge.util.MyRandom; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** *

* ReadPriceList class. diff --git a/forge-gui/src/main/java/forge/gui/card/CardPreferences.java b/forge-gui/src/main/java/forge/gui/card/CardPreferences.java index 9029fca11f5..2644f40c4ee 100644 --- a/forge-gui/src/main/java/forge/gui/card/CardPreferences.java +++ b/forge-gui/src/main/java/forge/gui/card/CardPreferences.java @@ -1,23 +1,21 @@ package forge.gui.card; -import java.io.File; -import java.io.FileNotFoundException; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import forge.card.CardDb; +import forge.item.IPaperCard; +import forge.localinstance.properties.ForgeConstants; +import forge.model.FModel; import forge.util.TextUtil; +import forge.util.XmlUtil; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; -import forge.item.IPaperCard; -import forge.localinstance.properties.ForgeConstants; -import forge.model.FModel; -import forge.util.XmlUtil; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.File; +import java.io.FileNotFoundException; +import java.util.HashMap; +import java.util.Map; /** * Preferences associated with individual cards diff --git a/forge-gui/src/main/java/forge/gui/card/CardReaderExperiments.java b/forge-gui/src/main/java/forge/gui/card/CardReaderExperiments.java index 9343ec1b678..ef810e5641a 100644 --- a/forge-gui/src/main/java/forge/gui/card/CardReaderExperiments.java +++ b/forge-gui/src/main/java/forge/gui/card/CardReaderExperiments.java @@ -1,21 +1,17 @@ package forge.gui.card; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStreamReader; -import java.io.PrintWriter; +import forge.CardStorageReader; +import forge.card.CardRules; +import forge.localinstance.properties.ForgeConstants; +import forge.util.FileUtil; + +import java.io.*; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import forge.CardStorageReader; -import forge.card.CardRules; -import forge.localinstance.properties.ForgeConstants; -import forge.util.FileUtil; - public class CardReaderExperiments { //utility functions to parse all cards and perform certain actions on each card diff --git a/forge-gui/src/main/java/forge/gui/card/CardScriptInfo.java b/forge-gui/src/main/java/forge/gui/card/CardScriptInfo.java index f97d2e9384e..049af08bdbb 100644 --- a/forge-gui/src/main/java/forge/gui/card/CardScriptInfo.java +++ b/forge-gui/src/main/java/forge/gui/card/CardScriptInfo.java @@ -17,14 +17,14 @@ */ package forge.gui.card; +import forge.localinstance.properties.ForgeConstants; +import forge.util.FileUtil; + import java.io.File; import java.io.PrintWriter; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import forge.localinstance.properties.ForgeConstants; -import forge.util.FileUtil; - public final class CardScriptInfo { private String text; private final File file; diff --git a/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java b/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java index 76de4179a71..06bb498eaf3 100644 --- a/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java +++ b/forge-gui/src/main/java/forge/gui/card/CardScriptParser.java @@ -1,23 +1,21 @@ package forge.gui.card; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Predicate; - -import org.apache.commons.lang3.StringUtils; - import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; - import forge.card.CardType; import forge.game.ability.AbilityFactory; import forge.game.ability.AbilityFactory.AbilityRecordType; import forge.game.ability.ApiType; import forge.game.replacement.ReplacementType; import forge.game.trigger.TriggerType; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Predicate; public final class CardScriptParser { diff --git a/forge-gui/src/main/java/forge/gui/control/FControlGameEventHandler.java b/forge-gui/src/main/java/forge/gui/control/FControlGameEventHandler.java index ae678d65575..9ae66851e08 100644 --- a/forge-gui/src/main/java/forge/gui/control/FControlGameEventHandler.java +++ b/forge-gui/src/main/java/forge/gui/control/FControlGameEventHandler.java @@ -1,12 +1,8 @@ package forge.gui.control; -import java.util.*; -import java.util.Map.Entry; - import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.eventbus.Subscribe; - import forge.game.Game; import forge.game.card.Card; import forge.game.card.CardCollection; @@ -26,6 +22,9 @@ import forge.util.Lang; import forge.util.maps.MapOfLists; +import java.util.*; +import java.util.Map.Entry; + public class FControlGameEventHandler extends IGameEventVisitor.Base { private final PlayerControllerHuman humanController; private final IGuiGame matchController; diff --git a/forge-gui/src/main/java/forge/gui/control/FControlGamePlayback.java b/forge-gui/src/main/java/forge/gui/control/FControlGamePlayback.java index e59a66f12d6..0430f64fef1 100644 --- a/forge-gui/src/main/java/forge/gui/control/FControlGamePlayback.java +++ b/forge-gui/src/main/java/forge/gui/control/FControlGamePlayback.java @@ -1,27 +1,17 @@ package forge.gui.control; -import java.util.concurrent.BrokenBarrierException; -import java.util.concurrent.CyclicBarrier; -import java.util.concurrent.atomic.AtomicBoolean; - import com.google.common.eventbus.Subscribe; - import forge.game.Game; import forge.game.card.CardView; -import forge.game.event.GameEvent; -import forge.game.event.GameEventBlockersDeclared; -import forge.game.event.GameEventGameFinished; -import forge.game.event.GameEventGameStarted; -import forge.game.event.GameEventLandPlayed; -import forge.game.event.GameEventPlayerPriority; -import forge.game.event.GameEventSpellAbilityCast; -import forge.game.event.GameEventSpellResolved; -import forge.game.event.GameEventTurnPhase; -import forge.game.event.IGameEventVisitor; +import forge.game.event.*; import forge.gamemodes.match.input.InputPlaybackControl; import forge.gui.FThreads; import forge.player.PlayerControllerHuman; +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.atomic.AtomicBoolean; + public class FControlGamePlayback extends IGameEventVisitor.Base { private InputPlaybackControl inputPlayback; private final AtomicBoolean paused = new AtomicBoolean(false); diff --git a/forge-gui/src/main/java/forge/gui/control/WatchLocalGame.java b/forge-gui/src/main/java/forge/gui/control/WatchLocalGame.java index d568fa526cd..f60a54f4630 100644 --- a/forge-gui/src/main/java/forge/gui/control/WatchLocalGame.java +++ b/forge-gui/src/main/java/forge/gui/control/WatchLocalGame.java @@ -3,8 +3,6 @@ */ package forge.gui.control; -import java.util.List; - import forge.LobbyPlayer; import forge.game.Game; import forge.game.card.CardView; @@ -17,6 +15,8 @@ import forge.player.PlayerControllerHuman; import forge.util.ITriggerEvent; +import java.util.List; + public class WatchLocalGame extends PlayerControllerHuman { public WatchLocalGame(final Game game0, final LobbyPlayer lp, final IGuiGame gui) { super(game0, null, lp); diff --git a/forge-gui/src/main/java/forge/gui/download/GuiDownloadAchievementImages.java b/forge-gui/src/main/java/forge/gui/download/GuiDownloadAchievementImages.java index 6bf24143028..7a4c1aea877 100644 --- a/forge-gui/src/main/java/forge/gui/download/GuiDownloadAchievementImages.java +++ b/forge-gui/src/main/java/forge/gui/download/GuiDownloadAchievementImages.java @@ -17,11 +17,11 @@ */ package forge.gui.download; +import forge.localinstance.properties.ForgeConstants; + import java.util.Map; import java.util.TreeMap; -import forge.localinstance.properties.ForgeConstants; - public class GuiDownloadAchievementImages extends GuiDownloadService { @Override public String getTitle() { diff --git a/forge-gui/src/main/java/forge/gui/download/GuiDownloadPicturesHQ.java b/forge-gui/src/main/java/forge/gui/download/GuiDownloadPicturesHQ.java index 921ddef503d..62885cb93ab 100644 --- a/forge-gui/src/main/java/forge/gui/download/GuiDownloadPicturesHQ.java +++ b/forge-gui/src/main/java/forge/gui/download/GuiDownloadPicturesHQ.java @@ -17,18 +17,14 @@ */ package forge.gui.download; -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - import forge.item.PaperCard; import forge.localinstance.properties.ForgeConstants; import forge.model.FModel; import forge.util.ImageUtil; +import java.io.File; +import java.util.*; + public class GuiDownloadPicturesHQ extends GuiDownloadService { final Map downloads = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); Set existingSets; diff --git a/forge-gui/src/main/java/forge/gui/download/GuiDownloadPicturesLQ.java b/forge-gui/src/main/java/forge/gui/download/GuiDownloadPicturesLQ.java index a8e771ad338..6e457342b8f 100644 --- a/forge-gui/src/main/java/forge/gui/download/GuiDownloadPicturesLQ.java +++ b/forge-gui/src/main/java/forge/gui/download/GuiDownloadPicturesLQ.java @@ -17,8 +17,6 @@ */ package forge.gui.download; -import java.util.*; - import forge.ImageKeys; import forge.StaticData; import forge.item.PaperCard; @@ -26,6 +24,10 @@ import forge.model.FModel; import forge.util.ImageUtil; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; + public class GuiDownloadPicturesLQ extends GuiDownloadService { final Map downloads = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); Set existingSets; diff --git a/forge-gui/src/main/java/forge/gui/download/GuiDownloadPrices.java b/forge-gui/src/main/java/forge/gui/download/GuiDownloadPrices.java index f30a6cce352..1fd12dee757 100644 --- a/forge-gui/src/main/java/forge/gui/download/GuiDownloadPrices.java +++ b/forge-gui/src/main/java/forge/gui/download/GuiDownloadPrices.java @@ -17,12 +17,11 @@ */ package forge.gui.download; -import java.util.Map; - import com.google.common.collect.ImmutableMap; - import forge.localinstance.properties.ForgeConstants; +import java.util.Map; + public class GuiDownloadPrices extends GuiDownloadService { @Override public String getTitle() { diff --git a/forge-gui/src/main/java/forge/gui/download/GuiDownloadQuestImages.java b/forge-gui/src/main/java/forge/gui/download/GuiDownloadQuestImages.java index aa167ea4a29..8bee82b6076 100644 --- a/forge-gui/src/main/java/forge/gui/download/GuiDownloadQuestImages.java +++ b/forge-gui/src/main/java/forge/gui/download/GuiDownloadQuestImages.java @@ -17,11 +17,11 @@ */ package forge.gui.download; +import forge.localinstance.properties.ForgeConstants; + import java.util.Map; import java.util.TreeMap; -import forge.localinstance.properties.ForgeConstants; - public class GuiDownloadQuestImages extends GuiDownloadService { @Override public String getTitle() { diff --git a/forge-gui/src/main/java/forge/gui/download/GuiDownloadService.java b/forge-gui/src/main/java/forge/gui/download/GuiDownloadService.java index 8f82b609ccc..2872ecb3a68 100644 --- a/forge-gui/src/main/java/forge/gui/download/GuiDownloadService.java +++ b/forge-gui/src/main/java/forge/gui/download/GuiDownloadService.java @@ -17,29 +17,7 @@ */ package forge.gui.download; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.ConnectException; -import java.net.HttpURLConnection; -import java.net.InetSocketAddress; -import java.net.MalformedURLException; -import java.net.Proxy; -import java.net.URL; -import java.net.URLDecoder; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.TimeUnit; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.commons.lang3.tuple.Pair; - import com.esotericsoftware.minlog.Log; - import forge.gui.FThreads; import forge.gui.GuiBase; import forge.gui.UiCommand; @@ -51,6 +29,16 @@ import forge.util.FileUtil; import forge.util.HttpUtil; import forge.util.TextUtil; +import org.apache.commons.lang3.tuple.Pair; + +import java.io.*; +import java.net.*; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; @SuppressWarnings("serial") public abstract class GuiDownloadService implements Runnable { diff --git a/forge-gui/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java b/forge-gui/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java index ee723815ecf..11dfb32c1e0 100644 --- a/forge-gui/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java +++ b/forge-gui/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java @@ -17,15 +17,7 @@ */ package forge.gui.download; -import java.io.File; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.TreeMap; - import com.google.common.collect.Iterables; -import org.apache.commons.lang3.StringUtils; - import forge.StaticData; import forge.card.CardEdition; import forge.item.PaperCard; @@ -33,6 +25,13 @@ import forge.model.FModel; import forge.util.ImageUtil; import forge.util.TextUtil; +import org.apache.commons.lang3.StringUtils; + +import java.io.File; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.TreeMap; public class GuiDownloadSetPicturesLQ extends GuiDownloadService { @Override diff --git a/forge-gui/src/main/java/forge/gui/download/GuiDownloadSkins.java b/forge-gui/src/main/java/forge/gui/download/GuiDownloadSkins.java index c062e531f9b..7501924e9b6 100644 --- a/forge-gui/src/main/java/forge/gui/download/GuiDownloadSkins.java +++ b/forge-gui/src/main/java/forge/gui/download/GuiDownloadSkins.java @@ -1,10 +1,10 @@ package forge.gui.download; +import forge.localinstance.properties.ForgeConstants; + import java.util.Map; import java.util.TreeMap; -import forge.localinstance.properties.ForgeConstants; - public class GuiDownloadSkins extends GuiDownloadService { @Override public String getTitle() { diff --git a/forge-gui/src/main/java/forge/gui/error/BugReporter.java b/forge-gui/src/main/java/forge/gui/error/BugReporter.java index 7d751505529..868df2b552a 100644 --- a/forge-gui/src/main/java/forge/gui/error/BugReporter.java +++ b/forge-gui/src/main/java/forge/gui/error/BugReporter.java @@ -17,13 +17,6 @@ */ package forge.gui.error; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; - import forge.gui.FThreads; import forge.gui.GuiBase; import forge.gui.util.SOptionPane; @@ -32,6 +25,8 @@ import forge.util.Localizer; import io.sentry.Sentry; +import java.io.*; + /** * The class ErrorViewer. Enables showing and saving error messages that * occurred in forge. diff --git a/forge-gui/src/main/java/forge/gui/interfaces/IGuiBase.java b/forge-gui/src/main/java/forge/gui/interfaces/IGuiBase.java index 2d59447c630..80a83fada46 100644 --- a/forge-gui/src/main/java/forge/gui/interfaces/IGuiBase.java +++ b/forge-gui/src/main/java/forge/gui/interfaces/IGuiBase.java @@ -1,12 +1,5 @@ package forge.gui.interfaces; -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.Collection; -import java.util.List; -import java.util.function.Function; - import forge.gamemodes.match.HostedMatch; import forge.gui.download.GuiDownloadService; import forge.item.PaperCard; @@ -17,6 +10,13 @@ import forge.util.Callback; import forge.util.ImageFetcher; +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.Collection; +import java.util.List; +import java.util.function.Function; + public interface IGuiBase { boolean isRunningOnDesktop(); boolean isLibgdxPort(); diff --git a/forge-gui/src/main/java/forge/gui/interfaces/IGuiGame.java b/forge-gui/src/main/java/forge/gui/interfaces/IGuiGame.java index 935ec605a3d..601bbb9b9cf 100644 --- a/forge-gui/src/main/java/forge/gui/interfaces/IGuiGame.java +++ b/forge-gui/src/main/java/forge/gui/interfaces/IGuiGame.java @@ -1,10 +1,5 @@ package forge.gui.interfaces; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - import forge.LobbyPlayer; import forge.ai.GameState; import forge.deck.CardPool; @@ -29,6 +24,11 @@ import forge.trackable.TrackableCollection; import forge.util.ITriggerEvent; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + public interface IGuiGame { void setGameView(GameView gameView); diff --git a/forge-gui/src/main/java/forge/gui/interfaces/IWinLoseView.java b/forge-gui/src/main/java/forge/gui/interfaces/IWinLoseView.java index b39472fe334..286e96e677b 100644 --- a/forge-gui/src/main/java/forge/gui/interfaces/IWinLoseView.java +++ b/forge-gui/src/main/java/forge/gui/interfaces/IWinLoseView.java @@ -1,10 +1,10 @@ package forge.gui.interfaces; -import java.util.List; - import forge.item.PaperCard; import forge.localinstance.skin.FSkinProp; +import java.util.List; + public interface IWinLoseView { T getBtnContinue(); T getBtnRestart(); diff --git a/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java b/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java index d212d9267dd..de64b8f41e6 100644 --- a/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java +++ b/forge-gui/src/main/java/forge/gui/util/SGuiChoose.java @@ -1,16 +1,15 @@ package forge.gui.util; +import com.google.common.collect.Iterables; +import forge.gui.GuiBase; +import org.apache.commons.lang3.StringUtils; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.function.Function; -import com.google.common.collect.Iterables; -import org.apache.commons.lang3.StringUtils; - -import forge.gui.GuiBase; - public class SGuiChoose { /** diff --git a/forge-gui/src/main/java/forge/gui/util/SOptionPane.java b/forge-gui/src/main/java/forge/gui/util/SOptionPane.java index 42312e9a6e9..254cc28eef4 100644 --- a/forge-gui/src/main/java/forge/gui/util/SOptionPane.java +++ b/forge-gui/src/main/java/forge/gui/util/SOptionPane.java @@ -1,13 +1,12 @@ package forge.gui.util; -import java.util.List; - import com.google.common.collect.ImmutableList; - import forge.gui.GuiBase; import forge.localinstance.skin.FSkinProp; import forge.util.Localizer; +import java.util.List; + public class SOptionPane { public static final FSkinProp QUESTION_ICON = FSkinProp.ICO_QUESTION; public static final FSkinProp INFORMATION_ICON = FSkinProp.ICO_INFORMATION; diff --git a/forge-gui/src/main/java/forge/model/CardBlock.java b/forge-gui/src/main/java/forge/model/CardBlock.java index 7fc4f6ca5ff..d11a31d8ce4 100644 --- a/forge-gui/src/main/java/forge/model/CardBlock.java +++ b/forge-gui/src/main/java/forge/model/CardBlock.java @@ -17,21 +17,20 @@ */ package forge.model; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.function.Predicate; - -import forge.item.PaperCardPredicates; -import org.apache.commons.lang3.StringUtils; - import forge.card.CardEdition; import forge.item.PaperCard; +import forge.item.PaperCardPredicates; import forge.item.generation.IUnOpenedProduct; import forge.item.generation.UnOpenedProduct; import forge.util.TextUtil; import forge.util.storage.StorageReaderFile; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.function.Predicate; // import forge.deck.Deck; diff --git a/forge-gui/src/main/java/forge/model/CardCollections.java b/forge-gui/src/main/java/forge/model/CardCollections.java index 07af6fb9548..7da2bd2cd04 100644 --- a/forge-gui/src/main/java/forge/model/CardCollections.java +++ b/forge-gui/src/main/java/forge/model/CardCollections.java @@ -17,8 +17,6 @@ */ package forge.model; -import java.io.File; - import forge.deck.Deck; import forge.deck.DeckGroup; import forge.deck.io.DeckGroupSerializer; @@ -27,6 +25,8 @@ import forge.util.storage.IStorage; import forge.util.storage.StorageImmediatelySerialized; +import java.io.File; + /** * Holds editable maps of decks saved to disk. Adding or removing items to(from) * such map turns into immediate file update diff --git a/forge-gui/src/main/java/forge/model/FModel.java b/forge-gui/src/main/java/forge/model/FModel.java index a91b01408d1..2ba393e1eaa 100644 --- a/forge-gui/src/main/java/forge/model/FModel.java +++ b/forge-gui/src/main/java/forge/model/FModel.java @@ -61,7 +61,9 @@ import forge.util.storage.StorageBase; import java.io.File; -import java.util.*; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.function.Function; /** diff --git a/forge-gui/src/main/java/forge/model/UnOpenedMeta.java b/forge-gui/src/main/java/forge/model/UnOpenedMeta.java index d8b82d312f2..4c2d14c3076 100644 --- a/forge-gui/src/main/java/forge/model/UnOpenedMeta.java +++ b/forge-gui/src/main/java/forge/model/UnOpenedMeta.java @@ -18,15 +18,15 @@ package forge.model; -import java.util.ArrayList; -import java.util.List; - import forge.gui.util.SGuiChoose; import forge.item.PaperCard; import forge.item.generation.IUnOpenedProduct; import forge.util.MyRandom; import forge.util.TextUtil; +import java.util.ArrayList; +import java.util.List; + /** * This type extends UnOpenedProduct to support booster choice or random boosters * in sealed deck games. See MetaSet.java for further information. diff --git a/forge-gui/src/main/java/forge/player/GamePlayerUtil.java b/forge-gui/src/main/java/forge/player/GamePlayerUtil.java index 1e6ec8987ec..09be7b3c4bd 100644 --- a/forge-gui/src/main/java/forge/player/GamePlayerUtil.java +++ b/forge-gui/src/main/java/forge/player/GamePlayerUtil.java @@ -1,9 +1,5 @@ package forge.player; -import java.util.Set; - -import org.apache.commons.lang3.StringUtils; - import forge.LobbyPlayer; import forge.ai.AIOption; import forge.ai.AiProfileUtil; @@ -14,6 +10,9 @@ import forge.model.FModel; import forge.util.GuiDisplayUtil; import forge.util.MyRandom; +import org.apache.commons.lang3.StringUtils; + +import java.util.Set; public final class GamePlayerUtil { private GamePlayerUtil() { } diff --git a/forge-gui/src/main/java/forge/player/HumanPlay.java b/forge-gui/src/main/java/forge/player/HumanPlay.java index 3db1d43a8cc..f6170430ef9 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlay.java +++ b/forge-gui/src/main/java/forge/player/HumanPlay.java @@ -1,37 +1,23 @@ package forge.player; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - import com.google.common.collect.Iterables; import forge.ImageKeys; -import forge.game.ability.AbilityKey; -import forge.game.cost.*; - import forge.card.CardStateName; import forge.card.mana.ManaCost; import forge.game.Game; import forge.game.GameActionUtil; import forge.game.GameEntityView; import forge.game.GameEntityViewMap; +import forge.game.ability.AbilityKey; import forge.game.ability.AbilityUtils; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardPredicates; -import forge.game.card.CardView; -import forge.game.card.CardZoneTable; -import forge.game.card.CounterEnumType; -import forge.game.card.CounterType; +import forge.game.card.*; +import forge.game.cost.*; import forge.game.mana.ManaConversionMatrix; import forge.game.mana.ManaCostBeingPaid; import forge.game.mana.ManaRefundService; import forge.game.player.Player; import forge.game.player.PlayerController; import forge.game.player.PlayerView; - import forge.game.spellability.OptionalCostValue; import forge.game.spellability.SpellAbility; import forge.game.staticability.StaticAbilityManaConvert; @@ -46,6 +32,10 @@ import forge.util.TextUtil; import forge.util.collect.FCollectionView; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + public class HumanPlay { diff --git a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java index 0c7ddab3310..d35f9cc2558 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java +++ b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java @@ -17,11 +17,7 @@ */ package forge.player; -import java.util.Collections; - import com.google.common.collect.Iterables; -import org.apache.commons.lang3.StringUtils; - import forge.card.CardType; import forge.card.MagicColor; import forge.game.Game; @@ -41,6 +37,9 @@ import forge.game.staticability.StaticAbilityManaConvert; import forge.game.zone.Zone; import forge.util.Localizer; +import org.apache.commons.lang3.StringUtils; + +import java.util.Collections; /** *

diff --git a/forge-gui/src/main/java/forge/player/PlayerZoneUpdate.java b/forge-gui/src/main/java/forge/player/PlayerZoneUpdate.java index 7ed01f9f469..ea55414b7b5 100644 --- a/forge-gui/src/main/java/forge/player/PlayerZoneUpdate.java +++ b/forge-gui/src/main/java/forge/player/PlayerZoneUpdate.java @@ -1,12 +1,12 @@ package forge.player; +import forge.game.player.PlayerView; +import forge.game.zone.ZoneType; + import java.io.Serializable; import java.util.EnumSet; import java.util.Set; -import forge.game.player.PlayerView; -import forge.game.zone.ZoneType; - public class PlayerZoneUpdate implements Serializable { private static final long serialVersionUID = -7666875897455073969L; diff --git a/forge-gui/src/main/java/forge/player/PlayerZoneUpdates.java b/forge-gui/src/main/java/forge/player/PlayerZoneUpdates.java index 17f71d1e6e2..9d85e139e0c 100644 --- a/forge-gui/src/main/java/forge/player/PlayerZoneUpdates.java +++ b/forge-gui/src/main/java/forge/player/PlayerZoneUpdates.java @@ -1,14 +1,13 @@ package forge.player; +import com.google.common.collect.Maps; +import forge.game.player.PlayerView; + import java.io.Serializable; import java.util.Collections; import java.util.Iterator; import java.util.Map; -import com.google.common.collect.Maps; - -import forge.game.player.PlayerView; - public class PlayerZoneUpdates implements Iterable, Serializable { private static final long serialVersionUID = 7023549243041119023L; diff --git a/forge-gui/src/main/java/forge/player/RecordActionsMacroSystem.java b/forge-gui/src/main/java/forge/player/RecordActionsMacroSystem.java index b82b783fe0e..972735d341e 100644 --- a/forge-gui/src/main/java/forge/player/RecordActionsMacroSystem.java +++ b/forge-gui/src/main/java/forge/player/RecordActionsMacroSystem.java @@ -8,7 +8,10 @@ import forge.game.player.actions.PassPriorityAction; import forge.game.player.actions.PayManaFromPoolAction; import forge.game.player.actions.PlayerAction; -import forge.gamemodes.match.input.*; +import forge.gamemodes.match.input.Input; +import forge.gamemodes.match.input.InputPassPriority; +import forge.gamemodes.match.input.InputPayMana; +import forge.gamemodes.match.input.InputSelectTargets; import forge.interfaces.IMacroSystem; import forge.util.ITriggerEvent; import forge.util.Localizer; diff --git a/forge-gui/src/main/java/forge/player/TargetSelection.java b/forge-gui/src/main/java/forge/player/TargetSelection.java index 679bb1cdb7e..452e1460b01 100644 --- a/forge-gui/src/main/java/forge/player/TargetSelection.java +++ b/forge-gui/src/main/java/forge/player/TargetSelection.java @@ -17,21 +17,9 @@ */ package forge.player; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Predicate; - import com.google.common.collect.Lists; import com.google.common.collect.Maps; - -import forge.game.Game; -import forge.game.GameEntity; -import forge.game.GameEntityView; -import forge.game.GameEntityViewMap; -import forge.game.GameObject; +import forge.game.*; import forge.game.card.Card; import forge.game.card.CardCollection; import forge.game.card.CardUtil; @@ -50,6 +38,9 @@ import forge.util.IterableUtil; import forge.util.TextUtil; +import java.util.*; +import java.util.function.Predicate; + /** *

* Target_Selection class. diff --git a/forge-gui/src/main/java/forge/sound/EventVisualizer.java b/forge-gui/src/main/java/forge/sound/EventVisualizer.java index 3d83b1d1fb8..09661a72fc1 100644 --- a/forge-gui/src/main/java/forge/sound/EventVisualizer.java +++ b/forge-gui/src/main/java/forge/sound/EventVisualizer.java @@ -1,8 +1,5 @@ package forge.sound; -import java.io.File; -import java.util.Collection; - import forge.LobbyPlayer; import forge.game.card.Card; import forge.game.event.*; @@ -16,6 +13,9 @@ import forge.util.TextUtil; import forge.util.maps.MapOfLists; +import java.io.File; +import java.util.Collection; + /** * This class is in charge of converting any forge.game.event.Event to a SoundEffectType. * diff --git a/forge-gui/src/main/java/forge/util/HttpUtil.java b/forge-gui/src/main/java/forge/util/HttpUtil.java index 3098135faf7..ca0a6d79a5d 100644 --- a/forge-gui/src/main/java/forge/util/HttpUtil.java +++ b/forge-gui/src/main/java/forge/util/HttpUtil.java @@ -17,18 +17,14 @@ */ package forge.util; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; +import forge.localinstance.properties.ForgePreferences; + +import java.io.*; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.Collection; -import forge.localinstance.properties.ForgePreferences; - public class HttpUtil { private static final String BOUNDARY = "--7d021a37605f0"; diff --git a/forge-gui/src/main/java/forge/util/IgnoringXStream.java b/forge-gui/src/main/java/forge/util/IgnoringXStream.java index 7d8ba579e65..e8b5e997818 100644 --- a/forge-gui/src/main/java/forge/util/IgnoringXStream.java +++ b/forge-gui/src/main/java/forge/util/IgnoringXStream.java @@ -1,11 +1,11 @@ package forge.util; -import java.util.ArrayList; -import java.util.List; - import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.mapper.MapperWrapper; +import java.util.ArrayList; +import java.util.List; + /** * TODO: Write javadoc for this type. * diff --git a/forge-gui/src/main/java/forge/util/WordUtil.java b/forge-gui/src/main/java/forge/util/WordUtil.java index 97478c69448..83251e58ec9 100644 --- a/forge-gui/src/main/java/forge/util/WordUtil.java +++ b/forge-gui/src/main/java/forge/util/WordUtil.java @@ -1,10 +1,10 @@ package forge.util; +import org.apache.commons.lang3.StringUtils; + import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.lang3.StringUtils; - public class WordUtil { public static String capitalize(String str) { if (StringUtils.isEmpty(str)) { diff --git a/forge-gui/src/main/java/forge/util/XmlReader.java b/forge-gui/src/main/java/forge/util/XmlReader.java index d918f24ccd1..dff3e35ccfb 100644 --- a/forge-gui/src/main/java/forge/util/XmlReader.java +++ b/forge-gui/src/main/java/forge/util/XmlReader.java @@ -1,21 +1,19 @@ package forge.util; -import java.io.File; -import java.util.Collection; -import java.util.EnumMap; -import java.util.Map; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - +import forge.card.CardDb; +import forge.item.PaperCard; +import forge.util.XmlWriter.IXmlWritable; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import forge.card.CardDb; -import forge.item.PaperCard; -import forge.util.XmlWriter.IXmlWritable; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.File; +import java.util.Collection; +import java.util.EnumMap; +import java.util.Map; public class XmlReader { private Element currentElement; diff --git a/forge-gui/src/main/java/forge/util/XmlUtil.java b/forge-gui/src/main/java/forge/util/XmlUtil.java index e15a4cb7ad3..4d04a0166a6 100644 --- a/forge-gui/src/main/java/forge/util/XmlUtil.java +++ b/forge-gui/src/main/java/forge/util/XmlUtil.java @@ -17,8 +17,9 @@ */ package forge.util; -import java.io.File; -import java.io.StringWriter; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; @@ -26,10 +27,8 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; +import java.io.File; +import java.io.StringWriter; public class XmlUtil { diff --git a/forge-gui/src/main/java/forge/util/XmlWriter.java b/forge-gui/src/main/java/forge/util/XmlWriter.java index 3c6cddcaaf6..b15c6bdfa5f 100644 --- a/forge-gui/src/main/java/forge/util/XmlWriter.java +++ b/forge-gui/src/main/java/forge/util/XmlWriter.java @@ -1,19 +1,17 @@ package forge.util; +import forge.item.PaperCard; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; import java.util.EnumMap; import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; import java.util.Stack; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import forge.item.PaperCard; - public class XmlWriter { private final Document document; private final String filename; diff --git a/forge-lda/src/forge/lda/dataset/BagOfWords.java b/forge-lda/src/forge/lda/dataset/BagOfWords.java index f800c2fdddc..d425b931df2 100644 --- a/forge-lda/src/forge/lda/dataset/BagOfWords.java +++ b/forge-lda/src/forge/lda/dataset/BagOfWords.java @@ -24,7 +24,9 @@ import forge.util.storage.IStorage; import forge.util.storage.StorageImmediatelySerialized; -import java.io.*; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; import java.util.*; /** diff --git a/forge-lda/src/forge/lda/lda/inference/Inference.java b/forge-lda/src/forge/lda/lda/inference/Inference.java index 89b6ffdf2d1..b17b40febf0 100644 --- a/forge-lda/src/forge/lda/lda/inference/Inference.java +++ b/forge-lda/src/forge/lda/lda/inference/Inference.java @@ -16,12 +16,11 @@ package forge.lda.lda.inference; -import java.util.List; - import forge.lda.lda.LDA; - import org.apache.commons.lang3.tuple.Pair; +import java.util.List; + public interface Inference { /** * Set up for inference. diff --git a/forge-lda/src/forge/lda/lda/inference/internal/CollapsedGibbsSampler.java b/forge-lda/src/forge/lda/lda/inference/internal/CollapsedGibbsSampler.java index 60f969fecc4..6064ee8baab 100644 --- a/forge-lda/src/forge/lda/lda/inference/internal/CollapsedGibbsSampler.java +++ b/forge-lda/src/forge/lda/lda/inference/internal/CollapsedGibbsSampler.java @@ -16,19 +16,17 @@ package forge.lda.lda.inference.internal; -import java.util.Arrays; -import java.util.List; -import java.util.stream.IntStream; - +import forge.lda.dataset.Vocabulary; import forge.lda.lda.LDA; import forge.lda.lda.inference.Inference; import forge.lda.lda.inference.InferenceProperties; - import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.math3.distribution.EnumeratedIntegerDistribution; import org.apache.commons.math3.distribution.IntegerDistribution; -import forge.lda.dataset.Vocabulary; +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; public class CollapsedGibbsSampler implements Inference { private LDA lda; From 474be7bd67d4ab0c8f47a15c8b54acce34c76d69 Mon Sep 17 00:00:00 2001 From: Jetz Date: Thu, 26 Sep 2024 12:01:17 -0400 Subject: [PATCH 57/68] Fix ConcurrentModificationException --- .../limited/CardThemedDeckBuilder.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java index a54a2caa3fd..0079384ef58 100644 --- a/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java +++ b/forge-gui/src/main/java/forge/gamemodes/limited/CardThemedDeckBuilder.java @@ -319,17 +319,13 @@ public Deck buildDeck() { //Add remaining non-land colour matching cards to sideboard final CardPool cp = result.getOrCreate(DeckSection.Sideboard); - Iterator potentialSideboard = aiPlayables.stream() - .filter(PaperCardPredicates.fromRules(hasColor.and(CardRulesPredicates.IS_NON_LAND))).iterator(); - int i=0; - while(i<15 && potentialSideboard.hasNext()){ - PaperCard sbCard = potentialSideboard.next(); - cp.add(sbCard); - aiPlayables.remove(sbCard); - rankedColorList.remove(sbCard); - - ++i; - } + List sideboard = aiPlayables.stream() + .filter(PaperCardPredicates.fromRules(hasColor.and(CardRulesPredicates.IS_NON_LAND))) + .limit(15) + .collect(Collectors.toList()); + cp.addAllFlat(sideboard); + aiPlayables.removeAll(sideboard); + rankedColorList.removeAll(sideboard); if (logToConsole) { debugFinalDeck(); } From 2e769ac279e316a3001c676fb67c3f56a7dd4795 Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 29 Sep 2024 11:03:12 -0400 Subject: [PATCH 58/68] Bug fix in RandomReservoir accumulator --- forge-core/src/main/java/forge/util/StreamUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forge-core/src/main/java/forge/util/StreamUtil.java b/forge-core/src/main/java/forge/util/StreamUtil.java index e7eb383e52f..fc464b7aa8f 100644 --- a/forge-core/src/main/java/forge/util/StreamUtil.java +++ b/forge-core/src/main/java/forge/util/StreamUtil.java @@ -95,7 +95,7 @@ public RandomReservoir(int size) { public void accumulate(T next) { sampleCount++; - if(sampleCount < maxSize) { + if(sampleCount <= maxSize) { //Add the first [maxSize] items into the result list samples.add(next); return; From 2d6952f126d3ad0ace0892ebca11e7a3c3612158 Mon Sep 17 00:00:00 2001 From: Jetz Date: Mon, 14 Oct 2024 22:51:16 -0400 Subject: [PATCH 59/68] Swap out lingering use of `Iterables.any` --- forge-game/src/main/java/forge/game/card/CardProperty.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forge-game/src/main/java/forge/game/card/CardProperty.java b/forge-game/src/main/java/forge/game/card/CardProperty.java index b1a8b2d1dd4..6cb152973a5 100644 --- a/forge-game/src/main/java/forge/game/card/CardProperty.java +++ b/forge-game/src/main/java/forge/game/card/CardProperty.java @@ -848,7 +848,7 @@ public static boolean cardHasProperty(Card card, String property, Player sourceC final String restriction = property.split("sharesAllCardTypesWithOther ")[1]; CardCollection list = AbilityUtils.getDefinedCards(source, restriction, spellAbility); list.remove(card); - return Iterables.any(list, CardPredicates.sharesAllCardTypesWith(card)); + return list.anyMatch(CardPredicates.sharesAllCardTypesWith(card)); } else if (property.startsWith("sharesLandTypeWith")) { final String restriction = property.split("sharesLandTypeWith ")[1]; if (!AbilityUtils.getDefinedCards(source, restriction, spellAbility).anyMatch(CardPredicates.sharesLandTypeWith(card))) { From 64609b0867760b9cb65b7b7641e5fb7c8982ebd4 Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 20 Oct 2024 09:26:36 -0400 Subject: [PATCH 60/68] Add some helper methods to StreamUtil; Rewrite `generateParticipants` --- .../src/main/java/forge/util/StreamUtil.java | 24 +++++++++++++++++++ .../adventure/data/AdventureEventData.java | 16 ++++++------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/forge-core/src/main/java/forge/util/StreamUtil.java b/forge-core/src/main/java/forge/util/StreamUtil.java index fc464b7aa8f..3d5f671e2f4 100644 --- a/forge-core/src/main/java/forge/util/StreamUtil.java +++ b/forge-core/src/main/java/forge/util/StreamUtil.java @@ -7,11 +7,35 @@ import java.util.function.Supplier; import java.util.stream.Collector; import java.util.stream.Stream; +import java.util.stream.StreamSupport; public class StreamUtil { private StreamUtil(){} + /** + * @return a Stream with the provided iterable as its source. + * @deprecated Stream collections with {@link Collection#stream()}. + */ + @Deprecated + public static Stream stream(Collection collection) { + return collection.stream(); + } + + /** + * @return a Stream with the provided iterable as its source. + */ + public static Stream stream(Iterable iterable) { + return StreamSupport.stream(iterable.spliterator(), false); + } + + /** + * @return a Stream with the provided array as its source. + */ + public static Stream stream(T[] array) { + return Arrays.stream(array); + } + /** * Reduces a stream to a random element of the stream. Used with {@link Stream#collect}. * Result will be wrapped in an Optional, absent only if the stream is empty. diff --git a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java index 90e36c1c3a0..a9e69ad2a70 100644 --- a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java +++ b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java @@ -2,6 +2,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.utils.Array; +import com.google.common.collect.Iterables; import forge.Forge; import forge.adventure.character.EnemySprite; import forge.adventure.pointofintrest.PointOfInterestChanges; @@ -19,7 +20,9 @@ import forge.model.CardBlock; import forge.model.FModel; import forge.util.Aggregates; +import forge.util.IterableUtil; import forge.util.MyRandom; +import forge.util.StreamUtil; import org.apache.commons.lang3.tuple.Pair; import java.io.Serializable; @@ -429,14 +432,11 @@ public void startEvent() { } public void generateParticipants(int numberOfOpponents) { - participants = new AdventureEventParticipant[numberOfOpponents + 1]; - - List data = Aggregates.random(WorldData.getAllEnemies(), numberOfOpponents); - data.removeIf(q -> q.nextEnemy != null); - for (int i = 0; i < numberOfOpponents; i++) { - participants[i] = new AdventureEventParticipant().generate(data.get(i)); - } - + participants = StreamUtil.stream(WorldData.getAllEnemies()) + .filter(q -> q.nextEnemy == null) + .collect(StreamUtil.random(numberOfOpponents)).stream() + .map(q -> new AdventureEventParticipant().generate(q)) + .toArray(i -> new AdventureEventParticipant[i + 1]); participants[numberOfOpponents] = getHumanPlayer(); } From e52a7b1a539ea84f0e1541cc61e8b96fbc34161d Mon Sep 17 00:00:00 2001 From: Jetz Date: Sun, 20 Oct 2024 09:35:52 -0400 Subject: [PATCH 61/68] Remove unused imports --- forge-game/src/main/java/forge/game/cost/CostUnattach.java | 2 -- .../src/forge/adventure/data/AdventureEventData.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/forge-game/src/main/java/forge/game/cost/CostUnattach.java b/forge-game/src/main/java/forge/game/cost/CostUnattach.java index 2a0b0e56627..97d863b416f 100644 --- a/forge-game/src/main/java/forge/game/cost/CostUnattach.java +++ b/forge-game/src/main/java/forge/game/cost/CostUnattach.java @@ -24,8 +24,6 @@ import forge.game.spellability.SpellAbility; import forge.util.TextUtil; -import java.util.List; - /** * The Class CostUnattach. */ diff --git a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java index a9e69ad2a70..fc9048f2d46 100644 --- a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java +++ b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java @@ -2,7 +2,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.utils.Array; -import com.google.common.collect.Iterables; import forge.Forge; import forge.adventure.character.EnemySprite; import forge.adventure.pointofintrest.PointOfInterestChanges; @@ -20,7 +19,6 @@ import forge.model.CardBlock; import forge.model.FModel; import forge.util.Aggregates; -import forge.util.IterableUtil; import forge.util.MyRandom; import forge.util.StreamUtil; import org.apache.commons.lang3.tuple.Pair; From c9ba926f45218f605659af865d1b2390cf44c776 Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 8 Nov 2024 19:20:53 -0500 Subject: [PATCH 62/68] Guava migration - Replace `.negate()` with `Predicate.not(...)` in compound predicates. --- forge-ai/src/main/java/forge/ai/AiController.java | 3 ++- forge-ai/src/main/java/forge/ai/ComputerUtil.java | 2 +- forge-ai/src/main/java/forge/ai/ComputerUtilCost.java | 5 +++-- forge-ai/src/main/java/forge/ai/ability/AttachAi.java | 8 +++++--- forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java | 2 +- .../src/main/java/forge/ai/ability/ChooseSourceAi.java | 6 ++++-- forge-ai/src/main/java/forge/ai/ability/MutateAi.java | 5 +++-- .../src/main/java/forge/card/CardRulesPredicates.java | 4 ++-- .../java/forge/game/combat/AttackRestrictionType.java | 2 +- .../java/forge/gamemodes/net/server/FServerManager.java | 2 +- .../src/main/java/forge/gamemodes/quest/BoosterUtils.java | 7 +++---- 11 files changed, 26 insertions(+), 20 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index 8d088010cd6..ff7935b7828 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -1579,7 +1579,8 @@ private SpellAbility chooseSpellAbilityToPlayFromList(final List a if (sa.getHostCard().hasKeyword(Keyword.STORM) && sa.getApi() != ApiType.Counter // AI would suck at trying to deliberately proc a Storm counterspell && player.getZone(ZoneType.Hand).contains( - CardPredicates.LANDS.or(CardPredicates.hasKeyword("Storm")).negate())) { + Predicate.not(CardPredicates.LANDS.or(CardPredicates.hasKeyword("Storm"))) + )) { if (game.getView().getStormCount() < this.getIntProperty(AiProps.MIN_COUNT_FOR_STORM_SPELLS)) { // skip evaluating Storm unless we reached the minimum Storm count continue; diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtil.java b/forge-ai/src/main/java/forge/ai/ComputerUtil.java index a5b10e128a3..a231d00c305 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtil.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtil.java @@ -2438,7 +2438,7 @@ public static CardCollection getCardsToDiscardFromOpponent(Player chooser, Playe int minDiff = min - goodChoices.size(); if (minDiff > 0) { List choices = validCards.stream() - .filter(((Predicate) goodChoices::contains).negate()) + .filter(Predicate.not(goodChoices::contains)) .collect(StreamUtil.random(minDiff)); goodChoices.addAll(choices); return goodChoices; diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java index 9b9415a9df0..5ed95f81d32 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCost.java @@ -29,6 +29,7 @@ import java.util.List; import java.util.Set; +import java.util.function.Predicate; public class ComputerUtilCost { @@ -921,8 +922,8 @@ public static int getMaxXValue(SpellAbility sa, Player ai, final boolean effect) public static CardCollection paymentChoicesWithoutTargets(Iterable choices, SpellAbility source, Player ai) { if (source.usesTargeting()) { - final CardCollection targets = new CardCollection(source.getTargets().getTargetCards()); - choices = IterableUtil.filter(choices, CardPredicates.isController(ai).and(targets::contains).negate()); + final CardCollectionView targets = source.getTargets().getTargetCards(); + choices = IterableUtil.filter(choices, Predicate.not(CardPredicates.isController(ai).and(targets::contains))); } return new CardCollection(choices); } diff --git a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java index ed70ffd99e5..61c4e70eb21 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AttachAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AttachAi.java @@ -34,6 +34,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.function.Predicate; public class AttachAi extends SpellAbilityAi { @@ -1132,9 +1133,10 @@ private static Card attachAIPumpPreference(final Player ai, final SpellAbility s //some auras/equipments aren't useful in multiples if (attachSource.hasSVar("NonStackingAttachEffect")) { - prefList = CardLists.filter(prefList, CardPredicates.isEquippedBy(attachSource.getName()) - .or(CardPredicates.isEnchantedBy(attachSource.getName())).negate() - ); + prefList = CardLists.filter(prefList, Predicate.not( + CardPredicates.isEquippedBy(attachSource.getName()) + .or(CardPredicates.isEnchantedBy(attachSource.getName())) + )); } // Don't pump cards that will die. diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java index 3f79d0df6db..c211df16fc6 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseCardAi.java @@ -1,8 +1,8 @@ package forge.ai.ability; import com.google.common.collect.Iterables; -import forge.ai.*; import com.google.common.collect.Lists; +import forge.ai.*; import forge.game.Game; import forge.game.card.*; import forge.game.combat.Combat; diff --git a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java index 9e16b6bb3bf..a3a2cc489b7 100644 --- a/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/ChooseSourceAi.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.Map; +import java.util.function.Predicate; public class ChooseSourceAi extends SpellAbilityAi { @@ -133,8 +134,9 @@ public Card chooseSingleCard(final Player aiChoser, SpellAbility sa, Iterable oppCreatures = CardLists.filter(options, - CardPredicates.CREATURES.and(CardPredicates.isOwner(aiChoser).negate())); + List oppCreatures = CardLists.filter(options, Predicate.not( + CardPredicates.CREATURES.and(CardPredicates.isOwner(aiChoser)) + )); List aiNonCreatures = CardLists.filter(options, CardPredicates.NON_CREATURES .and(CardPredicates.PERMANENTS) diff --git a/forge-ai/src/main/java/forge/ai/ability/MutateAi.java b/forge-ai/src/main/java/forge/ai/ability/MutateAi.java index 432c86584fc..73c644b84fc 100644 --- a/forge-ai/src/main/java/forge/ai/ability/MutateAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/MutateAi.java @@ -13,6 +13,7 @@ import forge.game.spellability.SpellAbility; import java.util.Map; +import java.util.function.Predicate; public class MutateAi extends SpellAbilityAi { @Override @@ -22,12 +23,12 @@ protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { // Filter out some abilities that are useless // TODO: add other stuff useless for Mutate here - mutateTgts = CardLists.filter(mutateTgts, + mutateTgts = CardLists.filter(mutateTgts, Predicate.not( CardPredicates.hasKeyword(Keyword.DEFENDER) .or(CardPredicates.hasKeyword("CARDNAME can't attack.")) .or(CardPredicates.hasKeyword("CARDNAME can't block.")) .or(card -> ComputerUtilCard.isUselessCreature(aiPlayer, card)) - .negate() + ) ); if (mutateTgts.isEmpty()) { diff --git a/forge-core/src/main/java/forge/card/CardRulesPredicates.java b/forge-core/src/main/java/forge/card/CardRulesPredicates.java index a8e2c9fe4a5..838587234fc 100644 --- a/forge-core/src/main/java/forge/card/CardRulesPredicates.java +++ b/forge-core/src/main/java/forge/card/CardRulesPredicates.java @@ -468,9 +468,9 @@ private boolean op(final int op1, final int op2) { public static final Predicate IS_INSTANT = CardRulesPredicates.coreType(CardType.CoreType.Instant); public static final Predicate IS_SORCERY = CardRulesPredicates.coreType(CardType.CoreType.Sorcery); public static final Predicate IS_ENCHANTMENT = CardRulesPredicates.coreType(CardType.CoreType.Enchantment); - public static final Predicate IS_NON_CREATURE_SPELL = ( + public static final Predicate IS_NON_CREATURE_SPELL = Predicate.not( CardRulesPredicates.IS_CREATURE.or(CardRulesPredicates.IS_LAND).or(CardRules::isVariant) - ).negate(); + ); public static final Predicate IS_PLANE = CardRulesPredicates.coreType(CardType.CoreType.Plane); public static final Predicate IS_PHENOMENON = CardRulesPredicates.coreType(CardType.CoreType.Phenomenon); diff --git a/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java b/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java index 71eadf7c134..de7bfaf33ad 100644 --- a/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java +++ b/forge-game/src/main/java/forge/game/combat/AttackRestrictionType.java @@ -22,7 +22,7 @@ public Predicate getPredicate(final Card attacker) { case NEED_BLACK_OR_GREEN: return CardPredicates.isColor((byte) (MagicColor.BLACK | MagicColor.GREEN)) // may explicitly not be black/green itself - .and(((Predicate) attacker::equals).negate()); + .and(Predicate.not(attacker::equals)); case NOT_ALONE: return x -> true; default: diff --git a/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java b/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java index c42f07a4fb4..39bdcf72149 100644 --- a/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java +++ b/forge-gui/src/main/java/forge/gamemodes/net/server/FServerManager.java @@ -147,7 +147,7 @@ public void broadcastExcept(final NetEvent event, final RemoteClient notTo) { broadcastExcept(event, Collections.singleton(notTo)); } public void broadcastExcept(final NetEvent event, final Collection notTo) { - Predicate filter = ((Predicate) notTo::contains).negate(); + Predicate filter = Predicate.not(notTo::contains); broadcastTo(event, IterableUtil.filter(clients.values(), filter)); } private void broadcastTo(final NetEvent event, final Iterable to) { diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java index 0f74413be48..d045062cf66 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/BoosterUtils.java @@ -59,15 +59,14 @@ public final class BoosterUtils { private static final Predicate filterStandard = CardEdition.Predicates.CAN_MAKE_BOOSTER.and(formats.getStandard().editionLegalPredicate); private static final Predicate filterPioneerNotStandard = CardEdition.Predicates.CAN_MAKE_BOOSTER - .and(filterPioneer - .and(formats.getStandard().editionLegalPredicate.negate())); + .and(filterPioneer.and(Predicate.not(formats.getStandard().editionLegalPredicate))); private static final Predicate filterModernNotPioneer = CardEdition.Predicates.CAN_MAKE_BOOSTER - .and(filterModern.and(filterPioneer.negate())); + .and(filterModern.and(Predicate.not(filterPioneer))); /** The filter not ext. */ private static final Predicate filterNotModern = CardEdition.Predicates.CAN_MAKE_BOOSTER - .and(filterModern.negate()); + .and(Predicate.not(filterModern)); /** * Gets the quest starter deck. From 7bb8ccd0226e47c9dedf2cd3bc082436ed35fbe0 Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 8 Nov 2024 19:23:28 -0500 Subject: [PATCH 63/68] Remove unused imports --- .../main/java/forge/download/AutoUpdater.java | 31 +++---------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/forge-gui/src/main/java/forge/download/AutoUpdater.java b/forge-gui/src/main/java/forge/download/AutoUpdater.java index 57786f7e69a..9dff1d5c6a7 100644 --- a/forge-gui/src/main/java/forge/download/AutoUpdater.java +++ b/forge-gui/src/main/java/forge/download/AutoUpdater.java @@ -1,37 +1,12 @@ package forge.download; -import java.awt.Desktop; -import java.io.File; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.MalformedURLException; -import java.net.Socket; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.swing.SwingUtilities; - -import org.apache.commons.lang3.StringUtils; - import com.google.common.collect.ImmutableList; import forge.gui.GuiBase; import forge.gui.download.GuiDownloadZipService; import forge.gui.util.SOptionPane; import forge.localinstance.properties.ForgePreferences; import forge.model.FModel; -import forge.util.BuildInfo; -import forge.util.FileUtil; -import forge.util.Localizer; -import forge.util.TextUtil; -import forge.util.WaitCallback; +import forge.util.*; import org.apache.commons.lang3.StringUtils; import javax.swing.*; @@ -39,7 +14,11 @@ import java.io.File; import java.io.IOException; import java.net.*; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import java.util.regex.Matcher; import java.util.regex.Pattern; From 4bbc165460cbe87a32eb4227f5b4fda26959d9f9 Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 8 Nov 2024 19:33:45 -0500 Subject: [PATCH 64/68] Guava migration - Use `.toList()` --- .../main/java/forge/adventure/editor/QuestController.java | 6 +++--- forge-core/src/main/java/forge/card/CardDb.java | 2 +- .../src/main/java/forge/game/card/TokenCreateTable.java | 2 +- .../src/forge/adventure/character/EnemySprite.java | 2 +- .../src/forge/adventure/data/AdventureEventData.java | 2 +- .../src/forge/adventure/data/AdventureQuestStage.java | 2 +- .../src/forge/adventure/scene/SpellSmithScene.java | 2 +- .../src/forge/adventure/util/AdventureQuestController.java | 4 ++-- forge-gui-mobile/src/forge/adventure/util/CardUtil.java | 2 +- .../main/java/forge/deck/CardRelationMatrixGenerator.java | 2 +- .../java/forge/gamemodes/limited/CardThemedDeckBuilder.java | 6 +++--- .../java/forge/gamemodes/quest/QuestUtilUnlockSets.java | 4 ++-- .../src/main/java/forge/player/PlayerControllerHuman.java | 4 ++-- forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java | 2 +- 14 files changed, 21 insertions(+), 21 deletions(-) diff --git a/adventure-editor/src/main/java/forge/adventure/editor/QuestController.java b/adventure-editor/src/main/java/forge/adventure/editor/QuestController.java index 00e35bdaa31..ffd9e16c29e 100644 --- a/adventure-editor/src/main/java/forge/adventure/editor/QuestController.java +++ b/adventure-editor/src/main/java/forge/adventure/editor/QuestController.java @@ -51,7 +51,7 @@ public DefaultListModel getEnemyTags(){ toReturn.addElement(enemyTags.get(i)); } - List sortedObjects = Arrays.stream(toReturn.toArray()).sorted().collect(Collectors.toList()); + List sortedObjects = Arrays.stream(toReturn.toArray()).sorted().toList(); toReturn.clear(); @@ -69,7 +69,7 @@ public DefaultListModel getPOITags(){ toReturn.addElement(POITags.get(i)); } - List sortedObjects = Arrays.stream(toReturn.toArray()).sorted().collect(Collectors.toList()); + List sortedObjects = Arrays.stream(toReturn.toArray()).sorted().toList(); toReturn.clear(); @@ -89,7 +89,7 @@ public DefaultListModel getSourceTags(){ toReturn.addElement(questSourceTags.get(i)); } - List sortedObjects = Arrays.stream(toReturn.toArray()).sorted().collect(Collectors.toList()); + List sortedObjects = Arrays.stream(toReturn.toArray()).sorted().toList(); toReturn.clear(); diff --git a/forge-core/src/main/java/forge/card/CardDb.java b/forge-core/src/main/java/forge/card/CardDb.java index d7894cf612e..a0d503716d2 100644 --- a/forge-core/src/main/java/forge/card/CardDb.java +++ b/forge-core/src/main/java/forge/card/CardDb.java @@ -283,7 +283,7 @@ private boolean addFromSetByName(String cardName, CardEdition ed, CardRules cr) if (cr.hasFunctionalVariants()) { cardsInSet = cardsInSet.stream().filter(c -> StringUtils.isEmpty(c.functionalVariantName) || cr.getSupportedFunctionalVariants().contains(c.functionalVariantName) - ).collect(Collectors.toList()); + ).toList(); } if (cardsInSet.isEmpty()) return false; diff --git a/forge-game/src/main/java/forge/game/card/TokenCreateTable.java b/forge-game/src/main/java/forge/game/card/TokenCreateTable.java index 64b84ff5981..71154a96426 100644 --- a/forge-game/src/main/java/forge/game/card/TokenCreateTable.java +++ b/forge-game/src/main/java/forge/game/card/TokenCreateTable.java @@ -48,7 +48,7 @@ public int getFilterAmount(String validOwner, String validToken, final CardTrait if (validOwner != null) { Predicate restriction = GameObjectPredicates.restriction(validOwner.split(","), host.getController(), host, ctb); - filteredPlayer = rowKeySet().stream().filter(restriction).collect(Collectors.toList()); + filteredPlayer = rowKeySet().stream().filter(restriction).toList(); if (filteredPlayer.isEmpty()) { return 0; } diff --git a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java index b8ad177eef1..669416668c4 100644 --- a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java +++ b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java @@ -447,7 +447,7 @@ public Array getRewards() { if (Current.latestDeck() != null) { List paperCardList = Current.latestDeck().getMain().toFlatList().stream() .filter(paperCard -> !paperCard.isVeryBasicLand() && !paperCard.getName().startsWith("Mox")) - .collect(Collectors.toList()); + .toList(); //random uncommons from deck List uncommonCards = paperCardList.stream() .filter(paperCard -> CardRarity.Uncommon.equals(paperCard.getRarity()) || CardRarity.Special.equals(paperCard.getRarity())) diff --git a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java index d65b0a4d0c6..16f892d49ae 100644 --- a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java +++ b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java @@ -326,7 +326,7 @@ private CardBlock pickWeightedCardBlock() { Iterable src = FModel.getBlocks(); //all blocks Predicate filter = CardEdition.Predicates.CAN_MAKE_BOOSTER.and(selectSetPool()); List allEditions = new ArrayList<>(); - StreamSupport.stream(editions.spliterator(), false).filter(filter).filter(CardEdition::hasBoosterTemplate).collect(Collectors.toList()).iterator().forEachRemaining(allEditions::add); + StreamSupport.stream(editions.spliterator(), false).filter(filter).filter(CardEdition::hasBoosterTemplate).toList().iterator().forEachRemaining(allEditions::add); //Temporary restriction until rewards are more diverse - don't want to award restricted cards so these editions need different rewards added. List restrictedDrafts = new ArrayList<>(); diff --git a/forge-gui-mobile/src/forge/adventure/data/AdventureQuestStage.java b/forge-gui-mobile/src/forge/adventure/data/AdventureQuestStage.java index 3afbae2914b..0cb84b6ac65 100644 --- a/forge-gui-mobile/src/forge/adventure/data/AdventureQuestStage.java +++ b/forge-gui-mobile/src/forge/adventure/data/AdventureQuestStage.java @@ -166,7 +166,7 @@ public boolean checkIfTargetLocation(PointOfInterest locationToCheck) { return worldMapOK; } if (targetPOI == null) { - List enteredTags = Arrays.stream(locationToCheck.getData().questTags).collect(Collectors.toList()); + List enteredTags = Arrays.stream(locationToCheck.getData().questTags).toList(); for (String tag : POITags) { if (!enteredTags.contains(tag)) { return false; diff --git a/forge-gui-mobile/src/forge/adventure/scene/SpellSmithScene.java b/forge-gui-mobile/src/forge/adventure/scene/SpellSmithScene.java index 47a2da761d6..e7768de261d 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/SpellSmithScene.java +++ b/forge-gui-mobile/src/forge/adventure/scene/SpellSmithScene.java @@ -163,7 +163,7 @@ public void loadEditions() { return false; } List it = StreamSupport.stream(RewardData.getAllCards().spliterator(), false) - .filter(input2 -> input2.getEdition().equals(input.getCode())).collect(Collectors.toList()); + .filter(input2 -> input2.getEdition().equals(input.getCode())).toList(); if (it.size() == 0) return false; ConfigData configData = Config.instance().getConfigData(); diff --git a/forge-gui-mobile/src/forge/adventure/util/AdventureQuestController.java b/forge-gui-mobile/src/forge/adventure/util/AdventureQuestController.java index ed19393732f..4181be1b1b2 100644 --- a/forge-gui-mobile/src/forge/adventure/util/AdventureQuestController.java +++ b/forge-gui-mobile/src/forge/adventure/util/AdventureQuestController.java @@ -40,7 +40,7 @@ public List getExtraQuestSpawns(float difficultyFactor){ continue; } for (EnemyData enemy : WorldData.getAllEnemies()) { - List candidateTags = Arrays.stream(enemy.questTags).collect(Collectors.toList()); + List candidateTags = Arrays.stream(enemy.questTags).toList(); boolean match = true; for (String targetTag : c.enemyTags) { if (!candidateTags.contains(targetTag)) { @@ -73,7 +73,7 @@ public Map getBoostedSpawns(List localSpawns, float to List toBoost = new ArrayList<>(); if (c.mixedEnemies){ for (EnemyData enemy : localSpawns){ - List candidateTags = Arrays.stream(enemy.questTags).collect(Collectors.toList()); + List candidateTags = Arrays.stream(enemy.questTags).toList(); boolean match = true; for (String targetTag : c.enemyTags) { if (!candidateTags.contains(targetTag)) { diff --git a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java index f1e87bb344d..d9ecd15c99c 100644 --- a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java +++ b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java @@ -820,7 +820,7 @@ public static PaperCard getCardByNameAndEdition(String cardName, String edition) ? FModel.getMagicDb().getCommonCards().getAllCards(cardName) : FModel.getMagicDb().getCommonCards().getUniqueCardsNoAlt(cardName); List validCards = cardPool.stream() - .filter(input -> input.getEdition().equals(edition)).collect(Collectors.toList()); + .filter(input -> input.getEdition().equals(edition)).toList(); if (validCards.isEmpty()) { System.err.println("Unexpected behavior: tried to call getCardByNameAndEdition for card " + cardName + " from the edition " + edition + ", but didn't find it in the DB. A random existing instance will be returned."); diff --git a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java index a32f1a21bf7..0ef0ecaa380 100644 --- a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java @@ -147,7 +147,7 @@ public static HashMap>> initializeComma } //filter to just legal commanders - List legends = cardList.stream().filter(format.isLegalCommanderPredicate()).collect(Collectors.toList()); + List legends = cardList.stream().filter(format.isLegalCommanderPredicate()).toList(); //generate lookups for legends to link commander names to matrix rows for (int i=0; i keyCardList = aiPlayables.stream() .filter(PaperCardPredicates.name(secondKeyCard.getName())) - .collect(Collectors.toList()); + .toList(); deckList.addAll(keyCardList); aiPlayables.removeAll(keyCardList); rankedColorList.removeAll(keyCardList); @@ -418,7 +418,7 @@ protected void addLandKeyCards(){ if(secondKeyCard!=null && secondKeyCard.getRules().getMainPart().getType().isLand()) { final List keyCardList = aiPlayables.stream() .filter(PaperCardPredicates.name(secondKeyCard.getName())) - .collect(Collectors.toList()); + .toList(); deckList.addAll(keyCardList); aiPlayables.removeAll(keyCardList); rankedColorList.removeAll(keyCardList); @@ -443,7 +443,7 @@ public boolean test(CardRules subject) { * If evolving wilds is in the deck and there are fewer than 4 spaces for basic lands - remove evolving wilds */ protected void checkEvolvingWilds(){ - List evolvingWilds = deckList.stream().filter(PaperCardPredicates.name("Evolving Wilds")).collect(Collectors.toList()); + List evolvingWilds = deckList.stream().filter(PaperCardPredicates.name("Evolving Wilds")).toList(); if((evolvingWilds.size()>0 && landsNeeded<4 ) || colors.countColors()<2){ deckList.removeAll(evolvingWilds); landsNeeded=landsNeeded+evolvingWilds.size(); diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java index c5fc3c3a899..5e15869d336 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java @@ -140,12 +140,12 @@ private static List getUnlockableEditions(final QuestController qDa // Sort current sets by date List allowedSets = qData.getFormat().getAllowedSetCodes().stream() .map(editions::get) - .sorted().collect(Collectors.toList()); + .sorted().toList(); // Sort unlockable sets by date List excludedSets = qData.getFormat().getLockedSets().stream() .map(editions::get) - .sorted().collect(Collectors.toList()); + .sorted().toList(); // get a number of sets between an excluded and any included set List> excludedWithDistances = new ArrayList<>(); diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index bbad8fa0a50..cff4a28c35f 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -1885,7 +1885,7 @@ public ReplacementEffect chooseSingleReplacementEffect(final List res = possibleReplacers.stream().map(ReplacementEffect::toString).collect(Collectors.toList()); + final List res = possibleReplacers.stream().map(ReplacementEffect::toString).toList(); final String firstStr = res.get(0); final String prompt = localizer.getMessage("lblChooseFirstApplyReplacementEffect"); for (int i = 1; i < res.size(); i++) { @@ -1907,7 +1907,7 @@ public StaticAbility chooseSingleStaticAbility(final String prompt, final List sts = possibleStatics.stream().map(StaticAbility::toString).collect(Collectors.toList()); + final List sts = possibleStatics.stream().map(StaticAbility::toString).toList(); final String firstStr = sts.get(0); for (int i = 1; i < sts.size(); i++) { // prompt user if there are multiple different options diff --git a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java index 50d0b688af2..67c82ccba9a 100644 --- a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java +++ b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java @@ -304,7 +304,7 @@ public static HashMap>> initializeComma //filter to just legal commanders List legends = cardList.stream() .filter(PaperCardPredicates.fromRules(DeckFormat.Commander::isLegalCommander)) - .collect(Collectors.toList()); + .toList(); //generate lookups for legends to link commander names to matrix rows for (int i=0; i Date: Fri, 8 Nov 2024 19:34:02 -0500 Subject: [PATCH 65/68] Guava migration - Use `Arrays.stream()` --- .../src/main/java/forge/adventure/editor/RewardEdit.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adventure-editor/src/main/java/forge/adventure/editor/RewardEdit.java b/adventure-editor/src/main/java/forge/adventure/editor/RewardEdit.java index 6d7976b53de..a0a0274ea6e 100644 --- a/adventure-editor/src/main/java/forge/adventure/editor/RewardEdit.java +++ b/adventure-editor/src/main/java/forge/adventure/editor/RewardEdit.java @@ -25,10 +25,10 @@ public class RewardEdit extends FormPanel { TextListEdit colors =new TextListEdit(new String[] { "White", "Blue", "Black", "Red", "Green" }); TextListEdit rarity =new TextListEdit(new String[] { "Basic Land", "Common", "Uncommon", "Rare", "Mythic Rare" }); TextListEdit subTypes =new TextListEdit(); - TextListEdit cardTypes =new TextListEdit(Arrays.asList(CardType.CoreType.values()).stream().map(CardType.CoreType::toString).toArray(String[]::new)); - TextListEdit superTypes =new TextListEdit(Arrays.asList(CardType.Supertype.values()).stream().map(CardType.Supertype::toString).toArray(String[]::new)); + TextListEdit cardTypes =new TextListEdit(Arrays.stream(CardType.CoreType.values()).map(CardType.CoreType::toString).toArray(String[]::new)); + TextListEdit superTypes =new TextListEdit(Arrays.stream(CardType.Supertype.values()).map(CardType.Supertype::toString).toArray(String[]::new)); TextListEdit manaCosts =new TextListEdit(); - TextListEdit keyWords =new TextListEdit(Arrays.asList(Keyword.values()).stream().map(Keyword::toString).toArray(String[]::new)); + TextListEdit keyWords =new TextListEdit(Arrays.stream(Keyword.values()).map(Keyword::toString).toArray(String[]::new)); JComboBox colorType =new JComboBox(new String[] { "Any", "Colorless", "MultiColor", "MonoColor"}); JTextField cardText =new JTextField(); private boolean updating=false; From c6ad1226b0d33ea6b34ba8f978a1289f543dd7ee Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 8 Nov 2024 19:49:03 -0500 Subject: [PATCH 66/68] Guava migration - Swap in `StreamUtil.stream` --- .../main/java/forge/game/player/Player.java | 3 +-- .../adventure/data/AdventureEventData.java | 6 ++++-- .../forge/adventure/scene/SpellSmithScene.java | 18 ++++++++++-------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index 5fbb3ebfe96..43ce1bbaa71 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -63,7 +63,6 @@ import java.util.Map.Entry; import java.util.function.Function; import java.util.stream.Collectors; -import java.util.stream.StreamSupport; /** *

@@ -3968,7 +3967,7 @@ public Player getDeclaresBlockers() { } public List getUnlockedDoors() { - return StreamSupport.stream(getCardsIn(ZoneType.Battlefield).spliterator(), false) + return StreamUtil.stream(getCardsIn(ZoneType.Battlefield)) .filter(Card::isRoom) .map(Card::getUnlockedRoomNames) .flatMap(Collection::stream) diff --git a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java index 16f892d49ae..235be233eba 100644 --- a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java +++ b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java @@ -27,7 +27,6 @@ import java.util.*; import java.util.function.Predicate; import java.util.stream.Collectors; -import java.util.stream.StreamSupport; public class AdventureEventData implements Serializable { private static final long serialVersionUID = 1L; @@ -326,7 +325,10 @@ private CardBlock pickWeightedCardBlock() { Iterable src = FModel.getBlocks(); //all blocks Predicate filter = CardEdition.Predicates.CAN_MAKE_BOOSTER.and(selectSetPool()); List allEditions = new ArrayList<>(); - StreamSupport.stream(editions.spliterator(), false).filter(filter).filter(CardEdition::hasBoosterTemplate).toList().iterator().forEachRemaining(allEditions::add); + StreamUtil.stream(editions) + .filter(filter) + .filter(CardEdition::hasBoosterTemplate) + .forEach(allEditions::add); //Temporary restriction until rewards are more diverse - don't want to award restricted cards so these editions need different rewards added. List restrictedDrafts = new ArrayList<>(); diff --git a/forge-gui-mobile/src/forge/adventure/scene/SpellSmithScene.java b/forge-gui-mobile/src/forge/adventure/scene/SpellSmithScene.java index e7768de261d..5e3aced46fe 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/SpellSmithScene.java +++ b/forge-gui-mobile/src/forge/adventure/scene/SpellSmithScene.java @@ -20,13 +20,15 @@ import forge.card.CardRarity; import forge.item.PaperCard; import forge.model.FModel; +import forge.util.IterableUtil; import forge.util.MyRandom; +import forge.util.StreamUtil; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.*; +import java.util.function.Predicate; import java.util.stream.Collectors; -import java.util.stream.StreamSupport; public class SpellSmithScene extends UIScene { @@ -162,14 +164,14 @@ public void loadEditions() { if (input.getDate().after(Date.from(now.minus(1, ChronoUnit.DAYS)))) return false; } - List it = StreamSupport.stream(RewardData.getAllCards().spliterator(), false) - .filter(input2 -> input2.getEdition().equals(input.getCode())).toList(); - if (it.size() == 0) + String code = input.getCode(); + Predicate test = i -> i.getEdition().equals(code); + if (!IterableUtil.any(RewardData.getAllCards(), test)) return false; ConfigData configData = Config.instance().getConfigData(); if (configData.allowedEditions != null) - return Arrays.asList(configData.allowedEditions).contains(input.getCode()); - return (!Arrays.asList(configData.restrictedEditions).contains(input.getCode())); + return Arrays.asList(configData.allowedEditions).contains(code); + return (!Arrays.asList(configData.restrictedEditions).contains(code)); }).sorted(Comparator.comparing(CardEdition::getName)).collect(Collectors.toList()); } @@ -346,7 +348,7 @@ public void filterResults() { if (B.getValue().getColor().equals(Color.RED)) colorFilter.add("White"); break; } - P = StreamSupport.stream(P.spliterator(), false).filter(input -> { + P = StreamUtil.stream(P).filter(input -> { //L|Basic Land, C|Common, U|Uncommon, R|Rare, M|Mythic Rare, S|Special, N|None if (input == null) return false; final CardEdition cardEdition = FModel.getMagicDb().getEditions().get(edition); @@ -392,7 +394,7 @@ public void filterResults() { } if (cost_low > -1) totalCost *= 2.5f; //And CMC cost multiplier. - cardPool = StreamSupport.stream(P.spliterator(), false).collect(Collectors.toList()); + cardPool = StreamUtil.stream(P).collect(Collectors.toList()); poolSize.setText(((cardPool.size() > 0 ? "[/][FOREST]" : "[/][RED]")) + cardPool.size() + " possible card" + (cardPool.size() != 1 ? "s" : "")); currentPrice = (int) totalCost; currentShardPrice = (int) (totalCost * 0.2f); //Intentionally rounding up via the cast to int From 2b5fc37232f72c148cd65aaed7c0b964865c0284 Mon Sep 17 00:00:00 2001 From: Jetz Date: Fri, 8 Nov 2024 20:02:02 -0500 Subject: [PATCH 67/68] Remove unused imports --- .../src/main/java/forge/adventure/editor/QuestController.java | 1 - forge-game/src/main/java/forge/game/card/TokenCreateTable.java | 1 - .../src/forge/adventure/data/AdventureQuestStage.java | 1 - .../src/forge/adventure/util/AdventureQuestController.java | 1 - forge-gui-mobile/src/forge/adventure/util/CardUtil.java | 1 - .../src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java | 1 - 6 files changed, 6 deletions(-) diff --git a/adventure-editor/src/main/java/forge/adventure/editor/QuestController.java b/adventure-editor/src/main/java/forge/adventure/editor/QuestController.java index ffd9e16c29e..ba029fac853 100644 --- a/adventure-editor/src/main/java/forge/adventure/editor/QuestController.java +++ b/adventure-editor/src/main/java/forge/adventure/editor/QuestController.java @@ -13,7 +13,6 @@ import javax.swing.*; import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; public class QuestController { diff --git a/forge-game/src/main/java/forge/game/card/TokenCreateTable.java b/forge-game/src/main/java/forge/game/card/TokenCreateTable.java index 71154a96426..ec7abf45392 100644 --- a/forge-game/src/main/java/forge/game/card/TokenCreateTable.java +++ b/forge-game/src/main/java/forge/game/card/TokenCreateTable.java @@ -12,7 +12,6 @@ import java.util.List; import java.util.Map; import java.util.function.Predicate; -import java.util.stream.Collectors; public class TokenCreateTable extends ForwardingTable { diff --git a/forge-gui-mobile/src/forge/adventure/data/AdventureQuestStage.java b/forge-gui-mobile/src/forge/adventure/data/AdventureQuestStage.java index 0cb84b6ac65..9ad10a22358 100644 --- a/forge-gui-mobile/src/forge/adventure/data/AdventureQuestStage.java +++ b/forge-gui-mobile/src/forge/adventure/data/AdventureQuestStage.java @@ -12,7 +12,6 @@ import java.io.Serializable; import java.util.*; -import java.util.stream.Collectors; import static forge.adventure.util.AdventureQuestController.ObjectiveTypes.*; import static forge.adventure.util.AdventureQuestController.QuestStatus.*; diff --git a/forge-gui-mobile/src/forge/adventure/util/AdventureQuestController.java b/forge-gui-mobile/src/forge/adventure/util/AdventureQuestController.java index 4181be1b1b2..1cde9ffd3c5 100644 --- a/forge-gui-mobile/src/forge/adventure/util/AdventureQuestController.java +++ b/forge-gui-mobile/src/forge/adventure/util/AdventureQuestController.java @@ -18,7 +18,6 @@ import java.io.Serializable; import java.time.LocalDate; import java.util.*; -import java.util.stream.Collectors; import static forge.adventure.util.AdventureQuestController.QuestStatus.*; diff --git a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java index d9ecd15c99c..07ed4981c6b 100644 --- a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java +++ b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java @@ -27,7 +27,6 @@ import java.util.*; import java.util.function.Predicate; import java.util.regex.Pattern; -import java.util.stream.Collectors; import static forge.adventure.data.RewardData.generateAllCards; diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java index 5e15869d336..6ed888183e4 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java @@ -33,7 +33,6 @@ import org.apache.commons.lang3.tuple.ImmutablePair; import java.util.*; -import java.util.stream.Collectors; /** * This is a helper class for unlocking new sets during a format-limited From d81c5a40cf5af4ddc618f6e5d37fe1eb177859b6 Mon Sep 17 00:00:00 2001 From: Jetz Date: Wed, 13 Nov 2024 09:17:33 -0500 Subject: [PATCH 68/68] Revert `.toList()` for Android compatibility --- .../main/java/forge/adventure/editor/QuestController.java | 7 ++++--- forge-core/src/main/java/forge/card/CardDb.java | 2 +- .../src/main/java/forge/game/card/TokenCreateTable.java | 3 ++- .../src/forge/adventure/character/EnemySprite.java | 2 +- .../src/forge/adventure/data/AdventureQuestStage.java | 3 ++- .../src/forge/adventure/util/AdventureQuestController.java | 5 +++-- forge-gui-mobile/src/forge/adventure/util/CardUtil.java | 3 ++- .../main/java/forge/deck/CardRelationMatrixGenerator.java | 2 +- .../forge/gamemodes/limited/CardThemedDeckBuilder.java | 6 +++--- .../java/forge/gamemodes/quest/QuestUtilUnlockSets.java | 5 +++-- .../src/main/java/forge/player/PlayerControllerHuman.java | 4 ++-- forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java | 2 +- 12 files changed, 25 insertions(+), 19 deletions(-) diff --git a/adventure-editor/src/main/java/forge/adventure/editor/QuestController.java b/adventure-editor/src/main/java/forge/adventure/editor/QuestController.java index ba029fac853..00e35bdaa31 100644 --- a/adventure-editor/src/main/java/forge/adventure/editor/QuestController.java +++ b/adventure-editor/src/main/java/forge/adventure/editor/QuestController.java @@ -13,6 +13,7 @@ import javax.swing.*; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; public class QuestController { @@ -50,7 +51,7 @@ public DefaultListModel getEnemyTags(){ toReturn.addElement(enemyTags.get(i)); } - List sortedObjects = Arrays.stream(toReturn.toArray()).sorted().toList(); + List sortedObjects = Arrays.stream(toReturn.toArray()).sorted().collect(Collectors.toList()); toReturn.clear(); @@ -68,7 +69,7 @@ public DefaultListModel getPOITags(){ toReturn.addElement(POITags.get(i)); } - List sortedObjects = Arrays.stream(toReturn.toArray()).sorted().toList(); + List sortedObjects = Arrays.stream(toReturn.toArray()).sorted().collect(Collectors.toList()); toReturn.clear(); @@ -88,7 +89,7 @@ public DefaultListModel getSourceTags(){ toReturn.addElement(questSourceTags.get(i)); } - List sortedObjects = Arrays.stream(toReturn.toArray()).sorted().toList(); + List sortedObjects = Arrays.stream(toReturn.toArray()).sorted().collect(Collectors.toList()); toReturn.clear(); diff --git a/forge-core/src/main/java/forge/card/CardDb.java b/forge-core/src/main/java/forge/card/CardDb.java index a0d503716d2..d7894cf612e 100644 --- a/forge-core/src/main/java/forge/card/CardDb.java +++ b/forge-core/src/main/java/forge/card/CardDb.java @@ -283,7 +283,7 @@ private boolean addFromSetByName(String cardName, CardEdition ed, CardRules cr) if (cr.hasFunctionalVariants()) { cardsInSet = cardsInSet.stream().filter(c -> StringUtils.isEmpty(c.functionalVariantName) || cr.getSupportedFunctionalVariants().contains(c.functionalVariantName) - ).toList(); + ).collect(Collectors.toList()); } if (cardsInSet.isEmpty()) return false; diff --git a/forge-game/src/main/java/forge/game/card/TokenCreateTable.java b/forge-game/src/main/java/forge/game/card/TokenCreateTable.java index ec7abf45392..64b84ff5981 100644 --- a/forge-game/src/main/java/forge/game/card/TokenCreateTable.java +++ b/forge-game/src/main/java/forge/game/card/TokenCreateTable.java @@ -12,6 +12,7 @@ import java.util.List; import java.util.Map; import java.util.function.Predicate; +import java.util.stream.Collectors; public class TokenCreateTable extends ForwardingTable { @@ -47,7 +48,7 @@ public int getFilterAmount(String validOwner, String validToken, final CardTrait if (validOwner != null) { Predicate restriction = GameObjectPredicates.restriction(validOwner.split(","), host.getController(), host, ctb); - filteredPlayer = rowKeySet().stream().filter(restriction).toList(); + filteredPlayer = rowKeySet().stream().filter(restriction).collect(Collectors.toList()); if (filteredPlayer.isEmpty()) { return 0; } diff --git a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java index 669416668c4..b8ad177eef1 100644 --- a/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java +++ b/forge-gui-mobile/src/forge/adventure/character/EnemySprite.java @@ -447,7 +447,7 @@ public Array getRewards() { if (Current.latestDeck() != null) { List paperCardList = Current.latestDeck().getMain().toFlatList().stream() .filter(paperCard -> !paperCard.isVeryBasicLand() && !paperCard.getName().startsWith("Mox")) - .toList(); + .collect(Collectors.toList()); //random uncommons from deck List uncommonCards = paperCardList.stream() .filter(paperCard -> CardRarity.Uncommon.equals(paperCard.getRarity()) || CardRarity.Special.equals(paperCard.getRarity())) diff --git a/forge-gui-mobile/src/forge/adventure/data/AdventureQuestStage.java b/forge-gui-mobile/src/forge/adventure/data/AdventureQuestStage.java index 9ad10a22358..3afbae2914b 100644 --- a/forge-gui-mobile/src/forge/adventure/data/AdventureQuestStage.java +++ b/forge-gui-mobile/src/forge/adventure/data/AdventureQuestStage.java @@ -12,6 +12,7 @@ import java.io.Serializable; import java.util.*; +import java.util.stream.Collectors; import static forge.adventure.util.AdventureQuestController.ObjectiveTypes.*; import static forge.adventure.util.AdventureQuestController.QuestStatus.*; @@ -165,7 +166,7 @@ public boolean checkIfTargetLocation(PointOfInterest locationToCheck) { return worldMapOK; } if (targetPOI == null) { - List enteredTags = Arrays.stream(locationToCheck.getData().questTags).toList(); + List enteredTags = Arrays.stream(locationToCheck.getData().questTags).collect(Collectors.toList()); for (String tag : POITags) { if (!enteredTags.contains(tag)) { return false; diff --git a/forge-gui-mobile/src/forge/adventure/util/AdventureQuestController.java b/forge-gui-mobile/src/forge/adventure/util/AdventureQuestController.java index 1cde9ffd3c5..ed19393732f 100644 --- a/forge-gui-mobile/src/forge/adventure/util/AdventureQuestController.java +++ b/forge-gui-mobile/src/forge/adventure/util/AdventureQuestController.java @@ -18,6 +18,7 @@ import java.io.Serializable; import java.time.LocalDate; import java.util.*; +import java.util.stream.Collectors; import static forge.adventure.util.AdventureQuestController.QuestStatus.*; @@ -39,7 +40,7 @@ public List getExtraQuestSpawns(float difficultyFactor){ continue; } for (EnemyData enemy : WorldData.getAllEnemies()) { - List candidateTags = Arrays.stream(enemy.questTags).toList(); + List candidateTags = Arrays.stream(enemy.questTags).collect(Collectors.toList()); boolean match = true; for (String targetTag : c.enemyTags) { if (!candidateTags.contains(targetTag)) { @@ -72,7 +73,7 @@ public Map getBoostedSpawns(List localSpawns, float to List toBoost = new ArrayList<>(); if (c.mixedEnemies){ for (EnemyData enemy : localSpawns){ - List candidateTags = Arrays.stream(enemy.questTags).toList(); + List candidateTags = Arrays.stream(enemy.questTags).collect(Collectors.toList()); boolean match = true; for (String targetTag : c.enemyTags) { if (!candidateTags.contains(targetTag)) { diff --git a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java index 07ed4981c6b..f1e87bb344d 100644 --- a/forge-gui-mobile/src/forge/adventure/util/CardUtil.java +++ b/forge-gui-mobile/src/forge/adventure/util/CardUtil.java @@ -27,6 +27,7 @@ import java.util.*; import java.util.function.Predicate; import java.util.regex.Pattern; +import java.util.stream.Collectors; import static forge.adventure.data.RewardData.generateAllCards; @@ -819,7 +820,7 @@ public static PaperCard getCardByNameAndEdition(String cardName, String edition) ? FModel.getMagicDb().getCommonCards().getAllCards(cardName) : FModel.getMagicDb().getCommonCards().getUniqueCardsNoAlt(cardName); List validCards = cardPool.stream() - .filter(input -> input.getEdition().equals(edition)).toList(); + .filter(input -> input.getEdition().equals(edition)).collect(Collectors.toList()); if (validCards.isEmpty()) { System.err.println("Unexpected behavior: tried to call getCardByNameAndEdition for card " + cardName + " from the edition " + edition + ", but didn't find it in the DB. A random existing instance will be returned."); diff --git a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java index 0ef0ecaa380..a32f1a21bf7 100644 --- a/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java +++ b/forge-gui/src/main/java/forge/deck/CardRelationMatrixGenerator.java @@ -147,7 +147,7 @@ public static HashMap>> initializeComma } //filter to just legal commanders - List legends = cardList.stream().filter(format.isLegalCommanderPredicate()).toList(); + List legends = cardList.stream().filter(format.isLegalCommanderPredicate()).collect(Collectors.toList()); //generate lookups for legends to link commander names to matrix rows for (int i=0; i keyCardList = aiPlayables.stream() .filter(PaperCardPredicates.name(secondKeyCard.getName())) - .toList(); + .collect(Collectors.toList()); deckList.addAll(keyCardList); aiPlayables.removeAll(keyCardList); rankedColorList.removeAll(keyCardList); @@ -418,7 +418,7 @@ protected void addLandKeyCards(){ if(secondKeyCard!=null && secondKeyCard.getRules().getMainPart().getType().isLand()) { final List keyCardList = aiPlayables.stream() .filter(PaperCardPredicates.name(secondKeyCard.getName())) - .toList(); + .collect(Collectors.toList()); deckList.addAll(keyCardList); aiPlayables.removeAll(keyCardList); rankedColorList.removeAll(keyCardList); @@ -443,7 +443,7 @@ public boolean test(CardRules subject) { * If evolving wilds is in the deck and there are fewer than 4 spaces for basic lands - remove evolving wilds */ protected void checkEvolvingWilds(){ - List evolvingWilds = deckList.stream().filter(PaperCardPredicates.name("Evolving Wilds")).toList(); + List evolvingWilds = deckList.stream().filter(PaperCardPredicates.name("Evolving Wilds")).collect(Collectors.toList()); if((evolvingWilds.size()>0 && landsNeeded<4 ) || colors.countColors()<2){ deckList.removeAll(evolvingWilds); landsNeeded=landsNeeded+evolvingWilds.size(); diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java index 6ed888183e4..c5fc3c3a899 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java @@ -33,6 +33,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair; import java.util.*; +import java.util.stream.Collectors; /** * This is a helper class for unlocking new sets during a format-limited @@ -139,12 +140,12 @@ private static List getUnlockableEditions(final QuestController qDa // Sort current sets by date List allowedSets = qData.getFormat().getAllowedSetCodes().stream() .map(editions::get) - .sorted().toList(); + .sorted().collect(Collectors.toList()); // Sort unlockable sets by date List excludedSets = qData.getFormat().getLockedSets().stream() .map(editions::get) - .sorted().toList(); + .sorted().collect(Collectors.toList()); // get a number of sets between an excluded and any included set List> excludedWithDistances = new ArrayList<>(); diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index cff4a28c35f..bbad8fa0a50 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -1885,7 +1885,7 @@ public ReplacementEffect chooseSingleReplacementEffect(final List res = possibleReplacers.stream().map(ReplacementEffect::toString).toList(); + final List res = possibleReplacers.stream().map(ReplacementEffect::toString).collect(Collectors.toList()); final String firstStr = res.get(0); final String prompt = localizer.getMessage("lblChooseFirstApplyReplacementEffect"); for (int i = 1; i < res.size(); i++) { @@ -1907,7 +1907,7 @@ public StaticAbility chooseSingleStaticAbility(final String prompt, final List sts = possibleStatics.stream().map(StaticAbility::toString).toList(); + final List sts = possibleStatics.stream().map(StaticAbility::toString).collect(Collectors.toList()); final String firstStr = sts.get(0); for (int i = 1; i < sts.size(); i++) { // prompt user if there are multiple different options diff --git a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java index 67c82ccba9a..50d0b688af2 100644 --- a/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java +++ b/forge-lda/src/main/java/forge/lda/LDAModelGenetrator.java @@ -304,7 +304,7 @@ public static HashMap>> initializeComma //filter to just legal commanders List legends = cardList.stream() .filter(PaperCardPredicates.fromRules(DeckFormat.Commander::isLegalCommander)) - .toList(); + .collect(Collectors.toList()); //generate lookups for legends to link commander names to matrix rows for (int i=0; i