ChampionAbility - If subtypes parameter is set to null, Champion ability works with all creatures.

This commit is contained in:
LevelX2 2015-07-22 13:31:57 +02:00
parent 929a95a74d
commit 4afcd3be6d

View file

@ -68,24 +68,30 @@ import mage.util.CardUtil;
* the former as the direct result of a champion ability. #
*
*/
public class ChampionAbility extends StaticAbility {
protected String[] subtypes;
protected String objectDescription;
public ChampionAbility(Card card, String subtype) {
this(card, new String[]{subtype});
}
/**
* Champion one or more creature types or if the subtype array is empty
* champion every creature.
*
* @param card
* @param subtypes subtypes to champion with, if empty all creatures can be
* used
*/
public ChampionAbility(Card card, String[] subtypes) {
super(Zone.BATTLEFIELD, null);
this.subtypes = subtypes;
StringBuilder sb = new StringBuilder("another ");
ArrayList<Predicate<MageObject>> subtypesPredicates = new ArrayList<>();
if (subtypes != null) {
int i = 0;
for (String subtype : this.subtypes) {
subtypesPredicates.add(new SubtypePredicate(subtype));
@ -96,9 +102,14 @@ public class ChampionAbility extends StaticAbility {
}
i++;
}
} else {
sb.append("creature");
}
this.objectDescription = sb.toString();
FilterControlledPermanent filter = new FilterControlledPermanent(objectDescription);
if (subtypes != null) {
filter.add(Predicates.or(subtypesPredicates));
}
filter.add(new AnotherPredicate());
// When this permanent enters the battlefield, sacrifice it unless you exile another [object] you control.