mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Guava migration - Inline Predicates.or
This commit is contained in:
@@ -44,7 +44,6 @@ import forge.game.trigger.Trigger;
|
||||
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 @@ public class AiBlockController {
|
||||
}
|
||||
|
||||
private Predicate<Card> 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;
|
||||
});
|
||||
|
||||
@@ -1578,7 +1578,7 @@ 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.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;
|
||||
|
||||
@@ -2801,8 +2801,7 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
// 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";
|
||||
}
|
||||
|
||||
|
||||
@@ -505,7 +505,7 @@ public class ComputerUtilCard {
|
||||
|
||||
if (hasEnchantmants || hasArtifacts) {
|
||||
final List<Card> 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 class ComputerUtilCard {
|
||||
public static final Card getCheapestSpellAI(final Iterable<Card> 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;
|
||||
|
||||
@@ -52,7 +52,6 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
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 class SpecialCardAi {
|
||||
}
|
||||
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 class SpecialCardAi {
|
||||
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 class SpecialCardAi {
|
||||
|
||||
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 class SpecialCardAi {
|
||||
// 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();
|
||||
|
||||
@@ -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 @@ public class AttachAi extends SpellAbilityAi {
|
||||
|
||||
//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 @@ public class AttachAi extends SpellAbilityAi {
|
||||
|
||||
// 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"))) {
|
||||
|
||||
@@ -26,7 +26,6 @@ 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;
|
||||
@@ -57,7 +56,7 @@ public class EffectAi extends SpellAbilityAi {
|
||||
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()) {
|
||||
|
||||
@@ -30,7 +30,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 ManaAi extends SpellAbilityAi {
|
||||
|
||||
@@ -239,7 +238,7 @@ public class ManaAi extends SpellAbilityAi {
|
||||
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,
|
||||
|
||||
@@ -18,7 +18,6 @@ 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 {
|
||||
@@ -261,7 +260,7 @@ public class PermanentAi extends SpellAbilityAi {
|
||||
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;
|
||||
|
||||
@@ -20,7 +20,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 org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -450,7 +449,7 @@ public class PumpAi extends PumpAiBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Card> alliedTgts = CardLists.filter(tgts, Predicates.or(CardPredicates.isControlledByAnyOf(ai.getAllies()), CardPredicates.isController(ai)));
|
||||
List<Card> alliedTgts = CardLists.filter(tgts, CardPredicates.isControlledByAnyOf(ai.getAllies()).or(CardPredicates.isController(ai)));
|
||||
List<Card> oppTgts = CardLists.filter(tgts, CardPredicates.isControlledByAnyOf(ai.getOpponents()));
|
||||
|
||||
Card destroyTgt = null;
|
||||
@@ -512,7 +511,7 @@ public class PumpAi extends PumpAiBase {
|
||||
// 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;
|
||||
|
||||
@@ -27,7 +27,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 abstract class PumpAiBase extends SpellAbilityAi {
|
||||
|
||||
@@ -204,7 +203,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
&& ComputerUtilCombat.lifeInDanger(ai, game.getCombat())) {
|
||||
return true;
|
||||
}
|
||||
Predicate<Card> flyingOrReach = Predicates.or(CardPredicates.hasKeyword(Keyword.FLYING), CardPredicates.hasKeyword(Keyword.REACH));
|
||||
Predicate<Card> flyingOrReach = CardPredicates.hasKeyword(Keyword.FLYING).or(CardPredicates.hasKeyword(Keyword.REACH));
|
||||
if (ph.isPlayerTurn(opp) && combat != null
|
||||
&& !attackingFlyer.isEmpty()
|
||||
&& CombatUtil.canBlock(card)) {
|
||||
|
||||
@@ -569,7 +569,7 @@ public final class CardRulesPredicates {
|
||||
public static final Predicate<CardRules> IS_ENCHANTMENT = CardRulesPredicates.coreType(true, CardType.CoreType.Enchantment);
|
||||
public static final Predicate<CardRules> IS_PLANE = CardRulesPredicates.coreType(true, CardType.CoreType.Plane);
|
||||
public static final Predicate<CardRules> IS_PHENOMENON = CardRulesPredicates.coreType(true, CardType.CoreType.Phenomenon);
|
||||
public static final Predicate<CardRules> IS_PLANE_OR_PHENOMENON = Predicates.or(IS_PLANE, IS_PHENOMENON);
|
||||
public static final Predicate<CardRules> IS_PLANE_OR_PHENOMENON = IS_PLANE.or(IS_PHENOMENON);
|
||||
public static final Predicate<CardRules> IS_SCHEME = CardRulesPredicates.coreType(true, CardType.CoreType.Scheme);
|
||||
public static final Predicate<CardRules> IS_VANGUARD = CardRulesPredicates.coreType(true, CardType.CoreType.Vanguard);
|
||||
public static final Predicate<CardRules> IS_CONSPIRACY = CardRulesPredicates.coreType(true, CardType.CoreType.Conspiracy);
|
||||
@@ -577,8 +577,8 @@ public final class CardRulesPredicates {
|
||||
public static final Predicate<CardRules> IS_ATTRACTION = Presets.IS_ARTIFACT.and(CardRulesPredicates.subType("Attraction"));
|
||||
|
||||
public static final Predicate<CardRules> IS_NON_LAND = CardRulesPredicates.coreType(false, CardType.CoreType.Land);
|
||||
public static final Predicate<CardRules> CAN_BE_BRAWL_COMMANDER = Presets.IS_LEGENDARY.and(Predicates.or(Presets.IS_CREATURE, Presets.IS_PLANESWALKER));
|
||||
public static final Predicate<CardRules> CAN_BE_TINY_LEADERS_COMMANDER = Presets.IS_LEGENDARY.and(Predicates.or(Presets.IS_CREATURE, Presets.IS_PLANESWALKER));
|
||||
public static final Predicate<CardRules> CAN_BE_BRAWL_COMMANDER = Presets.IS_LEGENDARY.and(Presets.IS_CREATURE.or(Presets.IS_PLANESWALKER));
|
||||
public static final Predicate<CardRules> 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<CardRules> IS_NON_CREATURE_SPELL =
|
||||
|
||||
@@ -538,7 +538,7 @@ public enum DeckFormat {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ public abstract class DeckGeneratorBase {
|
||||
};
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -209,8 +209,7 @@ public interface IPaperCard extends InventoryItem, Serializable {
|
||||
public static final Predicate<PaperCard> IS_MYTHIC_RARE = Predicates.rarity(true, CardRarity.MythicRare);
|
||||
|
||||
/** The Constant isRareOrMythic. */
|
||||
public static final Predicate<PaperCard> IS_RARE_OR_MYTHIC = forge.util.Predicates.or(Presets.IS_RARE,
|
||||
Presets.IS_MYTHIC_RARE);
|
||||
public static final Predicate<PaperCard> IS_RARE_OR_MYTHIC = Presets.IS_RARE.or(Presets.IS_MYTHIC_RARE);
|
||||
|
||||
/** The Constant isSpecial. */
|
||||
public static final Predicate<PaperCard> IS_SPECIAL = Predicates.rarity(true, CardRarity.Special);
|
||||
|
||||
@@ -20,12 +20,4 @@ public class Predicates {
|
||||
public static <A, B> Predicate<A> compose(Predicate<B> predicate, Function<A, ? extends B> function) {
|
||||
return x -> predicate.test(function.apply(x));
|
||||
}
|
||||
|
||||
|
||||
//TODO: Inline everything below.
|
||||
|
||||
public static <T> Predicate<T> or(Predicate<? super T> first, Predicate<? super T> second) {
|
||||
//TODO: remove casting?
|
||||
return ((Predicate<T>) first).or(second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public final class CEditorCommander extends CDeckEditor<Deck> {
|
||||
}
|
||||
else {
|
||||
Predicate<CardRules> 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);
|
||||
|
||||
@@ -760,9 +760,10 @@ public class DeckgenUtil {
|
||||
cardDb = FModel.getMagicDb().getCommonCards();
|
||||
//shuffle first 400 random cards
|
||||
Iterable<PaperCard> 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());
|
||||
|
||||
@@ -183,7 +183,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
|
||||
*/
|
||||
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 class CardThemedDeckBuilder extends DeckGeneratorBase {
|
||||
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 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
|
||||
}
|
||||
}
|
||||
|
||||
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<PaperCard> threeColorList = Iterables.filter(aiPlayables,
|
||||
Predicates.compose(hasColor, PaperCard::getRules));
|
||||
for (final PaperCard card : threeColorList) {
|
||||
|
||||
@@ -134,7 +134,7 @@ public class LimitedDeckBuilder extends DeckGeneratorBase {
|
||||
@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<PaperCard> colorList = Iterables.filter(aiPlayables,
|
||||
Predicates.compose(hasColor, PaperCard::getRules));
|
||||
rankedColorList = CardRanker.rankCardsInDeck(colorList);
|
||||
@@ -497,8 +497,7 @@ public class LimitedDeckBuilder extends DeckGeneratorBase {
|
||||
}
|
||||
}
|
||||
|
||||
hasColor = Predicates.or(new DeckGeneratorBase.MatchColorIdentity(colors),
|
||||
DeckGeneratorBase.COLORLESS_CARDS);
|
||||
hasColor = new MatchColorIdentity(colors).or(DeckGeneratorBase.COLORLESS_CARDS);
|
||||
final Iterable<PaperCard> threeColorList = Iterables.filter(rankedOthers,
|
||||
Predicates.compose(hasColor, PaperCard::getRules));
|
||||
for (final PaperCard card : threeColorList) {
|
||||
|
||||
@@ -91,13 +91,13 @@ public abstract class QuestRewardCard implements IQuestRewardCard {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,6 @@ import forge.item.SealedProduct;
|
||||
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 @@ public class AdvancedSearch {
|
||||
pred = pred.and(predPiece);
|
||||
}
|
||||
else if (operator == Operator.OR) {
|
||||
pred = Predicates.or(pred, predPiece);
|
||||
pred = pred.or(predPiece);
|
||||
}
|
||||
operator = null;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class BooleanExpression {
|
||||
operators.pop();
|
||||
right = operands.pop();
|
||||
left = operands.pop();
|
||||
operands.push(Predicates.or(left, right));
|
||||
operands.push(left.or(right));
|
||||
break;
|
||||
case NOT:
|
||||
operators.pop();
|
||||
|
||||
@@ -346,8 +346,8 @@ public final class FModel {
|
||||
|
||||
public static ItemPool<PaperCard> 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user