mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Guava migration - Inline Predicates.equalTo
This commit is contained in:
@@ -37,10 +37,4 @@ public class Predicates {
|
||||
//TODO: remove casting?
|
||||
return ((Predicate<T>) 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 <T> Predicate<T> equalTo(T target) {
|
||||
return x -> Objects.equals(target, x);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1150,7 +1150,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
}
|
||||
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")) {
|
||||
|
||||
@@ -399,7 +399,7 @@ public class AttackConstraints {
|
||||
return null;
|
||||
}
|
||||
private static Attack findFirst(final List<Attack> reqs, final Card attacker) {
|
||||
return findFirst(reqs, Predicates.equalTo(attacker));
|
||||
return findFirst(reqs, attacker::equals);
|
||||
}
|
||||
private static Collection<Attack> findAll(final List<Attack> reqs, final Card attacker) {
|
||||
return Collections2.filter(reqs, input -> input.attacker.equals(attacker));
|
||||
|
||||
@@ -24,7 +24,7 @@ public enum AttackRestrictionType {
|
||||
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:
|
||||
|
||||
@@ -20,9 +20,9 @@ package forge.game.trigger;
|
||||
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 class TriggerChangesZone extends Trigger {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user