mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
ChampionAbility - If subtypes parameter is set to null, Champion ability works with all creatures.
This commit is contained in:
parent
929a95a74d
commit
4afcd3be6d
1 changed files with 28 additions and 17 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue