mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
Miscallaneous Cleanup Part 2 - Lambdas and Method References (#5737)
* Cleanup - Unnecessary Boxing * Cleanup - Unnecessary Unboxing * Cleanup - For-Each Loops * Cleanup - `indexOf != -1` -> `contains` * Cleanup - Merge identical catch blocks * Cleanup - Try-with-resources * Cleanup - System.lineSeparator * Cleanup - Reference types to primitives Some loops over Integers were switched to IntStreams to hopefully cut down on overall boxing. * Cleanup - Manually filling and copying arrays * Remove unused imports * Switch a lambda to a method reference * Cleanup - CardPredicate Aggregates to method references * Cleanup - Other static functions to method references * Cleanup - Ambiguous class reference Unclear when or how this happened... * Cleanup - Anonymous -> Method reference * Cleanup - Anonymous -> Lambda * Cleanup - Comparator helper methods * Cleanup - final method in final class * Cleanup - private final methods * Remove unused imports * Convert a couple more lambdas to comparators. * Simplify creature type list comparison. --------- Co-authored-by: Jetz <Jetz722@gmail.com> Co-authored-by: tool4ever <therealtoolkit@hotmail.com>
This commit is contained in:
@@ -8,41 +8,23 @@ import forge.game.keyword.Keyword;
|
||||
public class CardTraitPredicates {
|
||||
|
||||
public static final Predicate<CardTraitBase> isHostCard(final Card host) {
|
||||
return new Predicate<CardTraitBase>() {
|
||||
@Override
|
||||
public boolean apply(final CardTraitBase sa) {
|
||||
return host.equals(sa.getHostCard());
|
||||
}
|
||||
};
|
||||
return sa -> host.equals(sa.getHostCard());
|
||||
}
|
||||
|
||||
public static final Predicate<CardTraitBase> isKeyword(final Keyword kw) {
|
||||
return new Predicate<CardTraitBase>() {
|
||||
@Override
|
||||
public boolean apply(final CardTraitBase sa) {
|
||||
return sa.isKeyword(kw);
|
||||
}
|
||||
};
|
||||
return sa -> sa.isKeyword(kw);
|
||||
}
|
||||
|
||||
public static final Predicate<CardTraitBase> hasParam(final String name) {
|
||||
return new Predicate<CardTraitBase>() {
|
||||
@Override
|
||||
public boolean apply(final CardTraitBase sa) {
|
||||
return sa.hasParam(name);
|
||||
}
|
||||
};
|
||||
return sa -> sa.hasParam(name);
|
||||
}
|
||||
|
||||
public static final Predicate<CardTraitBase> hasParam(final String name, final String val) {
|
||||
return new Predicate<CardTraitBase>() {
|
||||
@Override
|
||||
public boolean apply(final CardTraitBase sa) {
|
||||
if (!sa.hasParam(name)) {
|
||||
return false;
|
||||
}
|
||||
return val.equals(sa.getParam(name));
|
||||
return sa -> {
|
||||
if (!sa.hasParam(name)) {
|
||||
return false;
|
||||
}
|
||||
return val.equals(sa.getParam(name));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,17 +504,14 @@ public class Game {
|
||||
}
|
||||
|
||||
public CardCollectionView getCardsPlayerCanActivateInStack() {
|
||||
return CardLists.filter(stackZone.getCards(), new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
for (final SpellAbility sa : c.getSpellAbilities()) {
|
||||
final ZoneType restrictZone = sa.getRestrictions().getZone();
|
||||
if (ZoneType.Stack == restrictZone) {
|
||||
return true;
|
||||
}
|
||||
return CardLists.filter(stackZone.getCards(), c -> {
|
||||
for (final SpellAbility sa : c.getSpellAbilities()) {
|
||||
final ZoneType restrictZone = sa.getRestrictions().getZone();
|
||||
if (ZoneType.Stack == restrictZone) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
package forge.game;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.*;
|
||||
import forge.GameCommand;
|
||||
import forge.StaticData;
|
||||
@@ -1132,15 +1131,10 @@ public class GameAction {
|
||||
}
|
||||
}, true);
|
||||
|
||||
final Comparator<StaticAbility> comp = new Comparator<StaticAbility>() {
|
||||
@Override
|
||||
public int compare(final StaticAbility a, final StaticAbility b) {
|
||||
return ComparisonChain.start()
|
||||
.compareTrueFirst(a.hasParam("CharacteristicDefining"), b.hasParam("CharacteristicDefining"))
|
||||
.compare(a.getHostCard().getLayerTimestamp(), b.getHostCard().getLayerTimestamp())
|
||||
.result();
|
||||
}
|
||||
};
|
||||
final Comparator<StaticAbility> comp = (a, b) -> ComparisonChain.start()
|
||||
.compareTrueFirst(a.hasParam("CharacteristicDefining"), b.hasParam("CharacteristicDefining"))
|
||||
.compare(a.getHostCard().getLayerTimestamp(), b.getHostCard().getLayerTimestamp())
|
||||
.result();
|
||||
Collections.sort(staticAbilities, comp);
|
||||
|
||||
final Map<StaticAbility, CardCollectionView> affectedPerAbility = Maps.newHashMap();
|
||||
@@ -1807,15 +1801,9 @@ public class GameAction {
|
||||
boolean recheck = false;
|
||||
|
||||
// Corner Case 1: Legendary with non legendary creature names
|
||||
CardCollection nonLegendaryNames = CardLists.filter(a, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card input) {
|
||||
return input.hasNonLegendaryCreatureNames();
|
||||
}
|
||||
CardCollection nonLegendaryNames = CardLists.filter(a, Card::hasNonLegendaryCreatureNames);
|
||||
|
||||
});
|
||||
|
||||
Multimap<String, Card> uniqueLegends = Multimaps.index(a, CardPredicates.Accessors.fnGetNetName);
|
||||
Multimap<String, Card> uniqueLegends = Multimaps.index(a, Card::getName);
|
||||
CardCollection removed = new CardCollection();
|
||||
|
||||
for (String name : uniqueLegends.keySet()) {
|
||||
@@ -2226,19 +2214,9 @@ public class GameAction {
|
||||
private void runPreOpeningHandActions(final Player first) {
|
||||
Player takesAction = first;
|
||||
do {
|
||||
List<Card> ploys = CardLists.filter(takesAction.getCardsIn(ZoneType.Command), new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card input) {
|
||||
return input.getName().equals("Emissary's Ploy");
|
||||
}
|
||||
});
|
||||
List<Card> ploys = CardLists.filter(takesAction.getCardsIn(ZoneType.Command), input -> input.getName().equals("Emissary's Ploy"));
|
||||
CardCollectionView all = CardLists.filterControlledBy(game.getCardsInGame(), takesAction);
|
||||
List<Card> spires = CardLists.filter(all, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card input) {
|
||||
return input.getName().equals("Cryptic Spires");
|
||||
}
|
||||
});
|
||||
List<Card> spires = CardLists.filter(all, input -> input.getName().equals("Cryptic Spires"));
|
||||
|
||||
int chosen = 1;
|
||||
List<Integer> cmc = Lists.newArrayList(1, 2, 3);
|
||||
|
||||
@@ -82,7 +82,7 @@ public final class GameActionUtil {
|
||||
* a possible alternative cost the provided activator can use to pay
|
||||
* the provided {@link SpellAbility}.
|
||||
*/
|
||||
public static final List<SpellAbility> getAlternativeCosts(final SpellAbility sa, final Player activator, boolean altCostOnly) {
|
||||
public static List<SpellAbility> getAlternativeCosts(final SpellAbility sa, final Player activator, boolean altCostOnly) {
|
||||
final List<SpellAbility> alternatives = Lists.newArrayList();
|
||||
|
||||
Card source = sa.getHostCard();
|
||||
@@ -577,7 +577,7 @@ public final class GameActionUtil {
|
||||
String n = o.split(":")[1];
|
||||
if (host.wasCast() && n.equals("X")) {
|
||||
CardCollectionView creatures = activator.getCreaturesInPlay();
|
||||
int max = Aggregates.max(creatures, CardPredicates.Accessors.fnGetNetPower);
|
||||
int max = Aggregates.max(creatures, Card::getNetPower);
|
||||
n = Integer.toString(pc.chooseNumber(sa, "Choose X for Casualty", 0, max));
|
||||
}
|
||||
final String casualtyCost = "Sac<1/Creature.powerGE" + n + "/creature with power " + n +
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
package forge.game;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -317,13 +316,6 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public static final Function<GameFormat, String> FN_GET_NAME = new Function<GameFormat, String>() {
|
||||
@Override
|
||||
public String apply(GameFormat arg1) {
|
||||
return arg1.getName();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int compareTo(GameFormat other) {
|
||||
if (null == other) {
|
||||
@@ -371,7 +363,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
}
|
||||
|
||||
public Reader(File forgeFormats, File customFormats, boolean includeArchived) {
|
||||
super(forgeFormats, customFormats, GameFormat.FN_GET_NAME);
|
||||
super(forgeFormats, customFormats, GameFormat::getName);
|
||||
this.includeArchived=includeArchived;
|
||||
}
|
||||
|
||||
@@ -462,12 +454,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
return TXT_FILE_FILTER;
|
||||
}
|
||||
|
||||
public static final FilenameFilter TXT_FILE_FILTER = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(final File dir, final String name) {
|
||||
return name.endsWith(".txt") || dir.isDirectory();
|
||||
}
|
||||
};
|
||||
public static final FilenameFilter TXT_FILE_FILTER = (dir, name) -> name.endsWith(".txt") || dir.isDirectory();
|
||||
}
|
||||
|
||||
public static class Collection extends StorageBase<GameFormat> {
|
||||
@@ -695,10 +682,5 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
}
|
||||
}
|
||||
|
||||
public final Predicate<CardEdition> editionLegalPredicate = new Predicate<CardEdition>() {
|
||||
@Override
|
||||
public boolean apply(final CardEdition subject) {
|
||||
return GameFormat.this.isSetLegal(subject.getCode());
|
||||
}
|
||||
};
|
||||
public final Predicate<CardEdition> editionLegalPredicate = subject -> GameFormat.this.isSetLegal(subject.getCode());
|
||||
}
|
||||
|
||||
@@ -32,22 +32,12 @@ import forge.game.player.Player;
|
||||
*/
|
||||
public final class GameObjectPredicates {
|
||||
|
||||
public static final Predicate<GameObject> restriction(final String[] restrictions, final Player sourceController, final Card source, final CardTraitBase spellAbility) {
|
||||
return new Predicate<GameObject>() {
|
||||
@Override
|
||||
public boolean apply(final GameObject c) {
|
||||
return c != null && c.isValid(restrictions, sourceController, source, spellAbility);
|
||||
}
|
||||
};
|
||||
public static Predicate<GameObject> restriction(final String[] restrictions, final Player sourceController, final Card source, final CardTraitBase spellAbility) {
|
||||
return c -> c != null && c.isValid(restrictions, sourceController, source, spellAbility);
|
||||
}
|
||||
|
||||
public static final Predicate<GameObject> matchesValidParam(final CardTraitBase ctb, final String param) {
|
||||
return new Predicate<GameObject>() {
|
||||
@Override
|
||||
public boolean apply(final GameObject c) {
|
||||
return ctb.matchesValidParam(param, c);
|
||||
}
|
||||
};
|
||||
public static Predicate<GameObject> matchesValidParam(final CardTraitBase ctb, final String param) {
|
||||
return c -> ctb.matchesValidParam(param, c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,41 +40,35 @@ public enum GameType {
|
||||
Planechase (DeckFormat.Planechase, false, false, true, "lblPlanechase", "lblPlanechaseDesc"),
|
||||
Archenemy (DeckFormat.Archenemy, false, false, true, "lblArchenemy", "lblArchenemyDesc"),
|
||||
ArchenemyRumble (DeckFormat.Archenemy, false, false, true, "lblArchenemyRumble", "lblArchenemyRumbleDesc"),
|
||||
MomirBasic (DeckFormat.Constructed, false, false, false, "lblMomirBasic", "lblMomirBasicDesc", new Function<RegisteredPlayer, Deck>() {
|
||||
@Override
|
||||
public Deck apply(RegisteredPlayer player) {
|
||||
Deck deck = new Deck();
|
||||
CardPool mainDeck = deck.getMain();
|
||||
String setcode = Aggregates.random(StaticData.instance().getBlockLands());
|
||||
mainDeck.add("Plains", setcode, 12, true);
|
||||
mainDeck.add("Island", setcode, 12, true);
|
||||
mainDeck.add("Swamp", setcode, 12, true);
|
||||
mainDeck.add("Mountain", setcode, 12, true);
|
||||
mainDeck.add("Forest", setcode, 12, true);
|
||||
deck.getOrCreate(DeckSection.Avatar).add(StaticData.instance().getVariantCards()
|
||||
.getCard("Momir Vig, Simic Visionary Avatar"), 1);
|
||||
return deck;
|
||||
}
|
||||
MomirBasic (DeckFormat.Constructed, false, false, false, "lblMomirBasic", "lblMomirBasicDesc", player -> {
|
||||
Deck deck = new Deck();
|
||||
CardPool mainDeck = deck.getMain();
|
||||
String setcode = Aggregates.random(StaticData.instance().getBlockLands());
|
||||
mainDeck.add("Plains", setcode, 12, true);
|
||||
mainDeck.add("Island", setcode, 12, true);
|
||||
mainDeck.add("Swamp", setcode, 12, true);
|
||||
mainDeck.add("Mountain", setcode, 12, true);
|
||||
mainDeck.add("Forest", setcode, 12, true);
|
||||
deck.getOrCreate(DeckSection.Avatar).add(StaticData.instance().getVariantCards()
|
||||
.getCard("Momir Vig, Simic Visionary Avatar"), 1);
|
||||
return deck;
|
||||
}),
|
||||
MoJhoSto (DeckFormat.Constructed, false, false, false, "lblMoJhoSto", "lblMoJhoStoDesc", new Function<RegisteredPlayer, Deck>() {
|
||||
@Override
|
||||
public Deck apply(RegisteredPlayer player) {
|
||||
Deck deck = new Deck();
|
||||
CardPool mainDeck = deck.getMain();
|
||||
String setcode = Aggregates.random(StaticData.instance().getBlockLands());
|
||||
mainDeck.add("Plains", setcode, 12, true);
|
||||
mainDeck.add("Island", setcode, 12, true);
|
||||
mainDeck.add("Swamp", setcode, 12, true);
|
||||
mainDeck.add("Mountain", setcode, 12, true);
|
||||
mainDeck.add("Forest", setcode, 12, true);
|
||||
deck.getOrCreate(DeckSection.Avatar).add(StaticData.instance().getVariantCards()
|
||||
.getCard("Momir Vig, Simic Visionary Avatar"), 1);
|
||||
deck.getOrCreate(DeckSection.Avatar).add(StaticData.instance().getVariantCards()
|
||||
.getCard("Jhoira of the Ghitu Avatar"), 1);
|
||||
deck.getOrCreate(DeckSection.Avatar).add(StaticData.instance().getVariantCards()
|
||||
.getCard("Stonehewer Giant Avatar"), 1);
|
||||
return deck;
|
||||
}
|
||||
MoJhoSto (DeckFormat.Constructed, false, false, false, "lblMoJhoSto", "lblMoJhoStoDesc", player -> {
|
||||
Deck deck = new Deck();
|
||||
CardPool mainDeck = deck.getMain();
|
||||
String setcode = Aggregates.random(StaticData.instance().getBlockLands());
|
||||
mainDeck.add("Plains", setcode, 12, true);
|
||||
mainDeck.add("Island", setcode, 12, true);
|
||||
mainDeck.add("Swamp", setcode, 12, true);
|
||||
mainDeck.add("Mountain", setcode, 12, true);
|
||||
mainDeck.add("Forest", setcode, 12, true);
|
||||
deck.getOrCreate(DeckSection.Avatar).add(StaticData.instance().getVariantCards()
|
||||
.getCard("Momir Vig, Simic Visionary Avatar"), 1);
|
||||
deck.getOrCreate(DeckSection.Avatar).add(StaticData.instance().getVariantCards()
|
||||
.getCard("Jhoira of the Ghitu Avatar"), 1);
|
||||
deck.getOrCreate(DeckSection.Avatar).add(StaticData.instance().getVariantCards()
|
||||
.getCard("Stonehewer Giant Avatar"), 1);
|
||||
return deck;
|
||||
});
|
||||
|
||||
private final DeckFormat deckFormat;
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
package forge.game;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
public interface IIdentifiable {
|
||||
int getId();
|
||||
Function<IIdentifiable, Integer> FN_GET_ID = new Function<IIdentifiable, Integer>() {
|
||||
@Override
|
||||
public Integer apply(final IIdentifiable input) {
|
||||
return input.getId();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
package forge.game.ability;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import forge.card.CardStateName;
|
||||
@@ -110,10 +109,10 @@ public final class AbilityFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public static final SpellAbility getAbility(final String abString, final Card card) {
|
||||
public static SpellAbility getAbility(final String abString, final Card card) {
|
||||
return getAbility(abString, card.getCurrentState());
|
||||
}
|
||||
public static final SpellAbility getAbility(final String abString, final Card card, final IHasSVars sVarHolder) {
|
||||
public static SpellAbility getAbility(final String abString, final Card card, final IHasSVars sVarHolder) {
|
||||
return getAbility(abString, card.getCurrentState(), sVarHolder);
|
||||
}
|
||||
/**
|
||||
@@ -127,11 +126,11 @@ public final class AbilityFactory {
|
||||
* a {@link forge.game.card.CardState} object.
|
||||
* @return a {@link forge.game.spellability.SpellAbility} object.
|
||||
*/
|
||||
public static final SpellAbility getAbility(final String abString, final CardState state) {
|
||||
public static SpellAbility getAbility(final String abString, final CardState state) {
|
||||
return getAbility(abString, state, state);
|
||||
}
|
||||
|
||||
private static final SpellAbility getAbility(final String abString, final CardState state, final IHasSVars sVarHolder) {
|
||||
private static SpellAbility getAbility(final String abString, final CardState state, final IHasSVars sVarHolder) {
|
||||
Map<String, String> mapParams;
|
||||
try {
|
||||
mapParams = AbilityFactory.getMapParams(abString);
|
||||
@@ -159,15 +158,15 @@ public final class AbilityFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public static final SpellAbility getAbility(final Card hostCard, final String svar) {
|
||||
public static SpellAbility getAbility(final Card hostCard, final String svar) {
|
||||
return getAbility(hostCard, svar, hostCard.getCurrentState());
|
||||
}
|
||||
|
||||
public static final SpellAbility getAbility(final Card hostCard, final String svar, final IHasSVars sVarHolder) {
|
||||
public static SpellAbility getAbility(final Card hostCard, final String svar, final IHasSVars sVarHolder) {
|
||||
return getAbility(hostCard.getCurrentState(), svar, sVarHolder);
|
||||
}
|
||||
|
||||
public static final SpellAbility getAbility(final CardState state, final String svar, final IHasSVars sVarHolder) {
|
||||
public static SpellAbility getAbility(final CardState state, final String svar, final IHasSVars sVarHolder) {
|
||||
if (!sVarHolder.hasSVar(svar)) {
|
||||
String source = state.getCard().getName();
|
||||
throw new RuntimeException("AbilityFactory : getAbility -- " + source + " has no SVar: " + svar);
|
||||
@@ -176,7 +175,7 @@ public final class AbilityFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public static final SpellAbility getAbility(final Map<String, String> mapParams, AbilityRecordType type, final CardState state, final IHasSVars sVarHolder) {
|
||||
public static SpellAbility getAbility(final Map<String, String> mapParams, AbilityRecordType type, final CardState state, final IHasSVars sVarHolder) {
|
||||
return getAbility(type, type.getApiTypeOf(mapParams), mapParams, null, state, sVarHolder);
|
||||
}
|
||||
|
||||
@@ -203,7 +202,7 @@ public final class AbilityFactory {
|
||||
return abCost;
|
||||
}
|
||||
|
||||
public static final SpellAbility getAbility(AbilityRecordType type, ApiType api, Map<String, String> mapParams,
|
||||
public static SpellAbility getAbility(AbilityRecordType type, ApiType api, Map<String, String> mapParams,
|
||||
Cost abCost, final CardState state, final IHasSVars sVarHolder) {
|
||||
final Card hostCard = state.getCard();
|
||||
TargetRestrictions abTgt = mapParams.containsKey("ValidTgts") ? readTarget(mapParams) : null;
|
||||
@@ -286,12 +285,7 @@ public final class AbilityFactory {
|
||||
final String key = "Choices";
|
||||
if (mapParams.containsKey(key)) {
|
||||
List<String> names = Lists.newArrayList(mapParams.get(key).split(","));
|
||||
spellAbility.setAdditionalAbilityList(key, Lists.transform(names, new Function<String, AbilitySub>() {
|
||||
@Override
|
||||
public AbilitySub apply(String input) {
|
||||
return getSubAbility(state, input, sVarHolder);
|
||||
}
|
||||
}));
|
||||
spellAbility.setAdditionalAbilityList(key, Lists.transform(names, input -> getSubAbility(state, input, sVarHolder)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +324,7 @@ public final class AbilityFactory {
|
||||
return spellAbility;
|
||||
}
|
||||
|
||||
private static final TargetRestrictions readTarget(Map<String, String> mapParams) {
|
||||
private static TargetRestrictions readTarget(Map<String, String> mapParams) {
|
||||
final String min = mapParams.getOrDefault("TargetMin", "1");
|
||||
final String max = mapParams.getOrDefault("TargetMax", "1");
|
||||
|
||||
@@ -424,7 +418,7 @@ public final class AbilityFactory {
|
||||
* @param sa
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
*/
|
||||
private static final void initializeParams(final SpellAbility sa) {
|
||||
private static void initializeParams(final SpellAbility sa) {
|
||||
if (sa.hasParam("NonBasicSpell")) {
|
||||
sa.setBasicSpell(false);
|
||||
}
|
||||
@@ -438,7 +432,7 @@ public final class AbilityFactory {
|
||||
* @param sa
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
*/
|
||||
private static final void makeRestrictions(final SpellAbility sa) {
|
||||
private static void makeRestrictions(final SpellAbility sa) {
|
||||
// SpellAbilityRestrictions should be added in here
|
||||
final SpellAbilityRestriction restrict = sa.getRestrictions();
|
||||
if (restrict != null) {
|
||||
@@ -454,7 +448,7 @@ public final class AbilityFactory {
|
||||
* @param sa
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
*/
|
||||
private static final void makeConditions(final SpellAbility sa) {
|
||||
private static void makeConditions(final SpellAbility sa) {
|
||||
// SpellAbilityConditions should be added in here
|
||||
final SpellAbilityCondition condition = sa.getConditions();
|
||||
condition.setConditions(sa.getMapParams());
|
||||
@@ -469,7 +463,7 @@ public final class AbilityFactory {
|
||||
*
|
||||
* @return a {@link forge.game.spellability.AbilitySub} object.
|
||||
*/
|
||||
private static final AbilitySub getSubAbility(CardState state, String sSub, final IHasSVars sVarHolder) {
|
||||
private static AbilitySub getSubAbility(CardState state, String sSub, final IHasSVars sVarHolder) {
|
||||
if (sVarHolder.hasSVar(sSub)) {
|
||||
return (AbilitySub) AbilityFactory.getAbility(state, sSub, sVarHolder);
|
||||
}
|
||||
@@ -478,11 +472,11 @@ public final class AbilityFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final Map<String, String> getMapParams(final String abString) {
|
||||
public static Map<String, String> getMapParams(final String abString) {
|
||||
return FileSection.parseToMap(abString, FileSection.DOLLAR_SIGN_KV_SEPARATOR);
|
||||
}
|
||||
|
||||
public static final void adjustChangeZoneTarget(final Map<String, String> params, final SpellAbility sa) {
|
||||
public static void adjustChangeZoneTarget(final Map<String, String> params, final SpellAbility sa) {
|
||||
if (params.containsKey("Origin")) {
|
||||
List<ZoneType> origin = ZoneType.listValueOf(params.get("Origin"));
|
||||
|
||||
@@ -495,7 +489,7 @@ public final class AbilityFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public static final SpellAbility buildFusedAbility(final Card card) {
|
||||
public static SpellAbility buildFusedAbility(final Card card) {
|
||||
if (!card.isSplitCard())
|
||||
throw new IllegalStateException("Fuse ability may be built only on split cards");
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.game.ability;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.*;
|
||||
import forge.card.CardStateName;
|
||||
import forge.card.CardType;
|
||||
@@ -2865,12 +2864,12 @@ public class AbilityUtils {
|
||||
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, CardPredicates.Accessors.fnGetNetPower), expr, c, ctb);
|
||||
return doXMath(Aggregates.sum(filteredCards, Card::getNetPower), 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<Card> powers = Aggregates.uniqueByLast(list, CardPredicates.Accessors.fnGetNetPower);
|
||||
final Iterable<Card> powers = Aggregates.uniqueByLast(list, Card::getNetPower);
|
||||
return doXMath(Iterables.size(powers), expr, c, ctb);
|
||||
}
|
||||
if (sq[0].startsWith("DifferentCounterKinds_")) {
|
||||
@@ -3024,7 +3023,7 @@ public class AbilityUtils {
|
||||
public static final String applyDescriptionTextChangeEffects(final String def, final Card card) {
|
||||
return applyTextChangeEffects(def, card, true);
|
||||
}
|
||||
private static final String applyTextChangeEffects(final String def, final Card card, final boolean isDescriptive) {
|
||||
private static String applyTextChangeEffects(final String def, final Card card, final boolean isDescriptive) {
|
||||
return applyTextChangeEffects(def, isDescriptive, card.getChangedTextColorWords(), card.getChangedTextTypeWords());
|
||||
}
|
||||
|
||||
@@ -3064,7 +3063,7 @@ public class AbilityUtils {
|
||||
return replaced;
|
||||
}
|
||||
|
||||
private static final String getReplacedText(final String text, final String originalWord, String newWord, final boolean isDescriptive) {
|
||||
private static String getReplacedText(final String text, final String originalWord, String newWord, final boolean isDescriptive) {
|
||||
if (isDescriptive) {
|
||||
newWord = "<strike>" + originalWord + "</strike> " + newWord;
|
||||
}
|
||||
@@ -3126,18 +3125,15 @@ public class AbilityUtils {
|
||||
return sa;
|
||||
}
|
||||
|
||||
final CardCollection splices = CardLists.filter(hand, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card input) {
|
||||
for (final KeywordInterface inst : input.getKeywords(Keyword.SPLICE)) {
|
||||
String k = inst.getOriginal();
|
||||
final String[] n = k.split(":");
|
||||
if (source.isValid(n[1].split(","), player, input, sa)) {
|
||||
return true;
|
||||
}
|
||||
final CardCollection splices = CardLists.filter(hand, input -> {
|
||||
for (final KeywordInterface inst : input.getKeywords(Keyword.SPLICE)) {
|
||||
String k = inst.getOriginal();
|
||||
final String[] n = k.split(":");
|
||||
if (source.isValid(n[1].split(","), player, input, sa)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
splices.remove(source);
|
||||
@@ -3532,7 +3528,7 @@ public class AbilityUtils {
|
||||
}
|
||||
|
||||
if (value.contains("TopOfLibraryCMC")) {
|
||||
return doXMath(Aggregates.sum(player.getCardsIn(ZoneType.Library, 1), CardPredicates.Accessors.fnGetCmc), m, source, ctb);
|
||||
return doXMath(Aggregates.sum(player.getCardsIn(ZoneType.Library, 1), Card::getCMC), m, source, ctb);
|
||||
}
|
||||
|
||||
if (value.contains("LandsPlayed")) {
|
||||
@@ -3685,18 +3681,18 @@ public class AbilityUtils {
|
||||
}
|
||||
|
||||
if (string.startsWith("GreatestPower")) {
|
||||
return Aggregates.max(paidList, CardPredicates.Accessors.fnGetNetPower);
|
||||
return Aggregates.max(paidList, Card::getNetPower);
|
||||
}
|
||||
if (string.startsWith("GreatestToughness")) {
|
||||
return Aggregates.max(paidList, CardPredicates.Accessors.fnGetNetToughness);
|
||||
return Aggregates.max(paidList, Card::getNetToughness);
|
||||
}
|
||||
|
||||
if (string.startsWith("SumToughness")) {
|
||||
return Aggregates.sum(paidList, CardPredicates.Accessors.fnGetNetToughness);
|
||||
return Aggregates.sum(paidList, Card::getNetToughness);
|
||||
}
|
||||
|
||||
if (string.startsWith("GreatestCMC")) {
|
||||
return Aggregates.max(paidList, CardPredicates.Accessors.fnGetCmc);
|
||||
return Aggregates.max(paidList, Card::getCMC);
|
||||
}
|
||||
|
||||
if (string.equals("DifferentColorPair")) {
|
||||
@@ -3718,7 +3714,7 @@ public class AbilityUtils {
|
||||
}
|
||||
|
||||
if (string.startsWith("SumCMC")) {
|
||||
return Aggregates.sum(paidList, CardPredicates.Accessors.fnGetCmc);
|
||||
return Aggregates.sum(paidList, Card::getCMC);
|
||||
}
|
||||
|
||||
if (string.startsWith("Valid")) {
|
||||
@@ -3890,21 +3886,11 @@ public class AbilityUtils {
|
||||
// if (sq[0].contains("Green")) someCards = CardLists.filter(someCards, CardPredicates.isColor(MagicColor.GREEN));
|
||||
|
||||
if (sq[0].contains("Multicolor")) {
|
||||
someCards = CardLists.filter(someCards, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.getColor().isMulticolor();
|
||||
}
|
||||
});
|
||||
someCards = CardLists.filter(someCards, c1 -> c1.getColor().isMulticolor());
|
||||
}
|
||||
|
||||
if (sq[0].contains("Monocolor")) {
|
||||
someCards = CardLists.filter(someCards, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.getColor().isMonoColor();
|
||||
}
|
||||
});
|
||||
someCards = CardLists.filter(someCards, c12 -> c12.getColor().isMonoColor());
|
||||
}
|
||||
return someCards;
|
||||
}
|
||||
|
||||
@@ -99,12 +99,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
||||
int div = changingTgtSA.getTotalDividedValue();
|
||||
List<GameEntity> candidates = changingTgtSA.getTargetRestrictions().getAllCandidates(changingTgtSA, true);
|
||||
if (sa.hasParam("RandomTargetRestriction")) {
|
||||
candidates.removeIf(new java.util.function.Predicate<GameEntity>() {
|
||||
@Override
|
||||
public boolean test(GameEntity c) {
|
||||
return !c.isValid(sa.getParam("RandomTargetRestriction").split(","), activator, sa.getHostCard(), sa);
|
||||
}
|
||||
});
|
||||
candidates.removeIf(c -> !c.isValid(sa.getParam("RandomTargetRestriction").split(","), activator, sa.getHostCard(), sa));
|
||||
}
|
||||
// CR 115.7a If a target can't be changed to another legal target, the original target is unchanged
|
||||
if (candidates.isEmpty()) {
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
|
||||
if (sa.hasParam("OptionQuestion")) {
|
||||
message = TextUtil.fastReplace(sa.getParam("OptionQuestion"), "TARGETS", targets);
|
||||
} else {
|
||||
message = Localizer.getInstance().getMessage("lblMoveTargetFromOriginToDestination", targets, Lang.joinHomogenous(origin, ZoneType.Accessors.GET_TRANSLATED_NAME), destination.getTranslatedName());
|
||||
message = Localizer.getInstance().getMessage("lblMoveTargetFromOriginToDestination", targets, Lang.joinHomogenous(origin, ZoneType::getTranslatedName), destination.getTranslatedName());
|
||||
}
|
||||
|
||||
if (!sa.getActivatingPlayer().getController().confirmAction(sa, null, message, null)) {
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
fetchers = Lists.newArrayList(host.getController());
|
||||
}
|
||||
|
||||
final String fetcherNames = Lang.joinHomogenous(fetchers, Player.Accessors.FN_GET_NAME);
|
||||
final String fetcherNames = Lang.joinHomogenous(fetchers, GameEntity::getName);
|
||||
|
||||
// Player who chooses the cards to move
|
||||
List<Player> choosers = Lists.newArrayList();
|
||||
@@ -536,7 +536,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
hostCard.addRemembered(CardCopyService.getLKICopy(gameCard));
|
||||
}
|
||||
|
||||
final String prompt = TextUtil.concatWithSpace(Localizer.getInstance().getMessage("lblDoYouWantMoveTargetFromOriToDest", CardTranslation.getTranslatedName(gameCard.getName()), Lang.joinHomogenous(origin, ZoneType.Accessors.GET_TRANSLATED_NAME), destination.getTranslatedName()));
|
||||
final String prompt = TextUtil.concatWithSpace(Localizer.getInstance().getMessage("lblDoYouWantMoveTargetFromOriToDest", CardTranslation.getTranslatedName(gameCard.getName()), Lang.joinHomogenous(origin, ZoneType::getTranslatedName), destination.getTranslatedName()));
|
||||
if (optional && !chooser.getController().confirmAction(sa, null, prompt, null))
|
||||
continue;
|
||||
|
||||
@@ -956,9 +956,9 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
prompt = sa.getParam("OptionalPrompt");
|
||||
} else {
|
||||
if (defined) {
|
||||
prompt = Localizer.getInstance().getMessage("lblPutThatCardFromPlayerOriginToDestination", "{player's}", Lang.joinHomogenous(origin, ZoneType.Accessors.GET_TRANSLATED_NAME).toLowerCase(), destination.getTranslatedName().toLowerCase());
|
||||
prompt = Localizer.getInstance().getMessage("lblPutThatCardFromPlayerOriginToDestination", "{player's}", Lang.joinHomogenous(origin, ZoneType::getTranslatedName).toLowerCase(), destination.getTranslatedName().toLowerCase());
|
||||
} else {
|
||||
prompt = Localizer.getInstance().getMessage("lblSearchPlayerZoneConfirm", "{player's}", Lang.joinHomogenous(origin, ZoneType.Accessors.GET_TRANSLATED_NAME).toLowerCase());
|
||||
prompt = Localizer.getInstance().getMessage("lblSearchPlayerZoneConfirm", "{player's}", Lang.joinHomogenous(origin, ZoneType::getTranslatedName).toLowerCase());
|
||||
}
|
||||
}
|
||||
String message = MessageUtil.formatMessage(prompt , decider, player);
|
||||
@@ -1089,7 +1089,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
source.clearRemembered();
|
||||
}
|
||||
|
||||
String selectPrompt = sa.hasParam("SelectPrompt") ? sa.getParam("SelectPrompt") : MessageUtil.formatMessage(Localizer.getInstance().getMessage("lblSelectCardFromPlayerZone", "{player's}", Lang.joinHomogenous(origin, ZoneType.Accessors.GET_TRANSLATED_NAME).toLowerCase()), decider, player);
|
||||
String selectPrompt = sa.hasParam("SelectPrompt") ? sa.getParam("SelectPrompt") : MessageUtil.formatMessage(Localizer.getInstance().getMessage("lblSelectCardFromPlayerZone", "{player's}", Lang.joinHomogenous(origin, ZoneType::getTranslatedName).toLowerCase()), decider, player);
|
||||
final String totalcmc = sa.getParam("WithTotalCMC");
|
||||
final String totalpower = sa.getParam("WithTotalPower");
|
||||
int totcmc = AbilityUtils.calculateAmount(source, totalcmc, sa);
|
||||
@@ -1119,9 +1119,9 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
// new default messaging for multi select
|
||||
if (fetchList.size() > changeNum) {
|
||||
//Select up to %changeNum cards from %players %origin
|
||||
selectPrompt = MessageUtil.formatMessage(Localizer.getInstance().getMessage("lblSelectUpToNumCardFromPlayerZone", String.valueOf(changeNum), "{player's}", Lang.joinHomogenous(origin, ZoneType.Accessors.GET_TRANSLATED_NAME).toLowerCase()), decider, player);
|
||||
selectPrompt = MessageUtil.formatMessage(Localizer.getInstance().getMessage("lblSelectUpToNumCardFromPlayerZone", String.valueOf(changeNum), "{player's}", Lang.joinHomogenous(origin, ZoneType::getTranslatedName).toLowerCase()), decider, player);
|
||||
} else {
|
||||
selectPrompt = MessageUtil.formatMessage(Localizer.getInstance().getMessage("lblSelectCardsFromPlayerZone", "{player's}", Lang.joinHomogenous(origin, ZoneType.Accessors.GET_TRANSLATED_NAME).toLowerCase()), decider, player);
|
||||
selectPrompt = MessageUtil.formatMessage(Localizer.getInstance().getMessage("lblSelectCardsFromPlayerZone", "{player's}", Lang.joinHomogenous(origin, ZoneType::getTranslatedName).toLowerCase()), decider, player);
|
||||
}
|
||||
}
|
||||
// ensure that selection is within maximum allowed changeNum
|
||||
@@ -1147,7 +1147,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()), CardPredicates.Accessors.fnGetNetPower)));
|
||||
fetchList = CardLists.filter(fetchList, Predicates.not(Predicates.compose(Predicates.equalTo(c.getNetPower()), Card::getNetPower)));
|
||||
}
|
||||
}
|
||||
if (sa.hasParam("ShareLandType")) {
|
||||
|
||||
@@ -269,12 +269,7 @@ public class CharmEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
// Sort Chosen by SA order
|
||||
chosen.sort(new Comparator<AbilitySub>() {
|
||||
@Override
|
||||
public int compare(AbilitySub o1, AbilitySub o2) {
|
||||
return Integer.compare(o1.getSVarInt("CharmOrder"), o2.getSVarInt("CharmOrder"));
|
||||
}
|
||||
});
|
||||
chosen.sort(Comparator.comparingInt(o -> o.getSVarInt("CharmOrder")));
|
||||
|
||||
for (AbilitySub sub : chosen) {
|
||||
// Clone the chosen, just in case the same subAb gets chosen multiple times
|
||||
|
||||
@@ -155,7 +155,7 @@ public class ChooseCardEffect extends SpellAbilityEffect {
|
||||
} else if (sa.hasParam("WithTotalPower")) {
|
||||
final int totP = AbilityUtils.calculateAmount(host, sa.getParam("WithTotalPower"), sa);
|
||||
CardCollection negativeCreats = CardLists.filterLEPower(p.getCreaturesInPlay(), -1);
|
||||
int negativeNum = Aggregates.sum(negativeCreats, CardPredicates.Accessors.fnGetNetPower);
|
||||
int negativeNum = Aggregates.sum(negativeCreats, Card::getNetPower);
|
||||
CardCollection creature = CardLists.filterLEPower(p.getCreaturesInPlay(), totP - negativeNum);
|
||||
CardCollection chosenPool = new CardCollection();
|
||||
int chosenP = 0;
|
||||
@@ -171,7 +171,7 @@ public class ChooseCardEffect extends SpellAbilityEffect {
|
||||
chosenP += c.getNetPower();
|
||||
chosenPool.add(c);
|
||||
negativeCreats.remove(c);
|
||||
negativeNum = Aggregates.sum(negativeCreats, CardPredicates.Accessors.fnGetNetPower);
|
||||
negativeNum = Aggregates.sum(negativeCreats, Card::getNetPower);
|
||||
creature = CardLists.filterLEPower(p.getCreaturesInPlay(), totP - chosenP - negativeNum);
|
||||
creature.removeAll(chosenPool);
|
||||
}
|
||||
|
||||
@@ -33,25 +33,17 @@ public class ControlPlayerEffect extends SpellAbilityEffect {
|
||||
|
||||
for (final Player pTarget: getTargetPlayers(sa)) {
|
||||
// before next untap gain control
|
||||
game.getCleanup().addUntil(pTarget, new GameCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
// CR 800.4b
|
||||
if (!controller.isInGame()) {
|
||||
return;
|
||||
}
|
||||
|
||||
long ts = game.getNextTimestamp();
|
||||
pTarget.addController(ts, controller);
|
||||
|
||||
// after following cleanup release control
|
||||
game.getCleanup().addUntil(new GameCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
pTarget.removeController(ts);
|
||||
}
|
||||
});
|
||||
game.getCleanup().addUntil(pTarget, (GameCommand) () -> {
|
||||
// CR 800.4b
|
||||
if (!controller.isInGame()) {
|
||||
return;
|
||||
}
|
||||
|
||||
long ts = game.getNextTimestamp();
|
||||
pTarget.addController(ts, controller);
|
||||
|
||||
// after following cleanup release control
|
||||
game.getCleanup().addUntil((GameCommand) () -> pTarget.removeController(ts));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,11 +152,11 @@ public class CopyPermanentEffect extends TokenEffectBase {
|
||||
"X", Integer.toString(AbilityUtils.calculateAmount(host, "X", sa)));
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(valid, "creature")) {
|
||||
Predicate<PaperCard> cpp = Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, PaperCard.FN_GET_RULES);
|
||||
Predicate<PaperCard> cpp = Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, PaperCard::getRules);
|
||||
cards = Lists.newArrayList(Iterables.filter(cards, cpp));
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(valid, "equipment")) {
|
||||
Predicate<PaperCard> cpp = Predicates.compose(CardRulesPredicates.Presets.IS_EQUIPMENT, PaperCard.FN_GET_RULES);
|
||||
Predicate<PaperCard> cpp = Predicates.compose(CardRulesPredicates.Presets.IS_EQUIPMENT, PaperCard::getRules);
|
||||
cards = Lists.newArrayList(Iterables.filter(cards, cpp));
|
||||
}
|
||||
if (sa.hasParam("RandomCopied")) {
|
||||
@@ -187,7 +187,7 @@ public class CopyPermanentEffect extends TokenEffectBase {
|
||||
}
|
||||
}
|
||||
|
||||
Predicate<PaperCard> cpp = Predicates.compose(CardRulesPredicates.name(StringOp.EQUALS, name), PaperCard.FN_GET_RULES);
|
||||
Predicate<PaperCard> cpp = Predicates.compose(CardRulesPredicates.name(StringOp.EQUALS, name), PaperCard::getRules);
|
||||
cards = Lists.newArrayList(Iterables.filter(cards, cpp));
|
||||
|
||||
if (!cards.isEmpty()) {
|
||||
|
||||
@@ -193,7 +193,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
||||
if (sa.hasParam("Bolster")) {
|
||||
CardCollection creatsYouCtrl = activator.getCreaturesInPlay();
|
||||
CardCollection leastToughness = new CardCollection(
|
||||
Aggregates.listWithMin(creatsYouCtrl, CardPredicates.Accessors.fnGetNetToughness));
|
||||
Aggregates.listWithMin(creatsYouCtrl, Card::getNetToughness));
|
||||
|
||||
Map<String, Object> params = Maps.newHashMap();
|
||||
params.put("CounterType", counterType);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
@@ -100,23 +99,20 @@ public class FlipOntoBattlefieldEffect extends SpellAbilityEffect {
|
||||
Player controller = c.getController();
|
||||
ArrayList<Card> attachments = Lists.newArrayList();
|
||||
ArrayList<Card> cardsOTB = Lists.newArrayList(CardLists.filter(
|
||||
controller.getCardsIn(ZoneType.Battlefield), new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card card) {
|
||||
if (card.isAttachedToEntity(c)) {
|
||||
attachments.add(card);
|
||||
return true;
|
||||
} else if (c.isCreature()) {
|
||||
return card.isCreature();
|
||||
} else if (c.isPlaneswalker() || c.isArtifact() || (c.isEnchantment() && !c.isAura())) {
|
||||
return card.isPlaneswalker() || card.isArtifact() || (c.isEnchantment() && !c.isAura());
|
||||
} else if (c.isLand()) {
|
||||
return card.isLand();
|
||||
} else if (c.isAttachedToEntity()) {
|
||||
return card.isAttachedToEntity(c.getEntityAttachedTo()) || c.equals(card.getAttachedTo());
|
||||
}
|
||||
return card.sharesCardTypeWith(c);
|
||||
controller.getCardsIn(ZoneType.Battlefield), card -> {
|
||||
if (card.isAttachedToEntity(c)) {
|
||||
attachments.add(card);
|
||||
return true;
|
||||
} else if (c.isCreature()) {
|
||||
return card.isCreature();
|
||||
} else if (c.isPlaneswalker() || c.isArtifact() || (c.isEnchantment() && !c.isAura())) {
|
||||
return card.isPlaneswalker() || card.isArtifact() || (c.isEnchantment() && !c.isAura());
|
||||
} else if (c.isLand()) {
|
||||
return card.isLand();
|
||||
} else if (c.isAttachedToEntity()) {
|
||||
return card.isAttachedToEntity(c.getEntityAttachedTo()) || c.equals(card.getAttachedTo());
|
||||
}
|
||||
return card.sharesCardTypeWith(c);
|
||||
}
|
||||
));
|
||||
|
||||
|
||||
@@ -125,11 +125,11 @@ public class PlayEffect extends SpellAbilityEffect {
|
||||
}
|
||||
} else if (valid.equalsIgnoreCase("sorcery")) {
|
||||
cards = Lists.newArrayList(StaticData.instance().getCommonCards().getUniqueCards());
|
||||
final Predicate<PaperCard> cpp = Predicates.compose(CardRulesPredicates.Presets.IS_SORCERY, PaperCard.FN_GET_RULES);
|
||||
final Predicate<PaperCard> cpp = Predicates.compose(CardRulesPredicates.Presets.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<PaperCard> cpp = Predicates.compose(CardRulesPredicates.Presets.IS_INSTANT, PaperCard.FN_GET_RULES);
|
||||
final Predicate<PaperCard> cpp = Predicates.compose(CardRulesPredicates.Presets.IS_INSTANT, PaperCard::getRules);
|
||||
cards = Lists.newArrayList(Iterables.filter(cards, cpp));
|
||||
}
|
||||
if (sa.hasParam("RandomCopied")) {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class PlayLandVariantEffect extends SpellAbilityEffect {
|
||||
final String landType = sa.getParam("Clone");
|
||||
List<PaperCard> cards = Lists.newArrayList(StaticData.instance().getCommonCards().getUniqueCards());
|
||||
if ("BasicLand".equals(landType)) {
|
||||
final Predicate<PaperCard> cpp = Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard.FN_GET_RULES);
|
||||
final Predicate<PaperCard> cpp = Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, PaperCard::getRules);
|
||||
cards = Lists.newArrayList(Iterables.filter(cards, cpp));
|
||||
}
|
||||
// current color of source card
|
||||
@@ -47,12 +47,7 @@ public class PlayLandVariantEffect extends SpellAbilityEffect {
|
||||
}
|
||||
}
|
||||
|
||||
final Predicate<PaperCard> cp = Predicates.compose(new Predicate<String>() {
|
||||
@Override
|
||||
public boolean apply(final String name) {
|
||||
return landNames.contains(name);
|
||||
}
|
||||
}, PaperCard.FN_GET_NAME);
|
||||
final Predicate<PaperCard> cp = Predicates.compose(landNames::contains, PaperCard::getName);
|
||||
cards = Lists.newArrayList(Iterables.filter(cards, cp));
|
||||
// get a random basic land
|
||||
Card random;
|
||||
|
||||
@@ -7,8 +7,6 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -361,23 +359,19 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
PlayerCollection players = AbilityUtils.getDefinedPlayers(host, defined, sa);
|
||||
if (players.isEmpty()) return;
|
||||
List<String> newKeywords = Lists.newArrayList();
|
||||
Iterables.removeIf(keywords, new Predicate<String>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(String input) {
|
||||
if (!input.contains("ChosenPlayerUID") && !input.contains("ChosenPlayerName")) {
|
||||
return false;
|
||||
}
|
||||
for (Player p : players) {
|
||||
String replacedID = String.valueOf(p.getId());
|
||||
String replacedName = p.getName();
|
||||
|
||||
String s = input.replaceAll("ChosenPlayerUID", replacedID);
|
||||
s = s.replaceAll("ChosenPlayerName", replacedName);
|
||||
newKeywords.add(s);
|
||||
}
|
||||
return true;
|
||||
Iterables.removeIf(keywords, input -> {
|
||||
if (!input.contains("ChosenPlayerUID") && !input.contains("ChosenPlayerName")) {
|
||||
return false;
|
||||
}
|
||||
for (Player p : players) {
|
||||
String replacedID = String.valueOf(p.getId());
|
||||
String replacedName = p.getName();
|
||||
|
||||
String s = input.replaceAll("ChosenPlayerUID", replacedID);
|
||||
s = s.replaceAll("ChosenPlayerName", replacedName);
|
||||
newKeywords.add(s);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
keywords.addAll(newKeywords);
|
||||
}
|
||||
@@ -480,30 +474,23 @@ public class PumpEffect extends SpellAbilityEffect {
|
||||
List<String> affectedKeywords = Lists.newArrayList(keywords);
|
||||
|
||||
if (!affectedKeywords.isEmpty()) {
|
||||
Iterables.removeIf(affectedKeywords, new Predicate<String>() {
|
||||
@Override
|
||||
public boolean apply(String input) {
|
||||
if (input.contains("CardManaCost")) {
|
||||
if (tgtC.getManaCost().isNoCost()) {
|
||||
return true;
|
||||
}
|
||||
Iterables.removeIf(affectedKeywords, input -> {
|
||||
if (input.contains("CardManaCost")) {
|
||||
if (tgtC.getManaCost().isNoCost()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
affectedKeywords = Lists.transform(affectedKeywords, new Function<String, String>() {
|
||||
|
||||
@Override
|
||||
public String apply(String input) {
|
||||
if (input.contains("CardManaCost")) {
|
||||
input = input.replace("CardManaCost", tgtC.getManaCost().getShortString());
|
||||
} else if (input.contains("ConvertedManaCost")) {
|
||||
final String costcmc = Integer.toString(tgtC.getCMC());
|
||||
input = input.replace("ConvertedManaCost", costcmc);
|
||||
}
|
||||
return input;
|
||||
affectedKeywords = Lists.transform(affectedKeywords, input -> {
|
||||
if (input.contains("CardManaCost")) {
|
||||
input = input.replace("CardManaCost", tgtC.getManaCost().getShortString());
|
||||
} else if (input.contains("ConvertedManaCost")) {
|
||||
final String costcmc = Integer.toString(tgtC.getCMC());
|
||||
input = input.replace("ConvertedManaCost", costcmc);
|
||||
}
|
||||
return input;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -184,16 +184,13 @@ public class RepeatEachEffect extends SpellAbilityEffect {
|
||||
continue;
|
||||
}
|
||||
if (nextTurn) {
|
||||
game.getCleanup().addUntil(p, new GameCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<Object> tempRemembered = Lists.newArrayList(Iterables.filter(source.getRemembered(), Player.class));
|
||||
source.removeRemembered(tempRemembered);
|
||||
source.addRemembered(p);
|
||||
AbilityUtils.resolve(repeat);
|
||||
source.removeRemembered(p);
|
||||
source.addRemembered(tempRemembered);
|
||||
}
|
||||
game.getCleanup().addUntil(p, (GameCommand) () -> {
|
||||
List<Object> tempRemembered = Lists.newArrayList(Iterables.filter(source.getRemembered(), Player.class));
|
||||
source.removeRemembered(tempRemembered);
|
||||
source.addRemembered(p);
|
||||
AbilityUtils.resolve(repeat);
|
||||
source.removeRemembered(p);
|
||||
source.addRemembered(tempRemembered);
|
||||
});
|
||||
} else {
|
||||
// to avoid risk of collision with other abilities swap out other Remembered Player while resolving
|
||||
|
||||
@@ -30,7 +30,7 @@ import forge.util.collect.FCollectionView;
|
||||
|
||||
public class SubgameEffect extends SpellAbilityEffect {
|
||||
|
||||
private final Game createSubGame(Game maingame, int startingLife) {
|
||||
private Game createSubGame(Game maingame, int startingLife) {
|
||||
List<RegisteredPlayer> players = Lists.newArrayList();
|
||||
|
||||
// Add remaining players to subgame
|
||||
@@ -41,7 +41,7 @@ public class SubgameEffect extends SpellAbilityEffect {
|
||||
return new Game(players, maingame.getRules(), maingame.getMatch(), maingame, startingLife);
|
||||
}
|
||||
|
||||
private final void setCardsInZone(Player player, final ZoneType zoneType, final CardCollectionView oldCards, boolean addMapping) {
|
||||
private void setCardsInZone(Player player, final ZoneType zoneType, final CardCollectionView oldCards, boolean addMapping) {
|
||||
PlayerZone zone = player.getZone(zoneType);
|
||||
List<Card> newCards = Lists.newArrayList();
|
||||
for (final Card card : oldCards) {
|
||||
@@ -59,7 +59,7 @@ public class SubgameEffect extends SpellAbilityEffect {
|
||||
zone.setCards(newCards);
|
||||
}
|
||||
|
||||
private final void initVariantsZonesSubgame(final Game subgame, final Player maingamePlayer, final Player player) {
|
||||
private void initVariantsZonesSubgame(final Game subgame, final Player maingamePlayer, final Player player) {
|
||||
PlayerZone com = player.getZone(ZoneType.Command);
|
||||
RegisteredPlayer registeredPlayer = player.getRegisteredPlayer();
|
||||
|
||||
|
||||
@@ -49,11 +49,11 @@ public class VentureEffect extends SpellAbilityEffect {
|
||||
.getAllCards(Predicates.compose(
|
||||
Predicates.and(CardRulesPredicates.Presets.IS_DUNGEON,
|
||||
CardRulesPredicates.subType(StringOp.EQUALS, sa.getParam("Dungeon"))),
|
||||
PaperCard.FN_GET_RULES));
|
||||
PaperCard::getRules));
|
||||
} else {
|
||||
// Create a new dungeon card chosen by player in command zone.
|
||||
dungeonCards = StaticData.instance().getVariantCards().getAllCards(
|
||||
Predicates.compose(CardRulesPredicates.Presets.IS_DUNGEON, PaperCard.FN_GET_RULES));
|
||||
Predicates.compose(CardRulesPredicates.Presets.IS_DUNGEON, PaperCard::getRules));
|
||||
dungeonCards.removeIf(c -> !c.getRules().isEnterableDungeon());
|
||||
}
|
||||
String message = Localizer.getInstance().getMessage("lblChooseDungeon");
|
||||
|
||||
@@ -4362,7 +4362,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
updateCloneState(true);
|
||||
}
|
||||
|
||||
private final void updateCloneState(final boolean updateView) {
|
||||
private void updateCloneState(final boolean updateView) {
|
||||
if (isFaceDown()) {
|
||||
setState(CardStateName.FaceDown, updateView, true);
|
||||
} else {
|
||||
@@ -4385,7 +4385,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
return CardStateName.Original;
|
||||
}
|
||||
|
||||
private final CardCloneStates getLastClonedState() {
|
||||
private CardCloneStates getLastClonedState() {
|
||||
if (clonedStates.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -5123,7 +5123,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
}
|
||||
}
|
||||
|
||||
private final KeywordInterface getCopyForStoredKeyword(Map.Entry<Triple<String, Long, Long>, KeywordInterface> e, boolean lki) {
|
||||
private KeywordInterface getCopyForStoredKeyword(Map.Entry<Triple<String, Long, Long>, KeywordInterface> e, boolean lki) {
|
||||
// for performance check if we already copied this
|
||||
if (lki) {
|
||||
for (KeywordsChange kc : changedCardKeywords.column(e.getKey().getMiddle()).values()) {
|
||||
@@ -6154,7 +6154,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
public final void setExcessDamageReceivedThisTurn(final int n) {
|
||||
excessDamageThisTurnAmount = n;
|
||||
}
|
||||
private final void resetExcessDamage() {
|
||||
private void resetExcessDamage() {
|
||||
hasBeenDealtExcessDamageThisTurn = false;
|
||||
excessDamageThisTurnAmount = 0;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
package forge.game.card;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import forge.ImageKeys;
|
||||
@@ -445,12 +444,7 @@ public class CardFactory {
|
||||
to.setAdditionalAbility(e.getKey(), e.getValue().copy(host, p, lki, keepTextChanges));
|
||||
}
|
||||
for (Map.Entry<String, List<AbilitySub>> e : from.getAdditionalAbilityLists().entrySet()) {
|
||||
to.setAdditionalAbilityList(e.getKey(), Lists.transform(e.getValue(), new Function<AbilitySub, AbilitySub>() {
|
||||
@Override
|
||||
public AbilitySub apply(AbilitySub input) {
|
||||
return (AbilitySub) input.copy(host, p, lki, keepTextChanges);
|
||||
}
|
||||
}));
|
||||
to.setAdditionalAbilityList(e.getKey(), Lists.transform(e.getValue(), input -> (AbilitySub) input.copy(host, p, lki, keepTextChanges)));
|
||||
}
|
||||
if (from.getRestrictions() != null) {
|
||||
to.setRestrictions((SpellAbilityRestriction) from.getRestrictions().copy());
|
||||
|
||||
@@ -54,65 +54,23 @@ public class CardLists {
|
||||
* @return a CardCollection
|
||||
*/
|
||||
public static CardCollection filterToughness(final Iterable<Card> in, final int atLeastToughness) {
|
||||
return CardLists.filter(in, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.getNetToughness() <= atLeastToughness;
|
||||
}
|
||||
});
|
||||
return CardLists.filter(in, c -> c.getNetToughness() <= atLeastToughness);
|
||||
}
|
||||
|
||||
public static CardCollection filterPower(final Iterable<Card> in, final int atLeastPower) {
|
||||
return CardLists.filter(in, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.getNetPower() >= atLeastPower;
|
||||
}
|
||||
});
|
||||
return CardLists.filter(in, c -> c.getNetPower() >= atLeastPower);
|
||||
}
|
||||
|
||||
public static CardCollection filterLEPower(final Iterable<Card> in, final int lessthanPower) {
|
||||
return CardLists.filter(in, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.getNetPower() <= lessthanPower;
|
||||
}
|
||||
});
|
||||
return CardLists.filter(in, c -> c.getNetPower() <= lessthanPower);
|
||||
}
|
||||
|
||||
public static final Comparator<Card> ToughnessComparator = new Comparator<Card>() {
|
||||
@Override
|
||||
public int compare(final Card a, final Card b) {
|
||||
return a.getNetToughness() - b.getNetToughness();
|
||||
}
|
||||
};
|
||||
public static final Comparator<Card> ToughnessComparatorInv = new Comparator<Card>() {
|
||||
@Override
|
||||
public int compare(final Card a, final Card b) {
|
||||
return b.getNetToughness() - a.getNetToughness();
|
||||
}
|
||||
};
|
||||
public static final Comparator<Card> PowerComparator = new Comparator<Card>() {
|
||||
@Override
|
||||
public int compare(final Card a, final Card b) {
|
||||
return a.getNetCombatDamage() - b.getNetCombatDamage();
|
||||
}
|
||||
};
|
||||
public static final Comparator<Card> CmcComparatorInv = new Comparator<Card>() {
|
||||
@Override
|
||||
public int compare(final Card a, final Card b) {
|
||||
return b.getCMC() - a.getCMC();
|
||||
}
|
||||
};
|
||||
public static final Comparator<Card> ToughnessComparator = Comparator.comparingInt(Card::getNetToughness);
|
||||
public static final Comparator<Card> ToughnessComparatorInv = Comparator.comparingInt(Card::getNetToughness).reversed();
|
||||
public static final Comparator<Card> PowerComparator = Comparator.comparingInt(Card::getNetCombatDamage);
|
||||
public static final Comparator<Card> CmcComparatorInv = Comparator.<Card>comparingInt(Card::getCMC).reversed();
|
||||
|
||||
public static final Comparator<Card> TextLenComparator = new Comparator<Card>() {
|
||||
@Override
|
||||
public int compare(final Card a, final Card b) {
|
||||
final int aLen = a.getView().getText().length();
|
||||
final int bLen = b.getView().getText().length();
|
||||
return aLen - bLen;
|
||||
}
|
||||
};
|
||||
public static final Comparator<Card> TextLenComparator = Comparator.comparingInt(a -> a.getView().getText().length());
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
||||
@@ -19,12 +19,12 @@ package forge.game.card;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.card.CardStateName;
|
||||
import forge.game.CardTraitBase;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.keyword.Keyword;
|
||||
import forge.game.keyword.KeywordInterface;
|
||||
@@ -46,490 +46,255 @@ import forge.util.collect.FCollectionView;
|
||||
*/
|
||||
public final class CardPredicates {
|
||||
|
||||
public static final Predicate<Card> isController(final Player p) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.getController().equals(p);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> isController(final Player p) {
|
||||
return c -> c.getController().equals(p);
|
||||
}
|
||||
public static final Predicate<Card> isControlledByAnyOf(final FCollectionView<Player> pList) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return pList.contains(c.getController());
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> isControlledByAnyOf(final FCollectionView<Player> pList) {
|
||||
return c -> pList.contains(c.getController());
|
||||
}
|
||||
public static final Predicate<Card> isOwner(final Player p) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return p.equals(c.getOwner());
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> isOwner(final Player p) {
|
||||
return c -> p.equals(c.getOwner());
|
||||
}
|
||||
|
||||
public static final Predicate<Card> ownerLives() {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return !c.getOwner().hasLost();
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> ownerLives() {
|
||||
return c -> !c.getOwner().hasLost();
|
||||
}
|
||||
|
||||
public static final Predicate<Card> isType(final String cardType) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.getType().hasStringType(cardType);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> isType(final String cardType) {
|
||||
return c -> c.getType().hasStringType(cardType);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> hasKeyword(final String keyword) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.hasKeyword(keyword);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> hasKeyword(final String keyword) {
|
||||
return c -> c.hasKeyword(keyword);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> hasKeyword(final Keyword keyword) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.hasKeyword(keyword);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> hasKeyword(final Keyword keyword) {
|
||||
return c -> c.hasKeyword(keyword);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> containsKeyword(final String keyword) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (Iterables.any(c.getHiddenExtrinsicKeywords(), PredicateString.contains(keyword))) {
|
||||
public static Predicate<Card> containsKeyword(final String keyword) {
|
||||
return c -> {
|
||||
if (Iterables.any(c.getHiddenExtrinsicKeywords(), PredicateString.contains(keyword))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (KeywordInterface k : c.getKeywords()) {
|
||||
if (k.getOriginal().contains(keyword)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (KeywordInterface k : c.getKeywords()) {
|
||||
if (k.getOriginal().contains(keyword)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> isTargetableBy(final SpellAbility source) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return source.canTarget(c);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> isTargetableBy(final SpellAbility source) {
|
||||
return source::canTarget;
|
||||
}
|
||||
|
||||
public static final Predicate<Card> nameEquals(final String name) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.getName().equals(name);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> nameEquals(final String name) {
|
||||
return c -> c.getName().equals(name);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> sharesNameWith(final Card name) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.sharesNameWith(name);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> sharesNameWith(final Card name) {
|
||||
return c -> c.sharesNameWith(name);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> sharesCMCWith(final Card cmc) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.sharesCMCWith(cmc);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> sharesCMCWith(final Card cmc) {
|
||||
return c -> c.sharesCMCWith(cmc);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> sharesColorWith(final Card color) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.sharesColorWith(color);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> sharesColorWith(final Card color) {
|
||||
return c -> c.sharesColorWith(color);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> sharesControllerWith(final Card card) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.sharesControllerWith(card);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> sharesControllerWith(final Card card) {
|
||||
return c -> c.sharesControllerWith(card);
|
||||
}
|
||||
|
||||
public static Predicate<Card> sharesCardTypeWith(final Card card) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.sharesCardTypeWith(card);
|
||||
}
|
||||
};
|
||||
return c -> c.sharesCardTypeWith(card);
|
||||
}
|
||||
|
||||
public static Predicate<Card> sharesCreatureTypeWith(final Card card) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.sharesCreatureTypeWith(card);
|
||||
}
|
||||
};
|
||||
return c -> c.sharesCreatureTypeWith(card);
|
||||
}
|
||||
|
||||
public static Predicate<Card> sharesLandTypeWith(final Card card) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.sharesLandTypeWith(card);
|
||||
}
|
||||
};
|
||||
return c -> c.sharesLandTypeWith(card);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> possibleBlockers(final Card attacker) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.isCreature() && CombatUtil.canBlock(attacker, c);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> possibleBlockers(final Card attacker) {
|
||||
return c -> c.isCreature() && CombatUtil.canBlock(attacker, c);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> possibleBlockerForAtLeastOne(final Iterable<Card> attackers) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.isCreature() && CombatUtil.canBlockAtLeastOne(c, attackers);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> possibleBlockerForAtLeastOne(final Iterable<Card> attackers) {
|
||||
return c -> c.isCreature() && CombatUtil.canBlockAtLeastOne(c, attackers);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> restriction(final String[] restrictions, final Player sourceController, final Card source, final CardTraitBase spellAbility) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c != null && c.isValid(restrictions, sourceController, source, spellAbility);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> restriction(final String[] restrictions, final Player sourceController, final Card source, final CardTraitBase spellAbility) {
|
||||
return c -> c != null && c.isValid(restrictions, sourceController, source, spellAbility);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> restriction(final String restrictions, final Player sourceController, final Card source, final CardTraitBase spellAbility) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c != null && c.isValid(restrictions, sourceController, source, spellAbility);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> restriction(final String restrictions, final Player sourceController, final Card source, final CardTraitBase spellAbility) {
|
||||
return c -> c != null && c.isValid(restrictions, sourceController, source, spellAbility);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> canBeSacrificedBy(final SpellAbility sa, final boolean effect) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.canBeSacrificedBy(sa, effect);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> canBeSacrificedBy(final SpellAbility sa, final boolean effect) {
|
||||
return c -> c.canBeSacrificedBy(sa, effect);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> canExiledBy(final SpellAbility sa, final boolean effect) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.canExiledBy(sa, effect);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> canExiledBy(final SpellAbility sa, final boolean effect) {
|
||||
return c -> c.canExiledBy(sa, effect);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> canBeAttached(final Card aura, final SpellAbility sa) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.canBeAttached(aura, sa);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> canBeAttached(final Card aura, final SpellAbility sa) {
|
||||
return c -> c.canBeAttached(aura, sa);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> isColor(final byte color) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.getColor().hasAnyColor(color);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> isColor(final byte color) {
|
||||
return c -> c.getColor().hasAnyColor(color);
|
||||
} // getColor()
|
||||
|
||||
public static final Predicate<Card> isExactlyColor(final byte color) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.getColor().hasExactlyColor(color);
|
||||
}
|
||||
public static Predicate<Card> isExactlyColor(final byte color) {
|
||||
return c -> c.getColor().hasExactlyColor(color);
|
||||
}
|
||||
|
||||
public static Predicate<Card> isColorless() {
|
||||
return c -> c.getColor().isColorless();
|
||||
}
|
||||
|
||||
public static Predicate<Card> isEquippedBy(final String name) {
|
||||
return c -> c.isEquippedBy(name);
|
||||
}
|
||||
|
||||
public static Predicate<Card> isEnchantedBy(final String name) {
|
||||
return c -> c.isEnchantedBy(name);
|
||||
}
|
||||
|
||||
public static Predicate<Card> hasCMC(final int cmc) {
|
||||
return c -> c.sharesCMCWith(cmc);
|
||||
}
|
||||
|
||||
public static Predicate<Card> greaterCMC(final int cmc) {
|
||||
return c -> {
|
||||
// do not check for Split card anymore
|
||||
return c.getCMC() >= cmc;
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> isColorless() {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.getColor().isColorless();
|
||||
}
|
||||
public static Predicate<Card> lessCMC(final int cmc) {
|
||||
return c -> {
|
||||
// do not check for Split card anymore
|
||||
return c.getCMC() <= cmc;
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> isEquippedBy(final String name) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.isEquippedBy(name);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> evenCMC() {
|
||||
return c -> c.getCMC() % 2 == 0;
|
||||
}
|
||||
|
||||
public static final Predicate<Card> isEnchantedBy(final String name) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.isEnchantedBy(name);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> oddCMC() {
|
||||
return c -> c.getCMC() % 2 == 1;
|
||||
}
|
||||
|
||||
public static final Predicate<Card> hasCMC(final int cmc) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.sharesCMCWith(cmc);
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> hasSuspend() {
|
||||
return Card::hasSuspend;
|
||||
}
|
||||
|
||||
public static final Predicate<Card> greaterCMC(final int cmc) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
// do not check for Split card anymore
|
||||
return c.getCMC() >= cmc;
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> hasCounters() {
|
||||
return GameEntity::hasCounters;
|
||||
}
|
||||
|
||||
public static final Predicate<Card> lessCMC(final int cmc) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
// do not check for Split card anymore
|
||||
return c.getCMC() <= cmc;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> evenCMC() {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.getCMC() % 2 == 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> oddCMC() {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.getCMC() % 2 == 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> hasSuspend() {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.hasSuspend();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> hasCounters() {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.hasCounters();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> hasCounter(final CounterType type) {
|
||||
public static Predicate<Card> hasCounter(final CounterType type) {
|
||||
return hasCounter(type, 1);
|
||||
}
|
||||
public static final Predicate<Card> hasCounter(final CounterEnumType type) {
|
||||
public static Predicate<Card> hasCounter(final CounterEnumType type) {
|
||||
return hasCounter(type, 1);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> hasCounter(final CounterType type, final int n) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.getCounters(type) >= n;
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> hasCounter(final CounterType type, final int n) {
|
||||
return c -> c.getCounters(type) >= n;
|
||||
}
|
||||
public static final Predicate<Card> hasCounter(final CounterEnumType type, final int n) {
|
||||
public static Predicate<Card> hasCounter(final CounterEnumType type, final int n) {
|
||||
return hasCounter(CounterType.get(type), n);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> hasLessCounter(final CounterType type, final int n) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
int x = c.getCounters(type);
|
||||
return x > 0 && x <= n;
|
||||
}
|
||||
public static Predicate<Card> hasLessCounter(final CounterType type, final int n) {
|
||||
return c -> {
|
||||
int x = c.getCounters(type);
|
||||
return x > 0 && x <= n;
|
||||
};
|
||||
}
|
||||
public static final Predicate<Card> hasLessCounter(final CounterEnumType type, final int n) {
|
||||
public static Predicate<Card> hasLessCounter(final CounterEnumType type, final int n) {
|
||||
return hasLessCounter(CounterType.get(type), n);
|
||||
}
|
||||
|
||||
public static Predicate<Card> canReceiveCounters(final CounterType counter) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.canReceiveCounters(counter);
|
||||
}
|
||||
};
|
||||
return c -> c.canReceiveCounters(counter);
|
||||
}
|
||||
public static Predicate<Card> canReceiveCounters(final CounterEnumType counter) {
|
||||
return canReceiveCounters(CounterType.get(counter));
|
||||
}
|
||||
|
||||
public static final Predicate<Card> hasGreaterPowerThan(final int minPower) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.getNetPower() > minPower;
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> hasGreaterPowerThan(final int minPower) {
|
||||
return c -> c.getNetPower() > minPower;
|
||||
}
|
||||
|
||||
public static final Comparator<Card> compareByCounterType(final CounterType type) {
|
||||
return new Comparator<Card>() {
|
||||
@Override
|
||||
public int compare(Card arg0, Card arg1) {
|
||||
return Integer.compare(arg0.getCounters(type),
|
||||
arg1.getCounters(type));
|
||||
}
|
||||
};
|
||||
public static Comparator<Card> compareByCounterType(final CounterType type) {
|
||||
return Comparator.comparingInt(arg0 -> arg0.getCounters(type));
|
||||
}
|
||||
public static final Comparator<Card> compareByCounterType(final CounterEnumType type) {
|
||||
public static Comparator<Card> compareByCounterType(final CounterEnumType type) {
|
||||
return compareByCounterType(CounterType.get(type));
|
||||
}
|
||||
|
||||
public static final Predicate<Card> hasSVar(final String name) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.hasSVar(name);
|
||||
}
|
||||
public static Predicate<Card> hasSVar(final String name) {
|
||||
return c -> c.hasSVar(name);
|
||||
}
|
||||
|
||||
public static Predicate<Card> isExiledWith(final Card card) {
|
||||
return c -> card.equals(c.getExiledWith());
|
||||
}
|
||||
|
||||
public static Comparator<Card> compareByGameTimestamp() {
|
||||
return Comparator.comparingLong(Card::getGameTimestamp);
|
||||
}
|
||||
|
||||
public static Predicate<Card> inZone(final ZoneType zt) {
|
||||
return c -> {
|
||||
Zone z = c.getLastKnownZone();
|
||||
return z != null && z.is(zt);
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> isExiledWith(final Card card) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return card.equals(c.getExiledWith());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static final Comparator<Card> compareByGameTimestamp() {
|
||||
return new Comparator<Card>() {
|
||||
@Override
|
||||
public int compare(Card arg0, Card arg1) {
|
||||
return Long.compare(arg0.getGameTimestamp(), arg1.getGameTimestamp());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> inZone(final ZoneType zt) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
Zone z = c.getLastKnownZone();
|
||||
return z != null && z.is(zt);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> inZone(final Iterable<ZoneType> zt) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
Zone z = c.getLastKnownZone();
|
||||
if (z != null) {
|
||||
for (ZoneType t : zt) {
|
||||
if (z.is(t)) {
|
||||
return true;
|
||||
}
|
||||
public static Predicate<Card> inZone(final Iterable<ZoneType> zt) {
|
||||
return c -> {
|
||||
Zone z = c.getLastKnownZone();
|
||||
if (z != null) {
|
||||
for (ZoneType t : zt) {
|
||||
if (z.is(t)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
public static Predicate<Card> isRemAIDeck() {
|
||||
return c -> c.getRules() != null && c.getRules().getAiHints().getRemAIDecks();
|
||||
}
|
||||
|
||||
public static Predicate<Card> castSA(final Predicate<SpellAbility> predSA) {
|
||||
return c -> {
|
||||
if (c.getCastSA() == null) {
|
||||
return false;
|
||||
}
|
||||
return predSA.apply(c.getCastSA());
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> isRemAIDeck() {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c)
|
||||
{
|
||||
return c.getRules() != null && c.getRules().getAiHints().getRemAIDecks();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> castSA(final Predicate<SpellAbility> predSA) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c)
|
||||
{
|
||||
if (c.getCastSA() == null) {
|
||||
return false;
|
||||
}
|
||||
return predSA.apply(c.getCastSA());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Card> phasedIn() {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c)
|
||||
{
|
||||
return !c.isPhasedOut();
|
||||
}
|
||||
};
|
||||
public static Predicate<Card> phasedIn() {
|
||||
return c -> !c.isPhasedOut();
|
||||
}
|
||||
|
||||
public static Predicate<Card> isAttractionWithLight(int light) {
|
||||
@@ -541,275 +306,100 @@ public final class CardPredicates {
|
||||
/**
|
||||
* a Predicate<Card> to get all cards that are tapped.
|
||||
*/
|
||||
public static final Predicate<Card> TAPPED = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isTapped();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> TAPPED = Card::isTapped;
|
||||
|
||||
public static final Predicate<Card> FACE_DOWN = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isFaceDown();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> FACE_DOWN = Card::isFaceDown;
|
||||
|
||||
/**
|
||||
* a Predicate<Card> to get all cards that are untapped.
|
||||
*/
|
||||
public static final Predicate<Card> UNTAPPED = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isUntapped();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> UNTAPPED = Card::isUntapped;
|
||||
|
||||
public static final Predicate<Card> CAN_TAP = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.canTap();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> CAN_TAP = Card::canTap;
|
||||
|
||||
public static final Predicate<Card> CAN_CREW = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.canCrew();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> CAN_CREW = Card::canCrew;
|
||||
/**
|
||||
* a Predicate<Card> to get all creatures.
|
||||
*/
|
||||
public static final Predicate<Card> CREATURES = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isCreature();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> CREATURES = Card::isCreature;
|
||||
|
||||
/**
|
||||
* a Predicate<Card> to get all enchantments.
|
||||
*/
|
||||
public static final Predicate<Card> ENCHANTMENTS = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isEnchantment();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> ENCHANTMENTS = Card::isEnchantment;
|
||||
/**
|
||||
* a Predicate<Card> to get all aura.
|
||||
*/
|
||||
public static final Predicate<Card> AURA = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isAura();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> AURA = Card::isAura;
|
||||
/**
|
||||
* a Predicate<Card> to get all equipment.
|
||||
*/
|
||||
public static final Predicate<Card> EQUIPMENT = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isEquipment();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> EQUIPMENT = Card::isEquipment;
|
||||
/**
|
||||
* a Predicate<Card> to get all fortification.
|
||||
*/
|
||||
public static final Predicate<Card> FORTIFICATION = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isFortification();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> FORTIFICATION = Card::isFortification;
|
||||
|
||||
/**
|
||||
* a Predicate<Card> to get all curse.
|
||||
*/
|
||||
public static final Predicate<Card> CURSE = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isCurse();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> CURSE = Card::isCurse;
|
||||
|
||||
/**
|
||||
* a Predicate<Card> to get all unenchanted cards in a list.
|
||||
*/
|
||||
public static final Predicate<Card> UNENCHANTED = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return !c.isEnchanted();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> UNENCHANTED = c -> !c.isEnchanted();
|
||||
/**
|
||||
* a Predicate<Card> to get all enchanted cards in a list.
|
||||
*/
|
||||
public static final Predicate<Card> ENCHANTED = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isEnchanted();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> ENCHANTED = GameEntity::isEnchanted;
|
||||
/**
|
||||
* a Predicate<Card> to get all nontoken cards.
|
||||
*/
|
||||
public static final Predicate<Card> NON_TOKEN = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return !(c.isToken() || c.isTokenCard());
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> NON_TOKEN = c -> !(c.isToken() || c.isTokenCard());
|
||||
/**
|
||||
* a Predicate<Card> to get all token cards.
|
||||
*/
|
||||
public static final Predicate<Card> TOKEN = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isToken() || c.isTokenCard();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> TOKEN = c -> c.isToken() || c.isTokenCard();
|
||||
/**
|
||||
* a Predicate<Card> to get all basicLands.
|
||||
*/
|
||||
public static final Predicate<Card> BASIC_LANDS = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
// the isBasicLand() check here may be sufficient...
|
||||
return c.isLand() && c.isBasicLand();
|
||||
}
|
||||
public static final Predicate<Card> BASIC_LANDS = c -> {
|
||||
// the isBasicLand() check here may be sufficient...
|
||||
return c.isLand() && c.isBasicLand();
|
||||
};
|
||||
/**
|
||||
* a Predicate<Card> to get all artifacts.
|
||||
*/
|
||||
public static final Predicate<Card> ARTIFACTS = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isArtifact();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> ARTIFACTS = Card::isArtifact;
|
||||
/**
|
||||
* a Predicate<Card> to get all nonartifacts.
|
||||
*/
|
||||
public static final Predicate<Card> NON_ARTIFACTS = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return !c.isArtifact();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> NON_ARTIFACTS = c -> !c.isArtifact();
|
||||
/**
|
||||
* a Predicate<Card> to get all lands.
|
||||
*/
|
||||
public static final Predicate<Card> LANDS = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isLand() || (!c.isInZone(ZoneType.Battlefield) && c.isModal() && c.getState(CardStateName.Modal).getType().isLand());
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> LANDS = c -> c.isLand() || (!c.isInZone(ZoneType.Battlefield) && c.isModal() && c.getState(CardStateName.Modal).getType().isLand());
|
||||
/**
|
||||
* a Predicate<Card> to get all mana-producing lands.
|
||||
*/
|
||||
public static final Predicate<Card> LANDS_PRODUCING_MANA = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isBasicLand() || (c.isLand() && !c.getManaAbilities().isEmpty());
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> LANDS_PRODUCING_MANA = c -> c.isBasicLand() || (c.isLand() && !c.getManaAbilities().isEmpty());
|
||||
/**
|
||||
* a Predicate<Card> to get all permanents.
|
||||
*/
|
||||
public static final Predicate<Card> PERMANENTS = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isPermanent();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> PERMANENTS = Card::isPermanent;
|
||||
/**
|
||||
* a Predicate<Card> to get all nonland permanents.
|
||||
*/
|
||||
public static final Predicate<Card> NONLAND_PERMANENTS = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isPermanent() && !c.isLand();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> NONLAND_PERMANENTS = c -> c.isPermanent() && !c.isLand();
|
||||
|
||||
public static final Predicate<Card> hasFirstStrike = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isCreature() && (c.hasFirstStrike() || c.hasDoubleStrike());
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> hasSecondStrike = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return c.isCreature() && (!c.hasFirstStrike() || c.hasDoubleStrike());
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> SNOW_LANDS = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.isLand() && c.isSnow();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> PLANESWALKERS = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.isPlaneswalker();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> BATTLES = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.isBattle();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> CAN_BE_DESTROYED = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return c.canBeDestroyed();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> hasFirstStrike = c -> c.isCreature() && (c.hasFirstStrike() || c.hasDoubleStrike());
|
||||
public static final Predicate<Card> hasSecondStrike = c -> c.isCreature() && (!c.hasFirstStrike() || c.hasDoubleStrike());
|
||||
public static final Predicate<Card> SNOW_LANDS = c -> c.isLand() && c.isSnow();
|
||||
public static final Predicate<Card> PLANESWALKERS = Card::isPlaneswalker;
|
||||
public static final Predicate<Card> BATTLES = Card::isBattle;
|
||||
public static final Predicate<Card> CAN_BE_DESTROYED = Card::canBeDestroyed;
|
||||
public static final Predicate<Card> ATTRACTIONS = Card::isAttraction;
|
||||
}
|
||||
|
||||
public static class Accessors {
|
||||
public static final Function<Card, Integer> fnGetNetPower = new Function<Card, Integer>() {
|
||||
@Override
|
||||
public Integer apply(Card a) {
|
||||
return a.getNetPower();
|
||||
}
|
||||
};
|
||||
|
||||
public static final Function<Card, Integer> fnGetNetToughness = new Function<Card, Integer>() {
|
||||
@Override
|
||||
public Integer apply(Card a) {
|
||||
return a.getNetToughness();
|
||||
}
|
||||
};
|
||||
|
||||
public static final Function<Card, Integer> fnGetAttack = new Function<Card, Integer>() {
|
||||
@Override
|
||||
public Integer apply(Card a) {
|
||||
return a.getNetCombatDamage();
|
||||
}
|
||||
};
|
||||
|
||||
public static final Function<Card, Integer> fnGetCmc = new Function<Card, Integer>() {
|
||||
@Override
|
||||
public Integer apply(Card a) {
|
||||
return a.getCMC();
|
||||
}
|
||||
};
|
||||
|
||||
public static final Function<Card, String> fnGetNetName = new Function<Card, String>() {
|
||||
@Override
|
||||
public String apply(Card a) {
|
||||
return a.getName();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.game.card;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import forge.ImageKeys;
|
||||
@@ -570,12 +569,7 @@ public class CardView extends GameEntityView {
|
||||
public boolean canBeShownToAny(final Iterable<PlayerView> viewers) {
|
||||
if (viewers == null || Iterables.isEmpty(viewers)) { return true; }
|
||||
|
||||
return Iterables.any(viewers, new Predicate<PlayerView>() {
|
||||
@Override
|
||||
public final boolean apply(final PlayerView input) {
|
||||
return canBeShownTo(input);
|
||||
}
|
||||
});
|
||||
return Iterables.any(viewers, this::canBeShownTo);
|
||||
}
|
||||
|
||||
public boolean canBeShownTo(final PlayerView viewer) {
|
||||
@@ -641,12 +635,7 @@ public class CardView extends GameEntityView {
|
||||
public boolean canFaceDownBeShownToAny(final Iterable<PlayerView> viewers) {
|
||||
if (viewers == null || Iterables.isEmpty(viewers)) { return true; }
|
||||
|
||||
return Iterables.any(viewers, new Predicate<PlayerView>() {
|
||||
@Override
|
||||
public final boolean apply(final PlayerView input) {
|
||||
return canFaceDownBeShownTo(input);
|
||||
}
|
||||
});
|
||||
return Iterables.any(viewers, this::canFaceDownBeShownTo);
|
||||
}
|
||||
|
||||
public boolean canFaceDownBeShownTo(final PlayerView viewer) {
|
||||
|
||||
@@ -10,7 +10,6 @@ import java.util.Set;
|
||||
|
||||
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.Collections2;
|
||||
@@ -185,7 +184,7 @@ public class AttackConstraints {
|
||||
|
||||
// Now try all others (plus empty attack) and count their violations
|
||||
final FCollection<Map<Card, GameEntity>> legalAttackers = collectLegalAttackers(reqs, myMax);
|
||||
possible.putAll(Maps.asMap(legalAttackers.asSet(), FN_COUNT_VIOLATIONS));
|
||||
possible.putAll(Maps.asMap(legalAttackers.asSet(), this::countViolations));
|
||||
int empty = countViolations(Collections.emptyMap());
|
||||
if (empty != -1) {
|
||||
possible.put(Collections.emptyMap(), empty);
|
||||
@@ -195,11 +194,11 @@ public class AttackConstraints {
|
||||
return MapToAmountUtil.min(possible);
|
||||
}
|
||||
|
||||
private final FCollection<Map<Card, GameEntity>> collectLegalAttackers(final List<Attack> reqs, final int maximum) {
|
||||
private FCollection<Map<Card, GameEntity>> collectLegalAttackers(final List<Attack> reqs, final int maximum) {
|
||||
return new FCollection<>
|
||||
(collectLegalAttackers(Collections.emptyMap(), deepClone(reqs), new CardCollection(), maximum));
|
||||
}
|
||||
private final List<Map<Card, GameEntity>> collectLegalAttackers(final Map<Card, GameEntity> attackers, final List<Attack> reqs, final CardCollection reserved, final int maximum) {
|
||||
private List<Map<Card, GameEntity>> collectLegalAttackers(final Map<Card, GameEntity> attackers, final List<Attack> reqs, final CardCollection reserved, final int maximum) {
|
||||
final List<Map<Card, GameEntity>> result = Lists.newLinkedList();
|
||||
|
||||
int localMaximum = maximum;
|
||||
@@ -341,9 +340,9 @@ public class AttackConstraints {
|
||||
}
|
||||
}
|
||||
|
||||
private final List<Attack> getSortedFilteredRequirements() {
|
||||
private List<Attack> getSortedFilteredRequirements() {
|
||||
final List<Attack> result = Lists.newArrayList();
|
||||
final Map<Card, List<Pair<GameEntity, Integer>>> sortedRequirements = Maps.transformValues(requirements, AttackRequirement.SORT);
|
||||
final Map<Card, List<Pair<GameEntity, Integer>>> sortedRequirements = Maps.transformValues(requirements, AttackRequirement::getSortedRequirements);
|
||||
for (final Entry<Card, List<Pair<GameEntity, Integer>>> reqList : sortedRequirements.entrySet()) {
|
||||
final AttackRestriction restriction = restrictions.get(reqList.getKey());
|
||||
final List<Pair<GameEntity, Integer>> list = reqList.getValue();
|
||||
@@ -403,12 +402,7 @@ public class AttackConstraints {
|
||||
return findFirst(reqs, Predicates.equalTo(attacker));
|
||||
}
|
||||
private static Collection<Attack> findAll(final List<Attack> reqs, final Card attacker) {
|
||||
return Collections2.filter(reqs, new Predicate<Attack>() {
|
||||
@Override
|
||||
public boolean apply(final Attack input) {
|
||||
return input.attacker.equals(attacker);
|
||||
}
|
||||
});
|
||||
return Collections2.filter(reqs, input -> input.attacker.equals(attacker));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -446,10 +440,4 @@ public class AttackConstraints {
|
||||
|
||||
return violations;
|
||||
}
|
||||
private final Function<Map<Card, GameEntity>, Integer> FN_COUNT_VIOLATIONS = new Function<Map<Card,GameEntity>, Integer>() {
|
||||
@Override
|
||||
public Integer apply(final Map<Card, GameEntity> input) {
|
||||
return countViolations(input);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.util.Map;
|
||||
import forge.game.staticability.StaticAbilityMustAttack;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.game.Game;
|
||||
@@ -118,11 +117,5 @@ public class AttackRequirement {
|
||||
public List<Pair<GameEntity, Integer>> getSortedRequirements() {
|
||||
return MapToAmountUtil.sort(defenderSpecific);
|
||||
}
|
||||
public static final Function<AttackRequirement, List<Pair<GameEntity, Integer>>> SORT = new Function<AttackRequirement, List<Pair<GameEntity,Integer>>>() {
|
||||
@Override
|
||||
public List<Pair<GameEntity,Integer>> apply(final AttackRequirement input) {
|
||||
return input.getSortedRequirements();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
package forge.game.combat;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.*;
|
||||
import forge.game.*;
|
||||
import forge.game.ability.AbilityKey;
|
||||
@@ -225,12 +224,7 @@ public class Combat {
|
||||
}
|
||||
|
||||
public final Map<Card, GameEntity> getAttackersAndDefenders() {
|
||||
return Maps.asMap(getAttackers().asSet(), new Function<Card, GameEntity>() {
|
||||
@Override
|
||||
public GameEntity apply(final Card attacker) {
|
||||
return getDefenderByAttacker(attacker);
|
||||
}
|
||||
});
|
||||
return Maps.asMap(getAttackers().asSet(), this::getDefenderByAttacker);
|
||||
}
|
||||
|
||||
public final List<AttackingBand> getAttackingBandsOf(GameEntity defender) {
|
||||
@@ -690,7 +684,7 @@ public class Combat {
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean assignBlockersDamage(boolean firstStrikeDamage) {
|
||||
private boolean assignBlockersDamage(boolean firstStrikeDamage) {
|
||||
// Assign damage by Blockers
|
||||
final CardCollection blockers = getAllBlockers();
|
||||
boolean assignedDamage = false;
|
||||
@@ -746,7 +740,7 @@ public class Combat {
|
||||
return assignedDamage;
|
||||
}
|
||||
|
||||
private final boolean assignAttackersDamage(boolean firstStrikeDamage) {
|
||||
private boolean assignAttackersDamage(boolean firstStrikeDamage) {
|
||||
// Assign damage by Attackers
|
||||
CardCollection orderedBlockers = null;
|
||||
final CardCollection attackers = getAttackers();
|
||||
@@ -886,7 +880,7 @@ public class Combat {
|
||||
return assignedDamage;
|
||||
}
|
||||
|
||||
private final boolean dealDamageThisPhase(Card combatant, boolean firstStrikeDamage) {
|
||||
private boolean dealDamageThisPhase(Card combatant, boolean firstStrikeDamage) {
|
||||
// During first strike damage, double strike and first strike deal damage
|
||||
// During regular strike damage, double strike and anyone who hasn't dealt damage deal damage
|
||||
if (combatant.hasDoubleStrike()) {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
package forge.game.combat;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -111,19 +110,16 @@ public class CombatUtil {
|
||||
final Map<Card, GameEntity> attackers = new HashMap<>(combat.getAttackersAndDefenders());
|
||||
final Game game = attacker.getGame();
|
||||
|
||||
return Iterables.any(getAllPossibleDefenders(attacker.getController()), new Predicate<GameEntity>() {
|
||||
@Override
|
||||
public boolean apply(final GameEntity defender) {
|
||||
if (!canAttack(attacker, defender) || getAttackCost(game, attacker, defender) != null) {
|
||||
return false;
|
||||
}
|
||||
attackers.put(attacker, defender);
|
||||
final int myViolations = constraints.countViolations(attackers);
|
||||
if (myViolations == -1) {
|
||||
return false;
|
||||
}
|
||||
return myViolations <= bestAttack.getRight();
|
||||
return Iterables.any(getAllPossibleDefenders(attacker.getController()), defender -> {
|
||||
if (!canAttack(attacker, defender) || getAttackCost(game, attacker, defender) != null) {
|
||||
return false;
|
||||
}
|
||||
attackers.put(attacker, defender);
|
||||
final int myViolations = constraints.countViolations(attackers);
|
||||
if (myViolations == -1) {
|
||||
return false;
|
||||
}
|
||||
return myViolations <= bestAttack.getRight();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -154,12 +150,7 @@ public class CombatUtil {
|
||||
* @return a {@link CardCollection}.
|
||||
*/
|
||||
public static CardCollection getPossibleAttackers(final Player p) {
|
||||
return CardLists.filter(p.getCreaturesInPlay(), new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card attacker) {
|
||||
return canAttack(attacker);
|
||||
}
|
||||
});
|
||||
return CardLists.filter(p.getCreaturesInPlay(), CombatUtil::canAttack);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,12 +161,7 @@ public class CombatUtil {
|
||||
* @see #canAttack(Card, GameEntity)
|
||||
*/
|
||||
public static boolean canAttack(final Card attacker) {
|
||||
return Iterables.any(getAllPossibleDefenders(attacker.getController()), new Predicate<GameEntity>() {
|
||||
@Override
|
||||
public boolean apply(final GameEntity defender) {
|
||||
return canAttack(attacker, defender);
|
||||
}
|
||||
});
|
||||
return Iterables.any(getAllPossibleDefenders(attacker.getController()), defender -> canAttack(attacker, defender));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -118,12 +118,7 @@ public class Cost implements Serializable {
|
||||
// Things that are pretty much happen at the end (Untap) 16+
|
||||
// Things that NEED to happen last 100+
|
||||
|
||||
Collections.sort(this.costParts, new Comparator<CostPart>() {
|
||||
@Override
|
||||
public int compare(CostPart o1, CostPart o2) {
|
||||
return ObjectUtils.compare(o1.paymentOrder(), o2.paymentOrder());
|
||||
}
|
||||
});
|
||||
Collections.sort(this.costParts, (o1, o2) -> ObjectUtils.compare(o1.paymentOrder(), o2.paymentOrder()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -299,13 +299,10 @@ public enum Keyword {
|
||||
|
||||
public static Runnable getPreloadTask() {
|
||||
if (cardKeywordSetLookup.size() < 10000) { //allow preloading even if some but not all cards loaded
|
||||
return new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Collection<PaperCard> cards = StaticData.instance().getCommonCards().getUniqueCards();
|
||||
for (PaperCard card : cards) {
|
||||
getKeywordSet(card);
|
||||
}
|
||||
return () -> {
|
||||
final Collection<PaperCard> cards = StaticData.instance().getCommonCards().getUniqueCards();
|
||||
for (PaperCard card : cards) {
|
||||
getKeywordSet(card);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ public class ManaCostBeingPaid {
|
||||
public final void increaseShard(final ManaCostShard shard, final int toAdd) {
|
||||
increaseShard(shard, toAdd, false);
|
||||
}
|
||||
private final void increaseShard(final ManaCostShard shard, final int toAdd, final boolean forX) {
|
||||
private void increaseShard(final ManaCostShard shard, final int toAdd, final boolean forX) {
|
||||
if (toAdd <= 0) { return; }
|
||||
|
||||
ShardCount sc = unpaidShards.get(shard);
|
||||
@@ -460,15 +460,12 @@ public class ManaCostBeingPaid {
|
||||
//throw new RuntimeException("ManaCost : addMana() error, mana not needed - " + mana);
|
||||
}
|
||||
|
||||
Predicate<ManaCostShard> predCanBePaid = new Predicate<ManaCostShard>() {
|
||||
@Override
|
||||
public boolean apply(ManaCostShard ms) {
|
||||
// Check Colored X and see if the color is already used
|
||||
if (ms == ManaCostShard.COLORED_X && !canColoredXShardBePaidByColor(MagicColor.toShortString(colorMask), xManaCostPaidByColor)) {
|
||||
return false;
|
||||
}
|
||||
return pool.canPayForShardWithColor(ms, colorMask);
|
||||
Predicate<ManaCostShard> predCanBePaid = ms -> {
|
||||
// Check Colored X and see if the color is already used
|
||||
if (ms == ManaCostShard.COLORED_X && !canColoredXShardBePaidByColor(MagicColor.toShortString(colorMask), xManaCostPaidByColor)) {
|
||||
return false;
|
||||
}
|
||||
return pool.canPayForShardWithColor(ms, colorMask);
|
||||
};
|
||||
|
||||
return tryPayMana(colorMask, Iterables.filter(unpaidShards.keySet(), predCanBePaid), pool.getPossibleColorUses(colorMask)) != null;
|
||||
@@ -488,12 +485,7 @@ public class ManaCostBeingPaid {
|
||||
throw new RuntimeException("ManaCost : addMana() error, mana not needed - " + mana);
|
||||
}
|
||||
|
||||
Predicate<ManaCostShard> predCanBePaid = new Predicate<ManaCostShard>() {
|
||||
@Override
|
||||
public boolean apply(ManaCostShard ms) {
|
||||
return canBePaidWith(ms, mana, pool, xManaCostPaidByColor);
|
||||
}
|
||||
};
|
||||
Predicate<ManaCostShard> predCanBePaid = ms -> canBePaidWith(ms, mana, pool, xManaCostPaidByColor);
|
||||
|
||||
byte inColor = mana.getColor();
|
||||
byte outColor = pool.getPossibleColorUses(inColor);
|
||||
@@ -501,12 +493,7 @@ public class ManaCostBeingPaid {
|
||||
}
|
||||
|
||||
public final ManaCostShard payManaViaConvoke(final byte color) {
|
||||
Predicate<ManaCostShard> predCanBePaid = new Predicate<ManaCostShard>() {
|
||||
@Override
|
||||
public boolean apply(ManaCostShard ms) {
|
||||
return ms.canBePaidWithManaOfColor(color);
|
||||
}
|
||||
};
|
||||
Predicate<ManaCostShard> predCanBePaid = ms -> ms.canBePaidWithManaOfColor(color);
|
||||
return tryPayMana(color, Iterables.filter(unpaidShards.keySet(), predCanBePaid), (byte)0xFF);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
public final PhaseType getPhase() {
|
||||
return phase;
|
||||
}
|
||||
private final void setPhase(final PhaseType phase0) {
|
||||
private void setPhase(final PhaseType phase0) {
|
||||
if (phase == phase0) { return; }
|
||||
phase = phase0;
|
||||
game.updatePhaseForView();
|
||||
@@ -234,7 +234,7 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
private final void onPhaseBegin() {
|
||||
private void onPhaseBegin() {
|
||||
boolean skipped = false;
|
||||
|
||||
game.getTriggerHandler().resetActiveTriggers();
|
||||
|
||||
@@ -38,7 +38,7 @@ public enum PhaseType {
|
||||
|
||||
private static final Map<PhaseType, Integer> PHASE_INDEX = initializePhaseIndex();
|
||||
|
||||
private static final Map<PhaseType, Integer> initializePhaseIndex() {
|
||||
private static Map<PhaseType, Integer> initializePhaseIndex() {
|
||||
Map<PhaseType, Integer> phaseIndex = Maps.newEnumMap(PhaseType.class);
|
||||
phaseIndex.put(UNTAP, 0);
|
||||
phaseIndex.put(UPKEEP, 0);
|
||||
|
||||
@@ -105,12 +105,7 @@ public class Untap extends Phase {
|
||||
return !c.isExertedBy(playerTurn);
|
||||
}
|
||||
|
||||
public static final Predicate<Card> CANUNTAP = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return canUntap(c);
|
||||
}
|
||||
};
|
||||
public static final Predicate<Card> CANUNTAP = Untap::canUntap;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -155,14 +150,11 @@ public class Untap extends Phase {
|
||||
}
|
||||
final CardCollection untapList = new CardCollection(list);
|
||||
final String[] restrict = restrictUntap.keySet().toArray(new String[restrictUntap.keySet().size()]);
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
if (!Untap.canUntap(c)) {
|
||||
return false;
|
||||
}
|
||||
return !c.isValid(restrict, player, null, null);
|
||||
list = CardLists.filter(list, c -> {
|
||||
if (!Untap.canUntap(c)) {
|
||||
return false;
|
||||
}
|
||||
return !c.isValid(restrict, player, null, null);
|
||||
});
|
||||
|
||||
for (final Card c : list) {
|
||||
@@ -268,13 +260,10 @@ public class Untap extends Phase {
|
||||
|
||||
private static void doPhasing(final Player turn) {
|
||||
// Needs to include phased out cards
|
||||
final List<Card> list = CardLists.filter(turn.getGame().getCardsIncludePhasingIn(ZoneType.Battlefield), new Predicate<Card>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return (c.isPhasedOut(turn) && c.isDirectlyPhasedOut()) || (c.hasKeyword(Keyword.PHASING) && c.getController().equals(turn));
|
||||
}
|
||||
});
|
||||
final List<Card> list = CardLists.filter(turn.getGame().getCardsIncludePhasingIn(ZoneType.Battlefield),
|
||||
c -> (c.isPhasedOut(turn) && c.isDirectlyPhasedOut())
|
||||
|| (c.hasKeyword(Keyword.PHASING) && c.getController().equals(turn))
|
||||
);
|
||||
|
||||
CardCollection toPhase = new CardCollection();
|
||||
for (final Card tgtC : list) {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
package forge.game.player;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.*;
|
||||
import forge.ImageKeys;
|
||||
@@ -335,21 +334,21 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
* Find the smallest life total amongst this player's opponents.
|
||||
*/
|
||||
public final int getOpponentsSmallestLifeTotal() {
|
||||
return Aggregates.min(getOpponents(), Accessors.FN_GET_LIFE_TOTAL);
|
||||
return Aggregates.min(getOpponents(), Player::getLife);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the greatest life total amongst this player's opponents.
|
||||
*/
|
||||
public final int getOpponentsGreatestLifeTotal() {
|
||||
return Aggregates.max(getOpponents(), Accessors.FN_GET_LIFE_TOTAL);
|
||||
return Aggregates.max(getOpponents(), Player::getLife);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of poison counters amongst this player's opponents.
|
||||
*/
|
||||
public final int getOpponentsTotalPoisonCounters() {
|
||||
return Aggregates.sum(getOpponents(), Accessors.FN_GET_POISON_COUNTERS);
|
||||
return Aggregates.sum(getOpponents(), Player::getPoisonCounters);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -844,14 +843,14 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
* Get the total damage assigned to this player's opponents this turn.
|
||||
*/
|
||||
public final int getOpponentsAssignedDamage() {
|
||||
return Aggregates.sum(getOpponents(), Accessors.FN_GET_ASSIGNED_DAMAGE);
|
||||
return Aggregates.sum(getOpponents(), GameEntity::getAssignedDamage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the greatest amount of damage assigned to a single opponent this turn.
|
||||
*/
|
||||
public final int getMaxOpponentAssignedDamage() {
|
||||
return Aggregates.max(getRegisteredOpponents(), Accessors.FN_GET_ASSIGNED_DAMAGE);
|
||||
return Aggregates.max(getRegisteredOpponents(), GameEntity::getAssignedDamage);
|
||||
}
|
||||
|
||||
public final boolean canReceiveCounters(final CounterType type) {
|
||||
@@ -1847,7 +1846,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
public final Card getLastDrawnCard() {
|
||||
return lastDrawnCard;
|
||||
}
|
||||
private final Card setLastDrawnCard(final Card c) {
|
||||
private Card setLastDrawnCard(final Card c) {
|
||||
lastDrawnCard = c;
|
||||
return lastDrawnCard;
|
||||
}
|
||||
@@ -2153,7 +2152,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
}
|
||||
|
||||
public final int getBloodthirstAmount() {
|
||||
return Aggregates.sum(getRegisteredOpponents(), Accessors.FN_GET_ASSIGNED_DAMAGE);
|
||||
return Aggregates.sum(getRegisteredOpponents(), GameEntity::getAssignedDamage);
|
||||
}
|
||||
|
||||
public final int getOpponentLostLifeThisTurn() {
|
||||
@@ -2419,33 +2418,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
return draftNotes;
|
||||
}
|
||||
|
||||
public static class Accessors {
|
||||
public static Function<Player, String> FN_GET_NAME = new Function<Player, String>() {
|
||||
@Override
|
||||
public String apply(Player input) {
|
||||
return input.getName();
|
||||
}
|
||||
};
|
||||
public static Function<Player, Integer> FN_GET_LIFE_TOTAL = new Function<Player, Integer>() {
|
||||
@Override
|
||||
public Integer apply(Player input) {
|
||||
return input.getLife();
|
||||
}
|
||||
};
|
||||
public static Function<Player, Integer> FN_GET_POISON_COUNTERS = new Function<Player, Integer>() {
|
||||
@Override
|
||||
public Integer apply(Player input) {
|
||||
return input.getPoisonCounters();
|
||||
}
|
||||
};
|
||||
public static final Function<Player, Integer> FN_GET_ASSIGNED_DAMAGE = new Function<Player, Integer>() {
|
||||
@Override
|
||||
public Integer apply(Player input) {
|
||||
return input.getAssignedDamage();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public final LobbyPlayer getLobbyPlayer() {
|
||||
return getController().getLobbyPlayer();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import forge.game.CardTraitBase;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CounterEnumType;
|
||||
@@ -15,177 +16,86 @@ import forge.game.zone.ZoneType;
|
||||
|
||||
public final class PlayerPredicates {
|
||||
|
||||
public static final Predicate<Player> isTargetableBy(final SpellAbility source) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(final Player p) {
|
||||
return source.canTarget(p);
|
||||
}
|
||||
};
|
||||
public static Predicate<Player> isTargetableBy(final SpellAbility source) {
|
||||
return source::canTarget;
|
||||
}
|
||||
|
||||
public static final Predicate<Player> canDiscardBy(final SpellAbility source, final boolean effect) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(final Player p) {
|
||||
return p.canDiscardBy(source, effect);
|
||||
}
|
||||
};
|
||||
public static Predicate<Player> canDiscardBy(final SpellAbility source, final boolean effect) {
|
||||
return p -> p.canDiscardBy(source, effect);
|
||||
}
|
||||
|
||||
public static final Predicate<Player> isOpponentOf(final Player player) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(final Player p) {
|
||||
return p.isOpponentOf(player);
|
||||
}
|
||||
};
|
||||
public static Predicate<Player> isOpponentOf(final Player player) {
|
||||
return p -> p.isOpponentOf(player);
|
||||
}
|
||||
|
||||
public static final Predicate<Player> sameTeam(final Player player) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(final Player p) {
|
||||
return player.sameTeam(p);
|
||||
}
|
||||
};
|
||||
public static Predicate<Player> sameTeam(final Player player) {
|
||||
return player::sameTeam;
|
||||
}
|
||||
|
||||
public static final Predicate<Player> isCardInPlay(final String cardName) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(final Player p) {
|
||||
return p.isCardInPlay(cardName);
|
||||
}
|
||||
};
|
||||
public static Predicate<Player> isCardInPlay(final String cardName) {
|
||||
return p -> p.isCardInPlay(cardName);
|
||||
}
|
||||
|
||||
public static final Predicate<Player> isNotCardInPlay(final String cardName) {
|
||||
public static Predicate<Player> isNotCardInPlay(final String cardName) {
|
||||
return Predicates.not(isCardInPlay(cardName));
|
||||
}
|
||||
|
||||
public static final Predicate<Player> hasCounters() {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(final Player p) {
|
||||
return p.hasCounters();
|
||||
}
|
||||
};
|
||||
public static Predicate<Player> hasCounters() {
|
||||
return GameEntity::hasCounters;
|
||||
}
|
||||
|
||||
public static final Predicate<Player> lifeLessOrEqualTo(final int n) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(final Player p) {
|
||||
return p.getLife() <= n;
|
||||
}
|
||||
};
|
||||
public static Predicate<Player> lifeLessOrEqualTo(final int n) {
|
||||
return p -> p.getLife() <= n;
|
||||
}
|
||||
|
||||
public static final Predicate<Player> lifeGreaterOrEqualTo(final int n) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(final Player p) {
|
||||
return p.getLife() >= n;
|
||||
}
|
||||
};
|
||||
public static Predicate<Player> lifeGreaterOrEqualTo(final int n) {
|
||||
return p -> p.getLife() >= n;
|
||||
}
|
||||
|
||||
public static final Predicate<Player> hasCounter(final CounterType type) {
|
||||
public static Predicate<Player> hasCounter(final CounterType type) {
|
||||
return hasCounter(type, 1);
|
||||
}
|
||||
|
||||
public static final Predicate<Player> hasCounter(final CounterType type, final int n) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(final Player p) {
|
||||
return p.getCounters(type) >= n;
|
||||
}
|
||||
};
|
||||
public static Predicate<Player> hasCounter(final CounterType type, final int n) {
|
||||
return p -> p.getCounters(type) >= n;
|
||||
}
|
||||
|
||||
public static final Predicate<Player> hasCounter(final CounterEnumType type) {
|
||||
public static Predicate<Player> hasCounter(final CounterEnumType type) {
|
||||
return hasCounter(CounterType.get(type), 1);
|
||||
}
|
||||
|
||||
public static final Predicate<Player> hasCounter(final CounterEnumType type, final int n) {
|
||||
public static Predicate<Player> hasCounter(final CounterEnumType type, final int n) {
|
||||
return hasCounter(CounterType.get(type), n);
|
||||
}
|
||||
|
||||
public static final Predicate<Player> hasKeyword(final String keyword) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(final Player p) {
|
||||
return p.hasKeyword(keyword);
|
||||
}
|
||||
};
|
||||
public static Predicate<Player> hasKeyword(final String keyword) {
|
||||
return p -> p.hasKeyword(keyword);
|
||||
}
|
||||
|
||||
public static final Predicate<Player> canBeAttached(final Card aura, SpellAbility sa) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(final Player p) {
|
||||
return p.canBeAttached(aura, sa);
|
||||
}
|
||||
};
|
||||
public static Predicate<Player> canBeAttached(final Card aura, SpellAbility sa) {
|
||||
return p -> p.canBeAttached(aura, sa);
|
||||
}
|
||||
|
||||
public static final Predicate<Player> restriction(final String[] restrictions, final Player sourceController, final Card source, final CardTraitBase spellAbility) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(final Player c) {
|
||||
return c != null && c.isValid(restrictions, sourceController, source, spellAbility);
|
||||
}
|
||||
};
|
||||
public static Predicate<Player> restriction(final String[] restrictions, final Player sourceController, final Card source, final CardTraitBase spellAbility) {
|
||||
return c -> c != null && c.isValid(restrictions, sourceController, source, spellAbility);
|
||||
}
|
||||
|
||||
public static final Comparator<Player> compareByZoneSize(final ZoneType zone) {
|
||||
return new Comparator<Player>() {
|
||||
@Override
|
||||
public int compare(Player arg0, Player arg1) {
|
||||
return Integer.compare(arg0.getCardsIn(zone).size(), arg1.getCardsIn(zone).size());
|
||||
}
|
||||
};
|
||||
public static Comparator<Player> compareByZoneSize(final ZoneType zone) {
|
||||
return Comparator.comparingInt(arg0 -> arg0.getCardsIn(zone).size());
|
||||
}
|
||||
|
||||
public static final Comparator<Player> compareByZoneSize(final ZoneType zone, final Predicate<Card> pred) {
|
||||
return new Comparator<Player>() {
|
||||
@Override
|
||||
public int compare(Player arg0, Player arg1) {
|
||||
return Integer.compare(CardLists.count(arg0.getCardsIn(zone), pred),
|
||||
CardLists.count(arg1.getCardsIn(zone), pred));
|
||||
}
|
||||
};
|
||||
public static Comparator<Player> compareByZoneSize(final ZoneType zone, final Predicate<Card> pred) {
|
||||
return Comparator.comparingInt(arg0 -> CardLists.count(arg0.getCardsIn(zone), pred));
|
||||
}
|
||||
|
||||
public static final Comparator<Player> compareByLife() {
|
||||
return new Comparator<Player>() {
|
||||
@Override
|
||||
public int compare(Player arg0, Player arg1) {
|
||||
return Integer.compare(arg0.getLife(), arg1.getLife());
|
||||
}
|
||||
};
|
||||
public static Comparator<Player> compareByLife() {
|
||||
return Comparator.comparingInt(Player::getLife);
|
||||
}
|
||||
|
||||
public static final Comparator<Player> compareByPoison() {
|
||||
return new Comparator<Player>() {
|
||||
@Override
|
||||
public int compare(Player arg0, Player arg1) {
|
||||
return Integer.compare(arg0.getPoisonCounters(), arg1.getPoisonCounters());
|
||||
}
|
||||
};
|
||||
public static Comparator<Player> compareByPoison() {
|
||||
return Comparator.comparingInt(Player::getPoisonCounters);
|
||||
}
|
||||
|
||||
public static final Predicate<Player> NOT_LOST = new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(Player p) {
|
||||
return p.getOutcome() == null || p.getOutcome().hasWon();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Player> CANT_WIN = new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(final Player p) {
|
||||
return p.hasKeyword("You can't win the game.");
|
||||
}
|
||||
};
|
||||
public static final Predicate<Player> NOT_LOST = p -> p.getOutcome() == null || p.getOutcome().hasWon();
|
||||
public static final Predicate<Player> CANT_WIN = p -> p.hasKeyword("You can't win the game.");
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class AbilitySub extends SpellAbility implements java.io.Serializab
|
||||
* @param parent
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
*/
|
||||
public final void setParent(final SpellAbility parent) {
|
||||
public void setParent(final SpellAbility parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public final class AbilitySub extends SpellAbility implements java.io.Serializab
|
||||
* @return a {@link forge.game.spellability.SpellAbility} object.
|
||||
*/
|
||||
@Override
|
||||
public final SpellAbility getParent() {
|
||||
public SpellAbility getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public final class AbilitySub extends SpellAbility implements java.io.Serializab
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final Object clone() {
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (final Exception ex) {
|
||||
|
||||
@@ -50,7 +50,6 @@ import forge.game.card.CardCollectionView;
|
||||
import forge.game.card.CardDamageMap;
|
||||
import forge.game.card.CardFactory;
|
||||
import forge.game.card.CardPlayOption;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.card.CardZoneTable;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.cost.CostPart;
|
||||
@@ -1413,7 +1412,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
}
|
||||
|
||||
if (hasParam("MaxTotalTargetCMC") && entity instanceof Card) {
|
||||
int soFar = Aggregates.sum(getTargets().getTargetCards(), CardPredicates.Accessors.fnGetCmc);
|
||||
int soFar = Aggregates.sum(getTargets().getTargetCards(), Card::getCMC);
|
||||
// only add if it isn't already targeting
|
||||
if (!isTargeting(entity)) {
|
||||
final Card c = (Card) entity;
|
||||
@@ -1426,7 +1425,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
}
|
||||
|
||||
if (hasParam("MaxTotalTargetPower") && entity instanceof Card) {
|
||||
int soFar = Aggregates.sum(getTargets().getTargetCards(), CardPredicates.Accessors.fnGetNetPower);
|
||||
int soFar = Aggregates.sum(getTargets().getTargetCards(), Card::getNetPower);
|
||||
// only add if it isn't already targeting
|
||||
if (!isTargeting(entity)) {
|
||||
final Card c = (Card) entity;
|
||||
|
||||
@@ -9,75 +9,35 @@ import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
|
||||
public final class SpellAbilityPredicates extends CardTraitPredicates {
|
||||
public static final Predicate<SpellAbility> isApi(final ApiType type) {
|
||||
return new Predicate<SpellAbility>() {
|
||||
@Override
|
||||
public boolean apply(final SpellAbility sa) {
|
||||
return type.equals(sa.getApi());
|
||||
}
|
||||
};
|
||||
public static Predicate<SpellAbility> isApi(final ApiType type) {
|
||||
return sa -> type.equals(sa.getApi());
|
||||
}
|
||||
|
||||
public static final Predicate<SpellAbility> hasSubAbilityApi(final ApiType type) {
|
||||
return new Predicate<SpellAbility>() {
|
||||
@Override
|
||||
public boolean apply(final SpellAbility sa) {
|
||||
return sa.findSubAbilityByType(type) != null;
|
||||
}
|
||||
};
|
||||
public static Predicate<SpellAbility> hasSubAbilityApi(final ApiType type) {
|
||||
return sa -> sa.findSubAbilityByType(type) != null;
|
||||
}
|
||||
|
||||
public static final Predicate<SpellAbility> isMandatory() {
|
||||
return new Predicate<SpellAbility>() {
|
||||
@Override
|
||||
public boolean apply(final SpellAbility sa) {
|
||||
return sa.isMandatory();
|
||||
}
|
||||
};
|
||||
public static Predicate<SpellAbility> isMandatory() {
|
||||
return SpellAbility::isMandatory;
|
||||
}
|
||||
|
||||
public static final Predicate<SpellAbility> isManaAbility() {
|
||||
return new Predicate<SpellAbility>() {
|
||||
@Override
|
||||
public boolean apply(final SpellAbility sa) {
|
||||
return sa.isManaAbility();
|
||||
}
|
||||
};
|
||||
public static Predicate<SpellAbility> isManaAbility() {
|
||||
return SpellAbility::isManaAbility;
|
||||
}
|
||||
|
||||
public static final Predicate<SpellAbility> isIntrinsic() {
|
||||
return new Predicate<SpellAbility>() {
|
||||
@Override
|
||||
public boolean apply(final SpellAbility sa) {
|
||||
return sa.isIntrinsic();
|
||||
}
|
||||
};
|
||||
public static Predicate<SpellAbility> isIntrinsic() {
|
||||
return CardTraitBase::isIntrinsic;
|
||||
}
|
||||
|
||||
public static final Predicate<SpellAbility> isChapter() {
|
||||
return new Predicate<SpellAbility>() {
|
||||
@Override
|
||||
public boolean apply(final SpellAbility sa) {
|
||||
return sa.isChapter();
|
||||
}
|
||||
};
|
||||
public static Predicate<SpellAbility> isChapter() {
|
||||
return SpellAbility::isChapter;
|
||||
}
|
||||
|
||||
public static final Predicate<SpellAbility> isTrigger() {
|
||||
return new Predicate<SpellAbility>() {
|
||||
@Override
|
||||
public boolean apply(final SpellAbility sa) {
|
||||
return sa.isTrigger();
|
||||
}
|
||||
};
|
||||
public static Predicate<SpellAbility> isTrigger() {
|
||||
return SpellAbility::isTrigger;
|
||||
}
|
||||
|
||||
public static final Predicate<SpellAbility> isValid(String[] restrictions, Player sourceController, Card source, CardTraitBase spellAbility) {
|
||||
return new Predicate<SpellAbility>() {
|
||||
@Override
|
||||
public boolean apply(final SpellAbility sa) {
|
||||
return sa.isValid(restrictions, sourceController, source, spellAbility);
|
||||
}
|
||||
};
|
||||
public static Predicate<SpellAbility> isValid(String[] restrictions, Player sourceController, Card source, CardTraitBase spellAbility) {
|
||||
return sa -> sa.isValid(restrictions, sourceController, source, spellAbility);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ public class TargetRestrictions {
|
||||
*
|
||||
* @return the max targets
|
||||
*/
|
||||
private final String getMaxTotalCMC() {
|
||||
private String getMaxTotalCMC() {
|
||||
return this.maxTotalCMC;
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ public class TargetRestrictions {
|
||||
*
|
||||
* @return the max targets
|
||||
*/
|
||||
private final String getMaxTotalPower() {
|
||||
private String getMaxTotalPower() {
|
||||
return this.maxTotalPower;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ public class StaticAbility extends CardTraitBase implements IIdentifiable, Clone
|
||||
*
|
||||
* @return the applicable layers.
|
||||
*/
|
||||
private final Set<StaticAbilityLayer> generateLayer() {
|
||||
private Set<StaticAbilityLayer> generateLayer() {
|
||||
if (!checkMode("Continuous")) {
|
||||
return EnumSet.noneOf(StaticAbilityLayer.class);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
*/
|
||||
package forge.game.staticability;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -173,131 +171,122 @@ public final class StaticAbilityContinuous {
|
||||
// update keywords with Chosen parts
|
||||
final String hostCardUID = Integer.toString(hostCard.getId()); // Protection with "doesn't remove" effect
|
||||
|
||||
Iterables.removeIf(addKeywords, new Predicate<String>() {
|
||||
@Override
|
||||
public boolean apply(String input) {
|
||||
if (!hostCard.hasChosenColor() && input.contains("ChosenColor")) {
|
||||
return true;
|
||||
}
|
||||
if (!hostCard.hasChosenType() && input.contains("ChosenType")) {
|
||||
return true;
|
||||
}
|
||||
if (!hostCard.hasChosenNumber() && input.contains("ChosenNumber")) {
|
||||
return true;
|
||||
}
|
||||
if (!hostCard.hasChosenPlayer() && input.contains("ChosenPlayer")) {
|
||||
return true;
|
||||
}
|
||||
if (!hostCard.hasNamedCard() && input.contains("ChosenName")) {
|
||||
return true;
|
||||
}
|
||||
if (!hostCard.hasChosenEvenOdd() && (input.contains("ChosenEvenOdd") || input.contains("chosenEvenOdd"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (input.contains("AllColors") || input.contains("allColors")) {
|
||||
for (byte color : MagicColor.WUBRG) {
|
||||
final String colorWord = MagicColor.toLongString(color);
|
||||
String y = input.replaceAll("AllColors", StringUtils.capitalize(colorWord));
|
||||
y = y.replaceAll("allColors", colorWord);
|
||||
newKeywords.add(y);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (input.contains("CommanderColorID")) {
|
||||
if (!hostCard.getController().getCommanders().isEmpty()) {
|
||||
if (input.contains("NotCommanderColorID")) {
|
||||
for (Byte color : hostCard.getController().getNotCommanderColorID()) {
|
||||
newKeywords.add(input.replace("NotCommanderColorID", MagicColor.toLongString(color)));
|
||||
}
|
||||
return true;
|
||||
} else for (Byte color : hostCard.getController().getCommanderColorID()) {
|
||||
newKeywords.add(input.replace("CommanderColorID", MagicColor.toLongString(color)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// two variants for Red vs. red in keyword
|
||||
if (input.contains("ColorsYouCtrl") || input.contains("colorsYouCtrl")) {
|
||||
final ColorSet colorsYouCtrl = CardUtil.getColorsFromCards(controller.getCardsIn(ZoneType.Battlefield));
|
||||
|
||||
for (byte color : colorsYouCtrl) {
|
||||
final String colorWord = MagicColor.toLongString(color);
|
||||
String y = input.replaceAll("ColorsYouCtrl", StringUtils.capitalize(colorWord));
|
||||
y = y.replaceAll("colorsYouCtrl", colorWord);
|
||||
newKeywords.add(y);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (input.contains("YourBasic")) {
|
||||
CardCollectionView lands = hostCard.getController().getLandsInPlay();
|
||||
final List<String> basic = MagicColor.Constant.BASIC_LANDS;
|
||||
for (String type : basic) {
|
||||
if (Iterables.any(lands, CardPredicates.isType(type))) {
|
||||
String y = input.replaceAll("YourBasic", type);
|
||||
newKeywords.add(y);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (input.contains("EachCMCAmongDefined")) {
|
||||
String keywordDefined = params.get("KeywordDefined");
|
||||
CardCollectionView definedCards = game.getCardsIn(ZoneType.Battlefield);
|
||||
definedCards = CardLists.getValidCards(definedCards, keywordDefined, hostCard.getController(),
|
||||
hostCard, stAb);
|
||||
for (Card c : definedCards) {
|
||||
final int cmc = c.getCMC();
|
||||
String y = (input.replace(" from EachCMCAmongDefined", ":Card.cmcEQ"
|
||||
+ (cmc) + ":Protection from mana value " + (cmc)));
|
||||
if (!newKeywords.contains(y)) {
|
||||
newKeywords.add(y);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
Iterables.removeIf(addKeywords, input -> {
|
||||
if (!hostCard.hasChosenColor() && input.contains("ChosenColor")) {
|
||||
return true;
|
||||
}
|
||||
if (!hostCard.hasChosenType() && input.contains("ChosenType")) {
|
||||
return true;
|
||||
}
|
||||
if (!hostCard.hasChosenNumber() && input.contains("ChosenNumber")) {
|
||||
return true;
|
||||
}
|
||||
if (!hostCard.hasChosenPlayer() && input.contains("ChosenPlayer")) {
|
||||
return true;
|
||||
}
|
||||
if (!hostCard.hasNamedCard() && input.contains("ChosenName")) {
|
||||
return true;
|
||||
}
|
||||
if (!hostCard.hasChosenEvenOdd() && (input.contains("ChosenEvenOdd") || input.contains("chosenEvenOdd"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (input.contains("AllColors") || input.contains("allColors")) {
|
||||
for (byte color : MagicColor.WUBRG) {
|
||||
final String colorWord = MagicColor.toLongString(color);
|
||||
String y = input.replaceAll("AllColors", StringUtils.capitalize(colorWord));
|
||||
y = y.replaceAll("allColors", colorWord);
|
||||
newKeywords.add(y);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (input.contains("CommanderColorID")) {
|
||||
if (!hostCard.getController().getCommanders().isEmpty()) {
|
||||
if (input.contains("NotCommanderColorID")) {
|
||||
for (Byte color : hostCard.getController().getNotCommanderColorID()) {
|
||||
newKeywords.add(input.replace("NotCommanderColorID", MagicColor.toLongString(color)));
|
||||
}
|
||||
return true;
|
||||
} else for (Byte color : hostCard.getController().getCommanderColorID()) {
|
||||
newKeywords.add(input.replace("CommanderColorID", MagicColor.toLongString(color)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// two variants for Red vs. red in keyword
|
||||
if (input.contains("ColorsYouCtrl") || input.contains("colorsYouCtrl")) {
|
||||
final ColorSet colorsYouCtrl = CardUtil.getColorsFromCards(controller.getCardsIn(ZoneType.Battlefield));
|
||||
|
||||
for (byte color : colorsYouCtrl) {
|
||||
final String colorWord = MagicColor.toLongString(color);
|
||||
String y = input.replaceAll("ColorsYouCtrl", StringUtils.capitalize(colorWord));
|
||||
y = y.replaceAll("colorsYouCtrl", colorWord);
|
||||
newKeywords.add(y);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (input.contains("YourBasic")) {
|
||||
CardCollectionView lands = hostCard.getController().getLandsInPlay();
|
||||
final List<String> basic = MagicColor.Constant.BASIC_LANDS;
|
||||
for (String type : basic) {
|
||||
if (Iterables.any(lands, CardPredicates.isType(type))) {
|
||||
String y = input.replaceAll("YourBasic", type);
|
||||
newKeywords.add(y);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (input.contains("EachCMCAmongDefined")) {
|
||||
String keywordDefined = params.get("KeywordDefined");
|
||||
CardCollectionView definedCards = game.getCardsIn(ZoneType.Battlefield);
|
||||
definedCards = CardLists.getValidCards(definedCards, keywordDefined, hostCard.getController(),
|
||||
hostCard, stAb);
|
||||
for (Card c : definedCards) {
|
||||
final int cmc = c.getCMC();
|
||||
String y = (input.replace(" from EachCMCAmongDefined", ":Card.cmcEQ"
|
||||
+ (cmc) + ":Protection from mana value " + (cmc)));
|
||||
if (!newKeywords.contains(y)) {
|
||||
newKeywords.add(y);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
addKeywords.addAll(newKeywords);
|
||||
|
||||
addKeywords = Lists.transform(addKeywords, new Function<String, String>() {
|
||||
|
||||
@Override
|
||||
public String apply(String input) {
|
||||
if (hostCard.hasChosenColor()) {
|
||||
input = input.replaceAll("ChosenColor", StringUtils.capitalize(hostCard.getChosenColor()));
|
||||
input = input.replaceAll("chosenColor", hostCard.getChosenColor().toLowerCase());
|
||||
}
|
||||
if (hostCard.hasChosenType()) {
|
||||
input = input.replaceAll("ChosenType", hostCard.getChosenType());
|
||||
}
|
||||
if (hostCard.hasChosenNumber()) {
|
||||
input = input.replaceAll("ChosenNumber", String.valueOf(hostCard.getChosenNumber()));
|
||||
}
|
||||
if (hostCard.hasChosenPlayer()) {
|
||||
Player cp = hostCard.getChosenPlayer();
|
||||
input = input.replaceAll("ChosenPlayerUID", String.valueOf(cp.getId()));
|
||||
input = input.replaceAll("ChosenPlayerName", cp.getName());
|
||||
}
|
||||
if (hostCard.hasNamedCard()) {
|
||||
final String chosenName = hostCard.getNamedCard().replace(",", ";");
|
||||
input = input.replaceAll("ChosenName", "Card.named" + chosenName);
|
||||
}
|
||||
if (hostCard.hasChosenEvenOdd()) {
|
||||
input = input.replaceAll("ChosenEvenOdd", hostCard.getChosenEvenOdd().toString());
|
||||
input = input.replaceAll("chosenEvenOdd", hostCard.getChosenEvenOdd().toString().toLowerCase());
|
||||
}
|
||||
input = input.replace("HostCardUID", hostCardUID);
|
||||
if (params.containsKey("CalcKeywordN")) {
|
||||
input = input.replace("N", String.valueOf(AbilityUtils.calculateAmount(hostCard, params.get("CalcKeywordN"), stAb)));
|
||||
}
|
||||
return input;
|
||||
addKeywords = Lists.transform(addKeywords, input -> {
|
||||
if (hostCard.hasChosenColor()) {
|
||||
input = input.replaceAll("ChosenColor", StringUtils.capitalize(hostCard.getChosenColor()));
|
||||
input = input.replaceAll("chosenColor", hostCard.getChosenColor().toLowerCase());
|
||||
}
|
||||
|
||||
if (hostCard.hasChosenType()) {
|
||||
input = input.replaceAll("ChosenType", hostCard.getChosenType());
|
||||
}
|
||||
if (hostCard.hasChosenNumber()) {
|
||||
input = input.replaceAll("ChosenNumber", String.valueOf(hostCard.getChosenNumber()));
|
||||
}
|
||||
if (hostCard.hasChosenPlayer()) {
|
||||
Player cp = hostCard.getChosenPlayer();
|
||||
input = input.replaceAll("ChosenPlayerUID", String.valueOf(cp.getId()));
|
||||
input = input.replaceAll("ChosenPlayerName", cp.getName());
|
||||
}
|
||||
if (hostCard.hasNamedCard()) {
|
||||
final String chosenName = hostCard.getNamedCard().replace(",", ";");
|
||||
input = input.replaceAll("ChosenName", "Card.named" + chosenName);
|
||||
}
|
||||
if (hostCard.hasChosenEvenOdd()) {
|
||||
input = input.replaceAll("ChosenEvenOdd", hostCard.getChosenEvenOdd().toString());
|
||||
input = input.replaceAll("chosenEvenOdd", hostCard.getChosenEvenOdd().toString().toLowerCase());
|
||||
}
|
||||
input = input.replace("HostCardUID", hostCardUID);
|
||||
if (params.containsKey("CalcKeywordN")) {
|
||||
input = input.replace("N", String.valueOf(AbilityUtils.calculateAmount(hostCard, params.get("CalcKeywordN"), stAb)));
|
||||
}
|
||||
return input;
|
||||
});
|
||||
|
||||
if (params.containsKey("SharedKeywordsZone")) {
|
||||
@@ -384,60 +373,50 @@ public final class StaticAbilityContinuous {
|
||||
addTypes = Lists.newArrayList(Arrays.asList(params.get("AddType").split(" & ")));
|
||||
List<String> newTypes = Lists.newArrayList();
|
||||
|
||||
Iterables.removeIf(addTypes, new Predicate<String>() {
|
||||
@Override
|
||||
public boolean apply(String input) {
|
||||
if (input.equals("ChosenType") && !hostCard.hasChosenType()) {
|
||||
return true;
|
||||
}
|
||||
if (input.equals("ChosenType2") && !hostCard.hasChosenType2()) {
|
||||
return true;
|
||||
}
|
||||
if (input.equals("ImprintedCreatureType")) {
|
||||
if (hostCard.hasImprintedCard()) {
|
||||
newTypes.addAll(hostCard.getImprintedCards().getLast().getType().getCreatureTypes());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (input.equals("AllBasicLandType")) {
|
||||
newTypes.addAll(CardType.getBasicTypes());
|
||||
return true;
|
||||
}
|
||||
if (input.equals("AllNonBasicLandType")) {
|
||||
newTypes.addAll(CardType.getNonBasicTypes());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
Iterables.removeIf(addTypes, input -> {
|
||||
if (input.equals("ChosenType") && !hostCard.hasChosenType()) {
|
||||
return true;
|
||||
}
|
||||
if (input.equals("ChosenType2") && !hostCard.hasChosenType2()) {
|
||||
return true;
|
||||
}
|
||||
if (input.equals("ImprintedCreatureType")) {
|
||||
if (hostCard.hasImprintedCard()) {
|
||||
newTypes.addAll(hostCard.getImprintedCards().getLast().getType().getCreatureTypes());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (input.equals("AllBasicLandType")) {
|
||||
newTypes.addAll(CardType.getBasicTypes());
|
||||
return true;
|
||||
}
|
||||
if (input.equals("AllNonBasicLandType")) {
|
||||
newTypes.addAll(CardType.getNonBasicTypes());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
addTypes.addAll(newTypes);
|
||||
|
||||
addTypes = Lists.transform(addTypes, new Function<String, String>() {
|
||||
@Override
|
||||
public String apply(String input) {
|
||||
if (hostCard.hasChosenType2()) {
|
||||
input = input.replaceAll("ChosenType2", hostCard.getChosenType2());
|
||||
}
|
||||
if (hostCard.hasChosenType()) {
|
||||
input = input.replaceAll("ChosenType", hostCard.getChosenType());
|
||||
}
|
||||
return input;
|
||||
addTypes = Lists.transform(addTypes, input -> {
|
||||
if (hostCard.hasChosenType2()) {
|
||||
input = input.replaceAll("ChosenType2", hostCard.getChosenType2());
|
||||
}
|
||||
|
||||
if (hostCard.hasChosenType()) {
|
||||
input = input.replaceAll("ChosenType", hostCard.getChosenType());
|
||||
}
|
||||
return input;
|
||||
});
|
||||
}
|
||||
|
||||
if (params.containsKey("RemoveType")) {
|
||||
removeTypes = Lists.newArrayList(Arrays.asList(params.get("RemoveType").split(" & ")));
|
||||
|
||||
Iterables.removeIf(removeTypes, new Predicate<String>() {
|
||||
@Override
|
||||
public boolean apply(String input) {
|
||||
if (input.equals("ChosenType") && !hostCard.hasChosenType()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
Iterables.removeIf(removeTypes, input -> {
|
||||
if (input.equals("ChosenType") && !hostCard.hasChosenType()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
if (params.containsKey("AddAllCreatureTypes")) {
|
||||
@@ -745,37 +724,30 @@ public final class StaticAbilityContinuous {
|
||||
newKeywords = Lists.newArrayList(addKeywords);
|
||||
final List<String> extraKeywords = Lists.newArrayList();
|
||||
|
||||
Iterables.removeIf(newKeywords, new Predicate<String>() {
|
||||
@Override
|
||||
public boolean apply(String input) {
|
||||
if (input.contains("CardManaCost") && affectedCard.getManaCost().isNoCost()) {
|
||||
return true;
|
||||
}
|
||||
// replace one Keyword with list of keywords
|
||||
if (input.startsWith("Protection") && input.contains("CardColors")) {
|
||||
for (Byte color : affectedCard.getColor()) {
|
||||
extraKeywords.add(input.replace("CardColors", MagicColor.toLongString(color)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
Iterables.removeIf(newKeywords, input -> {
|
||||
if (input.contains("CardManaCost") && affectedCard.getManaCost().isNoCost()) {
|
||||
return true;
|
||||
}
|
||||
// replace one Keyword with list of keywords
|
||||
if (input.startsWith("Protection") && input.contains("CardColors")) {
|
||||
for (Byte color : affectedCard.getColor()) {
|
||||
extraKeywords.add(input.replace("CardColors", MagicColor.toLongString(color)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
newKeywords.addAll(extraKeywords);
|
||||
|
||||
newKeywords = Lists.transform(newKeywords, new Function<String, String>() {
|
||||
|
||||
@Override
|
||||
public String apply(String input) {
|
||||
if (input.contains("CardManaCost")) {
|
||||
input = input.replace("CardManaCost", affectedCard.getManaCost().getShortString());
|
||||
} else if (input.contains("ConvertedManaCost")) {
|
||||
final String costcmc = Integer.toString(affectedCard.getCMC());
|
||||
input = input.replace("ConvertedManaCost", costcmc);
|
||||
}
|
||||
return input;
|
||||
newKeywords = Lists.transform(newKeywords, input -> {
|
||||
if (input.contains("CardManaCost")) {
|
||||
input = input.replace("CardManaCost", affectedCard.getManaCost().getShortString());
|
||||
} else if (input.contains("ConvertedManaCost")) {
|
||||
final String costcmc = Integer.toString(affectedCard.getCMC());
|
||||
input = input.replace("ConvertedManaCost", costcmc);
|
||||
}
|
||||
return input;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
}
|
||||
clearUndoStack(Lists.newArrayList(sa));
|
||||
}
|
||||
private final void clearUndoStack(List<SpellAbility> sas) {
|
||||
private void clearUndoStack(List<SpellAbility> sas) {
|
||||
for (SpellAbility sa : sas) {
|
||||
// reset in case a trigger stopped it on a previous activation
|
||||
sa.setUndoable(true);
|
||||
@@ -629,7 +629,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
}
|
||||
}
|
||||
|
||||
private final void finishResolving(final SpellAbility sa, final boolean fizzle) {
|
||||
private void finishResolving(final SpellAbility sa, final boolean fizzle) {
|
||||
// SpellAbility is removed from the stack here
|
||||
// temporarily removed removing SA after resolution
|
||||
final SpellAbilityStackInstance si = getInstanceMatchingSpellAbilityID(sa);
|
||||
@@ -651,7 +651,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
curResolvingCard = null;
|
||||
}
|
||||
|
||||
private final void removeCardFromStack(final SpellAbility sa, final SpellAbilityStackInstance si, final boolean fizzle) {
|
||||
private void removeCardFromStack(final SpellAbility sa, final SpellAbilityStackInstance si, final boolean fizzle) {
|
||||
Card source = sa.getHostCard();
|
||||
|
||||
// need to update active trigger
|
||||
@@ -687,7 +687,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
return hasLegalTargeting(sa.getSubAbility());
|
||||
}
|
||||
|
||||
private final boolean hasFizzled(final SpellAbility sa, final Card source, Boolean fizzle) {
|
||||
private boolean hasFizzled(final SpellAbility sa, final Card source, Boolean fizzle) {
|
||||
List<GameObject> toRemove = Lists.newArrayList();
|
||||
if (sa.usesTargeting() && !sa.isZeroTargets()) {
|
||||
if (fizzle == null) {
|
||||
@@ -842,7 +842,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
return result;
|
||||
}
|
||||
|
||||
private final boolean chooseOrderOfSimultaneousStackEntry(final Player activePlayer, boolean isAbilityTriggered) {
|
||||
private boolean chooseOrderOfSimultaneousStackEntry(final Player activePlayer, boolean isAbilityTriggered) {
|
||||
if (simultaneousStackEntryList.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -41,12 +41,7 @@ public class PlayerZone extends Zone {
|
||||
|
||||
// the this is not the owner of the card
|
||||
private static Predicate<Card> alienCardsActivationFilter(final Player who) {
|
||||
return new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return !c.mayPlay(who).isEmpty() || c.mayPlayerLook(who);
|
||||
}
|
||||
};
|
||||
return c -> !c.mayPlay(who).isEmpty() || c.mayPlayerLook(who);
|
||||
}
|
||||
|
||||
private final class OwnCardsActivationFilter implements Predicate<Card> {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.game.zone;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import forge.util.Localizer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -97,13 +96,4 @@ public enum ZoneType {
|
||||
public static boolean isKnown(final String origin) {
|
||||
return !isHidden(origin);
|
||||
}
|
||||
|
||||
public static class Accessors {
|
||||
public static Function<ZoneType, String> GET_TRANSLATED_NAME = new Function<ZoneType, String>() {
|
||||
@Override
|
||||
public String apply(final ZoneType arg0) {
|
||||
return arg0.getTranslatedName();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user