AbilityUtils: add that getDefinedCards works with extra values using CardLists.getValidCards for filtering

This commit is contained in:
Hanmac
2016-06-28 10:43:01 +00:00
parent 4c98302954
commit 375a8c19b7

View File

@@ -64,8 +64,10 @@ public class AbilityUtils {
// everywhere.
// Probably will move to One function solution sometime in the future
public static CardCollection getDefinedCards(final Card hostCard, final String def, final SpellAbility sa) {
final CardCollection cards = new CardCollection();
final String defined = (def == null) ? "Self" : applyAbilityTextChangeEffects(def, sa); // default to Self
CardCollection cards = new CardCollection();
String defined = (def == null) ? "Self" : applyAbilityTextChangeEffects(def, sa); // default to Self
final String[] incR = defined.split("\\.", 2);
defined = incR[0];
final Game game = hostCard.getGame();
Card c = null;
@@ -282,6 +284,12 @@ public class AbilityUtils {
if (c != null) {
cards.add(c);
}
if (incR.length > 1 && !cards.isEmpty()) {
final String excR = "Card." + incR[1];
cards = CardLists.getValidCards(cards, excR.split(","), hostCard.getController(), hostCard, sa);
}
return cards;
}
@@ -766,6 +774,9 @@ public class AbilityUtils {
return new CardCollection();
}
}
else if (type.startsWith("Imprinted")) {
type = type.replace("Imprinted", "Card");
}
else if (type.equals("Card.AttachedBy")) {
source = source.getEnchantingCard();
type = type.replace("Card.AttachedBy", "Card.Self");