mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Guava migration - Inline Predicates.not
This commit is contained in:
@@ -367,7 +367,7 @@ public class AiBlockController {
|
||||
* @param combat a {@link forge.game.combat.Combat} object.
|
||||
*/
|
||||
private void makeGangBlocks(final Combat combat) {
|
||||
List<Card> currentAttackers = CardLists.filter(attackersLeft, Predicates.not(rampagesOrNeedsManyToBlock(combat)));
|
||||
List<Card> currentAttackers = CardLists.filter(attackersLeft, rampagesOrNeedsManyToBlock(combat).negate());
|
||||
List<Card> blockers;
|
||||
|
||||
// Try to block an attacker without first strike with a gang of first strikers
|
||||
@@ -739,11 +739,11 @@ public class AiBlockController {
|
||||
List<Card> chumpBlockers;
|
||||
|
||||
List<Card> 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 @@ public class AiBlockController {
|
||||
private void reinforceBlockersToKill(final Combat combat) {
|
||||
List<Card> safeBlockers;
|
||||
List<Card> blockers;
|
||||
List<Card> targetAttackers = CardLists.filter(blockedButUnkilled, Predicates.not(rampagesOrNeedsManyToBlock(combat)));
|
||||
List<Card> 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);
|
||||
|
||||
@@ -404,7 +404,7 @@ public class AiController {
|
||||
|
||||
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 @@ public class AiController {
|
||||
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 @@ public class AiController {
|
||||
}
|
||||
|
||||
// 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 @@ public class AiController {
|
||||
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 @@ public class AiController {
|
||||
|
||||
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;
|
||||
|
||||
@@ -14,7 +14,6 @@ import forge.game.spellability.SpellAbility;
|
||||
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 class AiCostDecision extends CostDecisionMakerBase {
|
||||
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);
|
||||
|
||||
@@ -639,7 +639,7 @@ public class ComputerUtil {
|
||||
// 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 class ComputerUtil {
|
||||
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 class ComputerUtil {
|
||||
// not enough good choices, need to fill the rest
|
||||
int minDiff = min - goodChoices.size();
|
||||
if (minDiff > 0) {
|
||||
goodChoices.addAll(Aggregates.random(CardLists.filter(validCards, Predicates.not(goodChoices::contains)), minDiff));
|
||||
goodChoices.addAll(Aggregates.random(CardLists.filter(validCards, ((Predicate<Card>) goodChoices::contains).negate()), minDiff));
|
||||
return goodChoices;
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ public class ComputerUtilCard {
|
||||
}
|
||||
|
||||
// prefer to target non basic lands
|
||||
final List<Card> nbLand = CardLists.filter(land, Predicates.not(CardPredicates.Presets.BASIC_LANDS));
|
||||
final List<Card> nbLand = CardLists.filter(land, CardPredicates.Presets.BASIC_LANDS.negate());
|
||||
|
||||
if (!nbLand.isEmpty()) {
|
||||
// TODO - Improve ranking various non-basic lands depending on context
|
||||
|
||||
@@ -633,7 +633,7 @@ public class ComputerUtilCost {
|
||||
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 class ComputerUtilCost {
|
||||
public static CardCollection paymentChoicesWithoutTargets(Iterable<Card> choices, SpellAbility source, Player ai) {
|
||||
if (source.usesTargeting()) {
|
||||
final CardCollection targets = new CardCollection(source.getTargets().getTargetCards());
|
||||
choices = Iterables.filter(choices, Predicates.not(Predicates.and(CardPredicates.isController(ai), targets::contains)));
|
||||
choices = Iterables.filter(choices, Predicates.and(CardPredicates.isController(ai), targets::contains).negate());
|
||||
}
|
||||
return new CardCollection(choices);
|
||||
}
|
||||
|
||||
@@ -764,7 +764,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
// 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 class PlayerControllerAi extends PlayerController {
|
||||
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 class PlayerControllerAi extends PlayerController {
|
||||
}
|
||||
} 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();
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class SpecialCardAi {
|
||||
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 class SpecialCardAi {
|
||||
List<Card> AiLandsOnly = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield),
|
||||
CardPredicates.Presets.LANDS);
|
||||
List<Card> 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 @@ public class SpecialCardAi {
|
||||
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 class SpecialCardAi {
|
||||
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 class SpecialCardAi {
|
||||
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 class SpecialCardAi {
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -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 @@ public class AttachAi extends SpellAbilityAi {
|
||||
//some auras aren't useful in multiples
|
||||
if (attachSource.hasSVar("NonStackingAttachEffect")) {
|
||||
prefList = CardLists.filter(prefList,
|
||||
Predicates.not(CardPredicates.isEnchantedBy(attachSource.getName()))
|
||||
CardPredicates.isEnchantedBy(attachSource.getName()).negate()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1143,10 +1144,10 @@ public class AttachAi extends SpellAbilityAi {
|
||||
|
||||
//some auras/equipments aren't useful in multiples
|
||||
if (attachSource.hasSVar("NonStackingAttachEffect")) {
|
||||
prefList = CardLists.filter(prefList, Predicates.not(Predicates.or(
|
||||
prefList = CardLists.filter(prefList, Predicates.or(
|
||||
CardPredicates.isEquippedBy(attachSource.getName()),
|
||||
CardPredicates.isEnchantedBy(attachSource.getName())
|
||||
)));
|
||||
).negate());
|
||||
}
|
||||
|
||||
// Don't pump cards that will die.
|
||||
|
||||
@@ -29,10 +29,10 @@ 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.*;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class ChangeZoneAi extends SpellAbilityAi {
|
||||
/*
|
||||
@@ -371,7 +371,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
|
||||
// remove cards that won't be seen if library can't be searched
|
||||
if (!ai.canSearchLibraryWith(sa, p)) {
|
||||
list = CardLists.filter(list, Predicates.not(CardPredicates.inZone(ZoneType.Library)));
|
||||
list = CardLists.filter(list, CardPredicates.inZone(ZoneType.Library).negate());
|
||||
}
|
||||
|
||||
if (type != null && p == ai) {
|
||||
@@ -614,8 +614,8 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// 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 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (source.isInZone(ZoneType.Hand)) {
|
||||
list = CardLists.filter(list, Predicates.not(CardPredicates.nameEquals(source.getName()))); // Don't get the same card back.
|
||||
Predicate<Card> 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 class ChangeZoneAi extends SpellAbilityAi {
|
||||
}
|
||||
} else {
|
||||
// Don't fetch another tutor with the same name
|
||||
CardCollection sameNamed = CardLists.filter(fetchList, Predicates.not(CardPredicates.nameEquals(ComputerUtilAbility.getAbilitySourceName(sa))));
|
||||
Predicate<Card> 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 class ChangeZoneAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (logic.contains("NonLand")) {
|
||||
scanList = CardLists.filter(scanList, Predicates.not(Presets.LANDS));
|
||||
scanList = CardLists.filter(scanList, Presets.LANDS.negate());
|
||||
}
|
||||
|
||||
if (logic.contains("NonExiled")) {
|
||||
|
||||
@@ -27,7 +27,6 @@ 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 {
|
||||
|
||||
@@ -271,7 +270,7 @@ public class ChooseCardAi extends SpellAbilityAi {
|
||||
} else if (logic.equals("Phylactery")) {
|
||||
CardCollection aiArtifacts = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Presets.ARTIFACTS);
|
||||
CardCollection indestructibles = CardLists.filter(aiArtifacts, CardPredicates.hasKeyword(Keyword.INDESTRUCTIBLE));
|
||||
CardCollection nonCreatures = CardLists.filter(aiArtifacts, Predicates.not(Presets.CREATURES));
|
||||
CardCollection nonCreatures = CardLists.filter(aiArtifacts, Presets.CREATURES.negate());
|
||||
CardCollection creatures = CardLists.filter(aiArtifacts, Presets.CREATURES);
|
||||
if (!indestructibles.isEmpty()) {
|
||||
// Choose the worst (smallest) indestructible artifact so that the opponent would have to waste
|
||||
|
||||
@@ -135,9 +135,9 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
||||
// No optimal creature was found above, so try to broaden the choice.
|
||||
if (!Iterables.isEmpty(options)) {
|
||||
List<Card> oppCreatures = CardLists.filter(options, Predicates.and(CardPredicates.Presets.CREATURES,
|
||||
Predicates.not(CardPredicates.isOwner(aiChoser))));
|
||||
CardPredicates.isOwner(aiChoser).negate()));
|
||||
List<Card> aiNonCreatures = CardLists.filter(options,
|
||||
Predicates.not(CardPredicates.Presets.CREATURES)
|
||||
CardPredicates.Presets.CREATURES.negate()
|
||||
.and(CardPredicates.Presets.PERMANENTS)
|
||||
.and(CardPredicates.isOwner(aiChoser))
|
||||
);
|
||||
|
||||
@@ -18,7 +18,6 @@ import forge.game.player.Player;
|
||||
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 @@ public class CloneAi extends SpellAbilityAi {
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -29,7 +29,6 @@ import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Iterables;
|
||||
import forge.util.Predicates;
|
||||
|
||||
|
||||
/**
|
||||
@@ -64,7 +63,7 @@ public class ControlGainVariantAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
public Card chooseSingleCard(Player ai, SpellAbility sa, Iterable<Card> options, boolean isOptional, Player targetedPlayer, Map<String, Object> params) {
|
||||
Iterable<Card> otherCtrl = CardLists.filter(options, Predicates.not(CardPredicates.isController(ai)));
|
||||
Iterable<Card> otherCtrl = CardLists.filter(options, CardPredicates.isController(ai).negate());
|
||||
if (Iterables.isEmpty(otherCtrl)) {
|
||||
return ComputerUtilCard.getWorstAI(options);
|
||||
} else {
|
||||
|
||||
@@ -3,6 +3,7 @@ package forge.ai.ability;
|
||||
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.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
|
||||
@@ -135,7 +135,8 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
||||
// 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<Card> nameEquals = CardPredicates.nameEquals(host.getName());
|
||||
list = CardLists.filter(list, nameEquals.negate());
|
||||
}
|
||||
|
||||
//Nothing to target
|
||||
@@ -143,7 +144,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
||||
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;
|
||||
|
||||
@@ -24,7 +24,6 @@ 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 {
|
||||
|
||||
@@ -104,7 +103,7 @@ public class CountersMultiplyAi extends SpellAbilityAi {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ 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;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class CountersPutAi extends CountersAi {
|
||||
|
||||
@@ -271,8 +271,9 @@ public class CountersPutAi extends CountersAi {
|
||||
return false;
|
||||
}
|
||||
|
||||
Predicate<Card> 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()) {
|
||||
|
||||
@@ -14,7 +14,8 @@ import forge.game.player.Player;
|
||||
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 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
list = ComputerUtilCard.prioritizeCreaturesWorthRemovingNow(ai, list, false);
|
||||
}
|
||||
if (!playReusable(ai, sa)) {
|
||||
list = CardLists.filter(list, Predicates.not(CardPredicates.hasCounter(CounterEnumType.SHIELD, 1)));
|
||||
Predicate<Card> 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 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
|
||||
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<Card> hasCounter = CardPredicates.hasCounter(CounterEnumType.SHIELD, 1);
|
||||
preferred = CardLists.filter(preferred, hasCounter.negate());
|
||||
if (CardLists.getNotType(preferred, "Creature").isEmpty()) {
|
||||
preferred = ComputerUtilCard.prioritizeCreaturesWorthRemovingNow(ai, preferred, false);
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ public class EffectAi extends SpellAbilityAi {
|
||||
runParams.put(AbilityKey.Regeneration, true);
|
||||
List<ReplacementEffect> 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 @@ public class EffectAi extends SpellAbilityAi {
|
||||
runParams.put(AbilityKey.Regeneration, true);
|
||||
List<ReplacementEffect> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import forge.game.keyword.Keyword;
|
||||
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 @@ public class MutateAi extends SpellAbilityAi {
|
||||
|
||||
// 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;
|
||||
|
||||
@@ -141,10 +141,10 @@ public class PermanentAi extends SpellAbilityAi {
|
||||
&& 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);
|
||||
|
||||
@@ -15,11 +15,11 @@ import forge.game.spellability.SpellAbility;
|
||||
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 @@ public class PhasesAi extends SpellAbilityAi {
|
||||
// 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<Card> 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;
|
||||
|
||||
@@ -222,7 +222,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
&& !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)
|
||||
|
||||
@@ -16,7 +16,6 @@ import forge.game.player.PlayerActionConfirmMode;
|
||||
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 @@ public class ScryAi extends SpellAbilityAi {
|
||||
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)) {
|
||||
|
||||
@@ -8,7 +8,6 @@ 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.CardPredicates.Presets;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.cost.Cost;
|
||||
@@ -23,7 +22,6 @@ 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;
|
||||
@@ -340,7 +338,7 @@ public class UntapAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// 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 @@ public class UntapAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -234,7 +234,7 @@ public abstract class DeckGeneratorBase {
|
||||
addSome(targetSize - actualSize, tDeck.toFlatList());
|
||||
}
|
||||
else if (actualSize > targetSize) {
|
||||
Predicate<PaperCard> exceptBasicLand = Predicates.not(Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules));
|
||||
Predicate<PaperCard> exceptBasicLand = Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules).negate();
|
||||
|
||||
for (int i = 0; i < 3 && actualSize > targetSize; i++) {
|
||||
Iterable<PaperCard> matchingCards = Iterables.filter(tDeck.toFlatList(), exceptBasicLand);
|
||||
@@ -388,7 +388,7 @@ public abstract class DeckGeneratorBase {
|
||||
|
||||
//filter to provide all dual lands from pool matching 2 or 3 colors from current deck
|
||||
Predicate<CardRules> dualLandFilter = CardRulesPredicates.coreType(true, CardType.CoreType.Land);
|
||||
Predicate<CardRules> exceptBasicLand = Predicates.not(CardRulesPredicates.Presets.IS_BASIC_LAND);
|
||||
Predicate<CardRules> exceptBasicLand = CardRulesPredicates.Presets.IS_BASIC_LAND.negate();
|
||||
|
||||
Iterable<PaperCard> landCards = pool.getAllCards(Predicates.compose(dualLandFilter.and(exceptBasicLand).and(canPlay), PaperCard::getRules));
|
||||
Iterable<String> dualLandPatterns = Arrays.asList("Add \\{([WUBRG])\\} or \\{([WUBRG])\\}",
|
||||
|
||||
@@ -726,7 +726,7 @@ public class BoosterGenerator {
|
||||
itOp.remove();
|
||||
|
||||
if (invert) {
|
||||
toAdd = Predicates.not(toAdd);
|
||||
toAdd = toAdd.negate();
|
||||
}
|
||||
conditions.add(toAdd);
|
||||
}
|
||||
|
||||
@@ -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 class Predicates {
|
||||
|
||||
//TODO: Inline everything below.
|
||||
|
||||
public static <T> Predicate<T> not(Predicate<T> predicate) {
|
||||
return predicate.negate();
|
||||
}
|
||||
|
||||
public static <T> Predicate<T> and(Predicate<? super T> first, Predicate<? super T> second) {
|
||||
//TODO: remove casting?
|
||||
return ((Predicate<T>) first).and(second);
|
||||
|
||||
@@ -1099,7 +1099,7 @@ public class Game {
|
||||
|
||||
private void chooseRandomCardsForAnte(final Player player, final Multimap<Player, Card> anteed) {
|
||||
final CardCollectionView lib = player.getCardsIn(ZoneType.Library);
|
||||
Predicate<Card> goodForAnte = Predicates.not(CardPredicates.Presets.BASIC_LANDS);
|
||||
Predicate<Card> 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");
|
||||
|
||||
@@ -138,12 +138,12 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
this.filterPrinted = this.buildFilterPrinted();
|
||||
}
|
||||
protected Predicate<PaperCard> buildFilter(boolean printed) {
|
||||
Predicate<PaperCard> p = Predicates.not(IPaperCard.Predicates.names(this.getBannedCardNames()));
|
||||
Predicate<PaperCard> 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()) {
|
||||
|
||||
@@ -1141,12 +1141,12 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
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")) {
|
||||
|
||||
@@ -219,7 +219,7 @@ public class CopyPermanentEffect extends TokenEffectBase {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -7,18 +7,13 @@ import com.google.common.collect.Maps;
|
||||
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 class InternalRadiationEffect extends SpellAbilityEffect {
|
||||
|
||||
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);
|
||||
|
||||
@@ -3372,7 +3372,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
// List only has nonMana
|
||||
if (null == mana) {
|
||||
List<SpellAbility> 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();
|
||||
|
||||
@@ -261,11 +261,11 @@ public class CardLists {
|
||||
}
|
||||
|
||||
public static CardCollection getNotKeyword(Iterable<Card> 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<Card> 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<Card> cardList, final String keyword) {
|
||||
@@ -285,7 +285,7 @@ public class CardLists {
|
||||
// cardType is like "Land" or "Goblin", returns a new CardCollection that is a
|
||||
// subset of current CardList
|
||||
public static CardCollection getNotType(Iterable<Card> 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<Card> cardList, String cardType) {
|
||||
@@ -293,7 +293,7 @@ public class CardLists {
|
||||
}
|
||||
|
||||
public static CardCollection getNotColor(Iterable<Card> 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<Card> cardList, byte color) {
|
||||
|
||||
@@ -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(attacker::equals));
|
||||
((Predicate<Card>) attacker::equals).negate());
|
||||
case NOT_ALONE:
|
||||
return x -> true;
|
||||
default:
|
||||
|
||||
@@ -353,7 +353,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
* 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) {
|
||||
|
||||
@@ -11,7 +11,6 @@ import forge.game.card.CounterEnumType;
|
||||
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 final class PlayerPredicates {
|
||||
}
|
||||
|
||||
public static Predicate<Player> isNotCardInPlay(final String cardName) {
|
||||
return Predicates.not(isCardInPlay(cardName));
|
||||
return isCardInPlay(cardName).negate();
|
||||
}
|
||||
|
||||
public static Predicate<Player> hasCounters() {
|
||||
|
||||
@@ -8,10 +8,10 @@ import forge.game.ability.AbilityKey;
|
||||
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 class StaticAbilityDisableTriggers {
|
||||
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<Card> 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;
|
||||
|
||||
@@ -70,7 +70,7 @@ public enum CDeckgen implements ICDoc {
|
||||
|
||||
final Deck randomDeck = new Deck();
|
||||
|
||||
final Predicate<PaperCard> notBasicLand = Predicates.not(Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules));
|
||||
final Predicate<PaperCard> notBasicLand = Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules).negate();
|
||||
final Iterable<PaperCard> source = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards(), notBasicLand);
|
||||
randomDeck.getMain().addAllFlat(Aggregates.random(source, 15 * 5));
|
||||
|
||||
|
||||
@@ -481,7 +481,7 @@ public class EnemySprite extends CharacterSprite implements Steerable<Vector2> {
|
||||
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 ));
|
||||
|
||||
@@ -74,7 +74,7 @@ public final class CardRelationMatrixGenerator {
|
||||
true);
|
||||
|
||||
final Iterable<PaperCard> 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<PaperCard> cardList = Lists.newArrayList(cards);
|
||||
cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes"));
|
||||
Map<String, Integer> cardIntegerMap = new HashMap<>();
|
||||
@@ -90,7 +90,7 @@ public final class CardRelationMatrixGenerator {
|
||||
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 final class CardRelationMatrixGenerator {
|
||||
|
||||
//get all cards
|
||||
final Iterable<PaperCard> 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<PaperCard> cardList = Lists.newArrayList(cards);
|
||||
cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes"));
|
||||
Map<String, Integer> cardIntegerMap = new HashMap<>();
|
||||
@@ -200,7 +200,7 @@ public final class CardRelationMatrixGenerator {
|
||||
public static void updateLegendMatrix(Deck deck, PaperCard legend, Map<String, Integer> cardIntegerMap,
|
||||
Map<String, Integer> 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())];
|
||||
|
||||
@@ -265,7 +265,7 @@ public class LimitedPlayerAI extends LimitedPlayer {
|
||||
|
||||
DeckGeneratorBase.MatchColorIdentity hasColor = new DeckGeneratorBase.MatchColorIdentity(colors);
|
||||
Iterable<PaperCard> colorList = Iterables.filter(deckCards,
|
||||
Predicates.not(Predicates.compose(hasColor, PaperCard::getRules)));
|
||||
Predicates.compose(hasColor, PaperCard::getRules).negate());
|
||||
|
||||
PaperCard exchangeCard = null;
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ 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;
|
||||
@@ -41,7 +40,7 @@ public class WinstonDraft extends BoosterDraft {
|
||||
for (final Supplier<List<PaperCard>> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ 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;
|
||||
@@ -33,6 +32,7 @@ import java.util.Collection;
|
||||
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 final class FServerManager {
|
||||
broadcastExcept(event, Collections.singleton(notTo));
|
||||
}
|
||||
public void broadcastExcept(final NetEvent event, final Collection<RemoteClient> notTo) {
|
||||
broadcastTo(event, Iterables.filter(clients.values(), Predicates.not(notTo::contains)));
|
||||
Predicate<RemoteClient> filter = ((Predicate<RemoteClient>) notTo::contains).negate();
|
||||
broadcastTo(event, Iterables.filter(clients.values(), filter));
|
||||
}
|
||||
private void broadcastTo(final NetEvent event, final Iterable<RemoteClient> to) {
|
||||
for (final RemoteClient client : to) {
|
||||
|
||||
@@ -77,15 +77,15 @@ public final class BoosterUtils {
|
||||
|
||||
private static final Predicate<CardEdition> 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<CardEdition> 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<CardEdition> filterNotModern = Predicates.and(CardEdition.Predicates.CAN_MAKE_BOOSTER,
|
||||
Predicates.not(filterModern));
|
||||
filterModern.negate());
|
||||
|
||||
/**
|
||||
* Gets the quest starter deck.
|
||||
|
||||
@@ -1574,7 +1574,7 @@ public class AdvancedSearch {
|
||||
predPiece = ((AdvancedSearch.Filter<T>) piece).getPredicate();
|
||||
}
|
||||
if (applyNot) {
|
||||
predPiece = Predicates.not(predPiece);
|
||||
predPiece = predPiece.negate();
|
||||
applyNot = false;
|
||||
}
|
||||
if (pred == null) {
|
||||
|
||||
@@ -133,7 +133,7 @@ public class BooleanExpression {
|
||||
case NOT:
|
||||
operators.pop();
|
||||
left = operands.pop();
|
||||
operands.push(Predicates.not(left));
|
||||
operands.push(left.negate());
|
||||
break;
|
||||
default:
|
||||
if (alwaysPopOperator) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SFilterUtil {
|
||||
try {
|
||||
Predicate<CardRules> 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 class SFilterUtil {
|
||||
|
||||
terms.add(Predicates.or(subands));
|
||||
}
|
||||
Predicate<CardRules> textFilter = invert ? Predicates.not(Predicates.or(terms)) : Predicates.and(terms);
|
||||
Predicate<CardRules> textFilter;
|
||||
textFilter = invert ? Predicates.or(terms).negate() : Predicates.and(terms);
|
||||
|
||||
return Predicates.compose(textFilter, PaperCard::getRules);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ 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() {
|
||||
@@ -28,7 +27,7 @@ public class AgainstAllOdds extends Achievement {
|
||||
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--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
}
|
||||
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 class HumanCostDecision extends CostDecisionMakerBase {
|
||||
}
|
||||
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);
|
||||
|
||||
@@ -291,7 +291,7 @@ public final class LDAModelGenetrator {
|
||||
|
||||
//get all cards
|
||||
final Iterable<PaperCard> 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<PaperCard> cardList = Lists.newArrayList(cards);
|
||||
cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes"));
|
||||
Map<String, Integer> cardIntegerMap = new HashMap<>();
|
||||
@@ -350,7 +350,7 @@ public final class LDAModelGenetrator {
|
||||
public static void updateLegendMatrix(Deck deck, PaperCard legend, Map<String, Integer> cardIntegerMap,
|
||||
Map<String, Integer> 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())];
|
||||
|
||||
Reference in New Issue
Block a user